hwc: Extend pause/resume functionality to VDS displays

Add support to handle pause/resume for virtual displays connected
either using VDS approach.

Change-Id: Iabd01c5597f2399ccc7f83712bda1a2c1103788d
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index e51a1a4..7bc29bc 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -32,6 +32,7 @@
 #include "comptype.h"
 #include "external.h"
 #include "virtual.h"
+#include "hwc_virtual.h"
 #include "mdp_version.h"
 using namespace overlay;
 namespace qhwc {
@@ -107,53 +108,15 @@
 }
 
 void handle_pause(hwc_context_t* ctx, int dpy) {
-    {
-        Locker::Autolock _l(ctx->mDrawLock);
-        ctx->dpyAttr[dpy].isActive = true;
-        ctx->dpyAttr[dpy].isPause = true;
-        ctx->proc->invalidate(ctx->proc);
-    }
-    usleep(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period
-           * 2 / 1000);
-    // At this point all the pipes used by External have been
-    // marked as UNSET.
-    {
-        Locker::Autolock _l(ctx->mDrawLock);
-        // Perform commit to unstage the pipes.
-        if (!Overlay::displayCommit(ctx->dpyAttr[dpy].fd)) {
-            ALOGE("%s: display commit fail! for %d dpy",
-                  __FUNCTION__, dpy);
-        }
+    if(ctx->mHWCVirtual) {
+        ctx->mHWCVirtual->pause(ctx, dpy);
     }
     return;
 }
 
 void handle_resume(hwc_context_t* ctx, int dpy) {
-    //Treat Resume as Online event
-    //Since external didnt have any pipes, force primary to give up
-    //its pipes; we don't allow inter-mixer pipe transfers.
-    {
-        Locker::Autolock _l(ctx->mDrawLock);
-
-        // A dynamic resolution change (DRC) can be made for a WiFi
-        // display. In order to support the resolution change, we
-        // need to reconfigure the corresponding display attributes.
-        // Since DRC is only on WiFi display, we only need to call
-        // configure() on the VirtualDisplay device.
-        if(dpy == HWC_DISPLAY_VIRTUAL)
-            ctx->mVirtualDisplay->configure();
-
-        ctx->dpyAttr[dpy].isConfiguring = true;
-        ctx->dpyAttr[dpy].isActive = true;
-        ctx->proc->invalidate(ctx->proc);
-    }
-    usleep(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period
-           * 2 / 1000);
-    //At this point external has all the pipes it would need.
-    {
-        Locker::Autolock _l(ctx->mDrawLock);
-        ctx->dpyAttr[dpy].isPause = false;
-        ctx->proc->invalidate(ctx->proc);
+    if(ctx->mHWCVirtual) {
+        ctx->mHWCVirtual->resume(ctx, dpy);
     }
     return;
 }