Loading...
Note: File does not exist in v4.6.
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
13struct device;
14struct device_node;
15struct drm_crtc;
16struct drm_device;
17struct mtk_plane_state;
18struct drm_crtc_state;
19
20enum mtk_ddp_comp_type {
21 MTK_DISP_AAL,
22 MTK_DISP_BLS,
23 MTK_DISP_CCORR,
24 MTK_DISP_COLOR,
25 MTK_DISP_DITHER,
26 MTK_DISP_DSC,
27 MTK_DISP_GAMMA,
28 MTK_DISP_MERGE,
29 MTK_DISP_MUTEX,
30 MTK_DISP_OD,
31 MTK_DISP_OVL,
32 MTK_DISP_OVL_2L,
33 MTK_DISP_POSTMASK,
34 MTK_DISP_PWM,
35 MTK_DISP_RDMA,
36 MTK_DISP_UFOE,
37 MTK_DISP_WDMA,
38 MTK_DPI,
39 MTK_DP_INTF,
40 MTK_DSI,
41 MTK_DDP_COMP_TYPE_MAX,
42};
43
44struct mtk_ddp_comp;
45struct cmdq_pkt;
46struct mtk_ddp_comp_funcs {
47 int (*clk_enable)(struct device *dev);
48 void (*clk_disable)(struct device *dev);
49 void (*config)(struct device *dev, unsigned int w,
50 unsigned int h, unsigned int vrefresh,
51 unsigned int bpc, struct cmdq_pkt *cmdq_pkt);
52 void (*start)(struct device *dev);
53 void (*stop)(struct device *dev);
54 void (*register_vblank_cb)(struct device *dev,
55 void (*vblank_cb)(void *),
56 void *vblank_cb_data);
57 void (*unregister_vblank_cb)(struct device *dev);
58 void (*enable_vblank)(struct device *dev);
59 void (*disable_vblank)(struct device *dev);
60 unsigned int (*supported_rotations)(struct device *dev);
61 unsigned int (*layer_nr)(struct device *dev);
62 int (*layer_check)(struct device *dev,
63 unsigned int idx,
64 struct mtk_plane_state *state);
65 void (*layer_config)(struct device *dev, unsigned int idx,
66 struct mtk_plane_state *state,
67 struct cmdq_pkt *cmdq_pkt);
68 void (*gamma_set)(struct device *dev,
69 struct drm_crtc_state *state);
70 void (*bgclr_in_on)(struct device *dev);
71 void (*bgclr_in_off)(struct device *dev);
72 void (*ctm_set)(struct device *dev,
73 struct drm_crtc_state *state);
74};
75
76struct mtk_ddp_comp {
77 struct device *dev;
78 int irq;
79 enum mtk_ddp_comp_id id;
80 const struct mtk_ddp_comp_funcs *funcs;
81};
82
83static inline int mtk_ddp_comp_clk_enable(struct mtk_ddp_comp *comp)
84{
85 if (comp->funcs && comp->funcs->clk_enable)
86 return comp->funcs->clk_enable(comp->dev);
87
88 return 0;
89}
90
91static inline void mtk_ddp_comp_clk_disable(struct mtk_ddp_comp *comp)
92{
93 if (comp->funcs && comp->funcs->clk_disable)
94 comp->funcs->clk_disable(comp->dev);
95}
96
97static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp,
98 unsigned int w, unsigned int h,
99 unsigned int vrefresh, unsigned int bpc,
100 struct cmdq_pkt *cmdq_pkt)
101{
102 if (comp->funcs && comp->funcs->config)
103 comp->funcs->config(comp->dev, w, h, vrefresh, bpc, cmdq_pkt);
104}
105
106static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp)
107{
108 if (comp->funcs && comp->funcs->start)
109 comp->funcs->start(comp->dev);
110}
111
112static inline void mtk_ddp_comp_stop(struct mtk_ddp_comp *comp)
113{
114 if (comp->funcs && comp->funcs->stop)
115 comp->funcs->stop(comp->dev);
116}
117
118static inline void mtk_ddp_comp_register_vblank_cb(struct mtk_ddp_comp *comp,
119 void (*vblank_cb)(void *),
120 void *vblank_cb_data)
121{
122 if (comp->funcs && comp->funcs->register_vblank_cb)
123 comp->funcs->register_vblank_cb(comp->dev, vblank_cb,
124 vblank_cb_data);
125}
126
127static inline void mtk_ddp_comp_unregister_vblank_cb(struct mtk_ddp_comp *comp)
128{
129 if (comp->funcs && comp->funcs->unregister_vblank_cb)
130 comp->funcs->unregister_vblank_cb(comp->dev);
131}
132
133static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp *comp)
134{
135 if (comp->funcs && comp->funcs->enable_vblank)
136 comp->funcs->enable_vblank(comp->dev);
137}
138
139static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp)
140{
141 if (comp->funcs && comp->funcs->disable_vblank)
142 comp->funcs->disable_vblank(comp->dev);
143}
144
145static inline
146unsigned int mtk_ddp_comp_supported_rotations(struct mtk_ddp_comp *comp)
147{
148 if (comp->funcs && comp->funcs->supported_rotations)
149 return comp->funcs->supported_rotations(comp->dev);
150
151 return 0;
152}
153
154static inline unsigned int mtk_ddp_comp_layer_nr(struct mtk_ddp_comp *comp)
155{
156 if (comp->funcs && comp->funcs->layer_nr)
157 return comp->funcs->layer_nr(comp->dev);
158
159 return 0;
160}
161
162static inline int mtk_ddp_comp_layer_check(struct mtk_ddp_comp *comp,
163 unsigned int idx,
164 struct mtk_plane_state *state)
165{
166 if (comp->funcs && comp->funcs->layer_check)
167 return comp->funcs->layer_check(comp->dev, idx, state);
168 return 0;
169}
170
171static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp,
172 unsigned int idx,
173 struct mtk_plane_state *state,
174 struct cmdq_pkt *cmdq_pkt)
175{
176 if (comp->funcs && comp->funcs->layer_config)
177 comp->funcs->layer_config(comp->dev, idx, state, cmdq_pkt);
178}
179
180static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp *comp,
181 struct drm_crtc_state *state)
182{
183 if (comp->funcs && comp->funcs->gamma_set)
184 comp->funcs->gamma_set(comp->dev, state);
185}
186
187static inline void mtk_ddp_comp_bgclr_in_on(struct mtk_ddp_comp *comp)
188{
189 if (comp->funcs && comp->funcs->bgclr_in_on)
190 comp->funcs->bgclr_in_on(comp->dev);
191}
192
193static inline void mtk_ddp_comp_bgclr_in_off(struct mtk_ddp_comp *comp)
194{
195 if (comp->funcs && comp->funcs->bgclr_in_off)
196 comp->funcs->bgclr_in_off(comp->dev);
197}
198
199static inline void mtk_ddp_ctm_set(struct mtk_ddp_comp *comp,
200 struct drm_crtc_state *state)
201{
202 if (comp->funcs && comp->funcs->ctm_set)
203 comp->funcs->ctm_set(comp->dev, state);
204}
205
206int mtk_ddp_comp_get_id(struct device_node *node,
207 enum mtk_ddp_comp_type comp_type);
208unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
209 struct device *dev);
210int mtk_ddp_comp_init(struct device_node *comp_node, struct mtk_ddp_comp *comp,
211 enum mtk_ddp_comp_id comp_id);
212enum mtk_ddp_comp_type mtk_ddp_comp_get_type(enum mtk_ddp_comp_id comp_id);
213void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value,
214 struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
215 unsigned int offset);
216void mtk_ddp_write_relaxed(struct cmdq_pkt *cmdq_pkt, unsigned int value,
217 struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
218 unsigned int offset);
219void mtk_ddp_write_mask(struct cmdq_pkt *cmdq_pkt, unsigned int value,
220 struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
221 unsigned int offset, unsigned int mask);
222#endif /* MTK_DRM_DDP_COMP_H */