From 7d2ba073adef9c4c6f7a679befa2a5d19cbf4735 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Sun, 19 Jan 2014 22:13:36 +0100 Subject: lib: add __gem_create Useful for when a gem_create ioctl is expected to fail. Signed-off-by: Daniel Vetter --- lib/drmtest.c | 15 +++++++++++++++ lib/drmtest.h | 1 + 2 files changed, 16 insertions(+) diff --git a/lib/drmtest.c b/lib/drmtest.c index 246f2f74..8bc70a35 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -540,6 +540,21 @@ void gem_sync(int fd, uint32_t handle) gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); } +uint32_t __gem_create(int fd, int size) +{ + struct drm_i915_gem_create create; + int ret; + + create.handle = 0; + create.size = size; + ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create); + + if (ret < 0) + return 0; + else + return create.handle; +} + uint32_t gem_create(int fd, int size) { struct drm_i915_gem_create create; diff --git a/lib/drmtest.h b/lib/drmtest.h index 0240a053..d42a6f77 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -72,6 +72,7 @@ void gem_read(int fd, uint32_t handle, uint32_t offset, void *buf, uint32_t size void gem_set_domain(int fd, uint32_t handle, uint32_t read_domains, uint32_t write_domain); void gem_sync(int fd, uint32_t handle); +uint32_t __gem_create(int fd, int size); uint32_t gem_create(int fd, int size); void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf); -- cgit v1.2.3