]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/commitdiff
Fix property name lookup
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 22 Jun 2016 09:38:30 +0000 (12:38 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Sun, 10 Jul 2016 16:38:37 +0000 (19:38 +0300)
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>
kms++/inc/kms++/card.h
kms++/inc/kms++/drmpropobject.h
kms++/src/atomicreq.cpp
kms++/src/card.cpp
kms++/src/drmpropobject.cpp
py/pykmsbase.cpp

index 5ecaecf429560ab18a0ec82855754d36a3397294..09c9bbafcc0897238331367bce4aee4185d42f66 100644 (file)
@@ -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;
        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; }
 
        bool master() const { return m_master; }
        bool has_atomic() const { return m_has_atomic; }
index ec28d45ea08d52d44f7f0ba83d96c1da9479d498..38de584fbca20bf59910d5b175b8d5aed5927b46 100644 (file)
@@ -14,6 +14,9 @@ class DrmPropObject : public DrmObject
        friend class Card;
 public:
        void refresh_props();
        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;
        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;
index c8dd86284322c00a61a532c32049c90f3f3fa90f..f2809afefeea14383fd26c64ec4628ec3c988538 100644 (file)
@@ -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)
 {
 
 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)
 }
 
 void AtomicReq::add(kms::DrmPropObject* ob, const map<string, uint64_t>& values)
index 0a34d14222ebd71629183cf8becd7c0754aaa580..12bdef6173f29b592d64b875bd00ca3d43f071ee 100644 (file)
@@ -143,16 +143,6 @@ void Card::restore_modes()
                conn->restore_mode();
 }
 
                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) {
 Connector* Card::get_first_connected_connector() const
 {
        for(auto c : m_connectors) {
index f2edf8bbfe30a883b9bcf26b5621b15886d166e1..f5a3c978b4dd28da9636b66b53d42642f0c94235 100644 (file)
@@ -45,6 +45,18 @@ void DrmPropObject::refresh_props()
        drmModeFreeObjectProperties(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);
 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)
 {
 
 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);
 
        if (prop == nullptr)
                throw invalid_argument("property not found: " + name);
index 4dbcd7e1b691093a336271ebe5f1691b8bf61425..637e4f59cdc7e896b1ca21f69fe1f3c6a14c7dc3 100644 (file)
@@ -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_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")
                        ;
 
        py::class_<DrmObject, DrmObject*>(m, "DrmObject")