merge in mnc-release history after reset to mnc-dev
diff --git a/msm8974/libgralloc/gpu.cpp b/msm8974/libgralloc/gpu.cpp
index f6046df..5e3680b 100644
--- a/msm8974/libgralloc/gpu.cpp
+++ b/msm8974/libgralloc/gpu.cpp
@@ -272,6 +272,13 @@
             grallocFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; //NV21
         else if(usage & GRALLOC_USAGE_HW_CAMERA_WRITE)
             grallocFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; //NV21
+        //If flexible yuv is used for sw read/write, need map to NV21
+        else if(format == HAL_PIXEL_FORMAT_YCbCr_420_888 &&
+            (usage & GRALLOC_USAGE_SW_WRITE_MASK ||
+            usage & GRALLOC_USAGE_SW_READ_MASK)) {
+            grallocFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP;
+        }
+
     }
 
     if (grallocFormat == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED &&
diff --git a/msm8994/libgralloc/alloc_controller.cpp b/msm8994/libgralloc/alloc_controller.cpp
index b501863..5da016a 100644
--- a/msm8994/libgralloc/alloc_controller.cpp
+++ b/msm8994/libgralloc/alloc_controller.cpp
@@ -160,12 +160,12 @@
     {
         case HAL_PIXEL_FORMAT_YCrCb_420_SP:
         case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:
-        case HAL_PIXEL_FORMAT_RAW10:
-            aligned_w = ALIGN(width * 10 /8, 16);
-            break;
         case HAL_PIXEL_FORMAT_RAW16:
             aligned_w = ALIGN(width, 32);
             break;
+        case HAL_PIXEL_FORMAT_RAW10:
+            aligned_w = ALIGN(width * 10 /8, 16);
+            break;
         case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
             aligned_w = ALIGN(width, 128);
             break;
@@ -478,12 +478,12 @@
         case HAL_PIXEL_FORMAT_RGB_565:
         case HAL_PIXEL_FORMAT_RGBA_5551:
         case HAL_PIXEL_FORMAT_RGBA_4444:
-        case HAL_PIXEL_FORMAT_RAW10:
-            size = ALIGN(alignedw * alignedh, 4096);
-            break;
         case HAL_PIXEL_FORMAT_RAW16:
             size = alignedw * alignedh * 2;
             break;
+        case HAL_PIXEL_FORMAT_RAW10:
+            size = ALIGN(alignedw * alignedh, 4096);
+            break;
             // adreno formats
         case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:  // NV21
             size  = ALIGN(alignedw*alignedh, 4096);