From patchwork Thu Jun 1 12:10:16 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: 101915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp272207vqr; Thu, 1 Jun 2023 05:12:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5A9arQnUd2Cn872yy19IlOJyVUIQGv/fP5A7pPFwyypXQoA38Zesr87ypEiAWkhcmjMiRX X-Received: by 2002:a05:6a00:15ca:b0:64f:e997:50fc with SMTP id o10-20020a056a0015ca00b0064fe99750fcmr7870200pfu.2.1685621578724; Thu, 01 Jun 2023 05:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685621578; cv=none; d=google.com; s=arc-20160816; b=bSiHXwAQ2fjw+b3miLTqXt2F+c+Vh3NncQZfhZlyak6fGKWBBlzbcaBie/z2VGTFco pIqe4Ke/CgQNwhJ6p6hbMkBv8JMsf6yIf8+cGDE03CUSf/sld3zRCjBe6sfEc1qo0Xo4 /XmXhKjTOOnZZawmM4Qvxq+kS8GCSChtAj+Fu4UqAdG1ibprCm9bNrmvzD1ZMiyPsbYC GVzyfCRMy8ovJebrPIeexXW+JDbz2p1YLsT5LBgcmEws+Y1SxnxNnPC8Pxfp2neqPhmp vPsUGkkDgMbhj3Zzr2Ao8LRComci/BJRt55K1uKJPb/13rvWl1qh8Djdkn+rGI2K/Dxe csdQ== 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=; b=I4g6XuT6JX2IkIDEejiE3MmN8oukW8Ltuw17ex1zu/Tup2kg3pkZyZPvSRl8gwti1z P1PRyVbVrmO5xRXabceT/6U5Lrx31uuvajb2hdiG4sBfEcBowOMp3+ce0oTUzkytc8w3 I+gM43d4V/cbrnX5V6JqxwZLMjpde4P+8Pixx1xFUyMR5gNkuw2BSSzGm0Ij35LWcJkR tqfd+dYAWv3Az7YE/ZXxHUQsixqCY2kQTsxfHeV9Q7IQq/UpvQgRtwAmYsc8EuFtxodJ tem5XYe75fSwhSBA1or3llHOYo0zv8VBK4XdZs6ABNs0ZRxrQPWiwB511iLIDeLTQs3n S1PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZLfRxmI2; 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 f28-20020aa79d9c000000b0063b52b9a8f5si5415936pfq.267.2023.06.01.05.12.46; Thu, 01 Jun 2023 05:12:58 -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=ZLfRxmI2; 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 S232605AbjFAMLJ (ORCPT + 99 others); Thu, 1 Jun 2023 08:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233324AbjFAMKp (ORCPT ); Thu, 1 Jun 2023 08:10:45 -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 3DA5E19D for ; Thu, 1 Jun 2023 05:10:33 -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 3F0376606EC9; Thu, 1 Jun 2023 13:10:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1685621432; bh=IbtbZnmCWfYYE0XVFaNK/WT77zqaqxGqnAMw0WmBnlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZLfRxmI2i2kajRuBE6YRfMNVdSDH9ZwpoAcw6EI19EPsRNdvWQy612KE0SPQ10pVy I+buzzmD29GVm7Bp1yrURkuadQhRbAXwLIGiDtWoymlh5iFtNq8rC/GXrOFyiB4Bmy YKwgGBQh9p+Kl4AQ8t7z/UGwxWjHfDOvMJKCpogX2oySNloDGUhP5JnCcVTCw06NWE PfTPx972jDklYMTNkFd0+jVQa7qyzc+u6haMNVlPIgobpc5b1x1Mfb+zICbItCnRNu lXGCDU+9wqVtAz/8iKFA5g1C/YR6MANix0/iZDYxIEW+tCcjMwOt/eohoYYt3X8Obl zoW0rFJ2SrZ5Q== 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, "Jason-JH . Lin" Subject: [PATCH v5 05/11] drm/mediatek: gamma: Enable the Gamma LUT table only after programming Date: Thu, 1 Jun 2023 14:10:16 +0200 Message-Id: <20230601121022.2401844-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601121022.2401844-1-angelogioacchino.delregno@collabora.com> References: <20230601121022.2401844-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767502332376766794?= X-GMAIL-MSGID: =?utf-8?q?1767502332376766794?= 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)