1 #include <pybind11/pybind11.h>
2 #include <pybind11/stl.h>
3 #include <kms++/kms++.h>
4 #include <kms++/omap/omapkms++.h>
6 namespace py = pybind11;
8 using namespace kms;
9 using namespace std;
11 void init_pykmsomap(py::module &m)
12 {
13 py::class_<OmapCard>(m, "OmapCard", py::base<Card>())
14 .def(py::init<>())
15 ;
17 py::class_<OmapFramebuffer> omapfb(m, "OmapFramebuffer", py::base<MappedFramebuffer>());
19 // XXX we should use py::arithmetic() here to support or and and operators, but it's not supported in the pybind11 we use
20 py::enum_<OmapFramebuffer::Flags>(omapfb, "Flags")
21 .value("None", OmapFramebuffer::Flags::None)
22 .value("Tiled", OmapFramebuffer::Flags::Tiled)
23 .export_values()
24 ;
26 omapfb
27 .def(py::init<OmapCard&, uint32_t, uint32_t, const string&, OmapFramebuffer::Flags>(),
28 py::keep_alive<1, 2>(), // Keep Card alive until this is destructed
29 py::arg("card"), py::arg("width"), py::arg("height"), py::arg("fourcc"), py::arg("flags") = OmapFramebuffer::None)
30 .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat, OmapFramebuffer::Flags>(),
31 py::keep_alive<1, 2>(), // Keep OmapCard alive until this is destructed
32 py::arg("card"), py::arg("width"), py::arg("height"), py::arg("pixfmt"), py::arg("flags") = OmapFramebuffer::None)
33 .def_property_readonly("format", &OmapFramebuffer::format)
34 .def_property_readonly("num_planes", &OmapFramebuffer::num_planes)
35 .def("fd", &OmapFramebuffer::prime_fd)
36 .def("stride", &OmapFramebuffer::stride)
37 .def("offset", &OmapFramebuffer::offset)
38 ;
39 }