summaryrefslogtreecommitdiff
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
parent4604b871792546498e6665989eb4a30c0a47c152 (diff)
Property: add getters
-rw-r--r--libkms++/property.cpp53
-rw-r--r--libkms++/property.h22
2 files changed, 75 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;
diff --git a/libkms++/property.h b/libkms++/property.h
index 148e325..147496e 100644
--- a/libkms++/property.h
+++ b/libkms++/property.h
@@ -1,12 +1,24 @@
#pragma once
#include "drmobject.h"
+#include <map>
+#include <vector>
namespace kms
{
struct PropertyPriv;
+enum class PropertyType
+{
+ Range,
+ Enum,
+ Blob,
+ Bitmask,
+ Object,
+ SignedRange,
+};
+
class Property : public DrmObject
{
friend class Card;
@@ -14,10 +26,20 @@ public:
const std::string& name() const;
const std::string to_str(uint64_t val) const;
+
+ bool is_immutable() const;
+ bool is_pending() const;
+
+ PropertyType type() const { return m_type; }
+ std::map<uint64_t, std::string> get_enums() const;
+ std::vector<uint64_t> get_values() const;
+ std::vector<uint32_t> get_blob_ids() const;
private:
Property(Card& card, uint32_t id);
~Property();
+ PropertyType m_type;
+
PropertyPriv* m_priv;
std::string m_name;
};