Skip to content

Commit 0d4caaa

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: gamma: Enable the Gamma LUT table only after programming
Move the write to DISP_GAMMA_CFG to enable the Gamma LUT to after programming the actual table to avoid potential visual glitches during table modification. Note: GAMMA should get enabled in between vblanks, but this requires many efforts in order to make this happen, as that requires migrating all of the writes to make use of CMDQ instead of cpu writes and that's not trivial. For this reason, this patch only moves the LUT enable. The CMDQ rework will come at a later time. Reviewed-by: Jason-JH.Lin <[email protected]> Reviewed-by: Alexandre Mergnat <[email protected]> Reviewed-by: CK Hu <[email protected]> Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent c18119d commit 0d4caaa

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/gpu/drm/mediatek/mtk_disp_gamma.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ unsigned int mtk_gamma_get_lut_size(struct device *dev)
6565
void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crtc_state *state)
6666
{
6767
struct mtk_disp_gamma *gamma;
68-
unsigned int i, reg;
68+
unsigned int i;
6969
struct drm_color_lut *lut;
7070
void __iomem *lut_base;
7171
bool lut_diff;
7272
u16 lut_size;
73-
u32 word;
73+
u32 cfg_val, word;
7474

7575
/* If there's no gamma lut there's nothing to do here. */
7676
if (!state->gamma_lut)
@@ -87,9 +87,6 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt
8787
lut_size = 512;
8888
}
8989

90-
reg = readl(regs + DISP_GAMMA_CFG);
91-
reg = reg | GAMMA_LUT_EN;
92-
writel(reg, regs + DISP_GAMMA_CFG);
9390
lut_base = regs + DISP_GAMMA_LUT;
9491
lut = (struct drm_color_lut *)state->gamma_lut->data;
9592
for (i = 0; i < lut_size; i++) {
@@ -119,6 +116,13 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt
119116
}
120117
writel(word, lut_base + i * 4);
121118
}
119+
120+
cfg_val = readl(regs + DISP_GAMMA_CFG);
121+
122+
/* Enable the gamma table */
123+
cfg_val |= GAMMA_LUT_EN;
124+
125+
writel(cfg_val, regs + DISP_GAMMA_CFG);
122126
}
123127

124128
void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)

0 commit comments

Comments
 (0)