summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-22 12:38:30 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-07-10 19:38:37 +0300
commita706f157b86e90696808025db01de99646d51a77 (patch)
tree699133c93fab2fe8881fd51dcf53a963ab66976d
parentb66820089b4823f82392b7a17aaf122d53e2b822 (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>
-rw-r--r--kms++/inc/kms++/card.h1
-rw-r--r--kms++/inc/kms++/drmpropobject.h3
-rw-r--r--kms++/src/atomicreq.cpp2
-rw-r--r--kms++/src/card.cpp10
-rw-r--r--kms++/src/drmpropobject.cpp14
-rw-r--r--py/pykmsbase.cpp1
6 files changed, 17 insertions, 14 deletions
diff --git a/kms++/inc/kms++/card.h b/kms++/inc/kms++/card.h
index 5ecaecf..09c9bba 100644
--- a/kms++/inc/kms++/card.h
+++ b/kms++/inc/kms++/card.h
@@ -32,7 +32,6 @@ public:
Encoder* get_encoder(uint32_t id) const;
Plane* get_plane(uint32_t id) const;
Property* get_prop(uint32_t id) const;
- Property* get_prop(const std::string& name) const;
bool master() const { return m_master; }
bool has_atomic() const { return m_has_atomic; }
diff --git a/kms++/inc/kms++/drmpropobject.h b/kms++/inc/kms++/drmpropobject.h
index ec28d45..38de584 100644
--- a/kms++/inc/kms++/drmpropobject.h
+++ b/kms++/inc/kms++/drmpropobject.h
@@ -14,6 +14,9 @@ class DrmPropObject : public DrmObject
friend class Card;
public:
void refresh_props();
+
+ Property* get_prop(const std::string& name) const;
+
uint64_t get_prop_value(uint32_t id) const;
uint64_t get_prop_value(const std::string& name) const;
std::unique_ptr<Blob> get_prop_value_as_blob(const std::string& name) const;
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);
diff --git a/py/pykmsbase.cpp b/py/pykmsbase.cpp
index 4dbcd7e..637e4f5 100644
--- a/py/pykmsbase.cpp
+++ b/py/pykmsbase.cpp
@@ -20,7 +20,6 @@ void init_pykmsbase(py::module &m)
.def_property_readonly("has_atomic", &Card::has_atomic)
.def("call_page_flip_handlers", &Card::call_page_flip_handlers)
.def("get_prop", (Property* (Card::*)(uint32_t) const)&Card::get_prop)
- .def("get_prop", (Property* (Card::*)(const string&) const)&Card::get_prop)
;
py::class_<DrmObject, DrmObject*>(m, "DrmObject")