diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-06-22 12:38:30 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-07-10 19:38:37 +0300 |
commit | a706f157b86e90696808025db01de99646d51a77 (patch) | |
tree | 699133c93fab2fe8881fd51dcf53a963ab66976d /kms++/src | |
parent | b66820089b4823f82392b7a17aaf122d53e2b822 (diff) |
Fix property name lookup
Object types can have different properties with the same name, so we
need to move name-based property lookup from Card to DrmPropObject.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'kms++/src')
-rw-r--r-- | kms++/src/atomicreq.cpp | 2 | ||||
-rw-r--r-- | kms++/src/card.cpp | 10 | ||||
-rw-r--r-- | kms++/src/drmpropobject.cpp | 14 |
3 files changed, 14 insertions, 12 deletions
diff --git a/kms++/src/atomicreq.cpp b/kms++/src/atomicreq.cpp index c8dd862..f2809af 100644 --- a/kms++/src/atomicreq.cpp +++ b/kms++/src/atomicreq.cpp @@ -51,7 +51,7 @@ void AtomicReq::add(DrmPropObject* ob, Property *prop, uint64_t value) void AtomicReq::add(kms::DrmPropObject* ob, const string& prop, uint64_t value) { - add(ob, m_card.get_prop(prop), value); + add(ob, ob->get_prop(prop), value); } void AtomicReq::add(kms::DrmPropObject* ob, const map<string, uint64_t>& values) diff --git a/kms++/src/card.cpp b/kms++/src/card.cpp index 0a34d14..12bdef6 100644 --- a/kms++/src/card.cpp +++ b/kms++/src/card.cpp @@ -143,16 +143,6 @@ void Card::restore_modes() conn->restore_mode(); } -Property* Card::get_prop(const string& name) const -{ - for (auto prop : m_properties) { - if (name == prop->name()) - return prop; - } - - throw invalid_argument(string("Card property ") + name + " not found"); -} - Connector* Card::get_first_connected_connector() const { for(auto c : m_connectors) { diff --git a/kms++/src/drmpropobject.cpp b/kms++/src/drmpropobject.cpp index f2edf8b..f5a3c97 100644 --- a/kms++/src/drmpropobject.cpp +++ b/kms++/src/drmpropobject.cpp @@ -45,6 +45,18 @@ void DrmPropObject::refresh_props() drmModeFreeObjectProperties(props); } +Property* DrmPropObject::get_prop(const string& name) const +{ + for (auto pair : m_prop_values) { + auto prop = card().get_prop(pair.first); + + if (name == prop->name()) + return prop; + } + + throw invalid_argument(string("property ") + name + " not found"); +} + uint64_t DrmPropObject::get_prop_value(uint32_t id) const { return m_prop_values.at(id); @@ -75,7 +87,7 @@ int DrmPropObject::set_prop_value(uint32_t id, uint64_t value) int DrmPropObject::set_prop_value(const string &name, uint64_t value) { - Property* prop = card().get_prop(name); + Property* prop = get_prop(name); if (prop == nullptr) throw invalid_argument("property not found: " + name); |