[Mesa-dev] [PATCH 01/13] isl: Add func isl_tiling_from_drm_format_mod()
Chad Versace
chadversary at chromium.org
Mon Mar 6 20:40:10 UTC 2017
It converts a DRM format modifier to enum isl_tiling. That's all.
---
src/intel/isl/isl.c | 23 +++++++++++++++++++++++
src/intel/isl/isl.h | 3 +++
2 files changed, 26 insertions(+)
diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index ec8424cd48b..c70fac8a176 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -25,6 +25,8 @@
#include <stdarg.h>
#include <stdio.h>
+#include <drm_fourcc.h>
+
#include "isl.h"
#include "isl_gen4.h"
#include "isl_gen6.h"
@@ -33,6 +35,10 @@
#include "isl_gen9.h"
#include "isl_priv.h"
+#ifndef DRM_FORMAT_MOD_LINEAR
+#define DRM_FORMAT_MOD_LINEAR 0 /* Linux 4.10 */
+#endif
+
void PRINTFLIKE(3, 4) UNUSED
__isl_finishme(const char *file, int line, const char *fmt, ...)
{
@@ -60,6 +66,23 @@ static const struct {
[9] = {64, 64, 32, 40},
};
+enum isl_tiling
+isl_tiling_from_drm_format_mod(uint64_t mod)
+{
+ switch (mod) {
+ default:
+ unreachable("bad drm format modifier");
+ case DRM_FORMAT_MOD_LINEAR:
+ return ISL_TILING_LINEAR;
+ case I915_FORMAT_MOD_X_TILED:
+ return ISL_TILING_X;
+ case I915_FORMAT_MOD_Y_TILED:
+ return ISL_TILING_Y0;
+ case I915_FORMAT_MOD_Yf_TILED:
+ return ISL_TILING_Yf;
+ }
+}
+
void
isl_device_init(struct isl_device *dev,
const struct gen_device_info *info,
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index 4fcd416054d..597819f0a74 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1176,6 +1176,9 @@ bool
isl_has_matching_typed_storage_image_format(const struct gen_device_info *devinfo,
enum isl_format fmt);
+/** Behavior is undefined if isl does not recognize the modifier. */
+enum isl_tiling isl_tiling_from_drm_format_mod(uint64_t mod);
+
static inline bool
isl_tiling_is_any_y(enum isl_tiling tiling)
{
--
2.12.0
More information about the mesa-dev
mailing list