Re: [PATCH v3 4/9] drm/mediatek: Add gamma support different lut_size for other SoC
From: Jason-JH Lin
Date: Tue Sep 13 2022 - 21:36:13 EST
Hi Angelo,
Thanks for the reviews.
On Mon, 2022-09-12 at 12:24 +0200, AngeloGioacchino Del Regno wrote:
> Il 11/09/22 17:37, Jason-JH.Lin ha scritto:
> > 1. Add mtk_drm_gamma_get_lut_size() and remove MTK_LUT_SIZE macro.
> > 2. Add lut_size to gamma driver data for different SoC.
> >
> > Signed-off-by: Jason-JH.Lin <jason-jh.lin@xxxxxxxxxxxx>
> > ---
> > drivers/gpu/drm/mediatek/mtk_disp_drv.h | 1 +
> > drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 22
> > +++++++++++++++++++--
> > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 ++--
> > drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 1 -
> > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 9 +++++++++
> > 5 files changed, 32 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> > b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> > index a83e5fbc8724..6a05bb56e693 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> > +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> > @@ -51,6 +51,7 @@ void mtk_gamma_clk_disable(struct device *dev);
> > void mtk_gamma_config(struct device *dev, unsigned int w,
> > unsigned int h, unsigned int vrefresh,
> > unsigned int bpc, struct cmdq_pkt *cmdq_pkt);
> > +unsigned int mtk_gamma_get_lut_size(struct device *dev);
> > void mtk_gamma_set(struct device *dev, struct drm_crtc_state
> > *state);
> > void mtk_gamma_set_common(struct device *dev, void __iomem *regs,
> > struct drm_crtc_state *state);
> > void mtk_gamma_start(struct device *dev);
> > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
> > b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
> > index f54a6a618348..e69d0b205b9a 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
> > @@ -24,10 +24,12 @@
> > #define DISP_GAMMA_LUT 0x0700
> >
> > #define LUT_10BIT_MASK 0x03ff
> > +#define LUT_SIZE_DEFAULT 512 /* for setting
> > gamma lut from AAL */
> >
> > struct mtk_disp_gamma_data {
> > bool has_dither;
> > bool lut_diff;
> > + u16 lut_size;
> > };
> >
> > /*
> > @@ -54,18 +56,32 @@ void mtk_gamma_clk_disable(struct device *dev)
> > clk_disable_unprepare(gamma->clk);
> > }
> >
> > +unsigned int mtk_gamma_get_size(struct device *dev)
> > +{
> > + struct mtk_disp_gamma *gamma = dev_get_drvdata(dev);
> > + unsigned int lut_size = LUT_SIZE_DEFAULT;
> > +
> > + if (gamma && gamma->data)
> > + lut_size = gamma->data->lut_size;
> > +
> > + return lut_size;
> > +}
> > +
> > void mtk_gamma_set_common(struct device *dev, void __iomem *regs,
> > struct drm_crtc_state *state)
> > {
> > struct mtk_disp_gamma *gamma = dev_get_drvdata(dev);
> > bool lut_diff = false;
> > + u16 lut_size = LUT_SIZE_DEFAULT;
>
> This makes us get a double assignment in case gamma->data is
> populated.
>
> > unsigned int i, reg;
> > struct drm_color_lut *lut;
> > void __iomem *lut_base;
> > u32 word;
> > u32 diff[3] = {0};
> >
> > - if (gamma && gamma->data)
> > + if (gamma && gamma->data) {
> > lut_diff = gamma->data->lut_diff;
> > + lut_size = gamma->data->lut_size;
> > + }
>
> ...you can avoid it like that:
>
> } else {
> lut_size = LUT_SIZE_DEFAULT;
> }
>
>
> Regards,
> Angelo
>
OK, I'll fix it, but I'll move the gamma priv data handling to the
mtk_gamma_set.
Regards,
Jason-JH.Lin
>
--
Jason-JH Lin <jason-jh.lin@xxxxxxxxxxxx>