text stringlengths 0 1.47k |
|---|
} |
out := make([]string, 0, pages) |
for i := 0; i < pages; i++ { |
out = append(out, strconv.Itoa(i*yres)) |
} |
return strings.Join(out, ", ") |
} |
// daemonPID is the daemon's pid if it is running, found the way the rescue notes do: by the name the |
// kernel knows it by. Best effort, since it only decorates a warning. |
func daemonPID() string { |
ents, err := os.ReadDir("/proc") |
if err != nil { |
return "" |
} |
for _, e := range ents { |
if !e.IsDir() { |
continue |
} |
if _, err := strconv.Atoi(e.Name()); err != nil { |
continue |
} |
b, err := os.ReadFile("/proc/" + e.Name() + "/comm") |
if err != nil { |
continue |
} |
if strings.TrimSpace(string(b)) == "techo5" { |
return e.Name() |
} |
} |
return "" |
} |
// spread sorts ds and returns its smallest, middle, 95th and largest. |
func spread(ds []time.Duration) (min, p50, p95, max time.Duration) { |
sort.Slice(ds, func(i, j int) bool { return ds[i] < ds[j] }) |
at := func(q float64) time.Duration { return ds[int(q*float64(len(ds)-1))] } |
return ds[0], at(0.5), at(0.95), ds[len(ds)-1] |
} |
// counts is a page tally in offset order, for a line somebody has to read: "0 x15, 960 x14". |
func counts(m map[uint32]int) string { |
keys := make([]uint32, 0, len(m)) |
for k := range m { |
keys = append(keys, k) |
} |
sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) |
out := make([]string, 0, len(keys)) |
for _, k := range keys { |
out = append(out, fmt.Sprintf("%d x%d", k, m[k])) |
} |
return strings.Join(out, ", ") |
} |
// watchFrames reports how often the panel's page actually changes. It only reads: nothing is written |
// to the framebuffer and nothing is asked of the driver that changes it, so it can be run against a |
// device whose daemon is still working. That is the point of it: what the daemon presents while it |
// is working is the question, and a frozen daemon answers a different one. |
// |
// Each change of the pan offset is one frame the driver was told to show, and the pan does not |
// return until the command queue has run it (mtkfb_pan_display_impl asks for a blocking flush), so |
// this counts frames put up rather than frames asked for. What it cannot see is the glass: the right |
// page at the wrong moment looks perfect here, which is why a panel's own faults still need a camera. |
// |
// The sampling interval is the sleep below. Five thousand looks a second sample a 33 ms frame 150 |
// times and time it to about a fifth of a millisecond, which is finer than anything being decided |
// here, and it costs a fraction of one of the device's four cores rather than all of it. |
func watchFrames(f *os.File, forDur time.Duration, each bool) error { |
const poll = 200 * time.Microsecond |
var v varInfo |
if err := ioctl(f.Fd(), fbioGetVScreenInfo, unsafe.Pointer(&v)); err != nil { |
return fmt.Errorf("FBIOGET_VSCREENINFO: %w", err) |
} |
pages := pageCount(v) |
fmt.Printf("fb %dx%d, %d page(s) of %d rows: yoffset cycles %s\n", |
v.Xres, v.Yres, pages, v.Yres, pageOffsets(pages, int(v.Yres))) |
runFor := "until interrupted" |
if forDur > 0 { |
runFor = "for " + forDur.String() |
} |
fmt.Printf("watching %s, reading only (the daemon is left running)\n\n", runFor) |
cur := v.Yoffset |
start, prev := time.Now(), time.Now() |
var gaps []time.Duration |
seen := map[uint32]int{} |
for { |
v = varInfo{} |
if err := ioctl(f.Fd(), fbioGetVScreenInfo, unsafe.Pointer(&v)); err != nil { |
return fmt.Errorf("FBIOGET_VSCREENINFO: %w", err) |
} |
now := time.Now() |
if v.Yoffset != cur { |
cur = v.Yoffset |
gaps = append(gaps, now.Sub(prev)) |
prev = now |
seen[cur]++ |
if each { |
fmt.Printf(" %8.3fs frame %5d yoffset %6d interval %v\n", |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.