mirror of
https://github.com/torvalds/linux.git
synced 2026-04-24 01:25:49 -04:00
drm/vkms: Add kunit tests for linear and sRGB LUTs
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> Signed-off-by: Simon Ser <contact@emersion.fr> Link: https://patch.msgid.link/20251115000237.3561250-18-alex.hung@amd.com
This commit is contained in:
committed by
Simon Ser
parent
9b5c7e8b45
commit
cb500b4c24
@@ -6,6 +6,7 @@
|
||||
#include <drm/drm_mode.h>
|
||||
#include "../vkms_composer.h"
|
||||
#include "../vkms_drv.h"
|
||||
#include "../vkms_luts.h"
|
||||
|
||||
#define TEST_LUT_SIZE 16
|
||||
|
||||
@@ -99,6 +100,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)
|
||||
@@ -112,9 +126,33 @@ static void vkms_color_test_lerp(struct kunit *test)
|
||||
}
|
||||
}
|
||||
|
||||
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),
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user