From 9beaf4ead91f3d161e6e7c6606dc6195a019a3ec Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Mon, 5 Aug 2024 13:05:59 +1000 Subject: [PATCH] platforms/common: Add missing `mgk::ObjectProperties` implementations --- .../server/kms-utils/drm_mode_resources.cpp | 22 ++++++++++++++++++- .../server/kms-utils/drm_mode_resources.h | 5 +++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/platforms/common/server/kms-utils/drm_mode_resources.cpp b/src/platforms/common/server/kms-utils/drm_mode_resources.cpp index d6c9e51825e..fd179d84018 100644 --- a/src/platforms/common/server/kms-utils/drm_mode_resources.cpp +++ b/src/platforms/common/server/kms-utils/drm_mode_resources.cpp @@ -271,7 +271,15 @@ mgk::ObjectProperties::ObjectProperties( int drm_fd, uint32_t object_id, uint32_t object_type) - : properties_table{extract_properties(drm_fd, get_object_properties(drm_fd, object_id, object_type))} + : parent_id_{object_id}, + properties_table{extract_properties(drm_fd, get_object_properties(drm_fd, object_id, object_type))} +{ +} + +mgk::ObjectProperties::ObjectProperties( + int drm_fd, + DRMModeCrtcUPtr const& crtc) + : ObjectProperties(drm_fd, crtc->crtc_id, DRM_MODE_OBJECT_CRTC) { } @@ -282,6 +290,13 @@ mgk::ObjectProperties::ObjectProperties( { } +mgk::ObjectProperties::ObjectProperties( + int drm_fd, + DRMModeConnectorUPtr const& connector) + : ObjectProperties(drm_fd, connector->connector_id, DRM_MODE_OBJECT_CONNECTOR) +{ +} + uint64_t mgk::ObjectProperties::operator[](char const* name) const { return properties_table.at(name).value; @@ -297,6 +312,11 @@ bool mgk::ObjectProperties::has_property(char const* property_name) const return properties_table.count(property_name) > 0; } +uint32_t mgk::ObjectProperties::parent_id() const +{ + return parent_id_; +} + auto mgk::ObjectProperties::begin() const -> std::unordered_map::const_iterator { return properties_table.begin(); diff --git a/src/platforms/common/server/kms-utils/drm_mode_resources.h b/src/platforms/common/server/kms-utils/drm_mode_resources.h index 410f6b4b8d1..986fa370bef 100644 --- a/src/platforms/common/server/kms-utils/drm_mode_resources.h +++ b/src/platforms/common/server/kms-utils/drm_mode_resources.h @@ -120,7 +120,12 @@ class ObjectProperties std::unordered_map::const_iterator begin() const; std::unordered_map::const_iterator end() const; + /** + * The ID of the DRM object these properties relate to + */ + uint32_t parent_id() const; private: + uint32_t const parent_id_; std::unordered_map const properties_table; };