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_uimirror.cpp b/libhwcomposer/hwc_uimirror.cpp
index 9cf91af..3bbe30e 100644
--- a/libhwcomposer/hwc_uimirror.cpp
+++ b/libhwcomposer/hwc_uimirror.cpp
@@ -33,7 +33,7 @@
 int getDeviceOrientation(hwc_context_t* ctx,  hwc_layer_list_t *list) {
     int orientation =  list->hwLayers[0].transform;
     if(!ctx) {
-         ALOGD_IF(HWC_UI_MIRROR, "In %s: ctx is NULL!!", __FUNCTION__);
+         ALOGE("In %s: ctx is NULL!!", __FUNCTION__);
         return -1;
     }
     for(size_t i=0; i <= list->numHwLayers;i++ )
@@ -60,6 +60,12 @@
 bool UIMirrorOverlay::prepare(hwc_context_t *ctx, hwc_layer_list_t *list) {
     sState = ovutils::OV_CLOSED;
     sIsUiMirroringOn = false;
+
+    if(!ctx->hasOverlay) {
+       ALOGD_IF(HWC_UI_MIRROR, "%s, this hw doesnt support mirroring",
+                                                               __FUNCTION__);
+       return false;
+    }
     // If external display is connected
     if(ctx->mExtDisplay->getExternalDisplay()) {
         sState = ovutils::OV_UI_MIRROR;
@@ -95,7 +101,7 @@
                 dest = ovutils::OV_PIPE0;
             }
 
-            ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_MEMORY_ID_TYPE_FB;
+            ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_FLAGS_NONE;
             /* - TODO: Secure content
                if (hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER) {
                ovutils::setMdpFlags(mdpFlags,
@@ -160,20 +166,20 @@
                 if (!ov.queueBuffer(m->framebuffer->fd, m->currentOffset,
                                                            ovutils::OV_PIPE0)) {
                     ALOGE("%s: queueBuffer failed for external", __FUNCTION__);
+                    ret = false;
                 }
                 break;
             case ovutils::OV_2D_TRUE_UI_MIRROR:
                 if (!ov.queueBuffer(m->framebuffer->fd, m->currentOffset,
                                                            ovutils::OV_PIPE2)) {
                     ALOGE("%s: queueBuffer failed for external", __FUNCTION__);
+                    ret = false;
                 }
                 break;
 
         default:
             break;
         }
-        // TODO:
-        // Call PANDISPLAY ioctl here to kickoff
     }
     return ret;
 }