diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2020-02-14 13:29:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-14 13:29:43 +0200 |
commit | 7c5e645112a899ad018219365c3898b0e896353f (patch) | |
tree | bf433d405c0b26c188153c9f2958c04d35927406 | |
parent | ada382fa5153dce6e4b8449c9e46c827c170eb95 (diff) | |
parent | 0891b9428b26a5ae208cc7cd1da70bd13eb688e9 (diff) |
Merge pull request #50 from jsarha/py-tests-tidss-updates-v3
Py tests tidss updates v3
-rwxr-xr-x | py/tests/alpha-test.py | 48 | ||||
-rwxr-xr-x | py/tests/ctm_test.py | 59 | ||||
-rwxr-xr-x | py/tests/global_alpha_test.py | 25 |
3 files changed, 94 insertions, 38 deletions
diff --git a/py/tests/alpha-test.py b/py/tests/alpha-test.py index e329ce4..94d3836 100755 --- a/py/tests/alpha-test.py +++ b/py/tests/alpha-test.py @@ -2,24 +2,38 @@ import pykms import time +import argparse + +parser = argparse.ArgumentParser(description='Simple alpha blending test.') +parser.add_argument('--resetcrtc', action="store_true", + help='Reset legacy CRTC color properties') +parser.add_argument('--connector', '-c', dest='connector', default="", + required=False, help='connector to output') +parser.add_argument('--mode', '-m', dest='modename', + required=False, help='Video mode name to use') +args = parser.parse_args() + +max_planes = 4 card = pykms.Card() res = pykms.ResourceManager(card) -conn = res.reserve_connector() +conn = res.reserve_connector(args.connector) crtc = res.reserve_crtc(conn) -mode = conn.get_default_mode() +if args.modename == None: + mode = conn.get_default_mode() +else: + mode = conn.get_mode(args.modename) planes = [] -for i in range(3): +for i in range(max_planes): p = res.reserve_generic_plane(crtc) - if p == None: - print("Need 3 planes!") - exit(1) - + break planes.append(p) +print("Got {} planes. Test supports up to 4 planes.".format(len(planes))) + card.disable_planes() w = mode.hdisplay @@ -27,25 +41,29 @@ h = mode.vdisplay fbs=[] -for i in range(len(planes)): +for i in range(max_planes): fbs.append(pykms.DumbFramebuffer(card, w, h, "AR24")) pykms.draw_rect(fbs[0], 50, 50, 200, 200, pykms.RGB(128, 255, 0, 0)) pykms.draw_rect(fbs[1], 150, 50, 200, 200, pykms.RGB(128, 0, 255, 0)) pykms.draw_rect(fbs[2], 50, 150, 200, 200, pykms.RGB(128, 0, 0, 255)) +pykms.draw_rect(fbs[3], 150, 150, 200, 200, pykms.RGB(128, 128, 128, 128)) + +card.disable_planes() -crtc.set_props({ - "trans-key-mode": 0, - "trans-key": 0, - "background": 0, - "alpha_blender": 1, -}) +if args.resetcrtc: + crtc.set_props({ + "trans-key-mode": 0, + "trans-key": 0, + "background": 0, + "alpha_blender": 1, + }) for i in range(len(planes)): plane = planes[i] fb = fbs[i] - print("set crtc {}, plane {}, fb {}".format(crtc.id, p.id, fbs[i].id)) + print("set crtc {}, plane {}, z {}, fb {}".format(crtc.id, plane.id, i, fb.id)) plane.set_props({ "FB_ID": fb.id, diff --git a/py/tests/ctm_test.py b/py/tests/ctm_test.py index 7ceed6f..2273221 100755 --- a/py/tests/ctm_test.py +++ b/py/tests/ctm_test.py @@ -2,6 +2,7 @@ import sys import pykms +import argparse def ctm_to_blob(ctm, card): len=9 @@ -22,33 +23,38 @@ def ctm_to_blob(ctm, card): return pykms.Blob(card, arr); -if len(sys.argv) > 1: - conn_name = sys.argv[1] -else: - conn_name = "" +parser = argparse.ArgumentParser(description='Simple CRTC CTM-property test.') +parser.add_argument('--connector', '-c', dest='connector', + required=False, help='connector to output') +parser.add_argument('--mode', '-m', dest='modename', + required=False, help='Video mode name to use') +parser.add_argument('--plane', '-p', dest='plane', type=int, + required=False, help='plane number to use') +args = parser.parse_args() card = pykms.Card() res = pykms.ResourceManager(card) -conn = res.reserve_connector(conn_name) +conn = res.reserve_connector(args.connector) crtc = res.reserve_crtc(conn) -mode = conn.get_default_mode() +format = pykms.PixelFormat.ARGB8888 +if args.modename == None: + mode = conn.get_default_mode() +else: + mode = conn.get_mode(args.modename) +modeb = mode.to_blob(card) fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); pykms.draw_test_pattern(fb); -crtc.set_mode(conn, fb, mode) - -input("press enter to set normal ctm\n") - -ctm = [ 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0 ] - -ctmb = ctm_to_blob(ctm, card) +if args.plane == None: + plane = res.reserve_generic_plane(crtc, fb.format) +else: + plane = card.planes[args.plane] -crtc.set_prop("CTM", ctmb.id) +card.disable_planes() +crtc.disable_mode() -input("press enter to set new ctm\n") +input("press enter to set ctm at the same time with crtc mode\n") ctm = [ 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, @@ -56,10 +62,27 @@ ctm = [ 0.0, 1.0, 0.0, ctmb = ctm_to_blob(ctm, card) -crtc.set_prop("CTM", ctmb.id) +req = pykms.AtomicReq(card) +req.add(conn, "CRTC_ID", crtc.id) +req.add(crtc, {"ACTIVE": 1, + "MODE_ID": modeb.id, + "CTM": ctmb.id}) +req.add_plane(plane, fb, crtc) +r = req.commit_sync(allow_modeset = True) +assert r == 0, "Initial commit failed: %d" % r print("r->b g->r b->g ctm active\n") +input("press enter to set normal ctm\n") + +ctm = [ 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 ] + +ctmb = ctm_to_blob(ctm, card) + +crtc.set_prop("CTM", ctmb.id) + input("press enter to set new ctm\n") ctm = [ 0.0, 0.0, 1.0, diff --git a/py/tests/global_alpha_test.py b/py/tests/global_alpha_test.py index 6981b72..33fd12e 100755 --- a/py/tests/global_alpha_test.py +++ b/py/tests/global_alpha_test.py @@ -2,12 +2,22 @@ import pykms import time - +import argparse + +parser = argparse.ArgumentParser(description='Plane "alpha"-property test.') +parser.add_argument('--connector', '-c', dest='connector', default="", + required=False, help='connector to output') +parser.add_argument('--mode', '-m', dest='modename', + required=False, help='Video mode name to use') +args = parser.parse_args() card = pykms.Card() res = pykms.ResourceManager(card) -conn = res.reserve_connector("") +conn = res.reserve_connector(args.connector) crtc = res.reserve_crtc(conn) -mode = conn.get_default_mode() +if args.modename == None: + mode = conn.get_default_mode() +else: + mode = conn.get_mode(args.modename) modeb = mode.to_blob(card) format = pykms.PixelFormat.ARGB8888 plane1 = res.reserve_generic_plane(crtc, format) @@ -24,6 +34,8 @@ pykms.draw_test_pattern(fb2); alpha = 0 +card.disable_planes() + req = pykms.AtomicReq(card) req.add(conn, "CRTC_ID", crtc.id) req.add(crtc, {"ACTIVE": 1, @@ -34,13 +46,16 @@ req.add_plane(plane2, fb2, crtc) r = req.commit_sync(allow_modeset = True) assert r == 0, "Initial commit failed: %d" % r +input("press enter start\n") + while alpha <= 0xFFFF: print("alpha %d" % (alpha >> 8)) req = pykms.AtomicReq(card) req.add(plane2, {"alpha": alpha }) r = req.commit_sync() assert r == 0, "alpha change commit failed: %d" % r - alpha = alpha + 0xFF - time.sleep(0.1) + alpha = alpha + 0x101 + time.sleep(0.03) input("press enter exit\n") +card.disable_planes() |