Merge "sdm: hwc_session: Make display members polymorphic"
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index e2c4677..3e3638c 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -69,7 +69,8 @@
     return new MDPCompNonSplit(dpy);
 }
 
-MDPComp::MDPComp(int dpy):mDpy(dpy){};
+MDPComp::MDPComp(int dpy) : mDpy(dpy), mModeOn(false), mPrevModeOn(false) {
+};
 
 void MDPComp::dump(android::String8& buf, hwc_context_t *ctx)
 {
@@ -1808,6 +1809,14 @@
 void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list,
         bool secureOnly, FrameInfo& frame) {
     int nYuvCount = ctx->listStats[mDpy].yuvCount;
+    int nVGpipes = qdutils::MDPVersion::getInstance().getVGPipes();
+
+    /* If number of YUV layers in the layer list is more than the number of
+       VG pipes available in the target (non-split), try to program maximum
+       possible number of YUV layers to MDP, instead of falling back to GPU
+       completely.*/
+    nYuvCount = (nYuvCount > nVGpipes) ? nVGpipes : nYuvCount;
+
     for(int index = 0;index < nYuvCount; index++){
         int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index];
         hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex];
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 5de3081..03c6341 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -854,7 +854,8 @@
                                ovutils::eTransform& orient) {
     // Swap width and height when there is a 90deg transform
     int extOrient = getExtOrientation(ctx);
-    if(dpy && ctx->mOverlay->isUIScalingOnExternalSupported()) {
+    if ((dpy || ctx->mHDMIDisplay->isHDMIPrimaryDisplay())
+            && ctx->mOverlay->isUIScalingOnExternalSupported()) {
         if(!isYuvBuffer(hnd)) {
             if(extOrient & HWC_TRANSFORM_ROT_90) {
                 int dstWidth = ctx->dpyAttr[dpy].xres;
@@ -1377,8 +1378,9 @@
     // Disable Action safe for 8974 due to HW limitation for downscaling
     // layers with overlapped region
     // Disable Actionsafe for non HDMI displays.
-    if(!(dpy == HWC_DISPLAY_EXTERNAL) ||
-        qdutils::MDPVersion::getInstance().is8x74v2() ||
+    if (!(dpy == HWC_DISPLAY_EXTERNAL ||
+                ctx->mHDMIDisplay->isHDMIPrimaryDisplay()) ||
+            qdutils::MDPVersion::getInstance().is8x74v2() ||
         ctx->mHDMIDisplay->isCEUnderscanSupported()) {
         return false;
     }