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 py::class_<OmapFramebuffer, Framebuffer> omapfb(m, "OmapFramebuffer");
17
18 // XXX we should use py::arithmetic() here to support or and and operators, but it's not supported in the pybind11 we use
19 py::enum_<OmapFramebuffer::Flags>(omapfb, "Flags")
20 .value("None", OmapFramebuffer::Flags::None)
21 .value("Tiled", OmapFramebuffer::Flags::Tiled)
22 .value("MemContig", OmapFramebuffer::Flags::MemContig)
23 .value("MemTiler", OmapFramebuffer::Flags::MemTiler)
24 .value("MemPin", OmapFramebuffer::Flags::MemPin)
25 .export_values();
26
27 omapfb
28 .def(py::init<OmapCard&, uint32_t, uint32_t, const string&, OmapFramebuffer::Flags>(),
29 py::keep_alive<1, 2>(), // Keep Card alive until this is destructed
30 py::arg("card"), py::arg("width"), py::arg("height"), py::arg("fourcc"), py::arg("flags") = OmapFramebuffer::None)
31 .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat, OmapFramebuffer::Flags>(),
32 py::keep_alive<1, 2>(), // Keep OmapCard alive until this is destructed
33 py::arg("card"), py::arg("width"), py::arg("height"), py::arg("pixfmt"), py::arg("flags") = OmapFramebuffer::None)
34 .def_property_readonly("format", &OmapFramebuffer::format)
35 .def_property_readonly("num_planes", &OmapFramebuffer::num_planes)
36 .def("fd", &OmapFramebuffer::prime_fd)
37 .def("stride", &OmapFramebuffer::stride)
38 .def("offset", &OmapFramebuffer::offset);
39 }
40