* [PATCH v3 0/2] drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono()
@ 2023-03-11 12:51 Arthur Grillo
2023-03-11 12:51 ` [PATCH v3 1/2] " Arthur Grillo
2023-03-11 12:51 ` [PATCH v3 2/2] drm/format-helper: Make "destination_pitch" test case usable for the monochrome case Arthur Grillo
0 siblings, 2 replies; 7+ messages in thread
From: Arthur Grillo @ 2023-03-11 12:51 UTC (permalink / raw)
To: dri-devel
Cc: davidgow, tales.aparecida, javierm, mairacanal, tzimmermann,
jose.exposito89, andrealmeid, Arthur Grillo
This patchset aims to insert a unit test for the conversion from
XRGB8888 to monochromatic.
Previously this was a single patch, but as the changes grew from v1 to
v2, I thought it would be better to split it in two.
Thanks for reviewing!
Best regards,
~Arthur Grillo
---
v1->v2: https://lore.kernel.org/all/20230302200131.754154-1-arthurgrillo@riseup.net/
- Remove extra helper an use the existing one that Javier patched [1].
- Make the expected results more intuitive by using the BIT macro.
- Change the "destination_pitch" test case colors.
v2->v3: https://lore.kernel.org/all/20230310200901.216971-1-arthurgrillo@riseup.net/
- Use binary constants instead of the BIT macros, to suppress a
warning pointed out by the kernel bot and still maintain the
intuitive intention.
---
[1]: https://lore.kernel.org/all/20230307215039.346863-1-javierm@redhat.com/
---
Arthur Grillo (2):
drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono()
drm/format-helper: Make "destination_pitch" test case usable for the
monochrome case
.../gpu/drm/tests/drm_format_helper_test.c | 134 +++++++++++++-----
1 file changed, 98 insertions(+), 36 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/2] drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono()
2023-03-11 12:51 [PATCH v3 0/2] drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono() Arthur Grillo
@ 2023-03-11 12:51 ` Arthur Grillo
2023-03-14 19:08 ` Javier Martinez Canillas
2023-03-11 12:51 ` [PATCH v3 2/2] drm/format-helper: Make "destination_pitch" test case usable for the monochrome case Arthur Grillo
1 sibling, 1 reply; 7+ messages in thread
From: Arthur Grillo @ 2023-03-11 12:51 UTC (permalink / raw)
To: dri-devel
Cc: davidgow, tales.aparecida, javierm, mairacanal, tzimmermann,
jose.exposito89, andrealmeid, Arthur Grillo
Extend the existing test cases to test the conversion from XRGB8888 to
monochromatic.
Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
---
.../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 84b5cc29c8fc..041b3d2f100f 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -67,6 +67,11 @@ struct convert_to_argb2101010_result {
const u32 expected[TEST_BUF_SIZE];
};
+struct convert_to_mono_result {
+ unsigned int dst_pitch;
+ const u8 expected[TEST_BUF_SIZE];
+};
+
struct convert_xrgb8888_case {
const char *name;
unsigned int pitch;
@@ -82,6 +87,7 @@ struct convert_xrgb8888_case {
struct convert_to_argb8888_result argb8888_result;
struct convert_to_xrgb2101010_result xrgb2101010_result;
struct convert_to_argb2101010_result argb2101010_result;
+ struct convert_to_mono_result mono_result;
};
static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
@@ -131,6 +137,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.dst_pitch = 0,
.expected = { 0xFFF00000 },
},
+ .mono_result = {
+ .dst_pitch = 0,
+ .expected = { 0b0 },
+ },
},
{
.name = "single_pixel_clip_rectangle",
@@ -181,6 +191,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.dst_pitch = 0,
.expected = { 0xFFF00000 },
},
+ .mono_result = {
+ .dst_pitch = 0,
+ .expected = { 0b0 },
+ },
},
{
/* Well known colors: White, black, red, green, blue, magenta,
@@ -293,6 +307,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
0xFFFFFC00, 0xC00FFFFF,
},
},
+ .mono_result = {
+ .dst_pitch = 0,
+ .expected = {
+ 0b01,
+ 0b10,
+ 0b00,
+ 0b11,
+ },
+ },
},
{
/* Randomly picked colors. Full buffer within the clip area. */
@@ -392,6 +415,14 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
0xEA20300C, 0xDB1705CD, 0xC3844672, 0x00000000, 0x00000000,
},
},
+ .mono_result = {
+ .dst_pitch = 2,
+ .expected = {
+ 0b000, 0b000,
+ 0b000, 0b000,
+ 0b000, 0b000,
+ },
+ },
},
};
@@ -792,6 +823,36 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test)
KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
}
+static void drm_test_fb_xrgb8888_to_mono(struct kunit *test)
+{
+ const struct convert_xrgb8888_case *params = test->param_value;
+ const struct convert_to_mono_result *result = ¶ms->mono_result;
+ size_t dst_size;
+ u8 *buf = NULL;
+ __le32 *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_C1, 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 = cpubuf_to_le32(test, params->xrgb8888, TEST_BUF_SIZE);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xrgb8888);
+ iosys_map_set_vaddr(&src, xrgb8888);
+
+ drm_fb_xrgb8888_to_mono(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip);
+ KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
+}
+
static struct kunit_case drm_format_helper_test_cases[] = {
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_gray8, convert_xrgb8888_gen_params),
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_params),
@@ -803,6 +864,7 @@ static struct kunit_case drm_format_helper_test_cases[] = {
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_argb8888, convert_xrgb8888_gen_params),
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010, convert_xrgb8888_gen_params),
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_argb2101010, convert_xrgb8888_gen_params),
+ KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_mono, convert_xrgb8888_gen_params),
{}
};
--
2.39.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/2] drm/format-helper: Make "destination_pitch" test case usable for the monochrome case
2023-03-11 12:51 [PATCH v3 0/2] drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono() Arthur Grillo
2023-03-11 12:51 ` [PATCH v3 1/2] " Arthur Grillo
@ 2023-03-11 12:51 ` Arthur Grillo
2023-03-14 19:11 ` Javier Martinez Canillas
1 sibling, 1 reply; 7+ messages in thread
From: Arthur Grillo @ 2023-03-11 12:51 UTC (permalink / raw)
To: dri-devel
Cc: davidgow, tales.aparecida, javierm, mairacanal, tzimmermann,
jose.exposito89, andrealmeid, Arthur Grillo
This test case uses an arbitrary pitch size, different of the default
one, to test if the conversions methods obey.
Change the "destination_pitch" colors to change the monochrome expected
result from being just zeros, as this makes the arbitrary pitch use
unusable.
Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
---
.../gpu/drm/tests/drm_format_helper_test.c | 78 +++++++++----------
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index 041b3d2f100f..bfa47f8ffd09 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -323,104 +323,104 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
.pitch = 3 * 4,
.clip = DRM_RECT_INIT(0, 0, 3, 3),
.xrgb8888 = {
- 0xA10E449C, 0xB1114D05, 0xC1A80303,
- 0xD16C7073, 0xA20E449C, 0xB2114D05,
- 0xC2A80303, 0xD26C7073, 0xA30E449C,
+ 0xA10E449C, 0xB1114D05, 0xC1A8F303,
+ 0xD16CF073, 0xA20E449C, 0xB2114D05,
+ 0xC2A80303, 0xD26CF073, 0xA30E449C,
},
.gray8_result = {
.dst_pitch = 5,
.expected = {
- 0x3C, 0x33, 0x34, 0x00, 0x00,
- 0x6F, 0x3C, 0x33, 0x00, 0x00,
- 0x34, 0x6F, 0x3C, 0x00, 0x00,
+ 0x3C, 0x33, 0xC4, 0x00, 0x00,
+ 0xBB, 0x3C, 0x33, 0x00, 0x00,
+ 0x34, 0xBB, 0x3C, 0x00, 0x00,
},
},
.rgb332_result = {
.dst_pitch = 5,
.expected = {
- 0x0A, 0x08, 0xA0, 0x00, 0x00,
- 0x6D, 0x0A, 0x08, 0x00, 0x00,
- 0xA0, 0x6D, 0x0A, 0x00, 0x00,
+ 0x0A, 0x08, 0xBC, 0x00, 0x00,
+ 0x7D, 0x0A, 0x08, 0x00, 0x00,
+ 0xA0, 0x7D, 0x0A, 0x00, 0x00,
},
},
.rgb565_result = {
.dst_pitch = 10,
.expected = {
- 0x0A33, 0x1260, 0xA800, 0x0000, 0x0000,
- 0x6B8E, 0x0A33, 0x1260, 0x0000, 0x0000,
- 0xA800, 0x6B8E, 0x0A33, 0x0000, 0x0000,
+ 0x0A33, 0x1260, 0xAF80, 0x0000, 0x0000,
+ 0x6F8E, 0x0A33, 0x1260, 0x0000, 0x0000,
+ 0xA800, 0x6F8E, 0x0A33, 0x0000, 0x0000,
},
.expected_swab = {
- 0x330A, 0x6012, 0x00A8, 0x0000, 0x0000,
- 0x8E6B, 0x330A, 0x6012, 0x0000, 0x0000,
- 0x00A8, 0x8E6B, 0x330A, 0x0000, 0x0000,
+ 0x330A, 0x6012, 0x80AF, 0x0000, 0x0000,
+ 0x8E6F, 0x330A, 0x6012, 0x0000, 0x0000,
+ 0x00A8, 0x8E6F, 0x330A, 0x0000, 0x0000,
},
},
.xrgb1555_result = {
.dst_pitch = 10,
.expected = {
- 0x0513, 0x0920, 0x5400, 0x0000, 0x0000,
- 0x35CE, 0x0513, 0x0920, 0x0000, 0x0000,
- 0x5400, 0x35CE, 0x0513, 0x0000, 0x0000,
+ 0x0513, 0x0920, 0x57C0, 0x0000, 0x0000,
+ 0x37CE, 0x0513, 0x0920, 0x0000, 0x0000,
+ 0x5400, 0x37CE, 0x0513, 0x0000, 0x0000,
},
},
.argb1555_result = {
.dst_pitch = 10,
.expected = {
- 0x8513, 0x8920, 0xD400, 0x0000, 0x0000,
- 0xB5CE, 0x8513, 0x8920, 0x0000, 0x0000,
- 0xD400, 0xB5CE, 0x8513, 0x0000, 0x0000,
+ 0x8513, 0x8920, 0xD7C0, 0x0000, 0x0000,
+ 0xB7CE, 0x8513, 0x8920, 0x0000, 0x0000,
+ 0xD400, 0xB7CE, 0x8513, 0x0000, 0x0000,
},
},
.rgba5551_result = {
.dst_pitch = 10,
.expected = {
- 0x0A27, 0x1241, 0xA801, 0x0000, 0x0000,
- 0x6B9D, 0x0A27, 0x1241, 0x0000, 0x0000,
- 0xA801, 0x6B9D, 0x0A27, 0x0000, 0x0000,
+ 0x0A27, 0x1241, 0xAF81, 0x0000, 0x0000,
+ 0x6F9D, 0x0A27, 0x1241, 0x0000, 0x0000,
+ 0xA801, 0x6F9D, 0x0A27, 0x0000, 0x0000,
},
},
.rgb888_result = {
.dst_pitch = 15,
.expected = {
- 0x9C, 0x44, 0x0E, 0x05, 0x4D, 0x11, 0x03, 0x03, 0xA8,
+ 0x9C, 0x44, 0x0E, 0x05, 0x4D, 0x11, 0x03, 0xF3, 0xA8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x73, 0x70, 0x6C, 0x9C, 0x44, 0x0E, 0x05, 0x4D, 0x11,
+ 0x73, 0xF0, 0x6C, 0x9C, 0x44, 0x0E, 0x05, 0x4D, 0x11,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x03, 0xA8, 0x73, 0x70, 0x6C, 0x9C, 0x44, 0x0E,
+ 0x03, 0x03, 0xA8, 0x73, 0xF0, 0x6C, 0x9C, 0x44, 0x0E,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
},
.argb8888_result = {
.dst_pitch = 20,
.expected = {
- 0xFF0E449C, 0xFF114D05, 0xFFA80303, 0x00000000, 0x00000000,
- 0xFF6C7073, 0xFF0E449C, 0xFF114D05, 0x00000000, 0x00000000,
- 0xFFA80303, 0xFF6C7073, 0xFF0E449C, 0x00000000, 0x00000000,
+ 0xFF0E449C, 0xFF114D05, 0xFFA8F303, 0x00000000, 0x00000000,
+ 0xFF6CF073, 0xFF0E449C, 0xFF114D05, 0x00000000, 0x00000000,
+ 0xFFA80303, 0xFF6CF073, 0xFF0E449C, 0x00000000, 0x00000000,
},
},
.xrgb2101010_result = {
.dst_pitch = 20,
.expected = {
- 0x03844672, 0x0444D414, 0x2A20300C, 0x00000000, 0x00000000,
- 0x1B1705CD, 0x03844672, 0x0444D414, 0x00000000, 0x00000000,
- 0x2A20300C, 0x1B1705CD, 0x03844672, 0x00000000, 0x00000000,
+ 0x03844672, 0x0444D414, 0x2A2F3C0C, 0x00000000, 0x00000000,
+ 0x1B1F0DCD, 0x03844672, 0x0444D414, 0x00000000, 0x00000000,
+ 0x2A20300C, 0x1B1F0DCD, 0x03844672, 0x00000000, 0x00000000,
},
},
.argb2101010_result = {
.dst_pitch = 20,
.expected = {
- 0xC3844672, 0xC444D414, 0xEA20300C, 0x00000000, 0x00000000,
- 0xDB1705CD, 0xC3844672, 0xC444D414, 0x00000000, 0x00000000,
- 0xEA20300C, 0xDB1705CD, 0xC3844672, 0x00000000, 0x00000000,
+ 0xC3844672, 0xC444D414, 0xEA2F3C0C, 0x00000000, 0x00000000,
+ 0xDB1F0DCD, 0xC3844672, 0xC444D414, 0x00000000, 0x00000000,
+ 0xEA20300C, 0xDB1F0DCD, 0xC3844672, 0x00000000, 0x00000000,
},
},
.mono_result = {
.dst_pitch = 2,
.expected = {
- 0b000, 0b000,
- 0b000, 0b000,
- 0b000, 0b000,
+ 0b100, 0b000,
+ 0b001, 0b000,
+ 0b010, 0b000,
},
},
},
--
2.39.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono()
2023-03-11 12:51 ` [PATCH v3 1/2] " Arthur Grillo
@ 2023-03-14 19:08 ` Javier Martinez Canillas
2023-03-14 22:17 ` Arthur Grillo Queiroz Cabral
0 siblings, 1 reply; 7+ messages in thread
From: Javier Martinez Canillas @ 2023-03-14 19:08 UTC (permalink / raw)
To: Arthur Grillo, dri-devel
Cc: davidgow, tales.aparecida, mairacanal, tzimmermann,
jose.exposito89, andrealmeid, Arthur Grillo
Arthur Grillo <arthurgrillo@riseup.net> writes:
Hello Arthur,
> Extend the existing test cases to test the conversion from XRGB8888 to
> monochromatic.
>
> Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
> ---
Patch looks good to me:
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Please let me know if you need someone to push this to the drm-misc tree.
--
Best regards,
Javier Martinez Canillas
Core Platforms
Red Hat
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 2/2] drm/format-helper: Make "destination_pitch" test case usable for the monochrome case
2023-03-11 12:51 ` [PATCH v3 2/2] drm/format-helper: Make "destination_pitch" test case usable for the monochrome case Arthur Grillo
@ 2023-03-14 19:11 ` Javier Martinez Canillas
0 siblings, 0 replies; 7+ messages in thread
From: Javier Martinez Canillas @ 2023-03-14 19:11 UTC (permalink / raw)
To: Arthur Grillo, dri-devel
Cc: davidgow, tales.aparecida, mairacanal, tzimmermann,
jose.exposito89, andrealmeid, Arthur Grillo
Arthur Grillo <arthurgrillo@riseup.net> writes:
> This test case uses an arbitrary pitch size, different of the default
> one, to test if the conversions methods obey.
>
> Change the "destination_pitch" colors to change the monochrome expected
> result from being just zeros, as this makes the arbitrary pitch use
> unusable.
>
> Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
> ---
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
--
Best regards,
Javier Martinez Canillas
Core Platforms
Red Hat
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono()
2023-03-14 19:08 ` Javier Martinez Canillas
@ 2023-03-14 22:17 ` Arthur Grillo Queiroz Cabral
2023-03-16 20:04 ` Javier Martinez Canillas
0 siblings, 1 reply; 7+ messages in thread
From: Arthur Grillo Queiroz Cabral @ 2023-03-14 22:17 UTC (permalink / raw)
To: Javier Martinez Canillas, dri-devel
Cc: davidgow, tales.aparecida, mairacanal, tzimmermann,
jose.exposito89, andrealmeid
Hello Javier,
On 14/03/23 16:08, Javier Martinez Canillas wrote:
> Arthur Grillo <arthurgrillo@riseup.net> writes:
>
> Hello Arthur,
>
>> Extend the existing test cases to test the conversion from XRGB8888 to
>> monochromatic.
>>
>> Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
>> ---
>
> Patch looks good to me:
>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>
> Please let me know if you need someone to push this to the drm-misc tree.
>
It would be nice if you did, as I don't have commit rights on this tree.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono()
2023-03-14 22:17 ` Arthur Grillo Queiroz Cabral
@ 2023-03-16 20:04 ` Javier Martinez Canillas
0 siblings, 0 replies; 7+ messages in thread
From: Javier Martinez Canillas @ 2023-03-16 20:04 UTC (permalink / raw)
To: Arthur Grillo Queiroz Cabral, dri-devel
Cc: davidgow, tales.aparecida, mairacanal, tzimmermann,
jose.exposito89, andrealmeid
Arthur Grillo Queiroz Cabral <arthurgrillo@riseup.net> writes:
> Hello Javier,
>
> On 14/03/23 16:08, Javier Martinez Canillas wrote:
>> Arthur Grillo <arthurgrillo@riseup.net> writes:
>>
>> Hello Arthur,
>>
>>> Extend the existing test cases to test the conversion from XRGB8888 to
>>> monochromatic.
>>>
>>> Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
>>> ---
>>
>> Patch looks good to me:
>>
>> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>>
>> Please let me know if you need someone to push this to the drm-misc tree.
>>
>
> It would be nice if you did, as I don't have commit rights on this tree.
>
Sure, pushed patch #1 and #2 to drm-misc (drm-misc-next). Thanks!
--
Best regards,
Javier Martinez Canillas
Core Platforms
Red Hat
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-03-16 20:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-11 12:51 [PATCH v3 0/2] drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono() Arthur Grillo
2023-03-11 12:51 ` [PATCH v3 1/2] " Arthur Grillo
2023-03-14 19:08 ` Javier Martinez Canillas
2023-03-14 22:17 ` Arthur Grillo Queiroz Cabral
2023-03-16 20:04 ` Javier Martinez Canillas
2023-03-11 12:51 ` [PATCH v3 2/2] drm/format-helper: Make "destination_pitch" test case usable for the monochrome case Arthur Grillo
2023-03-14 19:11 ` Javier Martinez Canillas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.