drm/i915: Add tiling attribute to the modifier descriptor
authorImre Deak <imre.deak@intel.com>
Wed, 20 Oct 2021 19:51:30 +0000 (22:51 +0300)
committerImre Deak <imre.deak@intel.com>
Thu, 21 Oct 2021 18:44:36 +0000 (21:44 +0300)
Add a tiling atttribute to the modifier descriptor, which let's us
get the tiling without listing the modifiers twice.

v1-v2: Unchanged.
v3:
- Initialize .tiling to I915_TILING_NONE explicitly (Ville)
- Move from previous patch lookup_modifier() to here, where it's first
  used.

Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211020195138.1841242-4-imre.deak@intel.com
drivers/gpu/drm/i915/display/intel_fb.c

index 42919d2..0355a73 100644 (file)
@@ -120,6 +120,7 @@ struct intel_modifier_desc {
        .formats = format_list, \
        .format_count = ARRAY_SIZE(format_list)
 
+       u8 tiling;
        u8 is_linear:1;
 
        struct {
@@ -136,6 +137,7 @@ static const struct intel_modifier_desc intel_modifiers[] = {
        {
                .modifier = I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS,
                .display_ver = { 12, 13 },
+               .tiling = I915_TILING_Y,
 
                .ccs.type = INTEL_CCS_MC,
 
@@ -143,6 +145,7 @@ static const struct intel_modifier_desc intel_modifiers[] = {
        }, {
                .modifier = I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS,
                .display_ver = { 12, 13 },
+               .tiling = I915_TILING_Y,
 
                .ccs.type = INTEL_CCS_RC,
 
@@ -150,6 +153,7 @@ static const struct intel_modifier_desc intel_modifiers[] = {
        }, {
                .modifier = I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC,
                .display_ver = { 12, 13 },
+               .tiling = I915_TILING_Y,
 
                .ccs.type = INTEL_CCS_RC_CC,
 
@@ -157,6 +161,7 @@ static const struct intel_modifier_desc intel_modifiers[] = {
        }, {
                .modifier = I915_FORMAT_MOD_Yf_TILED_CCS,
                .display_ver = { 9, 11 },
+               .tiling = I915_TILING_NONE,
 
                .ccs.type = INTEL_CCS_RC,
 
@@ -164,6 +169,7 @@ static const struct intel_modifier_desc intel_modifiers[] = {
        }, {
                .modifier = I915_FORMAT_MOD_Y_TILED_CCS,
                .display_ver = { 9, 11 },
+               .tiling = I915_TILING_Y,
 
                .ccs.type = INTEL_CCS_RC,
 
@@ -171,15 +177,19 @@ static const struct intel_modifier_desc intel_modifiers[] = {
        }, {
                .modifier = I915_FORMAT_MOD_Yf_TILED,
                .display_ver = { 9, 11 },
+               .tiling = I915_TILING_NONE,
        }, {
                .modifier = I915_FORMAT_MOD_Y_TILED,
                .display_ver = { 9, 13 },
+               .tiling = I915_TILING_Y,
        }, {
                .modifier = I915_FORMAT_MOD_X_TILED,
                .display_ver = DISPLAY_VER_ALL,
+               .tiling = I915_TILING_X,
        }, {
                .modifier = DRM_FORMAT_MOD_LINEAR,
                .display_ver = DISPLAY_VER_ALL,
+               .tiling = I915_TILING_NONE,
 
                .is_linear = true,
        },
@@ -196,6 +206,16 @@ static const struct intel_modifier_desc *lookup_modifier_or_null(u64 modifier)
        return NULL;
 }
 
+static const struct intel_modifier_desc *lookup_modifier(u64 modifier)
+{
+       const struct intel_modifier_desc *md = lookup_modifier_or_null(modifier);
+
+       if (WARN_ON(!md))
+               return &intel_modifiers[0];
+
+       return md;
+}
+
 static const struct drm_format_info *
 lookup_format_info(const struct drm_format_info formats[],
                   int num_formats, u32 format)
@@ -520,18 +540,7 @@ intel_fb_align_height(const struct drm_framebuffer *fb,
 
 static unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier)
 {
-       switch (fb_modifier) {
-       case I915_FORMAT_MOD_X_TILED:
-               return I915_TILING_X;
-       case I915_FORMAT_MOD_Y_TILED:
-       case I915_FORMAT_MOD_Y_TILED_CCS:
-       case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS:
-       case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC:
-       case I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS:
-               return I915_TILING_Y;
-       default:
-               return I915_TILING_NONE;
-       }
+       return lookup_modifier(fb_modifier)->tiling;
 }
 
 unsigned int intel_cursor_alignment(const struct drm_i915_private *i915)