• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <pybind11/pybind11.h>
2 #include <pybind11/stl.h>
3 #include <kms++/kms++.h>
4 #include <kms++util/kms++util.h>
5 
6 namespace py = pybind11;
7 
8 using namespace kms;
9 using namespace std;
10 
init_pykmstest(py::module & m)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&>())
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);
21 
22 	py::class_<ResourceManager>(m, "ResourceManager")
23 		.def(py::init<Card&>())
24 		.def("reset", &ResourceManager::reset)
25 		.def("reserve_connector", (Connector * (ResourceManager::*)(const string& name)) & ResourceManager::reserve_connector,
26 		     py::arg("name") = string())
27 		.def("reserve_crtc", (Crtc * (ResourceManager::*)(Connector*)) & ResourceManager::reserve_crtc)
28 		.def("reserve_plane", (Plane * (ResourceManager::*)(Crtc*, PlaneType, PixelFormat)) & ResourceManager::reserve_plane,
29 		     py::arg("crtc"),
30 		     py::arg("type"),
31 		     py::arg("format") = PixelFormat::Undefined)
32 		.def("reserve_generic_plane", &ResourceManager::reserve_generic_plane,
33 		     py::arg("crtc"),
34 		     py::arg("format") = PixelFormat::Undefined)
35 		.def("reserve_primary_plane", &ResourceManager::reserve_primary_plane,
36 		     py::arg("crtc"),
37 		     py::arg("format") = PixelFormat::Undefined)
38 		.def("reserve_overlay_plane", &ResourceManager::reserve_overlay_plane,
39 		     py::arg("crtc"),
40 		     py::arg("format") = PixelFormat::Undefined);
41 	py::enum_<YUVType>(m, "YUVType")
42 		.value("BT601_Lim", YUVType::BT601_Lim)
43 		.value("BT601_Full", YUVType::BT601_Full)
44 		.value("BT709_Lim", YUVType::BT709_Lim)
45 		.value("BT709_Full", YUVType::BT709_Full);
46 
47 	// Use lambdas to handle IFramebuffer
48 	m.def(
49 		"draw_test_pattern", [](Framebuffer& fb, YUVType yuvt) { draw_test_pattern(fb, yuvt); },
50 		py::arg("fb"),
51 		py::arg("yuvt") = YUVType::BT601_Lim);
52 	m.def("draw_color_bar", [](Framebuffer& fb, int old_xpos, int xpos, int width) {
53 		draw_color_bar(fb, old_xpos, xpos, width);
54 	});
55 	m.def("draw_rect", [](Framebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color) {
56 		draw_rect(fb, x, y, w, h, color);
57 	});
58 	m.def("draw_circle", [](Framebuffer& fb, int32_t xCenter, int32_t yCenter, int32_t radius, RGB color) {
59 		draw_circle(fb, xCenter, yCenter, radius, color);
60 	});
61 	m.def("draw_text", [](Framebuffer& fb, uint32_t x, uint32_t y, const string& str, RGB color) { draw_text(fb, x, y, str, color); });
62 }
63