display: External display refactor

- cleans up external library
- add separate library for virtual display
- process virtual updates in its separate path
  in hwc.
- Acquire blank mutex lock for one complete drawing
  cycle

Change-Id: Ib984c578464a131ecdb27ee48960f58d68b7a5a7
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index fac0c49..ecd66a6 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -385,7 +385,6 @@
 }
 
 Overlay* Overlay::sInstance = 0;
-int Overlay::sExtFbIndex = 1;
 int Overlay::sDpyFbMap[DPY_MAX] = {0, -1, -1};
 int Overlay::sDMAMode = DMA_LINE_MODE;
 int Overlay::PipeBook::NUM_PIPES = 0;
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index 63f5bf1..fea50b3 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -92,11 +92,6 @@
      * displays
      */
     bool isPipeTypeAttached(utils::eMdpPipeType type);
-    /* set the framebuffer index for external display */
-    void setExtFbNum(int fbNum);
-    /* Returns framebuffer index of the current external display */
-    /* TODO Deprecate */
-    int getExtFbNum();
     /* Returns pipe dump. Expects a NULL terminated buffer of big enough size
      * to populate.
      */
@@ -171,8 +166,6 @@
 
     /* Singleton Instance*/
     static Overlay *sInstance;
-    //TODO Deprecate
-    static int sExtFbIndex;
     static int sDpyFbMap[DPY_MAX];
     static int sDMAMode;
 };
@@ -201,14 +194,6 @@
     return avail;
 }
 
-inline void Overlay::setExtFbNum(int fbNum) {
-    sExtFbIndex = fbNum;
-}
-
-inline int Overlay::getExtFbNum() {
-    return sExtFbIndex;
-}
-
 inline void Overlay::setDMAMode(const int& mode) {
     if(mode == DMA_LINE_MODE || mode == DMA_BLOCK_MODE)
         sDMAMode = mode;
diff --git a/liboverlay/pipes/overlayGenPipe.cpp b/liboverlay/pipes/overlayGenPipe.cpp
index 0de7129..35f686c 100644
--- a/liboverlay/pipes/overlayGenPipe.cpp
+++ b/liboverlay/pipes/overlayGenPipe.cpp
@@ -47,13 +47,10 @@
     ALOGE_IF(DEBUG_OVERLAY, "GenericPipe init");
     mRotDownscaleOpt = false;
 
-    int fbNum = 0;
-    //TODO Remove the if block. What's in else block should be the standard way
-    //EXTERNAL's meaning has been overloaded in hwc to mean WFD also!
-    if(mDpy == Overlay::DPY_EXTERNAL) {
-        fbNum = Overlay::getInstance()->getExtFbNum();
-    } else if(mDpy == Overlay::DPY_WRITEBACK) {
-        fbNum = Overlay::getFbForDpy(mDpy);
+    int fbNum = Overlay::getFbForDpy(mDpy);
+    if( fbNum < 0 ) {
+        ALOGE("%s: Invalid FB for the display: %d",__FUNCTION__, mDpy);
+        return false;
     }
 
     ALOGD_IF(DEBUG_OVERLAY,"%s: mFbNum:%d",__FUNCTION__, fbNum);