From patchwork Mon Jul 31 13:04:33 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: 128680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2013967vqg; Mon, 31 Jul 2023 06:26:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlHlkqsYU94wdDlnNBFq3w9jRakped8F+oyfDcb/J7aM3DkqspxMzaXPJkWk2hqU7T9ZZRPI X-Received: by 2002:a17:902:c94f:b0:1ae:6947:e63b with SMTP id i15-20020a170902c94f00b001ae6947e63bmr11887381pla.16.1690810007667; Mon, 31 Jul 2023 06:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690810007; cv=none; d=google.com; s=arc-20160816; b=zomJFLwn3DltLA520N1vIIHr49k2laiTpX8kUPL/dQTN3kow1kiBUb/fZRwu0H0vFA xJUrqUEX0ulkEoOtUj5Jkkgg+6h/bG4LQaHw4OLc57ep/c3A+EDoM2jslAk54Qsf0Jpf CwqUMB1kvyD7XrDvLkpPLladqDJiljW30psRG+XUAS2HGUgMYtBAd+ORuAFApGWNh2Fs 8Q46CP5OPdg49Gezz4JA5bfv7ueMr9+OdbOUDb0Sz41vk/CuQ0cTzEpeK9vJInKFvWok /8X5xPE+5I1P9jnbf8/60LKuRvLtr1wpRsDqOtbxqgXFE+GMngg+4lGyROVw3yCB9iZ7 Hegw== 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=dm6Nc3M0XahRr5SgCwL2z7cNin/dAvbdfmHjVdvJV98=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=eWtXc2H6XlNcMeBJAjFrN8z4GI+0sPqUZyAuZfsSIK8X+B6IAOUXr8Yq/y/JDr6P8U OHX/L+JEsmsZaF9ehzLT1XetVzRtb2Gb/wc9Jii1b8AjFLnG4WHvoI4NDRKnRvixl/Rq F0zfzo/W8VptdBoufJRmzxVFkP7THPpLc2V8KttxW06xx5sv5PiUsZgXlXX/+Eh1fKaH Imh8VGSwbl7jMPf0Rt8LdIDc7ShYgUVj0dlS+1HQ7Nwr3uaCrlPsi7v/F3iduut7Vy2Z x9kHXHQXKcNLj3pI0cFDABD0vZWgqX4zxyWghmIU+2Jsx6tli+EgZecr8lE4gXCHZG6y I8VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=gOw9PS5P; 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 jz14-20020a170903430e00b001b53c722c3fsi51079plb.597.2023.07.31.06.26.33; Mon, 31 Jul 2023 06:26:47 -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=gOw9PS5P; 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 S230314AbjGaNFG (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231626AbjGaNEw (ORCPT ); Mon, 31 Jul 2023 09:04:52 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A766210EB for ; Mon, 31 Jul 2023 06:04:51 -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 B31C2660710D; Mon, 31 Jul 2023 14:04:49 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808690; bh=jQ1ukxJYhgqz3VRiaaOzbMrQXLA2ENp1Hjs7vpajFxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gOw9PS5P/p8lyy95aWK13qA0Y9of/ZPlfhrniaS/yKcPm4KtAgyLt+fU4K61ORRXA 9BmaNiyohXn7igHtssMjEOZAVbth9fptvV0sQ2IlkGNIKTIEC1KkD2Mh3CLqW5cj0y GIeSHH3aRYBPn3hKCkwu6br1J7ZdPS1lDc/rXSiOrabR3G58Xgg4zdT9LMcu2lwTCg QRc++U3T0wj+AzVv/ll0ScPNbkU9CSHZNcr+LPq6A5Kq2ynPQdV26jVaxA+eH5h/To 2GhIIqusCzsnu0rNF22+RJd29t6XpaPw3ATd0IDEFZPurtcbauLryMOJqrPG0Kz5ao Do6qUfPfnOdVg== 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" , Alexandre Mergnat Subject: [PATCH v7 05/13] drm/mediatek: gamma: Enable the Gamma LUT table only after programming Date: Mon, 31 Jul 2023 15:04:33 +0200 Message-ID: <20230731130441.173960-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731130441.173960-1-angelogioacchino.delregno@collabora.com> References: <20230731130441.173960-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772942795006598769 X-GMAIL-MSGID: 1772942795006598769 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 Reviewed-by: Alexandre Mergnat --- 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 fd6a75a64a9f..18b102bef370 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -68,12 +68,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; - 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)