From 4934864106c4c4ba56559ed2096970e1ea5d7d94 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 22 Nov 2016 13:13:20 +0200 Subject: py: Add OmapCard & OmapFramebuffer support Signed-off-by: Tomi Valkeinen --- CMakeLists.txt | 4 ++++ py/CMakeLists.txt | 8 +++++++- py/pykms.cpp | 7 +++++++ py/pykmsomap.cpp | 21 +++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 py/pykmsomap.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 30cb5f5..dccdf14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,11 @@ endif() find_package(PkgConfig REQUIRED) pkg_check_modules(LIBDRM libdrm>=2.4.64 REQUIRED) + pkg_check_modules(LIBDRM_OMAP libdrm_omap) +if(LIBDRM_OMAP_FOUND) + add_definitions(-DHAS_LIBDRM_OMAP) +endif() enable_testing() diff --git a/py/CMakeLists.txt b/py/CMakeLists.txt index 0cb4b99..69bb845 100644 --- a/py/CMakeLists.txt +++ b/py/CMakeLists.txt @@ -10,7 +10,13 @@ endif() include_directories(${PROJECT_SOURCE_DIR}/ext/pybind11/include) -add_library(pykms SHARED pykms.cpp pykmsbase.cpp pykmsutil.cpp pyvid.cpp) +set(SRCS pykms.cpp pykmsbase.cpp pykmsutil.cpp pyvid.cpp) + +if(LIBDRM_OMAP_FOUND) + set(SRCS ${SRCS} pykmsomap.cpp) +endif() + +add_library(pykms SHARED ${SRCS}) target_link_libraries(pykms kms++ kms++util ${LIBDRM_LIBRARIES}) # Don't add a 'lib' prefix to the shared library diff --git a/py/pykms.cpp b/py/pykms.cpp index c759d23..2199039 100644 --- a/py/pykms.cpp +++ b/py/pykms.cpp @@ -11,6 +11,10 @@ void init_pykmstest(py::module &m); void init_pykmsbase(py::module &m); void init_pyvid(py::module &m); +#if HAS_LIBDRM_OMAP +void init_pykmsomap(py::module &m); +#endif + class PyPageFlipHandlerBase : PageFlipHandlerBase { public: @@ -42,5 +46,8 @@ PYBIND11_PLUGIN(pykms) { init_pyvid(m); +#if HAS_LIBDRM_OMAP + init_pykmsomap(m); +#endif return m.ptr(); } diff --git a/py/pykmsomap.cpp b/py/pykmsomap.cpp new file mode 100644 index 0000000..525834b --- /dev/null +++ b/py/pykmsomap.cpp @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +namespace py = pybind11; + +using namespace kms; +using namespace std; + +void init_pykmsomap(py::module &m) +{ + py::class_(m, "OmapCard", py::base()) + .def(py::init<>()) + ; + + py::class_(m, "OmapFramebuffer", py::base()) + .def(py::init(), + py::keep_alive<1, 2>()) // Keep OmapCard alive until this is destructed + ; +} -- cgit v1.2.3