From d30c0a508a15eb6c61ec1657f4b4a27f21f01fc5 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Wed, 5 Jul 2017 17:50:18 +0900 Subject: [PATCH] minigbm: i915: Add support for buffers required by new camera subsystem 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 Tested-by: Tomasz Figa Reviewed-by: Gurchetan Singh --- i915.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/i915.c b/i915.c index 2f99ce5..b2520a8 100644 --- 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; -- 2.11.0