Avoid clobbering of YUV layout for flexible formats
Bug: 21787806
In function DeriveYUVLayout in fw/rs/driver/rsdAllocation.cpp, skip
initialization of DrvState if the yuv format is the flexible YCbCr
format.
Change-Id: Ie2c5253b2ed048887d034ad8793d0558f2cd7d4f
(cherry picked from commit 31c406a5991858d68886d35b6e9bf03acc0b3288)
diff --git a/driver/rsdAllocation.cpp b/driver/rsdAllocation.cpp
index 94efab2..790005d 100644
--- a/driver/rsdAllocation.cpp
+++ b/driver/rsdAllocation.cpp
@@ -252,6 +252,15 @@
static size_t DeriveYUVLayout(int yuv, Allocation::Hal::DrvState *state) {
+#ifndef RS_COMPATIBILITY_LIB
+ // For the flexible YCbCr format, layout is initialized during call to
+ // Allocation::ioReceive. Return early and avoid clobberring any
+ // pre-existing layout.
+ if (yuv == HAL_PIXEL_FORMAT_YCbCr_420_888) {
+ return 0;
+ }
+#endif
+
// YUV only supports basic 2d
// so we can stash the plane pointers in the mipmap levels.
size_t uvSize = 0;
@@ -286,11 +295,6 @@
uvSize += state->lod[1].stride * state->lod[1].dimY;
state->yuv.step = 2;
break;
-#ifndef RS_COMPATIBILITY_LIB
- case HAL_PIXEL_FORMAT_YCbCr_420_888:
- // This will be filled in by ioReceive()
- break;
-#endif
default:
rsAssert(0);
}