From 9c3fb32dd4a8b9a3cf870c533d1e88dd542d7c16 Mon Sep 17 00:00:00 2001 From: "Kristian H. Kristensen" Date: Wed, 11 Apr 2018 15:55:13 -0700 Subject: [PATCH] i915: Allow allocating ARGB buffers for scanout MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Tested-by: Kristian H. Kristensen Reviewed-by: Stéphane Marchesin Reviewed-by: Gurchetan Singh --- i915.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/i915.c b/i915.c index cf5a7fd..fc877cb 100644 --- a/i915.c +++ b/i915.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -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 && -- 2.11.0