From 66ba007edf69911e0d66b43cd8311dfcfbce8b0f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 8 Dec 2016 15:23:38 +0200 Subject: py: db.py: Add support for cached buffers Signed-off-by: Laurent Pinchart --- py/tests/db.py | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'py/tests') diff --git a/py/tests/db.py b/py/tests/db.py index 89fec30..88dbca2 100755 --- a/py/tests/db.py +++ b/py/tests/db.py @@ -6,14 +6,38 @@ import selectors bar_width = 20 bar_speed = 8 +buffer_cached = False +conn_name = '' + +def usage(argv): + print('Usage: %s ' % argv[0]) + print('Supported options:') + print(' --cached Mapped buffers cached') + print(' --help Display this help screen') + +def parse_arguments(argv): + global buffer_cached + global conn_name + + for arg in argv[1:]: + if arg.startswith('--'): + if arg == '--cached': + buffer_cached = True + elif arg == '--help': + usage(argv) + exit(0) + else: + raise RuntimeError('Invalid argument %s' % arg) + else: + conn_name = arg class FlipHandler(): 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.fb1 = pykms.OmapFramebuffer(card, mode.hdisplay, mode.vdisplay, pykms.PixelFormat.XRGB8888, buffer_cached); + self.fb2 = pykms.OmapFramebuffer(card, mode.hdisplay, mode.vdisplay, pykms.PixelFormat.XRGB8888, buffer_cached); self.flips = 0 self.frames = 0 self.time = 0 @@ -57,12 +81,10 @@ class FlipHandler(): else: crtc.page_flip(fb, self) -if len(sys.argv) > 1: - conn_name = sys.argv[1] -else: - conn_name = '' -card = pykms.Card() +parse_arguments(sys.argv) + +card = pykms.OmapCard() res = pykms.ResourceManager(card) conn = res.reserve_connector(conn_name) crtc = res.reserve_crtc(conn) @@ -84,6 +106,12 @@ def readdrm(fileobj, mask): def readkey(fileobj, mask): #print("KEY EVENT"); sys.stdin.readline() + ctx = pykms.AtomicReq(card) + ctx.add(crtc.primary_plane, "CRTC_ID", 0) + ctx.add(crtc.primary_plane, "FB_ID", 0) + ctx.add(crtc, "ACTIVE", False) +# ctx.add(conn, "CRTC_ID", 0) + ctx.commit_sync(True) exit(0) sel = selectors.DefaultSelector() -- cgit v1.2.3