drm_hwcomposer: Move IsKMSDev to DrmDevice
IsKMSDev() is a DRM device helper, therefore DrmDevice class
is better home for it.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/drm/DrmDevice.cpp b/drm/DrmDevice.cpp
index 01327f8..be648b4 100644
--- a/drm/DrmDevice.cpp
+++ b/drm/DrmDevice.cpp
@@ -585,4 +585,22 @@
drmFreeVersion(ver);
return name;
}
+
+auto DrmDevice::IsKMSDev(const char *path) -> bool {
+ auto fd = UniqueFd(open(path, O_RDWR | O_CLOEXEC));
+ if (!fd) {
+ return false;
+ }
+
+ auto res = MakeDrmModeResUnique(fd.Get());
+ if (!res) {
+ return false;
+ }
+
+ bool is_kms = res->count_crtcs > 0 && res->count_connectors > 0 &&
+ res->count_encoders > 0;
+
+ return is_kms;
+}
+
} // namespace android
diff --git a/drm/DrmDevice.h b/drm/DrmDevice.h
index dfca263..04bfe3c 100644
--- a/drm/DrmDevice.h
+++ b/drm/DrmDevice.h
@@ -96,6 +96,8 @@
return *mDrmFbImporter.get();
}
+ static auto IsKMSDev(const char *path) -> bool;
+
private:
int TryEncoderForDisplay(int display, DrmEncoder *enc);
int GetProperty(uint32_t obj_id, uint32_t obj_type, const char *prop_name,
diff --git a/drm/ResourceManager.cpp b/drm/ResourceManager.cpp
index 5a5a241..c55d6b8 100644
--- a/drm/ResourceManager.cpp
+++ b/drm/ResourceManager.cpp
@@ -51,7 +51,7 @@
if (stat(path.str().c_str(), &buf))
break;
- if (IsKMSDev(path.str().c_str()))
+ if (DrmDevice::IsKMSDev(path.str().c_str()))
ret = AddDrmDevice(path.str());
}
}
@@ -83,23 +83,6 @@
return ret;
}
-bool ResourceManager::IsKMSDev(const char *path) {
- auto fd = UniqueFd(open(path, O_RDWR | O_CLOEXEC));
- if (!fd) {
- return false;
- }
-
- auto res = MakeDrmModeResUnique(fd.Get());
- if (!res) {
- return false;
- }
-
- bool is_kms = res->count_crtcs > 0 && res->count_connectors > 0 &&
- res->count_encoders > 0;
-
- return is_kms;
-}
-
DrmDevice *ResourceManager::GetDrmDevice(int display) {
for (auto &drm : drms_) {
if (drm->HandlesDisplay(display))
diff --git a/drm/ResourceManager.h b/drm/ResourceManager.h
index 4d090ab..d9e0712 100644
--- a/drm/ResourceManager.h
+++ b/drm/ResourceManager.h
@@ -43,7 +43,6 @@
private:
int AddDrmDevice(std::string const &path);
- static bool IsKMSDev(const char *path);
int num_displays_;
std::vector<std::unique_ptr<DrmDevice>> drms_;