Skip to content

Commit

Permalink
platforms/common: Add missing mgk::ObjectProperties implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
RAOF committed Aug 5, 2024
1 parent 1a04ed1 commit 9beaf4e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/platforms/common/server/kms-utils/drm_mode_resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand All @@ -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;
Expand All @@ -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<std::string, Prop>::const_iterator
{
return properties_table.begin();
Expand Down
5 changes: 5 additions & 0 deletions src/platforms/common/server/kms-utils/drm_mode_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ class ObjectProperties
std::unordered_map<std::string, Prop>::const_iterator begin() const;
std::unordered_map<std::string, Prop>::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<std::string, Prop> const properties_table;
};

Expand Down

0 comments on commit 9beaf4e

Please sign in to comment.