[PATCH i-g-t] lib: Extract gem_get_tiling() from a couple of tests.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Damien Lespiau <damien.lespiau@xxxxxxxxx>
---
 lib/ioctl_wrappers.c           | 25 +++++++++++++++++++++++++
 lib/ioctl_wrappers.h           |  1 +
 tests/gem_tiled_pread.c        | 16 ----------------
 tests/gem_tiled_pread_pwrite.c | 16 ----------------
 4 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index af63be3..67351af 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -108,6 +108,31 @@ gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd, const char *name, uint
 	return bo;
 }
 
+/**
+ * gem_get_tiling:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @tiling: (out) tiling mode of the gem buffer
+ * @swizzle: (out) bit 6 swizzle mode
+ *
+ * This wraps the GET_TILING ioctl.
+ */
+void
+gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle)
+{
+	struct drm_i915_gem_get_tiling get_tiling;
+	int ret;
+
+	memset(&get_tiling, 0, sizeof(get_tiling));
+	get_tiling.handle = handle;
+
+	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling);
+	igt_assert(ret == 0);
+
+	*tiling = get_tiling.tiling_mode;
+	*swizzle = get_tiling.swizzle_mode;
+}
+
 int __gem_set_tiling(int fd, uint32_t handle, uint32_t tiling, uint32_t stride)
 {
 	struct drm_i915_gem_set_tiling st;
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 8ca2181..310d82e 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -42,6 +42,7 @@ drm_intel_bo * gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd,
 /* ioctl_wrappers.c:
  *
  * ioctl wrappers and similar stuff for bare metal testing */
+void gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle);
 void gem_set_tiling(int fd, uint32_t handle, uint32_t tiling, uint32_t stride);
 int __gem_set_tiling(int fd, uint32_t handle, uint32_t tiling, uint32_t stride);
 
diff --git a/tests/gem_tiled_pread.c b/tests/gem_tiled_pread.c
index 4815b72..d99b4ea 100644
--- a/tests/gem_tiled_pread.c
+++ b/tests/gem_tiled_pread.c
@@ -60,22 +60,6 @@ static int tile_width;
 static int tile_height;
 static int tile_size;
 
-static void
-gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle)
-{
-	struct drm_i915_gem_get_tiling get_tiling;
-	int ret;
-
-	memset(&get_tiling, 0, sizeof(get_tiling));
-	get_tiling.handle = handle;
-
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling);
-	igt_assert(ret == 0);
-
-	*tiling = get_tiling.tiling_mode;
-	*swizzle = get_tiling.swizzle_mode;
-}
-
 static uint32_t
 create_bo(int fd)
 {
diff --git a/tests/gem_tiled_pread_pwrite.c b/tests/gem_tiled_pread_pwrite.c
index b6d9d62..5ab4678 100644
--- a/tests/gem_tiled_pread_pwrite.c
+++ b/tests/gem_tiled_pread_pwrite.c
@@ -68,22 +68,6 @@ static uint32_t current_tiling_mode;
 
 #define PAGE_SIZE 4096
 
-static void
-gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle)
-{
-	struct drm_i915_gem_get_tiling get_tiling;
-	int ret;
-
-	memset(&get_tiling, 0, sizeof(get_tiling));
-	get_tiling.handle = handle;
-
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling);
-	igt_assert(ret == 0);
-
-	*tiling = get_tiling.tiling_mode;
-	*swizzle = get_tiling.swizzle_mode;
-}
-
 static uint32_t
 create_bo_and_fill(int fd)
 {
-- 
1.8.3.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux