summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@iki.fi>2015-09-28 01:13:34 +0300
committerTomi Valkeinen <tomi.valkeinen@iki.fi>2015-09-28 01:13:34 +0300
commit009828beac9bfe9c36d336a4de0d297f90aece52 (patch)
tree3ea6b22f2036dcc0c23c459ce53bfc2ad282e3e7 /py
Initial version
Diffstat (limited to 'py')
-rw-r--r--py/CMakeLists.txt26
-rwxr-xr-xpy/functest.py19
-rw-r--r--py/pykms.i20
-rwxr-xr-xpy/test.py19
4 files changed, 84 insertions, 0 deletions
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")