Hello everyone,
This series is a follow up on my work adding KUnit test to the XRGB8888
conversion functions. This time RGB888, XRGB2101010 and gray8 are added.
Best wishes,
Jose
v1 -> v2:
Tested-by: Maíra Canal <[email protected]>
Reviewed-by: David Gow <[email protected]>
v2 -> v3:
Export symbol drm_fb_xrgb8888_to_xrgb2101010()
v3 -> v4:
Rebased on top of Maíra's prefix renaming work:
https://lore.kernel.org/dri-devel/[email protected]/T/
José Expósito (3):
drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb888()
drm/format-helper: Add KUnit tests for
drm_fb_xrgb8888_to_xrgb2101010()
drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_gray8()
drivers/gpu/drm/drm_format_helper.c | 1 +
.../gpu/drm/tests/drm_format_helper_test.c | 190 ++++++++++++++++++
2 files changed, 191 insertions(+)
base-commit: 961bcdf956a4645745407a5d919be8757549b062
prerequisite-patch-id: 605f4eb1bbdb8ed39cb2ebed95768d922486099f
prerequisite-patch-id: 3818f7fa7c81927c8a88607c4955a45d614ee69a
prerequisite-patch-id: 634952f085f249f2e18893a3f8344a2ff27c13ad
prerequisite-patch-id: fe7ea3dd385fe6c64d7c5c8d65ebe6f9c7ab047b
prerequisite-patch-id: c92ac7a03faee6e1000637928628e7fd127d0159
prerequisite-patch-id: f52fbd427e8730c62b5554f68713e6fa742ffcab
prerequisite-patch-id: 1a2dc68fd107316fd1d1bb91376fe19bdb039147
prerequisite-patch-id: d91c951338cfe9f06e8b8aa74856f6dc08ac8212
prerequisite-patch-id: 41a65e680affc8011670762aec58c373030ef4ea
prerequisite-patch-id: bbd5bf45c2185a9f2a551447247ce13f81df7c2a
prerequisite-patch-id: 9802d5e3291f150a9ceba345628bbf04be972aba
prerequisite-patch-id: 0bae228d241c6c5567c0b58fa4447a3bcb35d5f2
prerequisite-patch-id: e2ed4b2c89623279d2201a81259b49ce56c5bb38
prerequisite-patch-id: 57b3203672cf7617dc1d63d3eb1373e3b2b7ca34
prerequisite-patch-id: 85c127f8e3d55e4210a00d5c84e2c4f92e2e16ad
prerequisite-patch-id: cad729f2d039e636d2f3f937a9f26b1fb4455388
prerequisite-patch-id: c9e696a62ea5f2d4407914ff7a8371e285f33d55
prerequisite-patch-id: 08f30e5572d2e5a8153b563dd4d8fa0ece2cc575
prerequisite-patch-id: c7f7be4f8e90e5eb473a82c293a6b6a0f417e2ba
prerequisite-patch-id: b0c636c391f5d0ebb50a07222f3e41f48cab8c76
prerequisite-patch-id: 705cc9ff7eb3e3e2873cfdb68c2d2272fde38baf
prerequisite-patch-id: cfbe2b5cbfd69cf9f0b11c7c329cf8ec5a2ecff4
prerequisite-patch-id: e7df3b6bbfb6bb87efaf39e73f2e4ed1f83558af
--
2.25.1
Extend the existing test cases to test the conversion from XRGB8888 to
grayscale.
Tested-by: Maíra Canal <[email protected]>
Reviewed-by: David Gow <[email protected]>
Signed-off-by: José Expósito <[email protected]>
---
.../gpu/drm/tests/drm_format_helper_test.c | 62 +++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index 09d358b54da0..71722e828abe 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -37,6 +37,11 @@ struct convert_to_xrgb2101010_result {
const u32 expected[TEST_BUF_SIZE];
};
+struct convert_to_gray8_result {
+ unsigned int dst_pitch;
+ const u8 expected[TEST_BUF_SIZE];
+};
+
struct convert_xrgb8888_case {
const char *name;
unsigned int pitch;
@@ -46,6 +51,7 @@ struct convert_xrgb8888_case {
struct convert_to_rgb565_result rgb565_result;
struct convert_to_rgb888_result rgb888_result;
struct convert_to_xrgb2101010_result xrgb2101010_result;
+ struct convert_to_gray8_result gray8_result;
};
static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
@@ -71,6 +77,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.dst_pitch = 0,
.expected = { 0x3FF00000 },
},
+ .gray8_result = {
+ .dst_pitch = 0,
+ .expected = { 0x4C },
+ },
},
{
.name = "single_pixel_clip_rectangle",
@@ -97,6 +107,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.dst_pitch = 0,
.expected = { 0x3FF00000 },
},
+ .gray8_result = {
+ .dst_pitch = 0,
+ .expected = { 0x4C },
+ },
},
{
/* Well known colors: White, black, red, green, blue, magenta,
@@ -155,6 +169,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
0x3FFFFC00, 0x000FFFFF,
},
},
+ .gray8_result = {
+ .dst_pitch = 0,
+ .expected = {
+ 0xFF, 0x00,
+ 0x4C, 0x99,
+ 0x19, 0x66,
+ 0xE5, 0xB2,
+ },
+ },
},
{
/* Randomly picked colors. Full buffer within the clip area. */
@@ -206,6 +229,14 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
0x2A20300C, 0x1B1705CD, 0x03844672, 0x00000000, 0x00000000,
},
},
+ .gray8_result = {
+ .dst_pitch = 5,
+ .expected = {
+ 0x3C, 0x33, 0x34, 0x00, 0x00,
+ 0x6F, 0x3C, 0x33, 0x00, 0x00,
+ 0x34, 0x6F, 0x3C, 0x00, 0x00,
+ },
+ },
},
};
@@ -381,11 +412,42 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010_test(struct kunit *test)
KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0);
}
+static void drm_test_fb_xrgb8888_to_gray8_test(struct kunit *test)
+{
+ const struct convert_xrgb8888_case *params = test->param_value;
+ const struct convert_to_gray8_result *result = ¶ms->gray8_result;
+ size_t dst_size;
+ __u8 *buf = NULL;
+ __u32 *xrgb8888 = NULL;
+ struct iosys_map dst, src;
+
+ struct drm_framebuffer fb = {
+ .format = drm_format_info(DRM_FORMAT_XRGB8888),
+ .pitches = { params->pitch, 0, 0 },
+ };
+
+ dst_size = conversion_buf_size(DRM_FORMAT_R8, result->dst_pitch,
+ ¶ms->clip);
+ KUNIT_ASSERT_GT(test, dst_size, 0);
+
+ buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
+ iosys_map_set_vaddr(&dst, buf);
+
+ xrgb8888 = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xrgb8888);
+ iosys_map_set_vaddr(&src, xrgb8888);
+
+ drm_fb_xrgb8888_to_gray8(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip);
+ KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0);
+}
+
static struct kunit_case drm_format_helper_test_cases[] = {
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_params),
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb565, convert_xrgb8888_gen_params),
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888_test, convert_xrgb8888_gen_params),
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010_test, convert_xrgb8888_gen_params),
+ KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_gray8_test, convert_xrgb8888_gen_params),
{}
};
--
2.25.1
Hi,
On Mon, Sep 19, 2022 at 09:15:31AM +0200, Jos? Exp?sito wrote:
> Extend the existing test cases to test the conversion from XRGB8888 to
> grayscale.
>
> Tested-by: Ma?ra Canal <[email protected]>
> Reviewed-by: David Gow <[email protected]>
> Signed-off-by: Jos? Exp?sito <[email protected]>
> ---
> .../gpu/drm/tests/drm_format_helper_test.c | 62 +++++++++++++++++++
> 1 file changed, 62 insertions(+)
>
> diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
> index 09d358b54da0..71722e828abe 100644
> --- a/drivers/gpu/drm/tests/drm_format_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
> @@ -37,6 +37,11 @@ struct convert_to_xrgb2101010_result {
> const u32 expected[TEST_BUF_SIZE];
> };
>
> +struct convert_to_gray8_result {
> + unsigned int dst_pitch;
> + const u8 expected[TEST_BUF_SIZE];
> +};
> +
> struct convert_xrgb8888_case {
> const char *name;
> unsigned int pitch;
> @@ -46,6 +51,7 @@ struct convert_xrgb8888_case {
> struct convert_to_rgb565_result rgb565_result;
> struct convert_to_rgb888_result rgb888_result;
> struct convert_to_xrgb2101010_result xrgb2101010_result;
> + struct convert_to_gray8_result gray8_result;
> };
>
> static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
> @@ -71,6 +77,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
> .dst_pitch = 0,
> .expected = { 0x3FF00000 },
> },
> + .gray8_result = {
> + .dst_pitch = 0,
> + .expected = { 0x4C },
> + },
> },
> {
> .name = "single_pixel_clip_rectangle",
> @@ -97,6 +107,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
> .dst_pitch = 0,
> .expected = { 0x3FF00000 },
> },
> + .gray8_result = {
> + .dst_pitch = 0,
> + .expected = { 0x4C },
> + },
> },
> {
> /* Well known colors: White, black, red, green, blue, magenta,
> @@ -155,6 +169,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
> 0x3FFFFC00, 0x000FFFFF,
> },
> },
> + .gray8_result = {
> + .dst_pitch = 0,
> + .expected = {
> + 0xFF, 0x00,
> + 0x4C, 0x99,
> + 0x19, 0x66,
> + 0xE5, 0xB2,
> + },
> + },
> },
> {
> /* Randomly picked colors. Full buffer within the clip area. */
> @@ -206,6 +229,14 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
> 0x2A20300C, 0x1B1705CD, 0x03844672, 0x00000000, 0x00000000,
> },
> },
> + .gray8_result = {
> + .dst_pitch = 5,
> + .expected = {
> + 0x3C, 0x33, 0x34, 0x00, 0x00,
> + 0x6F, 0x3C, 0x33, 0x00, 0x00,
> + 0x34, 0x6F, 0x3C, 0x00, 0x00,
> + },
> + },
> },
> };
>
> @@ -381,11 +412,42 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010_test(struct kunit *test)
> KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0);
> }
>
> +static void drm_test_fb_xrgb8888_to_gray8_test(struct kunit *test)
> +{
> + const struct convert_xrgb8888_case *params = test->param_value;
> + const struct convert_to_gray8_result *result = ¶ms->gray8_result;
> + size_t dst_size;
> + __u8 *buf = NULL;
> + __u32 *xrgb8888 = NULL;
> + struct iosys_map dst, src;
> +
> + struct drm_framebuffer fb = {
> + .format = drm_format_info(DRM_FORMAT_XRGB8888),
> + .pitches = { params->pitch, 0, 0 },
> + };
> +
> + dst_size = conversion_buf_size(DRM_FORMAT_R8, result->dst_pitch,
> + ¶ms->clip);
> + KUNIT_ASSERT_GT(test, dst_size, 0);
> +
> + buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
> + iosys_map_set_vaddr(&dst, buf);
> +
> + xrgb8888 = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xrgb8888);
> + iosys_map_set_vaddr(&src, xrgb8888);
> +
> + drm_fb_xrgb8888_to_gray8(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip);
> + KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0);
> +}
> +
> static struct kunit_case drm_format_helper_test_cases[] = {
> KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_params),
> KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb565, convert_xrgb8888_gen_params),
> KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888_test, convert_xrgb8888_gen_params),
> KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010_test, convert_xrgb8888_gen_params),
> + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_gray8_test, convert_xrgb8888_gen_params),
The trailing test feels redundant, and we should order them
alphabetically to avoid conflicts as much as possible.
Feel free to add my
Acked-by: Maxime Ripard <[email protected]>
And fix this while applying
Maxime
Extend the existing test cases to test the conversion from XRGB8888 to
RGB888.
Tested-by: Maíra Canal <[email protected]>
Reviewed-by: David Gow <[email protected]>
Signed-off-by: José Expósito <[email protected]>
---
.../gpu/drm/tests/drm_format_helper_test.c | 65 +++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index ab49f5e8796c..cc1ab672314a 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -27,6 +27,11 @@ struct convert_to_rgb565_result {
const u16 expected_swab[TEST_BUF_SIZE];
};
+struct convert_to_rgb888_result {
+ unsigned int dst_pitch;
+ const u8 expected[TEST_BUF_SIZE];
+};
+
struct convert_xrgb8888_case {
const char *name;
unsigned int pitch;
@@ -34,6 +39,7 @@ struct convert_xrgb8888_case {
const u32 xrgb8888[TEST_BUF_SIZE];
struct convert_to_rgb332_result rgb332_result;
struct convert_to_rgb565_result rgb565_result;
+ struct convert_to_rgb888_result rgb888_result;
};
static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
@@ -51,6 +57,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.expected = { 0xF800 },
.expected_swab = { 0x00F8 },
},
+ .rgb888_result = {
+ .dst_pitch = 0,
+ .expected = { 0x00, 0x00, 0xFF },
+ },
},
{
.name = "single_pixel_clip_rectangle",
@@ -69,6 +79,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.expected = { 0xF800 },
.expected_swab = { 0x00F8 },
},
+ .rgb888_result = {
+ .dst_pitch = 0,
+ .expected = { 0x00, 0x00, 0xFF },
+ },
},
{
/* Well known colors: White, black, red, green, blue, magenta,
@@ -109,6 +123,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
0xE0FF, 0xFF07,
},
},
+ .rgb888_result = {
+ .dst_pitch = 0,
+ .expected = {
+ 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00,
+ 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF,
+ 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
+ },
+ },
},
{
/* Randomly picked colors. Full buffer within the clip area. */
@@ -141,6 +164,17 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
0x00A8, 0x8E6B, 0x330A, 0x0000, 0x0000,
},
},
+ .rgb888_result = {
+ .dst_pitch = 15,
+ .expected = {
+ 0x9C, 0x44, 0x0E, 0x05, 0x4D, 0x11, 0x03, 0x03, 0xA8,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x73, 0x70, 0x6C, 0x9C, 0x44, 0x0E, 0x05, 0x4D, 0x11,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x03, 0xA8, 0x73, 0x70, 0x6C, 0x9C, 0x44, 0x0E,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ },
+ },
},
};
@@ -255,9 +289,40 @@ static void drm_test_fb_xrgb8888_to_rgb565(struct kunit *test)
KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected_swab, dst_size), 0);
}
+static void drm_test_fb_xrgb8888_to_rgb888_test(struct kunit *test)
+{
+ const struct convert_xrgb8888_case *params = test->param_value;
+ const struct convert_to_rgb888_result *result = ¶ms->rgb888_result;
+ size_t dst_size;
+ __u8 *buf = NULL;
+ __u32 *xrgb8888 = NULL;
+ struct iosys_map dst, src;
+
+ struct drm_framebuffer fb = {
+ .format = drm_format_info(DRM_FORMAT_XRGB8888),
+ .pitches = { params->pitch, 0, 0 },
+ };
+
+ dst_size = conversion_buf_size(DRM_FORMAT_RGB888, result->dst_pitch,
+ ¶ms->clip);
+ KUNIT_ASSERT_GT(test, dst_size, 0);
+
+ buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
+ iosys_map_set_vaddr(&dst, buf);
+
+ xrgb8888 = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xrgb8888);
+ iosys_map_set_vaddr(&src, xrgb8888);
+
+ drm_fb_xrgb8888_to_rgb888(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip);
+ KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0);
+}
+
static struct kunit_case drm_format_helper_test_cases[] = {
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_params),
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb565, convert_xrgb8888_gen_params),
+ KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888_test, convert_xrgb8888_gen_params),
{}
};
--
2.25.1
Extend the existing test cases to test the conversion from XRGB8888 to
XRGB2101010.
In order to be able to call drm_fb_xrgb8888_to_xrgb2101010() when
compiling CONFIG_DRM_KMS_HELPER as a module export the symbol.
Tested-by: Maíra Canal <[email protected]>
Reviewed-by: David Gow <[email protected]>
Signed-off-by: José Expósito <[email protected]>
---
drivers/gpu/drm/drm_format_helper.c | 1 +
.../gpu/drm/tests/drm_format_helper_test.c | 63 +++++++++++++++++++
2 files changed, 64 insertions(+)
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index 4afc4ac27342..e2f76621453c 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -553,6 +553,7 @@ void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *d
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
drm_fb_xrgb8888_to_xrgb2101010_line);
}
+EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010);
static void drm_fb_xrgb8888_to_gray8_line(void *dbuf, const void *sbuf, unsigned int pixels)
{
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index cc1ab672314a..09d358b54da0 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -32,6 +32,11 @@ struct convert_to_rgb888_result {
const u8 expected[TEST_BUF_SIZE];
};
+struct convert_to_xrgb2101010_result {
+ unsigned int dst_pitch;
+ const u32 expected[TEST_BUF_SIZE];
+};
+
struct convert_xrgb8888_case {
const char *name;
unsigned int pitch;
@@ -40,6 +45,7 @@ struct convert_xrgb8888_case {
struct convert_to_rgb332_result rgb332_result;
struct convert_to_rgb565_result rgb565_result;
struct convert_to_rgb888_result rgb888_result;
+ struct convert_to_xrgb2101010_result xrgb2101010_result;
};
static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
@@ -61,6 +67,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.dst_pitch = 0,
.expected = { 0x00, 0x00, 0xFF },
},
+ .xrgb2101010_result = {
+ .dst_pitch = 0,
+ .expected = { 0x3FF00000 },
+ },
},
{
.name = "single_pixel_clip_rectangle",
@@ -83,6 +93,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.dst_pitch = 0,
.expected = { 0x00, 0x00, 0xFF },
},
+ .xrgb2101010_result = {
+ .dst_pitch = 0,
+ .expected = { 0x3FF00000 },
+ },
},
{
/* Well known colors: White, black, red, green, blue, magenta,
@@ -132,6 +146,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
},
},
+ .xrgb2101010_result = {
+ .dst_pitch = 0,
+ .expected = {
+ 0x3FFFFFFF, 0x00000000,
+ 0x3FF00000, 0x000FFC00,
+ 0x000003FF, 0x3FF003FF,
+ 0x3FFFFC00, 0x000FFFFF,
+ },
+ },
},
{
/* Randomly picked colors. Full buffer within the clip area. */
@@ -175,6 +198,14 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
},
+ .xrgb2101010_result = {
+ .dst_pitch = 20,
+ .expected = {
+ 0x03844672, 0x0444D414, 0x2A20300C, 0x00000000, 0x00000000,
+ 0x1B1705CD, 0x03844672, 0x0444D414, 0x00000000, 0x00000000,
+ 0x2A20300C, 0x1B1705CD, 0x03844672, 0x00000000, 0x00000000,
+ },
+ },
},
};
@@ -319,10 +350,42 @@ static void drm_test_fb_xrgb8888_to_rgb888_test(struct kunit *test)
KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0);
}
+static void drm_test_fb_xrgb8888_to_xrgb2101010_test(struct kunit *test)
+{
+ const struct convert_xrgb8888_case *params = test->param_value;
+ const struct convert_to_xrgb2101010_result *result = ¶ms->xrgb2101010_result;
+ size_t dst_size;
+ __u32 *buf = NULL;
+ __u32 *xrgb8888 = NULL;
+ struct iosys_map dst, src;
+
+ struct drm_framebuffer fb = {
+ .format = drm_format_info(DRM_FORMAT_XRGB8888),
+ .pitches = { params->pitch, 0, 0 },
+ };
+
+ dst_size = conversion_buf_size(DRM_FORMAT_XRGB2101010,
+ result->dst_pitch, ¶ms->clip);
+ KUNIT_ASSERT_GT(test, dst_size, 0);
+
+ buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
+ iosys_map_set_vaddr(&dst, buf);
+
+ xrgb8888 = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xrgb8888);
+ iosys_map_set_vaddr(&src, xrgb8888);
+
+ drm_fb_xrgb8888_to_xrgb2101010(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip);
+ buf = le32buf_to_cpu(test, buf, TEST_BUF_SIZE);
+ KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0);
+}
+
static struct kunit_case drm_format_helper_test_cases[] = {
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_params),
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb565, convert_xrgb8888_gen_params),
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888_test, convert_xrgb8888_gen_params),
+ KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010_test, convert_xrgb8888_gen_params),
{}
};
--
2.25.1
Hi Maxime,
Thanks for looking into the patches.
On Mon, Sep 19, 2022 at 09:36:45AM +0200, Maxime Ripard wrote:
> Hi,
>
> On Mon, Sep 19, 2022 at 09:15:31AM +0200, Jos? Exp?sito wrote:
> > Extend the existing test cases to test the conversion from XRGB8888 to
> > grayscale.
> >
> > Tested-by: Ma?ra Canal <[email protected]>
> > Reviewed-by: David Gow <[email protected]>
> > Signed-off-by: Jos? Exp?sito <[email protected]>
> > ---
> > .../gpu/drm/tests/drm_format_helper_test.c | 62 +++++++++++++++++++
> > 1 file changed, 62 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
> > index 09d358b54da0..71722e828abe 100644
> > --- a/drivers/gpu/drm/tests/drm_format_helper_test.c
> > +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
> > @@ -37,6 +37,11 @@ struct convert_to_xrgb2101010_result {
> > const u32 expected[TEST_BUF_SIZE];
> > };
> >
> > +struct convert_to_gray8_result {
> > + unsigned int dst_pitch;
> > + const u8 expected[TEST_BUF_SIZE];
> > +};
> > +
> >
> > [...]
> >
> > static struct kunit_case drm_format_helper_test_cases[] = {
> > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_params),
> > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb565, convert_xrgb8888_gen_params),
> > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888_test, convert_xrgb8888_gen_params),
> > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010_test, convert_xrgb8888_gen_params),
> > + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_gray8_test, convert_xrgb8888_gen_params),
>
> The trailing test feels redundant,
Why do you feel like it is redundant? Under the hood, most conversion
functions reuse the same code, but the *_line() function is unique and
I think that it is worth testing it.
> and we should order them
> alphabetically to avoid conflicts as much as possible.
Good point, I'll sort them alphabetically.
> Feel free to add my
> Acked-by: Maxime Ripard <[email protected]>
>
> And fix this while applying
>
> Maxime
Thanks!
Jose
On Mon, Sep 19, 2022 at 10:18:01AM +0200, Jos? Exp?sito wrote:
> Hi Maxime,
>
> Thanks for looking into the patches.
>
> On Mon, Sep 19, 2022 at 09:36:45AM +0200, Maxime Ripard wrote:
> > Hi,
> >
> > On Mon, Sep 19, 2022 at 09:15:31AM +0200, Jos? Exp?sito wrote:
> > > Extend the existing test cases to test the conversion from XRGB8888 to
> > > grayscale.
> > >
> > > Tested-by: Ma?ra Canal <[email protected]>
> > > Reviewed-by: David Gow <[email protected]>
> > > Signed-off-by: Jos? Exp?sito <[email protected]>
> > > ---
> > > .../gpu/drm/tests/drm_format_helper_test.c | 62 +++++++++++++++++++
> > > 1 file changed, 62 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
> > > index 09d358b54da0..71722e828abe 100644
> > > --- a/drivers/gpu/drm/tests/drm_format_helper_test.c
> > > +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
> > > @@ -37,6 +37,11 @@ struct convert_to_xrgb2101010_result {
> > > const u32 expected[TEST_BUF_SIZE];
> > > };
> > >
> > > +struct convert_to_gray8_result {
> > > + unsigned int dst_pitch;
> > > + const u8 expected[TEST_BUF_SIZE];
> > > +};
> > > +
> > >
> > > [...]
> > >
> > > static struct kunit_case drm_format_helper_test_cases[] = {
> > > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_params),
> > > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb565, convert_xrgb8888_gen_params),
> > > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888_test, convert_xrgb8888_gen_params),
> > > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010_test, convert_xrgb8888_gen_params),
> > > + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_gray8_test, convert_xrgb8888_gen_params),
> >
> > The trailing test feels redundant,
>
> Why do you feel like it is redundant? Under the hood, most conversion
> functions reuse the same code, but the *_line() function is unique and
> I think that it is worth testing it.
Sure, I wasn't commenting on the code itself, but the trailing "test" in
the test name: drm_test_fb_xrgb8888_to_gray8_test
^
Which is redundant since we already have "test" in the prefix.
Maxime
On Mon, Sep 19, 2022 at 10:25:19AM +0200, Maxime Ripard wrote:
> On Mon, Sep 19, 2022 at 10:18:01AM +0200, Jos? Exp?sito wrote:
> > Hi Maxime,
> >
> > Thanks for looking into the patches.
> >
> > On Mon, Sep 19, 2022 at 09:36:45AM +0200, Maxime Ripard wrote:
> > > Hi,
> > >
> > > On Mon, Sep 19, 2022 at 09:15:31AM +0200, Jos? Exp?sito wrote:
> > > > Extend the existing test cases to test the conversion from XRGB8888 to
> > > > grayscale.
> > > >
> > > > Tested-by: Ma?ra Canal <[email protected]>
> > > > Reviewed-by: David Gow <[email protected]>
> > > > Signed-off-by: Jos? Exp?sito <[email protected]>
> > > > ---
> > > > .../gpu/drm/tests/drm_format_helper_test.c | 62 +++++++++++++++++++
> > > > 1 file changed, 62 insertions(+)
> > > >
> > > > diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
> > > > index 09d358b54da0..71722e828abe 100644
> > > > --- a/drivers/gpu/drm/tests/drm_format_helper_test.c
> > > > +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
> > > > @@ -37,6 +37,11 @@ struct convert_to_xrgb2101010_result {
> > > > const u32 expected[TEST_BUF_SIZE];
> > > > };
> > > >
> > > > +struct convert_to_gray8_result {
> > > > + unsigned int dst_pitch;
> > > > + const u8 expected[TEST_BUF_SIZE];
> > > > +};
> > > > +
> > > >
> > > > [...]
> > > >
> > > > static struct kunit_case drm_format_helper_test_cases[] = {
> > > > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_params),
> > > > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb565, convert_xrgb8888_gen_params),
> > > > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888_test, convert_xrgb8888_gen_params),
> > > > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010_test, convert_xrgb8888_gen_params),
> > > > + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_gray8_test, convert_xrgb8888_gen_params),
> > >
> > > The trailing test feels redundant,
> >
> > Why do you feel like it is redundant? Under the hood, most conversion
> > functions reuse the same code, but the *_line() function is unique and
> > I think that it is worth testing it.
>
> Sure, I wasn't commenting on the code itself, but the trailing "test" in
> the test name: drm_test_fb_xrgb8888_to_gray8_test
> ^
>
> Which is redundant since we already have "test" in the prefix.
>
> Maxime
Ah! OK, I misunderstood your first sentence. Indeed, the _test sufix
should be removed, added to my TODO list.
Thanks!!