hwc: enable vsync for external display

- wait for hdmi vsync when connected to hdmi
- add commit to call PANDISPLAY for updating ext display
- add functions to close fb and reset info

Change-Id: I49afbeb85935b111055a872b29a1f65d87ab72c9
Acked-by: Arun Kumar K.R <akumarkr@codeaurora.org>
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index c0bca9d..ba87f90 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -29,6 +29,7 @@
 #include "hwc_video.h"
 #include "hwc_uimirror.h"
 #include "hwc_copybit.h"
+#include "hwc_external.h"
 
 using namespace qhwc;
 
@@ -108,6 +109,10 @@
         case HWC_EVENT_VSYNC:
             if(ioctl(m->framebuffer->fd, MSMFB_OVERLAY_VSYNC_CTRL, &enabled) < 0)
                 ret = -errno;
+
+            if(ctx->mExtDisplay->getExternalDisplay()) {
+                ret = ctx->mExtDisplay->enableHDMIVsync(enabled);
+            }
            break;
         default:
             ret = -EINVAL;
@@ -150,6 +155,8 @@
         CopyBit::draw(ctx, list, (EGLDisplay)dpy, (EGLSurface)sur);
         EGLBoolean sucess = eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur);
         UIMirrorOverlay::draw(ctx);
+        if(ctx->mExtDisplay->getExternalDisplay())
+           ctx->mExtDisplay->commit();
     } else {
         ctx->mOverlay->setState(ovutils::OV_CLOSED);
         ctx->qbuf->unlockAllPrevious();