Lines Matching +full:mt8173 +full:- +full:disp

1 // SPDX-License-Identifier: GPL-2.0-only
12 #include <linux/soc/mediatek/mtk-cmdq.h>
54 * struct mtk_disp_gamma - Display Gamma driver structure
71 return clk_prepare_enable(gamma->clk);
78 clk_disable_unprepare(gamma->clk);
85 if (gamma && gamma->data)
86 return gamma->data->lut_size;
93 int last_entry = lut_size - 1;
102 * SoCs supporting 12-bits LUTs are using a new register layout that does
103 * always support (by HW) both 12-bits and 10-bits LUT but, on those, we
104 * ignore the support for 10-bits in this driver and always use 12-bits.
107 * - SoC HW support 9/10-bits LUT only
108 * - Old register layout
109 * - 10-bits LUT supported
110 * - 9-bits LUT not supported
111 * - SoC HW support both 10/12bits LUT
112 * - New register layout
113 * - 12-bits LUT supported
114 * - 10-its LUT not supported
119 void __iomem *lut0_base = gamma->regs + DISP_GAMMA_LUT;
120 void __iomem *lut1_base = gamma->regs + DISP_GAMMA_LUT1;
122 u8 lut_bits = gamma->data->lut_bits;
128 if (!state->gamma_lut)
131 num_lut_banks = gamma->data->lut_size / gamma->data->lut_bank_size;
132 lut = (struct drm_color_lut *)state->gamma_lut->data;
143 writel(lbank_val, gamma->regs + DISP_GAMMA_BANK);
146 for (i = 0; i < gamma->data->lut_bank_size; i++) {
147 int n = cur_bank * gamma->data->lut_bank_size + i;
154 if (!gamma->data->lut_diff || (i % 2 == 0)) {
165 diff.red = lut[n].red - lut[n - 1].red;
168 diff.green = lut[n].green - lut[n - 1].green;
171 diff.blue = lut[n].blue - lut[n - 1].blue;
190 cfg_val = readl(gamma->regs + DISP_GAMMA_CFG);
192 if (!gamma->data->has_dither) {
194 if (mtk_gamma_lut_is_descending(lut, gamma->data->lut_size - 1))
206 writel(cfg_val, gamma->regs + DISP_GAMMA_CFG);
219 mtk_ddp_write(cmdq_pkt, sz, &gamma->cmdq_reg, gamma->regs, DISP_GAMMA_SIZE);
220 if (gamma->data && gamma->data->has_dither)
221 mtk_dither_set_common(gamma->regs, &gamma->cmdq_reg, bpc,
229 writel(GAMMA_EN, gamma->regs + DISP_GAMMA_EN);
236 writel_relaxed(0x0, gamma->regs + DISP_GAMMA_EN);
257 struct device *dev = &pdev->dev;
263 return -ENOMEM;
265 priv->clk = devm_clk_get(dev, NULL);
266 if (IS_ERR(priv->clk))
267 return dev_err_probe(dev, PTR_ERR(priv->clk),
270 priv->regs = devm_platform_ioremap_resource(pdev, 0);
271 if (IS_ERR(priv->regs))
272 return dev_err_probe(dev, PTR_ERR(priv->regs),
276 ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
278 dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
281 priv->data = of_device_get_match_data(dev);
293 component_del(&pdev->dev, &mtk_disp_gamma_component_ops);
318 { .compatible = "mediatek,mt8173-disp-gamma",
320 { .compatible = "mediatek,mt8183-disp-gamma",
322 { .compatible = "mediatek,mt8195-disp-gamma",
332 .name = "mediatek-disp-gamma",