#!/bin/env python3 import os import sys import mmap import time import select import struct # import math # import numpy as np f = os.open("/dev/mem", os.O_RDWR | os.O_SYNC) cap = mmap.mmap(f, 0x1000, mmap.MAP_SHARED, mmap.PROT_READ | mmap.PROT_WRITE, offset=0x40000000) gen = mmap.mmap(f, 0x1000, mmap.MAP_SHARED, mmap.PROT_READ | mmap.PROT_WRITE, offset=0x40100000) mem = mmap.mmap(f, 0x30000000, mmap.MAP_SHARED, mmap.PROT_READ | mmap.PROT_WRITE, offset=0x10000000) def oreg_get(m, x): v = struct.unpack(" ocnt: obuf = obuf + 1 if obuf < last else 0 offs = 0x1800000 * obuf + 0x800 oreg_set(gen, 0, 0x10000000 + offs) size = 2048*1536*8 oreg_set(gen, 5, 0x10000000 + offs + size) ocnt += 1 oframe += 1 elif fd == u4: # limit = 0x10000000 + 0x1800000 * (0 * ibuf + 1) # while ireg_get(cap, 1) != limit: # continue # print("{:08X}".format(ireg_get(cap, 1))) ibuf = ibuf + 1 if ibuf < last else 0 offs = 0x1800000 * ibuf u64_set(mem, offs + 0x800, 0x0123456789AB0000) oreg_set(cap, 0, 0x10000000 + offs) size = 4096*3072*2 oreg_set(cap, 5, 0x10000000 + offs + size) oreg_set(cap, 1, 0x00060F82) oreg_set(cap, 1, 0x00000F82) oreg_set(cap, 1, 0x00080F82) icnt += 1 iframe += 1 os.write(fd, (1).to_bytes(4, byteorder='little', signed=False)) ctime = time.time() delta = ctime - stime print("I: {:2d} {:5d} {:6.2f} FPS " "O: {:2d} {:5d} {:6.2f} FPS ".format( ibuf, icnt, min(iframe/delta, 999), obuf, ocnt, min(oframe/delta, 999)), end = '\r') # oreg = oreg_get(gen, 0) # print(oreg) # oreg_set(gen, 1, (oreg[1] & 0xFFFFFF) | (flag << 24))