From 17d180891f1e237ea5d25835999a8b23a6e7946d Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sat, 11 Jun 2016 20:17:35 +0300 Subject: rename dirs --- kms++/property.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 kms++/property.cpp (limited to 'kms++/property.cpp') diff --git a/kms++/property.cpp b/kms++/property.cpp new file mode 100644 index 0000000..e4390ba --- /dev/null +++ b/kms++/property.cpp @@ -0,0 +1,87 @@ +#include +#include + +#include "kms++.h" + +using namespace std; + +namespace kms +{ + +struct PropertyPriv +{ + drmModePropertyPtr drm_prop; +}; + +Property::Property(Card& card, uint32_t id) + : DrmObject(card, id, DRM_MODE_OBJECT_PROPERTY) +{ + m_priv = new PropertyPriv(); + m_priv->drm_prop = drmModeGetProperty(card.fd(), id); + m_name = m_priv->drm_prop->name; + + PropertyType t; + drmModePropertyPtr p = m_priv->drm_prop; + if (drm_property_type_is(p, DRM_MODE_PROP_BITMASK)) + t = PropertyType::Bitmask; + else if (drm_property_type_is(p, DRM_MODE_PROP_BLOB)) + t = PropertyType::Blob; + else if (drm_property_type_is(p, DRM_MODE_PROP_ENUM)) + t = PropertyType::Enum; + else if (drm_property_type_is(p, DRM_MODE_PROP_OBJECT)) + t = PropertyType::Object; + else if (drm_property_type_is(p, DRM_MODE_PROP_RANGE)) + t = PropertyType::Range; + else if (drm_property_type_is(p, DRM_MODE_PROP_SIGNED_RANGE)) + t = PropertyType::SignedRange; + else + throw invalid_argument("Invalid property type"); + + m_type = t; +} + +Property::~Property() +{ + drmModeFreeProperty(m_priv->drm_prop); + delete m_priv; +} + +const string& Property::name() const +{ + return m_name; +} + +bool Property::is_immutable() const +{ + return m_priv->drm_prop->flags & DRM_MODE_PROP_IMMUTABLE; +} + +bool Property::is_pending() const +{ + return m_priv->drm_prop->flags & DRM_MODE_PROP_PENDING; +} + +vector Property::get_values() const +{ + drmModePropertyPtr p = m_priv->drm_prop; + return vector(p->values, p->values + p->count_values); +} + +map Property::get_enums() const +{ + drmModePropertyPtr p = m_priv->drm_prop; + + map map; + + for (int i = 0; i < p->count_enums; ++i) + map[p->enums[i].value] = string(p->enums[i].name); + + return map; +} + +vector Property::get_blob_ids() const +{ + drmModePropertyPtr p = m_priv->drm_prop; + return vector(p->blob_ids, p->blob_ids + p->count_blobs); +} +} -- cgit v1.2.3