text stringlengths 0 1.47k |
|---|
if err != nil { |
fatal("open %s: %v", fbDev, err) |
} |
defer wf.Close() |
if err := watchFrames(wf, *watchFor, *watchEach); err != nil { |
fatal("watch: %v", err) |
} |
return |
} |
// Before the device is opened, so this works on a workstation: it is how the rescue wording is |
// read by somebody who is not standing in front of a unit. |
if *png != "" { |
img, _, _, _ := compose(*pw, *ph, background(*fill), *fill, *title, *lines) |
out, err := os.Create(*png) |
if err != nil { |
fatal("create %s: %v", *png, err) |
} |
defer out.Close() |
if err := pngenc.Encode(out, img); err != nil { |
fatal("encode %s: %v", *png, err) |
} |
fmt.Printf("wrote %s (%dx%d)\n", *png, *pw, *ph) |
return |
} |
f, err := os.OpenFile(fbDev, os.O_RDWR, 0) |
if err != nil { |
fatal("open %s: %v", fbDev, err) |
} |
defer f.Close() |
var v varInfo |
var fx fixInfo |
if err := ioctl(f.Fd(), fbioGetVScreenInfo, unsafe.Pointer(&v)); err != nil { |
fatal("FBIOGET_VSCREENINFO: %v", err) |
} |
if err := ioctl(f.Fd(), fbioGetFScreenInfo, unsafe.Pointer(&fx)); err != nil { |
fatal("FBIOGET_FSCREENINFO: %v", err) |
} |
fmt.Printf("fb: %dx%d (virtual %dx%d) %d bpp, line %d bytes, smem %d bytes, offsets r%d g%d b%d a%d, rotate %d\n", |
v.Xres, v.Yres, v.XresVirtual, v.YresVirtual, v.BitsPerPixel, fx.LineLength, fx.SmemLen, |
v.Red[0], v.Green[0], v.Blue[0], v.Transp[0], v.Rotate) |
if *info { |
return |
} |
// The MediaTek driver reports smem_len as 0; the virtual geometry is what it maps. If the full |
// mapping is refused, try one frame, then a page, to learn what the driver will give. |
full := int(fx.LineLength) * int(v.YresVirtual) |
if fx.SmemLen != 0 && full > int(fx.SmemLen) { |
full = int(fx.SmemLen) |
} |
frame1 := int(fx.LineLength) * int(v.Yres) |
var mem []byte |
for _, size := range []int{*mapSize, full, frame1, 4096} { |
if size <= 0 { |
continue |
} |
m, err := unix.Mmap(int(f.Fd()), 0, size, unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED) |
if err != nil { |
fmt.Fprintf(os.Stderr, "mmap %d bytes: %v\n", size, err) |
continue |
} |
fmt.Printf("mapped %d bytes\n", size) |
mem = m |
break |
} |
if mem == nil { |
fatal("no mapping size accepted") |
} |
defer unix.Munmap(mem) |
if len(mem) < frame1 { |
fatal("mapping too small to hold a frame (%d < %d)", len(mem), frame1) |
} |
// -dump reads the page the panel is on and writes it out, so what is on the glass can be looked |
// at from somewhere else. It reads only. |
if *dump != "" { |
if err := dumpPanel(mem, v, int(fx.LineLength), int(v.Xres), int(v.Yres), *dump); err != nil { |
fatal("dump: %v", err) |
} |
return |
} |
// -decode times the path a streamed frame takes, and writes to the panel to do it. |
if *decodeDir != "" { |
kept := keepPanel(mem, int(fx.LineLength), int(v.Yres), pageCount(v), v) |
guardPanel(kept, f, mem, v) |
err := decodeCost(f, mem, v, int(fx.LineLength), int(v.Xres), int(v.Yres), *decodeDir, *decodeN) |
kept.restore(f, mem, v) |
if err != nil { |
fatal("decode: %v", err) |
} |
return |
} |
// -bench drives the panel itself. The daemon must be frozen first: it presents to the same |
// panel, and two writers to one framebuffer measure each other rather than the driver. |
if *bench > 0 || *benchFor > 0 { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.