hwc: Release non VIG pipes during padding round and HDMI configure

1. Fall back to video only composition instead of full GPU composition
   to release all pipes assigned to RGB layers for primary display
   during external configuration and padding round. Do this only for
   the target which has total number of pipes >= 8.
2. This resolves blinks when HDMI is connected during secure video
   playback usecase.

Change-Id: I6cf3a20c3eb3c2b82ad6c70eba84292cf59ecf26
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 0d968c8..4c4dcd2 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -426,14 +426,21 @@
         ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round",
                 __FUNCTION__);
         ret = false;
-    } else if(isSecondaryConfiguring(ctx)) {
-        ALOGD_IF( isDebug(),"%s: External Display connection is pending",
-                  __FUNCTION__);
-        ret = false;
-    } else if(ctx->isPaddingRound) {
-        ALOGD_IF(isDebug(), "%s: padding round invoked for dpy %d",
-                 __FUNCTION__,mDpy);
-        ret = false;
+    } else if(qdutils::MDPVersion::getInstance().getTotalPipes() < 8) {
+       /* TODO: freeing up all the resources only for the targets having total
+                number of pipes < 8. Need to analyze number of VIG pipes used
+                for primary in previous draw cycle and accordingly decide
+                whether to fall back to full GPU comp or video only comp
+        */
+        if(isSecondaryConfiguring(ctx)) {
+            ALOGD_IF( isDebug(),"%s: External Display connection is pending",
+                      __FUNCTION__);
+            ret = false;
+        } else if(ctx->isPaddingRound) {
+            ALOGD_IF(isDebug(), "%s: padding round invoked for dpy %d",
+                     __FUNCTION__,mDpy);
+            ret = false;
+        }
     }
     return ret;
 }
@@ -692,6 +699,18 @@
         return false;
     }
 
+    // if secondary is configuring or Padding round, fall back to video only
+    // composition and release all assigned non VIG pipes from primary.
+    if(isSecondaryConfiguring(ctx)) {
+        ALOGD_IF( isDebug(),"%s: External Display connection is pending",
+                  __FUNCTION__);
+        return false;
+    } else if(ctx->isPaddingRound) {
+        ALOGD_IF(isDebug(), "%s: padding round invoked for dpy %d",
+                 __FUNCTION__,mDpy);
+        return false;
+    }
+
     MDPVersion& mdpHw = MDPVersion::getInstance();
     if(mDpy > HWC_DISPLAY_PRIMARY &&
             (priDispW >  mdpHw.getMaxMixerWidth()) &&