hwc: allow DMA pipe in BLOCK mode for virtual dpy

For portrait videos case on WFD, driver supports multiplexing
of DMA pipe in LINE and BLOCK mode.
Loosen the requirements to allow DMA pipe in block mode for
portrait case of virtual display.

Change-Id: I5821501f89b17bb2d29c425aee0a6c16b2a4783b
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index f32ad34..977cf0e 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -1685,9 +1685,9 @@
     if(qdutils::MDPVersion::getInstance().is8x26() &&
             ctx->mVirtualDisplay->isConnected() &&
             !ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isPause) {
-        // Allow if YUV needs rotation and DMA is configured to BLOCK mode for
-        // primary. For portrait videos usecase on WFD, Driver supports
-        // multiplexing of DMA pipe in LINE and BLOCK mode.
+        /* 8x26 mdss driver supports multiplexing of DMA pipe
+         * in LINE and BLOCK modes for writeback panels.
+         */
         if(dpy == HWC_DISPLAY_PRIMARY)
             return false;
     }
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index 9222af5..d9baadd 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -52,6 +52,7 @@
 
     mDumpStr[0] = '\0';
     initScalar();
+    setDMAMultiplexingSupported();
 }
 
 Overlay::~Overlay() {
@@ -117,8 +118,10 @@
             (mPipeBook[i].mMixer == MIXER_UNUSED || //Free or same mixer
              mPipeBook[i].mMixer == mixer) &&
             PipeBook::isNotAllocated(i) && //Free pipe
-            !(sDMAMode == DMA_BLOCK_MODE && //DMA pipe in Line mode
-               PipeBook::getPipeType((eDest)i) == OV_MDP_PIPE_DMA)) {
+            ( (sDMAMultiplexingSupported && dpy) ||
+              !(sDMAMode == DMA_BLOCK_MODE && //DMA pipe in Line mode
+               PipeBook::getPipeType((eDest)i) == OV_MDP_PIPE_DMA)) ){
+              //DMA-Multiplexing is only supported for WB on 8x26
             dest = (eDest)i;
             PipeBook::setAllocation(i);
             break;
@@ -458,6 +461,7 @@
 Overlay* Overlay::sInstance = 0;
 int Overlay::sDpyFbMap[DPY_MAX] = {0, -1, -1};
 int Overlay::sDMAMode = DMA_LINE_MODE;
+bool Overlay::sDMAMultiplexingSupported = false;
 int Overlay::sForceSetBitmap = 0;
 int Overlay::PipeBook::NUM_PIPES = 0;
 int Overlay::PipeBook::sPipeUsageBitmap = 0;
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index 854fa30..4df921f 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -31,6 +31,7 @@
 #define OVERLAY_H
 
 #include "overlayUtils.h"
+#include "mdp_version.h"
 #include "utils/threads.h"
 
 struct MetaData_t;
@@ -122,6 +123,7 @@
     explicit Overlay();
     /*Validate index range, abort if invalid */
     void validate(int index);
+    static void setDMAMultiplexingSupported();
     void dump() const;
     /* Creates a scalar object using libscale.so */
     static void initScalar();
@@ -185,6 +187,7 @@
     static Overlay *sInstance;
     static int sDpyFbMap[DPY_MAX];
     static int sDMAMode;
+    static bool sDMAMultiplexingSupported;
     static int sForceSetBitmap;
     static void *sLibScaleHandle;
     static scale::Scale *sScale;
@@ -247,6 +250,12 @@
         sDMAMode = mode;
 }
 
+inline void Overlay::setDMAMultiplexingSupported() {
+    sDMAMultiplexingSupported = false;
+    if(qdutils::MDPVersion::getInstance().is8x26())
+        sDMAMultiplexingSupported = true;
+}
+
 inline int Overlay::getDMAMode() {
     return sDMAMode;
 }