Skip to content

Commit a6b39cd

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: De-commonize disp_aal/disp_gamma gamma_set functions
In preparation for adding a 12-bits gamma support for the DISP_GAMMA IP, remove the mtk_gamma_set_common() function and move the relevant bits in mtk_gamma_set() for DISP_GAMMA and mtk_aal_gamma_set() for DISP_AAL: since the latter has no more support for gamma manipulation (being moved to a different IP) in newer revisions, those functions are about to diverge and it makes no sense to keep a common one (with all the complications of passing common data and making exclusions for device driver data) for just a few bits. This commit brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: Nícolas F. R. A. Prado <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 36e5da1 commit a6b39cd

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

drivers/gpu/drm/mediatek/mtk_disp_gamma.c

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,41 +69,28 @@ unsigned int mtk_gamma_get_lut_size(struct device *dev)
6969
return 0;
7070
}
7171

72-
void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crtc_state *state)
72+
void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)
7373
{
74-
struct mtk_disp_gamma *gamma;
74+
struct mtk_disp_gamma *gamma = dev_get_drvdata(dev);
7575
unsigned int i;
7676
struct drm_color_lut *lut;
7777
void __iomem *lut_base;
78-
bool lut_diff;
79-
u16 lut_size;
8078
u32 cfg_val, word;
8179

8280
/* If there's no gamma lut there's nothing to do here. */
8381
if (!state->gamma_lut)
8482
return;
8583

86-
/* If we're called from AAL, dev is NULL */
87-
gamma = dev ? dev_get_drvdata(dev) : NULL;
88-
89-
if (gamma && gamma->data) {
90-
lut_diff = gamma->data->lut_diff;
91-
lut_size = gamma->data->lut_size;
92-
} else {
93-
lut_diff = false;
94-
lut_size = 512;
95-
}
96-
97-
lut_base = regs + DISP_GAMMA_LUT;
84+
lut_base = gamma->regs + DISP_GAMMA_LUT;
9885
lut = (struct drm_color_lut *)state->gamma_lut->data;
99-
for (i = 0; i < lut_size; i++) {
86+
for (i = 0; i < gamma->data->lut_size; i++) {
10087
struct drm_color_lut diff, hwlut;
10188

10289
hwlut.red = drm_color_lut_extract(lut[i].red, 10);
10390
hwlut.green = drm_color_lut_extract(lut[i].green, 10);
10491
hwlut.blue = drm_color_lut_extract(lut[i].blue, 10);
10592

106-
if (!lut_diff || (i % 2 == 0)) {
93+
if (!gamma->data->lut_diff || (i % 2 == 0)) {
10794
word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, hwlut.red);
10895
word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, hwlut.green);
10996
word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, hwlut.blue);
@@ -124,19 +111,12 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt
124111
writel(word, lut_base + i * 4);
125112
}
126113

127-
cfg_val = readl(regs + DISP_GAMMA_CFG);
114+
cfg_val = readl(gamma->regs + DISP_GAMMA_CFG);
128115

129116
/* Enable the gamma table */
130117
cfg_val |= FIELD_PREP(GAMMA_LUT_EN, 1);
131118

132-
writel(cfg_val, regs + DISP_GAMMA_CFG);
133-
}
134-
135-
void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)
136-
{
137-
struct mtk_disp_gamma *gamma = dev_get_drvdata(dev);
138-
139-
mtk_gamma_set_common(dev, gamma->regs, state);
119+
cfg_val = readl(gamma->regs + DISP_GAMMA_CFG);
140120
}
141121

142122
void mtk_gamma_config(struct device *dev, unsigned int w,

0 commit comments

Comments
 (0)