From patchwork Mon Jul 31 13:04:29 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: 128676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2013534vqg; Mon, 31 Jul 2023 06:26:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlFNOjTe7gJmZM39VbGb3iz1hrTR92Vxl4MSg7mx80yc45R/3ZZ8ycRxpWO+1TZftr9aNc4N X-Received: by 2002:a9d:6a16:0:b0:6b8:79e6:a2ba with SMTP id g22-20020a9d6a16000000b006b879e6a2bamr9434160otn.25.1690809960441; Mon, 31 Jul 2023 06:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690809960; cv=none; d=google.com; s=arc-20160816; b=OVThR/FSZhfFVDnFvAfcjaJ8VgiVANbwVlJ5I+6KNL3tUfFOCXmLOEPPG0fTJrHOuz MT08YvWtQ13gdZAorrSncVRxXANLVp0/4XSR680qkOT3uOTbZ3sbWs5QcNxexF/lPsEX iU/bzasrLoutC/LV77tt/5k7T8swiSz07WSg97S5q/NuVw1yVGdH9Z3DGm2b3OmVNZng D6IXMkSoXItIw2fp9G9Em/16PBKAA3XhOwDCiPNYQ6wI3iwYnFXgA/vvDrj5ikMZwR1z JkSer7YK8dKXzoqn2tTZIBhIGz6AgT8GOqJqtKfOoxVwujXVfK43he1xGDPH3D6blaCu cVLg== 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=qNF4mo6j/sr2H/XkAsr/xbNiamMSN0ztDQJtRgYEuS4=; fh=gdyVfTReZam6BHfFvmjIYWDSfE6dT3OdouNqzuwswZM=; b=aYeN3/eI/XvEsBPjmGfbJ/fSdbN5qJlL+dML+WMuZtd3vOaGv+L7kIaewitg881nXj fF2aDPfVy8uAo5VTLUBvaTqqVQCQINd+wwLtgkCusyrpc6YaLObQMkpLLJAC3UJ0uXc8 h96u4zz4YM912Wtu2/tF5PwZkdFoSafg2mxq7g/cExQsp++4On/knOzjNVVZdUrt7P/t YmBFfT3v8HINjCu96JYDfomU83F6U6Yq/IGuGJPJR5oH1u/Mor48suCoc2KnmmJ/W7DJ zOXdVeXb+Zn+GeE+sc7n2RPeaJgs3j9uufJo/8G6l18yIWqc/bDV6kxtX0p6392MVjT0 xoOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=OtmQQL+X; 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 j10-20020a63230a000000b005575a066782si7058317pgj.255.2023.07.31.06.25.46; Mon, 31 Jul 2023 06:26:00 -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=OtmQQL+X; 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 S232095AbjGaNEx (ORCPT + 99 others); Mon, 31 Jul 2023 09:04:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231453AbjGaNEt (ORCPT ); Mon, 31 Jul 2023 09:04:49 -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 08E3D10E9 for ; Mon, 31 Jul 2023 06:04:48 -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 F02CB6606FCD; Mon, 31 Jul 2023 14:04:45 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808686; bh=yEFNmriytfzFlnNR03nQnEhTvtOxc2/EEUJg2NG5628=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OtmQQL+XpI7BW6TN4SDxP70Jz6+P0pcn8Y2VumodGS0FgBRC8PiSbnqNdaKGJjdHd Ux23Lyln6vT2/Oca42FVswayUMKCiIp3QjzTYg7xbtADpnZ1U8Gif+rFanN86p+6pP P9wjixqsOBb7Mln7SaPRSyXL90iHJX+tDyLK1gRzUBfh3k8xZDPuHWXN7f8StaOlbB suA3P1T4nOd+w6+yltafI5WY/FiKevMwJXgQacTnkmK3QE2BEGRfqXwWaRl6ueFYBm HQneAQYlqnN5F8kd/Oxaza/jLd82mIPJli4t8/njg+M8GALgAOrxm1FwxYtOf/pjon iW5+U1nfsn9zg== 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 01/13] drm/mediatek: gamma: Adjust mtk_drm_gamma_set_common parameters Date: Mon, 31 Jul 2023 15:04:29 +0200 Message-ID: <20230731130441.173960-2-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,RCVD_IN_DNSWL_BLOCKED, 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: 1772942744875886186 X-GMAIL-MSGID: 1772942744875886186 From: "Jason-JH.Lin" Adjust the parameters in mtk_drm_gamma_set_common() - add (struct device *dev) to get lut_diff from gamma's driver data - remove (bool lut_diff) and use false as default value in the function Signed-off-by: Jason-JH.Lin Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_aal.c | 2 +- drivers/gpu/drm/mediatek/mtk_disp_drv.h | 2 +- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_aal.c b/drivers/gpu/drm/mediatek/mtk_disp_aal.c index cdbec79474d1..2f602f1f1c49 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_aal.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_aal.c @@ -66,7 +66,7 @@ void mtk_aal_gamma_set(struct device *dev, struct drm_crtc_state *state) struct mtk_disp_aal *aal = dev_get_drvdata(dev); if (aal->data && aal->data->has_gamma) - mtk_gamma_set_common(aal->regs, state, false); + mtk_gamma_set_common(NULL, aal->regs, state); } void mtk_aal_start(struct device *dev) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/mediatek/mtk_disp_drv.h index 2254038519e1..75045932353e 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h @@ -54,7 +54,7 @@ void mtk_gamma_config(struct device *dev, unsigned int w, unsigned int h, unsigned int vrefresh, unsigned int bpc, struct cmdq_pkt *cmdq_pkt); void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state); -void mtk_gamma_set_common(void __iomem *regs, struct drm_crtc_state *state, bool lut_diff); +void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crtc_state *state); void mtk_gamma_start(struct device *dev); void mtk_gamma_stop(struct device *dev); diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 7746dceadb20..d42cc0698d83 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -54,14 +54,24 @@ void mtk_gamma_clk_disable(struct device *dev) clk_disable_unprepare(gamma->clk); } -void mtk_gamma_set_common(void __iomem *regs, struct drm_crtc_state *state, bool lut_diff) +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; struct drm_color_lut *lut; void __iomem *lut_base; + bool lut_diff; u32 word; u32 diff[3] = {0}; + /* If we're called from AAL, dev is NULL */ + gamma = dev ? dev_get_drvdata(dev) : NULL; + + if (gamma && gamma->data) + lut_diff = gamma->data->lut_diff; + else + lut_diff = false; + if (state->gamma_lut) { reg = readl(regs + DISP_GAMMA_CFG); reg = reg | GAMMA_LUT_EN; @@ -91,12 +101,8 @@ void mtk_gamma_set_common(void __iomem *regs, struct drm_crtc_state *state, bool void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state) { struct mtk_disp_gamma *gamma = dev_get_drvdata(dev); - bool lut_diff = false; - - if (gamma->data) - lut_diff = gamma->data->lut_diff; - mtk_gamma_set_common(gamma->regs, state, lut_diff); + mtk_gamma_set_common(dev, gamma->regs, state); } void mtk_gamma_config(struct device *dev, unsigned int w, From patchwork Mon Jul 31 13:04:30 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: 128691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2023943vqg; Mon, 31 Jul 2023 06:44:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHCF1M2qcqMcGMgwXbBWBxB4eaIVL/nCIJcf4C00A+YhWrIm0hQ9tLrCPsmdUEe56J3NJUN X-Received: by 2002:aa7:df8b:0:b0:51d:9ddf:f0f3 with SMTP id b11-20020aa7df8b000000b0051d9ddff0f3mr7381710edy.31.1690811057536; Mon, 31 Jul 2023 06:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690811057; cv=none; d=google.com; s=arc-20160816; b=ZuKMTckje4LHgwz8LH2/e0s1poyNd162kuFFlocsj6HWieIAepR0UgNpfJoDEaiUlP HHPvxLK1WaTZMMbDe1xQJ3JDV4f8Cl5nkXcguwrB6SXXqFAcAut82dkFYCubjEgCQCdh j34lTlrPm1S3GS3OgpPhEATP2GVFFA/nkJv1Zz2MSpfsZoijlWvmC3gItXzDKmkEbgmw WYq7VIc6TkShlnip8EBa8wOCY21C4jrPjqguXu13WVJbbrGGZgfYdSj0b5RPePFOPtJm knMd/o4zFng3oMjFcKdH6+dwcsMx6TzIbQsOnuY9zPDKQhBjGF+fpCRU/Um+8MlHTDNv vmig== 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=QxtRWSpYyOj5LmE/Q+Bsip++G5zdnJCcTZ/on+0LwCA=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=iu/M0BzWQGyNzpIIh8iPv+HmEwXuPt4stJSEYVx3VM9thqEceQrnTuy72Jbs7Qshfu r+WKO0a6sjCCaBgvYCSZdvppRQF/Ahp6zwmZ/vdgopOVPISms3EmF2eLYHpr3ocTzW8R iGDkg4SYEOkxRKZrddltUSjsy+5ppN+vuN4O7rn1Hvcqmp8HHRZYCP4zcv8gS/YuFRBP Xw4yYziuPGLgNH/EZLKb94sJLdvXFPs/lnJ5HvO1/Hwj5HIXfxjbsPya3oS3j0PemG/N d3Ef+XPi5miShfo0HPqTYpsPbK5d/kDwD+DYdPAFfqhgraOp54qNhMV7cwF/bXl55xF7 EwWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=l8c1y3zC; 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 w12-20020a056402070c00b005222005e36dsi5867493edx.124.2023.07.31.06.43.53; Mon, 31 Jul 2023 06:44:17 -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=l8c1y3zC; 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 S232494AbjGaNEz (ORCPT + 99 others); Mon, 31 Jul 2023 09:04:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230365AbjGaNEt (ORCPT ); Mon, 31 Jul 2023 09:04:49 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0028B0 for ; Mon, 31 Jul 2023 06:04:48 -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 E11856606FD9; Mon, 31 Jul 2023 14:04:46 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808687; bh=kYeyT6HbEedO1YRPTVJsJxzagOYrnms3xwsfF+B40oU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l8c1y3zC/lWm5krDtOFSjzYWODsuXyoNNopnvjbO7aBCMCugzrO995ZfSXjAjNhlF pl0YV5ygpXOzlu/PDQ8V6uUzPYS+zsHjfETwH17XzNI26oTpX8+fK+x0ZRKoFgAeVU yNX83VBuJiBYji/nN4D01cBhIQMNGxKeWZQBLoHnPVnsAdGuMQSRHtC1OiYNtEKDMR jN3qSLPiYV5c+fz/iw8yC3/g4WnhIhJXGfY/vxkZtvZ0EESlL/12dsUL89jA2trBo0 QgYQSr3m4ER4WiGvjFH2MLPgeLPa3nAsEBtkNRiWbiLkYOXL53Gn5iiq8pcZ+oOvh5 0KkP4TMVa1XhA== 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 02/13] drm/mediatek: gamma: Reduce indentation in mtk_gamma_set_common() Date: Mon, 31 Jul 2023 15:04:30 +0200 Message-ID: <20230731130441.173960-3-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: 1772943895339903870 X-GMAIL-MSGID: 1772943895339903870 Invert the check for state->gamma_lut and move it at the beginning of the function to reduce indentation: this prepares the code for keeping readability on later additions. This commit brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Jason-JH.Lin Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 45 ++++++++++++----------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index d42cc0698d83..47751864bd5c 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -64,6 +64,10 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt u32 word; u32 diff[3] = {0}; + /* If there's no gamma lut there's nothing to do here. */ + if (!state->gamma_lut) + return; + /* If we're called from AAL, dev is NULL */ gamma = dev ? dev_get_drvdata(dev) : NULL; @@ -72,29 +76,26 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt else lut_diff = false; - if (state->gamma_lut) { - reg = readl(regs + DISP_GAMMA_CFG); - reg = reg | GAMMA_LUT_EN; - writel(reg, regs + DISP_GAMMA_CFG); - lut_base = regs + DISP_GAMMA_LUT; - lut = (struct drm_color_lut *)state->gamma_lut->data; - for (i = 0; i < MTK_LUT_SIZE; i++) { - - if (!lut_diff || (i % 2 == 0)) { - word = (((lut[i].red >> 6) & LUT_10BIT_MASK) << 20) + - (((lut[i].green >> 6) & LUT_10BIT_MASK) << 10) + - ((lut[i].blue >> 6) & LUT_10BIT_MASK); - } else { - diff[0] = (lut[i].red >> 6) - (lut[i - 1].red >> 6); - diff[1] = (lut[i].green >> 6) - (lut[i - 1].green >> 6); - diff[2] = (lut[i].blue >> 6) - (lut[i - 1].blue >> 6); - - word = ((diff[0] & LUT_10BIT_MASK) << 20) + - ((diff[1] & LUT_10BIT_MASK) << 10) + - (diff[2] & LUT_10BIT_MASK); - } - writel(word, (lut_base + i * 4)); + reg = readl(regs + DISP_GAMMA_CFG); + reg = reg | GAMMA_LUT_EN; + writel(reg, regs + DISP_GAMMA_CFG); + lut_base = regs + DISP_GAMMA_LUT; + lut = (struct drm_color_lut *)state->gamma_lut->data; + for (i = 0; i < MTK_LUT_SIZE; i++) { + if (!lut_diff || (i % 2 == 0)) { + word = (((lut[i].red >> 6) & LUT_10BIT_MASK) << 20) + + (((lut[i].green >> 6) & LUT_10BIT_MASK) << 10) + + ((lut[i].blue >> 6) & LUT_10BIT_MASK); + } else { + diff[0] = (lut[i].red >> 6) - (lut[i - 1].red >> 6); + diff[1] = (lut[i].green >> 6) - (lut[i - 1].green >> 6); + diff[2] = (lut[i].blue >> 6) - (lut[i - 1].blue >> 6); + + word = ((diff[0] & LUT_10BIT_MASK) << 20) + + ((diff[1] & LUT_10BIT_MASK) << 10) + + (diff[2] & LUT_10BIT_MASK); } + writel(word, (lut_base + i * 4)); } } From patchwork Mon Jul 31 13:04:31 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: 128684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2015049vqg; Mon, 31 Jul 2023 06:28:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlEwDUtpxz6ZrFuCkhCyVZe1S4YlcXXXm5rYms+CBTd1TvdOQdj+bclIkTFb1cNOvp9+HfLC X-Received: by 2002:a17:902:aa41:b0:1bb:c7c6:3454 with SMTP id c1-20020a170902aa4100b001bbc7c63454mr8518410plr.48.1690810134524; Mon, 31 Jul 2023 06:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690810134; cv=none; d=google.com; s=arc-20160816; b=VF9uj/uKXIe7vXjmoV9bDA+bTulhxL5msEFAQ34nVfCikH88tMiD0XtVbYv3DRni5h Wwp+RRIlA8lsoXfy1gel4c3IEVQSmWCgD7uojjpIaLaESLY0v/6LZ/DReDAR+VOLcptx 0z8YHWwKq1ecK1X/pv4d+o0IFJvVABJQBu/7Yrl1M2MZQcathPw8z0eLGcK/AFkBp4jL UfKFe0lE+5WZfICIpFzQ7z/hAdhTGfSlY9vpWlFzMyXrINNV7nW1NcOSvqhrxVV+HQHa OsBxo/Juq6bsdGEX7+DXhyeSINo/m7pQouGDW2tnI8nsdqb97PVjnPi8yF9B2x9oe4/d gONg== 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=MY9lb1xK+lPvmtApb4D05N5/rllUxBXNetH8DwmCWro=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=R+m1y4OiDhDIU2R0rZXY9Cy07v8UJ9fJ+8/WjmXJ7zPrpyXHY8lq5GrMxRvr7dYljo jxJeLDB+PZ3i38KYMfuNJTPAqf5y0KFUe3lZvtDO+rn7GTlDYsk3XS3MyP+5KuVHrzdL dGZXTYQb580nyx9K47UZdTS+XHkVEQ+nDpSL2Vs7Cmrjyn6LIi1xCH7l5Bb1afOIlsg7 nAppj1+t1TJKL6hrPF/Z8DtY3m9Xxv3qyqzyAKJkngqGYX5hOgomt1PKFPrl/nHzJbqD fedtobj7uJYPIUK6NUk3TApo9MapBKV0E2ZcLIFZsb0d5Yp0o7yWtvOpr27T8sGdDuNN OHAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lV5WgdN1; 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 e5-20020a17090301c500b001bb9d4dc202si7675780plh.49.2023.07.31.06.28.41; Mon, 31 Jul 2023 06:28:54 -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=lV5WgdN1; 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 S231894AbjGaNFA (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbjGaNEv (ORCPT ); Mon, 31 Jul 2023 09:04:51 -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 C471210E3 for ; Mon, 31 Jul 2023 06:04:49 -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 D1AAE66070F7; Mon, 31 Jul 2023 14:04:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808688; bh=dRCUBSAJhyuAuYLj+KM0no1asegc1IsekM6rzVKVlw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lV5WgdN1JlNDhedIKv1Q2b34sNqF7+DiDQRxpZIwCtQIQP0pr8H+x+rUbfJD+BZuN t4FQBtAOrcusjDxs01dZ0vypuY7bx73lD1HjgmA9uPc2ifVnyE7bLwIjSu/loxS1bN fQo5HhRhJmbNd4Dks/zK9bgwvqRvtVg8Mtzv9CY4dPkB3Ve4vbuMoL19qisZ1a68+C rlNBYWjDXwVvuyj9QJpd2QcXgGvCwDBa7MuFMKp9rT5eMbZ2fWr0EgnpS8P8+yYzsG vuRZz+tNjMSEZaQBWmU3DFGdmJdPwR404Q9VcDBG2hVWkVM+2//f3uGLMCMvHwYaYA 56ClMSdXXqYaA== 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 03/13] drm/mediatek: gamma: Support SoC specific LUT size Date: Mon, 31 Jul 2023 15:04:31 +0200 Message-ID: <20230731130441.173960-4-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,RCVD_IN_DNSWL_BLOCKED, 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: 1772942927437331569 X-GMAIL-MSGID: 1772942927437331569 Newer SoCs support a bigger Gamma LUT table: wire up a callback to retrieve the correct LUT size for each different Gamma IP. Co-developed-by: Jason-JH.Lin Signed-off-by: Jason-JH.Lin [Angelo: Rewritten commit message/description + porting] Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Jason-JH.Lin Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_aal.c | 17 ++++++++++++++- drivers/gpu/drm/mediatek/mtk_disp_drv.h | 2 ++ drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 23 ++++++++++++++++++--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 8 +++++-- drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 1 - drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 2 ++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 9 ++++++++ 7 files changed, 55 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_aal.c b/drivers/gpu/drm/mediatek/mtk_disp_aal.c index 2f602f1f1c49..e2e4155faf01 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_aal.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_aal.c @@ -19,7 +19,7 @@ #define AAL_EN BIT(0) #define DISP_AAL_SIZE 0x0030 #define DISP_AAL_OUTPUT_SIZE 0x04d8 - +#define DISP_AAL_LUT_SIZE 512 struct mtk_disp_aal_data { bool has_gamma; @@ -61,6 +61,21 @@ void mtk_aal_config(struct device *dev, unsigned int w, mtk_ddp_write(cmdq_pkt, w << 16 | h, &aal->cmdq_reg, aal->regs, DISP_AAL_OUTPUT_SIZE); } +/** + * mtk_aal_gamma_get_lut_size() - Get gamma LUT size for AAL + * @dev: Pointer to struct device + * + * Return: 0 if gamma control not supported in AAL or gamma LUT size + */ +unsigned int mtk_aal_gamma_get_lut_size(struct device *dev) +{ + struct mtk_disp_aal *aal = dev_get_drvdata(dev); + + if (aal->data && aal->data->has_gamma) + return DISP_AAL_LUT_SIZE; + return 0; +} + void mtk_aal_gamma_set(struct device *dev, struct drm_crtc_state *state) { struct mtk_disp_aal *aal = dev_get_drvdata(dev); diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/mediatek/mtk_disp_drv.h index 75045932353e..ca377265e5eb 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h @@ -17,6 +17,7 @@ void mtk_aal_clk_disable(struct device *dev); void mtk_aal_config(struct device *dev, unsigned int w, unsigned int h, unsigned int vrefresh, unsigned int bpc, struct cmdq_pkt *cmdq_pkt); +unsigned int mtk_aal_gamma_get_lut_size(struct device *dev); void mtk_aal_gamma_set(struct device *dev, struct drm_crtc_state *state); void mtk_aal_start(struct device *dev); void mtk_aal_stop(struct device *dev); @@ -53,6 +54,7 @@ void mtk_gamma_clk_disable(struct device *dev); void mtk_gamma_config(struct device *dev, unsigned int w, unsigned int h, unsigned int vrefresh, unsigned int bpc, struct cmdq_pkt *cmdq_pkt); +unsigned int mtk_gamma_get_lut_size(struct device *dev); void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state); void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crtc_state *state); void mtk_gamma_start(struct device *dev); diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 47751864bd5c..7575237625d2 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -24,10 +24,12 @@ #define DISP_GAMMA_LUT 0x0700 #define LUT_10BIT_MASK 0x03ff +#define LUT_SIZE_DEFAULT 512 struct mtk_disp_gamma_data { bool has_dither; bool lut_diff; + u16 lut_size; }; /* @@ -54,6 +56,15 @@ void mtk_gamma_clk_disable(struct device *dev) clk_disable_unprepare(gamma->clk); } +unsigned int mtk_gamma_get_lut_size(struct device *dev) +{ + struct mtk_disp_gamma *gamma = dev_get_drvdata(dev); + + if (gamma && gamma->data) + return gamma->data->lut_size; + return LUT_SIZE_DEFAULT; +} + void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crtc_state *state) { struct mtk_disp_gamma *gamma; @@ -61,6 +72,7 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt struct drm_color_lut *lut; void __iomem *lut_base; bool lut_diff; + u16 lut_size; u32 word; u32 diff[3] = {0}; @@ -71,17 +83,20 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt /* If we're called from AAL, dev is NULL */ gamma = dev ? dev_get_drvdata(dev) : NULL; - if (gamma && gamma->data) + if (gamma && gamma->data) { lut_diff = gamma->data->lut_diff; - else + lut_size = gamma->data->lut_size; + } else { lut_diff = false; + lut_size = LUT_SIZE_DEFAULT; + } reg = readl(regs + DISP_GAMMA_CFG); reg = reg | GAMMA_LUT_EN; writel(reg, regs + DISP_GAMMA_CFG); lut_base = regs + DISP_GAMMA_LUT; lut = (struct drm_color_lut *)state->gamma_lut->data; - for (i = 0; i < MTK_LUT_SIZE; i++) { + for (i = 0; i < lut_size; i++) { if (!lut_diff || (i % 2 == 0)) { word = (((lut[i].red >> 6) & LUT_10BIT_MASK) << 20) + (((lut[i].green >> 6) & LUT_10BIT_MASK) << 10) + @@ -198,10 +213,12 @@ static int mtk_disp_gamma_remove(struct platform_device *pdev) static const struct mtk_disp_gamma_data mt8173_gamma_driver_data = { .has_dither = true, + .lut_size = 512, }; static const struct mtk_disp_gamma_data mt8183_gamma_driver_data = { .lut_diff = true, + .lut_size = 512, }; static const struct of_device_id mtk_disp_gamma_driver_dt_match[] = { diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 8a43656ecc30..ebe0cc3a1a4c 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -959,8 +959,12 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, mtk_crtc->ddp_comp[i] = comp; if (comp->funcs) { - if (comp->funcs->gamma_set) - gamma_lut_size = MTK_LUT_SIZE; + if (comp->funcs->gamma_set && comp->funcs->gamma_get_lut_size) { + unsigned int lut_sz = mtk_ddp_gamma_get_lut_size(comp); + + if (lut_sz) + gamma_lut_size = lut_sz; + } if (comp->funcs->ctm_set) has_ctm = true; diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h index 3e9046993d09..b2e50292e57d 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h @@ -10,7 +10,6 @@ #include "mtk_drm_ddp_comp.h" #include "mtk_drm_plane.h" -#define MTK_LUT_SIZE 512 #define MTK_MAX_BPC 10 #define MTK_MIN_BPC 3 diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index f114da4d36a9..f3212e08f2cd 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -271,6 +271,7 @@ static void mtk_ufoe_start(struct device *dev) static const struct mtk_ddp_comp_funcs ddp_aal = { .clk_enable = mtk_aal_clk_enable, .clk_disable = mtk_aal_clk_disable, + .gamma_get_lut_size = mtk_aal_gamma_get_lut_size, .gamma_set = mtk_aal_gamma_set, .config = mtk_aal_config, .start = mtk_aal_start, @@ -322,6 +323,7 @@ static const struct mtk_ddp_comp_funcs ddp_dsi = { static const struct mtk_ddp_comp_funcs ddp_gamma = { .clk_enable = mtk_gamma_clk_enable, .clk_disable = mtk_gamma_clk_disable, + .gamma_get_lut_size = mtk_gamma_get_lut_size, .gamma_set = mtk_gamma_set, .config = mtk_gamma_config, .start = mtk_gamma_start, diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index febcaeef16a1..c1355960e195 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -67,6 +67,7 @@ struct mtk_ddp_comp_funcs { void (*layer_config)(struct device *dev, unsigned int idx, struct mtk_plane_state *state, struct cmdq_pkt *cmdq_pkt); + unsigned int (*gamma_get_lut_size)(struct device *dev); void (*gamma_set)(struct device *dev, struct drm_crtc_state *state); void (*bgclr_in_on)(struct device *dev); @@ -186,6 +187,14 @@ static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp, comp->funcs->layer_config(comp->dev, idx, state, cmdq_pkt); } +static inline unsigned int mtk_ddp_gamma_get_lut_size(struct mtk_ddp_comp *comp) +{ + if (comp->funcs && comp->funcs->gamma_get_lut_size) + return comp->funcs->gamma_get_lut_size(comp->dev); + + return 0; +} + static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp *comp, struct drm_crtc_state *state) { From patchwork Mon Jul 31 13:04:32 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: 128685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2015169vqg; Mon, 31 Jul 2023 06:29:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlH+iMMCCCvokYdQAiQokRO7dHaHta7fHng4WEjyhbQOyPtj7D/ZVnHXzNMlaQxi4B4TzoAy X-Received: by 2002:a05:6a00:1741:b0:686:de6c:a9e5 with SMTP id j1-20020a056a00174100b00686de6ca9e5mr12872116pfc.31.1690810151010; Mon, 31 Jul 2023 06:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690810150; cv=none; d=google.com; s=arc-20160816; b=VOt0df3C/OwAsgrM6XCgaDzbvh/0jy0ne2pvI/j0y52R3bkzHgHd9pfuH0RKVXe1Xu ZnaXTDbtJugSsP4tOungdWOA/N9bIaxdx7j63zHxFbR0cWwdvHvQyEiKZgEuBbfl1Hnv WsOHFcruQovKandZzBbFxpzgDHGyZb6KEdcZ8hZyxPEWBBfje+OdnvPaut6Bu4v3ObyM hGsdvoCoOZifUl3EZDDYiHImD+LChxuh0mDSHZlrJxodO8gp3LnbWj0XjM/qa8EurRJO HJ2P9PfJsGM1hOtLKzV1a8DEZfMZZFOKD50Wuh9uPRR3fyKo5MzuxgsoD078TFQ6/tD3 9RZQ== 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=HB+HZWBM7tPTSGGnj20X/FY1SFqRET0vKitAUXYktpU=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=ePh+yq+FP2hhOo/L3v2P3MWlzuaG4A36EHCWbL6+8M1yaj1R8nkOckrj+T+QemLYZP Ts2c0hECBo5Z1Kh5/vtHRx0rbqQfsrI4s4KLqLJpzDQeWmlJJzPfRnWn4oZo2+YR66SB v42d7KSRFIB1g2nLxXkSdDfPborMTciEFPMkwCCZ1XRXLBRKMzR5PJtqqwgGG5D8HVQH hwGl3Ij+GWvaMp0/QgBGErvJWZrAomi8eO46MT9aUg2rSjP4mBzmoMk7pTJ//Ip2oN/C caI1HS1l57W431dusg25iEKG1LeoUejL3p185IBQIalPX0QD9kdERs3ty9+9CGoydUbb JRuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TUmLNvZG; 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 s10-20020a056a0008ca00b006871cbe9759si3862904pfu.227.2023.07.31.06.28.58; Mon, 31 Jul 2023 06:29:10 -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=TUmLNvZG; 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 S232316AbjGaNFD (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231542AbjGaNEw (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 C8483B0 for ; Mon, 31 Jul 2023 06:04:50 -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 C33906607105; Mon, 31 Jul 2023 14:04:48 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808689; bh=pRGB2s9t6NTvTDhsegnJ/Yxt/Lp5Ax+diF2jcyd4avU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUmLNvZGZL9lGCqA4MRBWifBlAWNO7+tiJJIOGW4bL1wl7h0KqpUTtsPXyVmHkQnC FMW8O+PAMLUOrCZ/T7Lv+fa3UvKf5k3wSuM3Ov6T2SXLCBL72eeLQ7QNsaWlDpV7Ru mZb5QlsgTLejSzpb0kI84O6k7Ckc4NrEctFpqZRrsZscIGE1jIbuBAmmkOBcjgslOu hOxNxxBy3kLUUItMwh1BcPauAtpHmY0RgGE5H6KCkR0v88j9XES6kQmB53f3xJyEh3 4cLOSVw4SsZXBHwtOMKHhf3iSpnKhrOWjcQXXxorcYrCDEj7Y67BcC6I46x9zSAFC4 6ut8+6qqJf0lQ== 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 04/13] drm/mediatek: gamma: Improve and simplify HW LUT calculation Date: Mon, 31 Jul 2023 15:04:32 +0200 Message-ID: <20230731130441.173960-5-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: 1772942945208773648 X-GMAIL-MSGID: 1772942945208773648 Use drm_color_lut_extract() to avoid open-coding the bits reduction calculations for each color channel and use a struct drm_color_lut to temporarily store the information instead of an array of u32. Also, slightly improve the precision of the HW LUT calculation in the LUT DIFF case by performing the subtractions on the 16-bits values and doing the 10 bits conversion later. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Jason-JH.Lin Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 30 +++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 7575237625d2..fd6a75a64a9f 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -74,7 +74,6 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt bool lut_diff; u16 lut_size; u32 word; - u32 diff[3] = {0}; /* If there's no gamma lut there's nothing to do here. */ if (!state->gamma_lut) @@ -97,18 +96,29 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt lut_base = regs + DISP_GAMMA_LUT; lut = (struct drm_color_lut *)state->gamma_lut->data; for (i = 0; i < lut_size; i++) { + struct drm_color_lut diff, hwlut; + + hwlut.red = drm_color_lut_extract(lut[i].red, 10); + hwlut.green = drm_color_lut_extract(lut[i].green, 10); + hwlut.blue = drm_color_lut_extract(lut[i].blue, 10); + if (!lut_diff || (i % 2 == 0)) { - word = (((lut[i].red >> 6) & LUT_10BIT_MASK) << 20) + - (((lut[i].green >> 6) & LUT_10BIT_MASK) << 10) + - ((lut[i].blue >> 6) & LUT_10BIT_MASK); + word = hwlut.red << 20 + + hwlut.green << 10 + + hwlut.red; } else { - diff[0] = (lut[i].red >> 6) - (lut[i - 1].red >> 6); - diff[1] = (lut[i].green >> 6) - (lut[i - 1].green >> 6); - diff[2] = (lut[i].blue >> 6) - (lut[i - 1].blue >> 6); + diff.red = lut[i].red - lut[i - 1].red; + diff.red = drm_color_lut_extract(diff.red, 10); + + diff.green = lut[i].green - lut[i - 1].green; + diff.green = drm_color_lut_extract(diff.green, 10); + + diff.blue = lut[i].blue - lut[i - 1].blue; + diff.blue = drm_color_lut_extract(diff.blue, 10); - word = ((diff[0] & LUT_10BIT_MASK) << 20) + - ((diff[1] & LUT_10BIT_MASK) << 10) + - (diff[2] & LUT_10BIT_MASK); + word = diff.blue << 20 + + diff.green << 10 + + diff.red; } writel(word, (lut_base + i * 4)); } 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) From patchwork Mon Jul 31 13:04:34 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: 128740 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2045959vqg; Mon, 31 Jul 2023 07:17:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlFv35Wwq6qCZ2JDOpfJ/TC0EId1JZHFjCd4JHkEkfYp/hhleJWmthSlZWmhZiUoLgIgsI8f X-Received: by 2002:a05:6a20:dda6:b0:10f:52e2:49ec with SMTP id kw38-20020a056a20dda600b0010f52e249ecmr7912263pzb.53.1690813053678; Mon, 31 Jul 2023 07:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690813053; cv=none; d=google.com; s=arc-20160816; b=v4+pXdwl103ONFU5F0sFRiuH067F27jlxfZU6+WZctPOFK3TLfIFHuVWOjcL4Jl0i/ N2dyzcTY6l+ng/RVodrY3FV4oKMRY5IYy/40xF+Icx2y0RkHtAYq8w/ROAPhRxPKQ5ug Ds9gUp/bP4FKLHVSRkkexmymjfYj4auYdRQORq1fLvrZ19vjX2/PoNEtw34Jis+QqhOi fiMffVfv6u04Q2dB7fk7uM/vb7tgZ9KoneQzLs+Hy9Jxb1t6vnXjbbdyew2xFWeBrGd9 7LW1tHVTfh2W81sG7r/HCXu4FsShp0+JWtwfUCig4l4TGK7G28jTTMIy/yXlIRTVfzk9 ELPg== 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=x5jSNP/HLg0W4x1NzZ4fCZF9Dw9LqbXuRV+zXDZs1Ss=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=C2aTTBpPnjUUI4SM3PQEGeA6Gx9YzbUV/VVKUDQk7BmnS3zRxdyohjRGDCRDt16c4h hnq6lt69CXSLmCeNLhGNc4PYkJVu62Ox73Hzva0rq+VF6eANhMvcu+EQwPNZesWDOtax G7wWZzS6ayk89Tkbv21/pMMM4k1LlRcB7s5OsqfOriuE3elD20U43OC4VxtJLnGa2KKw LRGjBS1cNEGlQ4rfy+8eHel+L+FmhdqNVI07bhP9p/pUc81DLQyngQM1OVzhaQqFBuFJ Qqy0Uj67GoSnQIOSh9MsVa9G3uLEgZbgo3sh7baNdE/ptzBV+jAUjzVPeSWxL+MG4vq4 w2pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=XDXUDt7K; 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 y64-20020a638a43000000b0053f479ef142si4383628pgd.124.2023.07.31.07.17.18; Mon, 31 Jul 2023 07:17:33 -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=XDXUDt7K; 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 S231775AbjGaNFK (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232114AbjGaNEx (ORCPT ); Mon, 31 Jul 2023 09:04:53 -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 A56EE10F2 for ; Mon, 31 Jul 2023 06:04:52 -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 A87A5660707D; Mon, 31 Jul 2023 14:04:50 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808691; bh=0Ced9zHqXOE8csCfTU84KdtIY5YMgWKarAWvRB7Z5c0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XDXUDt7K1kSIaUhC9K1XmvqmJn71QL51mmmpax4Y05DaenmpHtr2DWrDL3lJ3M8xK g0aa/nF3M6ivkC4h9SwMlz3FtdGC1jhYU31Z+GNj8BJapIvG/cgn4CW4oRXNCXEtED qbxGSMhoer24/ljfRR5egiiDfL8LqxBlQTJ6GH+rHnfOBbEvFAStjxJ3E6nGFd4ogx gZfSV8y9WxFoJwVE5mPDjweq2iN4Qj3ES7P+YNS+gmKOpoKKg/jDzaEE/JRDXg7DJ4 gdgnG/Q1/9/w2SxXocGwJ8+myQZ8cLX0HjsaKBMOdhSIfzWGV8e1NHa/Y2RFH/eTjm x9dj8mnZ1tBvw== 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 06/13] drm/mediatek: gamma: Use bitfield macros Date: Mon, 31 Jul 2023 15:04:34 +0200 Message-ID: <20230731130441.173960-7-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,RCVD_IN_DNSWL_BLOCKED, 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: 1772945988486203327 X-GMAIL-MSGID: 1772945988486203327 Make the code more robust and improve readability by using bitfield macros instead of open coding bit operations. While at it, also add a definition for LUT_BITS_DEFAULT. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Jason-JH.Lin Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 41 ++++++++++++++--------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 18b102bef370..ea91d3619716 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -3,6 +3,7 @@ * Copyright (c) 2021 MediaTek Inc. */ +#include #include #include #include @@ -21,9 +22,16 @@ #define GAMMA_LUT_EN BIT(1) #define GAMMA_DITHERING BIT(2) #define DISP_GAMMA_SIZE 0x0030 +#define DISP_GAMMA_SIZE_HSIZE GENMASK(28, 16) +#define DISP_GAMMA_SIZE_VSIZE GENMASK(12, 0) #define DISP_GAMMA_LUT 0x0700 +#define DISP_GAMMA_LUT_10BIT_R GENMASK(29, 20) +#define DISP_GAMMA_LUT_10BIT_G GENMASK(19, 10) +#define DISP_GAMMA_LUT_10BIT_B GENMASK(9, 0) + #define LUT_10BIT_MASK 0x03ff +#define LUT_BITS_DEFAULT 10 #define LUT_SIZE_DEFAULT 512 struct mtk_disp_gamma_data { @@ -96,33 +104,33 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt for (i = 0; i < lut_size; i++) { struct drm_color_lut diff, hwlut; - hwlut.red = drm_color_lut_extract(lut[i].red, 10); - hwlut.green = drm_color_lut_extract(lut[i].green, 10); - hwlut.blue = drm_color_lut_extract(lut[i].blue, 10); + hwlut.red = drm_color_lut_extract(lut[i].red, LUT_BITS_DEFAULT); + hwlut.green = drm_color_lut_extract(lut[i].green, LUT_BITS_DEFAULT); + hwlut.blue = drm_color_lut_extract(lut[i].blue, LUT_BITS_DEFAULT); if (!lut_diff || (i % 2 == 0)) { - word = hwlut.red << 20 + - hwlut.green << 10 + - hwlut.red; + word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, hwlut.red); + word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, hwlut.green); + word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, hwlut.blue); } else { diff.red = lut[i].red - lut[i - 1].red; - diff.red = drm_color_lut_extract(diff.red, 10); + diff.red = drm_color_lut_extract(diff.red, LUT_BITS_DEFAULT); diff.green = lut[i].green - lut[i - 1].green; - diff.green = drm_color_lut_extract(diff.green, 10); + diff.green = drm_color_lut_extract(diff.green, LUT_BITS_DEFAULT); diff.blue = lut[i].blue - lut[i - 1].blue; - diff.blue = drm_color_lut_extract(diff.blue, 10); + diff.blue = drm_color_lut_extract(diff.blue, LUT_BITS_DEFAULT); - word = diff.blue << 20 + - diff.green << 10 + - diff.red; + word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, diff.red); + word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, diff.green); + word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, diff.blue); } writel(word, (lut_base + i * 4)); } /* Enable the gamma table */ - cfg_val = cfg_val | GAMMA_LUT_EN; + cfg_val |= FIELD_PREP(GAMMA_LUT_EN, 1); writel(cfg_val, regs + DISP_GAMMA_CFG); } @@ -139,9 +147,12 @@ void mtk_gamma_config(struct device *dev, unsigned int w, unsigned int bpc, struct cmdq_pkt *cmdq_pkt) { struct mtk_disp_gamma *gamma = dev_get_drvdata(dev); + u32 sz; + + sz = FIELD_PREP(DISP_GAMMA_SIZE_HSIZE, w); + sz |= FIELD_PREP(DISP_GAMMA_SIZE_VSIZE, h); - mtk_ddp_write(cmdq_pkt, h << 16 | w, &gamma->cmdq_reg, gamma->regs, - DISP_GAMMA_SIZE); + mtk_ddp_write(cmdq_pkt, sz, &gamma->cmdq_reg, gamma->regs, DISP_GAMMA_SIZE); if (gamma->data && gamma->data->has_dither) mtk_dither_set_common(gamma->regs, &gamma->cmdq_reg, bpc, DISP_GAMMA_CFG, GAMMA_DITHERING, cmdq_pkt); From patchwork Mon Jul 31 13:04:35 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: 128678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2013894vqg; Mon, 31 Jul 2023 06:26:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGcB5kaD3KqnNNWbXNNVTqbVffnUTapBkyn88TFG5iStywdLlxPGIAHKCe9Kzkjft1lAeTX X-Received: by 2002:a05:6870:783:b0:1bb:b061:cb5e with SMTP id en3-20020a056870078300b001bbb061cb5emr10553794oab.34.1690809998885; Mon, 31 Jul 2023 06:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690809998; cv=none; d=google.com; s=arc-20160816; b=MABh0X942ovZyH5Lez5jsWIlOY4bf5lvzSi8lRGSq7olwIAD7/Co8xXUZDMGQdi9xx zfB/igWo0jvk+PduRmozaQCs63iRh3kRag4rS05NWgC9jcLcxmSH2SKSBHtCGSLkCXCW 9ZK+QsJzc1vjWnS3MwyAjuOiAIBz13W6lxy2rGjmGzSiiLLCePhvKpj602GrphNEGqHQ ZYQdgKKtKjt1DSVAwSpPvn5ieW26cmyjHD0bM/zN09GcdAVgb5G2kN9dHLXkuk43MgGE 9B1ZcmPpdA9NIqPn1KbSqXwjpv8A+/L4wfMrh16ccTsn3Dmg3VeO7quBYBj1vv1mHtga L+SQ== 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=/6z0rrRZrrLlwSrtZRFMHNjy5tho8eoWy7RCpvn+XsE=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=O0Re+NlvsDdIR1C8ve1nBhc5VpiumdF4l/nabD1b5kU0KL1PKha9hI/E0uf3ildNE2 zT1ksB79f/x7xhCLdyBkS3tRvnqLAgzhDSS7ely/9Lfpt1JiJbhJDlxbgP7+LeHjB4tF iabW0uxcDJCSQcteAUw3w7DDyvMdPlEcI8zWKj1+mEnL6n+fXRAUsmjiPExCYSs7W+pI RFmLWlK7E9sAizwUSnGOProg7MFLHt5V5BGbHkxlBk6Q6C9m4aEWEFXAMoByQ+1ZRkNC sktESiLjJKqpOszAw+nutyouqkanBXWXfFRv0Kf8f1VYdpezcvpdlB84nl76r6xgKk7Q fo+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JoBYB4XL; 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 w7-20020a637b07000000b005643758e9c9si2932766pgc.515.2023.07.31.06.26.25; Mon, 31 Jul 2023 06:26:38 -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=JoBYB4XL; 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 S230077AbjGaNFN (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232164AbjGaNEy (ORCPT ); Mon, 31 Jul 2023 09:04:54 -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 7C947E78 for ; Mon, 31 Jul 2023 06:04:53 -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 9BB0C6606FD9; Mon, 31 Jul 2023 14:04:51 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808692; bh=H4ZBSh9kNegCse5QzFRAMY+FZwOpupGhU+7vtU2T9X8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JoBYB4XLyS6CqH8q14qwpY/f1D5fQ1zJU9GPsQIsjFXLh9qkfmO5PKHFTeLGNqAo6 j55AvrwuYl0fWTvxnL5tkKCXUVZGKTRGHxkczbzmYzcyaUNxF/LVlzwSSTASkiuHUv AN8B7phpTyPzNWsGbQNM/0KrM6IxMgcYCR0HiYcba+TJryG1YpZCWeFK4Iefr8AXXg OoZFk5PIMGlvL8sJrt4VavdIuYmFJ17+B7runQbtOavmuLkmztU2CggAOBZDkX+BeK PAC6O22Vz6AxI9WLNNMwwggBL+IqEUB3nsZg6W5tyUK1lsXyGEcipw1bTZGji+06JS X5B1q+cGOlfZA== 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 07/13] drm/mediatek: gamma: Support specifying number of bits per LUT component Date: Mon, 31 Jul 2023 15:04:35 +0200 Message-ID: <20230731130441.173960-8-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,RCVD_IN_DNSWL_BLOCKED, 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: 1772942785192874029 X-GMAIL-MSGID: 1772942785192874029 New SoCs, like MT8195, not only may support bigger lookup tables, but have got a different register layout to support bigger precision: support specifying the number of `lut_bits` for each SoC and use it in mtk_gamma_set_common() to perform the right calculation. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Jason-JH.Lin Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index ea91d3619716..8a45eac53875 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -38,6 +38,7 @@ struct mtk_disp_gamma_data { bool has_dither; bool lut_diff; u16 lut_size; + u8 lut_bits; }; /* @@ -81,6 +82,7 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt void __iomem *lut_base; bool lut_diff; u16 lut_size; + u8 lut_bits; u32 cfg_val, word; /* If there's no gamma lut there's nothing to do here. */ @@ -92,9 +94,11 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt if (gamma && gamma->data) { lut_diff = gamma->data->lut_diff; + lut_bits = gamma->data->lut_bits; lut_size = gamma->data->lut_size; } else { lut_diff = false; + lut_bits = LUT_BITS_DEFAULT; lut_size = LUT_SIZE_DEFAULT; } @@ -104,9 +108,9 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt for (i = 0; i < lut_size; i++) { struct drm_color_lut diff, hwlut; - hwlut.red = drm_color_lut_extract(lut[i].red, LUT_BITS_DEFAULT); - hwlut.green = drm_color_lut_extract(lut[i].green, LUT_BITS_DEFAULT); - hwlut.blue = drm_color_lut_extract(lut[i].blue, LUT_BITS_DEFAULT); + hwlut.red = drm_color_lut_extract(lut[i].red, lut_bits); + hwlut.green = drm_color_lut_extract(lut[i].green, lut_bits); + hwlut.blue = drm_color_lut_extract(lut[i].blue, lut_bits); if (!lut_diff || (i % 2 == 0)) { word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, hwlut.red); @@ -114,13 +118,13 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, hwlut.blue); } else { diff.red = lut[i].red - lut[i - 1].red; - diff.red = drm_color_lut_extract(diff.red, LUT_BITS_DEFAULT); + diff.red = drm_color_lut_extract(diff.red, lut_bits); diff.green = lut[i].green - lut[i - 1].green; - diff.green = drm_color_lut_extract(diff.green, LUT_BITS_DEFAULT); + diff.green = drm_color_lut_extract(diff.green, lut_bits); diff.blue = lut[i].blue - lut[i - 1].blue; - diff.blue = drm_color_lut_extract(diff.blue, LUT_BITS_DEFAULT); + diff.blue = drm_color_lut_extract(diff.blue, lut_bits); word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, diff.red); word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, diff.green); @@ -237,10 +241,12 @@ static int mtk_disp_gamma_remove(struct platform_device *pdev) static const struct mtk_disp_gamma_data mt8173_gamma_driver_data = { .has_dither = true, + .lut_bits = 10, .lut_size = 512, }; static const struct mtk_disp_gamma_data mt8183_gamma_driver_data = { + .lut_bits = 10, .lut_diff = true, .lut_size = 512, }; From patchwork Mon Jul 31 13:04:36 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: 128688 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2019112vqg; Mon, 31 Jul 2023 06:35:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlFUTFNnhpxi0jgvVY1aCr059Af+QaSklxAwbgMEdjtUF5rYTtwbFUw7eUb977LNAwe58hdj X-Received: by 2002:a17:907:2717:b0:99b:ee8b:5707 with SMTP id w23-20020a170907271700b0099bee8b5707mr6797498ejk.74.1690810526977; Mon, 31 Jul 2023 06:35:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690810526; cv=none; d=google.com; s=arc-20160816; b=sibuMME2mSJdpZRTZlNeeJakTQcrNcO/skmDKBtPlLSjfnBtfW+qQxw6cu5xwEVrzF f7UkmC5RpZFxO/q3WFaGq5Sa6d6y7rFOiw3tkVN8LPGB4sDzwUJulYtJiccn9SdVSRU6 vmQ7uG6H6ROGqsL7cauPCY0MbU4u793lDVYoAyQB7w96qUY6enz+u8OzVEen7x4uBN70 P83eKJxZNcF68NYzbOGbnrHtCVfAWQSLUT3nRdtt3lyw+84JK19zQ7We4fqv8LBvVbeJ 9SGP0yMBBu39NRw/XUU7R3EWqbmEXd53YcGqU4D2l+lv8U4yUt8/pa6/rpn7liP85cmI Uv1A== 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=9K0WbbWiMRu8OTiJQtJgnElIRnTLikE8x/VIwZTPGQ8=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=GdouAYSf7Ehu14vTja840IBWA7ubicWa18SYPDHNyb2fwKouB+1wLbCUQwLqtiH2F7 HkAdJ2rs8/QqLZP9/5SIuOfIwsDqZSJXTv/n0WmDSvOyd0tEOJkY3c20egXcHGgFWuKv +mIxcGl/OVcUF4X9qYx7QB/bmMP14z2huGbBoD96gXGJ2B0ZKslVzWns5Loizo+GGdeZ tsGxuoFAwpzoRUg+2Q2fMk0J2a1Z6wHwty0jwjf8+NNxgBlQuuoT6zX8NWGh7NWLbsAS bK0U+LJGlF+o3swn4otN8TWgOpxrx0Dr+O+pu8Qdhq8VYzQLeIXlcCvIG1Svaj/NhBBT 64Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i+Roxdh4; 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 o5-20020a17090608c500b0099307a6635esi6761585eje.701.2023.07.31.06.35.02; Mon, 31 Jul 2023 06:35:26 -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=i+Roxdh4; 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 S231244AbjGaNFR (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232693AbjGaNE6 (ORCPT ); Mon, 31 Jul 2023 09:04:58 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B3910FB for ; Mon, 31 Jul 2023 06:04:54 -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 8E0F96607003; Mon, 31 Jul 2023 14:04:52 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808693; bh=JPjjG2QuZmeysV616cmfgYvud3Z5xrxzJr7h2Ftv49o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i+Roxdh4itWI5pmDZ2gel4FwjItXoIteJQMPZvJNE/bNTxmU1uatMiMhdUKJITFRK aoNkwA3uAzW8pJ8J2KuSctQ/40WrD4941ZN+JCfXv/ZcybdIQNNIk/mTwAJm7losj4 IduN1Qz+sTgNLAnJcwUV0oTpINjRCnzkBjcFinCDcmaQFdHpdYBOA2QBqPLqbdiF7z l5qb+gaInpZ+xKYmPR59kpEmi5+AXA0Ji8QpHmUvCTas6qoOiEHlk/mvvd8Afyg6WJ NKvKeiN4J4Vgblg2lKugq0x0fFwLi9Sw+Z3I2ieFjjZkQV+67lWjysUCnZTzdEHLDL FEckK3wT8lPRA== 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 08/13] drm/mediatek: gamma: Support multi-bank gamma LUT Date: Mon, 31 Jul 2023 15:04:36 +0200 Message-ID: <20230731130441.173960-9-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: 1772943338873565734 X-GMAIL-MSGID: 1772943338873565734 Newer Gamma IP have got multiple LUT banks: support specifying the size of the LUT banks and handle bank-switching before programming the LUT in mtk_gamma_set_common() in preparation for adding support for MT8195 and newer SoCs. Suggested-by: Jason-JH.Lin [Angelo: Refactored original commit] Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 74 ++++++++++++++--------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 8a45eac53875..65b90e1831c5 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -24,6 +24,8 @@ #define DISP_GAMMA_SIZE 0x0030 #define DISP_GAMMA_SIZE_HSIZE GENMASK(28, 16) #define DISP_GAMMA_SIZE_VSIZE GENMASK(12, 0) +#define DISP_GAMMA_BANK 0x0100 +#define DISP_GAMMA_BANK_BANK GENMASK(1, 0) #define DISP_GAMMA_LUT 0x0700 #define DISP_GAMMA_LUT_10BIT_R GENMASK(29, 20) @@ -37,6 +39,7 @@ struct mtk_disp_gamma_data { bool has_dither; bool lut_diff; + u16 lut_bank_size; u16 lut_size; u8 lut_bits; }; @@ -81,9 +84,10 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt struct drm_color_lut *lut; void __iomem *lut_base; bool lut_diff; - u16 lut_size; + u16 lut_bank_size, lut_size; u8 lut_bits; - u32 cfg_val, word; + u32 cfg_val, lbank_val, word; + int cur_bank, num_lut_banks; /* If there's no gamma lut there's nothing to do here. */ if (!state->gamma_lut) @@ -94,43 +98,57 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt if (gamma && gamma->data) { lut_diff = gamma->data->lut_diff; + lut_bank_size = gamma->data->lut_bank_size; lut_bits = gamma->data->lut_bits; lut_size = gamma->data->lut_size; } else { lut_diff = false; + lut_bank_size = LUT_SIZE_DEFAULT; lut_bits = LUT_BITS_DEFAULT; lut_size = LUT_SIZE_DEFAULT; } + num_lut_banks = lut_size / lut_bank_size; 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++) { - struct drm_color_lut diff, hwlut; - - hwlut.red = drm_color_lut_extract(lut[i].red, lut_bits); - hwlut.green = drm_color_lut_extract(lut[i].green, lut_bits); - hwlut.blue = drm_color_lut_extract(lut[i].blue, lut_bits); - - if (!lut_diff || (i % 2 == 0)) { - word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, hwlut.red); - word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, hwlut.green); - word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, hwlut.blue); - } else { - diff.red = lut[i].red - lut[i - 1].red; - diff.red = drm_color_lut_extract(diff.red, lut_bits); - - diff.green = lut[i].green - lut[i - 1].green; - diff.green = drm_color_lut_extract(diff.green, lut_bits); - - diff.blue = lut[i].blue - lut[i - 1].blue; - diff.blue = drm_color_lut_extract(diff.blue, lut_bits); - - word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, diff.red); - word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, diff.green); - word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, diff.blue); + + for (cur_bank = 0; cur_bank < num_lut_banks; cur_bank++) { + + /* Switch gamma bank and set data mode before writing LUT */ + if (num_lut_banks > 1) { + lbank_val = FIELD_PREP(DISP_GAMMA_BANK_BANK, cur_bank); + writel(lbank_val, regs + DISP_GAMMA_BANK); + } + + for (i = 0; i < lut_bank_size; i++) { + int n = (cur_bank * lut_bank_size) + i; + struct drm_color_lut diff, hwlut; + + hwlut.red = drm_color_lut_extract(lut[n].red, lut_bits); + hwlut.green = drm_color_lut_extract(lut[n].green, lut_bits); + hwlut.blue = drm_color_lut_extract(lut[n].blue, lut_bits); + + if (!lut_diff || (i % 2 == 0)) { + word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, hwlut.red); + word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, hwlut.green); + word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, hwlut.blue); + } else { + diff.red = lut[n].red - lut[n - 1].red; + diff.red = drm_color_lut_extract(diff.red, lut_bits); + + diff.green = lut[n].green - lut[n - 1].green; + diff.green = drm_color_lut_extract(diff.green, lut_bits); + + diff.blue = lut[n].blue - lut[n - 1].blue; + diff.blue = drm_color_lut_extract(diff.blue, lut_bits); + + word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, diff.red); + word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, diff.green); + word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, diff.blue); + } + writel(word, (lut_base + i * 4)); } - writel(word, (lut_base + i * 4)); } /* Enable the gamma table */ @@ -241,11 +259,13 @@ static int mtk_disp_gamma_remove(struct platform_device *pdev) static const struct mtk_disp_gamma_data mt8173_gamma_driver_data = { .has_dither = true, + .lut_bank_size = 512, .lut_bits = 10, .lut_size = 512, }; static const struct mtk_disp_gamma_data mt8183_gamma_driver_data = { + .lut_bank_size = 512, .lut_bits = 10, .lut_diff = true, .lut_size = 512, From patchwork Mon Jul 31 13:04:37 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: 128721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2040166vqg; Mon, 31 Jul 2023 07:09:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGFmbybnos/Ic7opFZcop258tA7PcFsVaKubVZCicMb7pT+pBTnKmmYVRsl3cHLa2U5JkOr X-Received: by 2002:a17:90a:1289:b0:268:105b:ca1c with SMTP id g9-20020a17090a128900b00268105bca1cmr8918883pja.32.1690812590974; Mon, 31 Jul 2023 07:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690812590; cv=none; d=google.com; s=arc-20160816; b=PqOr5SGOlQUnsSbT4qkA9UpsWRtpfZf9mElwGEonKEcc/mT0E9ZiA3uhEvY5TzEHGS LtTP1umR8D94mmp2BlNKnERBk1PytCZiWZ3qUtj93D/Ob63RP5NhWEh+32IptniEPzTi xnttqX2I8HOYl0WMBBOsPnFumYxcAPDDMJ66tIjyyyAXqAAzBC8xyl4zU18Ffd6JtzEY 071Uog4rLb6FJGS3W8tPSAhsuK6YapJNwXNDCOdtGhMERBqfycMQHRsNfh/rjfpyC7HE CZpXZXR67mPtls0E4a5irHy3YE+PILT3TFLlba2mAyStV7p2qbYci7c46bQUQ8BbUsHV oDfw== 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=ZH7GYwxr0XAnD/qgfrJ66/Bsrqbmktm5x8kxowpNOGU=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=AuuGXGG2yRR8ooeT56w/ZhdPF42wdqPEJ/vxiB4H2nHR+NibY/t71krqvdOtNVTlCe IWWo2spw1VJs0+xJ5TdLU5uN1zIlREfeSct4SwWlViu6Ee4N82RFzhK6KoELlsxIsQud xDerOrprgwCWDaG59rQRgw2WKekIH1rteuWPz0MNSuSQVU5F5vTYfaJC2Ineygx7cmbS uK1uSIYwORWm+Ehm4BMEWoI23LAjeWHyk0HteLOPF29IvfT2eUjhYFfAPsiJh393X9oP PaCFVOcwFy1d4N57a/Fx58pFbMyU95CbkeKbB7HJlUGonYgceD05aaMLx2CP3A99WNxR Vlgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="H/7+Lkgo"; 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 17-20020a630211000000b0056334ba88easi3443580pgc.263.2023.07.31.07.09.37; Mon, 31 Jul 2023 07:09:50 -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="H/7+Lkgo"; 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 S232654AbjGaNFT (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232732AbjGaNE6 (ORCPT ); Mon, 31 Jul 2023 09:04:58 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E0D41703 for ; Mon, 31 Jul 2023 06:04:55 -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 7F38566003AC; Mon, 31 Jul 2023 14:04:53 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808694; bh=tprg8D4PIAOwQO4rwDJlmaDM6kdKyuT9+Awg1cdynKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H/7+Lkgo1LqXdetdmxd+xS06ByeTvXhuRX8g5wNsDllR2fEgTYdqiKe2G0kC4CXFg 3lPTs6kLJK3f51APxrJe5gBPJzP/HBNP0ZKS13OAHlxe7cLpSXo9FRyhKPVbR7WE/W w0EJsbzIzeyH4N3T8Fcz3HiBi2ZkwljxKkle2VPM/ZPAVbbFa1mGRh1ryNUr1aopKP V3O5aKG3g0VPzZaf26aTNGel3gUOsPOOZKc8dqxW6lISBppEGXSX1Q7dJIF1WZoKpq HBo1i87Qfm7v2hVQpNg8BDCs/dQ6b+ljyJ1Z1SGXxkJy56/Pjle3c+cAxmq+a3zQOB VOJtAxhGKVr6g== 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 09/13] drm/mediatek: gamma: Add support for 12-bit LUT and MT8195 Date: Mon, 31 Jul 2023 15:04:37 +0200 Message-ID: <20230731130441.173960-10-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: 1772945503192465770 X-GMAIL-MSGID: 1772945503192465770 Add support for 12-bit gamma lookup tables and introduce the first user for it: MT8195. While at it, also reorder the variables in mtk_gamma_set_common() and rename `lut_base` to `lut0_base` to improve readability. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Jason-JH.Lin Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 76 +++++++++++++++++++---- 1 file changed, 63 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 65b90e1831c5..a846d0dbaa69 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -26,12 +26,20 @@ #define DISP_GAMMA_SIZE_VSIZE GENMASK(12, 0) #define DISP_GAMMA_BANK 0x0100 #define DISP_GAMMA_BANK_BANK GENMASK(1, 0) +#define DISP_GAMMA_BANK_DATA_MODE BIT(2) #define DISP_GAMMA_LUT 0x0700 +#define DISP_GAMMA_LUT1 0x0b00 +/* For 10 bit LUT layout, R/G/B are in the same register */ #define DISP_GAMMA_LUT_10BIT_R GENMASK(29, 20) #define DISP_GAMMA_LUT_10BIT_G GENMASK(19, 10) #define DISP_GAMMA_LUT_10BIT_B GENMASK(9, 0) +/* For 12 bit LUT layout, R/G are in LUT, B is in LUT1 */ +#define DISP_GAMMA_LUT_12BIT_R GENMASK(11, 0) +#define DISP_GAMMA_LUT_12BIT_G GENMASK(23, 12) +#define DISP_GAMMA_LUT_12BIT_B GENMASK(11, 0) + #define LUT_10BIT_MASK 0x03ff #define LUT_BITS_DEFAULT 10 #define LUT_SIZE_DEFAULT 512 @@ -77,17 +85,33 @@ unsigned int mtk_gamma_get_lut_size(struct device *dev) return LUT_SIZE_DEFAULT; } +/* + * SoCs supporting 12-bits LUTs are using a new register layout that does + * always support (by HW) both 12-bits and 10-bits LUT but, on those, we + * ignore the support for 10-bits in this driver and always use 12-bits. + * + * Summarizing: + * - SoC HW support 9/10-bits LUT only + * - Old register layout + * - 10-bits LUT supported + * - 9-bits LUT not supported + * - SoC HW support both 10/12bits LUT + * - New register layout + * - 12-bits LUT supported + * - 10-its LUT not supported + */ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crtc_state *state) { struct mtk_disp_gamma *gamma; - unsigned int i; + void __iomem *lut0_base = regs + DISP_GAMMA_LUT; + void __iomem *lut1_base = regs + DISP_GAMMA_LUT1; + u32 cfg_val, data_mode, lbank_val, word[2]; + int cur_bank, num_lut_banks; + u16 lut_bank_size, lut_size; struct drm_color_lut *lut; - void __iomem *lut_base; + unsigned int i; bool lut_diff; - u16 lut_bank_size, lut_size; u8 lut_bits; - u32 cfg_val, lbank_val, word; - int cur_bank, num_lut_banks; /* If there's no gamma lut there's nothing to do here. */ if (!state->gamma_lut) @@ -110,14 +134,17 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt num_lut_banks = lut_size / lut_bank_size; cfg_val = readl(regs + DISP_GAMMA_CFG); - lut_base = regs + DISP_GAMMA_LUT; lut = (struct drm_color_lut *)state->gamma_lut->data; + /* Switch to 12 bits data mode if supported */ + data_mode = FIELD_PREP(DISP_GAMMA_BANK_DATA_MODE, !!(lut_bits == 12)); + for (cur_bank = 0; cur_bank < num_lut_banks; cur_bank++) { /* Switch gamma bank and set data mode before writing LUT */ if (num_lut_banks > 1) { lbank_val = FIELD_PREP(DISP_GAMMA_BANK_BANK, cur_bank); + lbank_val |= data_mode; writel(lbank_val, regs + DISP_GAMMA_BANK); } @@ -130,9 +157,15 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt hwlut.blue = drm_color_lut_extract(lut[n].blue, lut_bits); if (!lut_diff || (i % 2 == 0)) { - word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, hwlut.red); - word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, hwlut.green); - word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, hwlut.blue); + if (lut_bits == 12) { + word[0] = FIELD_PREP(DISP_GAMMA_LUT_12BIT_R, hwlut.red); + word[0] |= FIELD_PREP(DISP_GAMMA_LUT_12BIT_G, hwlut.green); + word[1] = FIELD_PREP(DISP_GAMMA_LUT_12BIT_B, hwlut.blue); + } else { + word[0] = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, hwlut.red); + word[0] |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, hwlut.green); + word[0] |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, hwlut.blue); + } } else { diff.red = lut[n].red - lut[n - 1].red; diff.red = drm_color_lut_extract(diff.red, lut_bits); @@ -143,11 +176,19 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt diff.blue = lut[n].blue - lut[n - 1].blue; diff.blue = drm_color_lut_extract(diff.blue, lut_bits); - word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, diff.red); - word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, diff.green); - word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, diff.blue); + if (lut_bits == 12) { + word[0] = FIELD_PREP(DISP_GAMMA_LUT_12BIT_R, diff.red); + word[0] |= FIELD_PREP(DISP_GAMMA_LUT_12BIT_G, diff.green); + word[1] = FIELD_PREP(DISP_GAMMA_LUT_12BIT_B, diff.blue); + } else { + word[0] = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, diff.red); + word[0] |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, diff.green); + word[0] |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_B, diff.blue); + } } - writel(word, (lut_base + i * 4)); + writel(word[0], (lut0_base + i * 4)); + if (lut_bits == 12) + writel(word[1], (lut1_base + i * 4)); } } @@ -271,11 +312,20 @@ static const struct mtk_disp_gamma_data mt8183_gamma_driver_data = { .lut_size = 512, }; +static const struct mtk_disp_gamma_data mt8195_gamma_driver_data = { + .lut_bank_size = 256, + .lut_bits = 12, + .lut_diff = true, + .lut_size = 1024, +}; + static const struct of_device_id mtk_disp_gamma_driver_dt_match[] = { { .compatible = "mediatek,mt8173-disp-gamma", .data = &mt8173_gamma_driver_data}, { .compatible = "mediatek,mt8183-disp-gamma", .data = &mt8183_gamma_driver_data}, + { .compatible = "mediatek,mt8195-disp-gamma", + .data = &mt8195_gamma_driver_data}, {}, }; MODULE_DEVICE_TABLE(of, mtk_disp_gamma_driver_dt_match); From patchwork Mon Jul 31 13:04:38 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: 128711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2036165vqg; Mon, 31 Jul 2023 07:04:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlF+M4N8JcSHP2GI74H/YlqLQzySil1n3LzqJaySDYGDxDF8FIW2/uQyv9H7gcQ2b2J8cnMr X-Received: by 2002:a17:902:c407:b0:1bb:de7f:a49c with SMTP id k7-20020a170902c40700b001bbde7fa49cmr11416708plk.47.1690812286271; Mon, 31 Jul 2023 07:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690812286; cv=none; d=google.com; s=arc-20160816; b=f4kB0gS4QMJujyijzeryaqPRwCCDdvpnS+3YeQcUmqYeAcq+jwuYlNhFCvimvjtCe6 TQo/6p9s0bGTqjsxtht8jMgReS3ZE4iRqavRE3k2InBSv1+n22020uz0n3o/zNwfB8Yt ViBi+dUtaK1lSW9sv9z/2kTfjXOcnHRSKfg7nzdSU6sYC7nORAfjaP6YJMil01GtUZD9 ww/dj92+yziiw7QlsHlrQYLvGmG+6GaBEzwzTCalPRQak+Os0M3TBDwy+xUsw2jBJMi1 6Dq1YwEV4Np5w5jsUdnKgxd4sxnLcnbcIO4sP5jGKUTMWm8PXE5m5iF46O066MTrkUHT +cfw== 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=xHLkCYHaqHmIThAh12xOIQHwcQ+KQC9Ir3p8qjFqDS0=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=kX4oaNSqaHQaMF8CL+t9tUo5y6WBQbyh4kmfe/UaBano+EbSKk5Lq4QREw07gUqgzX qZPPph7ivJ6PkiY1BegS22DWcG0iZdHFICGUdT84o9gagqhNFaoEul4ja1vvkZlYHu/7 MZlDMxE9YIiQjUdk7a3y8mS4jhL4q+sDBS0/8kRPAypmRGoUJEIlKeCC827TCuRHjHaH NVYpPcC3/sBl2cc3HDE8c4PlzOJME/XKwAg//B4SsUh/xt7zptPn+tIyghTeWzkMPX/d j2dGTLkd+BoWxXHqJ/5vYxYVKXInjCgQymZj3pSQehODFb+5ewKm577E4m/z9nH+4ERn E4LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lcyrATkc; 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 fy24-20020a17090b021800b0026384c02c03si7467245pjb.140.2023.07.31.07.04.31; Mon, 31 Jul 2023 07:04:46 -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=lcyrATkc; 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 S230142AbjGaNFV (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232827AbjGaNE6 (ORCPT ); Mon, 31 Jul 2023 09:04:58 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FD1B1709 for ; Mon, 31 Jul 2023 06:04:56 -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 6ED3666070F7; Mon, 31 Jul 2023 14:04:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808695; bh=ku3saUJmkxnMvFquNrLcvYui7sCcvn9fbu+KQWEoQ/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lcyrATkc+TEKSOg4PgIF2EfzSGDC+xLhHA8q5zRAIl+rwklu+l4nJskht8U17VmIV vZK7cjeSoYK+wLz0/1KsZcFid0bZnqCTLBpzJBjt2Irzx293MIDWLkcNJJjkShYQR7 YBhHz17sZI55I2kfx6KN2GFNQsboVrFvD3dHo7Utfovqp7MuGUaF5T+kzEU6BRxsVc 3gX28ifHDhByecdtOp/C6pL8sExcrriURNLKk9mJjqA+FXDKCo5Tu3WLgaPbQIQipN 7mtdM9rohkCX4n+nDxqvOsKweYvCwao/72ZwcrT7ELm+5bHevGb7F1ropoHLE2aqQo fJrSESViVMlxA== 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 10/13] drm/mediatek: gamma: Make sure relay mode is disabled Date: Mon, 31 Jul 2023 15:04:38 +0200 Message-ID: <20230731130441.173960-11-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: 1772945183610130779 X-GMAIL-MSGID: 1772945183610130779 Disable relay mode at the end of LUT programming to make sure that the processed image goes through. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Jason-JH.Lin Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index a846d0dbaa69..659d5c512238 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -19,6 +19,7 @@ #define DISP_GAMMA_EN 0x0000 #define GAMMA_EN BIT(0) #define DISP_GAMMA_CFG 0x0020 +#define GAMMA_RELAY_MODE BIT(0) #define GAMMA_LUT_EN BIT(1) #define GAMMA_DITHERING BIT(2) #define DISP_GAMMA_SIZE 0x0030 @@ -195,6 +196,9 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt /* Enable the gamma table */ cfg_val |= FIELD_PREP(GAMMA_LUT_EN, 1); + /* Disable RELAY mode to pass the processed image */ + cfg_val &= ~GAMMA_RELAY_MODE; + writel(cfg_val, regs + DISP_GAMMA_CFG); } From patchwork Mon Jul 31 13:04:39 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: 128769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2087150vqg; Mon, 31 Jul 2023 08:22:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlFwC2EfsBNFnoX+0ZdDoAoJi8b9qgJYEYTvTHxUFKoudKK6bRiq0AzRTxun2/UjUTKnRiaH X-Received: by 2002:aa7:cd0f:0:b0:522:1f34:2265 with SMTP id b15-20020aa7cd0f000000b005221f342265mr203005edw.2.1690816966621; Mon, 31 Jul 2023 08:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690816966; cv=none; d=google.com; s=arc-20160816; b=PsKNlB/eqn42zIifcrbUPOUumQama7ryBp9djV4XtPNBSqGJ8b133quqyWNtfDdU7F nhTRrXQnohcfQE44fQIkn8XvpHD/Af4KfsnSSiYoskvZKiWElA2AaAn0IVtgyb1tH1UY Uww0rel9S9JLTQRELO+UePRdUoRGnlP7n3wbCRgZJB0lQZ69J3+ezHfatBtkFID+LT6T l6jr0yiySs42LhA1wm/QKTO7QnV20fuDmWild5Q4wKzas2ZhLlFwrxL+lIlgcnuhH9ol RxWL2zl67loqijAK74X5DQdG5I3e7tJBvJ/16u9zkBSvkFq6mu5v8DI2TUWRwPJbycIT KJ4w== 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=KN85wiWkZVFwggRuVX2kPZbQo9VZUZBF4boe+uUJZno=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=Friuj2GYXdU6Brz49QTvcVDceJBVYEziqPTk5KsexQFIwuVr3e/aRctCxlzZ0xKQSy INupRBkngHmmugWNjK1kL18hqOEWPC/4RRSOl04Jir2+uGRm3X3Kpxlo4HjB+We/IHbY aggMOhLBv05cyE4gzI7w2k5WDsrXDkYXo+ZLWDu8+laXg1F/vDLtr+Y3ItZiQZaxTlqs Bmu236bNp/zcgPYpoPTDOS0oTk0kqXowLJ6XvQQI0n7BBpwF+XH/rCms+2RdgP1KCGxR qb23s1359pT/+zL2H9wzRqzDxjkpaOQ5oKzxRSskodxOCuGfVs9fPpVQPbZsnjth6o88 7XaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZVXhalDl; 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 f18-20020a056402151200b0052257c0e629si7513881edw.316.2023.07.31.08.22.22; Mon, 31 Jul 2023 08:22:46 -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=ZVXhalDl; 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 S232740AbjGaNFa (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231991AbjGaNFL (ORCPT ); Mon, 31 Jul 2023 09:05:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF6811723 for ; Mon, 31 Jul 2023 06:04:57 -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 607156607186; Mon, 31 Jul 2023 14:04:55 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808696; bh=JyiXp46HkBH9WpMUqKvCDJPiZ8ZADL6pJeyaAgpHTPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZVXhalDl1WIW+iMpTN24xPmdb/ngijVWmOxfIKgCRiWCiMEJ6rx2i5KSXZj7UTaWF O2gXayCb5nZ2cBc2mMXcN+i1t7j4ma5fxURbmCl/83omsDbkRMlcoFXqBU2pQLsWUH BBtG+ZczQLNOsU7zeObcpmg/pGlKrb/tTb4eZZoyf3zuSlyAbYnZc9FS54RxJu8Ax2 X/vP0E2Xjok6TGFncAb2HhOx5KJIk6YLR8XSnP0Os1+ceHEGRe8ud3kaMlA8jRt7xa yqgSS8znUh0gRTa0zppT8SVLia5WKzR8TITeJJ5TYVh8dhMVBu2gyHLjFkVGG4CRgC QMP0Rpzd4XV/g== 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 11/13] drm/mediatek: gamma: Program gamma LUT type for descending or rising Date: Mon, 31 Jul 2023 15:04:39 +0200 Message-ID: <20230731130441.173960-12-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: 1772950091413278141 X-GMAIL-MSGID: 1772950091413278141 All of the SoCs that don't have dithering control in the gamma IP have got a GAMMA_LUT_TYPE bit that tells to the IP if the LUT is "descending" (bit set) or "rising" (bit cleared): make sure to set it correctly after programming the LUT. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Jason-JH.Lin Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 659d5c512238..6fa3f583f8a1 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -22,6 +22,7 @@ #define GAMMA_RELAY_MODE BIT(0) #define GAMMA_LUT_EN BIT(1) #define GAMMA_DITHERING BIT(2) +#define GAMMA_LUT_TYPE BIT(2) #define DISP_GAMMA_SIZE 0x0030 #define DISP_GAMMA_SIZE_HSIZE GENMASK(28, 16) #define DISP_GAMMA_SIZE_VSIZE GENMASK(12, 0) @@ -86,6 +87,16 @@ unsigned int mtk_gamma_get_lut_size(struct device *dev) return LUT_SIZE_DEFAULT; } +static bool mtk_gamma_lut_is_descending(struct drm_color_lut *lut, u32 lut_size) +{ + u64 first, last; + + first = lut[0].red + lut[0].green + lut[0].blue; + last = lut[lut_size].red + lut[lut_size].green + lut[lut_size].blue; + + return !!(first > last); +} + /* * SoCs supporting 12-bits LUTs are using a new register layout that does * always support (by HW) both 12-bits and 10-bits LUT but, on those, we @@ -193,6 +204,14 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt } } + if (gamma && gamma->data && !gamma->data->has_dither) { + /* Descending or Rising LUT */ + if (mtk_gamma_lut_is_descending(lut, lut_size)) + cfg_val |= FIELD_PREP(GAMMA_LUT_TYPE, 1); + else + cfg_val &= ~GAMMA_LUT_TYPE; + } + /* Enable the gamma table */ cfg_val |= FIELD_PREP(GAMMA_LUT_EN, 1); From patchwork Mon Jul 31 13:04:40 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: 128690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2022535vqg; Mon, 31 Jul 2023 06:41:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlHhdkFHKjtdQNlmKzV/Q4K25xyWGi45AdGy2xhsiaZ8YMCqWktbmWDXqhDtCQjSngEcTfeV X-Received: by 2002:a05:6402:1b1e:b0:522:2019:201e with SMTP id by30-20020a0564021b1e00b005222019201emr5514edb.17.1690810893956; Mon, 31 Jul 2023 06:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690810893; cv=none; d=google.com; s=arc-20160816; b=qaJhrde6CmmmRqO9ltxTok/JOattGzRiedj19x5kIWu0bHxBq0cpLMXBM6xnUSU1I3 J16NPDy+02WbHknrGSUQ3m9P33gE9iJoYL2wa1rvv9EkZ/Owh2fNgou1YiezBW+wOhiD /qhwFlxXIHBNddgrLfxkRKlasZx+TTntZn1vYvobFUdBZSerWDnO8aUORT/Z4A3gRUbU GanpflH33CgnRFzbS1XxqxmiNZYbw5wrs7jYul7UL9HU7z3n5WRzkEyA1UE5tPI72Zvc HAXsbwP7mFTHk3BiQtfOn91KTiNL4yzqUBXDe5t/kqa3oR20FbWvZHARrV2o5vs0+47C 4k0Q== 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=jS5J8eLr8lYnGGhAT+utjtqEaEHn118i5XURQzgOUdk=; fh=9Aon3jQEVE1p+dS8p5fghxMOlPjmNOu/O0E5mCMmCJg=; b=u6DoHnqrrSRf2TSI8UuGUXFHKE1yok5eMyHixAcPYGyGuYTTaYrokU5pUd18Y4+q6D jRk7svYan0npBvefOU3YoGFLsmJ+LNAhpHRo8I4xM4w8jjdzJWMx9rCOCZotjMheFRNB qFRrEO+HaLUaJaWTGiJmY+KlZIFmCF/eeZeRigZKgRUmQENQe9X6d48bPa2wNQ1q9WHU ArJhzHciFI/Qtb+L6wcX2ILe3F55Ou4IkgkC6se69NALvuUBpUe9lR/ki6pVwBs0uGpy RmxwDUTd2BiHGVlp8D9j+1FR1khIAlVcACkGUo2/ecV1o2o/Kh81GG6EDu2/vRUOqJxY chPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="lJ/qBrIl"; 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 v18-20020aa7d9d2000000b0052229b2e04fsi3097619eds.671.2023.07.31.06.41.09; Mon, 31 Jul 2023 06:41:33 -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="lJ/qBrIl"; 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 S230258AbjGaNFf (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230365AbjGaNFM (ORCPT ); Mon, 31 Jul 2023 09:05:12 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA4EB1729 for ; Mon, 31 Jul 2023 06:04:58 -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 516F46607109; Mon, 31 Jul 2023 14:04:56 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808697; bh=Ty0rQR9CismILWHOJ9rVqiJlfrfqryVc5J0W+SMm8aw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJ/qBrIlNdzyNH5lU1jL2PV4Di/QpqJC8xTyJ26kc6HThEVPaX3hFrajMuBrZk8fi Ca/ts09vEPNXLg1Y9D/Udxbk3uS42IgWEn6LKqI8SbYqWPXiOJ5+i2TBXlWth6eFul bCLUGFuBRNZj/4oHQ9ztdljuAXvdqyK9VcqsALMFk8pA5Tc97iZKU0a6s/EXyYx+sU wiWuQqfwbU8GRUvQ+zGGjHJRlFC+prditImZKDWO7oEQhJHS8pvFgwk8FR28SkGLMu 8NuIXr3Fq+fPyxGE/xwg49ZfP8nMCDmUCCZcbVffcKyjqqON/DW8rgfOBB7EllmyjD EJTRjRJd+wQ2A== 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 Subject: [PATCH v7 12/13] drm/mediatek: aal: Rewrite kerneldoc for struct mtk_disp_aal Date: Mon, 31 Jul 2023 15:04:40 +0200 Message-ID: <20230731130441.173960-13-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: 1772943724294334282 X-GMAIL-MSGID: 1772943724294334282 The kerneldoc for struct mtk_disp_aal was entirely wrong: rewrite it to actually document the structure. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_disp_aal.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_aal.c b/drivers/gpu/drm/mediatek/mtk_disp_aal.c index e2e4155faf01..2b51d6f79bfe 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_aal.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_aal.c @@ -26,9 +26,11 @@ struct mtk_disp_aal_data { }; /** - * struct mtk_disp_aal - DISP_AAL driver structure - * @ddp_comp - structure containing type enum and hardware resources - * @crtc - associated crtc to report irq events to + * struct mtk_disp_aal - Display Adaptive Ambient Light driver structure + * @clk: clock for DISP_AAL controller + * @regs: MMIO registers base + * @cmdq_reg: CMDQ Client register + * @data: platform specific data for DISP_AAL */ struct mtk_disp_aal { struct clk *clk; From patchwork Mon Jul 31 13:04:41 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: 128696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2028096vqg; Mon, 31 Jul 2023 06:51:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlFovNeydjAk8abwo1h4i15OtZzAN9hLwBZeBr0ZHdJws+ptjIk05UXSo4wfCQ8gs6I/nifT X-Received: by 2002:a17:906:cc50:b0:993:f127:2391 with SMTP id mm16-20020a170906cc5000b00993f1272391mr7699176ejb.32.1690811510394; Mon, 31 Jul 2023 06:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690811510; cv=none; d=google.com; s=arc-20160816; b=KoslHEiDmZIrwnreZX2tkNF9HEt+uk2PMKZHhbcsc97ua3TCUYXPl3jUCANEJk1xap qRdYEwYU4MK1e4oFH8usFw7yFNGGO7osPPmyFC1v2DntbzAASVxPlmHehqM84b/XHn0A anPQS7mLwew0l5FQ5MFuPN8isRpMk8WDeDfeCgYQuPqs33j7X07Xz4XD6LZ5w/MOVllW 9BNOpDP9HbgAvd5alSM15ZRvTHsfV+sR0vfNoNAZRL2EtxgMmoRAgD5u5D/75zQK2rrp zRDksXT9l6EBPIeL21S5yxBjIoFrY/0thzvLnJyRucl0XhHvoebDfe78rbO09O9Wqbyq Pgyw== 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=A7mNQobM15yRT5EDU/Yn6Q2oH+hIhpVna+0HfgmKdxM=; fh=9Aon3jQEVE1p+dS8p5fghxMOlPjmNOu/O0E5mCMmCJg=; b=UYOuhgD3IsUqBbTFpQuj0rbHMzN6yqnTyWdWcHnbRXwxA1hD8AwoJqJwe1s5g3pTDh dWJG+YIX3Z1QeIwUUjkCI5n0oh/UKJrU2k5WIR5saFOPa63r5o7S5cbHveEooSEx99xg IkZoJIEATq0lNVVvxDavpETT1dURqDAxScwJegMcSnwk0lZ6LHW2CAcm8G9i3YhZXKAu DWxQX/qs252W4rlsrvDLMlcGENNsz7O6KNNdwIPYWVeN8n9FS3cggzIH3xNhQhUTyrwM 5cY23aWQTjH4DF0m9rdFGU3QEklXEILNlFFu779G0tpikWRjaTf3gJulvNDgFLr1aF9O NwLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Neol1ctU; 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 dx6-20020a170906a84600b0099bcb3d5670si6765673ejb.749.2023.07.31.06.51.26; Mon, 31 Jul 2023 06:51:50 -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=Neol1ctU; 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 S232936AbjGaNFi (ORCPT + 99 others); Mon, 31 Jul 2023 09:05:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbjGaNFP (ORCPT ); Mon, 31 Jul 2023 09:05:15 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9579F1735 for ; Mon, 31 Jul 2023 06:04:59 -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 3240D6607190; Mon, 31 Jul 2023 14:04:57 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690808697; bh=oi90BFzw+vRNJ7SDlZut9Au2BJmQDV5m4O2v1GmjzUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Neol1ctUBENvx71Ht4UmmXxdW4B/HmSgfgO4UrxYzk4nyv5+yBqiYSWym7rWoplHb 1wU0NRRTIHt6lmJKxNLd4tzRfL6rYn9YHIlmIX4yQBKeYdFKQcAojop057QAv1/J7x i5KysVJ6F8zps4h31ahGBaNvUsxc+Q+HtynSjyFj5hIJptL7lt/1GtXXKqPvHhLe/6 GEdUPRHMyIyrq8vErVGJt3YDJN/iFNlr2T0ZVd/VjRHWJwetfRD1ingh4+RKimn33v qaIVou/udg7UvsjkZHosSSc3lpn70Fi5zc9gmAd5QRJHLkmbc8ddyW/s6YwuJOn93c gjRLJSOgg8jCA== 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 Subject: [PATCH v7 13/13] drm/mediatek: gamma: Add kerneldoc for struct mtk_disp_gamma Date: Mon, 31 Jul 2023 15:04:41 +0200 Message-ID: <20230731130441.173960-14-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: 1772944370662978401 X-GMAIL-MSGID: 1772944370662978401 The mtk_disp_gamma structure was completely undocumented: add some kerneldoc documentation to it. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 6fa3f583f8a1..ee6b06223291 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -54,8 +54,12 @@ struct mtk_disp_gamma_data { u8 lut_bits; }; -/* - * struct mtk_disp_gamma - DISP_GAMMA driver structure +/** + * struct mtk_disp_gamma - Display Gamma driver structure + * @clk: clock for DISP_GAMMA block + * @regs: MMIO registers base + * @cmdq_reg: CMDQ Client register + * @data: platform data for DISP_GAMMA */ struct mtk_disp_gamma { struct clk *clk;