[RFC v3 15/22] intel/isl: Add ISL tiling -> modifier conversion

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Wed Sep 27 05:28:45 UTC 2017


From: Daniel Stone <daniels at collabora.com>

Given a tiling mode and an aux usage, return the DRM modifier.

Signed-off-by: Daniel Stone <daniels at collabora.com>
---
 src/intel/isl/isl.h     |  6 +++++-
 src/intel/isl/isl_drm.c | 17 +++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index df275f85c4..d30b2deb16 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1546,7 +1546,7 @@ isl_tiling_is_std_y(enum isl_tiling tiling)
 uint32_t
 isl_tiling_to_i915_tiling(enum isl_tiling tiling);
 
-enum isl_tiling 
+enum isl_tiling
 isl_tiling_from_i915_tiling(uint32_t tiling);
 
 const struct isl_drm_modifier_info * ATTRIBUTE_CONST
@@ -1578,6 +1578,10 @@ isl_drm_modifier_get_default_aux_state(uint64_t modifier)
                                            ISL_AUX_STATE_COMPRESSED_NO_CLEAR;
 }
 
+uint64_t ATTRIBUTE_CONST
+isl_drm_modifier_from_tiling(enum isl_tiling tiling,
+                             enum isl_aux_usage aux_usage);
+
 struct isl_extent2d ATTRIBUTE_CONST
 isl_get_interleaved_msaa_px_size_sa(uint32_t samples);
 
diff --git a/src/intel/isl/isl_drm.c b/src/intel/isl/isl_drm.c
index eb3c6f5913..a40142c6ec 100644
--- a/src/intel/isl/isl_drm.c
+++ b/src/intel/isl/isl_drm.c
@@ -30,6 +30,10 @@
 #include "isl.h"
 #include "common/gen_device_info.h"
 
+#ifndef DRM_FORMAT_MOD_INVALID
+#define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1)
+#endif
+
 uint32_t
 isl_tiling_to_i915_tiling(enum isl_tiling tiling)
 {
@@ -106,3 +110,16 @@ isl_drm_modifier_get_info(uint64_t modifier)
 
    return NULL;
 }
+
+uint64_t
+isl_drm_modifier_from_tiling(enum isl_tiling tiling,
+                             enum isl_aux_usage aux_usage)
+{
+   for (unsigned i = 0; i < ARRAY_SIZE(modifier_info); i++) {
+      if (modifier_info[i].tiling == tiling &&
+          modifier_info[i].aux_usage == aux_usage)
+         return modifier_info[i].modifier;
+   }
+
+   return DRM_FORMAT_MOD_INVALID;
+}
-- 
2.13.0



More information about the xorg-devel mailing list