lib/drmtest: extract gem_create

Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Daniel Vetter 2012-01-10 18:29:30 +01:00
parent 73d1b88129
commit 7a6042e87e
19 changed files with 19 additions and 190 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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,

View File

@ -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,

View File

@ -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)

View File

@ -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;

View File

@ -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)
{

View File

@ -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);

View File

@ -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--)

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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;