hwc: Enable downscale feature through system property

Add support to turn the MDP downscale feature ON through the
use of a system property. 'sys.hwc.mdp_downscale_enabled' shall be
set to 'true' in build.prop file to enable this functionality.

This is required for OEMs that might have privacy concerns over panel
size information being exposed.

Change-Id: I354b25b1fdabe5786aed7552f2afccda35412467
diff --git a/libexternal/external.cpp b/libexternal/external.cpp
index 1268b0f..65628aa 100644
--- a/libexternal/external.cpp
+++ b/libexternal/external.cpp
@@ -585,7 +585,8 @@
         mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].xres = width;
         mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].yres = height;
         mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].mDownScaleMode = false;
-        if(!qdutils::MDPVersion::getInstance().is8x26()) {
+        if(!qdutils::MDPVersion::getInstance().is8x26()
+                && mHwcContext->mMDPDownscaleEnabled) {
             int priW = mHwcContext->dpyAttr[HWC_DISPLAY_PRIMARY].xres;
             int priH = mHwcContext->dpyAttr[HWC_DISPLAY_PRIMARY].yres;
             // if primary resolution is more than the hdmi resolution
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index d2104ed..68461c7 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -238,6 +238,14 @@
     ctx->mBufferMirrorMode = false;
     ctx->mVPUClient = NULL;
 
+    // Read the system property to determine if downscale feature is enabled.
+    ctx->mMDPDownscaleEnabled = false;
+    char value[PROPERTY_VALUE_MAX];
+    if(property_get("sys.hwc.mdp_downscale_enabled", value, "false")
+            && !strcmp(value, "true")) {
+        ctx->mMDPDownscaleEnabled = true;
+    }
+
 #ifdef VPU_TARGET
     if(qdutils::MDPVersion::getInstance().is8092())
         ctx->mVPUClient = new VPUClient(ctx);
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 8293505..660916d 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -516,6 +516,9 @@
     bool mPanelResetStatus;
     // number of active Displays
     int numActiveDisplays;
+    // Downscale feature switch, set via system the property
+    // sys.hwc.mdp_downscale_enabled
+    bool mMDPDownscaleEnabled;
 };
 
 namespace qhwc {
diff --git a/libvirtual/virtual.cpp b/libvirtual/virtual.cpp
index 795d8a1..7d8b942 100644
--- a/libvirtual/virtual.cpp
+++ b/libvirtual/virtual.cpp
@@ -167,7 +167,13 @@
 
         initResolution(extW, extH);
 
-        if(!qdutils::MDPVersion::getInstance().is8x26()) {
+        // Dynamic Resolution Change depends on MDP downscaling.
+        // MDP downscale property will be ignored to exercise DRC use case.
+        // If DRC is in progress, ext WxH will have non-zero values.
+        bool isDRC = (extW > 0) && (extH > 0);
+
+        if(!qdutils::MDPVersion::getInstance().is8x26()
+                && (mHwcContext->mMDPDownscaleEnabled || isDRC)) {
 
             // maxArea represents the maximum resolution between
             // primary and virtual display.