Commit 7a6042e8 authored by Daniel Vetter's avatar Daniel Vetter

lib/drmtest: extract gem_create

Signed-Off-by: Daniel Vetter's avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 73d1b881
......@@ -188,3 +188,17 @@ 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);
assert(ret == 0);
assert(create.handle);
return create.handle;
}
......@@ -44,3 +44,4 @@ 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);
......@@ -49,7 +49,7 @@
* objects have size > 0.
*/
static uint32_t gem_create(int fd, int size, int *retval)
static uint32_t do_gem_create(int fd, int size, int *retval)
{
struct drm_i915_gem_create create;
int ret;
......@@ -73,7 +73,7 @@ static void create0(int fd)
{
int retval = 0;
printf("trying to create a zero-length gem object\n");
gem_create(fd, 0, &retval);
do_gem_create(fd, 0, &retval);
assert(retval == EINVAL);
}
......@@ -88,7 +88,7 @@ static void exec0(int fd)
* for the zero-length buffer, but never crash.
*/
exec[0].handle = gem_create(fd, 4096, NULL);
exec[0].handle = gem_create(fd, 4096);
gem_write(fd, exec[0].handle, 0, buf, sizeof(buf));
exec[0].relocation_count = 0;
exec[0].relocs_ptr = 0;
......
......@@ -52,17 +52,6 @@
#define BLT_SRC_TILED (1<<15)
#define BLT_DST_TILED (1<<11)
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = (size + 4095) & -4096;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
return create.handle;
}
static int gem_linear_blt(uint32_t *batch,
uint32_t src,
uint32_t dst,
......
......@@ -77,17 +77,6 @@ mmap_bo(int fd, uint32_t handle)
return ptr;
}
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = (size + 4095) & -4096;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
return create.handle;
}
static int gem_linear_blt(uint32_t *batch,
uint32_t src,
uint32_t dst,
......
......@@ -44,17 +44,6 @@
#define MI_BATCH_BUFFER_END (0xA<<23)
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
return create.handle;
}
static double elapsed(const struct timeval *start,
const struct timeval *end,
int loop)
......
......@@ -45,17 +45,6 @@
#define OBJECT_SIZE 16384
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
return create.handle;
}
static void *gem_mmap(int fd, uint32_t handle, int size, int prot)
{
struct drm_i915_gem_mmap_gtt mmap_arg;
......
......@@ -54,18 +54,6 @@
static uint32_t linear[WIDTH*HEIGHT];
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
assert(create.handle);
return create.handle;
}
static uint64_t
gem_aperture_size(int fd)
{
......
......@@ -42,19 +42,6 @@
#define OBJECT_SIZE (16*1024*1024)
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
int ret;
create.handle = 0;
create.size = (size + 4095) & -4096;
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
assert(ret == 0);
return create.handle;
}
static void set_domain(int fd, uint32_t handle)
{
gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
......
......@@ -51,17 +51,6 @@
#define BLT_DST_TILED (1<<11)
#define MI_BATCH_BUFFER_END (0xA<<23)
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = (size + 4095) & -4096;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
return create.handle;
}
static void do_gem_write(int fd, uint32_t handle, void *buf, int len, int loops)
{
while (loops--)
......
......@@ -61,18 +61,6 @@ static int tile_width;
static int tile_height;
static int tile_size;
static uint32_t
gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
return create.handle;
}
static void *gem_mmap(int fd, uint32_t handle, int size, int prot)
{
struct drm_i915_gem_mmap_gtt mmap_arg;
......
......@@ -67,18 +67,6 @@ static uint32_t current_tiling_mode;
#define PAGE_SIZE 4096
static uint32_t
gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
return create.handle;
}
static void *gem_mmap(int fd, uint32_t handle, int size, int prot)
{
struct drm_i915_gem_mmap_gtt mmap_arg;
......
......@@ -65,18 +65,6 @@ int main(int argc, char **argv)
static uint32_t linear[WIDTH*HEIGHT];
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
assert(create.handle);
return create.handle;
}
static uint32_t gem_vmap(int fd, void *ptr, int size, int read_only)
{
struct drm_i915_gem_vmap vmap;
......
......@@ -65,18 +65,6 @@ static inline uint32_t pack_float(float f)
return u.dw;
}
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
assert(create.handle);
return create.handle;
}
static uint64_t
gem_aperture_size(int fd)
{
......
......@@ -65,18 +65,6 @@ static inline uint32_t pack_float(float f)
return u.dw;
}
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
assert(create.handle);
return create.handle;
}
static uint64_t
gem_aperture_size(int fd)
{
......
......@@ -65,18 +65,6 @@ static inline uint32_t pack_float(float f)
return u.dw;
}
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
assert(create.handle);
return create.handle;
}
static uint64_t
gem_aperture_size(int fd)
{
......
......@@ -65,18 +65,6 @@ static inline uint32_t pack_float(float f)
return u.dw;
}
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
assert(create.handle);
return create.handle;
}
static uint64_t
gem_aperture_size(int fd)
{
......
......@@ -65,18 +65,6 @@ static inline uint32_t pack_float(float f)
return u.dw;
}
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = size;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
assert(create.handle);
return create.handle;
}
static uint64_t
gem_aperture_size(int fd)
{
......
......@@ -66,6 +66,7 @@
#include "xf86drm.h"
#include "xf86drmMode.h"
#include "i915_drm.h"
#include "drmtest.h"
#if defined(DRM_IOCTL_MODE_ADDFB2) && defined(DRM_I915_SET_SPRITE_COLORKEY)
#define TEST_PLANES 1
......@@ -383,17 +384,6 @@ static void connector_find_preferred_mode(struct connector *c)
c->connector = connector;
}
static uint32_t gem_create(int fd, int size)
{
struct drm_i915_gem_create create;
create.handle = 0;
create.size = (size + 4095) & -4096;
(void)drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
return create.handle;
}
static void *gem_mmap(int fd, uint32_t handle, int size, int prot)
{
struct drm_i915_gem_mmap_gtt mmap_arg;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment