diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2017-01-02 16:42:08 +0200 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2017-01-03 10:46:42 +0200 |
commit | b11baff09f78a4a383f817ec35208ae8966ab832 (patch) | |
tree | 610e89719c4a3d9714a472cdc6681e36df419a1b /py/pykms/pykmsutil.cpp | |
parent | c6f964425cdec25e3d0ecd0054d398d3420fdfeb (diff) |
py: Reorganize source directory
Separate the Python bindings sources from the test scripts. While at it,
remove the unneeded run.sh script.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'py/pykms/pykmsutil.cpp')
-rw-r--r-- | py/pykms/pykmsutil.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/py/pykms/pykmsutil.cpp b/py/pykms/pykmsutil.cpp new file mode 100644 index 0000000..b3b7594 --- /dev/null +++ b/py/pykms/pykmsutil.cpp @@ -0,0 +1,49 @@ +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> +#include <kms++/kms++.h> +#include <kms++util/kms++util.h> + +namespace py = pybind11; + +using namespace kms; +using namespace std; + +void init_pykmstest(py::module &m) +{ + py::class_<RGB>(m, "RGB") + .def(py::init<>()) + .def(py::init<uint8_t, uint8_t, uint8_t&>()) + .def(py::init<uint8_t, uint8_t, uint8_t, uint8_t&>()) + .def_property_readonly("rgb888", &RGB::rgb888) + .def_property_readonly("argb8888", &RGB::argb8888) + .def_property_readonly("abgr8888", &RGB::abgr8888) + .def_property_readonly("rgb565", &RGB::rgb565) + ; + + py::class_<ResourceManager>(m, "ResourceManager") + .def(py::init<Card&>()) + .def("reset", &ResourceManager::reset) + .def("reserve_connector", &ResourceManager::reserve_connector, + py::arg("name") = string()) + .def("reserve_crtc", &ResourceManager::reserve_crtc) + .def("reserve_plane", &ResourceManager::reserve_plane, + py::arg("crtc"), + py::arg("type"), + py::arg("format") = PixelFormat::Undefined) + .def("reserve_primary_plane", &ResourceManager::reserve_primary_plane, + py::arg("crtc"), + py::arg("format") = PixelFormat::Undefined) + .def("reserve_overlay_plane", &ResourceManager::reserve_overlay_plane, + py::arg("crtc"), + py::arg("format") = PixelFormat::Undefined) + ; + + // Use lambdas to handle IMappedFramebuffer + m.def("draw_test_pattern", [](MappedFramebuffer& fb) { draw_test_pattern(fb); } ); + m.def("draw_color_bar", [](MappedFramebuffer& fb, int old_xpos, int xpos, int width) { + draw_color_bar(fb, old_xpos, xpos, width); + } ); + m.def("draw_rect", [](MappedFramebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color) { + draw_rect(fb, x, y, w, h, color); + } ); +} |