mirror of
https://github.com/torvalds/linux.git
synced 2026-04-22 00:33:58 -04:00
drm/format-helper: Rework XRGB8888-to-RGBG565 conversion
Update XRGB8888-to-RGB565 conversion to support struct iosys_map and convert all users. Although these are single-plane color formats, the new interface supports multi-plane formats for consistency with drm_fb_blit(). v2: * update new Kunit tests * update documentation (Sam) * add TODO on vaddr location (Sam) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Tested-by: Noralf Trønnes <noralf@tronnes.org> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20220808125406.20752-7-tzimmermann@suse.de
This commit is contained in:
@@ -227,8 +227,9 @@ static void xrgb8888_to_rgb565_test(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 *dst = NULL;
|
||||
__u32 *src = NULL;
|
||||
__u16 *buf = NULL;
|
||||
__u32 *xrgb8888 = NULL;
|
||||
struct iosys_map dst, src;
|
||||
|
||||
struct drm_framebuffer fb = {
|
||||
.format = drm_format_info(DRM_FORMAT_XRGB8888),
|
||||
@@ -239,19 +240,19 @@ static void xrgb8888_to_rgb565_test(struct kunit *test)
|
||||
¶ms->clip);
|
||||
KUNIT_ASSERT_GT(test, dst_size, 0);
|
||||
|
||||
dst = kunit_kzalloc(test, dst_size, GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dst);
|
||||
buf = kunit_kzalloc(test, dst_size, GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
|
||||
iosys_map_set_vaddr(&dst, buf);
|
||||
|
||||
src = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, src);
|
||||
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_rgb565(dst, result->dst_pitch, src, &fb,
|
||||
¶ms->clip, false);
|
||||
KUNIT_EXPECT_EQ(test, memcmp(dst, result->expected, dst_size), 0);
|
||||
drm_fb_xrgb8888_to_rgb565(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip, false);
|
||||
KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0);
|
||||
|
||||
drm_fb_xrgb8888_to_rgb565(dst, result->dst_pitch, src, &fb,
|
||||
¶ms->clip, true);
|
||||
KUNIT_EXPECT_EQ(test, memcmp(dst, result->expected_swab, dst_size), 0);
|
||||
drm_fb_xrgb8888_to_rgb565(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip, true);
|
||||
KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected_swab, dst_size), 0);
|
||||
}
|
||||
|
||||
static struct kunit_case drm_format_helper_test_cases[] = {
|
||||
|
||||
Reference in New Issue
Block a user