mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 23:03:57 -04:00
drm/format-helper: Add conversion from XRGB8888 to BGR888
Add XRGB8888 emulation helper for devices that only support BGR888. Signed-off-by: Kerem Karabay <kekrby@gmail.com> Signed-off-by: Aditya Garg <gargaditya08@live.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patchwork.freedesktop.org/patch/msgid/9A67EA95-9BC7-4D56-8F87-05EAC1C166AD@live.com
This commit is contained in:
committed by
Thomas Zimmermann
parent
16e57a7278
commit
c9043706cb
@@ -60,6 +60,11 @@ struct convert_to_rgb888_result {
|
||||
const u8 expected[TEST_BUF_SIZE];
|
||||
};
|
||||
|
||||
struct convert_to_bgr888_result {
|
||||
unsigned int dst_pitch;
|
||||
const u8 expected[TEST_BUF_SIZE];
|
||||
};
|
||||
|
||||
struct convert_to_argb8888_result {
|
||||
unsigned int dst_pitch;
|
||||
const u32 expected[TEST_BUF_SIZE];
|
||||
@@ -107,6 +112,7 @@ struct convert_xrgb8888_case {
|
||||
struct convert_to_argb1555_result argb1555_result;
|
||||
struct convert_to_rgba5551_result rgba5551_result;
|
||||
struct convert_to_rgb888_result rgb888_result;
|
||||
struct convert_to_bgr888_result bgr888_result;
|
||||
struct convert_to_argb8888_result argb8888_result;
|
||||
struct convert_to_xrgb2101010_result xrgb2101010_result;
|
||||
struct convert_to_argb2101010_result argb2101010_result;
|
||||
@@ -151,6 +157,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
|
||||
.dst_pitch = TEST_USE_DEFAULT_PITCH,
|
||||
.expected = { 0x00, 0x00, 0xFF },
|
||||
},
|
||||
.bgr888_result = {
|
||||
.dst_pitch = TEST_USE_DEFAULT_PITCH,
|
||||
.expected = { 0xFF, 0x00, 0x00 },
|
||||
},
|
||||
.argb8888_result = {
|
||||
.dst_pitch = TEST_USE_DEFAULT_PITCH,
|
||||
.expected = { 0xFFFF0000 },
|
||||
@@ -217,6 +227,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
|
||||
.dst_pitch = TEST_USE_DEFAULT_PITCH,
|
||||
.expected = { 0x00, 0x00, 0xFF },
|
||||
},
|
||||
.bgr888_result = {
|
||||
.dst_pitch = TEST_USE_DEFAULT_PITCH,
|
||||
.expected = { 0xFF, 0x00, 0x00 },
|
||||
},
|
||||
.argb8888_result = {
|
||||
.dst_pitch = TEST_USE_DEFAULT_PITCH,
|
||||
.expected = { 0xFFFF0000 },
|
||||
@@ -330,6 +344,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
||||
},
|
||||
},
|
||||
.bgr888_result = {
|
||||
.dst_pitch = TEST_USE_DEFAULT_PITCH,
|
||||
.expected = {
|
||||
0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF,
|
||||
0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF,
|
||||
},
|
||||
},
|
||||
.argb8888_result = {
|
||||
.dst_pitch = TEST_USE_DEFAULT_PITCH,
|
||||
.expected = {
|
||||
@@ -468,6 +491,17 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
},
|
||||
},
|
||||
.bgr888_result = {
|
||||
.dst_pitch = 15,
|
||||
.expected = {
|
||||
0x0E, 0x44, 0x9C, 0x11, 0x4D, 0x05, 0xA8, 0xF3, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x6C, 0xF0, 0x73, 0x0E, 0x44, 0x9C, 0x11, 0x4D, 0x05,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xA8, 0x03, 0x03, 0x6C, 0xF0, 0x73, 0x0E, 0x44, 0x9C,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
},
|
||||
},
|
||||
.argb8888_result = {
|
||||
.dst_pitch = 20,
|
||||
.expected = {
|
||||
@@ -914,6 +948,52 @@ static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test)
|
||||
KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
|
||||
}
|
||||
|
||||
static void drm_test_fb_xrgb8888_to_bgr888(struct kunit *test)
|
||||
{
|
||||
const struct convert_xrgb8888_case *params = test->param_value;
|
||||
const struct convert_to_bgr888_result *result = ¶ms->bgr888_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_BGR888, 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);
|
||||
|
||||
/*
|
||||
* BGR888 expected results are already in little-endian
|
||||
* order, so there's no need to convert the test output.
|
||||
*/
|
||||
drm_fb_xrgb8888_to_bgr888(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip,
|
||||
&fmtcnv_state);
|
||||
KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
|
||||
|
||||
buf = dst.vaddr; /* restore original value of buf */
|
||||
memset(buf, 0, dst_size);
|
||||
|
||||
int blit_result = 0;
|
||||
|
||||
blit_result = drm_fb_blit(&dst, &result->dst_pitch, DRM_FORMAT_BGR888, &src, &fb, ¶ms->clip,
|
||||
&fmtcnv_state);
|
||||
|
||||
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)
|
||||
{
|
||||
const struct convert_xrgb8888_case *params = test->param_value;
|
||||
@@ -1851,6 +1931,7 @@ static struct kunit_case drm_format_helper_test_cases[] = {
|
||||
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_argb1555, convert_xrgb8888_gen_params),
|
||||
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgba5551, convert_xrgb8888_gen_params),
|
||||
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888, convert_xrgb8888_gen_params),
|
||||
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_bgr888, convert_xrgb8888_gen_params),
|
||||
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),
|
||||
|
||||
Reference in New Issue
Block a user