Tomi Valkeinen | fa91e51 | 2016-05-22 23:14:38 +0300 | [diff] [blame] | 1 | #include <pybind11/pybind11.h> |
| 2 | #include <pybind11/stl.h> |
Tomi Valkeinen | 9916712 | 2016-06-11 21:46:24 +0300 | [diff] [blame] | 3 | #include <kms++/kms++.h> |
Tomi Valkeinen | 3c6ea25 | 2016-06-11 22:39:24 +0300 | [diff] [blame] | 4 | #include <kms++util/kms++util.h> |
Tomi Valkeinen | fa91e51 | 2016-05-22 23:14:38 +0300 | [diff] [blame] | 5 | |
| 6 | namespace py = pybind11; |
| 7 | |
| 8 | using namespace kms; |
| 9 | using namespace std; |
| 10 | |
| 11 | void init_pykmstest(py::module &m) |
| 12 | { |
| 13 | py::class_<RGB>(m, "RGB") |
| 14 | .def(py::init<>()) |
| 15 | .def(py::init<uint8_t, uint8_t, uint8_t&>()) |
| 16 | .def(py::init<uint8_t, uint8_t, uint8_t, uint8_t&>()) |
Tomi Valkeinen | 0bc5bbd | 2016-05-23 09:31:08 +0300 | [diff] [blame] | 17 | .def_property_readonly("rgb888", &RGB::rgb888) |
| 18 | .def_property_readonly("argb8888", &RGB::argb8888) |
| 19 | .def_property_readonly("abgr8888", &RGB::abgr8888) |
| 20 | .def_property_readonly("rgb565", &RGB::rgb565) |
Tomi Valkeinen | fa91e51 | 2016-05-22 23:14:38 +0300 | [diff] [blame] | 21 | ; |
| 22 | |
Tomi Valkeinen | 84d89b1 | 2016-06-14 22:20:08 +0300 | [diff] [blame] | 23 | py::class_<ResourceManager>(m, "ResourceManager") |
| 24 | .def(py::init<Card&>()) |
| 25 | .def("reset", &ResourceManager::reset) |
Tomi Valkeinen | 05009c9 | 2017-02-07 13:39:15 +0200 | [diff] [blame] | 26 | .def("reserve_connector", (Connector* (ResourceManager::*)(const string& name))&ResourceManager::reserve_connector, |
Tomi Valkeinen | 84d89b1 | 2016-06-14 22:20:08 +0300 | [diff] [blame] | 27 | py::arg("name") = string()) |
| 28 | .def("reserve_crtc", &ResourceManager::reserve_crtc) |
| 29 | .def("reserve_plane", &ResourceManager::reserve_plane, |
| 30 | py::arg("crtc"), |
| 31 | py::arg("type"), |
| 32 | py::arg("format") = PixelFormat::Undefined) |
Jyri Sarha | b4e12b3 | 2017-03-20 18:23:17 +0200 | [diff] [blame] | 33 | .def("reserve_generic_plane", &ResourceManager::reserve_generic_plane, |
| 34 | py::arg("crtc"), |
| 35 | py::arg("format") = PixelFormat::Undefined) |
Tomi Valkeinen | 84d89b1 | 2016-06-14 22:20:08 +0300 | [diff] [blame] | 36 | .def("reserve_primary_plane", &ResourceManager::reserve_primary_plane, |
| 37 | py::arg("crtc"), |
| 38 | py::arg("format") = PixelFormat::Undefined) |
| 39 | .def("reserve_overlay_plane", &ResourceManager::reserve_overlay_plane, |
| 40 | py::arg("crtc"), |
| 41 | py::arg("format") = PixelFormat::Undefined) |
| 42 | ; |
Jyri Sarha | 7adbef5 | 2017-05-09 17:37:15 +0300 | [diff] [blame] | 43 | py::enum_<YUVType>(m, "YUVType") |
| 44 | .value("BT601_Lim", YUVType::BT601_Lim) |
| 45 | .value("BT601_Full", YUVType::BT601_Full) |
| 46 | .value("BT709_Lim", YUVType::BT709_Lim) |
| 47 | .value("BT709_Full", YUVType::BT709_Full) |
| 48 | ; |
Tomi Valkeinen | 84d89b1 | 2016-06-14 22:20:08 +0300 | [diff] [blame] | 49 | |
Tomi Valkeinen | fa91e51 | 2016-05-22 23:14:38 +0300 | [diff] [blame] | 50 | // Use lambdas to handle IMappedFramebuffer |
Jyri Sarha | 7adbef5 | 2017-05-09 17:37:15 +0300 | [diff] [blame] | 51 | m.def("draw_test_pattern", [](MappedFramebuffer& fb, YUVType yuvt) { draw_test_pattern(fb, yuvt); }, |
| 52 | py::arg("fb"), |
| 53 | py::arg("yuvt") = YUVType::BT601_Lim); |
Tomi Valkeinen | 1e96518 | 2016-11-22 12:52:14 +0200 | [diff] [blame] | 54 | m.def("draw_color_bar", [](MappedFramebuffer& fb, int old_xpos, int xpos, int width) { |
Tomi Valkeinen | fa91e51 | 2016-05-22 23:14:38 +0300 | [diff] [blame] | 55 | draw_color_bar(fb, old_xpos, xpos, width); |
| 56 | } ); |
Tomi Valkeinen | 1e96518 | 2016-11-22 12:52:14 +0200 | [diff] [blame] | 57 | m.def("draw_rect", [](MappedFramebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color) { |
Tomi Valkeinen | fa91e51 | 2016-05-22 23:14:38 +0300 | [diff] [blame] | 58 | draw_rect(fb, x, y, w, h, color); |
| 59 | } ); |
Tomi Valkeinen | 248a588 | 2017-05-16 15:10:10 +0300 | [diff] [blame] | 60 | m.def("draw_text", [](MappedFramebuffer& fb, uint32_t x, uint32_t y, const string& str, RGB color) { |
| 61 | draw_text(fb, x, y, str, color); } ); |
Tomi Valkeinen | fa91e51 | 2016-05-22 23:14:38 +0300 | [diff] [blame] | 62 | } |