Revert "hwc: Perform MDP downscaling for WFD/HDMI Scenario"

This reverts commit 1291675ee44cadc234c4403cf1b0cfe70eadaf3a.
diff --git a/libhwcomposer/hwc_fbupdate.cpp b/libhwcomposer/hwc_fbupdate.cpp
index 7c2e643..b5ac2b8 100644
--- a/libhwcomposer/hwc_fbupdate.cpp
+++ b/libhwcomposer/hwc_fbupdate.cpp
@@ -26,12 +26,10 @@
 #include "hwc_fbupdate.h"
 #include "mdp_version.h"
 #include "external.h"
-#include "virtual.h"
 
 using namespace qdutils;
 using namespace overlay;
 using overlay::Rotator;
-using namespace overlay::utils;
 
 namespace qhwc {
 
@@ -120,32 +118,27 @@
         // Do not use getNonWormholeRegion() function to calculate the
         // sourceCrop during animation on external display and
         // Dont do wormhole calculation when extorientation is set on External
-        // Dont do wormhole calculation when extDownscale is enabled on External
         if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) {
             sourceCrop = layer->displayFrame;
             displayFrame = sourceCrop;
-        } else if((!mDpy ||
-                   (mDpy && !ctx->mExtOrientation
-                   && !ctx->dpyAttr[mDpy].mDownScaleMode))
-                   && (extOnlyLayerIndex == -1)) {
+        } else if((!mDpy || (mDpy && !ctx->mExtOrientation))
+                               && extOnlyLayerIndex == -1) {
             if(!qdutils::MDPVersion::getInstance().is8x26()) {
                 getNonWormholeRegion(list, sourceCrop);
                 displayFrame = sourceCrop;
             }
         }
+
         if(mDpy && !qdutils::MDPVersion::getInstance().is8x26()) {
-            if(ctx->mExtOrientation || ctx->dpyAttr[mDpy].mDownScaleMode) {
-                calcExtDisplayPosition(ctx, mDpy, sourceCrop, displayFrame);
+            if(ctx->mExtOrientation) {
+                calcExtDisplayPosition(ctx, mDpy, displayFrame);
                 // If there is a external orientation set, use that
-                if(ctx->mExtOrientation) {
-                    transform = ctx->mExtOrientation;
-                    orient =
-                        static_cast<ovutils::eTransform >(ctx->mExtOrientation);
-                }
+                transform = ctx->mExtOrientation;
+                orient = static_cast<ovutils::eTransform >(ctx->mExtOrientation);
             }
             // Calculate the actionsafe dimensions for External(dpy = 1 or 2)
             getActionSafePosition(ctx, mDpy, displayFrame);
-        }
+       }
         setMdpFlags(layer, mdpFlags, 0, transform);
         // For External use rotator if there is a rotation value set
         if(mDpy && (ctx->mExtOrientation & HWC_TRANSFORM_ROT_90)) {
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index e013876..91cf337 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -159,9 +159,6 @@
     ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected = false;
     ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isActive = false;
     ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected = false;
-    ctx->dpyAttr[HWC_DISPLAY_PRIMARY].mDownScaleMode= false;
-    ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].mDownScaleMode = false;
-    ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].mDownScaleMode = false;
 
     ctx->mMDPComp[HWC_DISPLAY_PRIMARY] =
          MDPComp::getObject(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres,
@@ -417,56 +414,6 @@
                  "y = %d w = %d h = %d", __FUNCTION__, outPos.x, outPos.y,
                  outPos.w, outPos.h);
 
-    // For sidesync, the dest fb will be in portrait orientation, and the crop
-    // will be updated to avoid the black side bands, and it will be upscaled
-    // to fit the dest RB, so recalculate
-    // the position based on the new width and height
-    if ((extOrientation & HWC_TRANSFORM_ROT_90) &&
-                        isOrientationPortrait(ctx)) {
-        hwc_rect_t r;
-        //Calculate the position
-        xRatio = (outPos.x - xPos)/width;
-        // GetaspectRatio -- tricky to get the correct aspect ratio
-        // But we need to do this.
-        getAspectRatioPosition(width, height, width, height, r);
-        xPos = r.left;
-        yPos = r.top;
-        float tempWidth = r.right - r.left;
-        float tempHeight = r.bottom - r.top;
-        yRatio = yPos/height;
-        wRatio = outPos.w/width;
-        hRatio = tempHeight/height;
-
-        //Map the coordinates back to Framebuffer domain
-        outPos.x = (xRatio * fbWidth);
-        outPos.y = (yRatio * fbHeight);
-        outPos.w = wRatio * fbWidth;
-        outPos.h = hRatio * fbHeight;
-
-        ALOGD_IF(HWC_UTILS_DEBUG, "%s: Calculated AspectRatio for device in"
-                 "portrait: x = %d,y = %d w = %d h = %d", __FUNCTION__,
-                 outPos.x, outPos.y,
-                 outPos.w, outPos.h);
-    }
-    if(ctx->dpyAttr[dpy].mDownScaleMode) {
-        int extW, extH;
-        if(dpy == HWC_DISPLAY_EXTERNAL)
-            ctx->mExtDisplay->getAttributes(extW, extH);
-        else
-            ctx->mVirtualDisplay->getAttributes(extW, extH);
-        fbWidth  = ctx->dpyAttr[dpy].xres;
-        fbHeight = ctx->dpyAttr[dpy].yres;
-        //Calculate the position...
-        xRatio = outPos.x/fbWidth;
-        yRatio = outPos.y/fbHeight;
-        wRatio = outPos.w/fbWidth;
-        hRatio = outPos.h/fbHeight;
-
-        outPos.x = xRatio * extW;
-        outPos.y = yRatio * extH;
-        outPos.w = wRatio * extW;
-        outPos.h = hRatio * extH;
-    }
     // Convert Dim to hwc_rect_t
     outRect.left = outPos.x;
     outRect.top = outPos.y;
@@ -485,60 +432,20 @@
     return false;
 }
 
-bool isOrientationPortrait(hwc_context_t *ctx) {
-    if(isPrimaryPortrait(ctx)) {
-        return !(ctx->deviceOrientation & 0x1);
-    }
-    return (ctx->deviceOrientation & 0x1);
-}
-
-void calcExtDisplayPosition(hwc_context_t *ctx, int dpy,
-                               hwc_rect_t& sourceCrop,
-                               hwc_rect_t& displayFrame) {
+void calcExtDisplayPosition(hwc_context_t *ctx,
+                               int dpy, hwc_rect_t& displayFrame) {
+    int dstWidth = ctx->dpyAttr[dpy].xres;
+    int dstHeight = ctx->dpyAttr[dpy].yres;;
+    int srcWidth = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres;
+    int srcHeight = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres;
     // Swap width and height when there is a 90deg transform
     if(ctx->mExtOrientation & HWC_TRANSFORM_ROT_90) {
-        int dstWidth = ctx->dpyAttr[dpy].xres;
-        int dstHeight = ctx->dpyAttr[dpy].yres;;
-        int srcWidth = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres;
-        int srcHeight = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres;
         if(!isPrimaryPortrait(ctx)) {
             swap(srcWidth, srcHeight);
         }                    // Get Aspect Ratio for external
         getAspectRatioPosition(dstWidth, dstHeight, srcWidth,
                             srcHeight, displayFrame);
-        // Crop - this is needed, because for sidesync, the dest fb will
-        // be in portrait orientation, so update the crop to not show the
-        // black side bands.
-        if (isOrientationPortrait(ctx)) {
-            sourceCrop = displayFrame;
-            displayFrame.left = 0;
-            displayFrame.top = 0;
-            displayFrame.right = dstWidth;
-            displayFrame.bottom = dstHeight;
-        }
     }
-    if(ctx->dpyAttr[dpy].mDownScaleMode) {
-        int extW, extH;
-        // if downscale is enabled, map the co-ordinates to new
-        // domain(downscaled)
-        float fbWidth  = ctx->dpyAttr[dpy].xres;
-        float fbHeight = ctx->dpyAttr[dpy].yres;
-        // query MDP configured attributes
-        if(dpy == HWC_DISPLAY_EXTERNAL)
-            ctx->mExtDisplay->getAttributes(extW, extH);
-        else
-            ctx->mVirtualDisplay->getAttributes(extW, extH);
-        //Calculate the ratio...
-        float wRatio = ((float)extW)/fbWidth;
-        float hRatio = ((float)extH)/fbHeight;
-
-        //convert Dim to hwc_rect_t
-        displayFrame.left *= wRatio;
-        displayFrame.top *= hRatio;
-        displayFrame.right *= wRatio;
-        displayFrame.bottom *= hRatio;
-    }
-
 }
 
 bool needsScaling(hwc_context_t* ctx, hwc_layer_1_t const* layer,
@@ -1167,12 +1074,8 @@
     if(dpy) {
         // Just need to set the position to portrait as the transformation
         // will already be set to required orientation on TV
-        if(ctx->mExtOrientation || ctx->dpyAttr[dpy].mDownScaleMode) {
+        if(ctx->mExtOrientation) {
             getAspectRatioPosition(ctx, dpy, ctx->mExtOrientation, dst, dst);
-            if(ctx->mExtOrientation) {
-                transform = ctx->mExtOrientation;
-                orient = static_cast<eTransform>(transform);
-            }
         }
         // Calculate the actionsafe dimensions for External(dpy = 1 or 2)
         getActionSafePosition(ctx, dpy, dst);
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 8809493..251b3cb 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -83,8 +83,6 @@
     // To trigger padding round to clean up mdp
     // pipes
     bool isConfiguring;
-    // External Display is in MDP Downscale mode indicator
-    bool mDownScaleMode;
 };
 
 struct ListStats {
@@ -187,12 +185,8 @@
 
 bool isPrimaryPortrait(hwc_context_t *ctx);
 
-bool isOrientationPortrait(hwc_context_t *ctx);
-
 void calcExtDisplayPosition(hwc_context_t *ctx,
-                               int dpy,
-                               hwc_rect_t& sourceCrop,
-                               hwc_rect_t& displayFrame);
+                               int dpy, hwc_rect_t& displayFrame);
 
 //Close acquireFenceFds of all layers of incoming list
 void closeAcquireFds(hwc_display_contents_1_t* list);