diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2023-01-02 12:29:18 +0100 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2023-01-03 14:24:08 +0100 |
commit | f21d62c9ce3db2c74875a15bec6afbae93ee43cc (patch) | |
tree | 6fb97727b4005415b2c289b1e0081ec5da47b973 /drivers/gpu/drm/tests/drm_format_helper_test.c | |
parent | 58f5d9830da0d4f257cc39244ba982cf90e3199c (diff) | |
download | linux-stable-f21d62c9ce3db2c74875a15bec6afbae93ee43cc.tar.gz linux-stable-f21d62c9ce3db2c74875a15bec6afbae93ee43cc.tar.bz2 linux-stable-f21d62c9ce3db2c74875a15bec6afbae93ee43cc.zip |
drm/format-helper: Store RGB565 in little-endian order
Fix to-RGB565 conversion helpers to store the result in little-
endian byte order. Update test cases as well.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: José Expósito <jose.exposito89@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230102112927.26565-5-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/tests/drm_format_helper_test.c')
-rw-r--r-- | drivers/gpu/drm/tests/drm_format_helper_test.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index e7c49e6d3f6d..04fe373c9d97 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -264,6 +264,21 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch, return dst_pitch * drm_rect_height(clip); } +static u16 *le16buf_to_cpu(struct kunit *test, const __le16 *buf, size_t buf_size) +{ + u16 *dst = NULL; + int n; + + dst = kunit_kzalloc(test, sizeof(*dst) * buf_size, GFP_KERNEL); + if (!dst) + return NULL; + + for (n = 0; n < buf_size; n++) + dst[n] = le16_to_cpu(buf[n]); + + return dst; +} + static u32 *le32buf_to_cpu(struct kunit *test, const u32 *buf, size_t buf_size) { u32 *dst = NULL; @@ -368,7 +383,7 @@ static void drm_test_fb_xrgb8888_to_rgb565(struct kunit *test) const struct convert_xrgb8888_case *params = test->param_value; const struct convert_to_rgb565_result *result = ¶ms->rgb565_result; size_t dst_size; - __u16 *buf = NULL; + u16 *buf = NULL; __le32 *xrgb8888 = NULL; struct iosys_map dst, src; @@ -390,9 +405,12 @@ static void drm_test_fb_xrgb8888_to_rgb565(struct kunit *test) iosys_map_set_vaddr(&src, xrgb8888); drm_fb_xrgb8888_to_rgb565(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip, false); + buf = le16buf_to_cpu(test, (__force const __le16 *)buf, dst_size / sizeof(__le16)); KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); + buf = dst.vaddr; /* restore original value of buf */ 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_EQ(test, memcmp(buf, result->expected_swab, dst_size), 0); } |