diff options
author | Eric Anholt <eric@anholt.net> | 2016-01-25 13:15:36 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2016-02-08 16:34:13 -0800 |
commit | 59f98997ab315465a052ed11e43ed7f6b0ec708a (patch) | |
tree | 63f0f5f5c5cb575b053009d2d90f4465e4062e5b | |
parent | b8badc243630e88f243b66c20599cfd035286382 (diff) |
igt: Add a helper function for creating VC4 BOs.
v2: Use do_ioctl().
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
-rw-r--r-- | lib/igt_vc4.c | 20 | ||||
-rw-r--r-- | lib/igt_vc4.h | 1 | ||||
-rw-r--r-- | tests/vc4_wait_bo.c | 9 |
3 files changed, 17 insertions, 13 deletions
diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c index 8d00764a..894c73aa 100644 --- a/lib/igt_vc4.c +++ b/lib/igt_vc4.c @@ -68,9 +68,7 @@ uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval) /* A single row will be a page. */ uint32_t width = 1024; uint32_t height = size / (width * 4); - struct drm_vc4_create_bo create = { - .size = size, - }; + uint32_t handle = igt_vc4_create_bo(fd, size); struct drm_vc4_submit_cl submit = { .color_write = { .hindex = 0, @@ -84,7 +82,7 @@ uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval) .msaa_color_write = { .hindex = ~0 }, .msaa_zs_write = { .hindex = ~0 }, - .bo_handles = (uint64_t)(uintptr_t)&create.handle, + .bo_handles = (uint64_t)(uintptr_t)&handle, .bo_handle_count = 1, .width = width, .height = height, @@ -96,10 +94,20 @@ uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval) igt_assert_eq_u32(width * height * 4, size); - do_ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create); - do_ioctl(fd, DRM_IOCTL_VC4_SUBMIT_CL, &submit); + return handle; +} + +int +igt_vc4_create_bo(int fd, size_t size) +{ + struct drm_vc4_create_bo create = { + .size = size, + }; + + do_ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create); + return create.handle; } diff --git a/lib/igt_vc4.h b/lib/igt_vc4.h index d428f391..e9252461 100644 --- a/lib/igt_vc4.h +++ b/lib/igt_vc4.h @@ -25,6 +25,7 @@ #define IGT_VC4_H uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval); +int igt_vc4_create_bo(int fd, size_t size); void *igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot); #endif /* IGT_VC4_H */ diff --git a/tests/vc4_wait_bo.c b/tests/vc4_wait_bo.c index 04828ed6..1b924642 100644 --- a/tests/vc4_wait_bo.c +++ b/tests/vc4_wait_bo.c @@ -22,6 +22,7 @@ */ #include "igt.h" +#include "igt_vc4.h" #include <unistd.h> #include <stdlib.h> #include <stdio.h> @@ -39,14 +40,8 @@ igt_main int bo_handle; igt_fixture { - struct drm_vc4_create_bo create = { - .size = 4096, - }; - fd = drm_open_driver(DRIVER_VC4); - - do_ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create); - bo_handle = create.handle; + bo_handle = igt_vc4_create_bo(fd, 4096); } igt_subtest("bad-bo") { |