5873612cc31006e209b100ca50ee9a1e66df6347
1 #!/usr/bin/python3
3 import pykms
4 import time
6 # This hack makes drm initialize the fbcon, setting up the default connector
7 card = pykms.Card()
8 card = 0
10 card = pykms.Card()
11 res = pykms.ResourceManager(card)
12 conn = res.reserve_connector()
13 crtc = res.reserve_crtc(conn)
14 mode = conn.get_default_mode()
16 planes = []
17 for p in card.planes:
18 if p.supports_crtc(crtc) == False:
19 continue
20 planes.append(p)
22 if len(planes) != 3:
23 print("Need 3 planes!")
24 exit(1)
26 card.disable_planes()
28 w = mode.hdisplay
29 h = mode.vdisplay
31 fbs=[]
33 for i in range(len(planes)):
34 fbs.append(pykms.DumbFramebuffer(card, w, h, "AR24"))
36 pykms.draw_rect(fbs[0], 50, 50, 200, 200, pykms.RGB(128, 255, 0, 0))
37 pykms.draw_rect(fbs[1], 150, 50, 200, 200, pykms.RGB(128, 0, 255, 0))
38 pykms.draw_rect(fbs[2], 50, 150, 200, 200, pykms.RGB(128, 0, 0, 255))
41 crtc.set_props({
42 "trans-key-mode": 0,
43 "trans-key": 0,
44 "background": 0,
45 "alpha_blender": 1,
46 })
48 for i in range(len(planes)):
49 plane = planes[i]
50 fb = fbs[i]
52 print("set crtc {}, plane {}, fb {}".format(crtc.id, p.id, fbs[i].id))
54 plane.set_props({
55 "FB_ID": fb.id,
56 "CRTC_ID": crtc.id,
57 "SRC_W": fb.width << 16,
58 "SRC_H": fb.height << 16,
59 "CRTC_W": fb.width,
60 "CRTC_H": fb.height,
61 "zorder": i,
62 })
64 time.sleep(1)
66 input("press enter to exit\n")