drm_hwcomposer: Allow accessing ResourceManager from DrmDevce
This is useful for accessing the main lock from drm / compositor
related code blocks.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/drm/ResourceManager.cpp b/drm/ResourceManager.cpp
index ddf59dd..53e98dc 100644
--- a/drm/ResourceManager.cpp
+++ b/drm/ResourceManager.cpp
@@ -58,7 +58,10 @@
int path_len = property_get("vendor.hwc.drm.device", path_pattern,
"/dev/dri/card%");
if (path_pattern[path_len - 1] != '%') {
- AddDrmDevice(std::string(path_pattern));
+ auto dev = DrmDevice::CreateInstance(path_pattern, this);
+ if (dev) {
+ drms_.emplace_back(std::move(dev));
+ }
} else {
path_pattern[path_len - 1] = '\0';
for (int idx = 0;; ++idx) {
@@ -69,8 +72,9 @@
if (stat(path.str().c_str(), &buf) != 0)
break;
- if (DrmDevice::IsKMSDev(path.str().c_str())) {
- AddDrmDevice(path.str());
+ auto dev = DrmDevice::CreateInstance(path.str(), this);
+ if (dev) {
+ drms_.emplace_back(std::move(dev));
}
}
}
@@ -108,13 +112,6 @@
initialized_ = false;
}
-int ResourceManager::AddDrmDevice(const std::string &path) {
- auto drm = std::make_unique<DrmDevice>();
- int ret = drm->Init(path.c_str());
- drms_.push_back(std::move(drm));
- return ret;
-}
-
auto ResourceManager::GetTimeMonotonicNs() -> int64_t {
struct timespec ts {};
clock_gettime(CLOCK_MONOTONIC, &ts);