|
20 | 20 | #include "mtk_drm_ddp_comp.h" |
21 | 21 | #include "mtk_drm_crtc.h" |
22 | 22 |
|
23 | | -#define DISP_REG_OD_EN 0x0000 |
24 | | -#define DISP_REG_OD_CFG 0x0020 |
25 | | -#define DISP_REG_OD_SIZE 0x0030 |
26 | | -#define DISP_REG_DITHER_5 0x0114 |
27 | | -#define DISP_REG_DITHER_7 0x011c |
28 | | -#define DISP_REG_DITHER_15 0x013c |
29 | | -#define DISP_REG_DITHER_16 0x0140 |
30 | | - |
31 | | -#define DISP_REG_UFO_START 0x0000 |
32 | 23 |
|
33 | 24 | #define DISP_REG_DITHER_EN 0x0000 |
34 | 25 | #define DITHER_EN BIT(0) |
35 | 26 | #define DISP_REG_DITHER_CFG 0x0020 |
36 | 27 | #define DITHER_RELAY_MODE BIT(0) |
37 | 28 | #define DITHER_ENGINE_EN BIT(1) |
38 | | -#define DISP_REG_DITHER_SIZE 0x0030 |
39 | | - |
40 | | -#define OD_RELAYMODE BIT(0) |
41 | | - |
42 | | -#define UFO_BYPASS BIT(2) |
43 | | - |
44 | 29 | #define DISP_DITHERING BIT(2) |
| 30 | +#define DISP_REG_DITHER_SIZE 0x0030 |
| 31 | +#define DISP_REG_DITHER_5 0x0114 |
| 32 | +#define DISP_REG_DITHER_7 0x011c |
| 33 | +#define DISP_REG_DITHER_15 0x013c |
45 | 34 | #define DITHER_LSB_ERR_SHIFT_R(x) (((x) & 0x7) << 28) |
46 | 35 | #define DITHER_ADD_LSHIFT_R(x) (((x) & 0x7) << 20) |
47 | 36 | #define DITHER_NEW_BIT_MODE BIT(0) |
| 37 | +#define DISP_REG_DITHER_16 0x0140 |
48 | 38 | #define DITHER_LSB_ERR_SHIFT_B(x) (((x) & 0x7) << 28) |
49 | 39 | #define DITHER_ADD_LSHIFT_B(x) (((x) & 0x7) << 20) |
50 | 40 | #define DITHER_LSB_ERR_SHIFT_G(x) (((x) & 0x7) << 12) |
51 | 41 | #define DITHER_ADD_LSHIFT_G(x) (((x) & 0x7) << 4) |
52 | 42 |
|
| 43 | +#define DISP_REG_OD_EN 0x0000 |
| 44 | +#define DISP_REG_OD_CFG 0x0020 |
| 45 | +#define OD_RELAYMODE BIT(0) |
| 46 | +#define DISP_REG_OD_SIZE 0x0030 |
| 47 | + |
53 | 48 | #define DISP_REG_POSTMASK_EN 0x0000 |
54 | 49 | #define POSTMASK_EN BIT(0) |
55 | 50 | #define DISP_REG_POSTMASK_CFG 0x0020 |
56 | 51 | #define POSTMASK_RELAY_MODE BIT(0) |
57 | 52 | #define DISP_REG_POSTMASK_SIZE 0x0030 |
58 | 53 |
|
| 54 | +#define DISP_REG_UFO_START 0x0000 |
| 55 | +#define UFO_BYPASS BIT(2) |
| 56 | + |
59 | 57 | struct mtk_ddp_comp_dev { |
60 | 58 | struct clk *clk; |
61 | 59 | void __iomem *regs; |
@@ -147,66 +145,58 @@ void mtk_dither_set_common(void __iomem *regs, struct cmdq_client_reg *cmdq_reg, |
147 | 145 | } |
148 | 146 | } |
149 | 147 |
|
150 | | -static void mtk_dither_set(struct device *dev, unsigned int bpc, |
151 | | - unsigned int cfg, struct cmdq_pkt *cmdq_pkt) |
152 | | -{ |
153 | | - struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev); |
154 | | - |
155 | | - mtk_dither_set_common(priv->regs, &priv->cmdq_reg, bpc, cfg, |
156 | | - DISP_DITHERING, cmdq_pkt); |
157 | | -} |
158 | | - |
159 | | -static void mtk_od_config(struct device *dev, unsigned int w, |
160 | | - unsigned int h, unsigned int vrefresh, |
161 | | - unsigned int bpc, struct cmdq_pkt *cmdq_pkt) |
| 148 | +static void mtk_dither_config(struct device *dev, unsigned int w, |
| 149 | + unsigned int h, unsigned int vrefresh, |
| 150 | + unsigned int bpc, struct cmdq_pkt *cmdq_pkt) |
162 | 151 | { |
163 | 152 | struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev); |
164 | 153 |
|
165 | | - mtk_ddp_write(cmdq_pkt, w << 16 | h, &priv->cmdq_reg, priv->regs, DISP_REG_OD_SIZE); |
166 | | - mtk_ddp_write(cmdq_pkt, OD_RELAYMODE, &priv->cmdq_reg, priv->regs, DISP_REG_OD_CFG); |
167 | | - mtk_dither_set(dev, bpc, DISP_REG_OD_CFG, cmdq_pkt); |
| 154 | + mtk_ddp_write(cmdq_pkt, h << 16 | w, &priv->cmdq_reg, priv->regs, DISP_REG_DITHER_SIZE); |
| 155 | + mtk_ddp_write(cmdq_pkt, DITHER_RELAY_MODE, &priv->cmdq_reg, priv->regs, |
| 156 | + DISP_REG_DITHER_CFG); |
| 157 | + mtk_dither_set_common(priv->regs, &priv->cmdq_reg, bpc, DISP_REG_DITHER_CFG, |
| 158 | + DITHER_ENGINE_EN, cmdq_pkt); |
168 | 159 | } |
169 | 160 |
|
170 | | -static void mtk_od_start(struct device *dev) |
| 161 | +static void mtk_dither_start(struct device *dev) |
171 | 162 | { |
172 | 163 | struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev); |
173 | 164 |
|
174 | | - writel(1, priv->regs + DISP_REG_OD_EN); |
| 165 | + writel(DITHER_EN, priv->regs + DISP_REG_DITHER_EN); |
175 | 166 | } |
176 | 167 |
|
177 | | -static void mtk_ufoe_start(struct device *dev) |
| 168 | +static void mtk_dither_stop(struct device *dev) |
178 | 169 | { |
179 | 170 | struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev); |
180 | 171 |
|
181 | | - writel(UFO_BYPASS, priv->regs + DISP_REG_UFO_START); |
| 172 | + writel_relaxed(0x0, priv->regs + DISP_REG_DITHER_EN); |
182 | 173 | } |
183 | 174 |
|
184 | | -static void mtk_dither_config(struct device *dev, unsigned int w, |
185 | | - unsigned int h, unsigned int vrefresh, |
186 | | - unsigned int bpc, struct cmdq_pkt *cmdq_pkt) |
| 175 | +static void mtk_dither_set(struct device *dev, unsigned int bpc, |
| 176 | + unsigned int cfg, struct cmdq_pkt *cmdq_pkt) |
187 | 177 | { |
188 | 178 | struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev); |
189 | 179 |
|
190 | | - mtk_ddp_write(cmdq_pkt, h << 16 | w, &priv->cmdq_reg, priv->regs, |
191 | | - DISP_REG_DITHER_SIZE); |
192 | | - mtk_ddp_write(cmdq_pkt, DITHER_RELAY_MODE, &priv->cmdq_reg, priv->regs, |
193 | | - DISP_REG_DITHER_CFG); |
194 | | - mtk_dither_set_common(priv->regs, &priv->cmdq_reg, bpc, DISP_REG_DITHER_CFG, |
195 | | - DITHER_ENGINE_EN, cmdq_pkt); |
| 180 | + mtk_dither_set_common(priv->regs, &priv->cmdq_reg, bpc, cfg, |
| 181 | + DISP_DITHERING, cmdq_pkt); |
196 | 182 | } |
197 | 183 |
|
198 | | -static void mtk_dither_start(struct device *dev) |
| 184 | +static void mtk_od_config(struct device *dev, unsigned int w, |
| 185 | + unsigned int h, unsigned int vrefresh, |
| 186 | + unsigned int bpc, struct cmdq_pkt *cmdq_pkt) |
199 | 187 | { |
200 | 188 | struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev); |
201 | 189 |
|
202 | | - writel(DITHER_EN, priv->regs + DISP_REG_DITHER_EN); |
| 190 | + mtk_ddp_write(cmdq_pkt, w << 16 | h, &priv->cmdq_reg, priv->regs, DISP_REG_OD_SIZE); |
| 191 | + mtk_ddp_write(cmdq_pkt, OD_RELAYMODE, &priv->cmdq_reg, priv->regs, DISP_REG_OD_CFG); |
| 192 | + mtk_dither_set(dev, bpc, DISP_REG_OD_CFG, cmdq_pkt); |
203 | 193 | } |
204 | 194 |
|
205 | | -static void mtk_dither_stop(struct device *dev) |
| 195 | +static void mtk_od_start(struct device *dev) |
206 | 196 | { |
207 | 197 | struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev); |
208 | 198 |
|
209 | | - writel_relaxed(0x0, priv->regs + DISP_REG_DITHER_EN); |
| 199 | + writel(1, priv->regs + DISP_REG_OD_EN); |
210 | 200 | } |
211 | 201 |
|
212 | 202 | static void mtk_postmask_config(struct device *dev, unsigned int w, |
@@ -235,6 +225,13 @@ static void mtk_postmask_stop(struct device *dev) |
235 | 225 | writel_relaxed(0x0, priv->regs + DISP_REG_POSTMASK_EN); |
236 | 226 | } |
237 | 227 |
|
| 228 | +static void mtk_ufoe_start(struct device *dev) |
| 229 | +{ |
| 230 | + struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev); |
| 231 | + |
| 232 | + writel(UFO_BYPASS, priv->regs + DISP_REG_UFO_START); |
| 233 | +} |
| 234 | + |
238 | 235 | static const struct mtk_ddp_comp_funcs ddp_aal = { |
239 | 236 | .clk_enable = mtk_aal_clk_enable, |
240 | 237 | .clk_disable = mtk_aal_clk_disable, |
@@ -337,23 +334,23 @@ static const struct mtk_ddp_comp_funcs ddp_ufoe = { |
337 | 334 | }; |
338 | 335 |
|
339 | 336 | static const char * const mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX] = { |
340 | | - [MTK_DISP_OVL] = "ovl", |
341 | | - [MTK_DISP_OVL_2L] = "ovl-2l", |
342 | | - [MTK_DISP_RDMA] = "rdma", |
343 | | - [MTK_DISP_WDMA] = "wdma", |
344 | | - [MTK_DISP_COLOR] = "color", |
345 | | - [MTK_DISP_CCORR] = "ccorr", |
346 | 337 | [MTK_DISP_AAL] = "aal", |
347 | | - [MTK_DISP_GAMMA] = "gamma", |
| 338 | + [MTK_DISP_BLS] = "bls", |
| 339 | + [MTK_DISP_CCORR] = "ccorr", |
| 340 | + [MTK_DISP_COLOR] = "color", |
348 | 341 | [MTK_DISP_DITHER] = "dither", |
349 | | - [MTK_DISP_UFOE] = "ufoe", |
350 | | - [MTK_DSI] = "dsi", |
351 | | - [MTK_DPI] = "dpi", |
352 | | - [MTK_DISP_PWM] = "pwm", |
| 342 | + [MTK_DISP_GAMMA] = "gamma", |
353 | 343 | [MTK_DISP_MUTEX] = "mutex", |
354 | 344 | [MTK_DISP_OD] = "od", |
355 | | - [MTK_DISP_BLS] = "bls", |
| 345 | + [MTK_DISP_OVL] = "ovl", |
| 346 | + [MTK_DISP_OVL_2L] = "ovl-2l", |
356 | 347 | [MTK_DISP_POSTMASK] = "postmask", |
| 348 | + [MTK_DISP_PWM] = "pwm", |
| 349 | + [MTK_DISP_RDMA] = "rdma", |
| 350 | + [MTK_DISP_UFOE] = "ufoe", |
| 351 | + [MTK_DISP_WDMA] = "wdma", |
| 352 | + [MTK_DPI] = "dpi", |
| 353 | + [MTK_DSI] = "dsi", |
357 | 354 | }; |
358 | 355 |
|
359 | 356 | struct mtk_ddp_comp_match { |
@@ -511,12 +508,12 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp, |
511 | 508 | type == MTK_DISP_CCORR || |
512 | 509 | type == MTK_DISP_COLOR || |
513 | 510 | type == MTK_DISP_GAMMA || |
514 | | - type == MTK_DPI || |
515 | | - type == MTK_DSI || |
516 | 511 | type == MTK_DISP_OVL || |
517 | 512 | type == MTK_DISP_OVL_2L || |
518 | 513 | type == MTK_DISP_PWM || |
519 | | - type == MTK_DISP_RDMA) |
| 514 | + type == MTK_DISP_RDMA || |
| 515 | + type == MTK_DPI || |
| 516 | + type == MTK_DSI) |
520 | 517 | return 0; |
521 | 518 |
|
522 | 519 | priv = devm_kzalloc(comp->dev, sizeof(*priv), GFP_KERNEL); |
|
0 commit comments