From 009828beac9bfe9c36d336a4de0d297f90aece52 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 28 Sep 2015 01:13:34 +0300 Subject: Initial version --- py/CMakeLists.txt | 26 ++++++++++++++++++++++++++ py/functest.py | 19 +++++++++++++++++++ py/pykms.i | 20 ++++++++++++++++++++ py/test.py | 19 +++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 py/CMakeLists.txt create mode 100755 py/functest.py create mode 100644 py/pykms.i create mode 100755 py/test.py (limited to 'py') diff --git a/py/CMakeLists.txt b/py/CMakeLists.txt new file mode 100644 index 0000000..39e6ec6 --- /dev/null +++ b/py/CMakeLists.txt @@ -0,0 +1,26 @@ +set(SWIG_EXECUTABLE "swig3.0") +find_package(SWIG 3.0 REQUIRED) +include(${SWIG_USE_FILE}) + +include_directories(${LIBDRM_INCLUDE_DIRS}) +link_directories(${LIBDRM_LIBRARY_DIRS}) + +pkg_check_modules(PYTHON python-3.4 REQUIRED) +include_directories(${PYTHON_INCLUDE_DIRS}) + +#include_directories(libkms) +#XXX +include_directories(../libkms++) + +#set(CMAKE_SWIG_FLAGS "-I../../libkms") + +set_source_files_properties(pykms.i PROPERTIES CPLUSPLUS ON) +swig_add_module(pykms python pykms.i) +swig_link_libraries(pykms kms++ ${LIBDRM_LIBRARIES} ${PYTHON_LIBRARIES}) + +add_custom_target(pyextras SOURCES test.py functest.py) + +add_test(NAME pytest COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/functest.py") +set_property(TEST pytest PROPERTY + ENVIRONMENT "PYTHONPATH=." "LD_LIBRARY_PATH=." +) diff --git a/py/functest.py b/py/functest.py new file mode 100755 index 0000000..54c3363 --- /dev/null +++ b/py/functest.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3.4 + +import pykms + +card = pykms.Card() + +conn = card.get_first_connected_connector() + +mode = conn.get_default_mode() + +fb = pykms.Framebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); +fb.draw_test_pattern(0); + +crtc = conn.get_current_crtc() + +crtc.set_mode(conn, fb, mode) + +print("OK") + diff --git a/py/pykms.i b/py/pykms.i new file mode 100644 index 0000000..6a6ad11 --- /dev/null +++ b/py/pykms.i @@ -0,0 +1,20 @@ +%module pykms +%{ +#include "kms++.h" +#include "utils/testpat.h" +using namespace kms; +%} + +%include "stdint.i" + +%include "decls.h" +%include "drmobject.h" +%include "atomicreq.h" +%include "crtc.h" +%include "card.h" +%include "property.h" +%include "framebuffer.h" +%include "plane.h" +%include "connector.h" +%include "encoder.h" +%include "utils/testpat.h" diff --git a/py/test.py b/py/test.py new file mode 100755 index 0000000..a104ba5 --- /dev/null +++ b/py/test.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3.4 + +import pykms + +card = pykms.Card() +card.print_short() + +conn = card.get_first_connected_connector() + +mode = conn.get_default_mode() + +fb = pykms.Framebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); +pykms.draw_test_pattern(fb); + +crtc = conn.get_current_crtc() + +crtc.set_mode(conn, fb, mode) + +input("press enter to exit\n") -- cgit v1.2.3