Skip to content

Commit aa5fb24

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: gamma: Reduce indentation in mtk_gamma_set_common()
Invert the check for state->gamma_lut and move it at the beginning of the function to reduce indentation: this prepares the code for keeping readability on later additions. This commit brings no functional changes. 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 1c5a880 commit aa5fb24

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

drivers/gpu/drm/mediatek/mtk_disp_gamma.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt
6464
u32 word;
6565
u32 diff[3] = {0};
6666

67+
/* If there's no gamma lut there's nothing to do here. */
68+
if (!state->gamma_lut)
69+
return;
70+
6771
/* If we're called from AAL, dev is NULL */
6872
gamma = dev ? dev_get_drvdata(dev) : NULL;
6973

@@ -72,29 +76,26 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt
7276
else
7377
lut_diff = false;
7478

75-
if (state->gamma_lut) {
76-
reg = readl(regs + DISP_GAMMA_CFG);
77-
reg = reg | GAMMA_LUT_EN;
78-
writel(reg, regs + DISP_GAMMA_CFG);
79-
lut_base = regs + DISP_GAMMA_LUT;
80-
lut = (struct drm_color_lut *)state->gamma_lut->data;
81-
for (i = 0; i < MTK_LUT_SIZE; i++) {
82-
83-
if (!lut_diff || (i % 2 == 0)) {
84-
word = (((lut[i].red >> 6) & LUT_10BIT_MASK) << 20) +
85-
(((lut[i].green >> 6) & LUT_10BIT_MASK) << 10) +
86-
((lut[i].blue >> 6) & LUT_10BIT_MASK);
87-
} else {
88-
diff[0] = (lut[i].red >> 6) - (lut[i - 1].red >> 6);
89-
diff[1] = (lut[i].green >> 6) - (lut[i - 1].green >> 6);
90-
diff[2] = (lut[i].blue >> 6) - (lut[i - 1].blue >> 6);
91-
92-
word = ((diff[0] & LUT_10BIT_MASK) << 20) +
93-
((diff[1] & LUT_10BIT_MASK) << 10) +
94-
(diff[2] & LUT_10BIT_MASK);
95-
}
96-
writel(word, (lut_base + i * 4));
79+
reg = readl(regs + DISP_GAMMA_CFG);
80+
reg = reg | GAMMA_LUT_EN;
81+
writel(reg, regs + DISP_GAMMA_CFG);
82+
lut_base = regs + DISP_GAMMA_LUT;
83+
lut = (struct drm_color_lut *)state->gamma_lut->data;
84+
for (i = 0; i < MTK_LUT_SIZE; i++) {
85+
if (!lut_diff || (i % 2 == 0)) {
86+
word = (((lut[i].red >> 6) & LUT_10BIT_MASK) << 20) +
87+
(((lut[i].green >> 6) & LUT_10BIT_MASK) << 10) +
88+
((lut[i].blue >> 6) & LUT_10BIT_MASK);
89+
} else {
90+
diff[0] = (lut[i].red >> 6) - (lut[i - 1].red >> 6);
91+
diff[1] = (lut[i].green >> 6) - (lut[i - 1].green >> 6);
92+
diff[2] = (lut[i].blue >> 6) - (lut[i - 1].blue >> 6);
93+
94+
word = ((diff[0] & LUT_10BIT_MASK) << 20) +
95+
((diff[1] & LUT_10BIT_MASK) << 10) +
96+
(diff[2] & LUT_10BIT_MASK);
9797
}
98+
writel(word, (lut_base + i * 4));
9899
}
99100
}
100101

0 commit comments

Comments
 (0)