diff options
author | Pritama Biswas <pritbisw@codeaurora.org> | 2021-10-21 16:17:00 +0530 |
---|---|---|
committer | Pritama Biswas <pritbisw@codeaurora.org> | 2021-10-26 17:54:05 +0530 |
commit | d7fe61498c28f3729ae27ee39d215489c8a24457 (patch) | |
tree | 31cfb8521a3ed2fd58a3f29324c4e051ccd10685 | |
parent | 533cb619ee8e9a5727320e56046a04784c8bc0aa (diff) |
hwc: Deallocate resources when display is disconnected
Change-Id: I0581b19461122cec5c459ca7d3f7c285f1cb90b1
-rw-r--r-- | sdm/libs/hwc2/hwc_session.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp index 794ebc33..209790ed 100644 --- a/sdm/libs/hwc2/hwc_session.cpp +++ b/sdm/libs/hwc2/hwc_session.cpp @@ -858,12 +858,14 @@ int32_t HWCSession::RegisterCallback(hwc2_device_t *device, int32_t descriptor, if (hwc_session->HandleBuiltInDisplays()) { DLOGW("Failed handling built-in displays."); } - DLOGI("Handling pluggable displays..."); - int32_t err = hwc_session->HandlePluggableDisplays(false); - if (err) { - DLOGW("All displays could not be created. Error %d '%s'. Hotplug handling %s.", err, - strerror(abs(err)), hwc_session->hotplug_pending_event_ == kHotPlugEvent ? "deferred" : - "dropped"); + if(!hwc_session->pluggable_is_primary_) { + DLOGI("Handling pluggable displays..."); + int32_t err = hwc_session->HandlePluggableDisplays(false); + if (err) { + DLOGW("All displays could not be created. Error %d '%s'. Hotplug handling %s.", err, + strerror(abs(err)), hwc_session->hotplug_pending_event_ == kHotPlugEvent ? + "deferred" : "dropped"); + } } // If previously registered, call hotplug for all connected displays to refresh @@ -2940,6 +2942,22 @@ bool HWCSession::HasHDRSupport(HWCDisplay *hwc_display) { } int HWCSession::HandleDisconnectedDisplays(HWDisplaysInfo *hw_displays_info) { + if (pluggable_is_primary_) { + bool disconnect = true; + DisplayMapInfo map_info = map_info_primary_; + for (auto &iter : *hw_displays_info) { + auto &info = iter.second; + if (info.display_id != map_info.sdm_id) { + continue; + } + if (info.is_connected) { + disconnect = false; + } + } + if (disconnect) { + DestroyDisplay(&map_info); + } + } // Destroy pluggable displays which were connected earlier but got disconnected now. for (auto &map_info : map_info_pluggable_) { bool disconnect = true; // disconnect in case display id is not found in list. |