overlay: Support for returning pipe based on capability

Add support for returning pipes based on capabilities.
getPipe() API takes in pipe specifications like format class,
scaling, display, mixer, fb and decides what pipe to return.
The nextPipe() API is now just a private helper.

Change-Id: I0ab809662c0ad6297e19a44f39264ee929944d13
diff --git a/libhwcomposer/hwc_fbupdate.cpp b/libhwcomposer/hwc_fbupdate.cpp
index d69d68e..74e6da4 100644
--- a/libhwcomposer/hwc_fbupdate.cpp
+++ b/libhwcomposer/hwc_fbupdate.cpp
@@ -139,14 +139,14 @@
                 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
                     mTileEnabled));
 
-        //Request a pipe
-        ovutils::eMdpPipeType type = ovutils::OV_MDP_PIPE_ANY;
-        if((qdutils::MDPVersion::getInstance().is8x26() ||
-                   qdutils::MDPVersion::getInstance().is8x16()) && mDpy) {
-            //For 8x26 external always use DMA pipe
-            type = ovutils::OV_MDP_PIPE_DMA;
-        }
-        ovutils::eDest dest = ov.nextPipe(type, mDpy, Overlay::MIXER_DEFAULT);
+        Overlay::PipeSpecs pipeSpecs;
+        pipeSpecs.formatClass = Overlay::FORMAT_RGB;
+        pipeSpecs.needsScaling = qhwc::needsScaling(layer);
+        pipeSpecs.dpy = mDpy;
+        pipeSpecs.mixer = Overlay::MIXER_DEFAULT;
+        pipeSpecs.fb = true;
+
+        ovutils::eDest dest = ov.getPipe(pipeSpecs);
         if(dest == ovutils::OV_INVALID) { //None available
             ALOGE("%s: No pipes available to configure fb for dpy %d",
                 __FUNCTION__, mDpy);
@@ -308,10 +308,16 @@
         hwc_rect_t displayFrame = fbUpdatingRect;
 
         ret = true;
+        Overlay::PipeSpecs pipeSpecs;
+        pipeSpecs.formatClass = Overlay::FORMAT_RGB;
+        pipeSpecs.needsScaling = qhwc::needsScaling(layer);
+        pipeSpecs.dpy = mDpy;
+        pipeSpecs.fb = true;
+
         /* Configure left pipe */
         if(displayFrame.left < lSplit) {
-            ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
-                                               Overlay::MIXER_LEFT);
+            pipeSpecs.mixer = Overlay::MIXER_LEFT;
+            ovutils::eDest destL = ov.getPipe(pipeSpecs);
             if(destL == ovutils::OV_INVALID) { //None available
                 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
                       " mixer", __FUNCTION__, mDpy);
@@ -344,8 +350,8 @@
 
         /* Configure right pipe */
         if(displayFrame.right > lSplit) {
-            ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
-                                               Overlay::MIXER_RIGHT);
+            pipeSpecs.mixer = Overlay::MIXER_RIGHT;
+            ovutils::eDest destR = ov.getPipe(pipeSpecs);
             if(destR == ovutils::OV_INVALID) { //None available
                 ALOGE("%s: No pipes available to configure fb for dpy %d's"
                       " right mixer", __FUNCTION__, mDpy);
@@ -455,8 +461,13 @@
     hwc_rect_t cropR = fbUpdatingRect;
 
     //Request left pipe (or 1 by default)
-    ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
-            Overlay::MIXER_DEFAULT);
+    Overlay::PipeSpecs pipeSpecs;
+    pipeSpecs.formatClass = Overlay::FORMAT_RGB;
+    pipeSpecs.needsScaling = qhwc::needsScaling(layer);
+    pipeSpecs.dpy = mDpy;
+    pipeSpecs.mixer = Overlay::MIXER_DEFAULT;
+    pipeSpecs.fb = true;
+    ovutils::eDest destL = ov.getPipe(pipeSpecs);
     if(destL == ovutils::OV_INVALID) {
         ALOGE("%s: No pipes available to configure fb for dpy %d's left"
                 " mixer", __FUNCTION__, mDpy);
@@ -468,8 +479,7 @@
     //Request right pipe (2 pipes needed only if dim > 2048)
     if((fbUpdatingRect.right - fbUpdatingRect.left) >
             qdutils::MAX_DISPLAY_DIM) {
-        destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
-                Overlay::MIXER_DEFAULT);
+        destR = ov.getPipe(pipeSpecs);
         if(destR == ovutils::OV_INVALID) {
             ALOGE("%s: No pipes available to configure fb for dpy %d's right"
                     " mixer", __FUNCTION__, mDpy);