From 38e504709494afa17d1df0d163d9a595ca729801 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 8 Mar 2016 10:54:33 +0200 Subject: add ob::set_prop_value() --- libkms++/drmobject.cpp | 17 ++++++++++++++++- libkms++/drmobject.h | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'libkms++') 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& 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); -- cgit v1.2.3