From patchwork Thu Aug 3 11:02:07 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: 130526 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp1091366vqx; Thu, 3 Aug 2023 04:53:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlGg/aOtI1WQyibwESUnJPIaLehXEi+gnO0f1DfEen/Mk1LR64ZX7UFbqTrQ1KF6fm/7gi05 X-Received: by 2002:a05:6808:1314:b0:3a7:57a6:e077 with SMTP id y20-20020a056808131400b003a757a6e077mr5603073oiv.37.1691063581907; Thu, 03 Aug 2023 04:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691063581; cv=none; d=google.com; s=arc-20160816; b=KvW+dgE6EjiTVRwTWKoCTRbL//5k/qxE0YQcdQXv8QyAHdNWcseuZRdyuglVKiPZEF pvDWvlzzAwYd++VjvNEOagCRXbe2REBdtwrrN5sO6FINwqbQwiIq2plQxzBf7Hm8v/Bq FUhFQzVu0aBXy7j0MDPJBlhMzSLg6X5otUMcG9QrOs9d2AK+ZWrCTAnBcmnkUxJWYjGS M/FYuEqYTKmBSERcZjaU6U/FcoBAEcp4romHoygQpUF8+hT0Um4Tb/2CGMxI+vKsZ1EC X7NoVPw5XFSymBsmxFjNcApRS4EVc+Mrg86nL3kuDQlGf68pDdq8YGVL5kdIeBJA9pSf bBJA== 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=kMdA727ML9GfYlwdB+N4dG3v8MdPr2da4KnC11PmGzE=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=d1pJB6zdv7z/7tUYqt8y+ZBBqAaV9Yd+RCl/nAymH76uwnew0ZqhbMSvqPvzPDt+xm kEzE2SNlfRj6c0d+L059j2o+VNJuafiFVE25SbLf6HwuQR+8+4rso7GfIzRe9RwONv29 HQrzM4Qlb+KG3f0Em1qMdr3zYsgCvMGqo6w5FGzFewvC+AOQwSMjJIZObV1TdfHU0c2f IOA4CtSgyIfszL9CYchoqNXPFr9SjnDerzKf6t0XGUr36gC470fEBckd/UYgK1r1VPwA 0JlZVBduuwikKW2mRBLKvZ1mlHVG+kUb0tr8Ss479fCzVEMjry0fJ7DKv6ARkthT4gRt u6SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=d0+Ftu88; 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 c12-20020a17090ad90c00b00262e5a82047si3007767pjv.44.2023.08.03.04.52.48; Thu, 03 Aug 2023 04:53:01 -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=d0+Ftu88; 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 S234018AbjHCLD2 (ORCPT + 99 others); Thu, 3 Aug 2023 07:03:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235359AbjHCLCb (ORCPT ); Thu, 3 Aug 2023 07:02:31 -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 846653A81 for ; Thu, 3 Aug 2023 04:02:30 -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 ACC3966071A9; Thu, 3 Aug 2023 12:02:28 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1691060549; bh=G9jUBbuND2wlk1NRIFaK24JaPI1K8tQwQG9IqubvDH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d0+Ftu88Cle2UkG96ilsTMn3206yazQ+Zze/3bL+tu2NQY2HNUsR1fN6VXUKAien3 GPGsUDgh0UtvOAULHZtxE83y5iLZMWn9uAFzIhA9g0TInmjQm+XKR0MyOva0h7274o wJJwkMDMNSJh3jiXOJWw3bAkiqmszPt0vZqF/DDK3pYRUweMPgn+Md8RFydu2CplwJ 6HKPyX4a4wN3u08M0OI0w6TAQAN2Iwj9ju24RefjXNQA3AGLX7E8dMyKs9e4xp+o5t rv3OFD0coc3DetFGDz7TqGdJxqhtpjiOUjvxnwnbS3IW1PDbNcdYyl+V3sEOMiLanO wfWQKzS0G7gbQ== 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 v9 09/16] drm/mediatek: gamma: Support specifying number of bits per LUT component Date: Thu, 3 Aug 2023 13:02:07 +0200 Message-ID: <20230803110214.163645-10-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803110214.163645-1-angelogioacchino.delregno@collabora.com> References: <20230803110214.163645-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: 1773208686652547600 X-GMAIL-MSGID: 1773208686652547600 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 001b98694761..1845bd326a6d 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; }; /* @@ -91,9 +92,9 @@ void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state) for (i = 0; i < gamma->data->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, gamma->data->lut_bits); + hwlut.green = drm_color_lut_extract(lut[i].green, gamma->data->lut_bits); + hwlut.blue = drm_color_lut_extract(lut[i].blue, gamma->data->lut_bits); if (!gamma->data->lut_diff || (i % 2 == 0)) { word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, hwlut.red); @@ -101,13 +102,13 @@ void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state) 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, gamma->data->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, gamma->data->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, gamma->data->lut_bits); word = FIELD_PREP(DISP_GAMMA_LUT_10BIT_R, diff.red); word |= FIELD_PREP(DISP_GAMMA_LUT_10BIT_G, diff.green); @@ -217,10 +218,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, };