hwc: Reset pipebook format to avoid pipe allocation failures.

Reset format type to FORMAT_NONE to select the pipe irrespective of
the format specifed by the client. This is required for the device
where SMP starvation is unlikely, we need not keep track of formats
programmed in the pipes to avoid potential pipe crunching.

Change-Id: Ifc00549802ca66936e171d00020124d3bcb60e0a
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index a34e599..b7c7fcc 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -151,6 +151,8 @@
         return getPipe_8x39(pipeSpecs);
     } else if(MDPVersion::getInstance().is8994()) {
         return getPipe_8994(pipeSpecs);
+    } else if(MDPVersion::getInstance().is8992()) {
+        return getPipe_8992(pipeSpecs);
     }
 
     eDest dest = OV_INVALID;
@@ -251,6 +253,13 @@
     //supported since we at least need 1 round in between where the DMA is
     //unused
     eDest dest = OV_INVALID;
+
+    // Reset format type to FORMAT_NONE to select the pipe irrespective of the
+    // format specifed by the client. This is required for the device where
+    // SMP starvation is unlikely, we need not keep track of formats
+    // programmed in the pipes to avoid potential pipe crunching.
+    resetPipeBookFormat(pipeSpecs.dpy);
+
     if(pipeSpecs.formatClass == FORMAT_YUV) {
         return nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
     } else {
@@ -262,9 +271,14 @@
             dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs);
         }
     }
+
     return dest;
 }
 
+utils::eDest Overlay::getPipe_8992(const PipeSpecs& pipeSpecs) {
+    return getPipe_8994(pipeSpecs);
+}
+
 void Overlay::endAllSessions() {
     for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
         if(mPipeBook[i].valid() && mPipeBook[i].mSession==PipeBook::START)
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index 45b5e57..49be930 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -178,6 +178,9 @@
     utils::eDest getPipe_8x16(const PipeSpecs& pipeSpecs);
     utils::eDest getPipe_8x39(const PipeSpecs& pipeSpecs);
     utils::eDest getPipe_8994(const PipeSpecs& pipeSpecs);
+    utils::eDest getPipe_8992(const PipeSpecs& pipeSpecs);
+
+    void resetPipeBookFormat(const int &dpy);
 
     /* Returns the handle to libscale.so's programScale function */
     static int (*getFnProgramScale())(struct mdp_overlay_list *);
@@ -443,6 +446,14 @@
     return "Invalid";
 }
 
+inline void Overlay::resetPipeBookFormat(const int &dpy) {
+    for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
+        if (mPipeBook[i].mDisplay == dpy) {
+            mPipeBook[i].mFormatType = FORMAT_NONE;
+        }
+    }
+}
+
 }; // overlay
 
 #endif // OVERLAY_H
diff --git a/libqdutils/mdp_version.cpp b/libqdutils/mdp_version.cpp
index 402e129..e045918 100644
--- a/libqdutils/mdp_version.cpp
+++ b/libqdutils/mdp_version.cpp
@@ -501,6 +501,10 @@
             mMdpRev < MDSS_MDP_HW_REV_109);
 }
 
+bool MDPVersion::is8992() {
+    return ((mMdpRev >= MDSS_MDP_HW_REV_110 and
+            mMdpRev < MDSS_MDP_HW_REV_200));
+}
 
 }; //namespace qdutils
 
diff --git a/libqdutils/mdp_version.h b/libqdutils/mdp_version.h
index 3b10010..aeb2218 100644
--- a/libqdutils/mdp_version.h
+++ b/libqdutils/mdp_version.h
@@ -151,6 +151,7 @@
     bool is8994();
     bool is8x16();
     bool is8x39();
+    bool is8992();
 
 private:
     bool updateSysFsInfo();