diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2017-03-08 12:11:11 +0200 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2017-03-08 12:56:29 +0200 |
commit | 84e240f64014f1e27dc1b3769f5ea83046f683d0 (patch) | |
tree | a44f0714ef3535d270b1b119e14be7532d2eaa0f /py/pykms/pykmsbase.cpp | |
parent | c02a6e019ef4f2a77fcbde67a720221c7f37225e (diff) |
New event handling
The current event handling relies on the PageFlipHandlerBase class which
has to be implemented on the python side.
This patch implements a more versatile event handling, where any python
object can be passed as data to the commit or page flip, and it's up to
the python implementation to decide what to do with that data when
receiving the event.
Note that when doing the commit or page_flip, the ref count of the
given python object is incremented to keep it alive. The ref count is
decremented when reading the events with the new helper method
card.read_events(). This helper _has_ to be used to ensure the objects
get released properly.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'py/pykms/pykmsbase.cpp')
-rw-r--r-- | py/pykms/pykmsbase.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp index 0d5bb86..1cc91d8 100644 --- a/py/pykms/pykmsbase.cpp +++ b/py/pykms/pykmsbase.cpp @@ -18,7 +18,6 @@ void init_pykmsbase(py::module &m) .def_property_readonly("encoders", &Card::get_encoders) .def_property_readonly("planes", &Card::get_planes) .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) ; @@ -49,7 +48,14 @@ void init_pykmsbase(py::module &m) py::class_<Crtc, Crtc*>(m, "Crtc", py::base<DrmPropObject>()) .def("set_mode", &Crtc::set_mode) - .def("page_flip", &Crtc::page_flip) + .def("page_flip", + [](Crtc* self, Framebuffer& fb, py::object ob) + { + // This adds a ref to the object, and must be unpacked with __ob_unpack_helper() + PyObject* pob = ob.ptr(); + Py_XINCREF(pob); + self->page_flip(fb, pob); + }) .def("set_plane", &Crtc::set_plane) .def_property_readonly("possible_planes", &Crtc::get_possible_planes) .def_property_readonly("primary_plane", &Crtc::get_primary_plane) @@ -167,7 +173,14 @@ void init_pykmsbase(py::module &m) .def("add", (void (AtomicReq::*)(DrmPropObject*, const string&, uint64_t)) &AtomicReq::add) .def("add", (void (AtomicReq::*)(DrmPropObject*, const map<string, uint64_t>&)) &AtomicReq::add) .def("test", &AtomicReq::test, py::arg("allow_modeset") = false) - .def("commit", &AtomicReq::commit, py::arg("data"), py::arg("allow_modeset") = false) + .def("commit", + [](AtomicReq* self, py::object ob, bool allow) + { + // This adds a ref to the object, and must be unpacked with __ob_unpack_helper() + PyObject* pob = ob.ptr(); + Py_XINCREF(pob); + self->commit(pob, allow); + }, py::arg("data"), py::arg("allow_modeset") = false) .def("commit_sync", &AtomicReq::commit_sync, py::arg("allow_modeset") = false) ; } |