Message ID | 20230518104857.124265-6-angelogioacchino.delregno@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp399317vqo; Thu, 18 May 2023 03:59:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7RtKJAi+K8DwAfFWfNCmkGGSgGPWDeXmM5yga5RAPzyRS3YjOcTEi8FkDwPRWOJ+x2SF9r X-Received: by 2002:a05:6a21:789a:b0:105:8d42:2622 with SMTP id bf26-20020a056a21789a00b001058d422622mr2009766pzc.41.1684407577710; Thu, 18 May 2023 03:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684407577; cv=none; d=google.com; s=arc-20160816; b=Y2dl7aAEIX98jhMmIlvg9FYoQ13Uhpo670wy6O8n8OKou8R3PkkVurZUVDfmqy0C5w qG8S/UH2lPo+5nMkWK9u8BLoWcWgrH/gODhtFXHYk9r9U9vmI9hi9nNDw6ZkPYyDOy1D r1Qy4/TATbbGBkttqycAkHIeRSM3UjZbP63llj7JUJ6yNggbfaXJfUcEuGylSBN4PSQx ApaeyqGmfpwqMeEdw4M2YExvKWL2697iITpnuFEYQoeK3kHnstOdbfGkRVi2TKjFoceR zHaTDeTndj6AZNP9HXRNQqyMphd//7jCkdmkiE4iWb+MJMPF/9QrPBhQaMlN8dA4DFTZ J31g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1eOWnkjQL7RHBWcdMDuTC+4Bn9ztmM1L5mKzuivGe+k=; b=gEymOUgzgg35ZQT8bP6Yii3Wh8OExIUCRFD4rcQTArQUcnFjWqRbJ3sQqSOgGdpCFy LNFztH8LMWMNTZERqaNNqyuA86+BwgZZYSFYL9DymcmZdBW6ChmzhOVgOxoJ+ywqOeuG Qvj3nrhNQ8A0Gvcd88xRLiOMDJMNybdSSedrX90z9xoZwUd5wmoDZkPMuNld/nv9KlUM BRwOXDq1XidiKtxsoY7zerkt35GZeOR+URfBRMsuT1xi75PC73QA7s780heIp3EDE2YY paVhPegzvPzJqzsyiahPnndq/umOeMKQ7zrouD8II3o9aoER4gZ19xV9ZcnxI4u9BbgI w27Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=k1Mz+zGC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v202-20020a6361d3000000b0050bede17e7bsi1099756pgb.347.2023.05.18.03.59.22; Thu, 18 May 2023 03:59:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=k1Mz+zGC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230413AbjERKt0 (ORCPT <rfc822;pacteraone@gmail.com> + 99 others); Thu, 18 May 2023 06:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbjERKtI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 18 May 2023 06:49:08 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7370B10C9 for <linux-kernel@vger.kernel.org>; Thu, 18 May 2023 03:49:07 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 57449660595E; Thu, 18 May 2023 11:49:05 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684406946; bh=UsapK5lR47Wj/X/uyrI/hv+xffw+LupSDhuQiXAKMmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k1Mz+zGCG1XzN+6Vhh9oMQXMHlpJCV2LDWlkDwqYovbVvJ35IsFAkh+w4ZR5bO3Zu WagAyqnBpOqWrzYbhE5/LKh0dF65srVQVGobJ3wVL6j1G/mjb8DtzuVOqrsqsXvtbq f/ZJei3ZehtvefOEWZAoCh1YCEFGJHrLZ8QTNfyCo0uMs98nhT0sE/EFyGXkWPjsHu wfn00PqSxJ533TJu0leST3N9hs277KPPNf1KL/dRq/Ys5ABS3vejQqpm6pTg5Fbl8e KTJk79S2HybfgsLr+xynkg4vRi3NpTAtA65zka4Ll89nEYOhParZk8O+FfTtJzVqZa BxZhK9DdesGAg== From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, wenst@chromium.org, kernel@collabora.com, "Jason-JH . Lin" <jason-jh.lin@mediatek.com> Subject: [PATCH v4 05/11] drm/mediatek: gamma: Enable the Gamma LUT table only after programming Date: Thu, 18 May 2023 12:48:51 +0200 Message-Id: <20230518104857.124265-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230518104857.124265-1-angelogioacchino.delregno@collabora.com> References: <20230518104857.124265-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766229360143809053?= X-GMAIL-MSGID: =?utf-8?q?1766229360143809053?= |
Series |
MediaTek DDP GAMMA - 12-bit LUT support
|
|
Commit Message
AngeloGioacchino Del Regno
May 18, 2023, 10:48 a.m. UTC
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. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Jason-JH.Lin <jason-jh.lin@mediatek.com> --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Comments
Hi, Angelo: On Thu, 2023-05-18 at 12:48 +0200, AngeloGioacchino Del Regno wrote: > External email : Please do not click links or open attachments until > you have verified the sender or the content. > > > 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. I think user could update the lut table frequently, so when do you disable the gamma function before next update? In addition, if we really care the glitches, update the register in vblank period which should use cmdq to update the register. But now, I think we do not care the glitches. You may skip this patch, or fix the problem I mention. Regards, CK > > Signed-off-by: AngeloGioacchino Del Regno < > angelogioacchino.delregno@collabora.com> > Reviewed-by: Jason-JH.Lin <jason-jh.lin@mediatek.com> > --- > drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c > b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c > index 60ccea8c1e1a..1592614b6de7 100644 > --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c > +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c > @@ -71,12 +71,12 @@ unsigned int mtk_gamma_get_lut_size(struct device > *dev) > 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); > - unsigned int i, reg; > + unsigned int i; > struct drm_color_lut *lut; > void __iomem *lut_base; > bool lut_diff; > u16 lut_size; > - u32 word; > + u32 cfg_val, word; > > /* If there's no gamma lut there's nothing to do here. */ > if (!state->gamma_lut) > @@ -90,9 +90,7 @@ void mtk_gamma_set_common(struct device *dev, void > __iomem *regs, struct drm_crt > lut_size = LUT_SIZE_DEFAULT; > } > > - reg = readl(regs + DISP_GAMMA_CFG); > - reg = reg | GAMMA_LUT_EN; > - writel(reg, regs + DISP_GAMMA_CFG); > + cfg_val = readl(regs + DISP_GAMMA_CFG); > lut_base = regs + DISP_GAMMA_LUT; > lut = (struct drm_color_lut *)state->gamma_lut->data; > for (i = 0; i < lut_size; i++) { > @@ -122,6 +120,11 @@ void mtk_gamma_set_common(struct device *dev, > void __iomem *regs, struct drm_crt > } > writel(word, (lut_base + i * 4)); > } > + > + /* Enable the gamma table */ > + cfg_val = cfg_val | GAMMA_LUT_EN; > + > + writel(cfg_val, regs + DISP_GAMMA_CFG); > } > > void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state) > -- > 2.40.1 >
Il 22/05/23 12:00, CK Hu (胡俊光) ha scritto: > Hi, Angelo: > > On Thu, 2023-05-18 at 12:48 +0200, AngeloGioacchino Del Regno wrote: >> External email : Please do not click links or open attachments until >> you have verified the sender or the content. >> >> >> 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. > > I think user could update the lut table frequently, so when do you > disable the gamma function before next update? In addition, if we > really care the glitches, update the register in vblank period which > should use cmdq to update the register. But now, I think we do not care > the glitches. You may skip this patch, or fix the problem I mention. > If you disable the GAMMA function (either set RELAY mode or disable the GAMMA_LUT_EN bit in GAMMA_CFG), there will be glitches during setting via the GNOME Night Mode color temperature slider. This commit prevents a glitch in the case in which the GAMMA LUT registers are not zeroed before setting the expected LUT, for which reason I disagree about skipping this patch. Please note that, while I agree about updating the GAMMA LUT through CMDQ setting and between vblanks, this requires a lot more effort to implement and it's out of scope for this specific series; depending on my bandwidth, this may come later and it would in any case require this patch to move the LUT enablement to after LUT registers setting. Besides, I have already tried to enable this through CMDQ, but didn't work as expected and since I had no time to dig further, I deemed this to be essential for at least an initial functionality implementation for MT8195, and a cleanup of this driver. Obviously, the *only* way to fix *all* of the corner cases of the problem that you mentioned is to use CMDQ and trying to implement this purely with cpu writes will in any case be prone to at least some glitches. In any case, while your concern is valid, I'm sure that you agree with me on the fact that enabling the LUT before actually programming it is something that should not happen in principle. For this reason, and for the others that I've just mentioned, I think that this patch is totally valid. Regards, Angelo > Regards, > CK > >> >> Signed-off-by: AngeloGioacchino Del Regno < >> angelogioacchino.delregno@collabora.com> >> Reviewed-by: Jason-JH.Lin <jason-jh.lin@mediatek.com> >> --- >> drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 13 ++++++++----- >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c >> b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c >> index 60ccea8c1e1a..1592614b6de7 100644 >> --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c >> +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c >> @@ -71,12 +71,12 @@ unsigned int mtk_gamma_get_lut_size(struct device >> *dev) >> 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); >> - unsigned int i, reg; >> + unsigned int i; >> struct drm_color_lut *lut; >> void __iomem *lut_base; >> bool lut_diff; >> u16 lut_size; >> - u32 word; >> + u32 cfg_val, word; >> >> /* If there's no gamma lut there's nothing to do here. */ >> if (!state->gamma_lut) >> @@ -90,9 +90,7 @@ void mtk_gamma_set_common(struct device *dev, void >> __iomem *regs, struct drm_crt >> lut_size = LUT_SIZE_DEFAULT; >> } >> >> - reg = readl(regs + DISP_GAMMA_CFG); >> - reg = reg | GAMMA_LUT_EN; >> - writel(reg, regs + DISP_GAMMA_CFG); >> + cfg_val = readl(regs + DISP_GAMMA_CFG); >> lut_base = regs + DISP_GAMMA_LUT; >> lut = (struct drm_color_lut *)state->gamma_lut->data; >> for (i = 0; i < lut_size; i++) { >> @@ -122,6 +120,11 @@ void mtk_gamma_set_common(struct device *dev, >> void __iomem *regs, struct drm_crt >> } >> writel(word, (lut_base + i * 4)); >> } >> + >> + /* Enable the gamma table */ >> + cfg_val = cfg_val | GAMMA_LUT_EN; >> + >> + writel(cfg_val, regs + DISP_GAMMA_CFG); >> } >> >> void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state) >> -- >> 2.40.1 >>
Hi, Angelo: On Mon, 2023-05-22 at 14:25 +0200, AngeloGioacchino Del Regno wrote: > External email : Please do not click links or open attachments until > you have verified the sender or the content. > > > Il 22/05/23 12:00, CK Hu (胡俊光) ha scritto: > > Hi, Angelo: > > > > On Thu, 2023-05-18 at 12:48 +0200, AngeloGioacchino Del Regno > > wrote: > > > External email : Please do not click links or open attachments > > > until > > > you have verified the sender or the content. > > > > > > > > > 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. > > > > I think user could update the lut table frequently, so when do you > > disable the gamma function before next update? In addition, if we > > really care the glitches, update the register in vblank period > > which > > should use cmdq to update the register. But now, I think we do not > > care > > the glitches. You may skip this patch, or fix the problem I > > mention. > > > > If you disable the GAMMA function (either set RELAY mode or disable > the > GAMMA_LUT_EN bit in GAMMA_CFG), there will be glitches during setting > via > the GNOME Night Mode color temperature slider. > > This commit prevents a glitch in the case in which the GAMMA LUT > registers > are not zeroed before setting the expected LUT, for which reason I > disagree > about skipping this patch. > > Please note that, while I agree about updating the GAMMA LUT through > CMDQ > setting and between vblanks, this requires a lot more effort to > implement > and it's out of scope for this specific series; depending on my > bandwidth, > this may come later and it would in any case require this patch to > move > the LUT enablement to after LUT registers setting. Besides, I have > already > tried to enable this through CMDQ, but didn't work as expected and > since I > had no time to dig further, I deemed this to be essential for at > least an > initial functionality implementation for MT8195, and a cleanup of > this > driver. > Obviously, the *only* way to fix *all* of the corner cases of the > problem > that you mentioned is to use CMDQ and trying to implement this purely > with > cpu writes will in any case be prone to at least some glitches. > > In any case, while your concern is valid, I'm sure that you agree > with me > on the fact that enabling the LUT before actually programming it is > something > that should not happen in principle. For this reason, and for the > others that > I've just mentioned, I think that this patch is totally valid. OK. So please add these comment to patch description so that we could know there is something to do. Regards, CK > > Regards, > Angelo > > > Regards, > > CK > > > > > > > > Signed-off-by: AngeloGioacchino Del Regno < > > > angelogioacchino.delregno@collabora.com> > > > Reviewed-by: Jason-JH.Lin <jason-jh.lin@mediatek.com> > > > --- > > > drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 13 ++++++++----- > > > 1 file changed, 8 insertions(+), 5 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c > > > b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c > > > index 60ccea8c1e1a..1592614b6de7 100644 > > > --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c > > > +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c > > > @@ -71,12 +71,12 @@ unsigned int mtk_gamma_get_lut_size(struct > > > device > > > *dev) > > > 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); > > > - unsigned int i, reg; > > > + unsigned int i; > > > struct drm_color_lut *lut; > > > void __iomem *lut_base; > > > bool lut_diff; > > > u16 lut_size; > > > - u32 word; > > > + u32 cfg_val, word; > > > > > > /* If there's no gamma lut there's nothing to do here. > > > */ > > > if (!state->gamma_lut) > > > @@ -90,9 +90,7 @@ void mtk_gamma_set_common(struct device *dev, > > > void > > > __iomem *regs, struct drm_crt > > > lut_size = LUT_SIZE_DEFAULT; > > > } > > > > > > - reg = readl(regs + DISP_GAMMA_CFG); > > > - reg = reg | GAMMA_LUT_EN; > > > - writel(reg, regs + DISP_GAMMA_CFG); > > > + cfg_val = readl(regs + DISP_GAMMA_CFG); > > > lut_base = regs + DISP_GAMMA_LUT; > > > lut = (struct drm_color_lut *)state->gamma_lut->data; > > > for (i = 0; i < lut_size; i++) { > > > @@ -122,6 +120,11 @@ void mtk_gamma_set_common(struct device > > > *dev, > > > void __iomem *regs, struct drm_crt > > > } > > > writel(word, (lut_base + i * 4)); > > > } > > > + > > > + /* Enable the gamma table */ > > > + cfg_val = cfg_val | GAMMA_LUT_EN; > > > + > > > + writel(cfg_val, regs + DISP_GAMMA_CFG); > > > } > > > > > > void mtk_gamma_set(struct device *dev, struct drm_crtc_state > > > *state) > > > -- > > > 2.40.1 > > > > >
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 60ccea8c1e1a..1592614b6de7 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -71,12 +71,12 @@ unsigned int mtk_gamma_get_lut_size(struct device *dev) 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); - unsigned int i, reg; + unsigned int i; struct drm_color_lut *lut; void __iomem *lut_base; bool lut_diff; u16 lut_size; - u32 word; + u32 cfg_val, word; /* If there's no gamma lut there's nothing to do here. */ if (!state->gamma_lut) @@ -90,9 +90,7 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt lut_size = LUT_SIZE_DEFAULT; } - reg = readl(regs + DISP_GAMMA_CFG); - reg = reg | GAMMA_LUT_EN; - writel(reg, regs + DISP_GAMMA_CFG); + cfg_val = readl(regs + DISP_GAMMA_CFG); lut_base = regs + DISP_GAMMA_LUT; lut = (struct drm_color_lut *)state->gamma_lut->data; for (i = 0; i < lut_size; i++) { @@ -122,6 +120,11 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt } writel(word, (lut_base + i * 4)); } + + /* Enable the gamma table */ + cfg_val = cfg_val | GAMMA_LUT_EN; + + writel(cfg_val, regs + DISP_GAMMA_CFG); } void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)