diff options
author | Jyri Sarha | 2017-03-06 07:18:59 -0600 |
---|---|---|
committer | Tomi Valkeinen | 2017-03-17 08:07:14 -0500 |
commit | 12ad56d1360d6140093f2871c32593751b8ae052 (patch) | |
tree | bc30c2ef43fb7b2d8f7c0b5b365ffd2f61461786 /py/tests/modeset_event.py | |
parent | 0fa2f20e7c79ce2ebe88b01847d875e37ff21e62 (diff) | |
download | external-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-x | py/tests/modeset_event.py | 73 |
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 | |||
3 | import pykms | ||
4 | import selectors | ||
5 | import sys | ||
6 | |||
7 | def readdrm(fileobj, mask): | ||
8 | for ev in card.read_events(): | ||
9 | ev.data(ev) | ||
10 | |||
11 | def 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 | |||
19 | def eventhandler(event): | ||
20 | print("Received %s event successfully (seq %d time %f)" % | ||
21 | (event.type, event.seq, event.time)) | ||
22 | |||
23 | card = pykms.Card() | ||
24 | sel = selectors.DefaultSelector() | ||
25 | sel.register(card.fd, selectors.EVENT_READ, readdrm) | ||
26 | |||
27 | res = pykms.ResourceManager(card) | ||
28 | conn = res.reserve_connector() | ||
29 | crtc = res.reserve_crtc(conn) | ||
30 | pplane = res.reserve_primary_plane(crtc) | ||
31 | |||
32 | mode = conn.get_default_mode() | ||
33 | modeb = mode.to_blob(card) | ||
34 | |||
35 | for format in pplane.formats: | ||
36 | if format == pykms.PixelFormat.XRGB8888: | ||
37 | break | ||
38 | if format == pykms.PixelFormat.RGB565: | ||
39 | break | ||
40 | |||
41 | fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, format); | ||
42 | pykms.draw_test_pattern(fb); | ||
43 | |||
44 | # Disable request | ||
45 | card.disable_planes() | ||
46 | |||
47 | print("Setting %s to %s using %s" % (conn.fullname, mode.name, format)) | ||
48 | |||
49 | req = pykms.AtomicReq(card) | ||
50 | |||
51 | req.add(conn, "CRTC_ID", crtc.id) | ||
52 | req.add(crtc, {"ACTIVE": 1, | ||
53 | "MODE_ID": modeb.id}) | ||
54 | req.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 | |||
65 | ret = req.test(True) | ||
66 | if ret != 0: | ||
67 | print("Atomic test failed: %d" % ret) | ||
68 | sys.exit() | ||
69 | |||
70 | req.commit(eventhandler, allow_modeset = True) | ||
71 | waitevent(sel) | ||
72 | |||
73 | input("press enter to exit\n") | ||