aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--py/pykms/__init__.py14
-rwxr-xr-xpy/tests/rottest.py29
2 files changed, 23 insertions, 20 deletions
diff --git a/py/pykms/__init__.py b/py/pykms/__init__.py
index 41c1219..3b5f743 100644
--- a/py/pykms/__init__.py
+++ b/py/pykms/__init__.py
@@ -16,6 +16,20 @@ white = RGB(255, 255, 255)
16cyan = RGB(0, 255, 255) 16cyan = RGB(0, 255, 255)
17 17
18# 18#
19# Rotation enum
20#
21
22class Rotation(int, Enum):
23 ROTATE_0 = 1 << 0
24 ROTATE_90 = 1 << 1
25 ROTATE_180 = 1 << 2
26 ROTATE_270 = 1 << 3
27 ROTATE_MASK = ROTATE_0 | ROTATE_90 | ROTATE_180 | ROTATE_270
28 REFLECT_X = 1 << 4
29 REFLECT_Y = 1 << 5
30 REFLECT_MASK = REFLECT_X | REFLECT_Y
31
32#
19# DrmObject API extensions 33# DrmObject API extensions
20# 34#
21 35
diff --git a/py/tests/rottest.py b/py/tests/rottest.py
index 4dae95e..d81a962 100755
--- a/py/tests/rottest.py
+++ b/py/tests/rottest.py
@@ -43,23 +43,12 @@ req.add(crtc, {"ACTIVE": 1,
43 43
44req.commit_sync(allow_modeset = True) 44req.commit_sync(allow_modeset = True)
45 45
46class Rotation(int, Enum):
47 ROTATE_0 = 1 << 0
48 ROTATE_90 = 1 << 1
49 ROTATE_180 = 1 << 2
50 ROTATE_270 = 1 << 3
51 ROTATE_MASK = ROTATE_0 | ROTATE_90 | ROTATE_180 | ROTATE_270
52 REFLECT_X = 1 << 4
53 REFLECT_Y = 1 << 5
54 REFLECT_MASK = REFLECT_X | REFLECT_Y
55
56
57def show_rot_plane(crtc, plane, fb, rot, x_scale, y_scale): 46def show_rot_plane(crtc, plane, fb, rot, x_scale, y_scale):
58 47
59 crtc_w = int(fb_w * x_scale) 48 crtc_w = int(fb_w * x_scale)
60 crtc_h = int(fb_h * y_scale) 49 crtc_h = int(fb_h * y_scale)
61 50
62 if (rot & Rotation.ROTATE_90) or (rot & Rotation.ROTATE_270): 51 if (rot & pykms.Rotation.ROTATE_90) or (rot & pykms.Rotation.ROTATE_270):
63 tmp = crtc_w 52 tmp = crtc_w
64 crtc_w = crtc_h 53 crtc_w = crtc_h
65 crtc_h = tmp 54 crtc_h = tmp
@@ -78,9 +67,9 @@ def show_rot_plane(crtc, plane, fb, rot, x_scale, y_scale):
78 src_x, src_y, src_w, src_h, 67 src_x, src_y, src_w, src_h,
79 crtc_x, crtc_y, crtc_w, crtc_h)) 68 crtc_x, crtc_y, crtc_w, crtc_h))
80 69
81 angle_str = Rotation(rot & Rotation.ROTATE_MASK).name 70 angle_str = pykms.Rotation(rot & pykms.Rotation.ROTATE_MASK).name
82 reflect_x_str = "REFLECT_X" if rot & Rotation.REFLECT_X else "" 71 reflect_x_str = "REFLECT_X" if rot & pykms.Rotation.REFLECT_X else ""
83 reflect_y_str = "REFLECT_Y" if rot & Rotation.REFLECT_Y else "" 72 reflect_y_str = "REFLECT_Y" if rot & pykms.Rotation.REFLECT_Y else ""
84 73
85 print("{} {} {}".format(angle_str, reflect_x_str, reflect_y_str)) 74 print("{} {} {}".format(angle_str, reflect_x_str, reflect_y_str))
86 75
@@ -119,7 +108,7 @@ pykms.draw_text(fb, even((fb_w // 2) - (8 * 6) // 2), fb_h - 8 - 4, "BOTTOM", py
119pykms.draw_text(fb, 4, even(((fb_h // 2) - 4)), "L", pykms.white) 108pykms.draw_text(fb, 4, even(((fb_h // 2) - 4)), "L", pykms.white)
120pykms.draw_text(fb, fb_w - 8 - 4, even(((fb_h // 2) - 4)), "R", pykms.white) 109pykms.draw_text(fb, fb_w - 8 - 4, even(((fb_h // 2) - 4)), "R", pykms.white)
121 110
122rots = [ Rotation.ROTATE_0, Rotation.ROTATE_90, Rotation.ROTATE_180, Rotation.ROTATE_270 ] 111rots = [ pykms.Rotation.ROTATE_0, pykms.Rotation.ROTATE_90, pykms.Rotation.ROTATE_180, pykms.Rotation.ROTATE_270 ]
123cursors = [ "A", "D", "B", "C" ] 112cursors = [ "A", "D", "B", "C" ]
124 113
125print("Use the cursor keys, x and y to change rotation. Press q to quit.") 114print("Use the cursor keys, x and y to change rotation. Press q to quit.")
@@ -131,7 +120,7 @@ tty.setcbreak(fd)
131try: 120try:
132 esc_seq = 0 121 esc_seq = 0
133 122
134 current_rot = Rotation.ROTATE_0 123 current_rot = pykms.Rotation.ROTATE_0
135 124
136 show_rot_plane(crtc, plane, fb, current_rot, x_scale, y_scale) 125 show_rot_plane(crtc, plane, fb, current_rot, x_scale, y_scale)
137 126
@@ -160,7 +149,7 @@ try:
160 149
161 rot = rots[cursors.index(c)] 150 rot = rots[cursors.index(c)]
162 151
163 current_rot &= ~Rotation.ROTATE_MASK 152 current_rot &= ~pykms.Rotation.ROTATE_MASK
164 current_rot |= rot 153 current_rot |= rot
165 154
166 changed = True 155 changed = True
@@ -169,10 +158,10 @@ try:
169 if c == "q": 158 if c == "q":
170 break 159 break
171 elif c == "x": 160 elif c == "x":
172 current_rot ^= Rotation.REFLECT_X 161 current_rot ^= pykms.Rotation.REFLECT_X
173 changed = True 162 changed = True
174 elif c == "y": 163 elif c == "y":
175 current_rot ^= Rotation.REFLECT_Y 164 current_rot ^= pykms.Rotation.REFLECT_Y
176 changed = True 165 changed = True
177 166
178 if changed: 167 if changed: