summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpy/tests/scale.py66
1 files changed, 48 insertions, 18 deletions
diff --git a/py/tests/scale.py b/py/tests/scale.py
index 0b97051..0cf71dd 100755
--- a/py/tests/scale.py
+++ b/py/tests/scale.py
@@ -3,50 +3,80 @@
import pykms
import time
import random
+import argparse
+
+def plane_commit(card, crtc, plane, fb, x, y, w, h) :
+ req = pykms.AtomicReq(card)
+ req.add_plane(plane, fb, crtc, None, (x, y, w, h))
+ r = req.commit_sync()
+ assert r == 0, "Plane commit failed: %d" % r
+
+
+parser = argparse.ArgumentParser(description='Simple scaling stress test.')
+parser.add_argument('--plane', '-p', dest='plane', default="",
+ required=False, help='plane number to use')
+parser.add_argument('--connector', '-c', dest='connector', default="",
+ required=False, help='connector to output')
+
+args = parser.parse_args()
card = pykms.Card()
res = pykms.ResourceManager(card)
-conn = res.reserve_connector("hdmi")
+conn = res.reserve_connector(args.connector)
crtc = res.reserve_crtc(conn)
-plane = res.reserve_overlay_plane(crtc)
+format = pykms.PixelFormat.NV12
-mode = conn.get_default_mode()
-#mode = conn.get_mode(1920, 1080, 60, False)
-
-# Blank framefuffer for primary plane
-fb0 = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "AR24");
+if args.plane == "":
+ plane = res.reserve_generic_plane(crtc, format)
+else:
+ plane = card.planes[int(args.plane)]
-crtc.set_mode(conn, fb0, mode)
+mode = conn.get_default_mode()
+modeb = mode.to_blob(card)
+req = pykms.AtomicReq(card)
+req.add(conn, "CRTC_ID", crtc.id)
+req.add(crtc, {"ACTIVE": 1,
+ "MODE_ID": modeb.id})
+r = req.commit_sync(allow_modeset = True)
+assert r == 0, "Initial commit failed: %d" % r
# Initialize framebuffer for the scaled plane
fbX = 1920
fbY = 1080
-fb = pykms.DumbFramebuffer(card, fbX, fbY, "RG16");
+fb = pykms.DumbFramebuffer(card, fbX, fbY, format);
pykms.draw_test_pattern(fb);
-# Plane's scaled size and size increments
-W = 72
-H = 54
-Winc = 1
-Hinc = 1
+# max downscale.
+# The values bellow are for DSS5. For DSS7 use 64 for both.
+max_downscale_x=5
+max_downscale_y=8
-# Plane's position and position increments
+# Plane's initial scaled size
+W = 640
+H = 480
+
+# Plane's initial position
X = 0
Y = 0
+
+# initialize increments
+Winc = 1
+Hinc = 1
Xinc = 1
Yinc = 1
+
while True:
print("+%d+%d %dx%d" % (X, Y, W, H))
- crtc.set_plane(plane, fb, X, Y, W, H, 0, 0, fbX, fbY)
+ plane_commit(card, crtc, plane, fb, X, Y, W, H)
W = W + Winc
H = H + Hinc
if (Winc == 1 and W >= mode.hdisplay - X):
Winc = -1
- if (Winc == -1 and W <= fbX/32):
+ if (Winc == -1 and W <= fbX/max_downscale_x):
Winc = 1
if (Hinc == 1 and H >= mode.vdisplay - Y):
Hinc = -1
- if (Hinc == -1 and H <= fbY/32):
+ if (Hinc == -1 and H <= fbY/max_downscale_y):
Hinc = 1
X = X + Xinc
Y = Y + Yinc