From patchwork Tue May 2 08:16:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13228585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A52B5C77B73 for ; Tue, 2 May 2023 08:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=F/KKE3ARIKoRXOzNKzyCPtcBEpbXy4duBWpEhsOeW2w=; b=Y4y+a1h5jQKk4s 5u+/nkCyC6MCFcFpIfqiscfyRsPH33nbXUU2isiDOAfi/gYg5u8e+OpQxz1QxuNDCscVdogy9sGi0 I5nv/VVnMvRePAPxNv4uXpMGKsWjmQB53XksmdA//Rm/kdCMUn9GbC7fGVan9aeo/VTgQ3vYzjQPS BLKTC25tEnTVCEh+qpgPiXBr0j8YEmEkQjg04/S+t93MRNbUgB5PF29nsRi9w1aRpgvLlxlgsR4QS BqyQmLYVgzPtW6PVnYZURSxvQKFE6rWU0YkpLCAEXDiKseNmYHf9yF2XkXoFoeu320GBDMKh4BDly wdDQOn/kGMwca/LWZODQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ptlCF-000a81-22; Tue, 02 May 2023 08:17:15 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ptlC5-000Zxp-11; Tue, 02 May 2023 08:17:06 +0000 Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (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 447746605639; Tue, 2 May 2023 09:17:00 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1683015421; bh=8+9JcA6Zz4WvK9lPx0N0XFAnJhjeuRVOIbom2ZpVRzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EdNVEbGZ5kSwKYSkLczpI3HPvthLI3xnLOtP9r0GuPz7Kzr2aElDzhdbfiJG1SYkO sePiv39k8qQYy2cFMA/9G6/BUcq/mDj+s4p5jKWorpOThL0HVUCtl/mpok9VcDEbrn Hr+fYnSsEZm2iplKDBO1Y0BqklbwZOcE8REUzfmX+C96SiYV2lr3RwJah/FVL9frnD jboEVF1sG3V7kd0riArx7Irh3IrA6TV9kK0+ddgeoRjzslNWrvQkY1CRlNVa21yeqk gMZZl66jf0qXeAbHj+FpdDemCtF0UnieJTZ8wbu1tPYHcj0/u2xQ/l8vMAH9+EPC7X byoc6qMfIbhTQ== From: AngeloGioacchino Del Regno 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 Subject: [PATCH 05/11] drm/mediatek: gamma: Enable the Gamma LUT table only after programming Date: Tue, 2 May 2023 10:16:44 +0200 Message-Id: <20230502081650.25947-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230502081650.25947-1-angelogioacchino.delregno@collabora.com> References: <20230502081650.25947-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230502_011705_486772_CE7AC930 X-CRM114-Status: GOOD ( 13.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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 89a1640c2e8f..97b34963ef73 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)