lib/drmtest: extract gem_set_tiling

Way too much copy-pasting going on here.

Also fix a compiler warnings in gem_stress while fixup things up.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Daniel Vetter
2012-01-10 14:59:58 +01:00
parent 1be3fd7eee
commit aa67b22e42
10 changed files with 39 additions and 149 deletions
+2 -17
View File
@@ -122,21 +122,6 @@ gem_read(int fd, uint32_t handle, int offset, int length, void *buf)
assert(ret == 0);
}
static void
gem_set_tiling(int fd, uint32_t handle, int tiling)
{
struct drm_i915_gem_set_tiling set_tiling;
int ret;
do {
set_tiling.handle = handle;
set_tiling.tiling_mode = tiling;
set_tiling.stride = WIDTH * sizeof(uint32_t);
ret = ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling);
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
}
static void
gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle)
{
@@ -161,7 +146,7 @@ create_bo_and_fill(int fd)
int i;
handle = gem_create(fd, sizeof(linear));
gem_set_tiling(fd, handle, current_tiling_mode);
gem_set_tiling(fd, handle, current_tiling_mode, WIDTH * sizeof(uint32_t));
/* Fill the BO with dwords starting at start_val */
data = gem_mmap(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE);
@@ -178,7 +163,7 @@ create_bo(int fd)
uint32_t handle;
handle = gem_create(fd, sizeof(linear));
gem_set_tiling(fd, handle, current_tiling_mode);
gem_set_tiling(fd, handle, current_tiling_mode, WIDTH * sizeof(uint32_t));
return handle;
}