OSDN Git Service

Add GBM_BO_USE_HW_VIDEO_ENCODER use flag
authorHirokazu Honda <hiroh@chromium.org>
Wed, 31 Jul 2019 07:35:52 +0000 (16:35 +0900)
committerchrome-bot <chrome-bot@chromium.org>
Fri, 16 Aug 2019 19:40:30 +0000 (12:40 -0700)
Chrome needs to allocate a linear buffer that a hardware video encoder can read
and cpu can read and write. There is no use flag in gbm that specifies the
former. This CL introduces a new use flag for that.

BUG=b:138703716
TEST=None

Change-Id: Ied0321914a366294a47e4fc5c2a8f08ee0351bd8
Reviewed-on: https://chromium-review.googlesource.com/1728729
Tested-by: Hirokazu Honda <hiroh@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>
amdgpu.c
gbm.h
gbm_helpers.c
i915.c
mediatek.c
msm.c
rockchip.c

index 8e578df..65dd864 100644 (file)
--- a/amdgpu.c
+++ b/amdgpu.c
@@ -37,9 +37,9 @@ const static uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMA
                                                  DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
                                                  DRM_FORMAT_XRGB8888 };
 
-const static uint32_t texture_source_formats[] = { DRM_FORMAT_GR88, DRM_FORMAT_R8, DRM_FORMAT_NV21,
-                                                  DRM_FORMAT_NV12, DRM_FORMAT_YVU420_ANDROID,
-                                                  DRM_FORMAT_YVU420 };
+const static uint32_t texture_source_formats[] = { DRM_FORMAT_GR88,          DRM_FORMAT_R8,
+                                                  DRM_FORMAT_NV21,           DRM_FORMAT_NV12,
+                                                  DRM_FORMAT_YVU420_ANDROID, DRM_FORMAT_YVU420 };
 
 static int amdgpu_init(struct driver *drv)
 {
@@ -79,6 +79,13 @@ static int amdgpu_init(struct driver *drv)
        drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
                             &metadata, BO_USE_TEXTURE_MASK);
 
+       /*
+        * Chrome uses DMA-buf mmap to write to YV12 buffers, which are then accessed by the
+        * 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);
+
        /* Android CTS tests require this. */
        drv_add_combination(drv, DRM_FORMAT_BGR888, &metadata, BO_USE_SW_MASK);
 
diff --git a/gbm.h b/gbm.h
index 6150530..a2f10f6 100644 (file)
--- a/gbm.h
+++ b/gbm.h
@@ -273,6 +273,10 @@ enum gbm_bo_flags {
     * The buffer will be written by a video decode accelerator.
     */
    GBM_BO_USE_HW_VIDEO_DECODER = (1 << 13),
+   /**
+    * The buffer will be read by a video encode accelerator.
+    */
+   GBM_BO_USE_HW_VIDEO_ENCODER = (1 << 14),
 };
 
 int
index 81d1680..0626a6d 100644 (file)
@@ -42,6 +42,8 @@ uint64_t gbm_convert_usage(uint32_t usage)
                use_flags |= BO_USE_SW_WRITE_RARELY;
        if (usage & GBM_BO_USE_HW_VIDEO_DECODER)
                use_flags |= BO_USE_HW_VIDEO_DECODER;
+       if (usage & GBM_BO_USE_HW_VIDEO_ENCODER)
+               use_flags |= BO_USE_HW_VIDEO_ENCODER;
 
        return use_flags;
 }
diff --git a/i915.c b/i915.c
index 6a36ae9..44f08f8 100644 (file)
--- a/i915.c
+++ b/i915.c
@@ -138,6 +138,13 @@ static int i915_add_combinations(struct driver *drv)
                             ARRAY_SIZE(tileable_texture_source_formats), &metadata,
                             texture_use_flags);
 
+       /*
+        * Chrome uses DMA-buf mmap to write to YV12 buffers, which are then accessed by the
+        * 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);
+
        /* Android CTS tests require this. */
        drv_add_combination(drv, DRM_FORMAT_BGR888, &metadata, BO_USE_SW_MASK);
 
index 8842850..fd0c126 100644 (file)
@@ -53,6 +53,13 @@ static int mediatek_init(struct driver *drv)
        drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
                             &LINEAR_METADATA, BO_USE_TEXTURE_MASK);
 
+       /*
+        * Chrome uses DMA-buf mmap to write to YV12 buffers, which are then accessed by the
+        * Video Encoder Accelerator (VEA). It could also support NV12 potentially in the future.
+        */
+       drv_modify_combination(drv, DRM_FORMAT_YVU420, &LINEAR_METADATA, BO_USE_HW_VIDEO_ENCODER);
+       drv_modify_combination(drv, DRM_FORMAT_NV12, &LINEAR_METADATA, BO_USE_HW_VIDEO_ENCODER);
+
        /* Android CTS tests require this. */
        drv_add_combination(drv, DRM_FORMAT_BGR888, &LINEAR_METADATA, BO_USE_SW_MASK);
 
diff --git a/msm.c b/msm.c
index 268e6d3..a8df000 100644 (file)
--- a/msm.c
+++ b/msm.c
@@ -166,6 +166,13 @@ static int msm_init(struct driver *drv)
        drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
                             &LINEAR_METADATA, texture_use_flags);
 
+       /*
+        * Chrome uses DMA-buf mmap to write to YV12 buffers, which are then accessed by the
+        * Video Encoder Accelerator (VEA). It could also support NV12 potentially in the future.
+        */
+       drv_modify_combination(drv, DRM_FORMAT_YVU420, &LINEAR_METADATA, BO_USE_HW_VIDEO_ENCODER);
+       drv_modify_combination(drv, DRM_FORMAT_NV12, &LINEAR_METADATA, BO_USE_HW_VIDEO_ENCODER);
+
        /* Android CTS tests require this. */
        drv_add_combination(drv, DRM_FORMAT_BGR888, &LINEAR_METADATA, BO_USE_SW_MASK);
 
index 840b37a..a1685af 100644 (file)
@@ -121,6 +121,13 @@ static int rockchip_init(struct driver *drv)
        drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
                             &metadata, BO_USE_TEXTURE_MASK);
 
+       /*
+        * Chrome uses DMA-buf mmap to write to YV12 buffers, which are then accessed by the
+        * 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_XRGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
        drv_modify_combination(drv, DRM_FORMAT_ARGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);