hwc: qbuf: Add API to unlock all

Add API to unlock all current and previous buffers.
This is essential in suspend cases.

Change-Id: I61c26db2e0e2b3e5e7f526a62a56424a8632f1d8
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 05bb61d..00635c5 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -195,7 +195,7 @@
                 ctx->mExtDisplay->commit();
         } else {
             ctx->mOverlay->setState(ovutils::OV_CLOSED);
-            ctx->qbuf->unlockAllPrevious();
+            ctx->qbuf->unlockAll();
         }
 
         if(!ctx->overlayInUse)
diff --git a/libhwcomposer/hwc_qbuf.h b/libhwcomposer/hwc_qbuf.h
index 6d75964..0e639cf 100644
--- a/libhwcomposer/hwc_qbuf.h
+++ b/libhwcomposer/hwc_qbuf.h
@@ -33,7 +33,10 @@
     }
     ~QueuedBufferStore() {}
     void lockAndAdd(private_handle_t*);
+    //Unlocks only previous and makes the current as previous
     void unlockAllPrevious();
+    //Unlocks previous as well as current, useful in suspend case
+    void unlockAll();
 
     private:
     QueuedBufferStore& operator=(const QueuedBufferStore&);
@@ -70,6 +73,13 @@
     clearCurrent();
 }
 
+inline void QueuedBufferStore::unlockAll() {
+    //Unlocks prev and moves current to prev
+    unlockAllPrevious();
+    //Unlocks the newly populated prev if any.
+    unlockAllPrevious();
+}
+
 //Clear currentbuf store
 inline void QueuedBufferStore::clearCurrent() {
     for(int i = 0; i < MAX_QUEUED_BUFS; i++)