OSDN Git Service

i915: Allow allocating ARGB buffers for scanout
authorKristian H. Kristensen <hoegsberg@chromium.org>
Wed, 11 Apr 2018 22:55:13 +0000 (15:55 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Thu, 12 Apr 2018 22:22:34 +0000 (15:22 -0700)
CL:991261 changed our primary framebuffer format from XRGB to ARGB. We
still only scanout as XRGB where the display controller doesn't
support ARGB, but minigbm doesn't know that. As a result, when we try
to allocate an ARGB buffer with the SCANOUT useflag, we get a linear
buffer.  This breaks PSR and regresses performance and, in general,
just isn't what we want.

This CL enables SCANOUT for all ARGB formats where the corresponding
XRGB formats supports scanout. In the end, it's up to the caller to
make sure a format works for scanout anyway.

BUG=827188,830969
TEST=test_that graphics_Idle on samus

Change-Id: Iab428e5b21abedcac7cee86fccc8df50dab3f471
Reviewed-on: https://chromium-review.googlesource.com/1008867
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
i915.c

diff --git a/i915.c b/i915.c
index cf5a7fd..fc877cb 100644 (file)
--- a/i915.c
+++ b/i915.c
@@ -8,6 +8,7 @@
 
 #include <errno.h>
 #include <i915_drm.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/mman.h>
@@ -49,6 +50,31 @@ static uint32_t i915_get_gen(int device_id)
        return 4;
 }
 
+/*
+ * We allow allocation of ARGB formats for SCANOUT if the corresponding XRGB
+ * formats supports it. It's up to the caller (chrome ozone) to ultimately not
+ * scan out ARGB if the display controller only supports XRGB, but we'll allow
+ * the allocation of the bo here.
+ */
+static bool format_compatible(const struct combination *combo, uint32_t format)
+{
+       if (combo->format == format)
+               return true;
+
+       switch (format) {
+       case DRM_FORMAT_XRGB8888:
+               return combo->format == DRM_FORMAT_ARGB8888;
+       case DRM_FORMAT_XBGR8888:
+               return combo->format == DRM_FORMAT_ABGR8888;
+       case DRM_FORMAT_RGBX8888:
+               return combo->format == DRM_FORMAT_RGBA8888;
+       case DRM_FORMAT_BGRX8888:
+               return combo->format == DRM_FORMAT_BGRA8888;
+       default:
+               return false;
+       }
+}
+
 static int i915_add_kms_item(struct driver *drv, const struct kms_item *item)
 {
        uint32_t i;
@@ -60,7 +86,7 @@ static int i915_add_kms_item(struct driver *drv, const struct kms_item *item)
         */
        for (i = 0; i < drv_array_size(drv->combos); i++) {
                combo = (struct combination *)drv_array_at_idx(drv->combos, i);
-               if (combo->format != item->format)
+               if (!format_compatible(combo, item->format))
                        continue;
 
                if (item->modifier == DRM_FORMAT_MOD_LINEAR &&