Skip to content
Snippets Groups Projects
Commit d007afcf authored by Robert Tarasov's avatar Robert Tarasov
Browse files

Fixes YV12 image creation crash

Workaround to address yv12 image creation crash in some CTS and CTS-V
tests due to lack of ycrcb routine gralloc4. This workaround doesn't
fix a render correctness and some tests will fail, but at lest they
will finish without crashes.

Bug: 225392099
Bug: 227530308

Test: Tested CTS-V "Projection Video Playback Test" on Osprey
Test: Tested CtsPermissionTestCases module on Osprey

Change-Id: Id84c042e46b2c8af088a63182e36eda910a748e2
parent 89f2147a
No related branches found
No related tags found
No related merge requests found
...@@ -199,24 +199,56 @@ droid_create_image_from_prime_fds_yuv(_EGLDisplay *disp, ...@@ -199,24 +199,56 @@ droid_create_image_from_prime_fds_yuv(_EGLDisplay *disp,
int ret; int ret;
unsigned error; unsigned error;
if (!dri2_dpy->gralloc->lock_ycbcr) {
_eglLog(_EGL_WARNING, "Gralloc does not support lock_ycbcr");
return NULL;
}
memset(&ycbcr, 0, sizeof(ycbcr)); memset(&ycbcr, 0, sizeof(ycbcr));
ret = dri2_dpy->gralloc->lock_ycbcr(dri2_dpy->gralloc, buf->handle, if (dri2_dpy->gralloc->lock_ycbcr) {
0, 0, 0, 0, 0, &ycbcr); ret = dri2_dpy->gralloc->lock_ycbcr(dri2_dpy->gralloc, buf->handle,
if (ret) { 0, 0, 0, 0, 0, &ycbcr);
/* HACK: See droid_create_image_from_prime_fds() and if (ret) {
* https://issuetracker.google.com/32077885.*/ /* HACK: See droid_create_image_from_prime_fds() and
if (buf->format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) * https://issuetracker.google.com/32077885.*/
if (buf->format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED)
return NULL;
_eglLog(_EGL_WARNING, "gralloc->lock_ycbcr failed: %d", ret);
return NULL; return NULL;
}
_eglLog(_EGL_WARNING, "gralloc->lock_ycbcr failed: %d", ret); dri2_dpy->gralloc->unlock(dri2_dpy->gralloc, buf->handle);
return NULL; } else {
_eglLog(_EGL_WARNING, "Gralloc does not support lock_ycbcr!");
// HACK: Prepare a hardcoded ycrcb struct to prevent crashes while trying
// to create a YVU420_ANDROID or FLEX_YCbCr_420 (NV12) image with gralloc4
// see: b/225392099
if (buf->format == HAL_PIXEL_FORMAT_YV12) {
// HAL_PIXEL_FORMAT_YV12 => DRM_FORMAT_YVU420_ANDROID
// The stride of Android YV12 buffers is required to be aligned to 16 bytes
size_t luma_stride = ALIGN(buf->width, 32);
size_t chroma_stride = ALIGN(buf->width/2, 16);
ycbcr.y = 0;
ycbcr.cr = (void*)(luma_stride*buf->height);
ycbcr.cb = (void*)(luma_stride*buf->height+chroma_stride*buf->height/2);
ycbcr.ystride = luma_stride;
ycbcr.cstride = chroma_stride;
ycbcr.chroma_step = 1;
_eglLog(_EGL_WARNING,
"Using a hardcoded ycbcr struct for DRM_FORMAT_YVU420_ANDROID format.");
} else if (buf->format == HAL_PIXEL_FORMAT_YCbCr_420_888) {
// HAL_PIXEL_FORMAT_YCbCr_420_888 => DRM_FORMAT_FLEX_YCbCr_420_888
size_t luma_stride = buf->width;
size_t chroma_stride = buf->width;
ycbcr.y = 0;
ycbcr.cr = (void*)(luma_stride*buf->height+1);
ycbcr.cb = (void*)(luma_stride*buf->height);
ycbcr.ystride = luma_stride;
ycbcr.cstride = chroma_stride;
ycbcr.chroma_step = 2;
_eglLog(_EGL_WARNING,
"Using a hardcoded ycbcr struct for DRM_FORMAT_FLEX_YCbCr_420_888 format.");
} else {
_eglLog(_EGL_WARNING,
"Unable to create an image for native YUV format %x", buf->format);
return NULL;
}
} }
dri2_dpy->gralloc->unlock(dri2_dpy->gralloc, buf->handle);
/* When lock_ycbcr's usage argument contains no SW_READ/WRITE flags /* When lock_ycbcr's usage argument contains no SW_READ/WRITE flags
* it will return the .y/.cb/.cr pointers based on a NULL pointer, * it will return the .y/.cb/.cr pointers based on a NULL pointer,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment