Message ID | 20220627161132.33256-5-jose.exposito89@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KUnit tests for RGB565 conversion | expand |
Hi Am 27.06.22 um 18:11 schrieb José Expósito: > Extend the existing test cases to test the conversion from XRGB8888 to > RGB565. > > The documentation and the color picker available on [1] are useful > resources to understand this patch and validate the values returned by > the conversion function. > > [1] http://www.barth-dev.de/online/rgb565-color-picker/ URLs in commit messages are usually given as Link tag like this: Link: http://www.barth-dev.de/online/rgb565-color-picker/ # [1] Put this somewhere below your signed-off-by tag. Best regards Thomas > > Signed-off-by: José Expósito <jose.exposito89@gmail.com> > --- > .../gpu/drm/tests/drm_format_helper_test.c | 100 +++++++++++++++++- > 1 file changed, 99 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c > index 52dc41cc7c60..3fbe8026bccc 100644 > --- a/drivers/gpu/drm/tests/drm_format_helper_test.c > +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c > @@ -48,7 +48,7 @@ struct convert_xrgb8888_case { > unsigned int pitch; > struct drm_rect clip; > const u32 xrgb8888[TEST_BUF_SIZE]; > - struct convert_xrgb8888_result results[1]; > + struct convert_xrgb8888_result results[3]; > }; > > static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { > @@ -64,6 +64,26 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { > .dst_pitch = 0, > .expected = { 0xE0 }, > }, > + { > + .dst_format = DRM_FORMAT_RGB565, > + .has_swab = true, > + .conv_swab = { > + .func = drm_fb_xrgb8888_to_rgb565, > + .swab = false, > + }, > + .dst_pitch = 0, > + .expected = { 0x00, 0xF8 }, > + }, > + { > + .dst_format = DRM_FORMAT_RGB565, > + .has_swab = true, > + .conv_swab = { > + .func = drm_fb_xrgb8888_to_rgb565, > + .swab = true, > + }, > + .dst_pitch = 0, > + .expected = { 0xF8, 0x00 }, > + }, > }, > }, > { > @@ -81,6 +101,26 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { > .dst_pitch = 0, > .expected = { 0xE0 }, > }, > + { > + .dst_format = DRM_FORMAT_RGB565, > + .has_swab = true, > + .conv_swab = { > + .func = drm_fb_xrgb8888_to_rgb565, > + .swab = false, > + }, > + .dst_pitch = 0, > + .expected = { 0x00, 0xF8 }, > + }, > + { > + .dst_format = DRM_FORMAT_RGB565, > + .has_swab = true, > + .conv_swab = { > + .func = drm_fb_xrgb8888_to_rgb565, > + .swab = true, > + }, > + .dst_pitch = 0, > + .expected = { 0xF8, 0x00 }, > + }, > }, > }, > { > @@ -110,6 +150,36 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { > 0xFC, 0x1F, > }, > }, > + { > + .dst_format = DRM_FORMAT_RGB565, > + .has_swab = true, > + .conv_swab = { > + .func = drm_fb_xrgb8888_to_rgb565, > + .swab = false, > + }, > + .dst_pitch = 0, > + .expected = { > + 0xFF, 0xFF, 0x00, 0x00, > + 0x00, 0xF8, 0xE0, 0x07, > + 0x1F, 0x00, 0x1F, 0xF8, > + 0xE0, 0xFF, 0xFF, 0x07, > + }, > + }, > + { > + .dst_format = DRM_FORMAT_RGB565, > + .has_swab = true, > + .conv_swab = { > + .func = drm_fb_xrgb8888_to_rgb565, > + .swab = true, > + }, > + .dst_pitch = 0, > + .expected = { > + 0xFF, 0xFF, 0x00, 0x00, > + 0xF8, 0x00, 0x07, 0xE0, > + 0x00, 0x1F, 0xF8, 0x1F, > + 0xFF, 0xE0, 0x07, 0xFF, > + }, > + }, > }, > }, > { > @@ -133,6 +203,34 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { > 0xA0, 0x6D, 0x0A, 0x00, 0x00, > }, > }, > + { > + .dst_format = DRM_FORMAT_RGB565, > + .has_swab = true, > + .conv_swab = { > + .func = drm_fb_xrgb8888_to_rgb565, > + .swab = false, > + }, > + .dst_pitch = 10, > + .expected = { > + 0x33, 0x0A, 0x60, 0x12, 0x00, 0xA8, 0x00, 0x00, 0x00, 0x00, > + 0x8E, 0x6B, 0x33, 0x0A, 0x60, 0x12, 0x00, 0x00, 0x00, 0x00, > + 0x00, 0xA8, 0x8E, 0x6B, 0x33, 0x0A, 0x00, 0x00, 0x00, 0x00, > + }, > + }, > + { > + .dst_format = DRM_FORMAT_RGB565, > + .has_swab = true, > + .conv_swab = { > + .func = drm_fb_xrgb8888_to_rgb565, > + .swab = true, > + }, > + .dst_pitch = 10, > + .expected = { > + 0x0A, 0x33, 0x12, 0x60, 0xA8, 0x00, 0x00, 0x00, 0x00, 0x00, > + 0x6B, 0x8E, 0x0A, 0x33, 0x12, 0x60, 0x00, 0x00, 0x00, 0x00, > + 0xA8, 0x00, 0x6B, 0x8E, 0x0A, 0x33, 0x00, 0x00, 0x00, 0x00, > + }, > + }, > }, > }, > };
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 52dc41cc7c60..3fbe8026bccc 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -48,7 +48,7 @@ struct convert_xrgb8888_case { unsigned int pitch; struct drm_rect clip; const u32 xrgb8888[TEST_BUF_SIZE]; - struct convert_xrgb8888_result results[1]; + struct convert_xrgb8888_result results[3]; }; static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { @@ -64,6 +64,26 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = 0, .expected = { 0xE0 }, }, + { + .dst_format = DRM_FORMAT_RGB565, + .has_swab = true, + .conv_swab = { + .func = drm_fb_xrgb8888_to_rgb565, + .swab = false, + }, + .dst_pitch = 0, + .expected = { 0x00, 0xF8 }, + }, + { + .dst_format = DRM_FORMAT_RGB565, + .has_swab = true, + .conv_swab = { + .func = drm_fb_xrgb8888_to_rgb565, + .swab = true, + }, + .dst_pitch = 0, + .expected = { 0xF8, 0x00 }, + }, }, }, { @@ -81,6 +101,26 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = 0, .expected = { 0xE0 }, }, + { + .dst_format = DRM_FORMAT_RGB565, + .has_swab = true, + .conv_swab = { + .func = drm_fb_xrgb8888_to_rgb565, + .swab = false, + }, + .dst_pitch = 0, + .expected = { 0x00, 0xF8 }, + }, + { + .dst_format = DRM_FORMAT_RGB565, + .has_swab = true, + .conv_swab = { + .func = drm_fb_xrgb8888_to_rgb565, + .swab = true, + }, + .dst_pitch = 0, + .expected = { 0xF8, 0x00 }, + }, }, }, { @@ -110,6 +150,36 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0xFC, 0x1F, }, }, + { + .dst_format = DRM_FORMAT_RGB565, + .has_swab = true, + .conv_swab = { + .func = drm_fb_xrgb8888_to_rgb565, + .swab = false, + }, + .dst_pitch = 0, + .expected = { + 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0xF8, 0xE0, 0x07, + 0x1F, 0x00, 0x1F, 0xF8, + 0xE0, 0xFF, 0xFF, 0x07, + }, + }, + { + .dst_format = DRM_FORMAT_RGB565, + .has_swab = true, + .conv_swab = { + .func = drm_fb_xrgb8888_to_rgb565, + .swab = true, + }, + .dst_pitch = 0, + .expected = { + 0xFF, 0xFF, 0x00, 0x00, + 0xF8, 0x00, 0x07, 0xE0, + 0x00, 0x1F, 0xF8, 0x1F, + 0xFF, 0xE0, 0x07, 0xFF, + }, + }, }, }, { @@ -133,6 +203,34 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0xA0, 0x6D, 0x0A, 0x00, 0x00, }, }, + { + .dst_format = DRM_FORMAT_RGB565, + .has_swab = true, + .conv_swab = { + .func = drm_fb_xrgb8888_to_rgb565, + .swab = false, + }, + .dst_pitch = 10, + .expected = { + 0x33, 0x0A, 0x60, 0x12, 0x00, 0xA8, 0x00, 0x00, 0x00, 0x00, + 0x8E, 0x6B, 0x33, 0x0A, 0x60, 0x12, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xA8, 0x8E, 0x6B, 0x33, 0x0A, 0x00, 0x00, 0x00, 0x00, + }, + }, + { + .dst_format = DRM_FORMAT_RGB565, + .has_swab = true, + .conv_swab = { + .func = drm_fb_xrgb8888_to_rgb565, + .swab = true, + }, + .dst_pitch = 10, + .expected = { + 0x0A, 0x33, 0x12, 0x60, 0xA8, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6B, 0x8E, 0x0A, 0x33, 0x12, 0x60, 0x00, 0x00, 0x00, 0x00, + 0xA8, 0x00, 0x6B, 0x8E, 0x0A, 0x33, 0x00, 0x00, 0x00, 0x00, + }, + }, }, }, };
Extend the existing test cases to test the conversion from XRGB8888 to RGB565. The documentation and the color picker available on [1] are useful resources to understand this patch and validate the values returned by the conversion function. [1] http://www.barth-dev.de/online/rgb565-color-picker/ Signed-off-by: José Expósito <jose.exposito89@gmail.com> --- .../gpu/drm/tests/drm_format_helper_test.c | 100 +++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-)