]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blob - py/alpha-test.py
py: use ResourceManager
[android/external-libkmsxx.git] / py / alpha-test.py
1 #!/usr/bin/python3
3 import pykms
4 from helpers import *
5 import time
7 # This hack makes drm initialize the fbcon, setting up the default connector
8 card = pykms.Card()
9 card = 0
11 card = pykms.Card()
12 res = pykms.ResourceManager(card)
13 conn = res.reserve_connector()
14 crtc = res.reserve_crtc(conn)
15 mode = conn.get_default_mode()
17 planes = []
18 for p in card.planes:
19     if p.supports_crtc(crtc) == False:
20         continue
21     planes.append(p)
23 if len(planes) != 3:
24     print("Need 3 planes!")
25     exit(1)
27 disable_planes(card)
29 w = mode.hdisplay
30 h = mode.vdisplay
32 fbs=[]
34 for i in range(len(planes)):
35     fbs.append(pykms.DumbFramebuffer(card, w, h, "AR24"))
37 pykms.draw_rect(fbs[0], 50, 50, 200, 200, pykms.RGB(128, 255, 0, 0))
38 pykms.draw_rect(fbs[1], 150, 50, 200, 200, pykms.RGB(128, 0, 255, 0))
39 pykms.draw_rect(fbs[2], 50, 150, 200, 200, pykms.RGB(128, 0, 0, 255))
42 set_props(crtc, {
43     "trans-key-mode": 0,
44     "trans-key": 0,
45     "background": 0,
46     "alpha_blender": 1,
47 })
49 for i in range(len(planes)):
50     plane = planes[i]
51     fb = fbs[i]
53     print("set crtc {}, plane {}, fb {}".format(crtc.id, p.id, fbs[i].id))
55     set_props(plane, {
56         "FB_ID": fb.id,
57         "CRTC_ID": crtc.id,
58         "SRC_W": fb.width << 16,
59         "SRC_H": fb.height << 16,
60         "CRTC_W": fb.width,
61         "CRTC_H": fb.height,
62         "zorder": i,
63     })
65     time.sleep(1)
67 input("press enter to exit\n")