Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2204650rwb; Thu, 27 Jul 2023 03:57:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlG9jM9i8JMU8o17IBY99MOJAu3Yz+LFKU96vTpuHYbQI7bcA4MNbU8aHFgYm+Y0SySCYjdp X-Received: by 2002:a17:902:b102:b0:1b8:9b1b:ae8e with SMTP id q2-20020a170902b10200b001b89b1bae8emr3605621plr.59.1690455461404; Thu, 27 Jul 2023 03:57:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690455461; cv=none; d=google.com; s=arc-20160816; b=jVtPTFbAScJ453352yMU+yyNwYVdbyYe/yqXOcRkSqNfIqUUv8xzdv7/3IyXVKWvoF +OfwTrfkF0om7mRdM43Z+QrbYtks+MQtX87UA3WjtSE4ZBYAsnvq50xttHp96J+xeYFh Itds6NnlPZdItqAmCpBQ1eph+eSyvBatiht1Ry9lSgqddrv7V9J/HLYuTSuf/CpJOxA+ VUobgiVMgq8+gaAsiTYHcHGVR8/sdff2zEAQ0qsV3OJZL2tMv1qWc8H+GqWf2tkNsfvu sNfrRcb+EKXsRV0wL9yIg8RFGv2atZS3F+cqi74Jg0w70sug9mbIbTjdED6AT9O5hjun DEVg== 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=B1lo3slqA2jkb8lxv13avUe75yDHWW3lfw5fd2eIIik=; fh=djell8ixvcyqU/mJ6veJqcbgRwD4nTeRiXMTlgu2sHI=; b=o0TfKJDRb4ylZk3UUzhEQMZQAatG7QpiY000RkHWTV5BQLrO3adT3XBfEOokQfzpNY yr14DODABfuoXXu7xaFLZXYUS2OqWApPxPX107odmdxhYV7zKQ7p+xnR2RsvnQsZwXF1 eMBkOBqY0t19cox1GeUfK78PCUtkOg0q1gWhYgGl96N1YJ0jiDsb90spU+gvNQg0UsHp 24np2sdq9LQbFW1n02AyHvySt3pPmhW03/yyjxaogu/sOwxIiqE1eBzdDxXRDGq0Bzqc Ko0mBzjd8+NwdM6d4SfVCjscLlbyrbc1akEdpe+sJnW+TMyh5MiID1NxelUzXFuunLPE t02w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=FTiasmgu; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a170902e5c800b001aff514a8f0si1206956plf.534.2023.07.27.03.57.27; Thu, 27 Jul 2023 03:57:41 -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=FTiasmgu; 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 S232947AbjG0Jq7 (ORCPT + 99 others); Thu, 27 Jul 2023 05:46:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232001AbjG0Jqs (ORCPT ); Thu, 27 Jul 2023 05:46:48 -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 EEA30A3 for ; Thu, 27 Jul 2023 02:46:43 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (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 0D23A660702D; Thu, 27 Jul 2023 10:46:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690451202; bh=IbtbZnmCWfYYE0XVFaNK/WT77zqaqxGqnAMw0WmBnlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FTiasmguwHtP8vwFf4YufBs3BGGM/m2n23IQPEZEBcnTMcckT6z06NKiYdJEQRMFB EkUyer8IE6m0NOog+YzC4cT2HtbeVxHiu2eXFmhwPhToPfYniskiTFQVoMBpnWROyC nGG//ekA/cCBfMcbx78Byz0itkVF5XqAjXFHvt0+j5+QCnYbK/V1qr0UF/vsiIa1Ho SDoK27mIbK4tqk+fiZ44rSSenWf+6oBlIp1VKQ2z2txhxxuXQaJoVvJZwIkFzAVnMd BDRnRgE6WXJUqbISxa63n1Inv/ws9Glaq70hy+ByBnveyZk7uaLnYv2nX/bLkEWtby AdJ+SzUn1V44w== 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, ehristev@collabora.com, "Jason-JH . Lin" Subject: [PATCH RESEND v6 05/11] drm/mediatek: gamma: Enable the Gamma LUT table only after programming Date: Thu, 27 Jul 2023 11:46:27 +0200 Message-ID: <20230727094633.22505-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727094633.22505-1-angelogioacchino.delregno@collabora.com> References: <20230727094633.22505-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: X-Mailing-List: linux-kernel@vger.kernel.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. Note: GAMMA should get enabled in between vblanks, but this requires many efforts in order to make this happen, as that requires migrating all of the writes to make use of CMDQ instead of cpu writes and that's not trivial. For this reason, this patch only moves the LUT enable. The CMDQ rework will come at a later time. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Jason-JH.Lin --- 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 204a1aa7bfc9..b75a77af5205 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