summaryrefslogtreecommitdiff
path: root/py/pykms
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2017-09-05 11:01:17 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-09-05 11:15:28 +0300
commit95de32aa7fbb1a2da547418b296f649ee4be1feb (patch)
tree50f81d2afc63357e7cfc18e2b23b1cd67e977a72 /py/pykms
parentd6300fcfb0bc420ff30a6c8f44f9b5fe862cdb3d (diff)
py: drop the fancy event handling
Unfortunately the nice event handler added previously doesn't work: we may get multiple page-flip events, which would lead to unref'ing the passed python object multiple times, leading to memory corruption. I guess it's only possible to pass a plain int as user data to commit() and page_flip().
Diffstat (limited to 'py/pykms')
-rw-r--r--py/pykms/__init__.py2
-rw-r--r--py/pykms/pykms.cpp5
-rw-r--r--py/pykms/pykmsbase.cpp18
3 files changed, 7 insertions, 18 deletions
diff --git a/py/pykms/__init__.py b/py/pykms/__init__.py
index 3b5f743..746c917 100644
--- a/py/pykms/__init__.py
+++ b/py/pykms/__init__.py
@@ -130,7 +130,7 @@ def __card_read_events(self):
seq = vbl_tuple[3]
time = vbl_tuple[1] + vbl_tuple[2] / 1000000.0;
- udata = pykms.__ob_unpack_helper(vbl_tuple[0])
+ udata = vbl_tuple[0]
yield DrmEvent(type, seq, time, udata)
diff --git a/py/pykms/pykms.cpp b/py/pykms/pykms.cpp
index 7752f19..1e54c9b 100644
--- a/py/pykms/pykms.cpp
+++ b/py/pykms/pykms.cpp
@@ -20,11 +20,6 @@ PYBIND11_PLUGIN(pykms) {
init_pykmsbase(m);
- m.def("__ob_unpack_helper", [](uint64_t v) {
- // AtomicReq::commit or Crtc::page_flip added a ref, so we can use borrowed = false
- return py::object((PyObject*)v, false);
- });
-
init_pykmstest(m);
init_pyvid(m);
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp
index 604e07c..e53fe54 100644
--- a/py/pykms/pykmsbase.cpp
+++ b/py/pykms/pykmsbase.cpp
@@ -53,13 +53,10 @@ void init_pykmsbase(py::module &m)
.def("set_mode", &Crtc::set_mode)
.def("disable_mode", &Crtc::disable_mode)
.def("page_flip",
- [](Crtc* self, Framebuffer& fb, py::object ob)
+ [](Crtc* self, Framebuffer& fb, uint32_t data)
{
- // 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);
- })
+ self->page_flip(fb, (void*)(intptr_t)data);
+ }, py::arg("fb"), py::arg("data") = 0)
.def("set_plane", &Crtc::set_plane)
.def_property_readonly("possible_planes", &Crtc::get_possible_planes)
.def_property_readonly("primary_plane", &Crtc::get_primary_plane)
@@ -196,13 +193,10 @@ void init_pykmsbase(py::module &m)
.def("add", (void (AtomicReq::*)(DrmPropObject*, const map<string, uint64_t>&)) &AtomicReq::add)
.def("test", &AtomicReq::test, py::arg("allow_modeset") = false)
.def("commit",
- [](AtomicReq* self, py::object ob, bool allow)
+ [](AtomicReq* self, uint32_t data, bool allow)
{
- // This adds a ref to the object, and must be unpacked with __ob_unpack_helper()
- PyObject* pob = ob.ptr();
- Py_XINCREF(pob);
- return self->commit(pob, allow);
- }, py::arg("data"), py::arg("allow_modeset") = false)
+ return self->commit((void*)(intptr_t)data, allow);
+ }, py::arg("data") = 0, py::arg("allow_modeset") = false)
.def("commit_sync", &AtomicReq::commit_sync, py::arg("allow_modeset") = false)
;
}