aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen2018-09-17 09:33:47 -0500
committerTomi Valkeinen2018-09-17 09:33:47 -0500
commit646082e35978b929d55533c7dafaee68fd6b6b6f (patch)
tree72b861b08df313614444316b4c559f1d42764eb8
parent524176c33ee2b79f78d454fa621e0d32e7e72488 (diff)
downloadexternal-libkmsxx-646082e35978b929d55533c7dafaee68fd6b6b6f.tar.gz
external-libkmsxx-646082e35978b929d55533c7dafaee68fd6b6b6f.tar.xz
external-libkmsxx-646082e35978b929d55533c7dafaee68fd6b6b6f.zip
py: add AtomicReq extensions and use them in test.py
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--py/pykms/__init__.py58
-rwxr-xr-xpy/tests/test.py19
2 files changed, 61 insertions, 16 deletions
diff --git a/py/pykms/__init__.py b/py/pykms/__init__.py
index 746c917..6ee9eba 100644
--- a/py/pykms/__init__.py
+++ b/py/pykms/__init__.py
@@ -80,6 +80,64 @@ class DrmEventType(Enum):
80 VBLANK = 0x01 80 VBLANK = 0x01
81 FLIP_COMPLETE = 0x02 81 FLIP_COMPLETE = 0x02
82 82
83#
84# AtomicReq API extensions
85#
86
87def __atomic_req_add_connector(req, conn, crtc):
88 req.add(conn, "CRTC_ID", crtc.id if crtc else 0)
89
90def __atomic_req_add_crtc(req, crtc, mode_blob):
91 if mode_blob:
92 req.add(crtc, {"ACTIVE": 1, "MODE_ID": mode_blob.id})
93 else:
94 req.add(crtc, {"ACTIVE": 0, "MODE_ID": 0})
95
96def __atomic_req_add_plane(req, plane, fb, crtc,
97 src=None, dst=None, zpos=None,
98 params={}):
99 if not src and fb:
100 src = (0, 0, fb.width, fb.height)
101
102 if not dst:
103 dst = src
104
105 m = {"FB_ID": fb.id if fb else 0,
106 "CRTC_ID": crtc.id if fb else 0}
107
108 if src is not None:
109 src_x = int(round(src[0] * 65536))
110 src_y = int(round(src[1] * 65536))
111 src_w = int(round(src[2] * 65536))
112 src_h = int(round(src[3] * 65536))
113
114 m["SRC_X"] = src_x
115 m["SRC_Y"] = src_y
116 m["SRC_W"] = src_w
117 m["SRC_H"] = src_h
118
119 if dst is not None:
120 crtc_x = int(round(dst[0]))
121 crtc_y = int(round(dst[1]))
122 crtc_w = int(round(dst[2]))
123 crtc_h = int(round(dst[3]))
124
125 m["CRTC_X"] = crtc_x
126 m["CRTC_Y"] = crtc_y
127 m["CRTC_W"] = crtc_w
128 m["CRTC_H"] = crtc_h
129
130 if zpos is not None:
131 m["zpos"] = zpos
132
133 m.update(params)
134
135 req.add(plane, m)
136
137pykms.AtomicReq.add_connector = __atomic_req_add_connector
138pykms.AtomicReq.add_crtc = __atomic_req_add_crtc
139pykms.AtomicReq.add_plane = __atomic_req_add_plane
140
83# struct drm_event { 141# struct drm_event {
84# __u32 type; 142# __u32 type;
85# __u32 length; 143# __u32 length;
diff --git a/py/tests/test.py b/py/tests/test.py
index 7bb1f28..61750dc 100755
--- a/py/tests/test.py
+++ b/py/tests/test.py
@@ -43,22 +43,9 @@ card.disable_planes()
43 43
44req = pykms.AtomicReq(card) 44req = pykms.AtomicReq(card)
45 45
46req.add(conn, "CRTC_ID", crtc.id) 46req.add_connector(conn, crtc)
47 47req.add_crtc(crtc, modeb)
48req.add(crtc, {"ACTIVE": 1, 48req.add_plane(plane, fb, crtc, dst=(0, 0, mode.hdisplay, mode.vdisplay))
49 "MODE_ID": modeb.id})
50
51req.add(plane, {"FB_ID": fb.id,
52 "CRTC_ID": crtc.id,
53 "SRC_X": 0 << 16,
54 "SRC_Y": 0 << 16,
55 "SRC_W": mode.hdisplay << 16,
56 "SRC_H": mode.vdisplay << 16,
57 "CRTC_X": 0,
58 "CRTC_Y": 0,
59 "CRTC_W": mode.hdisplay,
60 "CRTC_H": mode.vdisplay,
61 "zpos": 0})
62 49
63req.commit_sync(allow_modeset = True) 50req.commit_sync(allow_modeset = True)
64 51