aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJyri Sarha2017-03-06 07:18:59 -0600
committerTomi Valkeinen2017-03-17 08:07:14 -0500
commit12ad56d1360d6140093f2871c32593751b8ae052 (patch)
treebc30c2ef43fb7b2d8f7c0b5b365ffd2f61461786 /py/tests/modeset_event.py
parent0fa2f20e7c79ce2ebe88b01847d875e37ff21e62 (diff)
downloadexternal-kmsxx-12ad56d1360d6140093f2871c32593751b8ae052.tar.gz
external-kmsxx-12ad56d1360d6140093f2871c32593751b8ae052.tar.xz
external-kmsxx-12ad56d1360d6140093f2871c32593751b8ae052.zip
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/modeset_event.py')
-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 @@
1#!/usr/bin/python3
2
3import pykms
4import selectors
5import sys
6
7def readdrm(fileobj, mask):
8 for ev in card.read_events():
9 ev.data(ev)
10
11def waitevent(sel):
12 events = sel.select(1)
13 if not events:
14 print("Error: timeout receiving event")
15 else:
16 for key, mask in events:
17 key.data(key.fileobj, mask)
18
19def eventhandler(event):
20 print("Received %s event successfully (seq %d time %f)" %
21 (event.type, event.seq, event.time))
22
23card = pykms.Card()
24sel = selectors.DefaultSelector()
25sel.register(card.fd, selectors.EVENT_READ, readdrm)
26
27res = pykms.ResourceManager(card)
28conn = res.reserve_connector()
29crtc = res.reserve_crtc(conn)
30pplane = res.reserve_primary_plane(crtc)
31
32mode = conn.get_default_mode()
33modeb = mode.to_blob(card)
34
35for format in pplane.formats:
36 if format == pykms.PixelFormat.XRGB8888:
37 break
38 if format == pykms.PixelFormat.RGB565:
39 break
40
41fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, format);
42pykms.draw_test_pattern(fb);
43
44# Disable request
45card.disable_planes()
46
47print("Setting %s to %s using %s" % (conn.fullname, mode.name, format))
48
49req = pykms.AtomicReq(card)
50
51req.add(conn, "CRTC_ID", crtc.id)
52req.add(crtc, {"ACTIVE": 1,
53 "MODE_ID": modeb.id})
54req.add(pplane, {"FB_ID": fb.id,
55 "CRTC_ID": crtc.id,
56 "SRC_X": 0 << 16,
57 "SRC_Y": 0 << 16,
58 "SRC_W": mode.hdisplay << 16,
59 "SRC_H": mode.vdisplay << 16,
60 "CRTC_X": 0,
61 "CRTC_Y": 0,
62 "CRTC_W": mode.hdisplay,
63 "CRTC_H": mode.vdisplay})
64
65ret = req.test(True)
66if ret != 0:
67 print("Atomic test failed: %d" % ret)
68 sys.exit()
69
70req.commit(eventhandler, allow_modeset = True)
71waitevent(sel)
72
73input("press enter to exit\n")