[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220627161132.33256-5-jose.exposito89@gmail.com>
Date: Mon, 27 Jun 2022 18:11:32 +0200
From: José Expósito <jose.exposito89@...il.com>
To: javierm@...hat.com
Cc: davidgow@...gle.com, dlatypov@...gle.com, tzimmermann@...e.de,
mripard@...nel.org, daniel@...ll.ch, airlied@...ux.ie,
maarten.lankhorst@...ux.intel.com, jani.nikula@...ux.intel.com,
maira.canal@....br, isabbasso@...eup.net, magalilemes00@...il.com,
tales.aparecida@...il.com, dri-devel@...ts.freedesktop.org,
kunit-dev@...glegroups.com, linux-kernel@...r.kernel.org,
José Expósito <jose.exposito89@...il.com>
Subject: [PATCH 4/4] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb565()
Extend the existing test cases to test the conversion from XRGB8888 to
RGB565.
The documentation and the color picker available on [1] are useful
resources to understand this patch and validate the values returned by
the conversion function.
[1] http://www.barth-dev.de/online/rgb565-color-picker/
Signed-off-by: José Expósito <jose.exposito89@...il.com>
---
.../gpu/drm/tests/drm_format_helper_test.c | 100 +++++++++++++++++-
1 file changed, 99 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index 52dc41cc7c60..3fbe8026bccc 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -48,7 +48,7 @@ struct convert_xrgb8888_case {
unsigned int pitch;
struct drm_rect clip;
const u32 xrgb8888[TEST_BUF_SIZE];
- struct convert_xrgb8888_result results[1];
+ struct convert_xrgb8888_result results[3];
};
static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
@@ -64,6 +64,26 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.dst_pitch = 0,
.expected = { 0xE0 },
},
+ {
+ .dst_format = DRM_FORMAT_RGB565,
+ .has_swab = true,
+ .conv_swab = {
+ .func = drm_fb_xrgb8888_to_rgb565,
+ .swab = false,
+ },
+ .dst_pitch = 0,
+ .expected = { 0x00, 0xF8 },
+ },
+ {
+ .dst_format = DRM_FORMAT_RGB565,
+ .has_swab = true,
+ .conv_swab = {
+ .func = drm_fb_xrgb8888_to_rgb565,
+ .swab = true,
+ },
+ .dst_pitch = 0,
+ .expected = { 0xF8, 0x00 },
+ },
},
},
{
@@ -81,6 +101,26 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.dst_pitch = 0,
.expected = { 0xE0 },
},
+ {
+ .dst_format = DRM_FORMAT_RGB565,
+ .has_swab = true,
+ .conv_swab = {
+ .func = drm_fb_xrgb8888_to_rgb565,
+ .swab = false,
+ },
+ .dst_pitch = 0,
+ .expected = { 0x00, 0xF8 },
+ },
+ {
+ .dst_format = DRM_FORMAT_RGB565,
+ .has_swab = true,
+ .conv_swab = {
+ .func = drm_fb_xrgb8888_to_rgb565,
+ .swab = true,
+ },
+ .dst_pitch = 0,
+ .expected = { 0xF8, 0x00 },
+ },
},
},
{
@@ -110,6 +150,36 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
0xFC, 0x1F,
},
},
+ {
+ .dst_format = DRM_FORMAT_RGB565,
+ .has_swab = true,
+ .conv_swab = {
+ .func = drm_fb_xrgb8888_to_rgb565,
+ .swab = false,
+ },
+ .dst_pitch = 0,
+ .expected = {
+ 0xFF, 0xFF, 0x00, 0x00,
+ 0x00, 0xF8, 0xE0, 0x07,
+ 0x1F, 0x00, 0x1F, 0xF8,
+ 0xE0, 0xFF, 0xFF, 0x07,
+ },
+ },
+ {
+ .dst_format = DRM_FORMAT_RGB565,
+ .has_swab = true,
+ .conv_swab = {
+ .func = drm_fb_xrgb8888_to_rgb565,
+ .swab = true,
+ },
+ .dst_pitch = 0,
+ .expected = {
+ 0xFF, 0xFF, 0x00, 0x00,
+ 0xF8, 0x00, 0x07, 0xE0,
+ 0x00, 0x1F, 0xF8, 0x1F,
+ 0xFF, 0xE0, 0x07, 0xFF,
+ },
+ },
},
},
{
@@ -133,6 +203,34 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
0xA0, 0x6D, 0x0A, 0x00, 0x00,
},
},
+ {
+ .dst_format = DRM_FORMAT_RGB565,
+ .has_swab = true,
+ .conv_swab = {
+ .func = drm_fb_xrgb8888_to_rgb565,
+ .swab = false,
+ },
+ .dst_pitch = 10,
+ .expected = {
+ 0x33, 0x0A, 0x60, 0x12, 0x00, 0xA8, 0x00, 0x00, 0x00, 0x00,
+ 0x8E, 0x6B, 0x33, 0x0A, 0x60, 0x12, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xA8, 0x8E, 0x6B, 0x33, 0x0A, 0x00, 0x00, 0x00, 0x00,
+ },
+ },
+ {
+ .dst_format = DRM_FORMAT_RGB565,
+ .has_swab = true,
+ .conv_swab = {
+ .func = drm_fb_xrgb8888_to_rgb565,
+ .swab = true,
+ },
+ .dst_pitch = 10,
+ .expected = {
+ 0x0A, 0x33, 0x12, 0x60, 0xA8, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x6B, 0x8E, 0x0A, 0x33, 0x12, 0x60, 0x00, 0x00, 0x00, 0x00,
+ 0xA8, 0x00, 0x6B, 0x8E, 0x0A, 0x33, 0x00, 0x00, 0x00, 0x00,
+ },
+ },
},
},
};
--
2.25.1
Powered by blists - more mailing lists