text stringlengths 0 1.47k |
|---|
// |
// It is also the only thing that can write to the screen in the rescue environment, where the |
// daemon may not be running at all, so it can be given something to say instead of the test image. |
// |
// fbprobe # paint the test image and pan it onto the panel |
// fbprobe -fill 1c1511 # solid color only |
// fbprobe -info # print the framebuffer geometry and exit |
// fbprobe -dump shot.png # write what the panel is showing now to a PNG |
// fbprobe -title RESCUE -lines "first line|second line" -hold 1000h |
// fbprobe -watch -watch-for 30s # how often the panel's page changes, reading only |
// fbprobe -bench 300 # pan as fast as the driver takes it, timing fill and pan |
package main |
import ( |
"bytes" |
"encoding/binary" |
"flag" |
"fmt" |
"image" |
"image/color" |
"image/draw" |
"image/jpeg" |
pngenc "image/png" |
"os" |
"os/signal" |
"path/filepath" |
"sort" |
"strconv" |
"strings" |
"syscall" |
"time" |
"unsafe" |
"golang.org/x/image/font" |
"golang.org/x/image/font/basicfont" |
"golang.org/x/image/math/fixed" |
"golang.org/x/sys/unix" |
xdraw "golang.org/x/image/draw" |
) |
// fits is the message screen's text metrics for a panel of this width: how big to draw, how far in |
// to start, and how many characters then fit on a line. |
// |
// basicfont advances 7 pixels a character, so a line is 7*scale wide per character and the margins |
// take the rest. The numbers are checked against a counted ruler string rather than trusted: a line |
// that is one character too long does not wrap, it runs off the panel, and the line it eats is the |
// one telling somebody what to do. |
// |
// A Show 5 is 960 across and takes scale 3; a Spot is 480 and would fit 19 characters at that size, |
// which is not a sentence, so it drops to scale 2 and a narrower margin. A Show 8 is 1280 and has |
// room to spare. |
func fits(w int) (scale, margin, chars int) { |
scale, margin = 3, 40 |
if w < 720 { |
scale, margin = 2, 20 |
} |
return scale, margin, (w - 2*margin) / (7 * scale) |
} |
const ( |
fbDev = "/dev/graphics/fb0" |
fbioGetVScreenInfo = 0x4600 |
fbioPutVScreenInfo = 0x4601 |
fbioGetFScreenInfo = 0x4602 |
fbioPanDisplay = 0x4606 |
fbioBlank = 0x4611 |
) |
// fb_var_screeninfo, 160 bytes on every ABI (all u32). |
type varInfo struct { |
Xres, Yres, XresVirtual, YresVirtual, Xoffset, Yoffset uint32 |
BitsPerPixel, Grayscale uint32 |
Red, Green, Blue, Transp [3]uint32 // offset, length, msb_right |
Nonstd, Activate, Height, Width, AccelFlags uint32 |
Pixclock, LeftMargin, RightMargin, UpperMargin uint32 |
LowerMargin, HsyncLen, VsyncLen, Sync, Vmode, Rotate uint32 |
Colorspace uint32 |
Reserved [4]uint32 |
} |
// fb_fix_screeninfo on a 32-bit kernel ABI... this kernel is arm64 with a 32-bit userspace, so the |
// compat layout applies: unsigned long is 4 bytes here. |
type fixInfo struct { |
ID [16]byte |
SmemStart uint32 |
SmemLen uint32 |
Type, TypeAux, Visual uint32 |
Xpanstep, Ypanstep uint16 |
Ywrapstep uint16 |
_ uint16 |
LineLength uint32 |
MmioStart uint32 |
MmioLen, Accel uint32 |
Capabilities uint16 |
_ [2]uint16 |
_ uint16 |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.