hwc: Clean up ExternalDisplay class
1. Remove hwc_context_t from libexternal since this is a construct
that should only be used in libhwcomposer.
2. Clean up redundant code by creating utility functions to
a. open a sysfs node in a given mode
b. improving EDID mode storage/manipulation
c. creating/destroying composition objects
3. Add utility functions to
a. get the connected state of the external display
b. determine which interface the external display is connected to
(primary or external)
c. activate the hdmi interface by setting the resolution via an
ioctl
d. update/reset external display information when a device
connected/disconnected.
Change-Id: Iba34c9e43b39ccb9c9436deb726587bd1b26b779
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index ca6a741..f5351ce 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -39,24 +39,6 @@
#define HWC_UEVENT_SWITCH_STR "change@/devices/virtual/switch/"
#define HWC_UEVENT_THREAD_NAME "hwcUeventThread"
-static void setup(hwc_context_t* ctx, int dpy)
-{
- ctx->mFBUpdate[dpy] = IFBUpdate::getObject(ctx, dpy);
- ctx->mMDPComp[dpy] = MDPComp::getObject(ctx, dpy);
-}
-
-static void clear(hwc_context_t* ctx, int dpy)
-{
- if(ctx->mFBUpdate[dpy]) {
- delete ctx->mFBUpdate[dpy];
- ctx->mFBUpdate[dpy] = NULL;
- }
- if(ctx->mMDPComp[dpy]) {
- delete ctx->mMDPComp[dpy];
- ctx->mMDPComp[dpy] = NULL;
- }
-}
-
/* Parse uevent data for devices which we are interested */
static int getConnectedDisplay(const char* strUdata)
{
@@ -143,17 +125,13 @@
}
ctx->mDrawLock.lock();
- clear(ctx, dpy);
- ctx->dpyAttr[dpy].connected = false;
- ctx->dpyAttr[dpy].isActive = false;
- /* If disconnect comes before any composition cycle */
- ctx->dpyAttr[dpy].isConfiguring = false;
-
+ destroyCompositionResources(ctx, dpy);
if(dpy == HWC_DISPLAY_EXTERNAL) {
ctx->mExtDisplay->teardown();
} else {
ctx->mVirtualDisplay->teardown();
}
+ resetDisplayInfo(ctx, dpy);
ctx->mDrawLock.unlock();
/* We need to send hotplug to SF only when we are disconnecting
@@ -199,7 +177,7 @@
"when WFD is active");
{
Locker::Autolock _l(ctx->mDrawLock);
- clear(ctx, HWC_DISPLAY_VIRTUAL);
+ destroyCompositionResources(ctx, HWC_DISPLAY_VIRTUAL);
ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected = false;
ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isActive = false;
}
@@ -229,6 +207,10 @@
ctx->mWfdSyncLock.unlock();
}
ctx->mExtDisplay->configure();
+ ctx->mExtDisplay->activateDisplay();
+ ctx->mDrawLock.lock();
+ updateDisplayInfo(ctx, dpy);
+ ctx->mDrawLock.unlock();
} else {
{
Locker::Autolock _l(ctx->mDrawLock);
@@ -247,7 +229,7 @@
}
ctx->mDrawLock.lock();
- setup(ctx, dpy);
+ initCompositionResources(ctx, dpy);
ctx->dpyAttr[dpy].isPause = false;
ctx->dpyAttr[dpy].connected = true;
ctx->dpyAttr[dpy].isConfiguring = true;