OSDN Git Service

drm_hwcomposer: Move IsKMSDev to DrmDevice
authorRoman Stratiienko <roman.o.stratiienko@globallogic.com>
Wed, 29 Sep 2021 09:47:12 +0000 (12:47 +0300)
committerRoman Stratiienko <roman.o.stratiienko@globallogic.com>
Wed, 29 Sep 2021 09:47:12 +0000 (12:47 +0300)
IsKMSDev() is a DRM device helper, therefore DrmDevice class
is better home for it.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
drm/DrmDevice.cpp
drm/DrmDevice.h
drm/ResourceManager.cpp
drm/ResourceManager.h

index 01327f8..be648b4 100644 (file)
@@ -585,4 +585,22 @@ std::string DrmDevice::GetName() const {
   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
index dfca263..04bfe3c 100644 (file)
@@ -96,6 +96,8 @@ class DrmDevice {
     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,
index 5a5a241..c55d6b8 100644 (file)
@@ -51,7 +51,7 @@ int ResourceManager::Init() {
       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 @@ int ResourceManager::AddDrmDevice(const std::string &path) {
   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))
index 4d090ab..d9e0712 100644 (file)
@@ -43,7 +43,6 @@ class ResourceManager {
 
  private:
   int AddDrmDevice(std::string const &path);
-  static bool IsKMSDev(const char *path);
 
   int num_displays_;
   std::vector<std::unique_ptr<DrmDevice>> drms_;