diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-03-08 10:54:33 +0200 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-03-08 15:42:47 +0200 |
commit | 38e504709494afa17d1df0d163d9a595ca729801 (patch) | |
tree | 246e77c01cb3c947bde77d83becd646218cfda76 | |
parent | 0ce7250a3c10d51375d2b51138031c64d30571bc (diff) |
add ob::set_prop_value()
-rw-r--r-- | libkms++/drmobject.cpp | 17 | ||||
-rw-r--r-- | libkms++/drmobject.h | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/libkms++/drmobject.cpp b/libkms++/drmobject.cpp index 063ae32..ed7a71d 100644 --- a/libkms++/drmobject.cpp +++ b/libkms++/drmobject.cpp @@ -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) diff --git a/libkms++/drmobject.h b/libkms++/drmobject.h index 2ff1b04..516d70e 100644 --- a/libkms++/drmobject.h +++ b/libkms++/drmobject.h @@ -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); |