diff options
Diffstat (limited to 'tests/exynos/exynos_fimg2d_test.c')
-rw-r--r-- | tests/exynos/exynos_fimg2d_test.c | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/tests/exynos/exynos_fimg2d_test.c b/tests/exynos/exynos_fimg2d_test.c index 797fb6eb..99bb9233 100644 --- a/tests/exynos/exynos_fimg2d_test.c +++ b/tests/exynos/exynos_fimg2d_test.c | |||
@@ -3,17 +3,26 @@ | |||
3 | * Authors: | 3 | * Authors: |
4 | * Inki Dae <inki.dae@samsung.com> | 4 | * Inki Dae <inki.dae@samsung.com> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
7 | * under the terms of the GNU General Public License as published by the | 7 | * copy of this software and associated documentation files (the "Software"), |
8 | * Free Software Foundation; either version 2 of the License, or (at your | 8 | * to deal in the Software without restriction, including without limitation |
9 | * option) any later version. | 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
10 | * and/or sell copies of the Software, and to permit persons to whom the | ||
11 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | 12 | * |
13 | * The above copyright notice and this permission notice (including the next | ||
14 | * paragraph) shall be included in all copies or substantial portions of the | ||
15 | * Software. | ||
16 | * | ||
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
20 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
23 | * OTHER DEALINGS IN THE SOFTWARE. | ||
11 | */ | 24 | */ |
12 | 25 | ||
13 | #ifdef HAVE_CONFIG_H | ||
14 | #include "config.h" | ||
15 | #endif | ||
16 | |||
17 | #include <stdlib.h> | 26 | #include <stdlib.h> |
18 | #include <stdio.h> | 27 | #include <stdio.h> |
19 | #include <string.h> | 28 | #include <string.h> |
@@ -59,7 +68,6 @@ static void connector_find_mode(int fd, struct connector *c, | |||
59 | if (!connector) { | 68 | if (!connector) { |
60 | fprintf(stderr, "could not get connector %i: %s\n", | 69 | fprintf(stderr, "could not get connector %i: %s\n", |
61 | resources->connectors[i], strerror(errno)); | 70 | resources->connectors[i], strerror(errno)); |
62 | drmModeFreeConnector(connector); | ||
63 | continue; | 71 | continue; |
64 | } | 72 | } |
65 | 73 | ||
@@ -98,7 +106,6 @@ static void connector_find_mode(int fd, struct connector *c, | |||
98 | if (!c->encoder) { | 106 | if (!c->encoder) { |
99 | fprintf(stderr, "could not get encoder %i: %s\n", | 107 | fprintf(stderr, "could not get encoder %i: %s\n", |
100 | resources->encoders[i], strerror(errno)); | 108 | resources->encoders[i], strerror(errno)); |
101 | drmModeFreeEncoder(c->encoder); | ||
102 | continue; | 109 | continue; |
103 | } | 110 | } |
104 | 111 | ||
@@ -264,7 +271,8 @@ static int g2d_copy_test(struct exynos_device *dev, struct exynos_bo *src, | |||
264 | userptr = (unsigned long)malloc(size); | 271 | userptr = (unsigned long)malloc(size); |
265 | if (!userptr) { | 272 | if (!userptr) { |
266 | fprintf(stderr, "failed to allocate userptr.\n"); | 273 | fprintf(stderr, "failed to allocate userptr.\n"); |
267 | return -EFAULT; | 274 | ret = -EFAULT; |
275 | goto fail; | ||
268 | } | 276 | } |
269 | 277 | ||
270 | src_img.user_ptr[0].userptr = userptr; | 278 | src_img.user_ptr[0].userptr = userptr; |
@@ -469,7 +477,8 @@ static int g2d_copy_with_scale_test(struct exynos_device *dev, | |||
469 | userptr = (unsigned long)malloc(size); | 477 | userptr = (unsigned long)malloc(size); |
470 | if (!userptr) { | 478 | if (!userptr) { |
471 | fprintf(stderr, "failed to allocate userptr.\n"); | 479 | fprintf(stderr, "failed to allocate userptr.\n"); |
472 | return -EFAULT; | 480 | ret = -EFAULT; |
481 | goto fail; | ||
473 | } | 482 | } |
474 | 483 | ||
475 | src_img.user_ptr[0].userptr = userptr; | 484 | src_img.user_ptr[0].userptr = userptr; |
@@ -520,9 +529,10 @@ err_free_userptr: | |||
520 | fail: | 529 | fail: |
521 | g2d_fini(ctx); | 530 | g2d_fini(ctx); |
522 | 531 | ||
523 | return 0; | 532 | return ret; |
524 | } | 533 | } |
525 | 534 | ||
535 | #ifdef EXYNOS_G2D_USERPTR_TEST | ||
526 | static int g2d_blend_test(struct exynos_device *dev, | 536 | static int g2d_blend_test(struct exynos_device *dev, |
527 | struct exynos_bo *src, | 537 | struct exynos_bo *src, |
528 | struct exynos_bo *dst, | 538 | struct exynos_bo *dst, |
@@ -557,7 +567,8 @@ static int g2d_blend_test(struct exynos_device *dev, | |||
557 | userptr = (unsigned long)malloc(size); | 567 | userptr = (unsigned long)malloc(size); |
558 | if (!userptr) { | 568 | if (!userptr) { |
559 | fprintf(stderr, "failed to allocate userptr.\n"); | 569 | fprintf(stderr, "failed to allocate userptr.\n"); |
560 | return -EFAULT; | 570 | ret = -EFAULT; |
571 | goto fail; | ||
561 | } | 572 | } |
562 | 573 | ||
563 | src_img.user_ptr[0].userptr = userptr; | 574 | src_img.user_ptr[0].userptr = userptr; |
@@ -619,8 +630,9 @@ err_free_userptr: | |||
619 | fail: | 630 | fail: |
620 | g2d_fini(ctx); | 631 | g2d_fini(ctx); |
621 | 632 | ||
622 | return 0; | 633 | return ret; |
623 | } | 634 | } |
635 | #endif | ||
624 | 636 | ||
625 | static int g2d_checkerboard_test(struct exynos_device *dev, | 637 | static int g2d_checkerboard_test(struct exynos_device *dev, |
626 | struct exynos_bo *src, | 638 | struct exynos_bo *src, |
@@ -645,8 +657,8 @@ static int g2d_checkerboard_test(struct exynos_device *dev, | |||
645 | dst_y = 0; | 657 | dst_y = 0; |
646 | 658 | ||
647 | checkerboard = create_checkerboard_pattern(screen_width / 32, screen_height / 32, 32); | 659 | checkerboard = create_checkerboard_pattern(screen_width / 32, screen_height / 32, 32); |
648 | if (checkerboard == NULL) { | 660 | if (!checkerboard) { |
649 | ret = -1; | 661 | ret = -EFAULT; |
650 | goto fail; | 662 | goto fail; |
651 | } | 663 | } |
652 | 664 | ||
@@ -755,8 +767,8 @@ int main(int argc, char **argv) | |||
755 | 767 | ||
756 | dev = exynos_device_create(fd); | 768 | dev = exynos_device_create(fd); |
757 | if (!dev) { | 769 | if (!dev) { |
758 | drmClose(dev->fd); | 770 | ret = -EFAULT; |
759 | return -EFAULT; | 771 | goto err_drm_close; |
760 | } | 772 | } |
761 | 773 | ||
762 | resources = drmModeGetResources(dev->fd); | 774 | resources = drmModeGetResources(dev->fd); |
@@ -764,7 +776,7 @@ int main(int argc, char **argv) | |||
764 | fprintf(stderr, "drmModeGetResources failed: %s\n", | 776 | fprintf(stderr, "drmModeGetResources failed: %s\n", |
765 | strerror(errno)); | 777 | strerror(errno)); |
766 | ret = -EFAULT; | 778 | ret = -EFAULT; |
767 | goto err_drm_close; | 779 | goto err_dev_destory; |
768 | } | 780 | } |
769 | 781 | ||
770 | connector_find_mode(dev->fd, &con, resources); | 782 | connector_find_mode(dev->fd, &con, resources); |
@@ -773,7 +785,7 @@ int main(int argc, char **argv) | |||
773 | if (!con.mode) { | 785 | if (!con.mode) { |
774 | fprintf(stderr, "failed to find usable connector\n"); | 786 | fprintf(stderr, "failed to find usable connector\n"); |
775 | ret = -EFAULT; | 787 | ret = -EFAULT; |
776 | goto err_drm_close; | 788 | goto err_dev_destory; |
777 | } | 789 | } |
778 | 790 | ||
779 | screen_width = con.mode->hdisplay; | 791 | screen_width = con.mode->hdisplay; |
@@ -782,7 +794,7 @@ int main(int argc, char **argv) | |||
782 | if (screen_width == 0 || screen_height == 0) { | 794 | if (screen_width == 0 || screen_height == 0) { |
783 | fprintf(stderr, "failed to find sane resolution on connector\n"); | 795 | fprintf(stderr, "failed to find sane resolution on connector\n"); |
784 | ret = -EFAULT; | 796 | ret = -EFAULT; |
785 | goto err_drm_close; | 797 | goto err_dev_destory; |
786 | } | 798 | } |
787 | 799 | ||
788 | printf("screen width = %d, screen height = %d\n", screen_width, | 800 | printf("screen width = %d, screen height = %d\n", screen_width, |
@@ -791,7 +803,7 @@ int main(int argc, char **argv) | |||
791 | bo = exynos_create_buffer(dev, screen_width * screen_height * 4, 0); | 803 | bo = exynos_create_buffer(dev, screen_width * screen_height * 4, 0); |
792 | if (!bo) { | 804 | if (!bo) { |
793 | ret = -EFAULT; | 805 | ret = -EFAULT; |
794 | goto err_drm_close; | 806 | goto err_dev_destory; |
795 | } | 807 | } |
796 | 808 | ||
797 | handles[0] = bo->handle; | 809 | handles[0] = bo->handle; |
@@ -864,7 +876,7 @@ int main(int argc, char **argv) | |||
864 | * | 876 | * |
865 | * Disable the test for now, until the kernel code has been sanitized. | 877 | * Disable the test for now, until the kernel code has been sanitized. |
866 | */ | 878 | */ |
867 | #if 0 | 879 | #ifdef EXYNOS_G2D_USERPTR_TEST |
868 | ret = g2d_blend_test(dev, src, bo, G2D_IMGBUF_USERPTR); | 880 | ret = g2d_blend_test(dev, src, bo, G2D_IMGBUF_USERPTR); |
869 | if (ret < 0) | 881 | if (ret < 0) |
870 | fprintf(stderr, "failed to test blend operation.\n"); | 882 | fprintf(stderr, "failed to test blend operation.\n"); |
@@ -882,9 +894,11 @@ err_rm_fb: | |||
882 | err_destroy_buffer: | 894 | err_destroy_buffer: |
883 | exynos_destroy_buffer(bo); | 895 | exynos_destroy_buffer(bo); |
884 | 896 | ||
885 | err_drm_close: | 897 | err_dev_destory: |
886 | drmClose(dev->fd); | ||
887 | exynos_device_destroy(dev); | 898 | exynos_device_destroy(dev); |
888 | 899 | ||
889 | return 0; | 900 | err_drm_close: |
901 | drmClose(fd); | ||
902 | |||
903 | return ret; | ||
890 | } | 904 | } |