drm_hwcomposer: Refresh connectors on every Uevent to add MST connectors
Earlier only the physical connectors were added on init to the connectors_ vector and then hotplug handler only operated on these cached connectors. But in case of MST when new sinks are hotplugged to the downstream ports, new dynamic connectors get added. So refresh the list of connectors to remove the stale connectors and add new connectors on every uevent. This enables MST connectors hotplugged after boot. Change-Id: I9163c6a892c3604ad8e49be94d32b30af7a6dc88 Signed-off-by: Manasi Navare <navaremanasi@google.com>
This commit is contained in:
parent
025ea5bfbb
commit
7be759ccf5
3 changed files with 52 additions and 0 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "drm/DrmAtomicStateManager.h"
|
||||
#include "drm/DrmConnector.h"
|
||||
#include "drm/DrmPlane.h"
|
||||
#include "drm/ResourceManager.h"
|
||||
#include "utils/log.h"
|
||||
|
|
@ -252,6 +253,52 @@ auto DrmDevice::GetConnectors()
|
|||
return connectors_;
|
||||
}
|
||||
|
||||
auto DrmDevice::RefreshConnectors() -> void {
|
||||
auto res = MakeDrmModeResUnique(*GetFd());
|
||||
if (!res) {
|
||||
ALOGE("Failed to get DrmDevice resources");
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the stale connectors present in connectors_ but not in DRM resources
|
||||
std::set<uint32_t> conn_ids_present;
|
||||
for (auto it = begin(connectors_); it != end(connectors_);) {
|
||||
auto stale = true;
|
||||
for (int i = 0; i < res->count_connectors; ++i) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
if (it->get()->GetId() == res->connectors[i]) {
|
||||
stale = false;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
conn_ids_present.insert(res->connectors[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (stale && it->get()->GetPipeline() == nullptr) {
|
||||
it = connectors_.erase(it);
|
||||
} else {
|
||||
ALOGE_IF(stale, "Stale connector %d %s has pipeline attached",
|
||||
it->get()->GetId(), it->get()->GetName().c_str());
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
// Add new connectors in DRM resources that are not present in connectors_
|
||||
for (int i = 0; i < res->count_connectors; ++i) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
if (conn_ids_present.count(res->connectors[i]) != 0) {
|
||||
continue;
|
||||
}
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
auto conn = DrmConnector::CreateInstance(*this, res->connectors[i], i);
|
||||
if (!conn) {
|
||||
continue;
|
||||
}
|
||||
if (!conn->IsWriteback()) {
|
||||
connectors_.emplace_back(std::move(conn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto DrmDevice::GetPlanes() -> const std::vector<std::unique_ptr<DrmPlane>> & {
|
||||
return planes_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,8 @@ class DrmDevice {
|
|||
return cap_cursor_size_;
|
||||
}
|
||||
|
||||
auto RefreshConnectors() -> void;
|
||||
|
||||
private:
|
||||
explicit DrmDevice(ResourceManager *res_man, uint32_t index);
|
||||
auto Init(const char *path) -> int;
|
||||
|
|
|
|||
|
|
@ -103,6 +103,9 @@ void ResourceManager::Init() {
|
|||
|
||||
uevent_listener_->RegisterHotplugHandler([this] {
|
||||
const std::unique_lock lock(GetMainLock());
|
||||
for (auto &drm : drms_) {
|
||||
drm->RefreshConnectors();
|
||||
}
|
||||
UpdateFrontendDisplays();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue