gralloc: Add support to getFormatLayout HAL API.
- Add API getFormatLayout which is required by camera
team to get information of all the planes present
during YUV format call.
- Refactor the function GetYUVPlaneInfo to give some
extra information of YUV plane.
CRs-Fixed: 2464961
Change-Id: Ib84fd340f8c8926867a6f7e2ec7c0074c4dada06
diff --git a/gralloc/QtiMapperExtensions.cpp b/gralloc/QtiMapperExtensions.cpp
index 56b747b..cace7ba 100644
--- a/gralloc/QtiMapperExtensions.cpp
+++ b/gralloc/QtiMapperExtensions.cpp
@@ -342,11 +342,46 @@
Return<void> QtiMapperExtensions::getFormatLayout(int32_t format, uint64_t usage, int32_t flags,
int32_t width, int32_t height,
getFormatLayout_cb hidl_cb) {
- ALOGD_IF(DEBUG, "%s: Input parameters - wxh: %dx%d usage: 0x%" PRIu64 " format: %d flags: %d",
- __FUNCTION__, width, height, usage, format, flags);
- auto err = Error::NONE;
+ ALOGD_IF(DEBUG, "%s: Input parameters - wxh: %dx%d usage: 0x%" PRIu64 " format: %d", __FUNCTION__,
+ width, height, usage, format);
+ auto err = Error::BAD_BUFFER;
hidl_vec<PlaneLayout> plane_info;
+ unsigned int alignedw = 0, alignedh = 0;
+ int plane_count = 0;
uint64_t size = 0;
+ int custom_format = gralloc::GetImplDefinedFormat(usage, format);
+ BufferInfo info(width, height, custom_format, usage);
+ gralloc::GetAlignedWidthAndHeight(info, &alignedw, &alignedh);
+ size = gralloc::GetSize(info, alignedw, alignedh);
+ ALOGD_IF(DEBUG, "%s: Aligned width and height - wxh: %ux%u custom_format = %d", __FUNCTION__,
+ alignedw, alignedh, custom_format);
+ if (gralloc::IsYuvFormat(custom_format)) {
+ gralloc::PlaneLayoutInfo yuv_plane_info[8] = {};
+ gralloc::GetYUVPlaneInfo(info, custom_format, alignedw, alignedh, flags, &plane_count,
+ yuv_plane_info);
+ ALOGD_IF(DEBUG, "%s: Number of plane - %d, custom_format - %d", __FUNCTION__, plane_count,
+ custom_format);
+ plane_info.resize(plane_count);
+ for (int i = 0; i < plane_count; i++) {
+ plane_info[i].component = yuv_plane_info[i].component;
+ plane_info[i].h_subsampling = yuv_plane_info[i].h_subsampling;
+ plane_info[i].v_subsampling = yuv_plane_info[i].v_subsampling;
+ plane_info[i].offset = yuv_plane_info[i].offset;
+ plane_info[i].pixel_increment = yuv_plane_info[i].step;
+ plane_info[i].stride = yuv_plane_info[i].stride;
+ plane_info[i].stride_bytes = yuv_plane_info[i].stride_bytes;
+ plane_info[i].scanlines = yuv_plane_info[i].scanlines;
+ plane_info[i].size = yuv_plane_info[i].size;
+ ALOGD_IF(DEBUG, "%s: plane info: component - %d", __FUNCTION__, plane_info[i].component);
+ ALOGD_IF(DEBUG, "h_subsampling - %u, v_subsampling - %u, offset - %u, pixel_increment - %d",
+ plane_info[i].h_subsampling, plane_info[i].v_subsampling, plane_info[i].offset,
+ plane_info[i].pixel_increment);
+ ALOGD_IF(DEBUG, "stride_pixel - %d, stride_bytes - %d, scanlines - %d, size - %u",
+ plane_info[i].stride, plane_info[i].stride_bytes, plane_info[i].scanlines,
+ plane_info[i].size);
+ }
+ err = Error::NONE;
+ }
hidl_cb(err, size, plane_info);
return Void();
}