Message ID | 20230310200901.216971-2-arthurgrillo@riseup.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono() | expand |
Hi Arthur, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on drm-misc/drm-misc-next] [also build test WARNING on drm/drm-next drm-exynos/exynos-drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.3-rc1 next-20230310] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Arthur-Grillo/drm-format-helper-Add-Kunit-tests-for-drm_fb_xrgb8888_to_mono/20230311-041101 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230310200901.216971-2-arthurgrillo%40riseup.net patch subject: [PATCH v2 1/2] drm/format-helper: Add Kunit tests for drm_fb_xrgb8888_to_mono() config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230311/202303110624.afo4lQ9b-lkp@intel.com/config) compiler: m68k-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/efeeef1f599ecbb4a8c2ab1b4a4dd77d77ab63f4 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Arthur-Grillo/drm-format-helper-Add-Kunit-tests-for-drm_fb_xrgb8888_to_mono/20230311-041101 git checkout efeeef1f599ecbb4a8c2ab1b4a4dd77d77ab63f4 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/gpu/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202303110624.afo4lQ9b-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/gpu/drm/tests/drm_format_helper_test.c:314:41: warning: suggest parentheses around operand of '!' or change '|' to '||' or '!' to '~' [-Wparentheses] 314 | !BIT(0) | BIT(1), | ^ vim +314 drivers/gpu/drm/tests/drm_format_helper_test.c 92 93 static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 94 { 95 .name = "single_pixel_source_buffer", 96 .pitch = 1 * 4, 97 .clip = DRM_RECT_INIT(0, 0, 1, 1), 98 .xrgb8888 = { 0x01FF0000 }, 99 .gray8_result = { 100 .dst_pitch = 0, 101 .expected = { 0x4C }, 102 }, 103 .rgb332_result = { 104 .dst_pitch = 0, 105 .expected = { 0xE0 }, 106 }, 107 .rgb565_result = { 108 .dst_pitch = 0, 109 .expected = { 0xF800 }, 110 .expected_swab = { 0x00F8 }, 111 }, 112 .xrgb1555_result = { 113 .dst_pitch = 0, 114 .expected = { 0x7C00 }, 115 }, 116 .argb1555_result = { 117 .dst_pitch = 0, 118 .expected = { 0xFC00 }, 119 }, 120 .rgba5551_result = { 121 .dst_pitch = 0, 122 .expected = { 0xF801 }, 123 }, 124 .rgb888_result = { 125 .dst_pitch = 0, 126 .expected = { 0x00, 0x00, 0xFF }, 127 }, 128 .argb8888_result = { 129 .dst_pitch = 0, 130 .expected = { 0xFFFF0000 }, 131 }, 132 .xrgb2101010_result = { 133 .dst_pitch = 0, 134 .expected = { 0x3FF00000 }, 135 }, 136 .argb2101010_result = { 137 .dst_pitch = 0, 138 .expected = { 0xFFF00000 }, 139 }, 140 .mono_result = { 141 .dst_pitch = 0, 142 .expected = { !BIT(0) }, 143 }, 144 }, 145 { 146 .name = "single_pixel_clip_rectangle", 147 .pitch = 2 * 4, 148 .clip = DRM_RECT_INIT(1, 1, 1, 1), 149 .xrgb8888 = { 150 0x00000000, 0x00000000, 151 0x00000000, 0x10FF0000, 152 }, 153 .gray8_result = { 154 .dst_pitch = 0, 155 .expected = { 0x4C }, 156 }, 157 .rgb332_result = { 158 .dst_pitch = 0, 159 .expected = { 0xE0 }, 160 }, 161 .rgb565_result = { 162 .dst_pitch = 0, 163 .expected = { 0xF800 }, 164 .expected_swab = { 0x00F8 }, 165 }, 166 .xrgb1555_result = { 167 .dst_pitch = 0, 168 .expected = { 0x7C00 }, 169 }, 170 .argb1555_result = { 171 .dst_pitch = 0, 172 .expected = { 0xFC00 }, 173 }, 174 .rgba5551_result = { 175 .dst_pitch = 0, 176 .expected = { 0xF801 }, 177 }, 178 .rgb888_result = { 179 .dst_pitch = 0, 180 .expected = { 0x00, 0x00, 0xFF }, 181 }, 182 .argb8888_result = { 183 .dst_pitch = 0, 184 .expected = { 0xFFFF0000 }, 185 }, 186 .xrgb2101010_result = { 187 .dst_pitch = 0, 188 .expected = { 0x3FF00000 }, 189 }, 190 .argb2101010_result = { 191 .dst_pitch = 0, 192 .expected = { 0xFFF00000 }, 193 }, 194 .mono_result = { 195 .dst_pitch = 0, 196 .expected = { !BIT(0) }, 197 }, 198 }, 199 { 200 /* Well known colors: White, black, red, green, blue, magenta, 201 * yellow and cyan. Different values for the X in XRGB8888 to 202 * make sure it is ignored. Partial clip area. 203 */ 204 .name = "well_known_colors", 205 .pitch = 4 * 4, 206 .clip = DRM_RECT_INIT(1, 1, 2, 4), 207 .xrgb8888 = { 208 0x00000000, 0x00000000, 0x00000000, 0x00000000, 209 0x00000000, 0x11FFFFFF, 0x22000000, 0x00000000, 210 0x00000000, 0x33FF0000, 0x4400FF00, 0x00000000, 211 0x00000000, 0x550000FF, 0x66FF00FF, 0x00000000, 212 0x00000000, 0x77FFFF00, 0x8800FFFF, 0x00000000, 213 }, 214 .gray8_result = { 215 .dst_pitch = 0, 216 .expected = { 217 0xFF, 0x00, 218 0x4C, 0x99, 219 0x19, 0x66, 220 0xE5, 0xB2, 221 }, 222 }, 223 .rgb332_result = { 224 .dst_pitch = 0, 225 .expected = { 226 0xFF, 0x00, 227 0xE0, 0x1C, 228 0x03, 0xE3, 229 0xFC, 0x1F, 230 }, 231 }, 232 .rgb565_result = { 233 .dst_pitch = 0, 234 .expected = { 235 0xFFFF, 0x0000, 236 0xF800, 0x07E0, 237 0x001F, 0xF81F, 238 0xFFE0, 0x07FF, 239 }, 240 .expected_swab = { 241 0xFFFF, 0x0000, 242 0x00F8, 0xE007, 243 0x1F00, 0x1FF8, 244 0xE0FF, 0xFF07, 245 }, 246 }, 247 .xrgb1555_result = { 248 .dst_pitch = 0, 249 .expected = { 250 0x7FFF, 0x0000, 251 0x7C00, 0x03E0, 252 0x001F, 0x7C1F, 253 0x7FE0, 0x03FF, 254 }, 255 }, 256 .argb1555_result = { 257 .dst_pitch = 0, 258 .expected = { 259 0xFFFF, 0x8000, 260 0xFC00, 0x83E0, 261 0x801F, 0xFC1F, 262 0xFFE0, 0x83FF, 263 }, 264 }, 265 .rgba5551_result = { 266 .dst_pitch = 0, 267 .expected = { 268 0xFFFF, 0x0001, 269 0xF801, 0x07C1, 270 0x003F, 0xF83F, 271 0xFFC1, 0x07FF, 272 }, 273 }, 274 .rgb888_result = { 275 .dst_pitch = 0, 276 .expected = { 277 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 278 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 279 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 280 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 281 }, 282 }, 283 .argb8888_result = { 284 .dst_pitch = 0, 285 .expected = { 286 0xFFFFFFFF, 0xFF000000, 287 0xFFFF0000, 0xFF00FF00, 288 0xFF0000FF, 0xFFFF00FF, 289 0xFFFFFF00, 0xFF00FFFF, 290 }, 291 }, 292 .xrgb2101010_result = { 293 .dst_pitch = 0, 294 .expected = { 295 0x3FFFFFFF, 0x00000000, 296 0x3FF00000, 0x000FFC00, 297 0x000003FF, 0x3FF003FF, 298 0x3FFFFC00, 0x000FFFFF, 299 }, 300 }, 301 .argb2101010_result = { 302 .dst_pitch = 0, 303 .expected = { 304 0xFFFFFFFF, 0xC0000000, 305 0xFFF00000, 0xC00FFC00, 306 0xC00003FF, 0xFFF003FF, 307 0xFFFFFC00, 0xC00FFFFF, 308 }, 309 }, 310 .mono_result = { 311 .dst_pitch = 0, 312 .expected = { 313 BIT(0) | !BIT(1), > 314 !BIT(0) | BIT(1), 315 !BIT(0) | !BIT(1), 316 BIT(0) | BIT(1), 317 }, 318 }, 319 }, 320 { 321 /* Randomly picked colors. Full buffer within the clip area. */ 322 .name = "destination_pitch", 323 .pitch = 3 * 4, 324 .clip = DRM_RECT_INIT(0, 0, 3, 3), 325 .xrgb8888 = { 326 0xA10E449C, 0xB1114D05, 0xC1A80303, 327 0xD16C7073, 0xA20E449C, 0xB2114D05, 328 0xC2A80303, 0xD26C7073, 0xA30E449C, 329 }, 330 .gray8_result = { 331 .dst_pitch = 5, 332 .expected = { 333 0x3C, 0x33, 0x34, 0x00, 0x00, 334 0x6F, 0x3C, 0x33, 0x00, 0x00, 335 0x34, 0x6F, 0x3C, 0x00, 0x00, 336 }, 337 }, 338 .rgb332_result = { 339 .dst_pitch = 5, 340 .expected = { 341 0x0A, 0x08, 0xA0, 0x00, 0x00, 342 0x6D, 0x0A, 0x08, 0x00, 0x00, 343 0xA0, 0x6D, 0x0A, 0x00, 0x00, 344 }, 345 }, 346 .rgb565_result = { 347 .dst_pitch = 10, 348 .expected = { 349 0x0A33, 0x1260, 0xA800, 0x0000, 0x0000, 350 0x6B8E, 0x0A33, 0x1260, 0x0000, 0x0000, 351 0xA800, 0x6B8E, 0x0A33, 0x0000, 0x0000, 352 }, 353 .expected_swab = { 354 0x330A, 0x6012, 0x00A8, 0x0000, 0x0000, 355 0x8E6B, 0x330A, 0x6012, 0x0000, 0x0000, 356 0x00A8, 0x8E6B, 0x330A, 0x0000, 0x0000, 357 }, 358 }, 359 .xrgb1555_result = { 360 .dst_pitch = 10, 361 .expected = { 362 0x0513, 0x0920, 0x5400, 0x0000, 0x0000, 363 0x35CE, 0x0513, 0x0920, 0x0000, 0x0000, 364 0x5400, 0x35CE, 0x0513, 0x0000, 0x0000, 365 }, 366 }, 367 .argb1555_result = { 368 .dst_pitch = 10, 369 .expected = { 370 0x8513, 0x8920, 0xD400, 0x0000, 0x0000, 371 0xB5CE, 0x8513, 0x8920, 0x0000, 0x0000, 372 0xD400, 0xB5CE, 0x8513, 0x0000, 0x0000, 373 }, 374 }, 375 .rgba5551_result = { 376 .dst_pitch = 10, 377 .expected = { 378 0x0A27, 0x1241, 0xA801, 0x0000, 0x0000, 379 0x6B9D, 0x0A27, 0x1241, 0x0000, 0x0000, 380 0xA801, 0x6B9D, 0x0A27, 0x0000, 0x0000, 381 }, 382 }, 383 .rgb888_result = { 384 .dst_pitch = 15, 385 .expected = { 386 0x9C, 0x44, 0x0E, 0x05, 0x4D, 0x11, 0x03, 0x03, 0xA8, 387 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 388 0x73, 0x70, 0x6C, 0x9C, 0x44, 0x0E, 0x05, 0x4D, 0x11, 389 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 390 0x03, 0x03, 0xA8, 0x73, 0x70, 0x6C, 0x9C, 0x44, 0x0E, 391 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 392 }, 393 }, 394 .argb8888_result = { 395 .dst_pitch = 20, 396 .expected = { 397 0xFF0E449C, 0xFF114D05, 0xFFA80303, 0x00000000, 0x00000000, 398 0xFF6C7073, 0xFF0E449C, 0xFF114D05, 0x00000000, 0x00000000, 399 0xFFA80303, 0xFF6C7073, 0xFF0E449C, 0x00000000, 0x00000000, 400 }, 401 }, 402 .xrgb2101010_result = { 403 .dst_pitch = 20, 404 .expected = { 405 0x03844672, 0x0444D414, 0x2A20300C, 0x00000000, 0x00000000, 406 0x1B1705CD, 0x03844672, 0x0444D414, 0x00000000, 0x00000000, 407 0x2A20300C, 0x1B1705CD, 0x03844672, 0x00000000, 0x00000000, 408 }, 409 }, 410 .argb2101010_result = { 411 .dst_pitch = 20, 412 .expected = { 413 0xC3844672, 0xC444D414, 0xEA20300C, 0x00000000, 0x00000000, 414 0xDB1705CD, 0xC3844672, 0xC444D414, 0x00000000, 0x00000000, 415 0xEA20300C, 0xDB1705CD, 0xC3844672, 0x00000000, 0x00000000, 416 }, 417 }, 418 .mono_result = { 419 .dst_pitch = 2, 420 .expected = { 421 !BIT(0) | !BIT(1) | !BIT(2), 0x00, 422 !BIT(0) | !BIT(1) | !BIT(2), 0x00, 423 !BIT(0) | !BIT(1) | !BIT(2), 0x00, 424 }, 425 }, 426 }, 427 }; 428
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 84b5cc29c8fc..00f7acd54828 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -67,6 +67,11 @@ struct convert_to_argb2101010_result { const u32 expected[TEST_BUF_SIZE]; }; +struct convert_to_mono_result { + unsigned int dst_pitch; + const u8 expected[TEST_BUF_SIZE]; +}; + struct convert_xrgb8888_case { const char *name; unsigned int pitch; @@ -82,6 +87,7 @@ struct convert_xrgb8888_case { struct convert_to_argb8888_result argb8888_result; struct convert_to_xrgb2101010_result xrgb2101010_result; struct convert_to_argb2101010_result argb2101010_result; + struct convert_to_mono_result mono_result; }; static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { @@ -131,6 +137,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = 0, .expected = { 0xFFF00000 }, }, + .mono_result = { + .dst_pitch = 0, + .expected = { !BIT(0) }, + }, }, { .name = "single_pixel_clip_rectangle", @@ -181,6 +191,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = 0, .expected = { 0xFFF00000 }, }, + .mono_result = { + .dst_pitch = 0, + .expected = { !BIT(0) }, + }, }, { /* Well known colors: White, black, red, green, blue, magenta, @@ -293,6 +307,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0xFFFFFC00, 0xC00FFFFF, }, }, + .mono_result = { + .dst_pitch = 0, + .expected = { + BIT(0) | !BIT(1), + !BIT(0) | BIT(1), + !BIT(0) | !BIT(1), + BIT(0) | BIT(1), + }, + }, }, { /* Randomly picked colors. Full buffer within the clip area. */ @@ -392,6 +415,14 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0xEA20300C, 0xDB1705CD, 0xC3844672, 0x00000000, 0x00000000, }, }, + .mono_result = { + .dst_pitch = 2, + .expected = { + !BIT(0) | !BIT(1) | !BIT(2), 0x00, + !BIT(0) | !BIT(1) | !BIT(2), 0x00, + !BIT(0) | !BIT(1) | !BIT(2), 0x00, + }, + }, }, }; @@ -792,6 +823,36 @@ static void drm_test_fb_xrgb8888_to_argb2101010(struct kunit *test) KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); } +static void drm_test_fb_xrgb8888_to_mono(struct kunit *test) +{ + const struct convert_xrgb8888_case *params = test->param_value; + const struct convert_to_mono_result *result = ¶ms->mono_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_C1, result->dst_pitch, ¶ms->clip); + + 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); + + drm_fb_xrgb8888_to_mono(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); +} + static struct kunit_case drm_format_helper_test_cases[] = { KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_gray8, convert_xrgb8888_gen_params), KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_params), @@ -803,6 +864,7 @@ static struct kunit_case drm_format_helper_test_cases[] = { 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), + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_mono, convert_xrgb8888_gen_params), {} };
Extend the existing test cases to test the conversion from XRGB8888 to monochromatic. Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net> --- .../gpu/drm/tests/drm_format_helper_test.c | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+)