summaryrefslogtreecommitdiff
path: root/py/pykms
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2020-10-07 08:58:35 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2020-10-09 15:54:43 +0300
commitd9a1ffe56d0beb9cdd048d0e83f7d0177b31411a (patch)
tree6227b71ee23bfa344b4cd5896ec485409158a0bc /py/pykms
parent37d27443432b7b84d256bd5a7c505e7ef8e09bbd (diff)
Bulk format of all files
Diffstat (limited to 'py/pykms')
-rw-r--r--py/pykms/pykms.cpp11
-rw-r--r--py/pykms/pykmsbase.cpp413
-rw-r--r--py/pykms/pykmsomap.cpp41
-rw-r--r--py/pykms/pykmsutil.cpp79
-rw-r--r--py/pykms/pyvid.cpp62
5 files changed, 293 insertions, 313 deletions
diff --git a/py/pykms/pykms.cpp b/py/pykms/pykms.cpp
index fec8417..b91a1a9 100644
--- a/py/pykms/pykms.cpp
+++ b/py/pykms/pykms.cpp
@@ -7,15 +7,16 @@ namespace py = pybind11;
using namespace kms;
using namespace std;
-void init_pykmstest(py::module &m);
-void init_pykmsbase(py::module &m);
-void init_pyvid(py::module &m);
+void init_pykmstest(py::module& m);
+void init_pykmsbase(py::module& m);
+void init_pyvid(py::module& m);
#if HAS_LIBDRM_OMAP
-void init_pykmsomap(py::module &m);
+void init_pykmsomap(py::module& m);
#endif
-PYBIND11_MODULE(pykms, m) {
+PYBIND11_MODULE(pykms, m)
+{
init_pykmsbase(m);
init_pykmstest(m);
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp
index 6ed82a0..43c2dfd 100644
--- a/py/pykms/pykmsbase.cpp
+++ b/py/pykms/pykmsbase.cpp
@@ -17,275 +17,262 @@ static vector<unique_ptr<T, py::nodelete>> convert_vector(const vector<T*>& sour
return v;
}
-void init_pykmsbase(py::module &m)
+void init_pykmsbase(py::module& m)
{
py::class_<Card>(m, "Card")
- .def(py::init<>())
- .def(py::init<const string&>())
- .def(py::init<const string&, uint32_t>())
- .def_property_readonly("fd", &Card::fd)
- .def_property_readonly("minor", &Card::dev_minor)
- .def_property_readonly("get_first_connected_connector", &Card::get_first_connected_connector)
-
- // XXX pybind11 can't handle vector<T*> where T is non-copyable, and complains:
- // RuntimeError: return_value_policy = move, but the object is neither movable nor copyable!
- // So we do this manually.
- .def_property_readonly("connectors", [](Card* self) {
- return convert_vector(self->get_connectors());
- })
-
- .def_property_readonly("crtcs", [](Card* self) {
- return convert_vector(self->get_crtcs());
- })
-
- .def_property_readonly("encoders", [](Card* self) {
- return convert_vector(self->get_encoders());
- })
-
- .def_property_readonly("planes", [](Card* self) {
- return convert_vector(self->get_planes());
- })
-
- .def_property_readonly("has_atomic", &Card::has_atomic)
- .def("get_prop", (Property* (Card::*)(uint32_t) const)&Card::get_prop)
-
- .def_property_readonly("version_name", &Card::version_name);
- ;
+ .def(py::init<>())
+ .def(py::init<const string&>())
+ .def(py::init<const string&, uint32_t>())
+ .def_property_readonly("fd", &Card::fd)
+ .def_property_readonly("minor", &Card::dev_minor)
+ .def_property_readonly("get_first_connected_connector", &Card::get_first_connected_connector)
+
+ // XXX pybind11 can't handle vector<T*> where T is non-copyable, and complains:
+ // RuntimeError: return_value_policy = move, but the object is neither movable nor copyable!
+ // So we do this manually.
+ .def_property_readonly("connectors", [](Card* self) {
+ return convert_vector(self->get_connectors());
+ })
+
+ .def_property_readonly("crtcs", [](Card* self) {
+ return convert_vector(self->get_crtcs());
+ })
+
+ .def_property_readonly("encoders", [](Card* self) {
+ return convert_vector(self->get_encoders());
+ })
+
+ .def_property_readonly("planes", [](Card* self) {
+ return convert_vector(self->get_planes());
+ })
+
+ .def_property_readonly("has_atomic", &Card::has_atomic)
+ .def("get_prop", (Property * (Card::*)(uint32_t) const) & Card::get_prop)
+
+ .def_property_readonly("version_name", &Card::version_name);
+ ;
py::class_<DrmObject, unique_ptr<DrmObject, py::nodelete>>(m, "DrmObject")
- .def_property_readonly("id", &DrmObject::id)
- .def_property_readonly("idx", &DrmObject::idx)
- .def_property_readonly("card", &DrmObject::card)
- ;
+ .def_property_readonly("id", &DrmObject::id)
+ .def_property_readonly("idx", &DrmObject::idx)
+ .def_property_readonly("card", &DrmObject::card);
py::class_<DrmPropObject, DrmObject, unique_ptr<DrmPropObject, py::nodelete>>(m, "DrmPropObject")
- .def("refresh_props", &DrmPropObject::refresh_props)
- .def_property_readonly("prop_map", &DrmPropObject::get_prop_map)
- .def("get_prop_value", (uint64_t (DrmPropObject::*)(const string&) const)&DrmPropObject::get_prop_value)
- .def("set_prop_value",(int (DrmPropObject::*)(const string&, uint64_t)) &DrmPropObject::set_prop_value)
- .def("get_prop_value_as_blob", &DrmPropObject::get_prop_value_as_blob)
- .def("get_prop", &DrmPropObject::get_prop)
- .def("has_prop", &DrmPropObject::has_prop)
- ;
+ .def("refresh_props", &DrmPropObject::refresh_props)
+ .def_property_readonly("prop_map", &DrmPropObject::get_prop_map)
+ .def("get_prop_value", (uint64_t(DrmPropObject::*)(const string&) const) & DrmPropObject::get_prop_value)
+ .def("set_prop_value", (int (DrmPropObject::*)(const string&, uint64_t)) & DrmPropObject::set_prop_value)
+ .def("get_prop_value_as_blob", &DrmPropObject::get_prop_value_as_blob)
+ .def("get_prop", &DrmPropObject::get_prop)
+ .def("has_prop", &DrmPropObject::has_prop);
py::class_<Connector, DrmPropObject, unique_ptr<Connector, py::nodelete>>(m, "Connector")
- .def_property_readonly("fullname", &Connector::fullname)
- .def("get_default_mode", &Connector::get_default_mode)
- .def("get_current_crtc", &Connector::get_current_crtc)
- .def("get_possible_crtcs", [](Connector* self) {
- return convert_vector(self->get_possible_crtcs());
- })
- .def("get_modes", &Connector::get_modes)
- .def("get_mode", (Videomode (Connector::*)(const string& mode) const)&Connector::get_mode)
- .def("get_mode", (Videomode (Connector::*)(unsigned xres, unsigned yres, float refresh, bool ilace) const)&Connector::get_mode)
- .def("connected", &Connector::connected)
- .def("__repr__", [](const Connector& o) { return "<pykms.Connector " + to_string(o.id()) + ">"; })
- .def("refresh", &Connector::refresh)
- ;
+ .def_property_readonly("fullname", &Connector::fullname)
+ .def("get_default_mode", &Connector::get_default_mode)
+ .def("get_current_crtc", &Connector::get_current_crtc)
+ .def("get_possible_crtcs", [](Connector* self) {
+ return convert_vector(self->get_possible_crtcs());
+ })
+ .def("get_modes", &Connector::get_modes)
+ .def("get_mode", (Videomode(Connector::*)(const string& mode) const) & Connector::get_mode)
+ .def("get_mode", (Videomode(Connector::*)(unsigned xres, unsigned yres, float refresh, bool ilace) const) & Connector::get_mode)
+ .def("connected", &Connector::connected)
+ .def("__repr__", [](const Connector& o) { return "<pykms.Connector " + to_string(o.id()) + ">"; })
+ .def("refresh", &Connector::refresh);
py::class_<Crtc, DrmPropObject, unique_ptr<Crtc, py::nodelete>>(m, "Crtc")
- .def("set_mode", (int (Crtc::*)(Connector*, const Videomode&))&Crtc::set_mode)
- .def("set_mode", (int (Crtc::*)(Connector*, Framebuffer&, const Videomode&))&Crtc::set_mode)
- .def("disable_mode", &Crtc::disable_mode)
- .def("page_flip",
- [](Crtc* self, Framebuffer& fb, uint32_t data)
- {
- 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)
- .def_property_readonly("mode", &Crtc::mode)
- .def_property_readonly("mode_valid", &Crtc::mode_valid)
- .def("__repr__", [](const Crtc& o) { return "<pykms.Crtc " + to_string(o.id()) + ">"; })
- .def("refresh", &Crtc::refresh)
- ;
+ .def("set_mode", (int (Crtc::*)(Connector*, const Videomode&)) & Crtc::set_mode)
+ .def("set_mode", (int (Crtc::*)(Connector*, Framebuffer&, const Videomode&)) & Crtc::set_mode)
+ .def("disable_mode", &Crtc::disable_mode)
+ .def(
+ "page_flip",
+ [](Crtc* self, Framebuffer& fb, uint32_t data) {
+ 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)
+ .def_property_readonly("mode", &Crtc::mode)
+ .def_property_readonly("mode_valid", &Crtc::mode_valid)
+ .def("__repr__", [](const Crtc& o) { return "<pykms.Crtc " + to_string(o.id()) + ">"; })
+ .def("refresh", &Crtc::refresh);
py::class_<Encoder, DrmPropObject, unique_ptr<Encoder, py::nodelete>>(m, "Encoder")
- .def("refresh", &Encoder::refresh)
- ;
+ .def("refresh", &Encoder::refresh);
py::class_<Plane, DrmPropObject, unique_ptr<Plane, py::nodelete>>(m, "Plane")
- .def("supports_crtc", &Plane::supports_crtc)
- .def_property_readonly("formats", &Plane::get_formats)
- .def_property_readonly("plane_type", &Plane::plane_type)
- .def("__repr__", [](const Plane& o) { return "<pykms.Plane " + to_string(o.id()) + ">"; })
- ;
+ .def("supports_crtc", &Plane::supports_crtc)
+ .def_property_readonly("formats", &Plane::get_formats)
+ .def_property_readonly("plane_type", &Plane::plane_type)
+ .def("__repr__", [](const Plane& o) { return "<pykms.Plane " + to_string(o.id()) + ">"; });
py::enum_<PlaneType>(m, "PlaneType")
- .value("Overlay", PlaneType::Overlay)
- .value("Primary", PlaneType::Primary)
- .value("Cursor", PlaneType::Cursor)
- ;
+ .value("Overlay", PlaneType::Overlay)
+ .value("Primary", PlaneType::Primary)
+ .value("Cursor", PlaneType::Cursor);
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("name", &Property::name)
+ .def_property_readonly("enums", &Property::get_enums);
py::class_<Blob>(m, "Blob")
- .def(py::init([](Card& card, py::buffer buf) {
- py::buffer_info info = buf.request();
- if (info.ndim != 1)
- throw std::runtime_error("Incompatible buffer dimension!");
-
- return new Blob(card, info.ptr, info.size * info.itemsize);
- }),
- py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
-
- .def_property_readonly("data", &Blob::data)
-
- // 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.
- // Note that this means that python thinks we don't derive from DrmObject
- .def_property_readonly("id", &DrmObject::id)
- .def_property_readonly("idx", &DrmObject::idx)
- .def_property_readonly("card", &DrmObject::card)
- ;
+ .def(py::init([](Card& card, py::buffer buf) {
+ py::buffer_info info = buf.request();
+ if (info.ndim != 1)
+ throw std::runtime_error("Incompatible buffer dimension!");
+
+ return new Blob(card, info.ptr, info.size * info.itemsize);
+ }),
+ py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
+
+ .def_property_readonly("data", &Blob::data)
+
+ // 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.
+ // Note that this means that python thinks we don't derive from DrmObject
+ .def_property_readonly("id", &DrmObject::id)
+ .def_property_readonly("idx", &DrmObject::idx)
+ .def_property_readonly("card", &DrmObject::card);
py::class_<Framebuffer>(m, "Framebuffer")
- .def_property_readonly("width", &Framebuffer::width)
- .def_property_readonly("height", &Framebuffer::height)
- .def_property_readonly("format", &Framebuffer::format)
- .def_property_readonly("num_planes", &Framebuffer::num_planes)
- .def("stride", &Framebuffer::stride)
- .def("size", &Framebuffer::size)
- .def("offset", &Framebuffer::offset)
- .def("fd", &Framebuffer::prime_fd)
-
- // 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.
- // Note that this means that python thinks we don't derive from DrmObject
- .def_property_readonly("id", &DrmObject::id)
- .def_property_readonly("idx", &DrmObject::idx)
- .def_property_readonly("card", &DrmObject::card)
- ;
+ .def_property_readonly("width", &Framebuffer::width)
+ .def_property_readonly("height", &Framebuffer::height)
+ .def_property_readonly("format", &Framebuffer::format)
+ .def_property_readonly("num_planes", &Framebuffer::num_planes)
+ .def("stride", &Framebuffer::stride)
+ .def("size", &Framebuffer::size)
+ .def("offset", &Framebuffer::offset)
+ .def("fd", &Framebuffer::prime_fd)
+
+ // 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.
+ // Note that this means that python thinks we don't derive from DrmObject
+ .def_property_readonly("id", &DrmObject::id)
+ .def_property_readonly("idx", &DrmObject::idx)
+ .def_property_readonly("card", &DrmObject::card);
py::class_<DumbFramebuffer, Framebuffer>(m, "DumbFramebuffer")
- .def(py::init<Card&, uint32_t, uint32_t, const string&>(),
- 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(py::init<Card&, uint32_t, uint32_t, const string&>(),
+ 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
+ ;
py::class_<DmabufFramebuffer, Framebuffer>(m, "DmabufFramebuffer")
- .def(py::init<Card&, uint32_t, uint32_t, const string&, vector<int>, vector<uint32_t>, vector<uint32_t>>(),
- 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(py::init<Card&, uint32_t, uint32_t, const string&, vector<int>, vector<uint32_t>, vector<uint32_t>>(),
+ 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
+ ;
py::enum_<PixelFormat>(m, "PixelFormat")
- .value("Undefined", PixelFormat::Undefined)
+ .value("Undefined", PixelFormat::Undefined)
- .value("NV12", PixelFormat::NV12)
- .value("NV21", PixelFormat::NV21)
- .value("NV16", PixelFormat::NV16)
- .value("NV61", PixelFormat::NV61)
+ .value("NV12", PixelFormat::NV12)
+ .value("NV21", PixelFormat::NV21)
+ .value("NV16", PixelFormat::NV16)
+ .value("NV61", PixelFormat::NV61)
- .value("YUV420", PixelFormat::YUV420)
- .value("YVU420", PixelFormat::YVU420)
- .value("YUV422", PixelFormat::YUV422)
- .value("YVU422", PixelFormat::YVU422)
- .value("YUV444", PixelFormat::YUV444)
- .value("YVU444", PixelFormat::YVU444)
+ .value("YUV420", PixelFormat::YUV420)
+ .value("YVU420", PixelFormat::YVU420)
+ .value("YUV422", PixelFormat::YUV422)
+ .value("YVU422", PixelFormat::YVU422)
+ .value("YUV444", PixelFormat::YUV444)
+ .value("YVU444", PixelFormat::YVU444)
- .value("UYVY", PixelFormat::UYVY)
- .value("YUYV", PixelFormat::YUYV)
- .value("YVYU", PixelFormat::YVYU)
- .value("VYUY", PixelFormat::VYUY)
+ .value("UYVY", PixelFormat::UYVY)
+ .value("YUYV", PixelFormat::YUYV)
+ .value("YVYU", PixelFormat::YVYU)
+ .value("VYUY", PixelFormat::VYUY)
- .value("XRGB8888", PixelFormat::XRGB8888)
- .value("XBGR8888", PixelFormat::XBGR8888)
- .value("RGBX8888", PixelFormat::RGBX8888)
- .value("BGRX8888", PixelFormat::BGRX8888)
+ .value("XRGB8888", PixelFormat::XRGB8888)
+ .value("XBGR8888", PixelFormat::XBGR8888)
+ .value("RGBX8888", PixelFormat::RGBX8888)
+ .value("BGRX8888", PixelFormat::BGRX8888)
- .value("ARGB8888", PixelFormat::ARGB8888)
- .value("ABGR8888", PixelFormat::ABGR8888)
- .value("RGBA8888", PixelFormat::RGBA8888)
- .value("BGRA8888", PixelFormat::BGRA8888)
+ .value("ARGB8888", PixelFormat::ARGB8888)
+ .value("ABGR8888", PixelFormat::ABGR8888)
+ .value("RGBA8888", PixelFormat::RGBA8888)
+ .value("BGRA8888", PixelFormat::BGRA8888)
- .value("RGB888", PixelFormat::RGB888)
- .value("BGR888", PixelFormat::BGR888)
+ .value("RGB888", PixelFormat::RGB888)
+ .value("BGR888", PixelFormat::BGR888)
- .value("RGB332", PixelFormat::RGB332)
+ .value("RGB332", PixelFormat::RGB332)
- .value("RGB565", PixelFormat::RGB565)
- .value("BGR565", PixelFormat::BGR565)
+ .value("RGB565", PixelFormat::RGB565)
+ .value("BGR565", PixelFormat::BGR565)
- .value("XRGB4444", PixelFormat::XRGB4444)
- .value("XRGB1555", PixelFormat::XRGB1555)
+ .value("XRGB4444", PixelFormat::XRGB4444)
+ .value("XRGB1555", PixelFormat::XRGB1555)
- .value("ARGB4444", PixelFormat::ARGB4444)
- .value("ARGB1555", PixelFormat::ARGB1555)
+ .value("ARGB4444", PixelFormat::ARGB4444)
+ .value("ARGB1555", PixelFormat::ARGB1555)
- .value("XRGB2101010", PixelFormat::XRGB2101010)
- .value("XBGR2101010", PixelFormat::XBGR2101010)
- .value("RGBX1010102", PixelFormat::RGBX1010102)
- .value("BGRX1010102", PixelFormat::BGRX1010102)
+ .value("XRGB2101010", PixelFormat::XRGB2101010)
+ .value("XBGR2101010", PixelFormat::XBGR2101010)
+ .value("RGBX1010102", PixelFormat::RGBX1010102)
+ .value("BGRX1010102", PixelFormat::BGRX1010102)
- .value("ARGB2101010", PixelFormat::ARGB2101010)
- .value("ABGR2101010", PixelFormat::ABGR2101010)
- .value("RGBA1010102", PixelFormat::RGBA1010102)
- .value("BGRA1010102", PixelFormat::BGRA1010102)
- ;
+ .value("ARGB2101010", PixelFormat::ARGB2101010)
+ .value("ABGR2101010", PixelFormat::ABGR2101010)
+ .value("RGBA1010102", PixelFormat::RGBA1010102)
+ .value("BGRA1010102", PixelFormat::BGRA1010102);
py::enum_<SyncPolarity>(m, "SyncPolarity")
- .value("Undefined", SyncPolarity::Undefined)
- .value("Positive", SyncPolarity::Positive)
- .value("Negative", SyncPolarity::Negative)
- ;
+ .value("Undefined", SyncPolarity::Undefined)
+ .value("Positive", SyncPolarity::Positive)
+ .value("Negative", SyncPolarity::Negative);
py::class_<Videomode>(m, "Videomode")
- .def(py::init<>())
-
- .def_readwrite("name", &Videomode::name)
+ .def(py::init<>())
- .def_readwrite("clock", &Videomode::clock)
+ .def_readwrite("name", &Videomode::name)
- .def_readwrite("hdisplay", &Videomode::hdisplay)
- .def_readwrite("hsync_start", &Videomode::hsync_start)
- .def_readwrite("hsync_end", &Videomode::hsync_end)
- .def_readwrite("htotal", &Videomode::htotal)
+ .def_readwrite("clock", &Videomode::clock)
- .def_readwrite("vdisplay", &Videomode::vdisplay)
- .def_readwrite("vsync_start", &Videomode::vsync_start)
- .def_readwrite("vsync_end", &Videomode::vsync_end)
- .def_readwrite("vtotal", &Videomode::vtotal)
+ .def_readwrite("hdisplay", &Videomode::hdisplay)
+ .def_readwrite("hsync_start", &Videomode::hsync_start)
+ .def_readwrite("hsync_end", &Videomode::hsync_end)
+ .def_readwrite("htotal", &Videomode::htotal)
- .def_readwrite("vrefresh", &Videomode::vrefresh)
+ .def_readwrite("vdisplay", &Videomode::vdisplay)
+ .def_readwrite("vsync_start", &Videomode::vsync_start)
+ .def_readwrite("vsync_end", &Videomode::vsync_end)
+ .def_readwrite("vtotal", &Videomode::vtotal)
- .def_readwrite("flags", &Videomode::flags)
- .def_readwrite("type", &Videomode::type)
+ .def_readwrite("vrefresh", &Videomode::vrefresh)
- .def("__repr__", [](const Videomode& vm) { return "<pykms.Videomode " + to_string(vm.hdisplay) + "x" + to_string(vm.vdisplay) + ">"; })
+ .def_readwrite("flags", &Videomode::flags)
+ .def_readwrite("type", &Videomode::type)
- .def("to_blob", &Videomode::to_blob)
+ .def("__repr__", [](const Videomode& vm) { return "<pykms.Videomode " + to_string(vm.hdisplay) + "x" + to_string(vm.vdisplay) + ">"; })
- .def_property("hsync", &Videomode::hsync, &Videomode::set_hsync)
- .def_property("vsync", &Videomode::vsync, &Videomode::set_vsync)
+ .def("to_blob", &Videomode::to_blob)
- .def("to_string_short", &Videomode::to_string_short)
- .def("to_string_long", &Videomode::to_string_long)
- ;
+ .def_property("hsync", &Videomode::hsync, &Videomode::set_hsync)
+ .def_property("vsync", &Videomode::vsync, &Videomode::set_vsync)
+ .def("to_string_short", &Videomode::to_string_short)
+ .def("to_string_long", &Videomode::to_string_long);
m.def("videomode_from_timings", &videomode_from_timings);
py::class_<AtomicReq>(m, "AtomicReq")
- .def(py::init<Card&>(),
- py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
- .def("add", (void (AtomicReq::*)(DrmPropObject*, const string&, uint64_t)) &AtomicReq::add)
- .def("add", (void (AtomicReq::*)(DrmPropObject*, Property*, 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* self, uint32_t data, bool allow)
- {
- 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)
- ;
+ .def(py::init<Card&>(),
+ py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
+ .def("add", (void (AtomicReq::*)(DrmPropObject*, const string&, uint64_t)) & AtomicReq::add)
+ .def("add", (void (AtomicReq::*)(DrmPropObject*, Property*, 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* self, uint32_t data, bool allow) {
+ 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);
}
diff --git a/py/pykms/pykmsomap.cpp b/py/pykms/pykmsomap.cpp
index 4fc7084..eb01f47 100644
--- a/py/pykms/pykmsomap.cpp
+++ b/py/pykms/pykmsomap.cpp
@@ -8,35 +8,32 @@ namespace py = pybind11;
using namespace kms;
using namespace std;
-void init_pykmsomap(py::module &m)
+void init_pykmsomap(py::module& m)
{
py::class_<OmapCard, Card>(m, "OmapCard")
- .def(py::init<>())
- ;
+ .def(py::init<>());
py::class_<OmapFramebuffer, Framebuffer> omapfb(m, "OmapFramebuffer");
// XXX we should use py::arithmetic() here to support or and and operators, but it's not supported in the pybind11 we use
py::enum_<OmapFramebuffer::Flags>(omapfb, "Flags")
- .value("None", OmapFramebuffer::Flags::None)
- .value("Tiled", OmapFramebuffer::Flags::Tiled)
- .value("MemContig", OmapFramebuffer::Flags::MemContig)
- .value("MemTiler", OmapFramebuffer::Flags::MemTiler)
- .value("MemPin", OmapFramebuffer::Flags::MemPin)
- .export_values()
- ;
+ .value("None", OmapFramebuffer::Flags::None)
+ .value("Tiled", OmapFramebuffer::Flags::Tiled)
+ .value("MemContig", OmapFramebuffer::Flags::MemContig)
+ .value("MemTiler", OmapFramebuffer::Flags::MemTiler)
+ .value("MemPin", OmapFramebuffer::Flags::MemPin)
+ .export_values();
omapfb
- .def(py::init<OmapCard&, uint32_t, uint32_t, const string&, OmapFramebuffer::Flags>(),
- py::keep_alive<1, 2>(), // Keep Card alive until this is destructed
- py::arg("card"), py::arg("width"), py::arg("height"), py::arg("fourcc"), py::arg("flags") = OmapFramebuffer::None)
- .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat, OmapFramebuffer::Flags>(),
- py::keep_alive<1, 2>(), // Keep OmapCard alive until this is destructed
- py::arg("card"), py::arg("width"), py::arg("height"), py::arg("pixfmt"), py::arg("flags") = OmapFramebuffer::None)
- .def_property_readonly("format", &OmapFramebuffer::format)
- .def_property_readonly("num_planes", &OmapFramebuffer::num_planes)
- .def("fd", &OmapFramebuffer::prime_fd)
- .def("stride", &OmapFramebuffer::stride)
- .def("offset", &OmapFramebuffer::offset)
- ;
+ .def(py::init<OmapCard&, uint32_t, uint32_t, const string&, OmapFramebuffer::Flags>(),
+ py::keep_alive<1, 2>(), // Keep Card alive until this is destructed
+ py::arg("card"), py::arg("width"), py::arg("height"), py::arg("fourcc"), py::arg("flags") = OmapFramebuffer::None)
+ .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat, OmapFramebuffer::Flags>(),
+ py::keep_alive<1, 2>(), // Keep OmapCard alive until this is destructed
+ py::arg("card"), py::arg("width"), py::arg("height"), py::arg("pixfmt"), py::arg("flags") = OmapFramebuffer::None)
+ .def_property_readonly("format", &OmapFramebuffer::format)
+ .def_property_readonly("num_planes", &OmapFramebuffer::num_planes)
+ .def("fd", &OmapFramebuffer::prime_fd)
+ .def("stride", &OmapFramebuffer::stride)
+ .def("offset", &OmapFramebuffer::offset);
}
diff --git a/py/pykms/pykmsutil.cpp b/py/pykms/pykmsutil.cpp
index d5d7fde..666cbdc 100644
--- a/py/pykms/pykmsutil.cpp
+++ b/py/pykms/pykmsutil.cpp
@@ -8,58 +8,55 @@ namespace py = pybind11;
using namespace kms;
using namespace std;
-void init_pykmstest(py::module &m)
+void init_pykmstest(py::module& m)
{
py::class_<RGB>(m, "RGB")
- .def(py::init<>())
- .def(py::init<uint8_t, uint8_t, uint8_t&>())
- .def(py::init<uint8_t, uint8_t, uint8_t, uint8_t&>())
- .def_property_readonly("rgb888", &RGB::rgb888)
- .def_property_readonly("argb8888", &RGB::argb8888)
- .def_property_readonly("abgr8888", &RGB::abgr8888)
- .def_property_readonly("rgb565", &RGB::rgb565)
- ;
+ .def(py::init<>())
+ .def(py::init<uint8_t, uint8_t, uint8_t&>())
+ .def(py::init<uint8_t, uint8_t, uint8_t, uint8_t&>())
+ .def_property_readonly("rgb888", &RGB::rgb888)
+ .def_property_readonly("argb8888", &RGB::argb8888)
+ .def_property_readonly("abgr8888", &RGB::abgr8888)
+ .def_property_readonly("rgb565", &RGB::rgb565);
py::class_<ResourceManager>(m, "ResourceManager")
- .def(py::init<Card&>())
- .def("reset", &ResourceManager::reset)
- .def("reserve_connector", (Connector* (ResourceManager::*)(const string& name))&ResourceManager::reserve_connector,
- py::arg("name") = string())
- .def("reserve_crtc", (Crtc* (ResourceManager::*)(Connector*))&ResourceManager::reserve_crtc)
- .def("reserve_plane", (Plane* (ResourceManager::*)(Crtc*, PlaneType, PixelFormat))&ResourceManager::reserve_plane,
- py::arg("crtc"),
- py::arg("type"),
- py::arg("format") = PixelFormat::Undefined)
- .def("reserve_generic_plane", &ResourceManager::reserve_generic_plane,
- py::arg("crtc"),
- py::arg("format") = PixelFormat::Undefined)
- .def("reserve_primary_plane", &ResourceManager::reserve_primary_plane,
- py::arg("crtc"),
- py::arg("format") = PixelFormat::Undefined)
- .def("reserve_overlay_plane", &ResourceManager::reserve_overlay_plane,
- py::arg("crtc"),
- py::arg("format") = PixelFormat::Undefined)
- ;
+ .def(py::init<Card&>())
+ .def("reset", &ResourceManager::reset)
+ .def("reserve_connector", (Connector * (ResourceManager::*)(const string& name)) & ResourceManager::reserve_connector,
+ py::arg("name") = string())
+ .def("reserve_crtc", (Crtc * (ResourceManager::*)(Connector*)) & ResourceManager::reserve_crtc)
+ .def("reserve_plane", (Plane * (ResourceManager::*)(Crtc*, PlaneType, PixelFormat)) & ResourceManager::reserve_plane,
+ py::arg("crtc"),
+ py::arg("type"),
+ py::arg("format") = PixelFormat::Undefined)
+ .def("reserve_generic_plane", &ResourceManager::reserve_generic_plane,
+ py::arg("crtc"),
+ py::arg("format") = PixelFormat::Undefined)
+ .def("reserve_primary_plane", &ResourceManager::reserve_primary_plane,
+ py::arg("crtc"),
+ py::arg("format") = PixelFormat::Undefined)
+ .def("reserve_overlay_plane", &ResourceManager::reserve_overlay_plane,
+ py::arg("crtc"),
+ py::arg("format") = PixelFormat::Undefined);
py::enum_<YUVType>(m, "YUVType")
- .value("BT601_Lim", YUVType::BT601_Lim)
- .value("BT601_Full", YUVType::BT601_Full)
- .value("BT709_Lim", YUVType::BT709_Lim)
- .value("BT709_Full", YUVType::BT709_Full)
- ;
+ .value("BT601_Lim", YUVType::BT601_Lim)
+ .value("BT601_Full", YUVType::BT601_Full)
+ .value("BT709_Lim", YUVType::BT709_Lim)
+ .value("BT709_Full", YUVType::BT709_Full);
// Use lambdas to handle IFramebuffer
- m.def("draw_test_pattern", [](Framebuffer& fb, YUVType yuvt) { draw_test_pattern(fb, yuvt); },
- py::arg("fb"),
- py::arg("yuvt") = YUVType::BT601_Lim);
+ m.def(
+ "draw_test_pattern", [](Framebuffer& fb, YUVType yuvt) { draw_test_pattern(fb, yuvt); },
+ py::arg("fb"),
+ py::arg("yuvt") = YUVType::BT601_Lim);
m.def("draw_color_bar", [](Framebuffer& fb, int old_xpos, int xpos, int width) {
draw_color_bar(fb, old_xpos, xpos, width);
- } );
+ });
m.def("draw_rect", [](Framebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color) {
draw_rect(fb, x, y, w, h, color);
- } );
+ });
m.def("draw_circle", [](Framebuffer& fb, int32_t xCenter, int32_t yCenter, int32_t radius, RGB color) {
draw_circle(fb, xCenter, yCenter, radius, color);
- } );
- m.def("draw_text", [](Framebuffer& fb, uint32_t x, uint32_t y, const string& str, RGB color) {
- draw_text(fb, x, y, str, color); } );
+ });
+ m.def("draw_text", [](Framebuffer& fb, uint32_t x, uint32_t y, const string& str, RGB color) { draw_text(fb, x, y, str, color); });
}
diff --git a/py/pykms/pyvid.cpp b/py/pykms/pyvid.cpp
index 8b0450a..54ad480 100644
--- a/py/pykms/pyvid.cpp
+++ b/py/pykms/pyvid.cpp
@@ -9,40 +9,38 @@ namespace py = pybind11;
using namespace kms;
using namespace std;
-void init_pyvid(py::module &m)
+void init_pyvid(py::module& m)
{
py::class_<VideoDevice>(m, "VideoDevice")
- .def(py::init<const string&>())
- .def_property_readonly("fd", &VideoDevice::fd)
- .def_property_readonly("has_capture", &VideoDevice::has_capture)
- .def_property_readonly("has_output", &VideoDevice::has_output)
- .def_property_readonly("has_m2m", &VideoDevice::has_m2m)
- .def_property_readonly("capture_streamer", &VideoDevice::get_capture_streamer)
- .def_property_readonly("output_streamer", &VideoDevice::get_output_streamer)
- .def_property_readonly("discrete_frame_sizes", &VideoDevice::get_discrete_frame_sizes)
- .def_property_readonly("frame_sizes", &VideoDevice::get_frame_sizes)
- .def("get_capture_devices", &VideoDevice::get_capture_devices)
- ;
+ .def(py::init<const string&>())
+ .def_property_readonly("fd", &VideoDevice::fd)
+ .def_property_readonly("has_capture", &VideoDevice::has_capture)
+ .def_property_readonly("has_output", &VideoDevice::has_output)
+ .def_property_readonly("has_m2m", &VideoDevice::has_m2m)
+ .def_property_readonly("capture_streamer", &VideoDevice::get_capture_streamer)
+ .def_property_readonly("output_streamer", &VideoDevice::get_output_streamer)
+ .def_property_readonly("discrete_frame_sizes", &VideoDevice::get_discrete_frame_sizes)
+ .def_property_readonly("frame_sizes", &VideoDevice::get_frame_sizes)
+ .def("get_capture_devices", &VideoDevice::get_capture_devices);
py::class_<VideoStreamer>(m, "VideoStreamer")
- .def_property_readonly("fd", &VideoStreamer::fd)
- .def_property_readonly("ports", &VideoStreamer::get_ports)
- .def("set_port", &VideoStreamer::set_port)
- .def_property_readonly("formats", &VideoStreamer::get_formats)
- .def("set_format", &VideoStreamer::set_format)
- .def("get_selection", [](VideoStreamer *self) {
- uint32_t left, top, width, height;
- self->get_selection(left, top, width, height);
- return make_tuple(left, top, width, height);
- } )
- .def("set_selection", [](VideoStreamer *self, uint32_t left, uint32_t top, uint32_t width, uint32_t height) {
- self->set_selection(left, top, width, height);
- return make_tuple(left, top, width, height);
- } )
- .def("set_queue_size", &VideoStreamer::set_queue_size)
- .def("queue", &VideoStreamer::queue)
- .def("dequeue", &VideoStreamer::dequeue)
- .def("stream_on", &VideoStreamer::stream_on)
- .def("stream_off", &VideoStreamer::stream_off)
- ;
+ .def_property_readonly("fd", &VideoStreamer::fd)
+ .def_property_readonly("ports", &VideoStreamer::get_ports)
+ .def("set_port", &VideoStreamer::set_port)
+ .def_property_readonly("formats", &VideoStreamer::get_formats)
+ .def("set_format", &VideoStreamer::set_format)
+ .def("get_selection", [](VideoStreamer* self) {
+ uint32_t left, top, width, height;
+ self->get_selection(left, top, width, height);
+ return make_tuple(left, top, width, height);
+ })
+ .def("set_selection", [](VideoStreamer* self, uint32_t left, uint32_t top, uint32_t width, uint32_t height) {
+ self->set_selection(left, top, width, height);
+ return make_tuple(left, top, width, height);
+ })
+ .def("set_queue_size", &VideoStreamer::set_queue_size)
+ .def("queue", &VideoStreamer::queue)
+ .def("dequeue", &VideoStreamer::dequeue)
+ .def("stream_on", &VideoStreamer::stream_on)
+ .def("stream_off", &VideoStreamer::stream_off);
}