Merge "sde: Add support to read HDMI scan info"
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index aaaf16b..695de9b 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -174,9 +174,11 @@
     {
         case HAL_PIXEL_FORMAT_YCrCb_420_SP:
         case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:
-        case HAL_PIXEL_FORMAT_RAW_SENSOR:
             aligned_w = ALIGN(width, 32);
             break;
+        case HAL_PIXEL_FORMAT_RAW_SENSOR:
+            aligned_w = ALIGN(width, 16);
+            break;
         case HAL_PIXEL_FORMAT_RAW10:
             aligned_w = ALIGN(width * 10 /8, 16);
             break;
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index 00bd643..ae7431f 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -567,19 +567,11 @@
     mDirtyRect = list->hwLayers[last].displayFrame;
 
     if (mDirtyLayerIndex != NO_UPDATING_LAYER &&
-            CBUtils::getuiClearRegion(list, clearRegion, layerProp,
-                                                    mDirtyLayerIndex)) {
-       int clear_w =  clearRegion.right -  clearRegion.left;
-       int clear_h =  clearRegion.bottom - clearRegion.top;
-       //mdp can't handle solid fill for one line
-       //making solid fill as full in this case
-       //disable swap rect if presents
-       if ((clear_w == 1) || (clear_h ==1)) {
-           clear(renderBuffer, mDirtyRect);
-           mDirtyLayerIndex = -1;
-       }else
-           clear(renderBuffer, clearRegion);
+           not CBUtils::uiClearRegion(list, ctx->mMDP.version, layerProp,
+                                   mDirtyLayerIndex, mEngine, renderBuffer)){
+        mDirtyLayerIndex = -1;
     }
+
     if (mDirtyLayerIndex != -1) {
         if (mDirtyLayerIndex == NO_UPDATING_LAYER) {
             mDirtyRect = clearRegion;
@@ -648,10 +640,9 @@
     }
 
     //Clear the transparent or left out region on the render buffer
-    hwc_rect_t clearRegion = {0,0,0,0};
     LayerProp *layerProp = ctx->layerProp[0];
-    if(CBUtils::getuiClearRegion(list, clearRegion, layerProp))
-        clear(renderBuffer, clearRegion);
+    CBUtils::uiClearRegion(list, ctx->mMDP.version, layerProp, -1,
+                                                    mEngine, renderBuffer);
 
     int copybitLayerCount = 0;
     for(int j = 0; j < ptorInfo->count; j++) {
diff --git a/libqdutils/cb_utils.cpp b/libqdutils/cb_utils.cpp
index c17842a..350d7fd 100644
--- a/libqdutils/cb_utils.cpp
+++ b/libqdutils/cb_utils.cpp
@@ -36,12 +36,28 @@
     irect.bottom = max(rect1.bottom, rect2.bottom);
 }
 
+int clear (copybit_device_t *copybit, private_handle_t* hnd, hwc_rect_t& rect)
+{
+    int ret = 0;
+    copybit_rect_t clear_rect = {rect.left, rect.top,rect.right,rect.bottom};
+
+    copybit_image_t buf;
+    buf.w = ALIGN(getWidth(hnd),32);
+    buf.h = getHeight(hnd);
+    buf.format = hnd->format;
+    buf.base = (void *)hnd->base;
+    buf.handle = (native_handle_t *)hnd;
+
+    ret = copybit->clear(copybit, &buf, &clear_rect);
+    return ret;
+}
 using namespace android;
 using namespace qhwc;
 namespace qdutils {
 
-int CBUtils::getuiClearRegion(hwc_display_contents_1_t* list,
-          hwc_rect_t &clearWormholeRect, LayerProp *layerProp, int dirtyIndex) {
+int CBUtils::uiClearRegion(hwc_display_contents_1_t* list,
+        int version, LayerProp *layerProp,  int dirtyIndex,
+            copybit_device_t *copybit, private_handle_t *renderBuffer) {
 
     size_t last = list->numHwLayers - 1;
     hwc_rect_t fbFrame = list->hwLayers[last].displayFrame;
@@ -108,14 +124,22 @@
    while (it != end) {
        const Rect& r = *it++;
        hwc_rect_t tmpWormRect = {r.left,r.top,r.right,r.bottom};
-       int dst_w =  clearWormholeRect.right -  clearWormholeRect.left;
-       int dst_h =  clearWormholeRect.bottom -  clearWormholeRect.top;
-
-       if (!(dst_w || dst_h))
-             clearWormholeRect = tmpWormRect;
-       else
-             getUnion(clearWormholeRect, tmpWormRect, clearWormholeRect);
-
+       if (version == qdutils::MDP_V3_0_4 ||
+               version == qdutils::MDP_V3_0_5) {
+           int clear_w =  tmpWormRect.right - tmpWormRect.left;
+           int clear_h =  tmpWormRect.bottom - tmpWormRect.top;
+           //mdp can't handle solid fill for one line
+           //making solid fill as full in this case
+           //disable swap rect if presents
+           if ((clear_w == 1) || (clear_h ==1)) {
+               clear(copybit, renderBuffer, fbFrame);
+               return 0;
+           } else {
+               clear(copybit, renderBuffer, tmpWormRect);
+           }
+       } else {
+           clear(copybit, renderBuffer, tmpWormRect);
+       }
    }
    return 1;
 }
diff --git a/libqdutils/cb_utils.h b/libqdutils/cb_utils.h
index 59f452b..a383fb0 100644
--- a/libqdutils/cb_utils.h
+++ b/libqdutils/cb_utils.h
@@ -31,14 +31,15 @@
 
 #include <ui/Region.h>
 #include "hwc_utils.h"
+#include "copybit.h"
 
 using namespace qhwc;
 namespace qdutils {
 class CBUtils {
 public:
-static int getuiClearRegion(hwc_display_contents_1_t* list,
-                              hwc_rect_t &clearWormholeRec,
-                              LayerProp *layerProp, int dirtyIndex = -1);
+    static int uiClearRegion(hwc_display_contents_1_t* list,
+            int version, LayerProp *layerProp, int dirtyIndex,
+            copybit_device_t *copybit, private_handle_t *renderBuffer);
 };
 }//namespace qdutils
 #endif /* end of include guard: CB_UTIL_H*/