hwc: enable dual display on hwc 1.1

Enable dual display on HWC 1.1; video uses overlay.

Bug: 7124159
Change-Id: I8333e46cfc74072f6259fba2b82368f0dd52b6df
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libexternal/external.cpp b/libexternal/external.cpp
index 92a129b..c4f9aeb 100644
--- a/libexternal/external.cpp
+++ b/libexternal/external.cpp
@@ -382,23 +382,6 @@
         }
         mCurrentMode = ID;
     }
-    //Powerup
-    ret = ioctl(mFd, FBIOBLANK, FB_BLANK_UNBLANK);
-    if(ret < 0) {
-        ALOGD("In %s: FBIOBLANK failed Err Str = %s", __FUNCTION__,
-                                                            strerror(errno));
-    }
-    ret = ioctl(mFd, FBIOGET_VSCREENINFO, &mVInfo);
-    if(ret < 0) {
-        ALOGD("In %s: FBIOGET_VSCREENINFO failed Err Str = %s", __FUNCTION__,
-                                                            strerror(errno));
-    }
-    //Pan_Display
-    ret = ioctl(mFd, FBIOPAN_DISPLAY, &mVInfo);
-    if(ret < 0) {
-        ALOGD("In %s: FBIOPAN_DISPLAY  failed Err Str = %s", __FUNCTION__,
-                                                            strerror(errno));
-    }
 }
 
 void ExternalDisplay::setExternalDisplay(int connected)
@@ -411,7 +394,7 @@
         if(connected) {
             readResolution();
             //Get the best mode and set
-            // TODO: DO NOT call this for WFD
+            // TODO: Move this to activate
             setResolution(getBestMode());
             setDpyAttr();
             //enable hdmi vsync
@@ -422,17 +405,16 @@
         }
         // Store the external display
         mExternalDisplay = connected;
-        ALOGD_IF(DEBUG, "In %s: mExternalDisplay = %d", __FUNCTION__,
-                                                         mExternalDisplay);
         const char* prop = (connected) ? "1" : "0";
         // set system property
         property_set("hw.hdmiON", prop);
-        //Inform SF
+        ALOGD("%s sending hotplug: connected = %d", __FUNCTION__,connected);
+        //Inform SF. Disabled until SF calls unblank
         ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isActive = false;
-        //TODO remove invalidate send hotplug
-        //ctx->proc->hotplug(ctx->proc, HWC_DISPLAY_EXTERNAL, connected);
-        ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isActive = connected;
-        ctx->proc->invalidate(ctx->proc);
+        ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected = connected;
+
+        //TODO ideally should be done on "connected" not "online"
+        ctx->proc->hotplug(ctx->proc, HWC_DISPLAY_EXTERNAL, connected);
     }
     return;
 }
@@ -484,10 +466,11 @@
     int width = 0, height = 0, fps = 0;
     getAttrForMode(width, height, fps);
     if(mHwcContext) {
+        ALOGD("ExtDisplay setting xres = %d, yres = %d", width, height);
         mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].xres = width;
         mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].yres = height;
-        mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].vsync_period = 1000000000l /
-        fps;
+        mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].vsync_period =
+            1000000000l / fps;
     }
 }