OSDN Git Service

minigbm: tweak cros-gralloc flags
authorGurchetan Singh <gurchetansingh@chromium.org>
Tue, 29 Nov 2016 22:45:46 +0000 (14:45 -0800)
committerchrome-bot <chrome-bot@chromium.org>
Fri, 9 Dec 2016 11:30:18 +0000 (03:30 -0800)
The Play Store wants a ABGR8888 HW cursor, and we can't in
general support this, so let's ignore the cursor flag rather
than fail the allocation.

We also interpret GRALLOC_USAGE_HW_COMPOSER as BO_USE_SCANOUT
| BO_USE_RENDERING. This fails with YV12, since we can't scanout
from it on Intel/Mediatek. Let's first try to allocate with the
scanout flag enabled and then fall-back to rendering if it's
not supported (i.e, first try overlay but then try OpenGL).

In addition, let's interpret GRALLOC_USAGE_HW_FB the same as
GRALLOC_USAGE_HW_COMPOSER since the framebuffer device
(Chrome in our case) wants to scanout but can also fall back.

BUG=chromium:616275
TEST=run cts --package com.drawelements.deqp.egl on minnie
CQ-DEPEND=CL:414536

Change-Id: I57cd681ca8ff0186698bd0a046c3a7b346f3e434
Reviewed-on: https://chromium-review.googlesource.com/414537
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
cros_gralloc/cros_alloc_device.cc
cros_gralloc/cros_gralloc_helpers.cc

index 7a8dff6..9f70dd4 100644 (file)
@@ -10,6 +10,7 @@ static struct cros_gralloc_bo *cros_gralloc_bo_create(struct driver *drv,
                                                      int width, int height,
                                                      int format, int usage)
 {
+       int32_t supported;
        uint64_t drv_usage;
        uint32_t drv_format;
        struct cros_gralloc_bo *bo;
@@ -18,11 +19,20 @@ static struct cros_gralloc_bo *cros_gralloc_bo_create(struct driver *drv,
        drv_format = drv_resolve_format(drv, drv_format);
        drv_usage = cros_gralloc_convert_flags(usage);
 
-       if (!drv_is_combination_supported(drv, drv_format, drv_usage,
-                                         DRM_FORMAT_MOD_NONE)) {
+       supported = drv_is_combination_supported(drv, drv_format, drv_usage,
+                                                DRM_FORMAT_MOD_NONE);
+
+       if (!supported && (drv_usage & BO_USE_SCANOUT)) {
+               drv_usage &= ~BO_USE_SCANOUT;
+               supported = drv_is_combination_supported(drv, drv_format,
+                                                        drv_usage,
+                                                        DRM_FORMAT_MOD_NONE);
+       }
+
+       if (!supported) {
                cros_gralloc_error("Unsupported combination -- HAL format: %u, "
-                                   "HAL flags: %u, drv_format: %u, "
-                                   "drv_flags: %llu", format, usage,
+                                  "HAL flags: %u, drv_format: %u, "
+                                  "drv_flags: %llu", format, usage,
                                    drv_format, drv_usage);
                return NULL;
        }
index 0b06ef0..e5304a1 100644 (file)
@@ -16,7 +16,7 @@ uint64_t cros_gralloc_convert_flags(int flags)
        uint64_t usage = BO_USE_NONE;
 
        if (flags & GRALLOC_USAGE_CURSOR)
-               usage |= BO_USE_CURSOR;
+               usage |= BO_USE_NONE;
        if ((flags & sw_read()) == GRALLOC_USAGE_SW_READ_RARELY)
                usage |= BO_USE_SW_READ_RARELY;
        if ((flags & sw_read()) == GRALLOC_USAGE_SW_READ_OFTEN)
@@ -35,7 +35,7 @@ uint64_t cros_gralloc_convert_flags(int flags)
        /* HWC wants to use display hardware, but can defer to OpenGL. */
                usage |= BO_USE_SCANOUT | BO_USE_RENDERING;
        if (flags & GRALLOC_USAGE_HW_FB)
-               usage |= BO_USE_SCANOUT;
+               usage |= BO_USE_SCANOUT | BO_USE_RENDERING;
        if (flags & GRALLOC_USAGE_EXTERNAL_DISP)
        /* We're ignoring this flag until we decide what to with display link */
                usage |= BO_USE_NONE;