mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robert Mader <robert.mader@collabora.com>
To: dri-devel@lists.freedesktop.org
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>,
	Harry Wentland <harry.wentland@amd.com>,
	Melissa Wen <mwen@igalia.com>,
	Sebastian Wick <sebastian.wick@redhat.com>,
	Robert Mader <robert.mader@collabora.com>,
	Louis Chauvet <louis.chauvet@bootlin.com>,
	Haneen Mohammed <hamohammed.sa@gmail.com>,
	Simona Vetter <simona@ffwll.ch>,
	Melissa Wen <melissa.srw@gmail.com>,
	Oarora Etimis <oaroraetimis@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>,
	Leandro Ribeiro <leandro.ribeiro@collabora.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/4] drm/vkms: Make LUT test reusable
Date: Fri,  4 Dec 2026 15:53:41 +0100	[thread overview]
Message-ID: <20261204145427.221618-3-robert.mader@collabora.com> (raw)
In-Reply-To: <20261204145427.221618-1-robert.mader@collabora.com>

Factor out the logic so we can reuse it for other LUTs and, While on it,
add an average error which will become useful in follow-up commits.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
---
 drivers/gpu/drm/vkms/tests/vkms_color_test.c | 32 +++++++++++++++-----
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c
index c3c61037cb71..c031718b0a41 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_color_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c
@@ -120,20 +120,36 @@ static void vkms_color_test_linear(struct kunit *test)
 	}
 }
 
-static void vkms_color_srgb_inv_srgb(struct kunit *test)
+static void vkms_color_test_inv_lut(struct kunit *test,
+				    const struct vkms_color_lut *lut,
+				    const struct vkms_color_lut *inv_lut,
+				    u16 tolerance_max,
+				    u16 tolerance_avg)
 {
-	u16 srgb, final;
-	u16 tolerance = 11;
-	u32 x;
+	u32 sum = 0;
+	u16 count = 0;
 
 	for (u32 i = 0; i <= 4095; i++) {
+		u16 tmp, final;
+		u32 x;
+
 		x = i * U16_MAX / 4095;
-		srgb = apply_lut_to_channel_value(&srgb_eotf, x, LUT_RED);
-		final = apply_lut_to_channel_value(&srgb_inv_eotf, srgb, LUT_RED);
+		tmp = apply_lut_to_channel_value(lut, x, LUT_RED);
+		final = apply_lut_to_channel_value(inv_lut, tmp, LUT_RED);
 
-		KUNIT_EXPECT_GE(test, final, (int)x - tolerance);
-		KUNIT_EXPECT_LE(test, final, (int)x + tolerance);
+		KUNIT_EXPECT_GE(test, final, (int)x - tolerance_max);
+		KUNIT_EXPECT_LE(test, final, (int)x + tolerance_max);
+
+		sum += abs((int)x - final);
+		count++;
 	}
+
+	KUNIT_EXPECT_LE(test, sum / count, tolerance_avg);
+}
+
+static void vkms_color_srgb_inv_srgb(struct kunit *test)
+{
+	vkms_color_test_inv_lut(test, &srgb_eotf, &srgb_inv_eotf, 11, 0);
 }
 
 #define FIXPT_HALF        (DRM_FIXED_ONE >> 1)
-- 
2.56.1


  parent reply	other threads:[~2026-12-04 14:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 14:53 [PATCH v2 0/4] drm/vkms: Add gamma 2.2 and 2.4 1D curve colorops Robert Mader
2026-12-04 14:53 ` [PATCH v2 1/4] drm/vkms: Fix inverse lut naming scheme in script Robert Mader
2026-12-04 14:53 ` Robert Mader [this message]
2026-12-04 14:53 ` [PATCH v2 3/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22 Robert Mader
2026-12-04 14:53 ` [PATCH v2 4/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24 Robert Mader
2026-12-05  9:55   ` kernel test robot
2026-12-05  9:55   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204145427.221618-3-robert.mader@collabora.com \
    --to=robert.mader@collabora.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=harry.wentland@amd.com \
    --cc=leandro.ribeiro@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis.chauvet@bootlin.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=melissa.srw@gmail.com \
    --cc=mripard@kernel.org \
    --cc=mwen@igalia.com \
    --cc=oaroraetimis@gmail.com \
    --cc=pekka.paalanen@collabora.com \
    --cc=sebastian.wick@redhat.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®