• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python3
2
3import pykms
4import time
5import argparse
6
7parser = argparse.ArgumentParser(description='Simple alpha blending test.')
8parser.add_argument('--resetcrtc', action="store_true",
9		    help='Reset legacy CRTC color properties')
10parser.add_argument('--connector', '-c', dest='connector', default="",
11		    required=False, help='connector to output')
12parser.add_argument('--mode', '-m', dest='modename',
13		    required=False, help='Video mode name to use')
14args = parser.parse_args()
15
16max_planes = 4
17
18card = pykms.Card()
19res = pykms.ResourceManager(card)
20conn = res.reserve_connector(args.connector)
21crtc = res.reserve_crtc(conn)
22if args.modename == None:
23    mode = conn.get_default_mode()
24else:
25    mode = conn.get_mode(args.modename)
26
27planes = []
28
29for i in range(max_planes):
30    p = res.reserve_generic_plane(crtc)
31    if p == None:
32        break
33    planes.append(p)
34
35print("Got {} planes. Test supports up to 4 planes.".format(len(planes)))
36
37card.disable_planes()
38
39w = mode.hdisplay
40h = mode.vdisplay
41
42fbs=[]
43
44for i in range(max_planes):
45    fbs.append(pykms.DumbFramebuffer(card, w, h, "AR24"))
46
47pykms.draw_rect(fbs[0], 50, 50, 200, 200, pykms.RGB(128, 255, 0, 0))
48pykms.draw_rect(fbs[1], 150, 50, 200, 200, pykms.RGB(128, 0, 255, 0))
49pykms.draw_rect(fbs[2], 50, 150, 200, 200, pykms.RGB(128, 0, 0, 255))
50pykms.draw_rect(fbs[3], 150, 150, 200, 200, pykms.RGB(128, 128, 128, 128))
51
52card.disable_planes()
53
54if args.resetcrtc:
55    crtc.set_props({
56        "trans-key-mode": 0,
57        "trans-key": 0,
58        "background": 0,
59        "alpha_blender": 1,
60    })
61
62for i in range(len(planes)):
63    plane = planes[i]
64    fb = fbs[i]
65
66    print("set crtc {}, plane {}, z {}, fb {}".format(crtc.id, plane.id, i, fb.id))
67
68    plane.set_props({
69        "FB_ID": fb.id,
70        "CRTC_ID": crtc.id,
71        "SRC_W": fb.width << 16,
72        "SRC_H": fb.height << 16,
73        "CRTC_W": fb.width,
74        "CRTC_H": fb.height,
75        "zpos": i,
76    })
77
78    time.sleep(1)
79
80input("press enter to exit\n")
81