lib/drmtest: extract gem_read

Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Daniel Vetter 2012-01-10 15:37:53 +01:00
parent 319638ba6d
commit bd5cf9a07d
10 changed files with 20 additions and 105 deletions

View File

@ -156,3 +156,16 @@ void gem_write(int fd, uint32_t handle, uint32_t offset, const void *buf, uint32
assert(ret == 0);
}
void gem_read(int fd, uint32_t handle, uint32_t offset, void *buf, uint32_t length)
{
struct drm_i915_gem_pread gem_pread;
int ret;
gem_pread.handle = handle;
gem_pread.offset = offset;
gem_pread.size = length;
gem_pread.data_ptr = (uintptr_t)buf;
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &gem_pread);
assert(ret == 0);
}

View File

@ -40,3 +40,4 @@ int drm_open_any_master(void);
void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride);
void gem_close(int fd, uint32_t handle);
void gem_write(int fd, uint32_t handle, uint32_t offset, const void *buf, uint32_t size);
void gem_read(int fd, uint32_t handle, uint32_t offset, void *buf, uint32_t size);

View File

@ -72,19 +72,6 @@ static void *gem_mmap(int fd, uint32_t handle, int size, int prot)
return ptr;
}
static int gem_read(int fd,
uint32_t handle, uint32_t offset,
const void *src, int length)
{
struct drm_i915_gem_pread pread;
pread.handle = handle;
pread.offset = offset;
pread.size = length;
pread.data_ptr = (uintptr_t)src;
return drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &pread);
}
static double elapsed(const struct timeval *start,
const struct timeval *end,
int loop)

View File

@ -76,20 +76,6 @@ gem_aperture_size(int fd)
return aperture.aper_size;
}
static void
gem_read(int fd, uint32_t handle, int offset, int size, void *buf)
{
struct drm_i915_gem_pread pread;
int ret;
pread.handle = handle;
pread.offset = offset;
pread.size = size;
pread.data_ptr = (uintptr_t)buf;
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &pread);
assert(ret == 0);
}
static void
copy(int fd, uint32_t dst, uint32_t src)
{
@ -199,7 +185,7 @@ check_bo(int fd, uint32_t handle, uint32_t val)
{
int i;
gem_read(fd, handle, 0, sizeof(linear), linear);
gem_read(fd, handle, 0, linear, sizeof(linear));
for (i = 0; i < WIDTH*HEIGHT; i++) {
if (linear[i] != val) {
fprintf(stderr, "Expected 0x%08x, found 0x%08x "

View File

@ -55,22 +55,6 @@ static uint32_t gem_create(int fd, int size)
return create.handle;
}
static void gem_read(int fd,
uint32_t handle, uint32_t offset,
void *dst, int length)
{
struct drm_i915_gem_pread arg;
int ret;
arg.handle = handle;
arg.offset = offset;
arg.size = length;
arg.data_ptr = (uintptr_t)dst;
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &arg);
assert(ret == 0);
}
static void set_domain(int fd, uint32_t handle)
{
struct drm_i915_gem_set_domain set_domain;

View File

@ -72,20 +72,6 @@ gem_aperture_size(int fd)
return aperture.aper_size;
}
static void
gem_read(int fd, drm_intel_bo *bo, void *buf, int size)
{
struct drm_i915_gem_pread pread;
int ret;
pread.handle = bo->handle;
pread.offset = 0;
pread.size = size;
pread.data_ptr = (uintptr_t)buf;
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &pread);
assert(ret == 0);
}
static drm_intel_bo *
create_bo(int fd, uint32_t start_val)
{
@ -112,7 +98,7 @@ check_bo(int fd, drm_intel_bo *bo, uint32_t start_val)
{
int i;
gem_read(fd, bo, linear, sizeof(linear));
gem_read(fd, bo->handle, 0, linear, sizeof(linear));
for (i = 0; i < 1024 * 1024 / 4; i++) {
if (linear[i] != start_val) {

View File

@ -89,20 +89,6 @@ static void *gem_mmap(int fd, uint32_t handle, int size, int prot)
return ptr;
}
static void
gem_read(int fd, uint32_t handle, int offset, int length, void *buf)
{
struct drm_i915_gem_pread pread;
int ret;
pread.handle = handle;
pread.offset = offset;
pread.size = length;
pread.data_ptr = (uintptr_t)buf;
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &pread);
assert(ret == 0);
}
static void
gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle)
{
@ -213,7 +199,7 @@ main(int argc, char **argv)
len = size;
}
gem_read(fd, handle, offset, len, linear);
gem_read(fd, handle, offset, linear, len);
/* Translate from offsets in the read buffer to the swizzled
* address that it corresponds to. This is the opposite of

View File

@ -95,20 +95,6 @@ static void *gem_mmap(int fd, uint32_t handle, int size, int prot)
return ptr;
}
static void
gem_read(int fd, uint32_t handle, int offset, int length, void *buf)
{
struct drm_i915_gem_pread pread;
int ret;
pread.handle = handle;
pread.offset = offset;
pread.size = length;
pread.data_ptr = (uintptr_t)buf;
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &pread);
assert(ret == 0);
}
static void
gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle)
{
@ -175,7 +161,7 @@ main(int argc, char **argv)
handle = create_bo_and_fill(fd);
gem_get_tiling(fd, handle, &tiling, &swizzle);
gem_read(fd, handle, 0, sizeof(linear), linear);
gem_read(fd, handle, 0, linear, sizeof(linear));
handle_target = create_bo(fd);
gem_write(fd, handle_target, 0, linear, sizeof(linear));

View File

@ -269,7 +269,7 @@ check_cpu(uint32_t *ptr, uint32_t val)
static void
check_gpu(int fd, uint32_t handle, uint32_t val)
{
gem_read(fd, handle, 0, sizeof(linear), linear);
gem_read(fd, handle, 0, linear, sizeof(linear));
check_cpu(linear, val);
}

View File

@ -87,20 +87,6 @@ gem_aperture_size(int fd)
return aperture.aper_size;
}
static void
gem_read(int fd, uint32_t handle, int offset, int size, void *buf)
{
struct drm_i915_gem_pread pread;
int ret;
pread.handle = handle;
pread.offset = offset;
pread.size = size;
pread.data_ptr = (uintptr_t)buf;
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &pread);
assert(ret == 0);
}
static uint32_t fill_reloc(struct drm_i915_gem_relocation_entry *reloc,
uint32_t offset,
uint32_t handle,
@ -350,7 +336,7 @@ check_bo(int fd, uint32_t handle, uint32_t val)
{
int i;
gem_read(fd, handle, 0, sizeof(linear), linear);
gem_read(fd, handle, 0, linear, sizeof(linear));
for (i = 0; i < WIDTH*HEIGHT; i++) {
if (linear[i] != val) {
fprintf(stderr, "Expected 0x%08x, found 0x%08x "