add ob::set_prop_value()
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 8 Mar 2016 08:54:33 +0000 (10:54 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 8 Mar 2016 13:42:47 +0000 (15:42 +0200)
libkms++/drmobject.cpp
libkms++/drmobject.h

index 063ae327faba5d49413055344ea7a8ffc6dc0165..ed7a71d1a2d1b15171113873013967f733ef9618 100644 (file)
@@ -58,7 +58,22 @@ uint64_t DrmObject::get_prop_value(const string& name) const
                        return m_prop_values.at(prop->id());
        }
 
-       throw invalid_argument(string(name) + ": property not found");
+       throw invalid_argument("property not found: " + name);
+}
+
+int DrmObject::set_prop_value(uint32_t id, uint64_t value)
+{
+       return drmModeObjectSetProperty(card().fd(), this->id(), this->object_type(), id, value);
+}
+
+int DrmObject::set_prop_value(const string &name, uint64_t value)
+{
+       Property* prop = card().get_prop(name);
+
+       if (prop == nullptr)
+               throw invalid_argument("property not found: " + name);
+
+       return set_prop_value(prop->id(), value);
 }
 
 void DrmObject::set_id(uint32_t id)
index 2ff1b0493543ca4b051fe83e447e20ae20327dff..516d70eb77143d30e7dab39206eb3c431d090207 100644 (file)
@@ -27,6 +27,10 @@ public:
        const std::map<uint32_t, uint64_t>& get_prop_map() const {
                return m_prop_values;
        }
+
+       int set_prop_value(uint32_t id, uint64_t value);
+       int set_prop_value(const std::string& name, uint64_t value);
+
 protected:
        DrmObject(Card& card, uint32_t object_type);
        DrmObject(Card& card, uint32_t id, uint32_t object_type, uint32_t idx = 0);