def __init__(self): super().__init__() self.bar_xpos = 0 self.front_buf = 0 self.fb1 = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24") self.fb2 = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24") self.flips = 0 self.frames = 0 self.time = 0
def __init__(self, crtc, width, height): super().__init__() self.crtc = crtc self.timeline = Timeline() self.bar_xpos = 0 self.front_buf = 0 self.fb1 = pykms.DumbFramebuffer(crtc.card, width, height, "XR24") self.fb2 = pykms.DumbFramebuffer(crtc.card, width, height, "XR24") self.flips = 0 self.flips_last = 0 self.frame_last = 0 self.time_last = 0
def test_am5_trans_dest(): fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fb = fbs[0] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, purple) pykms.draw_rect(fb, 100, 100, 100, 200, green) pykms.draw_rect(fb, 300, 100, 100, 200, red) pykms.draw_rect(fb, 500, 100, 100, 200, white) fb = fbs[1] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, cyan) pykms.draw_rect(fb, 250, 100, 200, 200, yellow) set_props( crtc, { "trans-key-mode": 1, "trans-key": purple.rgb888, "background": 0, "alpha_blender": 0, }) plane = 0 for i in range(0, 2): print("set crtc {}, plane {}, fb {}".format(crtc.id, planes[i].id, fbs[i].id)) plane = planes[i] fb = fbs[i] set_props( plane, { "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_W": fb.width, "CRTC_H": fb.height, "zorder": i, }) time.sleep(1)
def test_am5_trans_src(): fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fb = fbs[0] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, pykms.white) pykms.draw_rect(fb, 200, 200, 100, 100, pykms.red) pykms.draw_rect(fb, fb.width - 300, 200, 100, 100, pykms.green) fb = fbs[1] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, pykms.cyan) pykms.draw_rect(fb, 100, 100, fb.width - 200, fb.height - 200, pykms.purple) crtc.set_props({ "trans-key-mode": 2, "trans-key": pykms.purple.rgb888, "background": 0, "alpha_blender": 0, }) plane = 0 for i in range(0, 2): print("set crtc {}, plane {}, fb {}".format(crtc.id, planes[i].id, fbs[i].id)) plane = planes[i] fb = fbs[i] plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_W": fb.width, "CRTC_H": fb.height, "zorder": 3 if i == 1 else 0, }) time.sleep(1)
def apply_mode(): global fb mode = pykms.Videomode() mode.clock = pclk_khz_widget.get_val() mode.hdisplay = hdisp2_widget.get_val() mode.hsync_start = hss_widget.get_val() mode.hsync_end = hse_widget.get_val() mode.htotal = htot_widget.get_val() mode.vdisplay = vdisp2_widget.get_val() mode.vsync_start = vss_widget.get_val() mode.vsync_end = vse_widget.get_val() mode.vtotal = vtot_widget.get_val() if ilace_box.state: mode.flags |= DRM_MODE_FLAG_INTERLACE if dblclk_box.state: mode.flags |= DRM_MODE_FLAG_DBLCLK if hsync_pol.state == True: mode.flags |= DRM_MODE_FLAG_PHSYNC elif hsync_pol.state == False: mode.flags |= DRM_MODE_FLAG_NHSYNC if vsync_pol.state == True: mode.flags |= DRM_MODE_FLAG_PVSYNC elif vsync_pol.state == False: mode.flags |= DRM_MODE_FLAG_NVSYNC fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24") pykms.draw_test_pattern(fb) crtc.set_mode(conn, fb, mode)
import pykms import time import random card = pykms.Card() res = pykms.ResourceManager(card) conn = res.reserve_connector("hdmi") crtc = res.reserve_crtc(conn) plane = res.reserve_overlay_plane(crtc) mode = conn.get_default_mode() #mode = conn.get_mode(1920, 1080, 60, False) # Blank framefuffer for primary plane fb0 = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "AR24") crtc.set_mode(conn, fb0, mode) # Initialize framebuffer for the scaled plane fbX = 1920 fbY = 1080 fb = pykms.DumbFramebuffer(card, fbX, fbY, "RG16") pykms.draw_test_pattern(fb) # Plane's scaled size and size increments W = 72 H = 54 Winc = 1 Hinc = 1
def test_am4_alpha_trans_src(): fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fbs.append(pykms.DumbFramebuffer(card, w // 2, h, "XR24")) fbs.append(pykms.DumbFramebuffer(card, w // 2, h, "XR24")) fb = fbs[0] pykms.draw_rect(fb, 0, 0, w, h, pykms.purple) pykms.draw_rect(fb, 200, 100, 50, 200, pykms.red) pykms.draw_rect(fb, w - 200 - 50, 100, 50, 200, pykms.green) fb = fbs[1] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, pykms.blue) pykms.draw_rect(fb, 100, 100, fb.width - 200, fb.height - 200, pykms.purple) fb = fbs[2] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, pykms.cyan) pykms.draw_rect(fb, 100, 100, fb.width - 200, fb.height - 200, pykms.purple) crtc.set_props({ "trans-key-mode": 1, "trans-key": pykms.purple.rgb888, "background": 0, "alpha_blender": 1, }) time.sleep(1) plane = planes[0] fb = fbs[0] plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_W": w, "CRTC_H": h, }) time.sleep(1) plane = planes[1] fb = fbs[1] plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_X": 0 << 16, "SRC_Y": 0 << 16, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_X": 0, "CRTC_Y": 0, "CRTC_W": fb.width, "CRTC_H": fb.height, }) time.sleep(1) plane = planes[2] fb = fbs[2] plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_X": 0 << 16, "SRC_Y": 0 << 16, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_X": w - fb.width, "CRTC_Y": 0, "CRTC_W": fb.width, "CRTC_H": fb.height, })
crtc_list.append(crtc) mode = conn.get_default_mode() mode_list.append(mode) print(' {}: {} ({}x{})'.format(conn.idx, conn.fullname, mode.hdisplay, mode.vdisplay)) fbX = sum(mode.hdisplay for mode in mode_list) fbY = max(mode.vdisplay for mode in mode_list) print('FB Resolution: {}x{}\n'.format(fbX, fbY)) # Create the (big)framebuffer(s) for x in range(2): fb_tmp = pykms.DumbFramebuffer(card, fbX, fbY, 'XR24') big_fb_list.append(fb_tmp) fb = big_fb_list[0] screen_offset = 0 card.disable_planes() for i in range(0, len(conn_list)): conn = conn_list[i] crtc = crtc_list[i] mode = mode_list[i] plane = res.reserve_generic_plane(crtc) plane_list.append(plane) modeb = mode.to_blob(card)
def test_am5_trans_dest(): fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fb = fbs[0] stepX = fb.width // 7 stepY = fb.height // 5; pykms.draw_rect(fb, 0, 0, fb.width, fb.height, pykms.purple) pykms.draw_rect(fb, stepX, stepY, stepX, fb.height - (stepY * 2), pykms.green) pykms.draw_rect(fb, stepX * 3, stepY, stepX, fb.height - (stepY * 2), pykms.red) pykms.draw_rect(fb, stepX * 5, stepY, stepX, fb.height - (stepY * 2), pykms.white) fb = fbs[1] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, pykms.cyan) pykms.draw_circle(fb, (stepX * 3) + (stepX // 2), fb.height // 2, (fb.height // 2) - stepY, pykms.yellow) crtc.set_props({ "trans-key-mode": 1, "trans-key": pykms.purple.rgb888, "background": 0, "alpha_blender": 0, }) print("Purple bg. Green, red, white boxes.") plane = planes[0] fb = fbs[0] z = 0 plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_W": fb.width, "CRTC_H": fb.height, "zpos": z, }) input("press enter\n") print("Cyan bg. Green, red, white boxes. Yellow circle behind the red box.") plane = planes[1] fb = fbs[1] z = 1 plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_W": fb.width, "CRTC_H": fb.height, "zpos": z, }) input("press enter\n")
def test_am4_alpha_trans_src(): fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fbs.append(pykms.DumbFramebuffer(card, w // 2, h, "XR24")) fbs.append(pykms.DumbFramebuffer(card, w // 2, h, "XR24")) fb = fbs[0] halfX = fb.width // 2 stepX = (fb.width // 2) // 5; stepY = fb.height // 5; pykms.draw_rect(fb, 0, 0, w, h, pykms.purple) pykms.draw_rect(fb, stepX * 2, stepY * 2, halfX - (stepX * 4), fb.height - (stepY * 4), pykms.red) pykms.draw_rect(fb, halfX + stepX * 2, stepY * 2, halfX - (stepX * 4), fb.height - (stepY * 4), pykms.green) fb = fbs[1] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, pykms.blue) pykms.draw_rect(fb, stepX, stepY, fb.width - (stepX * 2), fb.height - (stepY * 2), pykms.purple) fb = fbs[2] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, pykms.cyan) pykms.draw_rect(fb, stepX, stepY, fb.width - (stepX * 2), fb.height - (stepY * 2), pykms.purple) crtc.set_props({ "trans-key-mode": 1, "trans-key": pykms.purple.rgb888, "background": 0x666666, "alpha_blender": 1, }) print("grey background") input("press enter\n") plane = planes[0] fb = fbs[0] plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_W": w, "CRTC_H": h, }) print("grey background, red and green boxes") input("press enter\n") plane = planes[1] fb = fbs[1] plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_X": 0 << 16, "SRC_Y": 0 << 16, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_X": 0, "CRTC_Y": 0, "CRTC_W": fb.width, "CRTC_H": fb.height, }) print("left side: blue bg, purple box, red box inside purple. right side: unchanged") input("press enter\n") plane = planes[2] fb = fbs[2] plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_X": 0 << 16, "SRC_Y": 0 << 16, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_X": w - fb.width, "CRTC_Y": 0, "CRTC_W": fb.width, "CRTC_H": fb.height, }) print("left side: unchanged. right side: cyan bg, purple box, green box inside purple.") input("press enter\n")
# This is a base script for interactive libkms python environment import pykms from time import sleep from math import sin from math import cos from helpers import * card = pykms.Card() conn = card.get_first_connected_connector() mode = conn.get_default_mode() fb = pykms.DumbFramebuffer(card, 200, 200, "XR24"); pykms.draw_test_pattern(fb); crtc = conn.get_current_crtc() #crtc.set_mode(conn, fb, mode) i = 0 for p in card.planes: globals()["plane"+str(i)] = p i=i+1 i = 0 for c in card.crtcs: globals()["crtc"+str(i)] = c i=i+1
def test_am4_normal_trans_dst(): fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fbs.append(pykms.DumbFramebuffer(card, w * 2 // 3, h, "XR24")) fbs.append(pykms.DumbFramebuffer(card, w * 2 // 3, h, "XR24")) fb = fbs[0] pykms.draw_rect(fb, 0, 0, w, h, purple) pykms.draw_rect(fb, 100, 50, 50, 200, green) pykms.draw_rect(fb, 200, 50, 50, 200, red) pykms.draw_rect(fb, 300, 50, 50, 200, white) fb = fbs[1] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, blue) fb = fbs[2] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, cyan) set_props( crtc, { "trans-key-mode": 1, "trans-key": purple.rgb888, "background": 0, "alpha_blender": 0, }) time.sleep(1) plane = planes[0] fb = fbs[0] set_props( plane, { "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_W": w, "CRTC_H": h, }) time.sleep(1) plane = planes[1] fb = fbs[1] set_props( plane, { "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_X": 0 << 16, "SRC_Y": 0 << 16, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_X": 0, "CRTC_Y": 0, "CRTC_W": fb.width, "CRTC_H": fb.height, }) time.sleep(1) plane = planes[2] fb = fbs[2] set_props( plane, { "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_X": 0 << 16, "SRC_Y": 0 << 16, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_X": w // 3, "CRTC_Y": 0, "CRTC_W": fb.width, "CRTC_H": fb.height, })
continue planes.append(p) if len(planes) != 3: print("Need 3 planes!") exit(1) disable_planes(card) w = mode.hdisplay h = mode.vdisplay fbs = [] for i in range(len(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)) set_props(crtc, { "trans-key-mode": 0, "trans-key": 0, "background": 0, "alpha_blender": 1, }) for i in range(len(planes)): plane = planes[i] fb = fbs[i]
#!/usr/bin/python3 import pykms card = pykms.Card() res = pykms.ResourceManager(card) conn = res.reserve_connector("HDMI") crtc = res.reserve_crtc(conn) mode = conn.get_default_mode() modeb = mode.to_blob(card) plane = res.reserve_generic_plane(crtc, pykms.PixelFormat.UYVY) #plane = res.reserve_generic_plane(crtc, pykms.PixelFormat.Undefined) print("Got plane %d %d" % (plane.idx, plane.id)) fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "UYVY") pykms.draw_test_pattern(fb) req = pykms.AtomicReq(card) req.add(conn, "CRTC_ID", crtc.id) req.add(crtc, {"ACTIVE": 1, "MODE_ID": modeb.id}) input("Press enter to enable crtc idx %d at %s" % (crtc.idx, conn.fullname)) r = req.commit_sync(allow_modeset=True) input("Press enter to enable plane idx %d at %s" % (plane.idx, conn.fullname)) req = pykms.AtomicReq(card) req.add( plane, { "FB_ID": fb.id,
print('Invalid connector: {}'.format(sys.argv[i + 1])) sys.exit(-1) if conn.connected() == True: conn_list.append(conn) else: print('connector: {} is not connected'.format(sys.argv[i + 1])) sys.exit(-1) crtc = res.reserve_crtc(conn) crtc_list.append(crtc) mode = conn.get_default_mode() mode_list.append(mode) fb_tmp = pykms.DumbFramebuffer(card, src_w, src_h, 'XR24') fb_list.append(fb_tmp) rootplane = res.reserve_primary_plane(crtc, pykms.PixelFormat.XRGB8888) rootplane_list.append(rootplane) card.disable_planes() print('Using the following connectors:') for i in range(2): print(' {}: {} ({}x{})'.format(conn_list[i].idx, conn_list[i].fullname, mode_list[i].hdisplay, mode_list[i].vdisplay)) colors.append(pykms.red) colors.append(pykms.green)
crtc1 = res.reserve_crtc(conn1) mode1 = conn1.get_default_mode() modeb1 = mode1.to_blob(card) print("CRTC idx %d goes to %s connector" % (crtc1.idx, conn1.fullname)) if conn2: crtc2 = res.reserve_crtc(conn2) mode2 = conn2.get_default_mode() modeb2 = mode2.to_blob(card) print("CRTC idx %d goes to %s connector" % (crtc2.idx, conn2.fullname)) fbwidth = 480 fbheight = 270 fb = pykms.DumbFramebuffer(card, fbwidth, fbheight, "AR24") pykms.draw_test_pattern(fb) # Disable request card.disable_planes() plane_list = [] while True: plane = res.reserve_generic_plane(crtc1) if plane: print("Got plane idx %d" % plane.idx) plane_list.append(plane) else: break
modeb = mode.to_blob(card) card.disable_planes() req = pykms.AtomicReq(card) req.add(conn, "CRTC_ID", crtc.id) req.add(crtc, {"ACTIVE": 1, "MODE_ID": modeb.id}) req.commit_sync(allow_modeset=True) NUM_BUFS = 4 src_fbs = [] dst_fbs = [] for i in range(NUM_BUFS): fb = pykms.DumbFramebuffer(card, iw, ih, ifmt) pykms.draw_test_pattern(fb) pykms.draw_text(fb, iw // 2, 2, str(i), pykms.white) src_fbs.append(fb) fb = pykms.DumbFramebuffer(card, ow, oh, ofmt) dst_fbs.append(fb) # put the planes on the screen, so that WB doesn't take them req = pykms.AtomicReq(card) req.add_plane(plane1, src_fbs[0], crtc, dst=(0, 0, 400, 480)) req.add_plane(plane2, dst_fbs[1], crtc, dst=(400, 0, 400, 480)) r = req.commit_sync(allow_modeset=True) assert r == 0 vid = pykms.VideoDevice("/dev/video10")
res = pykms.ResourceManager(card) conn = res.reserve_connector() crtc = res.reserve_crtc(conn) pplane = res.reserve_primary_plane(crtc) mode = conn.get_default_mode() modeb = mode.to_blob(card) for format in pplane.formats: if format == pykms.PixelFormat.XRGB8888: break if format == pykms.PixelFormat.RGB565: break fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, format); pykms.draw_test_pattern(fb); # Disable request card.disable_planes() print("Setting %s to %s using %s" % (conn.fullname, mode.name, format)) req = pykms.AtomicReq(card) req.add(conn, "CRTC_ID", crtc.id) req.add(crtc, {"ACTIVE": 1, "MODE_ID": modeb.id}) req.add(pplane, {"FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_X": 0 << 16,
plane = res.reserve_generic_plane(crtc, format) else: plane = card.planes[int(args.plane)] mode = conn.get_default_mode() modeb = mode.to_blob(card) req = pykms.AtomicReq(card) req.add(conn, "CRTC_ID", crtc.id) req.add(crtc, {"ACTIVE": 1, "MODE_ID": modeb.id}) r = req.commit_sync(allow_modeset=True) assert r == 0, "Initial commit failed: %d" % r # Initialize framebuffer for the scaled plane fbX = 1920 fbY = 1080 fb = pykms.DumbFramebuffer(card, fbX, fbY, format) pykms.draw_test_pattern(fb) # max downscale. # The values bellow are for DSS5. For DSS7 use 64 for both. max_downscale_x = 5 max_downscale_y = 8 # Plane's initial scaled size W = 640 H = 480 # Plane's initial position X = 0 Y = 0
card = pykms.Card() card = 0 card = pykms.Card() res = pykms.ResourceManager(card) conn = res.reserve_connector() crtc = res.reserve_crtc(conn) plane = res.reserve_overlay_plane(crtc, fmt) mode = conn.get_default_mode() NUM_BUFS = 5 fbs = [] for i in range(NUM_BUFS): fb = pykms.DumbFramebuffer(card, w, h, fmt) fbs.append(fb) vidpath = pykms.VideoDevice.get_capture_devices()[0] vid = pykms.VideoDevice(vidpath) cap = vid.capture_streamer cap.set_port(0) cap.set_format(fmt, w, h) cap.set_queue_size(NUM_BUFS) for fb in fbs: cap.queue(fb) cap.stream_on()
res = pykms.ResourceManager(card) conn = res.reserve_connector(args.connector) crtc = res.reserve_crtc(conn) 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) plane2 = res.reserve_generic_plane(crtc, format) print("Got plane1 %d %d plane2 %d %d" % (plane1.idx, plane1.id, plane2.idx, plane2.id)) fb1 = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, format) pykms.draw_test_pattern(fb1) fb2 = pykms.DumbFramebuffer(card, mode.hdisplay >> 1, mode.vdisplay >> 1, format) 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, "MODE_ID": modeb.id}) req.add_plane(plane1, fb1, crtc) req.add_plane(plane2, fb2, crtc)
def test_am4_normal_trans_src(): fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24")) fb = fbs[0] halfX = fb.width // 2 stepX = (fb.width // 2) // 5; stepY = fb.height // 5; pykms.draw_rect(fb, 0, 0, fb.width, fb.height, pykms.white) pykms.draw_rect(fb, stepX * 2, stepY * 2, halfX - (stepX * 4), fb.height - (stepY * 4), pykms.red) pykms.draw_rect(fb, halfX + stepX * 2, stepY * 2, halfX - (stepX * 4), fb.height - (stepY * 4), pykms.green) fb = fbs[1] pykms.draw_rect(fb, 0, 0, fb.width, fb.height, pykms.cyan) pykms.draw_rect(fb, stepX, stepY, fb.width - (stepX * 2), fb.height - (stepY * 2), pykms.purple) crtc.set_props({ "trans-key-mode": 2, "trans-key": pykms.purple.rgb888, "background": 0, "alpha_blender": 0, }) print("White bg. Red and green boxes.") plane = planes[0] fb = fbs[0] z = 0 plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_W": fb.width, "CRTC_H": fb.height, "zpos": z, }) input("press enter\n") print("Cyan bg. Big white box, containing red and green boxes.") plane = planes[1] fb = fbs[1] z = 2 plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_W": fb.width << 16, "SRC_H": fb.height << 16, "CRTC_W": fb.width, "CRTC_H": fb.height, "zpos": z, }) input("press enter\n")
import pykms import argparse parser = argparse.ArgumentParser() parser.add_argument("-c", "--connector", default="") parser.add_argument("-l", "--legacy", action="store_true", default=False) args = parser.parse_args() card = pykms.Card() res = pykms.ResourceManager(card) conn = res.reserve_connector(args.connector) crtc = res.reserve_crtc(conn) mode = conn.get_default_mode() fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); pykms.draw_test_pattern(fb); crtc.set_mode(conn, fb, mode) use_legacy = args.legacy if not use_legacy: prop = crtc.get_prop("GAMMA_LUT") if not prop: prop = crtc.get_prop("DEGAMMA_LUT") if not prop: print("No gamma property found") exit(-1)
termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm) return result card = pykms.Card() res = pykms.ResourceManager(card) conn = res.reserve_connector() crtc = res.reserve_crtc(conn) mode = conn.get_default_mode() plane = res.reserve_generic_plane(crtc) card.disable_planes() crtc.set_mode(conn, mode) fb = pykms.DumbFramebuffer(card, 256, 256, "AR24") pykms.draw_rect(fb, 0, 0, 256, 256, pykms.RGB(255, 255, 0, 0)) print("set crtc {}, plane {}, fb {}".format(crtc.id, plane.id, fb.id)) size = 50 x = 100 y = 100 while True: plane.set_props({ "FB_ID": fb.id, "CRTC_ID": crtc.id, "SRC_X": size << 16, "SRC_Y": size << 16, "SRC_W": (fb.width - size) << 16,