hwc: Unlock prev. buffers in N+1th draw round.

Unlock previously locked overlay buffers in N+1th draw round, rather than N+2th.
This is now possible because of wait for PAN.
Provides an opportunity to improve genlock behavior.

Signed-off-by: Saurabh Shah <saurshah@codeaurora.org>

Change-Id: I13d9c39e276918c3d3d27b2f07ed486b27b58441
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index a46a172..a065834 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -81,9 +81,6 @@
     hwc_context_t* ctx = (hwc_context_t*)(dev);
     ctx->overlayInUse = false;
 
-    //Prepare is called after a vsync, so unlock previous buffers here.
-    ctx->qbuf->unlockAllPrevious();
-
     for (uint32_t i = 0; i <numDisplays; i++) {
         hwc_display_contents_1_t* list = displays[i];
         ctx->dpys[i] = list->dpy;
@@ -209,6 +206,7 @@
         if(!ctx->overlayInUse)
             ctx->mOverlay->setState(ovutils::OV_CLOSED);
     }
+    ctx->qbuf->unlockAllPrevious();
     return ret;
 }