Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2228709rwb; Thu, 27 Jul 2023 04:19:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlEIJebVndduxM02jLO9Z9e9EDh3zdsibHiYsIGvsPcRmqBfCcGkEMIs7iHOU2++nWZf5O41 X-Received: by 2002:a05:6402:31e8:b0:51e:4bd6:ce4a with SMTP id dy8-20020a05640231e800b0051e4bd6ce4amr1720335edb.11.1690456754527; Thu, 27 Jul 2023 04:19:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690456754; cv=none; d=google.com; s=arc-20160816; b=jXSllB/mOa0/SQ4mJhMrQl94MWQV/kHYPSSuR+cFDU7qlmjgDy6Dyr3ywNOOeyX9cf xlkx2Krbz5loH7cQjXQUch/QEGoOZlo4nFQUFM65h6hq2RJTAgeePViGA0OgL/wMkLGc HPNtu+i6HSZy5eFK74ili727huUoihmmxH52L2VEtMDkWsUpCKfac/Mxw4AGUKu/zU3d 6fh5R97+CxZCzPnz/56I+8ZbRHxve4bauKNKTcRE7SKJujcdw5p4wdvFeLCul7yv+OKa gyqi6TXpMVJchssHdH4WfSGh8uoagmNYFZ4N+jjAyMp3i/5lv1MP7vB4Vk4khCc7Fo0C wuwQ== 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=8z/MAQtUsbNTAMbiwZWgqELq9f/TdOpSaH556EXDWRY=; fh=djell8ixvcyqU/mJ6veJqcbgRwD4nTeRiXMTlgu2sHI=; b=j/SazVGhPGT/wKofLuyn9KQnJxF3cywxCICCH0GGvw8WAmuUhtkPcbMHpFcjW8hrp8 Ysw9fse4txU4WHUpMaSbB2GwozXYiZatAtFsCv8hFl34FICMLZqbSznHyhp1M6CGx4ZY uoirxbwYvKJ7B2owrdEpI6bl1TrMjIrF43hacQSuyvrox4Ijrsw+0mlhbb6r0GA5V3c5 7sk9CXoGmI4ZWiG+5dgakElR+MjMncCpV4yT6/3+ImGxTT9H5QXrtNJk15JetRiFEb8e DaGRYvyBPY7u14iPbwwsJCBjdtLiIQktneRnOQQSqOCqi1aIXtlsKEqR4zQnVon4nO27 6KWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=jt24KnpT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t23-20020a05640203d700b005222bf8eb74si843978edw.277.2023.07.27.04.18.50; Thu, 27 Jul 2023 04:19:14 -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=jt24KnpT; 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 S230185AbjG0JrD (ORCPT + 99 others); Thu, 27 Jul 2023 05:47:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232806AbjG0Jqx (ORCPT ); Thu, 27 Jul 2023 05:46: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 9CA94F2 for ; Thu, 27 Jul 2023 02:46:45 -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 C8BD46607038; Thu, 27 Jul 2023 10:46:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690451204; bh=wvL8C41awqGUjG6vSxsIBQRXHZy+wyE4bNAhpHhiqhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jt24KnpTOCmGKiShdNFN+03ReuLt11LmHWDu+5HOr1OSiYvtitD9k/Yh9G485s50m 1wjHv48alEixg1C4s0cv6oZz2qNQniuAGTerb1m3UbZQnYusuGZk8n8J9PMdEEcw9g i+9MpRJfiaifMmsZXNsmFgjnVZxkBD/P8gao6ULe5P4J1r6OsKDxb+rGqgHxao9/u2 qMeABJuRJ+XY9i+ShCfpTNH3wlkSADOSjiE6lk0sU+9YG6DzjI7t7FCVAx6rMWqCCR r9jWE6snKJJwY0BgQjNpoVZS1/ZHrFulj+k+CZUOqMrg79+EOJSuAFNDdWcI6a3w5A 5sNCQivAR6FCg== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, wenst@chromium.org, kernel@collabora.com, ehristev@collabora.com, "Jason-JH . Lin" Subject: [PATCH RESEND v6 07/11] drm/mediatek: gamma: Support specifying number of bits per LUT component Date: Thu, 27 Jul 2023 11:46:29 +0200 Message-ID: <20230727094633.22505-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727094633.22505-1-angelogioacchino.delregno@collabora.com> References: <20230727094633.22505-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 f4bf5b37992c..407fb0264b80 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -39,6 +39,7 @@ struct mtk_disp_gamma_data { bool has_dither; bool lut_diff; u16 lut_size; + u8 lut_bits; }; /* @@ -84,6 +85,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, }; -- 2.40.1