hwc: external: Cleanup overlay objects on external disconnect.
Cleanup overlay objects and close fds when external is disconnected. Without
this, the external does not come on when cable connected-disconnected multiple
times when device is in suspended state.
Bug: 7150885 (part of the fix)
Bug: 7295979
Bug: 7150885 (partial)
Change-Id: I1ae2ce7220b9928dde332ce3644dbe671d25c7e6
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index ee9cc54..9e7da37 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -48,6 +48,13 @@
}
}
+static void onExtDisconnect(const hwc_context_t::Callbacks& priv_proc) {
+ hwc_context_t *ctx = priv_proc.ctx;
+ overlay::Overlay& ov = *(ctx->mOverlay[HWC_DISPLAY_EXTERNAL]);
+ // Set overlay state
+ ov.setState(ovutils::OV_CLOSED);
+}
+
void initContext(hwc_context_t *ctx)
{
openFramebufferDevice(ctx);
@@ -66,6 +73,9 @@
pthread_cond_init(&(ctx->vstate.cond), NULL);
ctx->vstate.enable = false;
+ ctx->priv_proc.onExtDisconnect = onExtDisconnect;
+ ctx->priv_proc.ctx = ctx;
+
ALOGI("Initializing Qualcomm Hardware Composer");
ALOGI("MDP version: %d", ctx->mMDP.version);
}
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 37708e6..d27c509 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -168,6 +168,15 @@
struct hwc_context_t {
hwc_composer_device_1_t device;
const hwc_procs_t* proc;
+
+ //Private hwc handlers
+ struct Callbacks {
+ void (*onExtDisconnect)(const Callbacks& priv_proc);
+ hwc_context_t *ctx;
+ };
+
+ Callbacks priv_proc;
+
int numHwLayers;
int overlayInUse[HWC_NUM_DISPLAY_TYPES];
@@ -199,7 +208,6 @@
mutable Locker mBlankLock;
//Vsync
struct vsync_state vstate;
-
};
#endif //HWC_UTILS_H