* [PATCH v2 0/2] Add KUnit tests for drm_fb_blit()
@ 2023-09-05 21:27 Arthur Grillo
2023-09-05 21:27 ` [PATCH v2 1/2] drm/tests: Add calls to drm_fb_blit() on supported format conversion tests Arthur Grillo
2023-09-05 21:27 ` [PATCH v2 2/2] drm/tests: Add new format conversion tests to better cover drm_fb_blit() Arthur Grillo
0 siblings, 2 replies; 5+ messages in thread
From: Arthur Grillo @ 2023-09-05 21:27 UTC (permalink / raw)
To: dri-devel, linux-kernel
Cc: tales.aparecida, andrealmeid, mairacanal, David Airlie,
Daniel Vetter, José Expósito, Javier Martinez Canillas,
Thomas Zimmermann, Arthur Grillo
This patchset tests the drm_fb_blit() function.
As this function can be used with already tested formats, the first
patch adds calls to drm_fb_blit() on the tests of supported formats.
Some supported formats were not yet covered by the existing tests
because they are only supported by drm_fb_blit(). The second patch
adds those format conversion tests.
Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
---
Changes in v2:
- Split the patch into two (Maíra Canal)
- Link to v1: https://lore.kernel.org/r/20230901-final-gsoc-v1-1-e310c7685982@riseup.net
---
Arthur Grillo (2):
drm/tests: Add calls to drm_fb_blit() on supported format conversion tests
drm/tests: Add new format conversion tests to better cover drm_fb_blit()
drivers/gpu/drm/tests/drm_format_helper_test.c | 284 +++++++++++++++++++++++++
1 file changed, 284 insertions(+)
---
base-commit: f45acf7acf75921c0409d452f0165f51a19a74fd
change-id: 20230901-final-gsoc-395a84443c8f
Best regards,
--
Arthur Grillo <arthurgrillo@riseup.net>
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 1/2] drm/tests: Add calls to drm_fb_blit() on supported format conversion tests 2023-09-05 21:27 [PATCH v2 0/2] Add KUnit tests for drm_fb_blit() Arthur Grillo @ 2023-09-05 21:27 ` Arthur Grillo 2023-09-08 20:51 ` Maira Canal 2023-09-05 21:27 ` [PATCH v2 2/2] drm/tests: Add new format conversion tests to better cover drm_fb_blit() Arthur Grillo 1 sibling, 1 reply; 5+ messages in thread From: Arthur Grillo @ 2023-09-05 21:27 UTC (permalink / raw) To: dri-devel, linux-kernel Cc: tales.aparecida, andrealmeid, mairacanal, David Airlie, Daniel Vetter, José Expósito, Javier Martinez Canillas, Thomas Zimmermann, Arthur Grillo Add a call to drm_fb_blit() on existing format conversion tests that has support. Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net> --- drivers/gpu/drm/tests/drm_format_helper_test.c | 142 +++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 79bc9d4bbd71..b888f7334510 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -643,6 +643,18 @@ static void drm_test_fb_xrgb8888_to_rgb565(struct kunit *test) drm_fb_xrgb8888_to_rgb565(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip, true); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); KUNIT_EXPECT_MEMEQ(test, buf, result->expected_swab, dst_size); + + buf = dst.vaddr; + memset(buf, 0, TEST_BUF_SIZE); + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_RGB565, &src, &fb, ¶ms->clip); + + buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test) @@ -677,6 +689,18 @@ static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test) drm_fb_xrgb8888_to_xrgb1555(&dst, dst_pitch, &src, &fb, ¶ms->clip); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; /* restore original value of buf */ + memset(buf, 0, TEST_BUF_SIZE); + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB1555, &src, &fb, ¶ms->clip); + + buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) @@ -711,6 +735,18 @@ static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) drm_fb_xrgb8888_to_argb1555(&dst, dst_pitch, &src, &fb, ¶ms->clip); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; /* restore original value of buf */ + memset(buf, 0, TEST_BUF_SIZE); + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ARGB1555, &src, &fb, ¶ms->clip); + + buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) @@ -745,6 +781,18 @@ static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) drm_fb_xrgb8888_to_rgba5551(&dst, dst_pitch, &src, &fb, ¶ms->clip); buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; /* restore original value of buf */ + memset(buf, 0, TEST_BUF_SIZE); + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_RGBA5551, &src, &fb, ¶ms->clip); + + buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) @@ -782,6 +830,16 @@ static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) drm_fb_xrgb8888_to_rgb888(&dst, dst_pitch, &src, &fb, ¶ms->clip); KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; /* restore original value of buf */ + memset(buf, 0, TEST_BUF_SIZE); + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_RGB888, &src, &fb, ¶ms->clip); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) @@ -816,6 +874,18 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) drm_fb_xrgb8888_to_argb8888(&dst, dst_pitch, &src, &fb, ¶ms->clip); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; /* restore original value of buf */ + memset(buf, 0, TEST_BUF_SIZE); + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ARGB8888, &src, &fb, ¶ms->clip); + + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) @@ -850,6 +920,17 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, ¶ms->clip); buf = le32buf_to_cpu(test, buf, dst_size / sizeof(u32)); KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; /* restore original value of buf */ + memset(buf, 0, TEST_BUF_SIZE); + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB2101010, &src, &fb, + ¶ms->clip); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) @@ -884,6 +965,19 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) drm_fb_xrgb8888_to_argb2101010(&dst, dst_pitch, &src, &fb, ¶ms->clip); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; /* restore original value of buf */ + memset(buf, 0, TEST_BUF_SIZE); + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ARGB2101010, &src, &fb, + ¶ms->clip); + + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } static void drm_test_fb_xrgb8888_to_mono(struct kunit *test) @@ -951,6 +1045,41 @@ static void drm_test_fb_swab(struct kunit *test) drm_fb_swab(&dst, dst_pitch, &src, &fb, ¶ms->clip, false); buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; /* restore original value of buf */ + memset(buf, 0, TEST_BUF_SIZE); + + int blit_result; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB8888 | DRM_FORMAT_BIG_ENDIAN, + &src, &fb, ¶ms->clip); + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; + memset(buf, 0, TEST_BUF_SIZE); + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_BGRX8888, &src, &fb, ¶ms->clip); + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); + + buf = dst.vaddr; + memset(buf, 0, TEST_BUF_SIZE); + + struct drm_format_info mock_format = *fb.format; + + mock_format.format |= DRM_FORMAT_BIG_ENDIAN; + fb.format = &mock_format; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB8888, &src, &fb, ¶ms->clip); + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } struct clip_offset_case { @@ -1543,6 +1672,19 @@ static void drm_test_fb_memcpy(struct kunit *test) KUNIT_EXPECT_MEMEQ_MSG(test, buf[i], expected[i], dst_size[i], "Failed expectation on plane %zu", i); } + + memset(*buf, 0, TEST_BUF_SIZE * DRM_FORMAT_MAX_PLANES); + + int blit_result; + + blit_result = drm_fb_blit(dst, dst_pitches, params->format, src, &fb, ¶ms->clip); + + KUNIT_EXPECT_FALSE(test, blit_result); + for (size_t i = 0; i < fb.format->num_planes; i++) { + expected[i] = cpubuf_to_le32(test, params->expected[i], TEST_BUF_SIZE); + KUNIT_EXPECT_MEMEQ_MSG(test, buf[i], expected[i], dst_size[i], + "Failed expectation on plane %zu", i); + } } static struct kunit_case drm_format_helper_test_cases[] = { -- 2.41.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] drm/tests: Add calls to drm_fb_blit() on supported format conversion tests 2023-09-05 21:27 ` [PATCH v2 1/2] drm/tests: Add calls to drm_fb_blit() on supported format conversion tests Arthur Grillo @ 2023-09-08 20:51 ` Maira Canal 0 siblings, 0 replies; 5+ messages in thread From: Maira Canal @ 2023-09-08 20:51 UTC (permalink / raw) To: Arthur Grillo, dri-devel, linux-kernel Cc: tales.aparecida, andrealmeid, David Airlie, Daniel Vetter, José Expósito, Javier Martinez Canillas, Thomas Zimmermann Hi Arthur, On 9/5/23 18:27, Arthur Grillo wrote: > Add a call to drm_fb_blit() on existing format conversion tests that > has support. > > Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net> Reviewed-by: Maíra Canal <mairacanal@riseup.net> Best Regards, - Maíra > --- > drivers/gpu/drm/tests/drm_format_helper_test.c | 142 +++++++++++++++++++++++++ > 1 file changed, 142 insertions(+) > > diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c > index 79bc9d4bbd71..b888f7334510 100644 > --- a/drivers/gpu/drm/tests/drm_format_helper_test.c > +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c > @@ -643,6 +643,18 @@ static void drm_test_fb_xrgb8888_to_rgb565(struct kunit *test) > drm_fb_xrgb8888_to_rgb565(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip, true); > buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > KUNIT_EXPECT_MEMEQ(test, buf, result->expected_swab, dst_size); > + > + buf = dst.vaddr; > + memset(buf, 0, TEST_BUF_SIZE); > + > + int blit_result = 0; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_RGB565, &src, &fb, ¶ms->clip); > + > + buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test) > @@ -677,6 +689,18 @@ static void drm_test_fb_xrgb8888_to_xrgb1555(struct kunit *test) > drm_fb_xrgb8888_to_xrgb1555(&dst, dst_pitch, &src, &fb, ¶ms->clip); > buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > + > + buf = dst.vaddr; /* restore original value of buf */ > + memset(buf, 0, TEST_BUF_SIZE); > + > + int blit_result = 0; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB1555, &src, &fb, ¶ms->clip); > + > + buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) > @@ -711,6 +735,18 @@ static void drm_test_fb_xrgb8888_to_argb1555(struct kunit *test) > drm_fb_xrgb8888_to_argb1555(&dst, dst_pitch, &src, &fb, ¶ms->clip); > buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > + > + buf = dst.vaddr; /* restore original value of buf */ > + memset(buf, 0, TEST_BUF_SIZE); > + > + int blit_result = 0; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ARGB1555, &src, &fb, ¶ms->clip); > + > + buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) > @@ -745,6 +781,18 @@ static void drm_test_fb_xrgb8888_to_rgba5551(struct kunit *test) > drm_fb_xrgb8888_to_rgba5551(&dst, dst_pitch, &src, &fb, ¶ms->clip); > buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > + > + buf = dst.vaddr; /* restore original value of buf */ > + memset(buf, 0, TEST_BUF_SIZE); > + > + int blit_result = 0; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_RGBA5551, &src, &fb, ¶ms->clip); > + > + buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) > @@ -782,6 +830,16 @@ static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test) > > drm_fb_xrgb8888_to_rgb888(&dst, dst_pitch, &src, &fb, ¶ms->clip); > KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > + > + buf = dst.vaddr; /* restore original value of buf */ > + memset(buf, 0, TEST_BUF_SIZE); > + > + int blit_result = 0; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_RGB888, &src, &fb, ¶ms->clip); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) > @@ -816,6 +874,18 @@ static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test) > drm_fb_xrgb8888_to_argb8888(&dst, dst_pitch, &src, &fb, ¶ms->clip); > buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > + > + buf = dst.vaddr; /* restore original value of buf */ > + memset(buf, 0, TEST_BUF_SIZE); > + > + int blit_result = 0; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ARGB8888, &src, &fb, ¶ms->clip); > + > + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) > @@ -850,6 +920,17 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) > drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, ¶ms->clip); > buf = le32buf_to_cpu(test, buf, dst_size / sizeof(u32)); > KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > + > + buf = dst.vaddr; /* restore original value of buf */ > + memset(buf, 0, TEST_BUF_SIZE); > + > + int blit_result = 0; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB2101010, &src, &fb, > + ¶ms->clip); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) > @@ -884,6 +965,19 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) > drm_fb_xrgb8888_to_argb2101010(&dst, dst_pitch, &src, &fb, ¶ms->clip); > buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > + > + buf = dst.vaddr; /* restore original value of buf */ > + memset(buf, 0, TEST_BUF_SIZE); > + > + int blit_result = 0; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ARGB2101010, &src, &fb, > + ¶ms->clip); > + > + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > static void drm_test_fb_xrgb8888_to_mono(struct kunit *test) > @@ -951,6 +1045,41 @@ static void drm_test_fb_swab(struct kunit *test) > drm_fb_swab(&dst, dst_pitch, &src, &fb, ¶ms->clip, false); > buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > + > + buf = dst.vaddr; /* restore original value of buf */ > + memset(buf, 0, TEST_BUF_SIZE); > + > + int blit_result; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB8888 | DRM_FORMAT_BIG_ENDIAN, > + &src, &fb, ¶ms->clip); > + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > + > + buf = dst.vaddr; > + memset(buf, 0, TEST_BUF_SIZE); > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_BGRX8888, &src, &fb, ¶ms->clip); > + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > + > + buf = dst.vaddr; > + memset(buf, 0, TEST_BUF_SIZE); > + > + struct drm_format_info mock_format = *fb.format; > + > + mock_format.format |= DRM_FORMAT_BIG_ENDIAN; > + fb.format = &mock_format; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XRGB8888, &src, &fb, ¶ms->clip); > + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > struct clip_offset_case { > @@ -1543,6 +1672,19 @@ static void drm_test_fb_memcpy(struct kunit *test) > KUNIT_EXPECT_MEMEQ_MSG(test, buf[i], expected[i], dst_size[i], > "Failed expectation on plane %zu", i); > } > + > + memset(*buf, 0, TEST_BUF_SIZE * DRM_FORMAT_MAX_PLANES); > + > + int blit_result; > + > + blit_result = drm_fb_blit(dst, dst_pitches, params->format, src, &fb, ¶ms->clip); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + for (size_t i = 0; i < fb.format->num_planes; i++) { > + expected[i] = cpubuf_to_le32(test, params->expected[i], TEST_BUF_SIZE); > + KUNIT_EXPECT_MEMEQ_MSG(test, buf[i], expected[i], dst_size[i], > + "Failed expectation on plane %zu", i); > + } > } > > static struct kunit_case drm_format_helper_test_cases[] = { > ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] drm/tests: Add new format conversion tests to better cover drm_fb_blit() 2023-09-05 21:27 [PATCH v2 0/2] Add KUnit tests for drm_fb_blit() Arthur Grillo 2023-09-05 21:27 ` [PATCH v2 1/2] drm/tests: Add calls to drm_fb_blit() on supported format conversion tests Arthur Grillo @ 2023-09-05 21:27 ` Arthur Grillo 2023-09-08 20:52 ` Maira Canal 1 sibling, 1 reply; 5+ messages in thread From: Arthur Grillo @ 2023-09-05 21:27 UTC (permalink / raw) To: dri-devel, linux-kernel Cc: tales.aparecida, andrealmeid, mairacanal, David Airlie, Daniel Vetter, José Expósito, Javier Martinez Canillas, Thomas Zimmermann, Arthur Grillo To fully cover drm_fb_blit(), add format conversion tests that are only supported through drm_fb_blit(). Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net> --- drivers/gpu/drm/tests/drm_format_helper_test.c | 142 +++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index b888f7334510..889287245b1e 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -81,6 +81,16 @@ struct fb_swab_result { const u32 expected[TEST_BUF_SIZE]; }; +struct convert_to_xbgr8888_result { + unsigned int dst_pitch; + const u32 expected[TEST_BUF_SIZE]; +}; + +struct convert_to_abgr8888_result { + unsigned int dst_pitch; + const u32 expected[TEST_BUF_SIZE]; +}; + struct convert_xrgb8888_case { const char *name; unsigned int pitch; @@ -98,6 +108,8 @@ struct convert_xrgb8888_case { struct convert_to_argb2101010_result argb2101010_result; struct convert_to_mono_result mono_result; struct fb_swab_result swab_result; + struct convert_to_xbgr8888_result xbgr8888_result; + struct convert_to_abgr8888_result abgr8888_result; }; static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { @@ -155,6 +167,14 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = TEST_USE_DEFAULT_PITCH, .expected = { 0x0000FF01 }, }, + .xbgr8888_result = { + .dst_pitch = TEST_USE_DEFAULT_PITCH, + .expected = { 0x010000FF }, + }, + .abgr8888_result = { + .dst_pitch = TEST_USE_DEFAULT_PITCH, + .expected = { 0xFF0000FF }, + }, }, { .name = "single_pixel_clip_rectangle", @@ -213,6 +233,14 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = TEST_USE_DEFAULT_PITCH, .expected = { 0x0000FF10 }, }, + .xbgr8888_result = { + .dst_pitch = TEST_USE_DEFAULT_PITCH, + .expected = { 0x100000FF }, + }, + .abgr8888_result = { + .dst_pitch = TEST_USE_DEFAULT_PITCH, + .expected = { 0xFF0000FF }, + }, }, { /* Well known colors: White, black, red, green, blue, magenta, @@ -343,6 +371,24 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0x00FFFF77, 0xFFFF0088, }, }, + .xbgr8888_result = { + .dst_pitch = TEST_USE_DEFAULT_PITCH, + .expected = { + 0x11FFFFFF, 0x22000000, + 0x330000FF, 0x4400FF00, + 0x55FF0000, 0x66FF00FF, + 0x7700FFFF, 0x88FFFF00, + }, + }, + .abgr8888_result = { + .dst_pitch = TEST_USE_DEFAULT_PITCH, + .expected = { + 0xFFFFFFFF, 0xFF000000, + 0xFF0000FF, 0xFF00FF00, + 0xFFFF0000, 0xFFFF00FF, + 0xFF00FFFF, 0xFFFFFF00, + }, + }, }, { /* Randomly picked colors. Full buffer within the clip area. */ @@ -458,6 +504,22 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0x0303A8C2, 0x73F06CD2, 0x9C440EA3, 0x00000000, 0x00000000, }, }, + .xbgr8888_result = { + .dst_pitch = 20, + .expected = { + 0xA19C440E, 0xB1054D11, 0xC103F3A8, 0x00000000, 0x00000000, + 0xD173F06C, 0xA29C440E, 0xB2054D11, 0x00000000, 0x00000000, + 0xC20303A8, 0xD273F06C, 0xA39C440E, 0x00000000, 0x00000000, + }, + }, + .abgr8888_result = { + .dst_pitch = 20, + .expected = { + 0xFF9C440E, 0xFF054D11, 0xFF03F3A8, 0x00000000, 0x00000000, + 0xFF73F06C, 0xFF9C440E, 0xFF054D11, 0x00000000, 0x00000000, + 0xFF0303A8, 0xFF73F06C, 0xFF9C440E, 0x00000000, 0x00000000, + }, + }, }, }; @@ -1082,6 +1144,84 @@ static void drm_test_fb_swab(struct kunit *test) KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } +static void drm_test_fb_xrgb8888_to_abgr8888(struct kunit *test) +{ + const struct convert_xrgb8888_case *params = test->param_value; + const struct convert_to_abgr8888_result *result = ¶ms->abgr8888_result; + size_t dst_size; + u32 *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_XBGR8888, result->dst_pitch, ¶ms->clip, 0); + + 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); + + const unsigned int *dst_pitch = (result->dst_pitch == TEST_USE_DEFAULT_PITCH) ? + NULL : &result->dst_pitch; + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ABGR8888, &src, &fb, ¶ms->clip); + + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); +} + +static void drm_test_fb_xrgb8888_to_xbgr8888(struct kunit *test) +{ + const struct convert_xrgb8888_case *params = test->param_value; + const struct convert_to_xbgr8888_result *result = ¶ms->xbgr8888_result; + size_t dst_size; + u32 *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_XBGR8888, result->dst_pitch, ¶ms->clip, 0); + + 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); + + const unsigned int *dst_pitch = (result->dst_pitch == TEST_USE_DEFAULT_PITCH) ? + NULL : &result->dst_pitch; + + int blit_result = 0; + + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XBGR8888, &src, &fb, ¶ms->clip); + + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); + + KUNIT_EXPECT_FALSE(test, blit_result); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); +} + struct clip_offset_case { const char *name; unsigned int pitch; @@ -1700,6 +1840,8 @@ static struct kunit_case drm_format_helper_test_cases[] = { 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), KUNIT_CASE_PARAM(drm_test_fb_swab, convert_xrgb8888_gen_params), + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xbgr8888, convert_xrgb8888_gen_params), + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_abgr8888, convert_xrgb8888_gen_params), KUNIT_CASE_PARAM(drm_test_fb_clip_offset, clip_offset_gen_params), KUNIT_CASE_PARAM(drm_test_fb_build_fourcc_list, fb_build_fourcc_list_gen_params), KUNIT_CASE_PARAM(drm_test_fb_memcpy, fb_memcpy_gen_params), -- 2.41.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] drm/tests: Add new format conversion tests to better cover drm_fb_blit() 2023-09-05 21:27 ` [PATCH v2 2/2] drm/tests: Add new format conversion tests to better cover drm_fb_blit() Arthur Grillo @ 2023-09-08 20:52 ` Maira Canal 0 siblings, 0 replies; 5+ messages in thread From: Maira Canal @ 2023-09-08 20:52 UTC (permalink / raw) To: Arthur Grillo, dri-devel, linux-kernel Cc: tales.aparecida, andrealmeid, David Airlie, Daniel Vetter, José Expósito, Javier Martinez Canillas, Thomas Zimmermann Hi Arthur, On 9/5/23 18:27, Arthur Grillo wrote: > To fully cover drm_fb_blit(), add format conversion tests that are only > supported through drm_fb_blit(). > > Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net> Reviewed-by: Maíra Canal <mairacanal@riseup.net> Best Regards, - Maíra > --- > drivers/gpu/drm/tests/drm_format_helper_test.c | 142 +++++++++++++++++++++++++ > 1 file changed, 142 insertions(+) > > diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c > index b888f7334510..889287245b1e 100644 > --- a/drivers/gpu/drm/tests/drm_format_helper_test.c > +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c > @@ -81,6 +81,16 @@ struct fb_swab_result { > const u32 expected[TEST_BUF_SIZE]; > }; > > +struct convert_to_xbgr8888_result { > + unsigned int dst_pitch; > + const u32 expected[TEST_BUF_SIZE]; > +}; > + > +struct convert_to_abgr8888_result { > + unsigned int dst_pitch; > + const u32 expected[TEST_BUF_SIZE]; > +}; > + > struct convert_xrgb8888_case { > const char *name; > unsigned int pitch; > @@ -98,6 +108,8 @@ struct convert_xrgb8888_case { > struct convert_to_argb2101010_result argb2101010_result; > struct convert_to_mono_result mono_result; > struct fb_swab_result swab_result; > + struct convert_to_xbgr8888_result xbgr8888_result; > + struct convert_to_abgr8888_result abgr8888_result; > }; > > static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { > @@ -155,6 +167,14 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { > .dst_pitch = TEST_USE_DEFAULT_PITCH, > .expected = { 0x0000FF01 }, > }, > + .xbgr8888_result = { > + .dst_pitch = TEST_USE_DEFAULT_PITCH, > + .expected = { 0x010000FF }, > + }, > + .abgr8888_result = { > + .dst_pitch = TEST_USE_DEFAULT_PITCH, > + .expected = { 0xFF0000FF }, > + }, > }, > { > .name = "single_pixel_clip_rectangle", > @@ -213,6 +233,14 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { > .dst_pitch = TEST_USE_DEFAULT_PITCH, > .expected = { 0x0000FF10 }, > }, > + .xbgr8888_result = { > + .dst_pitch = TEST_USE_DEFAULT_PITCH, > + .expected = { 0x100000FF }, > + }, > + .abgr8888_result = { > + .dst_pitch = TEST_USE_DEFAULT_PITCH, > + .expected = { 0xFF0000FF }, > + }, > }, > { > /* Well known colors: White, black, red, green, blue, magenta, > @@ -343,6 +371,24 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { > 0x00FFFF77, 0xFFFF0088, > }, > }, > + .xbgr8888_result = { > + .dst_pitch = TEST_USE_DEFAULT_PITCH, > + .expected = { > + 0x11FFFFFF, 0x22000000, > + 0x330000FF, 0x4400FF00, > + 0x55FF0000, 0x66FF00FF, > + 0x7700FFFF, 0x88FFFF00, > + }, > + }, > + .abgr8888_result = { > + .dst_pitch = TEST_USE_DEFAULT_PITCH, > + .expected = { > + 0xFFFFFFFF, 0xFF000000, > + 0xFF0000FF, 0xFF00FF00, > + 0xFFFF0000, 0xFFFF00FF, > + 0xFF00FFFF, 0xFFFFFF00, > + }, > + }, > }, > { > /* Randomly picked colors. Full buffer within the clip area. */ > @@ -458,6 +504,22 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { > 0x0303A8C2, 0x73F06CD2, 0x9C440EA3, 0x00000000, 0x00000000, > }, > }, > + .xbgr8888_result = { > + .dst_pitch = 20, > + .expected = { > + 0xA19C440E, 0xB1054D11, 0xC103F3A8, 0x00000000, 0x00000000, > + 0xD173F06C, 0xA29C440E, 0xB2054D11, 0x00000000, 0x00000000, > + 0xC20303A8, 0xD273F06C, 0xA39C440E, 0x00000000, 0x00000000, > + }, > + }, > + .abgr8888_result = { > + .dst_pitch = 20, > + .expected = { > + 0xFF9C440E, 0xFF054D11, 0xFF03F3A8, 0x00000000, 0x00000000, > + 0xFF73F06C, 0xFF9C440E, 0xFF054D11, 0x00000000, 0x00000000, > + 0xFF0303A8, 0xFF73F06C, 0xFF9C440E, 0x00000000, 0x00000000, > + }, > + }, > }, > }; > > @@ -1082,6 +1144,84 @@ static void drm_test_fb_swab(struct kunit *test) > KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > } > > +static void drm_test_fb_xrgb8888_to_abgr8888(struct kunit *test) > +{ > + const struct convert_xrgb8888_case *params = test->param_value; > + const struct convert_to_abgr8888_result *result = ¶ms->abgr8888_result; > + size_t dst_size; > + u32 *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_XBGR8888, result->dst_pitch, ¶ms->clip, 0); > + > + 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); > + > + const unsigned int *dst_pitch = (result->dst_pitch == TEST_USE_DEFAULT_PITCH) ? > + NULL : &result->dst_pitch; > + > + int blit_result = 0; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ABGR8888, &src, &fb, ¶ms->clip); > + > + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > +} > + > +static void drm_test_fb_xrgb8888_to_xbgr8888(struct kunit *test) > +{ > + const struct convert_xrgb8888_case *params = test->param_value; > + const struct convert_to_xbgr8888_result *result = ¶ms->xbgr8888_result; > + size_t dst_size; > + u32 *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_XBGR8888, result->dst_pitch, ¶ms->clip, 0); > + > + 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); > + > + const unsigned int *dst_pitch = (result->dst_pitch == TEST_USE_DEFAULT_PITCH) ? > + NULL : &result->dst_pitch; > + > + int blit_result = 0; > + > + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XBGR8888, &src, &fb, ¶ms->clip); > + > + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); > + > + KUNIT_EXPECT_FALSE(test, blit_result); > + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); > +} > + > struct clip_offset_case { > const char *name; > unsigned int pitch; > @@ -1700,6 +1840,8 @@ static struct kunit_case drm_format_helper_test_cases[] = { > 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), > KUNIT_CASE_PARAM(drm_test_fb_swab, convert_xrgb8888_gen_params), > + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xbgr8888, convert_xrgb8888_gen_params), > + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_abgr8888, convert_xrgb8888_gen_params), > KUNIT_CASE_PARAM(drm_test_fb_clip_offset, clip_offset_gen_params), > KUNIT_CASE_PARAM(drm_test_fb_build_fourcc_list, fb_build_fourcc_list_gen_params), > KUNIT_CASE_PARAM(drm_test_fb_memcpy, fb_memcpy_gen_params), > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-09-08 20:52 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-09-05 21:27 [PATCH v2 0/2] Add KUnit tests for drm_fb_blit() Arthur Grillo 2023-09-05 21:27 ` [PATCH v2 1/2] drm/tests: Add calls to drm_fb_blit() on supported format conversion tests Arthur Grillo 2023-09-08 20:51 ` Maira Canal 2023-09-05 21:27 ` [PATCH v2 2/2] drm/tests: Add new format conversion tests to better cover drm_fb_blit() Arthur Grillo 2023-09-08 20:52 ` Maira Canal
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®