xref: /OK3568_Linux_fs/kernel/drivers/gpu/drm/rcar-du/rcar_du_vsp.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0+ */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * rcar_du_vsp.h  --  R-Car Display Unit VSP-Based Compositor
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2015 Renesas Electronics Corporation
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
8*4882a593Smuzhiyun  */
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #ifndef __RCAR_DU_VSP_H__
11*4882a593Smuzhiyun #define __RCAR_DU_VSP_H__
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include <drm/drm_plane.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun struct drm_framebuffer;
16*4882a593Smuzhiyun struct rcar_du_format_info;
17*4882a593Smuzhiyun struct rcar_du_vsp;
18*4882a593Smuzhiyun struct sg_table;
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun struct rcar_du_vsp_plane {
21*4882a593Smuzhiyun 	struct drm_plane plane;
22*4882a593Smuzhiyun 	struct rcar_du_vsp *vsp;
23*4882a593Smuzhiyun 	unsigned int index;
24*4882a593Smuzhiyun };
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun struct rcar_du_vsp {
27*4882a593Smuzhiyun 	unsigned int index;
28*4882a593Smuzhiyun 	struct device *vsp;
29*4882a593Smuzhiyun 	struct rcar_du_device *dev;
30*4882a593Smuzhiyun 	struct rcar_du_vsp_plane *planes;
31*4882a593Smuzhiyun 	unsigned int num_planes;
32*4882a593Smuzhiyun };
33*4882a593Smuzhiyun 
to_rcar_vsp_plane(struct drm_plane * p)34*4882a593Smuzhiyun static inline struct rcar_du_vsp_plane *to_rcar_vsp_plane(struct drm_plane *p)
35*4882a593Smuzhiyun {
36*4882a593Smuzhiyun 	return container_of(p, struct rcar_du_vsp_plane, plane);
37*4882a593Smuzhiyun }
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun /**
40*4882a593Smuzhiyun  * struct rcar_du_vsp_plane_state - Driver-specific plane state
41*4882a593Smuzhiyun  * @state: base DRM plane state
42*4882a593Smuzhiyun  * @format: information about the pixel format used by the plane
43*4882a593Smuzhiyun  * @sg_tables: scatter-gather tables for the frame buffer memory
44*4882a593Smuzhiyun  */
45*4882a593Smuzhiyun struct rcar_du_vsp_plane_state {
46*4882a593Smuzhiyun 	struct drm_plane_state state;
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun 	const struct rcar_du_format_info *format;
49*4882a593Smuzhiyun 	struct sg_table sg_tables[3];
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun static inline struct rcar_du_vsp_plane_state *
to_rcar_vsp_plane_state(struct drm_plane_state * state)53*4882a593Smuzhiyun to_rcar_vsp_plane_state(struct drm_plane_state *state)
54*4882a593Smuzhiyun {
55*4882a593Smuzhiyun 	return container_of(state, struct rcar_du_vsp_plane_state, state);
56*4882a593Smuzhiyun }
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun #ifdef CONFIG_DRM_RCAR_VSP
59*4882a593Smuzhiyun int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
60*4882a593Smuzhiyun 		     unsigned int crtcs);
61*4882a593Smuzhiyun void rcar_du_vsp_enable(struct rcar_du_crtc *crtc);
62*4882a593Smuzhiyun void rcar_du_vsp_disable(struct rcar_du_crtc *crtc);
63*4882a593Smuzhiyun void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc);
64*4882a593Smuzhiyun void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc);
65*4882a593Smuzhiyun int rcar_du_vsp_map_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb,
66*4882a593Smuzhiyun 		       struct sg_table sg_tables[3]);
67*4882a593Smuzhiyun void rcar_du_vsp_unmap_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb,
68*4882a593Smuzhiyun 			  struct sg_table sg_tables[3]);
69*4882a593Smuzhiyun #else
rcar_du_vsp_init(struct rcar_du_vsp * vsp,struct device_node * np,unsigned int crtcs)70*4882a593Smuzhiyun static inline int rcar_du_vsp_init(struct rcar_du_vsp *vsp,
71*4882a593Smuzhiyun 				   struct device_node *np,
72*4882a593Smuzhiyun 				   unsigned int crtcs)
73*4882a593Smuzhiyun {
74*4882a593Smuzhiyun 	return -ENXIO;
75*4882a593Smuzhiyun }
rcar_du_vsp_enable(struct rcar_du_crtc * crtc)76*4882a593Smuzhiyun static inline void rcar_du_vsp_enable(struct rcar_du_crtc *crtc) { };
rcar_du_vsp_disable(struct rcar_du_crtc * crtc)77*4882a593Smuzhiyun static inline void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { };
rcar_du_vsp_atomic_begin(struct rcar_du_crtc * crtc)78*4882a593Smuzhiyun static inline void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { };
rcar_du_vsp_atomic_flush(struct rcar_du_crtc * crtc)79*4882a593Smuzhiyun static inline void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc) { };
rcar_du_vsp_map_fb(struct rcar_du_vsp * vsp,struct drm_framebuffer * fb,struct sg_table sg_tables[3])80*4882a593Smuzhiyun static inline int rcar_du_vsp_map_fb(struct rcar_du_vsp *vsp,
81*4882a593Smuzhiyun 				     struct drm_framebuffer *fb,
82*4882a593Smuzhiyun 				     struct sg_table sg_tables[3])
83*4882a593Smuzhiyun {
84*4882a593Smuzhiyun 	return -ENXIO;
85*4882a593Smuzhiyun }
rcar_du_vsp_unmap_fb(struct rcar_du_vsp * vsp,struct drm_framebuffer * fb,struct sg_table sg_tables[3])86*4882a593Smuzhiyun static inline void rcar_du_vsp_unmap_fb(struct rcar_du_vsp *vsp,
87*4882a593Smuzhiyun 					struct drm_framebuffer *fb,
88*4882a593Smuzhiyun 					struct sg_table sg_tables[3])
89*4882a593Smuzhiyun {
90*4882a593Smuzhiyun }
91*4882a593Smuzhiyun #endif
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun #endif /* __RCAR_DU_VSP_H__ */
94