OSDN Git Service

minigbm: cros_gralloc: handle video decoder flag
authorDavid Stevens <stevensd@chromium.org>
Tue, 3 Sep 2019 01:49:50 +0000 (10:49 +0900)
committerchrome-bot <chrome-bot@chromium.org>
Sat, 21 Sep 2019 02:28:02 +0000 (19:28 -0700)
Although gralloc0 doesn't include a video decoder flag, the IAllocator
gralloc0 passthrough gives the lower 32 bits of the BufferUsage flags
to gralloc0. This change makes cros_gralloc add the video decoder BO_USE
flag when that happens. It also adds some missing combinations for when
the BO_USE_HW_VIDEO_DECODER flag is actually set.

Change-Id: If2248f33ac2456c077fe63e90d2c39e7f57e2568
Reviewed-on: https://chromium-review.googlesource.com/1786419
Tested-by: David Stevens <stevensd@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
cros_gralloc/gralloc0/gralloc0.cc
i915.c
virtio_gpu.c

index df1f62c..eef5d2f 100644 (file)
@@ -33,6 +33,11 @@ enum {
 };
 // clang-format on
 
+// Gralloc0 doesn't define a video decoder flag. However, the IAllocator gralloc0
+// passthrough gives the low 32-bits of the BufferUsage flags to gralloc0 in their
+// entirety, so we can detect the video decoder flag passed by IAllocator clients.
+#define BUFFER_USAGE_VIDEO_DECODER (1 << 22)
+
 static uint64_t gralloc0_convert_usage(int usage)
 {
        uint64_t use_flags = BO_USE_NONE;
@@ -75,6 +80,8 @@ static uint64_t gralloc0_convert_usage(int usage)
                use_flags |= BO_USE_CAMERA_READ;
        if (usage & GRALLOC_USAGE_RENDERSCRIPT)
                use_flags |= BO_USE_RENDERSCRIPT;
+       if (usage & BUFFER_USAGE_VIDEO_DECODER)
+               use_flags |= BO_USE_HW_VIDEO_DECODER;
 
        return use_flags;
 }
diff --git a/i915.c b/i915.c
index 3639eaa..ff5c66d 100644 (file)
--- a/i915.c
+++ b/i915.c
@@ -144,7 +144,8 @@ static int i915_add_combinations(struct driver *drv)
         * Video Encoder Accelerator (VEA). It could also support NV12 potentially in the future.
         */
        drv_modify_combination(drv, DRM_FORMAT_YVU420, &metadata, BO_USE_HW_VIDEO_ENCODER);
-       drv_modify_combination(drv, DRM_FORMAT_NV12, &metadata, BO_USE_HW_VIDEO_ENCODER);
+       drv_modify_combination(drv, DRM_FORMAT_NV12, &metadata,
+                              BO_USE_HW_VIDEO_ENCODER | BO_USE_HW_VIDEO_DECODER);
 
        /* Android CTS tests require this. */
        drv_add_combination(drv, DRM_FORMAT_BGR888, &metadata, BO_USE_SW_MASK);
index 0c94eaf..e3fd174 100644 (file)
@@ -205,7 +205,7 @@ static int virtio_gpu_init(struct driver *drv)
        drv_add_combination(drv, DRM_FORMAT_BGR888, &LINEAR_METADATA, BO_USE_SW_MASK);
 
        drv_modify_combination(drv, DRM_FORMAT_NV12, &LINEAR_METADATA,
-                              BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE);
+                              BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_HW_VIDEO_DECODER);
        drv_modify_combination(drv, DRM_FORMAT_R8, &LINEAR_METADATA,
                               BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE);