]> Git Repo - J-linux.git/blob - drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
Merge tag 'input-for-v6.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor...
[J-linux.git] / drivers / gpu / drm / mediatek / mtk_drm_ddp_comp.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2015 MediaTek Inc.
4  */
5
6 #ifndef MTK_DRM_DDP_COMP_H
7 #define MTK_DRM_DDP_COMP_H
8
9 #include <linux/io.h>
10 #include <linux/soc/mediatek/mtk-cmdq.h>
11 #include <linux/soc/mediatek/mtk-mmsys.h>
12 #include <linux/soc/mediatek/mtk-mutex.h>
13
14 struct device;
15 struct device_node;
16 struct drm_crtc;
17 struct drm_device;
18 struct mtk_plane_state;
19 struct drm_crtc_state;
20
21 enum mtk_ddp_comp_type {
22         MTK_DISP_AAL,
23         MTK_DISP_BLS,
24         MTK_DISP_CCORR,
25         MTK_DISP_COLOR,
26         MTK_DISP_DITHER,
27         MTK_DISP_DSC,
28         MTK_DISP_GAMMA,
29         MTK_DISP_MERGE,
30         MTK_DISP_MUTEX,
31         MTK_DISP_OD,
32         MTK_DISP_OVL,
33         MTK_DISP_OVL_2L,
34         MTK_DISP_OVL_ADAPTOR,
35         MTK_DISP_POSTMASK,
36         MTK_DISP_PWM,
37         MTK_DISP_RDMA,
38         MTK_DISP_UFOE,
39         MTK_DISP_WDMA,
40         MTK_DPI,
41         MTK_DP_INTF,
42         MTK_DSI,
43         MTK_DDP_COMP_TYPE_MAX,
44 };
45
46 struct mtk_ddp_comp;
47 struct cmdq_pkt;
48 struct mtk_ddp_comp_funcs {
49         int (*clk_enable)(struct device *dev);
50         void (*clk_disable)(struct device *dev);
51         void (*config)(struct device *dev, unsigned int w,
52                        unsigned int h, unsigned int vrefresh,
53                        unsigned int bpc, struct cmdq_pkt *cmdq_pkt);
54         void (*start)(struct device *dev);
55         void (*stop)(struct device *dev);
56         void (*register_vblank_cb)(struct device *dev,
57                                    void (*vblank_cb)(void *),
58                                    void *vblank_cb_data);
59         void (*unregister_vblank_cb)(struct device *dev);
60         void (*enable_vblank)(struct device *dev);
61         void (*disable_vblank)(struct device *dev);
62         unsigned int (*supported_rotations)(struct device *dev);
63         unsigned int (*layer_nr)(struct device *dev);
64         int (*layer_check)(struct device *dev,
65                            unsigned int idx,
66                            struct mtk_plane_state *state);
67         void (*layer_config)(struct device *dev, unsigned int idx,
68                              struct mtk_plane_state *state,
69                              struct cmdq_pkt *cmdq_pkt);
70         unsigned int (*gamma_get_lut_size)(struct device *dev);
71         void (*gamma_set)(struct device *dev,
72                           struct drm_crtc_state *state);
73         void (*bgclr_in_on)(struct device *dev);
74         void (*bgclr_in_off)(struct device *dev);
75         void (*ctm_set)(struct device *dev,
76                         struct drm_crtc_state *state);
77         struct device * (*dma_dev_get)(struct device *dev);
78         const u32 *(*get_formats)(struct device *dev);
79         size_t (*get_num_formats)(struct device *dev);
80         void (*connect)(struct device *dev, struct device *mmsys_dev, unsigned int next);
81         void (*disconnect)(struct device *dev, struct device *mmsys_dev, unsigned int next);
82         void (*add)(struct device *dev, struct mtk_mutex *mutex);
83         void (*remove)(struct device *dev, struct mtk_mutex *mutex);
84         unsigned int (*encoder_index)(struct device *dev);
85 };
86
87 struct mtk_ddp_comp {
88         struct device *dev;
89         int irq;
90         unsigned int id;
91         int encoder_index;
92         const struct mtk_ddp_comp_funcs *funcs;
93 };
94
95 static inline int mtk_ddp_comp_clk_enable(struct mtk_ddp_comp *comp)
96 {
97         if (comp->funcs && comp->funcs->clk_enable)
98                 return comp->funcs->clk_enable(comp->dev);
99
100         return 0;
101 }
102
103 static inline void mtk_ddp_comp_clk_disable(struct mtk_ddp_comp *comp)
104 {
105         if (comp->funcs && comp->funcs->clk_disable)
106                 comp->funcs->clk_disable(comp->dev);
107 }
108
109 static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp,
110                                        unsigned int w, unsigned int h,
111                                        unsigned int vrefresh, unsigned int bpc,
112                                        struct cmdq_pkt *cmdq_pkt)
113 {
114         if (comp->funcs && comp->funcs->config)
115                 comp->funcs->config(comp->dev, w, h, vrefresh, bpc, cmdq_pkt);
116 }
117
118 static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp)
119 {
120         if (comp->funcs && comp->funcs->start)
121                 comp->funcs->start(comp->dev);
122 }
123
124 static inline void mtk_ddp_comp_stop(struct mtk_ddp_comp *comp)
125 {
126         if (comp->funcs && comp->funcs->stop)
127                 comp->funcs->stop(comp->dev);
128 }
129
130 static inline void mtk_ddp_comp_register_vblank_cb(struct mtk_ddp_comp *comp,
131                                                    void (*vblank_cb)(void *),
132                                                    void *vblank_cb_data)
133 {
134         if (comp->funcs && comp->funcs->register_vblank_cb)
135                 comp->funcs->register_vblank_cb(comp->dev, vblank_cb,
136                                                 vblank_cb_data);
137 }
138
139 static inline void mtk_ddp_comp_unregister_vblank_cb(struct mtk_ddp_comp *comp)
140 {
141         if (comp->funcs && comp->funcs->unregister_vblank_cb)
142                 comp->funcs->unregister_vblank_cb(comp->dev);
143 }
144
145 static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp *comp)
146 {
147         if (comp->funcs && comp->funcs->enable_vblank)
148                 comp->funcs->enable_vblank(comp->dev);
149 }
150
151 static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp)
152 {
153         if (comp->funcs && comp->funcs->disable_vblank)
154                 comp->funcs->disable_vblank(comp->dev);
155 }
156
157 static inline
158 unsigned int mtk_ddp_comp_supported_rotations(struct mtk_ddp_comp *comp)
159 {
160         if (comp->funcs && comp->funcs->supported_rotations)
161                 return comp->funcs->supported_rotations(comp->dev);
162
163         return 0;
164 }
165
166 static inline unsigned int mtk_ddp_comp_layer_nr(struct mtk_ddp_comp *comp)
167 {
168         if (comp->funcs && comp->funcs->layer_nr)
169                 return comp->funcs->layer_nr(comp->dev);
170
171         return 0;
172 }
173
174 static inline int mtk_ddp_comp_layer_check(struct mtk_ddp_comp *comp,
175                                            unsigned int idx,
176                                            struct mtk_plane_state *state)
177 {
178         if (comp->funcs && comp->funcs->layer_check)
179                 return comp->funcs->layer_check(comp->dev, idx, state);
180         return 0;
181 }
182
183 static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp,
184                                              unsigned int idx,
185                                              struct mtk_plane_state *state,
186                                              struct cmdq_pkt *cmdq_pkt)
187 {
188         if (comp->funcs && comp->funcs->layer_config)
189                 comp->funcs->layer_config(comp->dev, idx, state, cmdq_pkt);
190 }
191
192 static inline unsigned int mtk_ddp_gamma_get_lut_size(struct mtk_ddp_comp *comp)
193 {
194         if (comp->funcs && comp->funcs->gamma_get_lut_size)
195                 return comp->funcs->gamma_get_lut_size(comp->dev);
196
197         return 0;
198 }
199
200 static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp *comp,
201                                      struct drm_crtc_state *state)
202 {
203         if (comp->funcs && comp->funcs->gamma_set)
204                 comp->funcs->gamma_set(comp->dev, state);
205 }
206
207 static inline void mtk_ddp_comp_bgclr_in_on(struct mtk_ddp_comp *comp)
208 {
209         if (comp->funcs && comp->funcs->bgclr_in_on)
210                 comp->funcs->bgclr_in_on(comp->dev);
211 }
212
213 static inline void mtk_ddp_comp_bgclr_in_off(struct mtk_ddp_comp *comp)
214 {
215         if (comp->funcs && comp->funcs->bgclr_in_off)
216                 comp->funcs->bgclr_in_off(comp->dev);
217 }
218
219 static inline void mtk_ddp_ctm_set(struct mtk_ddp_comp *comp,
220                                    struct drm_crtc_state *state)
221 {
222         if (comp->funcs && comp->funcs->ctm_set)
223                 comp->funcs->ctm_set(comp->dev, state);
224 }
225
226 static inline struct device *mtk_ddp_comp_dma_dev_get(struct mtk_ddp_comp *comp)
227 {
228         if (comp->funcs && comp->funcs->dma_dev_get)
229                 return comp->funcs->dma_dev_get(comp->dev);
230         return comp->dev;
231 }
232
233 static inline
234 const u32 *mtk_ddp_comp_get_formats(struct mtk_ddp_comp *comp)
235 {
236         if (comp->funcs && comp->funcs->get_formats)
237                 return comp->funcs->get_formats(comp->dev);
238
239         return NULL;
240 }
241
242 static inline
243 size_t mtk_ddp_comp_get_num_formats(struct mtk_ddp_comp *comp)
244 {
245         if (comp->funcs && comp->funcs->get_num_formats)
246                 return comp->funcs->get_num_formats(comp->dev);
247
248         return 0;
249 }
250
251 static inline bool mtk_ddp_comp_add(struct mtk_ddp_comp *comp, struct mtk_mutex *mutex)
252 {
253         if (comp->funcs && comp->funcs->add) {
254                 comp->funcs->add(comp->dev, mutex);
255                 return true;
256         }
257         return false;
258 }
259
260 static inline bool mtk_ddp_comp_remove(struct mtk_ddp_comp *comp, struct mtk_mutex *mutex)
261 {
262         if (comp->funcs && comp->funcs->remove) {
263                 comp->funcs->remove(comp->dev, mutex);
264                 return true;
265         }
266         return false;
267 }
268
269 static inline bool mtk_ddp_comp_connect(struct mtk_ddp_comp *comp, struct device *mmsys_dev,
270                                         unsigned int next)
271 {
272         if (comp->funcs && comp->funcs->connect) {
273                 comp->funcs->connect(comp->dev, mmsys_dev, next);
274                 return true;
275         }
276         return false;
277 }
278
279 static inline bool mtk_ddp_comp_disconnect(struct mtk_ddp_comp *comp, struct device *mmsys_dev,
280                                            unsigned int next)
281 {
282         if (comp->funcs && comp->funcs->disconnect) {
283                 comp->funcs->disconnect(comp->dev, mmsys_dev, next);
284                 return true;
285         }
286         return false;
287 }
288
289 static inline void mtk_ddp_comp_encoder_index_set(struct mtk_ddp_comp *comp)
290 {
291         if (comp->funcs && comp->funcs->encoder_index)
292                 comp->encoder_index = (int)comp->funcs->encoder_index(comp->dev);
293 }
294
295 int mtk_ddp_comp_get_id(struct device_node *node,
296                         enum mtk_ddp_comp_type comp_type);
297 unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
298                                                 struct device *dev);
299 int mtk_ddp_comp_init(struct device_node *comp_node, struct mtk_ddp_comp *comp,
300                       unsigned int comp_id);
301 enum mtk_ddp_comp_type mtk_ddp_comp_get_type(unsigned int comp_id);
302 void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value,
303                    struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
304                    unsigned int offset);
305 void mtk_ddp_write_relaxed(struct cmdq_pkt *cmdq_pkt, unsigned int value,
306                            struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
307                            unsigned int offset);
308 void mtk_ddp_write_mask(struct cmdq_pkt *cmdq_pkt, unsigned int value,
309                         struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
310                         unsigned int offset, unsigned int mask);
311 #endif /* MTK_DRM_DDP_COMP_H */
This page took 0.045498 seconds and 4 git commands to generate.