hwc: Enable rotator during resolution change.

MDP VG pipe framesize register is not double bufferred.
It introduces corrupted frame during resolution change especially when
rotator is not used. Enable rotator to handle the transition case.

Change-Id: Ifec55fee0c762dfb12a09580b80dca6f051a1c86
Acked-by: Ramkumar Radhakrishnan <ramkumar@codeaurora.org>
diff --git a/msm8960/libhwcomposer/hwc_utils.cpp b/msm8960/libhwcomposer/hwc_utils.cpp
index d2cf697..97acb37 100644
--- a/msm8960/libhwcomposer/hwc_utils.cpp
+++ b/msm8960/libhwcomposer/hwc_utils.cpp
@@ -943,6 +943,7 @@
     int rotFlags = ovutils::ROT_FLAGS_NONE;
     Whf whf(getWidth(hnd), getHeight(hnd),
             getMdpFormat(hnd->format), hnd->size);
+    bool forceRot = false;
 
     if(isYuvBuffer(hnd) && ctx->mMDP.version >= qdutils::MDP_V4_2 &&
        ctx->mMDP.version < qdutils::MDSS_V5) {
@@ -954,13 +955,24 @@
         if(downscale) {
             rotFlags = ROT_DOWNSCALE_ENABLED;
         }
+        unsigned int& prevWidth = ctx->mPrevWHF[dpy].w;
+        unsigned int& prevHeight = ctx->mPrevWHF[dpy].h;
+        if(prevWidth != (uint32_t)getWidth(hnd) ||
+               prevHeight != (uint32_t)getHeight(hnd)) {
+            uint32_t prevBufArea = (prevWidth * prevHeight);
+            if(prevBufArea) {
+                forceRot = true;
+            }
+            prevWidth = (uint32_t)getWidth(hnd);
+            prevHeight = (uint32_t)getHeight(hnd);
+        }
     }
 
     setMdpFlags(layer, mdpFlags, downscale);
     trimLayer(ctx, dpy, transform, crop, dst);
 
     if(isYuvBuffer(hnd) && //if 90 component or downscale, use rot
-            ((transform & HWC_TRANSFORM_ROT_90) || downscale)) {
+            ((transform & HWC_TRANSFORM_ROT_90) || downscale || forceRot)) {
         *rot = ctx->mRotMgr->getNext();
         if(*rot == NULL) return -1;
         //Configure rotator for pre-rotation
diff --git a/msm8960/libhwcomposer/hwc_utils.h b/msm8960/libhwcomposer/hwc_utils.h
index 6b32ec5..6fd14c4 100644
--- a/msm8960/libhwcomposer/hwc_utils.h
+++ b/msm8960/libhwcomposer/hwc_utils.h
@@ -321,6 +321,7 @@
     qhwc::LayerRotMap *mLayerRotMap[MAX_DISPLAYS];
     qhwc::MDPComp *mMDPComp[MAX_DISPLAYS];
     qhwc::CablProp mCablProp;
+    overlay::utils::Whf mPrevWHF[MAX_DISPLAYS];
 
     //Securing in progress indicator
     bool mSecuring;