summaryrefslogtreecommitdiff
path: root/py/tests
diff options
context:
space:
mode:
authorJyri Sarha <jsarha@ti.com>2017-03-06 15:18:59 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-03-17 15:07:14 +0200
commit12ad56d1360d6140093f2871c32593751b8ae052 (patch)
treebc30c2ef43fb7b2d8f7c0b5b365ffd2f61461786 /py/tests
parent0fa2f20e7c79ce2ebe88b01847d875e37ff21e62 (diff)
Add modeset_event.py
modeset_event.py tests committing a full mode set asynchronously and receiving a flip event about it. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'py/tests')
-rwxr-xr-xpy/tests/modeset_event.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/py/tests/modeset_event.py b/py/tests/modeset_event.py
new file mode 100755
index 0000000..0957e51
--- /dev/null
+++ b/py/tests/modeset_event.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python3
+
+import pykms
+import selectors
+import sys
+
+def readdrm(fileobj, mask):
+ for ev in card.read_events():
+ ev.data(ev)
+
+def waitevent(sel):
+ events = sel.select(1)
+ if not events:
+ print("Error: timeout receiving event")
+ else:
+ for key, mask in events:
+ key.data(key.fileobj, mask)
+
+def eventhandler(event):
+ print("Received %s event successfully (seq %d time %f)" %
+ (event.type, event.seq, event.time))
+
+card = pykms.Card()
+sel = selectors.DefaultSelector()
+sel.register(card.fd, selectors.EVENT_READ, readdrm)
+
+res = pykms.ResourceManager(card)
+conn = res.reserve_connector()
+crtc = res.reserve_crtc(conn)
+pplane = res.reserve_primary_plane(crtc)
+
+mode = conn.get_default_mode()
+modeb = mode.to_blob(card)
+
+for format in pplane.formats:
+ if format == pykms.PixelFormat.XRGB8888:
+ break
+ if format == pykms.PixelFormat.RGB565:
+ break
+
+fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, format);
+pykms.draw_test_pattern(fb);
+
+# Disable request
+card.disable_planes()
+
+print("Setting %s to %s using %s" % (conn.fullname, mode.name, format))
+
+req = pykms.AtomicReq(card)
+
+req.add(conn, "CRTC_ID", crtc.id)
+req.add(crtc, {"ACTIVE": 1,
+ "MODE_ID": modeb.id})
+req.add(pplane, {"FB_ID": fb.id,
+ "CRTC_ID": crtc.id,
+ "SRC_X": 0 << 16,
+ "SRC_Y": 0 << 16,
+ "SRC_W": mode.hdisplay << 16,
+ "SRC_H": mode.vdisplay << 16,
+ "CRTC_X": 0,
+ "CRTC_Y": 0,
+ "CRTC_W": mode.hdisplay,
+ "CRTC_H": mode.vdisplay})
+
+ret = req.test(True)
+if ret != 0:
+ print("Atomic test failed: %d" % ret)
+ sys.exit()
+
+req.commit(eventhandler, allow_modeset = True)
+waitevent(sel)
+
+input("press enter to exit\n")