diff options
author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2021-07-26 10:42:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-26 10:42:48 +0300 |
commit | 54f591ec0de61dd192baf781c9b2ec87d5b461f7 (patch) | |
tree | ffa4b6142b0b56c57ea73259a4fc054894acd723 /py | |
parent | 5afc8d918f2c084acd65027604868dfde43395cf (diff) | |
parent | 3d2cde2851e7631ad3454d8371f74e2bc2e7f206 (diff) |
Merge pull request #63 from notro/gud
Add partial fb flushing and expose some more properties in the python bindings
Diffstat (limited to 'py')
-rw-r--r-- | py/pykms/pykmsbase.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp index 382ef6f..088d267 100644 --- a/py/pykms/pykmsbase.cpp +++ b/py/pykms/pykmsbase.cpp @@ -46,6 +46,10 @@ void init_pykmsbase(py::module& m) return convert_vector(self->get_planes()); }) + .def_property_readonly("properties", [](Card* self) { + return convert_vector(self->get_properties()); + }) + .def_property_readonly("has_atomic", &Card::has_atomic) .def("get_prop", (Property * (Card::*)(uint32_t) const) & Card::get_prop) @@ -116,7 +120,20 @@ void init_pykmsbase(py::module& m) py::class_<Property, DrmObject, unique_ptr<Property, py::nodelete>>(m, "Property") .def_property_readonly("name", &Property::name) - .def_property_readonly("enums", &Property::get_enums); + .def_property_readonly("type", &Property::type) + .def_property_readonly("enums", &Property::get_enums) + .def_property_readonly("values", &Property::get_values) + .def("__repr__", [](const Property& o) { return "<pykms.Property " + to_string(o.id()) + " '" + o.name() + "'>"; }) + ; + + py::enum_<PropertyType>(m, "PropertyType") + .value("Range", PropertyType::Range) + .value("Enum", PropertyType::Enum) + .value("Blob", PropertyType::Blob) + .value("Bitmask", PropertyType::Bitmask) + .value("Object", PropertyType::Object) + .value("SignedRange", PropertyType::SignedRange) + ; py::class_<Blob>(m, "Blob") .def(py::init([](Card& card, py::buffer buf) { @@ -148,6 +165,9 @@ void init_pykmsbase(py::module& m) .def("offset", &Framebuffer::offset) .def("fd", &Framebuffer::prime_fd) + .def("flush", (void (Framebuffer::*)(void)) & Framebuffer::flush) + .def("flush", (void (Framebuffer::*)(uint32_t x, uint32_t y, uint32_t width, uint32_t height)) & Framebuffer::flush) + // XXX pybind11 doesn't support a base object (DrmObject) with custom holder-type, // and a subclass with standard holder-type. // So we just copy the DrmObject members here. @@ -161,6 +181,7 @@ void init_pykmsbase(py::module& m) py::keep_alive<1, 2>()) // Keep Card alive until this is destructed .def(py::init<Card&, uint32_t, uint32_t, PixelFormat>(), py::keep_alive<1, 2>()) // Keep Card alive until this is destructed + .def("__repr__", [](const DumbFramebuffer& o) { return "<pykms.DumbFramebuffer " + to_string(o.id()) + ">"; }) ; py::class_<DmabufFramebuffer, Framebuffer>(m, "DmabufFramebuffer") @@ -168,6 +189,7 @@ void init_pykmsbase(py::module& m) py::keep_alive<1, 2>()) // Keep Card alive until this is destructed .def(py::init<Card&, uint32_t, uint32_t, PixelFormat, vector<int>, vector<uint32_t>, vector<uint32_t>>(), py::keep_alive<1, 2>()) // Keep Card alive until this is destructed + .def("__repr__", [](const DmabufFramebuffer& o) { return "<pykms.DmabufFramebuffer " + to_string(o.id()) + ">"; }) ; py::enum_<PixelFormat>(m, "PixelFormat") |