xref: /linux/drivers/gpu/drm/renesas/rcar-du/rcar_du_vsp.h (revision 8c994eff8fcfe8ecb1f1dbebed25b4d7bb75be12)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * R-Car Display Unit VSP-Based Compositor
4  *
5  * Copyright (C) 2015 Renesas Electronics Corporation
6  *
7  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
8  */
9 
10 #ifndef __RCAR_DU_VSP_H__
11 #define __RCAR_DU_VSP_H__
12 
13 #include <drm/drm_plane.h>
14 
15 struct drm_framebuffer;
16 struct rcar_du_format_info;
17 struct rcar_du_vsp;
18 struct sg_table;
19 
20 struct rcar_du_vsp_plane {
21 	struct drm_plane plane;
22 	struct rcar_du_vsp *vsp;
23 	unsigned int index;
24 };
25 
26 struct 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 
34 static 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
43  * @sg_tables: scatter-gather tables for the frame buffer memory
44  */
45 struct rcar_du_vsp_plane_state {
46 	struct drm_plane_state state;
47 
48 	const struct rcar_du_format_info *format;
49 	struct sg_table sg_tables[3];
50 };
51 
52 static inline struct rcar_du_vsp_plane_state *
53 to_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
59 int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
60 		     unsigned int crtcs);
61 void rcar_du_vsp_enable(struct rcar_du_crtc *crtc);
62 void rcar_du_vsp_disable(struct rcar_du_crtc *crtc);
63 void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc);
64 void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc);
65 int rcar_du_vsp_map_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb,
66 		       struct sg_table sg_tables[3]);
67 void rcar_du_vsp_unmap_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb,
68 			  struct sg_table sg_tables[3]);
69 #else
70 static 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 }
76 static inline void rcar_du_vsp_enable(struct rcar_du_crtc *crtc) { };
77 static inline void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { };
78 static inline void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { };
79 static inline void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc) { };
80 static 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 }
86 static 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 }
91 #endif
92 
93 #endif /* __RCAR_DU_VSP_H__ */
94