OSDN Git Service

minigbm: i915: Fix handling of format modifiers
authorTomasz Figa <tfiga@chromium.org>
Sat, 8 Jul 2017 06:53:11 +0000 (15:53 +0900)
committerchrome-bot <chrome-bot@chromium.org>
Mon, 10 Jul 2017 22:27:27 +0000 (15:27 -0700)
As of today, drv_query_kms() does not report available format modifiers
and all returned items have DRM_FORMAT_MOD_NONE. The i915 backend has
a hack that adds KMS usage flags to X-tiled combinations even for items
without a modifier. However it is incorrect, as it adds cursor usage
flag, even though it isn't supported. On top of that, it is written in
a very convoluted way that hides the original problem.

Make i915_add_combinations() always set metadata.modifier (since we
already have the knowledge about mapping between I915 modifiers and
tiling modes) and use it to match combinations with KMS items. Add an
explicit special case for DRM_FORMAT_MOD_NONE and I915_TILING_X, which
adds KMS usage flags (other than cursor) to matched combinations.

BUG=b:37615277
TEST=test_that reef graphics_Drm.bvt

Change-Id: Ia7573a330ccc35c3d9868ba1aa45d73bda2f691b
Reviewed-on: https://chromium-review.googlesource.com/564187
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
i915.c

diff --git a/i915.c b/i915.c
index 1fd0dc4..adf2739 100644 (file)
--- a/i915.c
+++ b/i915.c
@@ -59,17 +59,22 @@ static int i915_add_kms_item(struct driver *drv, const struct kms_item *item)
         */
        for (i = 0; i < drv->backend->combos.size; i++) {
                combo = &drv->backend->combos.data[i];
-               if (combo->format == item->format) {
-                       if ((combo->metadata.tiling == I915_TILING_Y &&
-                            item->modifier == I915_FORMAT_MOD_Y_TILED) ||
-                           (combo->metadata.tiling == I915_TILING_X &&
-                            item->modifier == I915_FORMAT_MOD_X_TILED)) {
-                               combo->metadata.modifier = item->modifier;
-                               combo->usage |= item->usage;
-                       } else if (combo->metadata.tiling != I915_TILING_Y) {
-                               combo->usage |= item->usage;
-                       }
+               if (combo->format != item->format)
+                       continue;
+
+               if (item->modifier == DRM_FORMAT_MOD_NONE &&
+                   combo->metadata.tiling == I915_TILING_X) {
+                       /*
+                        * FIXME: drv_query_kms() does not report the available modifiers
+                        * yet, but we know that all hardware can scanout from X-tiled
+                        * buffers, so let's add this to our combinations, except for
+                        * cursor, which must not be tiled.
+                        */
+                       combo->usage |= item->usage & ~BO_USE_CURSOR;
                }
+
+               if (combo->metadata.modifier == item->modifier)
+                       combo->usage |= item->usage;
        }
 
        return 0;
@@ -119,6 +124,7 @@ static int i915_add_combinations(struct driver *drv)
 
        metadata.tiling = I915_TILING_X;
        metadata.priority = 2;
+       metadata.modifier = I915_FORMAT_MOD_X_TILED;
 
        ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
                                   &metadata, render_flags);
@@ -133,6 +139,7 @@ static int i915_add_combinations(struct driver *drv)
 
        metadata.tiling = I915_TILING_Y;
        metadata.priority = 3;
+       metadata.modifier = I915_FORMAT_MOD_Y_TILED;
 
        ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
                                   &metadata, render_flags);