1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2015 MediaTek Inc.
6 #ifndef MTK_DRM_DDP_COMP_H
7 #define MTK_DRM_DDP_COMP_H
15 struct mtk_plane_state
;
16 struct drm_crtc_state
;
18 enum mtk_ddp_comp_type
{
35 MTK_DDP_COMP_TYPE_MAX
,
38 enum mtk_ddp_comp_id
{
56 DDP_COMPONENT_OVL_2L0
,
57 DDP_COMPONENT_OVL_2L1
,
73 struct mtk_ddp_comp_funcs
{
74 void (*config
)(struct mtk_ddp_comp
*comp
, unsigned int w
,
75 unsigned int h
, unsigned int vrefresh
,
76 unsigned int bpc
, struct cmdq_pkt
*cmdq_pkt
);
77 void (*start
)(struct mtk_ddp_comp
*comp
);
78 void (*stop
)(struct mtk_ddp_comp
*comp
);
79 void (*enable_vblank
)(struct mtk_ddp_comp
*comp
, struct drm_crtc
*crtc
);
80 void (*disable_vblank
)(struct mtk_ddp_comp
*comp
);
81 unsigned int (*supported_rotations
)(struct mtk_ddp_comp
*comp
);
82 unsigned int (*layer_nr
)(struct mtk_ddp_comp
*comp
);
83 int (*layer_check
)(struct mtk_ddp_comp
*comp
,
85 struct mtk_plane_state
*state
);
86 void (*layer_config
)(struct mtk_ddp_comp
*comp
, unsigned int idx
,
87 struct mtk_plane_state
*state
,
88 struct cmdq_pkt
*cmdq_pkt
);
89 void (*gamma_set
)(struct mtk_ddp_comp
*comp
,
90 struct drm_crtc_state
*state
);
91 void (*bgclr_in_on
)(struct mtk_ddp_comp
*comp
);
92 void (*bgclr_in_off
)(struct mtk_ddp_comp
*comp
);
93 void (*ctm_set
)(struct mtk_ddp_comp
*comp
,
94 struct drm_crtc_state
*state
);
101 struct device
*larb_dev
;
102 enum mtk_ddp_comp_id id
;
103 const struct mtk_ddp_comp_funcs
*funcs
;
104 resource_size_t regs_pa
;
108 static inline void mtk_ddp_comp_config(struct mtk_ddp_comp
*comp
,
109 unsigned int w
, unsigned int h
,
110 unsigned int vrefresh
, unsigned int bpc
,
111 struct cmdq_pkt
*cmdq_pkt
)
113 if (comp
->funcs
&& comp
->funcs
->config
)
114 comp
->funcs
->config(comp
, w
, h
, vrefresh
, bpc
, cmdq_pkt
);
117 static inline void mtk_ddp_comp_start(struct mtk_ddp_comp
*comp
)
119 if (comp
->funcs
&& comp
->funcs
->start
)
120 comp
->funcs
->start(comp
);
123 static inline void mtk_ddp_comp_stop(struct mtk_ddp_comp
*comp
)
125 if (comp
->funcs
&& comp
->funcs
->stop
)
126 comp
->funcs
->stop(comp
);
129 static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp
*comp
,
130 struct drm_crtc
*crtc
)
132 if (comp
->funcs
&& comp
->funcs
->enable_vblank
)
133 comp
->funcs
->enable_vblank(comp
, crtc
);
136 static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp
*comp
)
138 if (comp
->funcs
&& comp
->funcs
->disable_vblank
)
139 comp
->funcs
->disable_vblank(comp
);
143 unsigned int mtk_ddp_comp_supported_rotations(struct mtk_ddp_comp
*comp
)
145 if (comp
->funcs
&& comp
->funcs
->supported_rotations
)
146 return comp
->funcs
->supported_rotations(comp
);
151 static inline unsigned int mtk_ddp_comp_layer_nr(struct mtk_ddp_comp
*comp
)
153 if (comp
->funcs
&& comp
->funcs
->layer_nr
)
154 return comp
->funcs
->layer_nr(comp
);
159 static inline int mtk_ddp_comp_layer_check(struct mtk_ddp_comp
*comp
,
161 struct mtk_plane_state
*state
)
163 if (comp
->funcs
&& comp
->funcs
->layer_check
)
164 return comp
->funcs
->layer_check(comp
, idx
, state
);
168 static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp
*comp
,
170 struct mtk_plane_state
*state
,
171 struct cmdq_pkt
*cmdq_pkt
)
173 if (comp
->funcs
&& comp
->funcs
->layer_config
)
174 comp
->funcs
->layer_config(comp
, idx
, state
, cmdq_pkt
);
177 static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp
*comp
,
178 struct drm_crtc_state
*state
)
180 if (comp
->funcs
&& comp
->funcs
->gamma_set
)
181 comp
->funcs
->gamma_set(comp
, state
);
184 static inline void mtk_ddp_comp_bgclr_in_on(struct mtk_ddp_comp
*comp
)
186 if (comp
->funcs
&& comp
->funcs
->bgclr_in_on
)
187 comp
->funcs
->bgclr_in_on(comp
);
190 static inline void mtk_ddp_comp_bgclr_in_off(struct mtk_ddp_comp
*comp
)
192 if (comp
->funcs
&& comp
->funcs
->bgclr_in_off
)
193 comp
->funcs
->bgclr_in_off(comp
);
196 static inline void mtk_ddp_ctm_set(struct mtk_ddp_comp
*comp
,
197 struct drm_crtc_state
*state
)
199 if (comp
->funcs
&& comp
->funcs
->ctm_set
)
200 comp
->funcs
->ctm_set(comp
, state
);
203 int mtk_ddp_comp_get_id(struct device_node
*node
,
204 enum mtk_ddp_comp_type comp_type
);
205 int mtk_ddp_comp_init(struct device
*dev
, struct device_node
*comp_node
,
206 struct mtk_ddp_comp
*comp
, enum mtk_ddp_comp_id comp_id
,
207 const struct mtk_ddp_comp_funcs
*funcs
);
208 int mtk_ddp_comp_register(struct drm_device
*drm
, struct mtk_ddp_comp
*comp
);
209 void mtk_ddp_comp_unregister(struct drm_device
*drm
, struct mtk_ddp_comp
*comp
);
210 void mtk_dither_set(struct mtk_ddp_comp
*comp
, unsigned int bpc
,
211 unsigned int CFG
, struct cmdq_pkt
*cmdq_pkt
);
212 enum mtk_ddp_comp_type
mtk_ddp_comp_get_type(enum mtk_ddp_comp_id comp_id
);
213 void mtk_ddp_write(struct cmdq_pkt
*cmdq_pkt
, unsigned int value
,
214 struct mtk_ddp_comp
*comp
, unsigned int offset
);
215 void mtk_ddp_write_relaxed(struct cmdq_pkt
*cmdq_pkt
, unsigned int value
,
216 struct mtk_ddp_comp
*comp
, unsigned int offset
);
217 void mtk_ddp_write_mask(struct cmdq_pkt
*cmdq_pkt
, unsigned int value
,
218 struct mtk_ddp_comp
*comp
, unsigned int offset
,
220 #endif /* MTK_DRM_DDP_COMP_H */