Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / mediatek / mtk_drm_ddp_comp.h
blob5aa52b7afeecbed8b3abe0d7d741c5bbde2fb684
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (c) 2015 MediaTek Inc.
4 */
6 #ifndef MTK_DRM_DDP_COMP_H
7 #define MTK_DRM_DDP_COMP_H
9 #include <linux/io.h>
10 #include <linux/soc/mediatek/mtk-mmsys.h>
12 struct device;
13 struct device_node;
14 struct drm_crtc;
15 struct drm_device;
16 struct mtk_plane_state;
17 struct drm_crtc_state;
19 enum mtk_ddp_comp_type {
20 MTK_DISP_OVL,
21 MTK_DISP_OVL_2L,
22 MTK_DISP_RDMA,
23 MTK_DISP_WDMA,
24 MTK_DISP_COLOR,
25 MTK_DISP_CCORR,
26 MTK_DISP_DITHER,
27 MTK_DISP_AAL,
28 MTK_DISP_GAMMA,
29 MTK_DISP_UFOE,
30 MTK_DSI,
31 MTK_DPI,
32 MTK_DISP_PWM,
33 MTK_DISP_MUTEX,
34 MTK_DISP_OD,
35 MTK_DISP_BLS,
36 MTK_DDP_COMP_TYPE_MAX,
39 struct mtk_ddp_comp;
40 struct cmdq_pkt;
41 struct mtk_ddp_comp_funcs {
42 void (*config)(struct mtk_ddp_comp *comp, unsigned int w,
43 unsigned int h, unsigned int vrefresh,
44 unsigned int bpc, struct cmdq_pkt *cmdq_pkt);
45 void (*start)(struct mtk_ddp_comp *comp);
46 void (*stop)(struct mtk_ddp_comp *comp);
47 void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc);
48 void (*disable_vblank)(struct mtk_ddp_comp *comp);
49 unsigned int (*supported_rotations)(struct mtk_ddp_comp *comp);
50 unsigned int (*layer_nr)(struct mtk_ddp_comp *comp);
51 int (*layer_check)(struct mtk_ddp_comp *comp,
52 unsigned int idx,
53 struct mtk_plane_state *state);
54 void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx,
55 struct mtk_plane_state *state,
56 struct cmdq_pkt *cmdq_pkt);
57 void (*gamma_set)(struct mtk_ddp_comp *comp,
58 struct drm_crtc_state *state);
59 void (*bgclr_in_on)(struct mtk_ddp_comp *comp);
60 void (*bgclr_in_off)(struct mtk_ddp_comp *comp);
61 void (*ctm_set)(struct mtk_ddp_comp *comp,
62 struct drm_crtc_state *state);
65 struct mtk_ddp_comp {
66 struct clk *clk;
67 void __iomem *regs;
68 int irq;
69 struct device *larb_dev;
70 enum mtk_ddp_comp_id id;
71 const struct mtk_ddp_comp_funcs *funcs;
72 resource_size_t regs_pa;
73 u8 subsys;
76 static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp,
77 unsigned int w, unsigned int h,
78 unsigned int vrefresh, unsigned int bpc,
79 struct cmdq_pkt *cmdq_pkt)
81 if (comp->funcs && comp->funcs->config)
82 comp->funcs->config(comp, w, h, vrefresh, bpc, cmdq_pkt);
85 static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp)
87 if (comp->funcs && comp->funcs->start)
88 comp->funcs->start(comp);
91 static inline void mtk_ddp_comp_stop(struct mtk_ddp_comp *comp)
93 if (comp->funcs && comp->funcs->stop)
94 comp->funcs->stop(comp);
97 static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp *comp,
98 struct drm_crtc *crtc)
100 if (comp->funcs && comp->funcs->enable_vblank)
101 comp->funcs->enable_vblank(comp, crtc);
104 static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp)
106 if (comp->funcs && comp->funcs->disable_vblank)
107 comp->funcs->disable_vblank(comp);
110 static inline
111 unsigned int mtk_ddp_comp_supported_rotations(struct mtk_ddp_comp *comp)
113 if (comp->funcs && comp->funcs->supported_rotations)
114 return comp->funcs->supported_rotations(comp);
116 return 0;
119 static inline unsigned int mtk_ddp_comp_layer_nr(struct mtk_ddp_comp *comp)
121 if (comp->funcs && comp->funcs->layer_nr)
122 return comp->funcs->layer_nr(comp);
124 return 0;
127 static inline int mtk_ddp_comp_layer_check(struct mtk_ddp_comp *comp,
128 unsigned int idx,
129 struct mtk_plane_state *state)
131 if (comp->funcs && comp->funcs->layer_check)
132 return comp->funcs->layer_check(comp, idx, state);
133 return 0;
136 static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp,
137 unsigned int idx,
138 struct mtk_plane_state *state,
139 struct cmdq_pkt *cmdq_pkt)
141 if (comp->funcs && comp->funcs->layer_config)
142 comp->funcs->layer_config(comp, idx, state, cmdq_pkt);
145 static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp *comp,
146 struct drm_crtc_state *state)
148 if (comp->funcs && comp->funcs->gamma_set)
149 comp->funcs->gamma_set(comp, state);
152 static inline void mtk_ddp_comp_bgclr_in_on(struct mtk_ddp_comp *comp)
154 if (comp->funcs && comp->funcs->bgclr_in_on)
155 comp->funcs->bgclr_in_on(comp);
158 static inline void mtk_ddp_comp_bgclr_in_off(struct mtk_ddp_comp *comp)
160 if (comp->funcs && comp->funcs->bgclr_in_off)
161 comp->funcs->bgclr_in_off(comp);
164 static inline void mtk_ddp_ctm_set(struct mtk_ddp_comp *comp,
165 struct drm_crtc_state *state)
167 if (comp->funcs && comp->funcs->ctm_set)
168 comp->funcs->ctm_set(comp, state);
171 int mtk_ddp_comp_get_id(struct device_node *node,
172 enum mtk_ddp_comp_type comp_type);
173 unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
174 struct mtk_ddp_comp ddp_comp);
175 int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node,
176 struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id,
177 const struct mtk_ddp_comp_funcs *funcs);
178 int mtk_ddp_comp_register(struct drm_device *drm, struct mtk_ddp_comp *comp);
179 void mtk_ddp_comp_unregister(struct drm_device *drm, struct mtk_ddp_comp *comp);
180 void mtk_dither_set(struct mtk_ddp_comp *comp, unsigned int bpc,
181 unsigned int CFG, struct cmdq_pkt *cmdq_pkt);
182 enum mtk_ddp_comp_type mtk_ddp_comp_get_type(enum mtk_ddp_comp_id comp_id);
183 void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value,
184 struct mtk_ddp_comp *comp, unsigned int offset);
185 void mtk_ddp_write_relaxed(struct cmdq_pkt *cmdq_pkt, unsigned int value,
186 struct mtk_ddp_comp *comp, unsigned int offset);
187 void mtk_ddp_write_mask(struct cmdq_pkt *cmdq_pkt, unsigned int value,
188 struct mtk_ddp_comp *comp, unsigned int offset,
189 unsigned int mask);
190 #endif /* MTK_DRM_DDP_COMP_H */