summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2021-07-26 10:42:48 +0300
committerGitHub <noreply@github.com>2021-07-26 10:42:48 +0300
commit54f591ec0de61dd192baf781c9b2ec87d5b461f7 (patch)
treeffa4b6142b0b56c57ea73259a4fc054894acd723
parent5afc8d918f2c084acd65027604868dfde43395cf (diff)
parent3d2cde2851e7631ad3454d8371f74e2bc2e7f206 (diff)
Merge pull request #63 from notro/gud
Add partial fb flushing and expose some more properties in the python bindings
-rw-r--r--kms++/inc/kms++/framebuffer.h1
-rw-r--r--kms++/src/framebuffer.cpp11
-rw-r--r--py/pykms/pykmsbase.cpp24
3 files changed, 35 insertions, 1 deletions
diff --git a/kms++/inc/kms++/framebuffer.h b/kms++/inc/kms++/framebuffer.h
index 6f77b98..1bd477c 100644
--- a/kms++/inc/kms++/framebuffer.h
+++ b/kms++/inc/kms++/framebuffer.h
@@ -41,6 +41,7 @@ public:
uint32_t width() const override { return m_width; }
uint32_t height() const override { return m_height; }
+ void flush(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
void flush();
protected:
diff --git a/kms++/src/framebuffer.cpp b/kms++/src/framebuffer.cpp
index f1cba3b..72e1a73 100644
--- a/kms++/src/framebuffer.cpp
+++ b/kms++/src/framebuffer.cpp
@@ -34,6 +34,17 @@ Framebuffer::Framebuffer(Card& card, uint32_t id)
card.m_framebuffers.push_back(this);
}
+void Framebuffer::flush(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
+{
+ drmModeClip clip{};
+ clip.x1 = x;
+ clip.y1 = y;
+ clip.x2 = x + width;
+ clip.y2 = y + height;
+
+ drmModeDirtyFB(card().fd(), id(), &clip, 1);
+}
+
void Framebuffer::flush()
{
drmModeClip clip{};
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")