Home | History | Annotate | Download | only in pykms
      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 
     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 
     23 	py::class_<ResourceManager>(m, "ResourceManager")
     24 			.def(py::init<Card&>())
     25 			.def("reset", &ResourceManager::reset)
     26 			.def("reserve_connector", (Connector* (ResourceManager::*)(const string& name))&ResourceManager::reserve_connector,
     27 			     py::arg("name") = string())
     28 			.def("reserve_crtc", (Crtc* (ResourceManager::*)(Connector*))&ResourceManager::reserve_crtc)
     29 			.def("reserve_plane", (Plane* (ResourceManager::*)(Crtc*, PlaneType, PixelFormat))&ResourceManager::reserve_plane,
     30 			     py::arg("crtc"),
     31 			     py::arg("type"),
     32 			     py::arg("format") = PixelFormat::Undefined)
     33 			.def("reserve_generic_plane", &ResourceManager::reserve_generic_plane,
     34 			     py::arg("crtc"),
     35 			     py::arg("format") = PixelFormat::Undefined)
     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 			;
     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 			;
     49 
     50 	// Use lambdas to handle IFramebuffer
     51 	m.def("draw_test_pattern", [](Framebuffer& fb, YUVType yuvt) { draw_test_pattern(fb, yuvt); },
     52 	      py::arg("fb"),
     53 	      py::arg("yuvt") = YUVType::BT601_Lim);
     54 	m.def("draw_color_bar", [](Framebuffer& fb, int old_xpos, int xpos, int width) {
     55 		draw_color_bar(fb, old_xpos, xpos, width);
     56 	} );
     57 	m.def("draw_rect", [](Framebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color) {
     58 		draw_rect(fb, x, y, w, h, color);
     59 	} );
     60 	m.def("draw_text", [](Framebuffer& fb, uint32_t x, uint32_t y, const string& str, RGB color) {
     61 		draw_text(fb, x, y, str, color); } );
     62 }
     63