text
stringlengths
0
1.47k
defer unix.Close(p[1])
const high = 100
if err := unix.Dup3(p[0], high, unix.O_CLOEXEC); err != nil {
t.Fatal(err)
}
defer unix.Close(high)
if selectRead(high, 10*time.Millisecond) {
t.Fatal("an empty pipe was readable")
}
if _, err := unix.Write(p[1], []byte{1}); err != nil {
t.Fatal(err)
}
if !selectRead(high, time.Second) {
t.Fatal("a pipe with a byte in it was not readable")
}
}
# ===== file: cmd/dispprobe/main.go =====
//go:build linux
// dispprobe paints a test picture on the Echo Show 5's panel through the MediaTek display
// controller (see internal/mtkdisp). It is the first proof that TECHO5 can own the screen
// without Android's SurfaceFlinger and hardware composer.
//
// Stop the composer first, or the two will fight over the overlay layers:
//
// stop vendor.hwcomposer-2-1
// dispprobe -hold 20s
// dispprobe -fill 1c1511
// dispprobe -info
package main
import (
"flag"
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
"os"
"strconv"
"time"
"golang.org/x/image/font"
"golang.org/x/image/font/basicfont"
"golang.org/x/image/math/fixed"
"github.com/HuskerMinion/techo5/internal/mtkdisp"
)
func main() {
info := flag.Bool("info", false, "print display information and exit")
fill := flag.String("fill", "", "fill with this rrggbb color only")
hold := flag.Duration("hold", 0, "keep repainting (with a clock) for this long; 0 paints once and exits")
interval := flag.Duration("interval", time.Second, "repaint interval while holding")
layer := flag.Int("layer", 0, "overlay layer to use")
formatName := flag.String("fmt", "bgra", "pixel format the controller is told: bgra or rgba")
scan := flag.Int("scan", 0, "debug: find the struct size the kernel accepts for this DISP ioctl number and exit")
capture := flag.String("capture", "", "read back what the panel shows into this PNG (landscape) and exit")
vsync := flag.Bool("vsync", false, "wait for three vertical syncs, print their timing, and exit")
mode := flag.Int("mode", 0, "set the session mode first: 1 direct link, 2 decouple (0 leaves it)")
regs := flag.Bool("regs", false, "dump the overlay and RDMA registers (also after painting, when combined)")
flag.Parse()
dumpRegs := func(when string) {
r, err := mtkdisp.ReadRegs()
if err != nil {
fmt.Fprintf(os.Stderr, "regs: %v\n", err)
return
}
fmt.Printf("registers %s:\n OVL0 sta %08x en %08x roi %08x bg %08x src_con %08x\n",
when, r.OvlSta, r.OvlEn, r.OvlRoiSize, r.OvlBgColor, r.OvlSrcCon)
for i, l := range r.Layer {
fmt.Printf(" L%d %s con %08x size %08x off %08x pitch %08x addr %08x\n",
i, map[bool]string{true: "on ", false: "off"}[r.Enabled(i)], l.Con, l.SrcSize, l.Offset, l.Pitch, l.Addr)
}
fmt.Printf(" RDMA0 global %08x size0 %08x size1 %08x memcon %08x memstart %08x pitch %08x\n",
r.RdmaGlobalCon, r.RdmaSizeCon0, r.RdmaSizeCon1, r.RdmaMemCon, r.RdmaMemStart, r.RdmaMemPitch)
}
if *regs {
dumpRegs("now")
}
if *scan != 0 {
for _, hit := range mtkdisp.ScanIoctlSize(*scan, 8, 4096) {
fmt.Printf("ioctl nr %d accepted with %d-byte argument\n", *scan, hit)
}
return
}
if awake, err := mtkdisp.Awake(); err != nil {
fmt.Fprintf(os.Stderr, "power state: %v\n", err)
} else {
fmt.Printf("panel path awake: %v\n", awake)
}
format := mtkdisp.FormatBGRA8888
if *formatName == "rgba" {
format = mtkdisp.FormatRGBA8888
}