lib/drmtest: extract gem_mmap

Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Daniel Vetter
2012-01-10 18:41:46 +01:00
parent 7a6042e87e
commit 527cad1618
12 changed files with 28 additions and 164 deletions
+17
View File
@@ -30,6 +30,7 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <string.h>
#include <sys/mman.h>
#include "drmtest.h"
#include "i915_drm.h"
#include "intel_chipset.h"
@@ -202,3 +203,19 @@ uint32_t gem_create(int fd, int size)
return create.handle;
}
void *gem_mmap(int fd, uint32_t handle, int size, int prot)
{
struct drm_i915_gem_mmap_gtt mmap_arg;
void *ptr;
mmap_arg.handle = handle;
if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg))
return NULL;
ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset);
if (ptr == MAP_FAILED)
ptr = NULL;
return ptr;
}
+1
View File
@@ -45,3 +45,4 @@ 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);
void *gem_mmap(int fd, uint32_t handle, int size, int prot);