Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/tests: Add new format conversion tests to better cover drm_fb_blit()

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>
Signed-off-by: Maíra Canal <mairacanal@riseup.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20230918-final-gsoc-v3-2-b999c042a4cc@riseup.net

authored by

Arthur Grillo and committed by
Maíra Canal
91951d36 15bda1f8

+142
+142
drivers/gpu/drm/tests/drm_format_helper_test.c
··· 81 81 const u32 expected[TEST_BUF_SIZE]; 82 82 }; 83 83 84 + struct convert_to_xbgr8888_result { 85 + unsigned int dst_pitch; 86 + const u32 expected[TEST_BUF_SIZE]; 87 + }; 88 + 89 + struct convert_to_abgr8888_result { 90 + unsigned int dst_pitch; 91 + const u32 expected[TEST_BUF_SIZE]; 92 + }; 93 + 84 94 struct convert_xrgb8888_case { 85 95 const char *name; 86 96 unsigned int pitch; ··· 108 98 struct convert_to_argb2101010_result argb2101010_result; 109 99 struct convert_to_mono_result mono_result; 110 100 struct fb_swab_result swab_result; 101 + struct convert_to_xbgr8888_result xbgr8888_result; 102 + struct convert_to_abgr8888_result abgr8888_result; 111 103 }; 112 104 113 105 static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { ··· 166 154 .swab_result = { 167 155 .dst_pitch = TEST_USE_DEFAULT_PITCH, 168 156 .expected = { 0x0000FF01 }, 157 + }, 158 + .xbgr8888_result = { 159 + .dst_pitch = TEST_USE_DEFAULT_PITCH, 160 + .expected = { 0x010000FF }, 161 + }, 162 + .abgr8888_result = { 163 + .dst_pitch = TEST_USE_DEFAULT_PITCH, 164 + .expected = { 0xFF0000FF }, 169 165 }, 170 166 }, 171 167 { ··· 232 212 .swab_result = { 233 213 .dst_pitch = TEST_USE_DEFAULT_PITCH, 234 214 .expected = { 0x0000FF10 }, 215 + }, 216 + .xbgr8888_result = { 217 + .dst_pitch = TEST_USE_DEFAULT_PITCH, 218 + .expected = { 0x100000FF }, 219 + }, 220 + .abgr8888_result = { 221 + .dst_pitch = TEST_USE_DEFAULT_PITCH, 222 + .expected = { 0xFF0000FF }, 235 223 }, 236 224 }, 237 225 { ··· 371 343 0x00FFFF77, 0xFFFF0088, 372 344 }, 373 345 }, 346 + .xbgr8888_result = { 347 + .dst_pitch = TEST_USE_DEFAULT_PITCH, 348 + .expected = { 349 + 0x11FFFFFF, 0x22000000, 350 + 0x330000FF, 0x4400FF00, 351 + 0x55FF0000, 0x66FF00FF, 352 + 0x7700FFFF, 0x88FFFF00, 353 + }, 354 + }, 355 + .abgr8888_result = { 356 + .dst_pitch = TEST_USE_DEFAULT_PITCH, 357 + .expected = { 358 + 0xFFFFFFFF, 0xFF000000, 359 + 0xFF0000FF, 0xFF00FF00, 360 + 0xFFFF0000, 0xFFFF00FF, 361 + 0xFF00FFFF, 0xFFFFFF00, 362 + }, 363 + }, 374 364 }, 375 365 { 376 366 /* Randomly picked colors. Full buffer within the clip area. */ ··· 502 456 0x9C440EA1, 0x054D11B1, 0x03F3A8C1, 0x00000000, 0x00000000, 503 457 0x73F06CD1, 0x9C440EA2, 0x054D11B2, 0x00000000, 0x00000000, 504 458 0x0303A8C2, 0x73F06CD2, 0x9C440EA3, 0x00000000, 0x00000000, 459 + }, 460 + }, 461 + .xbgr8888_result = { 462 + .dst_pitch = 20, 463 + .expected = { 464 + 0xA19C440E, 0xB1054D11, 0xC103F3A8, 0x00000000, 0x00000000, 465 + 0xD173F06C, 0xA29C440E, 0xB2054D11, 0x00000000, 0x00000000, 466 + 0xC20303A8, 0xD273F06C, 0xA39C440E, 0x00000000, 0x00000000, 467 + }, 468 + }, 469 + .abgr8888_result = { 470 + .dst_pitch = 20, 471 + .expected = { 472 + 0xFF9C440E, 0xFF054D11, 0xFF03F3A8, 0x00000000, 0x00000000, 473 + 0xFF73F06C, 0xFF9C440E, 0xFF054D11, 0x00000000, 0x00000000, 474 + 0xFF0303A8, 0xFF73F06C, 0xFF9C440E, 0x00000000, 0x00000000, 505 475 }, 506 476 }, 507 477 }, ··· 1144 1082 KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); 1145 1083 } 1146 1084 1085 + static void drm_test_fb_xrgb8888_to_abgr8888(struct kunit *test) 1086 + { 1087 + const struct convert_xrgb8888_case *params = test->param_value; 1088 + const struct convert_to_abgr8888_result *result = &params->abgr8888_result; 1089 + size_t dst_size; 1090 + u32 *buf = NULL; 1091 + __le32 *xrgb8888 = NULL; 1092 + struct iosys_map dst, src; 1093 + 1094 + struct drm_framebuffer fb = { 1095 + .format = drm_format_info(DRM_FORMAT_XRGB8888), 1096 + .pitches = { params->pitch, 0, 0 }, 1097 + }; 1098 + 1099 + dst_size = conversion_buf_size(DRM_FORMAT_XBGR8888, result->dst_pitch, &params->clip, 0); 1100 + 1101 + KUNIT_ASSERT_GT(test, dst_size, 0); 1102 + 1103 + buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); 1104 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf); 1105 + iosys_map_set_vaddr(&dst, buf); 1106 + 1107 + xrgb8888 = cpubuf_to_le32(test, params->xrgb8888, TEST_BUF_SIZE); 1108 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xrgb8888); 1109 + iosys_map_set_vaddr(&src, xrgb8888); 1110 + 1111 + const unsigned int *dst_pitch = (result->dst_pitch == TEST_USE_DEFAULT_PITCH) ? 1112 + NULL : &result->dst_pitch; 1113 + 1114 + int blit_result = 0; 1115 + 1116 + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_ABGR8888, &src, &fb, &params->clip); 1117 + 1118 + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); 1119 + 1120 + KUNIT_EXPECT_FALSE(test, blit_result); 1121 + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); 1122 + } 1123 + 1124 + static void drm_test_fb_xrgb8888_to_xbgr8888(struct kunit *test) 1125 + { 1126 + const struct convert_xrgb8888_case *params = test->param_value; 1127 + const struct convert_to_xbgr8888_result *result = &params->xbgr8888_result; 1128 + size_t dst_size; 1129 + u32 *buf = NULL; 1130 + __le32 *xrgb8888 = NULL; 1131 + struct iosys_map dst, src; 1132 + 1133 + struct drm_framebuffer fb = { 1134 + .format = drm_format_info(DRM_FORMAT_XRGB8888), 1135 + .pitches = { params->pitch, 0, 0 }, 1136 + }; 1137 + 1138 + dst_size = conversion_buf_size(DRM_FORMAT_XBGR8888, result->dst_pitch, &params->clip, 0); 1139 + 1140 + KUNIT_ASSERT_GT(test, dst_size, 0); 1141 + 1142 + buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); 1143 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf); 1144 + iosys_map_set_vaddr(&dst, buf); 1145 + 1146 + xrgb8888 = cpubuf_to_le32(test, params->xrgb8888, TEST_BUF_SIZE); 1147 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xrgb8888); 1148 + iosys_map_set_vaddr(&src, xrgb8888); 1149 + 1150 + const unsigned int *dst_pitch = (result->dst_pitch == TEST_USE_DEFAULT_PITCH) ? 1151 + NULL : &result->dst_pitch; 1152 + 1153 + int blit_result = 0; 1154 + 1155 + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_XBGR8888, &src, &fb, &params->clip); 1156 + 1157 + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); 1158 + 1159 + KUNIT_EXPECT_FALSE(test, blit_result); 1160 + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); 1161 + } 1162 + 1147 1163 struct clip_offset_case { 1148 1164 const char *name; 1149 1165 unsigned int pitch; ··· 1840 1700 KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_argb2101010, convert_xrgb8888_gen_params), 1841 1701 KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_mono, convert_xrgb8888_gen_params), 1842 1702 KUNIT_CASE_PARAM(drm_test_fb_swab, convert_xrgb8888_gen_params), 1703 + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xbgr8888, convert_xrgb8888_gen_params), 1704 + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_abgr8888, convert_xrgb8888_gen_params), 1843 1705 KUNIT_CASE_PARAM(drm_test_fb_clip_offset, clip_offset_gen_params), 1844 1706 KUNIT_CASE_PARAM(drm_test_fb_build_fourcc_list, fb_build_fourcc_list_gen_params), 1845 1707 KUNIT_CASE_PARAM(drm_test_fb_memcpy, fb_memcpy_gen_params),