summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-10-14 13:18:11 -0700
committerEric Anholt <eric@anholt.net>2008-10-14 13:23:04 -0700
commit993383873c215ab11975d98b93f131a4e3ea7ce6 (patch)
treef99889520b7b0127de0688f21a80d0780eea649c
parentd9c2f65dd8e50736a33e97a55c257ef6843e1ce7 (diff)
intel: Add interface for getting tiling mode of a bo.
-rw-r--r--libdrm/intel/intel_bufmgr.c10
-rw-r--r--libdrm/intel/intel_bufmgr.h2
-rw-r--r--libdrm/intel/intel_bufmgr_gem.c23
-rw-r--r--libdrm/intel/intel_bufmgr_priv.h9
4 files changed, 44 insertions, 0 deletions
diff --git a/libdrm/intel/intel_bufmgr.c b/libdrm/intel/intel_bufmgr.c
index fc7284b5..92b60467 100644
--- a/libdrm/intel/intel_bufmgr.c
+++ b/libdrm/intel/intel_bufmgr.c
@@ -192,3 +192,13 @@ int dri_bo_set_tiling(dri_bo *bo, uint32_t *tiling_mode)
*tiling_mode = I915_TILING_NONE;
return 0;
}
+
+int dri_bo_get_tiling(dri_bo *bo, uint32_t *tiling_mode, uint32_t *swizzle_mode)
+{
+ if (bo->bufmgr->bo_get_tiling)
+ return bo->bufmgr->bo_get_tiling(bo, tiling_mode, swizzle_mode);
+
+ *tiling_mode = I915_TILING_NONE;
+ *swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
+ return 0;
+}
diff --git a/libdrm/intel/intel_bufmgr.h b/libdrm/intel/intel_bufmgr.h
index c44d596b..0c7b0e47 100644
--- a/libdrm/intel/intel_bufmgr.h
+++ b/libdrm/intel/intel_bufmgr.h
@@ -87,6 +87,8 @@ int dri_bo_emit_reloc(dri_bo *reloc_buf,
int dri_bo_pin(dri_bo *buf, uint32_t alignment);
int dri_bo_unpin(dri_bo *buf);
int dri_bo_set_tiling(dri_bo *buf, uint32_t *tiling_mode);
+int dri_bo_get_tiling(dri_bo *buf, uint32_t *tiling_mode,
+ uint32_t *swizzle_mode);
int dri_bo_flink(dri_bo *buf, uint32_t *name);
/* intel_bufmgr_gem.c */
diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c
index 9bd44417..33853c4a 100644
--- a/libdrm/intel/intel_bufmgr_gem.c
+++ b/libdrm/intel/intel_bufmgr_gem.c
@@ -873,6 +873,28 @@ dri_gem_bo_set_tiling(dri_bo *bo, uint32_t *tiling_mode)
}
static int
+dri_gem_bo_get_tiling(dri_bo *bo, uint32_t *tiling_mode, uint32_t *swizzle_mode)
+{
+ dri_bufmgr_gem *bufmgr_gem = (dri_bufmgr_gem *)bo->bufmgr;
+ dri_bo_gem *bo_gem = (dri_bo_gem *)bo;
+ struct drm_i915_gem_get_tiling get_tiling;
+ int ret;
+
+ get_tiling.handle = bo_gem->gem_handle;
+
+ ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling);
+ if (ret != 0) {
+ *tiling_mode = I915_TILING_NONE;
+ *swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
+ return -errno;
+ }
+
+ *tiling_mode = get_tiling.tiling_mode;
+ *swizzle_mode = get_tiling.swizzle_mode;
+ return 0;
+}
+
+static int
dri_gem_bo_flink(dri_bo *bo, uint32_t *name)
{
dri_bufmgr_gem *bufmgr_gem = (dri_bufmgr_gem *)bo->bufmgr;
@@ -959,6 +981,7 @@ intel_bufmgr_gem_init(int fd, int batch_size)
bufmgr_gem->bufmgr.bo_emit_reloc = dri_gem_bo_emit_reloc;
bufmgr_gem->bufmgr.bo_pin = dri_gem_bo_pin;
bufmgr_gem->bufmgr.bo_unpin = dri_gem_bo_unpin;
+ bufmgr_gem->bufmgr.bo_get_tiling = dri_gem_bo_get_tiling;
bufmgr_gem->bufmgr.bo_set_tiling = dri_gem_bo_set_tiling;
bufmgr_gem->bufmgr.bo_flink = dri_gem_bo_flink;
bufmgr_gem->bufmgr.bo_exec = dri_gem_bo_exec;
diff --git a/libdrm/intel/intel_bufmgr_priv.h b/libdrm/intel/intel_bufmgr_priv.h
index 7f39bfc2..cbf3b311 100644
--- a/libdrm/intel/intel_bufmgr_priv.h
+++ b/libdrm/intel/intel_bufmgr_priv.h
@@ -150,6 +150,15 @@ struct _dri_bufmgr {
*/
int (*bo_set_tiling) (dri_bo *bo, uint32_t *tiling_mode);
/**
+ * Get the current tiling (and resulting swizzling) mode for the bo.
+ *
+ * \param buf Buffer to get tiling mode for
+ * \param tiling_mode returned tiling mode
+ * \param swizzle_mode returned swizzling mode
+ */
+ int (*bo_get_tiling) (dri_bo *bo, uint32_t *tiling_mode,
+ uint32_t *swizzle_mode);
+ /**
* Create a visible name for a buffer which can be used by other apps
*
* \param buf Buffer to create a name for