lib/drmtest: extract gem_write

Astonishing how many different function signatures are possible for
something that simple.

Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Daniel Vetter
2012-01-10 15:31:11 +01:00
parent 5dd17d3f4b
commit 319638ba6d
19 changed files with 29 additions and 252 deletions
+2 -16
View File
@@ -76,20 +76,6 @@ gem_aperture_size(int fd)
return aperture.aper_size;
}
static void
gem_write(int fd, uint32_t handle, int offset, int size, const void *buf)
{
struct drm_i915_gem_pwrite pwrite;
int ret;
pwrite.handle = handle;
pwrite.offset = offset;
pwrite.size = size;
pwrite.data_ptr = (uintptr_t)buf;
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
assert(ret == 0);
}
static void
gem_read(int fd, uint32_t handle, int offset, int size, void *buf)
{
@@ -130,7 +116,7 @@ copy(int fd, uint32_t dst, uint32_t src)
batch[9] = MI_NOOP;
handle = gem_create(fd, 4096);
gem_write(fd, handle, 0, sizeof(batch), batch);
gem_write(fd, handle, 0, batch, sizeof(batch));
reloc[0].target_handle = dst;
reloc[0].delta = 0;
@@ -203,7 +189,7 @@ create_bo(int fd, uint32_t val)
/* Fill the BO with dwords starting at val */
for (i = 0; i < WIDTH*HEIGHT; i++)
linear[i] = val++;
gem_write(fd, handle, 0, sizeof(linear), linear);
gem_write(fd, handle, 0, linear, sizeof(linear));
return handle;
}