hwc2: Check for display already used by another slot
Before connecting a display at an unused slot, check if the display
is already used at another slot.
CRs-Fixed: 2200594
Change-Id: I2b4c4a73a057bac29f3a907378a0f83934a0603c
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index c209bea..1d9fc28 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -2133,6 +2133,16 @@
continue;
}
+ // Check if we are already using the display.
+ auto display_used = std::find_if(map_info_pluggable_.begin(), map_info_pluggable_.end(),
+ [&](auto &p) {
+ return (p.sdm_id == info.display_id);
+ });
+ if (display_used != map_info_pluggable_.end()) {
+ // Display is already used in a slot.
+ continue;
+ }
+
// find an empty slot to create display.
for (auto &map_info : map_info_pluggable_) {
hwc2_display_t client_id = map_info.client_id;
@@ -2142,7 +2152,7 @@
SCOPE_LOCK(locker_[client_id]);
auto &hwc_display = hwc_display_[client_id];
if (hwc_display) {
- // Display is already connected.
+ // Display slot is already used.
continue;
}
@@ -2168,7 +2178,8 @@
return status;
}
- DLOGI("Created pluggable display successfully.");
+ DLOGI("Created pluggable display successfully: sdm id = %d, client id = %d",
+ info.display_id, client_id);
}
map_info.disp_type = info.display_type;
@@ -2201,7 +2212,7 @@
}
for (auto client_id : pending_hotplugs) {
- DLOGI("Notify hotplug connected: client id = %d", client_id);
+ DLOGI("Notify hotplug display connected: client id = %d", client_id);
callbacks_.Hotplug(client_id, HWC2::Connection::Connected);
}
@@ -2223,6 +2234,7 @@
if (info.is_connected) {
disconnect = false;
}
+ break;
}
if (disconnect) {
@@ -2251,7 +2263,8 @@
return;
}
- DLOGI("Destroy display type = %d, client id = %d", map_info->disp_type, client_id);
+ DLOGI("Destroy display %d-%d, client id = %d", map_info->sdm_id, map_info->disp_type,
+ client_id);
switch (map_info->disp_type) {
case kBuiltIn:
HWCDisplayBuiltIn::Destroy(hwc_display);
@@ -2275,6 +2288,7 @@
}
if (notify_hotplug) {
+ DLOGI("Notify hotplug display disconnected: client id = %d", client_id);
callbacks_.Hotplug(client_id, HWC2::Connection::Disconnected);
}
}