blob: a5a6041a22ebf40c38ce8ee1522973a8ffe7d942 [file] [log] [blame]
Tomi Valkeinenfa91e512016-05-22 23:14:38 +03001#include <pybind11/pybind11.h>
2#include <pybind11/stl.h>
Tomi Valkeinen99167122016-06-11 21:46:24 +03003#include <kms++/kms++.h>
Tomi Valkeinen3c6ea252016-06-11 22:39:24 +03004#include <kms++util/kms++util.h>
Tomi Valkeinenfa91e512016-05-22 23:14:38 +03005
6namespace py = pybind11;
7
8using namespace kms;
9using namespace std;
10
11void 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 Valkeinen0bc5bbd2016-05-23 09:31:08 +030017 .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 Valkeinenfa91e512016-05-22 23:14:38 +030021 ;
22
Tomi Valkeinen84d89b12016-06-14 22:20:08 +030023 py::class_<ResourceManager>(m, "ResourceManager")
24 .def(py::init<Card&>())
25 .def("reset", &ResourceManager::reset)
Tomi Valkeinen05009c92017-02-07 13:39:15 +020026 .def("reserve_connector", (Connector* (ResourceManager::*)(const string& name))&ResourceManager::reserve_connector,
Tomi Valkeinen84d89b12016-06-14 22:20:08 +030027 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 Sarhab4e12b32017-03-20 18:23:17 +020033 .def("reserve_generic_plane", &ResourceManager::reserve_generic_plane,
34 py::arg("crtc"),
35 py::arg("format") = PixelFormat::Undefined)
Tomi Valkeinen84d89b12016-06-14 22:20:08 +030036 .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 Sarha7adbef52017-05-09 17:37:15 +030043 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 Valkeinen84d89b12016-06-14 22:20:08 +030049
Tomi Valkeinenfa91e512016-05-22 23:14:38 +030050 // Use lambdas to handle IMappedFramebuffer
Jyri Sarha7adbef52017-05-09 17:37:15 +030051 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 Valkeinen1e965182016-11-22 12:52:14 +020054 m.def("draw_color_bar", [](MappedFramebuffer& fb, int old_xpos, int xpos, int width) {
Tomi Valkeinenfa91e512016-05-22 23:14:38 +030055 draw_color_bar(fb, old_xpos, xpos, width);
56 } );
Tomi Valkeinen1e965182016-11-22 12:52:14 +020057 m.def("draw_rect", [](MappedFramebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color) {
Tomi Valkeinenfa91e512016-05-22 23:14:38 +030058 draw_rect(fb, x, y, w, h, color);
59 } );
Tomi Valkeinen248a5882017-05-16 15:10:10 +030060 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 Valkeinenfa91e512016-05-22 23:14:38 +030062}