summaryrefslogtreecommitdiff
path: root/libkms++/property.cpp
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-03 16:37:17 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-04 22:33:53 +0300
commitac1b1691659acc41a9ffac258f9f0d09413b439d (patch)
tree6ed28463da250c66423ae75eb95319eaf81cf37c /libkms++/property.cpp
parent4604b871792546498e6665989eb4a30c0a47c152 (diff)
Property: add getters
Diffstat (limited to 'libkms++/property.cpp')
-rw-r--r--libkms++/property.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/libkms++/property.cpp b/libkms++/property.cpp
index 5ec6bfa..d4d03b6 100644
--- a/libkms++/property.cpp
+++ b/libkms++/property.cpp
@@ -19,6 +19,25 @@ Property::Property(Card& card, uint32_t id)
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()
@@ -32,6 +51,40 @@ 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<uint64_t> Property::get_values() const
+{
+ drmModePropertyPtr p = m_priv->drm_prop;
+ return vector<uint64_t>(p->values, p->values + p->count_values);
+}
+
+map<uint64_t, string> Property::get_enums() const
+{
+ drmModePropertyPtr p = m_priv->drm_prop;
+
+ map<uint64_t, string> map;
+
+ for (int i = 0; i < p->count_enums; ++i)
+ map[p->enums[i].value] = string(p->enums[i].name);
+
+ return map;
+}
+
+vector<uint32_t> Property::get_blob_ids() const
+{
+ drmModePropertyPtr p = m_priv->drm_prop;
+ return vector<uint32_t>(p->blob_ids, p->blob_ids + p->count_blobs);
+}
+
const std::string Property::to_str(uint64_t val) const
{
drmModePropertyPtr p = m_priv->drm_prop;