summaryrefslogtreecommitdiff
path: root/py/tests/plane_hog.py
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2017-03-21 15:04:24 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-03-21 15:04:24 +0200
commit2439ae8738ad9410441c6160f512ab64ec94333d (patch)
treefbb274db500a09fa0191f260b04659b85350154a /py/tests/plane_hog.py
parent9aeb121657a076a0c03ac6e7fc3c1e93e465e5d9 (diff)
parentdce8d396848c509d77b7fe8f745ea29e74af9c0c (diff)
Merge branch 'universal-planes2' of git://github.com/jsarha/kmsxx
Diffstat (limited to 'py/tests/plane_hog.py')
-rwxr-xr-xpy/tests/plane_hog.py136
1 files changed, 136 insertions, 0 deletions
diff --git a/py/tests/plane_hog.py b/py/tests/plane_hog.py
new file mode 100755
index 0000000..5bdc937
--- /dev/null
+++ b/py/tests/plane_hog.py
@@ -0,0 +1,136 @@
+#!/usr/bin/python3
+
+import pykms
+import sys
+
+card = pykms.Card()
+res = pykms.ResourceManager(card)
+
+conn1 = False
+conn2 = False
+
+for conn in card.connectors:
+ if not conn1:
+ conn1 = conn
+ elif not conn2:
+ conn2 = conn
+ else:
+ break
+
+crtc1 = res.reserve_crtc(conn1)
+mode1 = conn1.get_default_mode()
+modeb1 = mode1.to_blob(card)
+print("CRTC idx %d goes to %s connector" % (crtc1.idx, conn1.fullname))
+
+if conn2:
+ crtc2 = res.reserve_crtc(conn2)
+ mode2 = conn2.get_default_mode()
+ modeb2 = mode2.to_blob(card)
+ print("CRTC idx %d goes to %s connector" % (crtc2.idx, conn2.fullname))
+
+fbwidth = 480
+fbheight = 270
+
+fb = pykms.DumbFramebuffer(card, fbwidth, fbheight, "AR24");
+pykms.draw_test_pattern(fb);
+
+# Disable request
+card.disable_planes()
+
+plane_list = []
+
+while True:
+ plane = res.reserve_generic_plane(crtc1)
+ if plane:
+ print("Got plane idx %d" % plane.idx)
+ plane_list.append(plane)
+ else:
+ break
+
+print("Got %d planes" % len(plane_list))
+
+req = pykms.AtomicReq(card)
+req.add(conn1, "CRTC_ID", crtc1.id)
+req.add(crtc1, {"ACTIVE": 1,
+ "MODE_ID": modeb1.id})
+
+input("Press enter to enable crtc idx %d at %s" % (crtc1.idx, conn1.fullname))
+r = req.commit_sync(allow_modeset = True)
+
+print("Crtc enable request returned %d\n" % r)
+
+x = 0
+y = 0
+z = 0
+
+for plane in plane_list:
+ input("Press enter to enable plane idx %d on crtc idx %d" %
+ (plane.idx, crtc1.idx))
+ req = pykms.AtomicReq(card)
+ req.add(plane, {"FB_ID": fb.id,
+ "CRTC_ID": crtc1.id,
+ "SRC_X": 0 << 16,
+ "SRC_Y": 0 << 16,
+ "SRC_W": fb.width << 16,
+ "SRC_H": fb.height << 16,
+ "CRTC_X": x,
+ "CRTC_Y": y,
+ "CRTC_W": fb.width,
+ "CRTC_H": fb.height,
+ "zorder": z})
+ r = req.commit_sync()
+ print("Plane enable request returned %d\n" % r)
+
+ x = x + 50
+ y = y + 50
+ z = z + 1
+
+if not conn2:
+ sys.exit()
+
+req = pykms.AtomicReq(card)
+req.add(conn2, "CRTC_ID", crtc2.id)
+req.add(crtc2, {"ACTIVE": 1,
+ "MODE_ID": modeb2.id})
+
+input("Press enter to enable crtc idx %d at %s" % (crtc2.idx, conn2.fullname))
+r = req.commit_sync(allow_modeset = True)
+print("Crtc enable request returned %d\n" % r)
+
+x = 0
+y = 0
+z = 0
+
+# Code assumes that planes for crtc1 also work for crtc2
+for plane in reversed(plane_list):
+
+ input("Press enter to disable plane idx %d on crtc idx %d" %
+ (plane.idx, crtc1.idx))
+ req = pykms.AtomicReq(card)
+ req.add(plane, {"FB_ID": 0,
+ "CRTC_ID": 0})
+ r = req.commit_sync(allow_modeset = True)
+ print("Plane disable request returned %d\n" % r)
+
+ input("Press enter to enable plane idx %d on crtc idx %d" %
+ (plane.idx, crtc2.idx))
+ req = pykms.AtomicReq(card)
+ req.add(plane, {"FB_ID": fb.id,
+ "CRTC_ID": crtc2.id,
+ "SRC_X": 0 << 16,
+ "SRC_Y": 0 << 16,
+ "SRC_W": fb.width << 16,
+ "SRC_H": fb.height << 16,
+ "CRTC_X": x,
+ "CRTC_Y": y,
+ "CRTC_W": fb.width,
+ "CRTC_H": fb.height,
+ "zorder": z})
+ r = req.commit_sync(allow_modeset = True)
+ print("Plane enable request returned %d\n" % r)
+
+ x = x + 50
+ y = y + 50
+ z = z + 1
+
+input("press enter to exit\n")