aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Jakobi2015-11-29 21:12:20 -0600
committerEmil Velikov2015-12-18 11:42:54 -0600
commit6689e4ee14f2dd0f04db9b5b816a252dfeb01ca5 (patch)
tree99b7d514612120d952ed2f62136dcaaa64a6e827
parent676462c43e97896caa891b1e0aeb27d5d4f13637 (diff)
downloadexternal-libdrm-6689e4ee14f2dd0f04db9b5b816a252dfeb01ca5.tar.gz
external-libdrm-6689e4ee14f2dd0f04db9b5b816a252dfeb01ca5.tar.xz
external-libdrm-6689e4ee14f2dd0f04db9b5b816a252dfeb01ca5.zip
tests/exynos: add test for g2d_move
To check if g2d_move() works properly we create a small checkerboard pattern in the center of the screen and then shift this pattern around with g2d_move(). The pattern should be properly preserved by the operation (but not the surrounding area). Tested-by: Hyungwon Hwang <human.hwang@samsung.com> Reviewed-by: Hyungwon Hwang <human.hwang@samsung.com> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de> [Emil Velikov: add g2d_move to the symbol check] Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
-rwxr-xr-xexynos/exynos-symbol-check1
-rw-r--r--tests/exynos/exynos_fimg2d_test.c132
2 files changed, 133 insertions, 0 deletions
diff --git a/exynos/exynos-symbol-check b/exynos/exynos-symbol-check
index bb12315e..9692caa6 100755
--- a/exynos/exynos-symbol-check
+++ b/exynos/exynos-symbol-check
@@ -30,6 +30,7 @@ g2d_exec
30g2d_config_event 30g2d_config_event
31g2d_fini 31g2d_fini
32g2d_init 32g2d_init
33g2d_move
33g2d_scale_and_blend 34g2d_scale_and_blend
34g2d_solid_fill 35g2d_solid_fill
35EOF 36EOF
diff --git a/tests/exynos/exynos_fimg2d_test.c b/tests/exynos/exynos_fimg2d_test.c
index dfb00a0b..797fb6eb 100644
--- a/tests/exynos/exynos_fimg2d_test.c
+++ b/tests/exynos/exynos_fimg2d_test.c
@@ -313,6 +313,130 @@ fail:
313 return ret; 313 return ret;
314} 314}
315 315
316static int g2d_move_test(struct exynos_device *dev,
317 struct exynos_bo *tmp,
318 struct exynos_bo *buf,
319 enum e_g2d_buf_type type)
320{
321 struct g2d_context *ctx;
322 struct g2d_image img = {0}, tmp_img = {0};
323 unsigned int img_w, img_h, count;
324 int cur_x, cur_y;
325 void *checkerboard;
326 int ret;
327
328 static const struct g2d_step {
329 int x, y;
330 } steps[] = {
331 { 1, 0}, { 0, 1},
332 {-1, 0}, { 0, -1},
333 { 1, 1}, {-1, -1},
334 { 1, -1}, {-1, 1},
335 { 2, 1}, { 1, 2},
336 {-2, -1}, {-1, -2},
337 { 2, -1}, { 1, -2},
338 {-2, 1}, {-1, 2}
339 };
340 static const unsigned int num_steps =
341 sizeof(steps) / sizeof(struct g2d_step);
342
343 ctx = g2d_init(dev->fd);
344 if (!ctx)
345 return -EFAULT;
346
347 img.bo[0] = buf->handle;
348
349 /* create pattern of half the screen size */
350 checkerboard = create_checkerboard_pattern(screen_width / 64, screen_height / 64, 32);
351 if (!checkerboard) {
352 ret = -EFAULT;
353 goto fail;
354 }
355
356 img_w = (screen_width / 64) * 32;
357 img_h = (screen_height / 64) * 32;
358
359 switch (type) {
360 case G2D_IMGBUF_GEM:
361 memcpy(tmp->vaddr, checkerboard, img_w * img_h * 4);
362 tmp_img.bo[0] = tmp->handle;
363 break;
364 case G2D_IMGBUF_USERPTR:
365 tmp_img.user_ptr[0].userptr = (unsigned long)checkerboard;
366 tmp_img.user_ptr[0].size = img_w * img_h * 4;
367 break;
368 case G2D_IMGBUF_COLOR:
369 default:
370 ret = -EFAULT;
371 goto fail;
372 }
373
374 /* solid fill framebuffer with white color */
375 img.width = screen_width;
376 img.height = screen_height;
377 img.stride = screen_width * 4;
378 img.buf_type = G2D_IMGBUF_GEM;
379 img.color_mode = G2D_COLOR_FMT_ARGB8888 | G2D_ORDER_AXRGB;
380 img.color = 0xffffffff;
381
382 /* put checkerboard pattern in the center of the framebuffer */
383 cur_x = (screen_width - img_w) / 2;
384 cur_y = (screen_height - img_h) / 2;
385 tmp_img.width = img_w;
386 tmp_img.height = img_h;
387 tmp_img.stride = img_w * 4;
388 tmp_img.buf_type = type;
389 tmp_img.color_mode = G2D_COLOR_FMT_ARGB8888 | G2D_ORDER_AXRGB;
390
391 ret = g2d_solid_fill(ctx, &img, 0, 0, screen_width, screen_height) ||
392 g2d_copy(ctx, &tmp_img, &img, 0, 0, cur_x, cur_y, img_w, img_h);
393
394 if (!ret)
395 ret = g2d_exec(ctx);
396 if (ret < 0)
397 goto fail;
398
399 printf("move test with %s.\n",
400 type == G2D_IMGBUF_GEM ? "gem" : "userptr");
401
402 srand(time(NULL));
403 for (count = 0; count < 256; ++count) {
404 const struct g2d_step *s;
405
406 /* select step and validate it */
407 while (1) {
408 s = &steps[random() % num_steps];
409
410 if (cur_x + s->x < 0 || cur_y + s->y < 0 ||
411 cur_x + img_w + s->x >= screen_width ||
412 cur_y + img_h + s->y >= screen_height)
413 continue;
414 else
415 break;
416 }
417
418 ret = g2d_move(ctx, &img, cur_x, cur_y, cur_x + s->x, cur_y + s->y,
419 img_w, img_h);
420 if (!ret)
421 ret = g2d_exec(ctx);
422
423 if (ret < 0)
424 goto fail;
425
426 cur_x += s->x;
427 cur_y += s->y;
428
429 usleep(100000);
430 }
431
432fail:
433 g2d_fini(ctx);
434
435 free(checkerboard);
436
437 return ret;
438}
439
316static int g2d_copy_with_scale_test(struct exynos_device *dev, 440static int g2d_copy_with_scale_test(struct exynos_device *dev,
317 struct exynos_bo *src, 441 struct exynos_bo *src,
318 struct exynos_bo *dst, 442 struct exynos_bo *dst,
@@ -708,6 +832,14 @@ int main(int argc, char **argv)
708 832
709 wait_for_user_input(0); 833 wait_for_user_input(0);
710 834
835 ret = g2d_move_test(dev, src, bo, G2D_IMGBUF_GEM);
836 if (ret < 0) {
837 fprintf(stderr, "failed to test move operation.\n");
838 goto err_free_src;
839 }
840
841 wait_for_user_input(0);
842
711 ret = g2d_copy_with_scale_test(dev, src, bo, G2D_IMGBUF_GEM); 843 ret = g2d_copy_with_scale_test(dev, src, bo, G2D_IMGBUF_GEM);
712 if (ret < 0) { 844 if (ret < 0) {
713 fprintf(stderr, "failed to test copy and scale operation.\n"); 845 fprintf(stderr, "failed to test copy and scale operation.\n");