From: CK Hu <ck.hu@mediatek.com>
To: Yongqiang Niu <yongqiang.niu@mediatek.com>,
Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Yongqiang Niu <yongqiang.niu@mediatek.corp-partner.google.com>,
<devicetree@vger.kernel.org>,
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
David Airlie <airlied@linux.ie>,
Jassi Brar <jassisinghbrar@gmail.com>,
<linux-kernel@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
"Dennis YC Hsieh" <dennis-yc.hsieh@mediatek.com>,
Fabien Parent <fparent@baylibre.com>,
Rob Herring <robh+dt@kernel.org>,
<linux-mediatek@lists.infradead.org>,
Hsin-Yi Wang <hsinyi@chromium.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v2, 1/1] drm/mediatek: add lut diff flag for new gamma hardware support
Date: Thu, 28 Apr 2022 13:41:34 +0800 [thread overview]
Message-ID: <dacfb336fe619fdb690a275e8f6569147d9473ed.camel@mediatek.com> (raw)
In-Reply-To: <20220428024411.10133-2-yongqiang.niu@mediatek.com>
Hi, Yongqiang:
On Thu, 2022-04-28 at 10:44 +0800, Yongqiang Niu wrote:
> From: Yongqiang Niu <yongqiang.niu@mediatek.corp-partner.google.com>
>
> mt8183 gamma module usage is different with before soc,
> gamma odd(index start from 0) lut value set to hardware
> register should be
> the difference of current lut value with last lut value.
>
> for example, chrome os user space set lut
> like this(only r chanel for example):
> 2 4 6 8 10 12.
> 1) mt8183 gamma driver should set the gamma lut to hardware
> register like this:
> 2 [2] 6 [8] 10 [2]
2 [2] 6 [2] 10 [2]
> the value with [] is the difference value
> 2)gamma hardware process display data with original lut
>
> Signed-off-by: Yongqiang Niu <
> yongqiang.niu@mediatek.corp-partner.google.com>
Who send this patch should sign this patch. So sign by MediaTek mail
account.
Regards,
CK
> ---
> drivers/gpu/drm/mediatek/mtk_disp_aal.c | 2 +-
> drivers/gpu/drm/mediatek/mtk_disp_drv.h | 2 +-
> drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 34 +++++++++++++++++++
> ----
> 3 files changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_aal.c
> b/drivers/gpu/drm/mediatek/mtk_disp_aal.c
> index f46d4ab73d6a..0f9d7efb61d7 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_aal.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_aal.c
> @@ -66,7 +66,7 @@ void mtk_aal_gamma_set(struct device *dev, struct
> drm_crtc_state *state)
> struct mtk_disp_aal *aal = dev_get_drvdata(dev);
>
> if (aal->data && aal->data->has_gamma)
> - mtk_gamma_set_common(aal->regs, state);
> + mtk_gamma_set_common(aal->regs, state, false);
> }
>
> void mtk_aal_start(struct device *dev)
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> index 86c3068894b1..3380651c6707 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> @@ -51,7 +51,7 @@ void mtk_gamma_config(struct device *dev, unsigned
> int w,
> unsigned int h, unsigned int vrefresh,
> unsigned int bpc, struct cmdq_pkt *cmdq_pkt);
> void mtk_gamma_set(struct device *dev, struct drm_crtc_state
> *state);
> -void mtk_gamma_set_common(void __iomem *regs, struct drm_crtc_state
> *state);
> +void mtk_gamma_set_common(void __iomem *regs, struct drm_crtc_state
> *state, bool lut_diff);
> void mtk_gamma_start(struct device *dev);
> void mtk_gamma_stop(struct device *dev);
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
> b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
> index 3a5815ab4079..bbd558a036ec 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c
> @@ -27,6 +27,7 @@
>
> struct mtk_disp_gamma_data {
> bool has_dither;
> + bool lut_diff;
> };
>
> /*
> @@ -53,12 +54,13 @@ void mtk_gamma_clk_disable(struct device *dev)
> clk_disable_unprepare(gamma->clk);
> }
>
> -void mtk_gamma_set_common(void __iomem *regs, struct drm_crtc_state
> *state)
> +void mtk_gamma_set_common(void __iomem *regs, struct drm_crtc_state
> *state, bool lut_diff)
> {
> unsigned int i, reg;
> struct drm_color_lut *lut;
> void __iomem *lut_base;
> u32 word;
> + u32 diff[3] = {0};
>
> if (state->gamma_lut) {
> reg = readl(regs + DISP_GAMMA_CFG);
> @@ -67,9 +69,20 @@ void mtk_gamma_set_common(void __iomem *regs,
> struct drm_crtc_state *state)
> lut_base = regs + DISP_GAMMA_LUT;
> lut = (struct drm_color_lut *)state->gamma_lut->data;
> for (i = 0; i < MTK_LUT_SIZE; i++) {
> - word = (((lut[i].red >> 6) & LUT_10BIT_MASK) <<
> 20) +
> - (((lut[i].green >> 6) & LUT_10BIT_MASK)
> << 10) +
> - ((lut[i].blue >> 6) & LUT_10BIT_MASK);
> +
> + if (!lut_diff || (i % 2 == 0)) {
> + word = (((lut[i].red >> 6) &
> LUT_10BIT_MASK) << 20) +
> + (((lut[i].green >> 6) &
> LUT_10BIT_MASK) << 10) +
> + ((lut[i].blue >> 6) &
> LUT_10BIT_MASK);
> + } else {
> + diff[0] = (lut[i].red >> 6) - (lut[i -
> 1].red >> 6);
> + diff[1] = (lut[i].green >> 6) - (lut[i
> - 1].green >> 6);
> + diff[2] = (lut[i].blue >> 6) - (lut[i -
> 1].blue >> 6);
> +
> + word = ((diff[0] & LUT_10BIT_MASK) <<
> 20) +
> + ((diff[1] & LUT_10BIT_MASK) <<
> 10) +
> + (diff[2] & LUT_10BIT_MASK);
> + }
> writel(word, (lut_base + i * 4));
> }
> }
> @@ -78,8 +91,12 @@ void mtk_gamma_set_common(void __iomem *regs,
> struct drm_crtc_state *state)
> void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)
> {
> struct mtk_disp_gamma *gamma = dev_get_drvdata(dev);
> + bool lut_diff = false;
> +
> + if (gamma->data)
> + lut_diff = gamma->data->lut_diff;
>
> - mtk_gamma_set_common(gamma->regs, state);
> + mtk_gamma_set_common(gamma->regs, state, lut_diff);
> }
>
> void mtk_gamma_config(struct device *dev, unsigned int w,
> @@ -176,10 +193,15 @@ static const struct mtk_disp_gamma_data
> mt8173_gamma_driver_data = {
> .has_dither = true,
> };
>
> +static const struct mtk_disp_gamma_data mt8183_gamma_driver_data = {
> + .lut_diff = true,
> +};
> +
> static const struct of_device_id mtk_disp_gamma_driver_dt_match[] =
> {
> { .compatible = "mediatek,mt8173-disp-gamma",
> .data = &mt8173_gamma_driver_data},
> - { .compatible = "mediatek,mt8183-disp-gamma"},
> + { .compatible = "mediatek,mt8183-disp-gamma",
> + .data = &mt8183_gamma_driver_data},
> {},
> };
> MODULE_DEVICE_TABLE(of, mtk_disp_gamma_driver_dt_match);
prev parent reply other threads:[~2022-04-28 5:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 2:44 [PATCH v2, 0/1] " Yongqiang Niu
2022-04-28 2:44 ` [PATCH v2, 1/1] " Yongqiang Niu
2022-04-28 5:41 ` CK Hu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dacfb336fe619fdb690a275e8f6569147d9473ed.camel@mediatek.com \
--to=ck.hu@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=airlied@linux.ie \
--cc=chunkuang.hu@kernel.org \
--cc=dennis-yc.hsieh@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=fparent@baylibre.com \
--cc=hsinyi@chromium.org \
--cc=jassisinghbrar@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=yongqiang.niu@mediatek.com \
--cc=yongqiang.niu@mediatek.corp-partner.google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®