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/DrmDevice.cpp b/drm/DrmDevice.cpp
index fd4589e..5e160d4 100644
--- a/drm/DrmDevice.cpp
+++ b/drm/DrmDevice.cpp
@@ -28,12 +28,29 @@
#include "drm/DrmAtomicStateManager.h"
#include "drm/DrmPlane.h"
+#include "drm/ResourceManager.h"
#include "utils/log.h"
#include "utils/properties.h"
namespace android {
-DrmDevice::DrmDevice() {
+auto DrmDevice::CreateInstance(std::string const &path,
+ ResourceManager *res_man)
+ -> std::unique_ptr<DrmDevice> {
+ if (!IsKMSDev(path.c_str())) {
+ return {};
+ }
+
+ auto device = std::unique_ptr<DrmDevice>(new DrmDevice(res_man));
+
+ if (device->Init(path.c_str()) != 0) {
+ return {};
+ }
+
+ return device;
+}
+
+DrmDevice::DrmDevice(ResourceManager *res_man) : res_man_(res_man) {
drm_fb_importer_ = std::make_unique<DrmFbImporter>(*this);
}