summaryrefslogtreecommitdiff
path: root/libkms++
diff options
context:
space:
mode:
Diffstat (limited to 'libkms++')
-rw-r--r--libkms++/property.cpp40
-rw-r--r--libkms++/property.h1
2 files changed, 41 insertions, 0 deletions
diff --git a/libkms++/property.cpp b/libkms++/property.cpp
index e01bf60..3b8a0b8 100644
--- a/libkms++/property.cpp
+++ b/libkms++/property.cpp
@@ -36,4 +36,44 @@ const string& Property::name() const
{
return m_name;
}
+
+const std::string Property::to_str(uint64_t val) const
+{
+ drmModePropertyPtr p = m_priv->drm_prop;
+ string ret;
+
+ if (p->flags & DRM_MODE_PROP_ENUM) {
+ for (int i = 0; i < p->count_enums; i++) {
+ if (p->enums[i].value == val) {
+ ret += string("\"") + p->enums[i].name + "\"";
+ break;
+ }
+ }
+ ret += " (enum: " + to_string(val) + ")";
+ } else if (p->flags & DRM_MODE_PROP_RANGE) {
+ ret += to_string(val);
+ if (p->count_values == 2)
+ ret += " [" + to_string(p->values[0]) + "-" +
+ to_string(p->values[1]) + "]";
+ else
+ ret += " <broken range>";
+ } else if (p->flags & DRM_MODE_PROP_BLOB) {
+ ret += "Blob id: " + to_string(val);
+
+ auto blob = drmModeGetPropertyBlob(card().fd(), (uint32_t) val);
+ if (blob) {
+ ret += " length: " + to_string(blob->length);
+ drmModeFreePropertyBlob(blob);
+ }
+ } else {
+ ret += to_string(val);
+ }
+
+ if (p->flags & DRM_MODE_PROP_PENDING)
+ ret += " (pendig)";
+ if (p->flags & DRM_MODE_PROP_IMMUTABLE)
+ ret += " (immutable)";
+
+ return ret;
+}
}
diff --git a/libkms++/property.h b/libkms++/property.h
index ffab8d0..4cb2653 100644
--- a/libkms++/property.h
+++ b/libkms++/property.h
@@ -15,6 +15,7 @@ public:
const std::string& name() const;
+ const std::string to_str(uint64_t val) const;
private:
Property(Card& card, uint32_t id);
~Property();