OSDN Git Service

minigbm: i915: Add support for buffers required by new camera subsystem
authorTomasz Figa <tfiga@chromium.org>
Wed, 5 Jul 2017 08:50:18 +0000 (17:50 +0900)
committerchrome-bot <chrome-bot@chromium.org>
Tue, 11 Jul 2017 07:38:59 +0000 (00:38 -0700)
The new camera subsystem on ChromeOS (introduced with selected KBL
boards) requires following Android pixel formats to be supported:
 - HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
 - HAL_PIXEL_FORMAT_YCbCr_420_888,
 - HAL_PIXEL_FORMAT_BLOB (JPEG binary data).

The first two need to map to DRM_FORMAT_NV12, if used with camera, so
adjust .resolve_format() callback to choose this format when camera
usage bits are specified. Also add respective combinations.

The last one is used specifically for JPEG binary data and the
cros_gralloc layer maps it into DRM_FORMAT_R8, so we need to add it to
the list of combinations for camera usage.

Note that the new usage flags are used only be the new camera subsystem
and do not affect existing boards. They will be migrated later, with the
initial objective to support NV12, so the combinations should remain
valid.

BUG=b:37615277
TEST=Camera preview renders correctly on Poppy.

Change-Id: Ib1081374ed82df9ae1cf543d85a2f5c50ff23371
Reviewed-on: https://chromium-review.googlesource.com/559315
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
i915.c

diff --git a/i915.c b/i915.c
index 2f99ce5..b2520a8 100644 (file)
--- a/i915.c
+++ b/i915.c
@@ -114,6 +114,16 @@ static int i915_add_combinations(struct driver *drv)
        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);
 
+       /* IPU3 camera ISP supports only NV12 output. */
+       drv_modify_combination(drv, DRM_FORMAT_NV12, &metadata,
+                              BO_USE_HW_CAMERA_READ | BO_USE_HW_CAMERA_WRITE);
+       /*
+        * R8 format is used for Android's HAL_PIXEL_FORMAT_BLOB and is used for JPEG snapshots
+        * from camera.
+        */
+       drv_modify_combination(drv, DRM_FORMAT_R8, &metadata,
+                              BO_USE_HW_CAMERA_READ | BO_USE_HW_CAMERA_WRITE);
+
        render_flags &= ~BO_USE_SW_WRITE_OFTEN;
        render_flags &= ~BO_USE_SW_READ_OFTEN;
        render_flags &= ~BO_USE_LINEAR;
@@ -435,9 +445,15 @@ static uint32_t i915_resolve_format(uint32_t format, uint64_t usage)
 {
        switch (format) {
        case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED:
+               /* KBL camera subsystem requires NV12. */
+               if (usage & (BO_USE_HW_CAMERA_READ | BO_USE_HW_CAMERA_WRITE))
+                       return DRM_FORMAT_NV12;
                /*HACK: See b/28671744 */
                return DRM_FORMAT_XBGR8888;
        case DRM_FORMAT_FLEX_YCbCr_420_888:
+               /* KBL camera subsystem requires NV12. */
+               if (usage & (BO_USE_HW_CAMERA_READ | BO_USE_HW_CAMERA_WRITE))
+                       return DRM_FORMAT_NV12;
                return DRM_FORMAT_YVU420;
        default:
                return format;