1#!/usr/bin/python3 2 3import pykms 4 5card = pykms.Card() 6res = pykms.ResourceManager(card) 7conn = res.reserve_connector("HDMI") 8crtc = res.reserve_crtc(conn) 9mode = conn.get_default_mode() 10modeb = mode.to_blob(card) 11plane = res.reserve_generic_plane(crtc, pykms.PixelFormat.UYVY) 12#plane = res.reserve_generic_plane(crtc, pykms.PixelFormat.Undefined) 13 14print("Got plane %d %d" % (plane.idx, plane.id)) 15 16fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "UYVY"); 17pykms.draw_test_pattern(fb); 18 19req = pykms.AtomicReq(card) 20req.add(conn, "CRTC_ID", crtc.id) 21req.add(crtc, {"ACTIVE": 1, 22 "MODE_ID": modeb.id}) 23 24input("Press enter to enable crtc idx %d at %s" % (crtc.idx, conn.fullname)) 25r = req.commit_sync(allow_modeset = True) 26 27input("Press enter to enable plane idx %d at %s" % (plane.idx, conn.fullname)) 28 29req = pykms.AtomicReq(card) 30req.add(plane, {"FB_ID": fb.id, 31 "CRTC_ID": crtc.id, 32 "SRC_X": 0 << 16, 33 "SRC_Y": 0 << 16, 34 "SRC_W": fb.width << 16, 35 "SRC_H": fb.height << 16, 36 "CRTC_X": 0, 37 "CRTC_Y": 0, 38 "CRTC_W": fb.width, 39 "CRTC_H": fb.height, 40 "zorder": 0}) 41r = req.commit_sync() 42print("Plane enable request returned %d\n" % r) 43 44yuv_types = [pykms.YUVType.BT601_Lim, 45 pykms.YUVType.BT601_Full, 46 pykms.YUVType.BT709_Lim, 47 pykms.YUVType.BT709_Full] 48 49encoding_enums = plane.get_prop("COLOR_ENCODING").enums 50range_enums = plane.get_prop("COLOR_RANGE").enums 51 52for i in range(0, 2): 53 for j in range(0, 2): 54 input("press enter to for encoding: \"%s\" range: \"%s\"\n" % 55 (encoding_enums[i], range_enums[j])) 56 57 req = pykms.AtomicReq(card) 58 req.add(plane, {"COLOR_ENCODING": i, 59 "COLOR_RANGE": j}) 60 req.commit_sync() 61 62 for t in yuv_types: 63 input("press enter to redraw with yuv_type %s\n" % t) 64 pykms.draw_test_pattern(fb, t); 65 66input("press enter to exit\n") 67