sdm: Add support for LINEAR_FORMAT metadata operation

1. Define LINEAR_FORMAT operation in MetaData.
2. VENUS ouput buffer is linear for NV12_UBWC Interlaced video playback.
   So Video module performs LINEAR_FORMAT operation to set "linearFormat"
   metadata member to NV12 linear format in case of Interlaced video.
3. Handle LINEAR_FORMAT metadata operation in HWC wrapper and gralloc.

CRs-Fixed: 855474

Change-Id: I77dd72bec26f225de75adb6c214ccd90db239e3e
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 4ef4886..98079c2 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -655,21 +655,27 @@
     int err = 0;
     int width = hnd->width;
     int height = hnd->height;
+    int format = hnd->format;
     unsigned int ystride, cstride;
     unsigned int alignment = 4096;
 
     memset(ycbcr->reserved, 0, sizeof(ycbcr->reserved));
+    MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
+
+    // Check if UBWC buffer has been rendered in linear format.
+    if (metadata && (metadata->operation & LINEAR_FORMAT)) {
+        format = metadata->linearFormat;
+    }
 
     // Check metadata if the geometry has been updated.
-    MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
     if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
         AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(metadata->bufferDim.sliceWidth,
-                   metadata->bufferDim.sliceHeight, hnd->format, 0, width, height);
+                   metadata->bufferDim.sliceHeight, format, 0, width, height);
     }
 
     // Get the chroma offsets from the handle width/height. We take advantage
     // of the fact the width _is_ the stride
-    switch (hnd->format) {
+    switch (format) {
         //Semiplanar
         case HAL_PIXEL_FORMAT_YCbCr_420_SP:
         case HAL_PIXEL_FORMAT_YCbCr_422_SP:
@@ -745,8 +751,7 @@
         case HAL_PIXEL_FORMAT_YCrCb_422_I:
         case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
         default:
-        ALOGD("%s: Invalid format passed: 0x%x", __FUNCTION__,
-                hnd->format);
+        ALOGD("%s: Invalid format passed: 0x%x", __FUNCTION__, format);
         err = -EINVAL;
     }
     return err;