From 272ff4a626d2ee2b7232e1c0fbe6b745fcb355b2 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Tue, 13 Aug 2019 15:37:50 -0400 Subject: [PATCH] graphics: hwc2on1adapter: Buffer hotplug event after display creation If the HWC2 hotplug callback has not registered we buffer this event then return, but do so too early leading to no display being created. Buffer the event and return only after creating the display so when the callback is registered we have a display for this hotplug event. Test: Hotplug a display before the HWC2 hotplug callback is registered Change-Id: I999e3fd7cbe87d12969fb2d2d82dbd956ee8d97b Signed-off-by: Andrew F. Davis --- .../2.1/utils/hwc2on1adapter/HWC2On1Adapter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/graphics/composer/2.1/utils/hwc2on1adapter/HWC2On1Adapter.cpp b/graphics/composer/2.1/utils/hwc2on1adapter/HWC2On1Adapter.cpp index 3d138f7308..8b5ebb9f78 100644 --- a/graphics/composer/2.1/utils/hwc2on1adapter/HWC2On1Adapter.cpp +++ b/graphics/composer/2.1/utils/hwc2on1adapter/HWC2On1Adapter.cpp @@ -2590,13 +2590,6 @@ void HWC2On1Adapter::hwc1Hotplug(int hwc1DisplayId, int connected) { std::unique_lock lock(mStateMutex); - // If the HWC2-side callback hasn't been registered yet, buffer this until - // it is registered - if (mCallbacks.count(Callback::Hotplug) == 0) { - mPendingHotplugs.emplace_back(hwc1DisplayId, connected); - return; - } - hwc2_display_t displayId = UINT64_MAX; if (mHwc1DisplayMap.count(hwc1DisplayId) == 0) { if (connected == 0) { @@ -2625,6 +2618,13 @@ void HWC2On1Adapter::hwc1Hotplug(int hwc1DisplayId, int connected) { mDisplays.erase(displayId); } + // If the HWC2-side callback hasn't been registered yet, buffer this until + // it is registered + if (mCallbacks.count(Callback::Hotplug) == 0) { + mPendingHotplugs.emplace_back(hwc1DisplayId, connected); + return; + } + const auto& callbackInfo = mCallbacks[Callback::Hotplug]; // Call back without the state lock held