hwc: mdpcomp: split: Count total pipes needed per display also

When checking for pipes needed for each mixer, the pipes completely
unused are counted twice.
Add a per display check on top of per mixer check to make sure this
is taken care of.

For example: Each mixer needs 4 pipes, and total completely unused
pipes are 6. Each mixer will get 6 as available pipes, which is ok
at a mixer level, but at a display level 8 pipes are needed and 6
available. Need to account for that

Change-Id: I9811255aab96c7fe47331f8aa125fef2a4a2f704
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index 280223c..4b91038 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -84,6 +84,8 @@
 
     /* Returns available ("unallocated") pipes for a display's mixer */
     int availablePipes(int dpy, int mixer);
+    /* Returns available ("unallocated") pipes for a display */
+    int availablePipes(int dpy);
     /* Returns if any of the requested pipe type is attached to any of the
      * displays
      */
@@ -198,6 +200,21 @@
     return avail;
 }
 
+inline int Overlay::availablePipes(int dpy) {
+    int avail = 0;
+    for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
+        if( (mPipeBook[i].mDisplay == DPY_UNUSED ||
+             mPipeBook[i].mDisplay == dpy) &&
+            PipeBook::isNotAllocated(i) &&
+            !(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE &&
+              PipeBook::getPipeType((utils::eDest)i) ==
+              utils::OV_MDP_PIPE_DMA)) {
+            avail++;
+        }
+    }
+    return avail;
+}
+
 inline void Overlay::setDMAMode(const int& mode) {
     if(mode == DMA_LINE_MODE || mode == DMA_BLOCK_MODE)
         sDMAMode = mode;