gralloc: Report YUV plane info
The android_ycbcr structure in graphics.h is populated to give
the luma and chroma addresses. Use the same structure to give
this information to graphics via a gralloc perform call.
Change-Id: Ib42866a9ea90873886dcb60a1aac6cb375292642
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index a1b681c..bf698e6 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -256,28 +256,8 @@
{
private_handle_t* hnd = (private_handle_t*)handle;
int err = gralloc_map_and_invalidate(module, handle, usage);
- size_t ystride, cstride;
- if(!err) {
- //hnd->format holds our implementation defined format
- //HAL_PIXEL_FORMAT_YCrCb_420_SP is the only one set right now.
- switch (hnd->format) {
- case HAL_PIXEL_FORMAT_YCrCb_420_SP:
- ystride = ALIGN(hnd->width, 16);
- cstride = ALIGN(hnd->width, 16)/2;
- ycbcr->y = (void*)hnd->base;
- ycbcr->cr = (void*)(hnd->base + ystride * hnd->height);
- ycbcr->cb = (void*)(hnd->base + ystride * hnd->height + 1);
- ycbcr->ystride = ystride;
- ycbcr->cstride = cstride;
- ycbcr->chroma_step = 2;
- memset(ycbcr->reserved, 0, sizeof(ycbcr->reserved));
- break;
- default:
- ALOGD("%s: Invalid format passed: 0x%x", __FUNCTION__,
- hnd->format);
- err = -EINVAL;
- }
- }
+ if(!err)
+ err = getYUVPlaneInfo(hnd, ycbcr);
return err;
}
@@ -367,6 +347,15 @@
}
res = 0;
} break;
+ case GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO:
+ {
+ private_handle_t* hnd = va_arg(args, private_handle_t*);
+ android_ycbcr* ycbcr = va_arg(args, struct android_ycbcr *);
+ if (private_handle_t::validate(hnd)) {
+ res = getYUVPlaneInfo(hnd, ycbcr);
+ }
+ } break;
+
default:
break;
}