aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJyri Sarha2017-03-24 15:47:53 -0500
committerJyri Sarha2017-05-31 10:49:20 -0500
commite71c232660a7480c2b56f6e76e83fad4c7e9da8a (patch)
tree890f7255209604be2e5a7b2fa382b6b15a83ac85
parent2602a5d27444423595764556947218a8a23129ac (diff)
downloadexternal-libkmsxx-e71c232660a7480c2b56f6e76e83fad4c7e9da8a.tar.gz
external-libkmsxx-e71c232660a7480c2b56f6e76e83fad4c7e9da8a.tar.xz
external-libkmsxx-e71c232660a7480c2b56f6e76e83fad4c7e9da8a.zip
Add ctm_test.py test for testing CRTC's CTM color matrix property.
-rwxr-xr-xpy/tests/ctm_test.py86
1 files changed, 86 insertions, 0 deletions
diff --git a/py/tests/ctm_test.py b/py/tests/ctm_test.py
new file mode 100755
index 0000000..7ceed6f
--- /dev/null
+++ b/py/tests/ctm_test.py
@@ -0,0 +1,86 @@
1#!/usr/bin/python3
2
3import sys
4import pykms
5
6def ctm_to_blob(ctm, card):
7 len=9
8 arr = bytearray(len*8)
9 view = memoryview(arr).cast("I")
10
11 for x in range(len):
12 i, d = divmod(ctm[x], 1)
13 if i < 0:
14 i = -i
15 sign = 1 << 31
16 else:
17 sign = 0
18 view[x * 2 + 0] = int(d * ((2 ** 32) - 1))
19 view[x * 2 + 1] = int(i) | sign
20 #print("%f = %08x.%08x" % (ctm[x], view[x * 2 + 1], view[x * 2 + 0]))
21
22 return pykms.Blob(card, arr);
23
24
25if len(sys.argv) > 1:
26 conn_name = sys.argv[1]
27else:
28 conn_name = ""
29
30card = pykms.Card()
31res = pykms.ResourceManager(card)
32conn = res.reserve_connector(conn_name)
33crtc = res.reserve_crtc(conn)
34mode = conn.get_default_mode()
35
36fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24");
37pykms.draw_test_pattern(fb);
38
39crtc.set_mode(conn, fb, mode)
40
41input("press enter to set normal ctm\n")
42
43ctm = [ 1.0, 0.0, 0.0,
44 0.0, 1.0, 0.0,
45 0.0, 0.0, 1.0 ]
46
47ctmb = ctm_to_blob(ctm, card)
48
49crtc.set_prop("CTM", ctmb.id)
50
51input("press enter to set new ctm\n")
52
53ctm = [ 0.0, 1.0, 0.0,
54 0.0, 0.0, 1.0,
55 1.0, 0.0, 0.0 ]
56
57ctmb = ctm_to_blob(ctm, card)
58
59crtc.set_prop("CTM", ctmb.id)
60
61print("r->b g->r b->g ctm active\n")
62
63input("press enter to set new ctm\n")
64
65ctm = [ 0.0, 0.0, 1.0,
66 1.0, 0.0, 0.0,
67 0.0, 1.0, 0.0 ]
68
69ctmb = ctm_to_blob(ctm, card)
70
71crtc.set_prop("CTM", ctmb.id)
72input("r->g g->b b->r ctm active\n")
73
74input("press enter to turn off the crtc\n")
75
76crtc.disable_mode()
77
78input("press enter to enable crtc again\n")
79
80crtc.set_mode(conn, fb, mode)
81
82input("press enter to remove ctm\n")
83
84crtc.set_prop("CTM", 0)
85
86input("press enter to exit\n")