blob: 9b4724159378b7d38a3f79d4a464417eb750c42f [file] [log] [blame]
Kuninori Morimoto0bbce9e2018-07-26 02:37:32 +00001/* SPDX-License-Identifier: GPL-2.0+ */
Laurent Pinchart6d62ef32015-09-07 17:14:58 +03002/*
3 * rcar_du_vsp.h -- R-Car Display Unit VSP-Based Compositor
4 *
5 * Copyright (C) 2015 Renesas Electronics Corporation
6 *
7 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
Laurent Pinchart6d62ef32015-09-07 17:14:58 +03008 */
9
10#ifndef __RCAR_DU_VSP_H__
11#define __RCAR_DU_VSP_H__
12
Laurent Pinchart9a47db82018-12-27 11:26:56 +020013#include <drm/drm_plane.h>
Laurent Pinchart6d62ef32015-09-07 17:14:58 +030014
Laurent Pinchartd46a4e92019-02-21 03:20:42 +020015struct drm_framebuffer;
Laurent Pinchart6d62ef32015-09-07 17:14:58 +030016struct rcar_du_format_info;
17struct rcar_du_vsp;
Laurent Pinchartd46a4e92019-02-21 03:20:42 +020018struct sg_table;
Laurent Pinchart6d62ef32015-09-07 17:14:58 +030019
20struct rcar_du_vsp_plane {
21 struct drm_plane plane;
22 struct rcar_du_vsp *vsp;
23 unsigned int index;
24};
25
26struct rcar_du_vsp {
27 unsigned int index;
28 struct device *vsp;
29 struct rcar_du_device *dev;
30 struct rcar_du_vsp_plane *planes;
31 unsigned int num_planes;
32};
33
34static inline struct rcar_du_vsp_plane *to_rcar_vsp_plane(struct drm_plane *p)
35{
36 return container_of(p, struct rcar_du_vsp_plane, plane);
37}
38
39/**
40 * struct rcar_du_vsp_plane_state - Driver-specific plane state
41 * @state: base DRM plane state
42 * @format: information about the pixel format used by the plane
Laurent Pinchartfa5b4112017-05-17 02:20:07 +030043 * @sg_tables: scatter-gather tables for the frame buffer memory
Laurent Pinchart6d62ef32015-09-07 17:14:58 +030044 */
45struct rcar_du_vsp_plane_state {
46 struct drm_plane_state state;
47
48 const struct rcar_du_format_info *format;
Laurent Pinchartfa5b4112017-05-17 02:20:07 +030049 struct sg_table sg_tables[3];
Laurent Pinchart6d62ef32015-09-07 17:14:58 +030050};
51
52static inline struct rcar_du_vsp_plane_state *
53to_rcar_vsp_plane_state(struct drm_plane_state *state)
54{
55 return container_of(state, struct rcar_du_vsp_plane_state, state);
56}
57
58#ifdef CONFIG_DRM_RCAR_VSP
Laurent Pinchart3e813742017-06-26 13:12:01 +030059int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
60 unsigned int crtcs);
Laurent Pinchart6d62ef32015-09-07 17:14:58 +030061void rcar_du_vsp_enable(struct rcar_du_crtc *crtc);
62void rcar_du_vsp_disable(struct rcar_du_crtc *crtc);
63void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc);
64void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc);
Laurent Pinchartd46a4e92019-02-21 03:20:42 +020065int rcar_du_vsp_map_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb,
66 struct sg_table sg_tables[3]);
67void rcar_du_vsp_unmap_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb,
68 struct sg_table sg_tables[3]);
Laurent Pinchart6d62ef32015-09-07 17:14:58 +030069#else
Laurent Pinchart3e813742017-06-26 13:12:01 +030070static inline int rcar_du_vsp_init(struct rcar_du_vsp *vsp,
71 struct device_node *np,
72 unsigned int crtcs)
73{
74 return -ENXIO;
75}
Laurent Pinchart6d62ef32015-09-07 17:14:58 +030076static inline void rcar_du_vsp_enable(struct rcar_du_crtc *crtc) { };
77static inline void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { };
78static inline void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { };
79static inline void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc) { };
Laurent Pinchartd46a4e92019-02-21 03:20:42 +020080static inline int rcar_du_vsp_map_fb(struct rcar_du_vsp *vsp,
81 struct drm_framebuffer *fb,
82 struct sg_table sg_tables[3])
83{
84 return -ENXIO;
85}
86static inline void rcar_du_vsp_unmap_fb(struct rcar_du_vsp *vsp,
87 struct drm_framebuffer *fb,
88 struct sg_table sg_tables[3])
89{
90}
Laurent Pinchart6d62ef32015-09-07 17:14:58 +030091#endif
92
93#endif /* __RCAR_DU_VSP_H__ */