From: Alex Hung <alex.hung@amd.com>
To: <dri-devel@lists.freedesktop.org>, <amd-gfx@lists.freedesktop.org>
Cc: <wayland-devel@lists.freedesktop.org>, <harry.wentland@amd.com>,
<alex.hung@amd.com>, <leo.liu@amd.com>,
<ville.syrjala@linux.intel.com>, <pekka.paalanen@collabora.com>,
<contact@emersion.fr>, <mwen@igalia.com>, <jadahl@redhat.com>,
<sebastian.wick@redhat.com>, <shashank.sharma@amd.com>,
<agoins@nvidia.com>, <joshua@froggi.es>, <mdaenzer@redhat.com>,
<aleixpol@kde.org>, <xaver.hugl@gmail.com>,
<victoria@system76.com>, <daniel@ffwll.ch>,
<uma.shankar@intel.com>, <quic_naseer@quicinc.com>,
<quic_cbraga@quicinc.com>, <quic_abhinavk@quicinc.com>,
<marcan@marcan.st>, <Liviu.Dudau@arm.com>,
<sashamcintosh@google.com>, <chaitanya.kumar.borah@intel.com>,
<louis.chauvet@bootlin.com>, <arthurgrillo@riseup.net>,
Daniel Stone <daniels@collabora.com>
Subject: [PATCH V10 15/46] drm/vkms: Add kunit tests for linear and sRGB LUTs
Date: Mon, 16 Jun 2025 22:16:57 -0600 [thread overview]
Message-ID: <20250617041746.2884343-16-alex.hung@amd.com> (raw)
In-Reply-To: <20250617041746.2884343-1-alex.hung@amd.com>
From: Harry Wentland <harry.wentland@amd.com>
Two tests are added to VKMS LUT handling:
- linear
- inv_srgb
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
---
v7:
- Fix checkpatch warnings (Louis Chauvet)
- Adde a commit messages
- Fix code styles by adding and removing spaces (new lines, tabs and so on)
drivers/gpu/drm/vkms/tests/vkms_color_test.c | 39 +++++++++++++++++++-
drivers/gpu/drm/vkms/vkms_composer.c | 17 ++-------
drivers/gpu/drm/vkms/vkms_composer.h | 13 +++++++
3 files changed, 55 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c
index affca56cac7b..02fbe19c744a 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_color_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c
@@ -6,6 +6,7 @@
#include <drm/drm_mode.h>
#include "../vkms_drv.h"
#include "../vkms_composer.h"
+#include "../vkms_luts.h"
#define TEST_LUT_SIZE 16
@@ -36,7 +37,6 @@ static const struct vkms_color_lut test_linear_lut = {
.channel_value2index_ratio = 0xf000fll
};
-
static void vkms_color_test_get_lut_index(struct kunit *test)
{
s64 lut_index;
@@ -49,6 +49,19 @@ static void vkms_color_test_get_lut_index(struct kunit *test)
lut_index = get_lut_index(&test_linear_lut, test_linear_array[i].red);
KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(lut_index), i);
}
+
+ KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_eotf, 0x0)), 0x0);
+ KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x0)), 0x0);
+ KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x101)), 0x1);
+ KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x202)), 0x2);
+
+ KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0);
+ KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0);
+ KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x101)), 0x1);
+ KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x202)), 0x2);
+
+ KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xfefe)), 0xfe);
+ KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xffff)), 0xff);
}
static void vkms_color_test_lerp(struct kunit *test)
@@ -155,9 +168,33 @@ static void vkms_color_test_lerp(struct kunit *test)
KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x1, 0x80000000), 0x1);
}
+static void vkms_color_test_linear(struct kunit *test)
+{
+ for (int i = 0; i < LUT_SIZE; i++) {
+ int linear = apply_lut_to_channel_value(&linear_eotf, i * 0x101, LUT_RED);
+
+ KUNIT_EXPECT_EQ(test, DIV_ROUND_CLOSEST(linear, 0x101), i);
+ }
+}
+
+static void vkms_color_srgb_inv_srgb(struct kunit *test)
+{
+ u16 srgb, final;
+
+ for (int i = 0; i < LUT_SIZE; i++) {
+ srgb = apply_lut_to_channel_value(&srgb_eotf, i * 0x101, LUT_RED);
+ final = apply_lut_to_channel_value(&srgb_inv_eotf, srgb, LUT_RED);
+
+ KUNIT_EXPECT_GE(test, final / 0x101, i - 1);
+ KUNIT_EXPECT_LE(test, final / 0x101, i + 1);
+ }
+}
+
static struct kunit_case vkms_color_test_cases[] = {
KUNIT_CASE(vkms_color_test_get_lut_index),
KUNIT_CASE(vkms_color_test_lerp),
+ KUNIT_CASE(vkms_color_test_linear),
+ KUNIT_CASE(vkms_color_srgb_inv_srgb),
{}
};
diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 3ab829556db2..72890ffea13a 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -82,19 +82,8 @@ VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel
}
EXPORT_SYMBOL_IF_KUNIT(get_lut_index);
-/*
- * This enum is related to the positions of the variables inside
- * `struct drm_color_lut`, so the order of both needs to be the same.
- */
-enum lut_channel {
- LUT_RED = 0,
- LUT_GREEN,
- LUT_BLUE,
- LUT_RESERVED
-};
-
-static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value,
- enum lut_channel channel)
+VISIBLE_IF_KUNIT u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value,
+ enum lut_channel channel)
{
s64 lut_index = get_lut_index(lut, channel_value);
u16 *floor_lut_value, *ceil_lut_value;
@@ -119,6 +108,8 @@ static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 chan
return lerp_u16(floor_channel_value, ceil_channel_value,
lut_index & DRM_FIXED_DECIMAL_MASK);
}
+EXPORT_SYMBOL_IF_KUNIT(apply_lut_to_channel_value);
+
static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buffer *output_buffer)
{
diff --git a/drivers/gpu/drm/vkms/vkms_composer.h b/drivers/gpu/drm/vkms/vkms_composer.h
index 9316a053e7d7..67ae09913460 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.h
+++ b/drivers/gpu/drm/vkms/vkms_composer.h
@@ -5,9 +5,22 @@
#include <kunit/visibility.h>
+/*
+ * This enum is related to the positions of the variables inside
+ * `struct drm_color_lut`, so the order of both needs to be the same.
+ */
+enum lut_channel {
+ LUT_RED = 0,
+ LUT_GREEN,
+ LUT_BLUE,
+ LUT_RESERVED
+};
+
#if IS_ENABLED(CONFIG_KUNIT)
u16 lerp_u16(u16 a, u16 b, s64 t);
s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value);
+u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value,
+ enum lut_channel channel);
#endif
#endif /* _VKMS_COMPOSER_H_ */
--
2.43.0
next prev parent reply other threads:[~2025-06-17 4:22 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 4:16 [PATCH V10 00/46] Color Pipeline API w/ VKMS Alex Hung
2025-06-17 4:16 ` [PATCH V10 01/46] drm: Add helper for conversion from signed-magnitude Alex Hung
2025-06-17 4:16 ` [PATCH V10 02/46] drm/vkms: Add kunit tests for VKMS LUT handling Alex Hung
2025-06-17 10:54 ` Maíra Canal
2025-06-17 4:16 ` [PATCH V10 03/46] drm/doc/rfc: Describe why prescriptive color pipeline is needed Alex Hung
2025-06-17 4:16 ` [PATCH V10 04/46] drm/colorop: Introduce new drm_colorop mode object Alex Hung
2025-06-17 4:16 ` [PATCH V10 05/46] drm/colorop: Add TYPE property Alex Hung
2025-06-17 4:16 ` [PATCH V10 06/46] drm/colorop: Add 1D Curve subtype Alex Hung
2025-06-17 4:16 ` [PATCH V10 07/46] drm/colorop: Add BYPASS property Alex Hung
2025-06-17 4:16 ` [PATCH V10 08/46] drm/colorop: Add NEXT property Alex Hung
2025-06-17 4:16 ` [PATCH V10 09/46] drm/colorop: Add atomic state print for drm_colorop Alex Hung
2025-06-17 4:16 ` [PATCH V10 10/46] drm/plane: Add COLOR PIPELINE property Alex Hung
2025-06-17 4:16 ` [PATCH V10 11/46] drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE Alex Hung
2025-06-17 4:16 ` [PATCH V10 12/46] Documentation/gpu: document drm_colorop Alex Hung
2025-06-17 4:16 ` [PATCH V10 13/46] drm/colorop: Add destroy functions for color pipeline Alex Hung
2025-07-31 22:11 ` Nícolas F. R. A. Prado
2025-08-03 10:24 ` Simon Ser
2025-06-17 4:16 ` [PATCH V10 14/46] drm/vkms: Add enumerated 1D curve colorop Alex Hung
2025-06-17 4:16 ` Alex Hung [this message]
2025-06-18 17:59 ` [PATCH V10 15/46] drm/vkms: Add kunit tests for linear and sRGB LUTs kernel test robot
2025-06-17 4:16 ` [PATCH V10 16/46] drm/colorop: Add 3x4 CTM type Alex Hung
2025-06-17 4:16 ` [PATCH V10 17/46] drm/vkms: Use s32 for internal color pipeline precision Alex Hung
2025-06-17 4:17 ` [PATCH V10 18/46] drm/vkms: add 3x4 matrix in color pipeline Alex Hung
2025-07-30 21:42 ` Nícolas F. R. A. Prado
2025-06-17 4:17 ` [PATCH V10 19/46] drm/tests: Add a few tests around drm_fixed.h Alex Hung
2025-06-17 11:04 ` Maíra Canal
2025-06-17 14:17 ` Wentland, Harry
2025-06-17 4:17 ` [PATCH V10 20/46] drm/vkms: Add tests for CTM handling Alex Hung
2025-06-17 4:17 ` [PATCH V10 21/46] drm/colorop: pass plane_color_pipeline client cap to atomic check Alex Hung
2025-06-17 4:17 ` [PATCH V10 22/46] drm/colorop: define a new macro for_each_new_colorop_in_state Alex Hung
2025-06-17 4:17 ` [PATCH V10 23/46] drm/amd/display: Ignore deprecated props when plane_color_pipeline set Alex Hung
2025-06-17 4:17 ` [PATCH V10 24/46] drm/amd/display: Add bypass COLOR PIPELINE Alex Hung
2025-06-17 4:17 ` [PATCH V10 25/46] drm/amd/display: Skip color pipeline initialization for cursor plane Alex Hung
2025-06-17 4:17 ` [PATCH V10 26/46] drm/amd/display: Add support for sRGB EOTF in DEGAM block Alex Hung
2025-07-09 19:45 ` Melissa Wen
2025-06-17 4:17 ` [PATCH V10 27/46] drm/amd/display: Add support for sRGB Inverse EOTF in SHAPER block Alex Hung
2025-06-17 4:17 ` [PATCH V10 28/46] drm/amd/display: Add support for sRGB EOTF in BLND block Alex Hung
2025-06-17 4:17 ` [PATCH V10 29/46] drm/colorop: Add PQ 125 EOTF and its inverse Alex Hung
2025-06-17 4:17 ` [PATCH V10 30/46] drm/amd/display: Enable support for PQ 125 EOTF and Inverse Alex Hung
2025-06-17 4:17 ` [PATCH V10 31/46] drm/colorop: add BT2020/BT709 OETF and Inverse OETF Alex Hung
2025-06-17 4:17 ` [PATCH V10 32/46] drm/amd/display: Add support for BT.709 and BT.2020 TFs Alex Hung
2025-06-17 4:17 ` [PATCH V10 33/46] drm: Add Enhanced LUT precision structure Alex Hung
2025-07-08 15:10 ` Simon Ser
2025-07-11 16:28 ` Alex Hung
2025-07-15 4:37 ` Borah, Chaitanya Kumar
2025-07-15 7:44 ` Shankar, Uma
2025-07-15 22:08 ` Alex Hung
2025-07-09 18:49 ` Borah, Chaitanya Kumar
2025-07-11 16:25 ` Alex Hung
2025-06-17 4:17 ` [PATCH V10 34/46] drm/colorop: Add 1D Curve Custom LUT type Alex Hung
2025-06-17 4:17 ` [PATCH V10 35/46] drm/amd/display: add shaper and blend colorops for 1D Curve Custom LUT Alex Hung
2025-06-18 4:41 ` kernel test robot
2025-06-17 4:17 ` [PATCH V10 36/46] drm/amd/display: add 3x4 matrix colorop Alex Hung
2025-06-17 4:17 ` [PATCH V10 37/46] drm/colorop: Add multiplier type Alex Hung
2025-06-17 4:17 ` [PATCH V10 38/46] drm/amd/display: add multiplier colorop Alex Hung
2025-06-17 4:17 ` [PATCH V10 39/46] drm/amd/display: Swap matrix and multiplier Alex Hung
2025-06-17 4:17 ` [PATCH V10 40/46] drm/colorop: Define LUT_1D interpolation Alex Hung
2025-07-09 20:30 ` Simon Ser
2025-08-02 1:49 ` Alex Hung
2025-08-02 1:55 ` Simon Ser
2025-08-04 22:14 ` Xaver Hugl
2025-06-17 4:17 ` [PATCH V10 41/46] drm/colorop: allow non-bypass colorops Alex Hung
2025-07-23 14:00 ` Nícolas F. R. A. Prado
2025-06-17 4:17 ` [PATCH V10 42/46] drm/colorop: Add 3D LUT support to color pipeline Alex Hung
2025-06-17 4:17 ` [PATCH V10 43/46] drm/amd/display: add 3D LUT colorop Alex Hung
2025-08-04 19:51 ` Nícolas F. R. A. Prado
2025-08-12 23:05 ` Alex Hung
2025-06-17 4:17 ` [PATCH V10 44/46] drm/amd/display: Add AMD color pipeline doc Alex Hung
2025-06-17 4:17 ` [PATCH V10 45/46] drm/amd/display: Ensure 3D LUT for color pipeline Alex Hung
2025-07-09 19:56 ` Melissa Wen
2025-08-02 1:59 ` Alex Hung
2025-06-17 4:17 ` [PATCH V10 46/46] drm/amd/display: Disable CRTC degamma when color pipeline is enabled Alex Hung
2025-07-09 19:58 ` Melissa Wen
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=20250617041746.2884343-16-alex.hung@amd.com \
--to=alex.hung@amd.com \
--cc=Liviu.Dudau@arm.com \
--cc=agoins@nvidia.com \
--cc=aleixpol@kde.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=arthurgrillo@riseup.net \
--cc=chaitanya.kumar.borah@intel.com \
--cc=contact@emersion.fr \
--cc=daniel@ffwll.ch \
--cc=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=jadahl@redhat.com \
--cc=joshua@froggi.es \
--cc=leo.liu@amd.com \
--cc=louis.chauvet@bootlin.com \
--cc=marcan@marcan.st \
--cc=mdaenzer@redhat.com \
--cc=mwen@igalia.com \
--cc=pekka.paalanen@collabora.com \
--cc=quic_abhinavk@quicinc.com \
--cc=quic_cbraga@quicinc.com \
--cc=quic_naseer@quicinc.com \
--cc=sashamcintosh@google.com \
--cc=sebastian.wick@redhat.com \
--cc=shashank.sharma@amd.com \
--cc=uma.shankar@intel.com \
--cc=victoria@system76.com \
--cc=ville.syrjala@linux.intel.com \
--cc=wayland-devel@lists.freedesktop.org \
--cc=xaver.hugl@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).