1 #include <pybind11/pybind11.h>
2 #include <pybind11/stl.h>
3 #include <kms++/kms++.h>
4 #include <kms++/omap/omapkms++.h>
5
6 namespace py = pybind11;
7
8 using namespace kms;
9 using namespace std;
10
init_pykmsomap(py::module & m)11 void init_pykmsomap(py::module &m)
12 {
13 py::class_<OmapCard, Card>(m, "OmapCard")
14 .def(py::init<>())
15 ;
16
17 py::class_<OmapFramebuffer, Framebuffer> omapfb(m, "OmapFramebuffer");
18
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 .value("MemContig", OmapFramebuffer::Flags::MemContig)
24 .value("MemTiler", OmapFramebuffer::Flags::MemTiler)
25 .value("MemPin", OmapFramebuffer::Flags::MemPin)
26 .export_values()
27 ;
28
29 omapfb
30 .def(py::init<OmapCard&, uint32_t, uint32_t, const string&, OmapFramebuffer::Flags>(),
31 py::keep_alive<1, 2>(), // Keep Card alive until this is destructed
32 py::arg("card"), py::arg("width"), py::arg("height"), py::arg("fourcc"), py::arg("flags") = OmapFramebuffer::None)
33 .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat, OmapFramebuffer::Flags>(),
34 py::keep_alive<1, 2>(), // Keep OmapCard alive until this is destructed
35 py::arg("card"), py::arg("width"), py::arg("height"), py::arg("pixfmt"), py::arg("flags") = OmapFramebuffer::None)
36 .def_property_readonly("format", &OmapFramebuffer::format)
37 .def_property_readonly("num_planes", &OmapFramebuffer::num_planes)
38 .def("fd", &OmapFramebuffer::prime_fd)
39 .def("stride", &OmapFramebuffer::stride)
40 .def("offset", &OmapFramebuffer::offset)
41 ;
42 }
43