summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2019-10-02 12:19:10 +0300
committerGitHub <noreply@github.com>2019-10-02 12:19:10 +0300
commit934416e1dfa8222a0a1746a5a0951e2b08d02eae (patch)
treefaec976b3629eaa61335b781d1b0527c66d14c69 /py
parent6140ae4ef4ca98e3dcd9ac4aa5442abcfd44551b (diff)
parent21de1ab0f0ed584ee99b36134f4c44e9fe0fa403 (diff)
Merge pull request #37 from tomba/work
Formatting changes and testmodes.py
Diffstat (limited to 'py')
-rw-r--r--py/pykms/pykmsbase.cpp3
-rwxr-xr-xpy/tests/testmodes.py47
2 files changed, 50 insertions, 0 deletions
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp
index 668e6e3..b4dc090 100644
--- a/py/pykms/pykmsbase.cpp
+++ b/py/pykms/pykmsbase.cpp
@@ -229,6 +229,9 @@ void init_pykmsbase(py::module &m)
.def_property("hsync", &Videomode::hsync, &Videomode::set_hsync)
.def_property("vsync", &Videomode::vsync, &Videomode::set_vsync)
+
+ .def("to_string_short", &Videomode::to_string_short)
+ .def("to_string_long", &Videomode::to_string_long)
;
diff --git a/py/tests/testmodes.py b/py/tests/testmodes.py
new file mode 100755
index 0000000..0508f31
--- /dev/null
+++ b/py/tests/testmodes.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python3
+
+import sys
+import pykms
+import argparse
+
+parser = argparse.ArgumentParser()
+parser.add_argument("-c", "--connector", default="")
+args = parser.parse_args()
+
+card = pykms.Card()
+
+res = pykms.ResourceManager(card)
+conn = res.reserve_connector(args.connector)
+crtc = res.reserve_crtc(conn)
+plane = res.reserve_generic_plane(crtc)
+
+card.disable_planes()
+
+modes = conn.get_modes()
+
+def even(i):
+ return i & ~1
+
+for mode in modes:
+ long_str = mode.to_string_long()
+ short_str = mode.to_string_short()
+
+ print(long_str)
+
+ modeb = mode.to_blob(card)
+
+ fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24");
+ pykms.draw_test_pattern(fb);
+ pykms.draw_text(fb, even((fb.width // 2) - (8 * len(short_str)) // 2), 4, short_str, pykms.white)
+
+ req = pykms.AtomicReq(card)
+
+ req.add_connector(conn, crtc)
+ req.add_crtc(crtc, modeb)
+ req.add_plane(plane, fb, crtc, dst=(0, 0, mode.hdisplay, mode.vdisplay))
+
+ req.commit_sync(allow_modeset = True)
+
+ input("press enter to show next videomode\n")
+
+print("done")