Stop reboot backlight flicker with force-only PWM updates

This commit is contained in:
Luxferre committed 2026-11-11 08:23:12 +02:00
1 parent d61f2848db
commit 7a2b965ce3
10 files changed
+93 -62

No files matched your search

+15 -1
View File
@@ -13,13 +13,27 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
Work since `a1108` has focused on reliable 2720 Flip hardware support and a reproducible boot/flash path. Earlier incremental and superseded diagnostic entries are consolidated here.
### Bounded DPMS helper and final flicker fix
- **Root cause**: after reboot, two orphaned `bananarchy-display-power-sync` shells and two `xset dpms force on` processes were stuck in `pipe_read`; each new udev event spawned more helpers. The forced PWM update was still reachable from plain udev events, so the active panel flickered heavily.
- **Switch**: plain udev events are now strictly idempotent and never toggle `bl_power`; only the cover daemon's `force` mode performs the two-step PWM update. Every `xset dpms force` call in `bananarchy-display-power-sync` and `bananarchy-cover-dpms.sh` is bounded with `timeout 1`, so a hung X client cannot leave orphaned helpers behind. The cover service clears stale transition guards on every boot.
- **Live verification**: killed the stuck helper/`xset` processes, restored open/unlocked state, deployed the rebuilt daemon/helpers/init script and re-ran a 10 s sysfs/process monitor: 158 samples, 0 brightness/bl_power/DPMS/PWM changes, 0 helper processes, PWM duty 100000 ns, DPMS On, `state=unlock` and `fb0` non-white. The closed→lit→blank→open sequence still produced external TE toggles, zero SPI errors and restored normal internal brightness. `e2fsck -fn` passed on both partitions; `debugfs` confirms all rebuilt artifacts byte-for-byte; bootfs sync, boot image check, artifact sync, six host tests and `check-rebuild.sh` pass. The standalone boot image hash is unchanged.
- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu`; verified raw hash `f3f7ab1be04622a9554f0614080b7323689338710d711bfa3de0ee3bcbbbd6f1`, pinned by `scripts/check-rebuild.sh`.
### Flicker-free boot and udev power state
- **Root cause**: the forced two-step PWM update ran from every backlight udev event. Because `/run` is tmpfs, the state cache was empty after reboot, so each helper invocation toggled `bl_power` 4→0 and rewrote brightness; the nested udev events spawned up to four concurrent `bananarchy-display-power-sync` processes and produced heavy flicker on the active panel. The 1 s cover repaint also invoked the helper periodically.
- **Switch**: `bananarchy-display-power-sync` now has an explicit `force` mode used only by the compiled cover daemon on real state transitions; plain udev events use idempotent `set_if_changed` writes and never toggle `bl_power`. The 1 s repaint only redraws the framebuffer. `bananarchy-cover-display` clears stale `cover-bl-force` / `cover-power-state` guards in `start_pre()` after every reboot. `scripts/check-rebuild.sh` guards the force-mode helper.
- **Live verification**: stopped the reboot loop by seeding the open-state cache, restoring brightness 14 / `bl_power=0` / DPMS On and killing the stuck helper processes. The rebuilt daemon, helper and init script were deployed and a 5 s sysfs/process monitor confirmed no repeated PWM/DPMS changes and no runaway helper processes. `e2fsck -fn` passed on both partitions; `debugfs` confirms the rebuilt artifacts byte-for-byte; bootfs sync, boot image check, artifact sync, six host tests and `check-rebuild.sh` pass. The standalone boot image hash is unchanged.
- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu`; verified raw hash `abd1886df851688e20cbce35afbe88062b878d1d9d7980a16123cf42e4ee3e7a`, pinned by `scripts/check-rebuild.sh` Superseded by the bounded-xset rebuild below.
### Active-low cover backlight and reliable internal-panel handover
- **Root cause**: eyes-on testing confirmed the outer display lights only with PWM **duty 0** while gpio13 selects the cover; the main panel uses the same PMIC PWM with the opposite polarity and needs duty 14. Leaving the cover daemon frozen with duty 0 and gpio13 high made the outer display work but left the internal panel all-white, and a daemon restart could leave gpio13 latched high because the fresh process had no linehandle to drive low. `SET mux_closed_level 0` selects the internal panel, not the cover.
- **Switch**: `kernel_backlight_invert = 1`, `kernel_backlight_level = 14`, `kernel_backlight_power_path` and `kernel_power_sync_helper` are shipped. `/run/bananarchy/cover-backlight` contains `1` while the cover is lit (duty 0, `bl_power=0`, DPMS On) and `0` while the cover owns the bus but is dark (duty 14, `bl_power=0`, DPMS On). `bananarchy-display-power-sync` reads that marker and the invert/level keys, uses `/run/bananarchy/cover-bl-force` to suppress nested udev events during a forced two-step PWM update, and is also invoked directly by the daemon after marker changes. `cover_kernel_restore_internal()` explicitly drives gpio13 low, removes the marker, restores duty 14, `bl_power=0`, DPMS On and re-initialises the internal panel on `LID OPEN`, even after a stale high mux survives a daemon restart. `SET kernel_backlight_invert 0|1` remains a runtime rollback knob.
- **Guards**: `scripts/test-cover-kernel.py` now checks the dark/lit marker contents, the active-low duty, the OFF duty on blank, normal brightness on open, mux restore, 1 s repaint and the DPMS gate. `scripts/check-rebuild.sh` guards the new config keys, source functions and the active-low display-power-sync paths. README, MANUAL and `AGENTS.md` document the polarity and handover.
- **Live verification**: the user confirmed the outer display works with duty 0. The restore sequence returned the phone to `lid=open`, `state=unlock`, brightness 14, `bl_power=0`, DPMS On and all services started; a separate gpio13 probe drove the latched mux low. The rebuilt ARM daemon, config and scripts were deployed and the closed→lit→blank→open sequence was rechecked: cover lit showed `marker=1`, `br=0`, external TE toggles, 1382586 extra `spi0.0` bytes and zero SPI errors; cover dark showed `marker=0`; `LID OPEN` removed the marker and restored gpio13 low; the final open state showed `br=14`, `bl_power=0`, DPMS On, PWM duty 100000 ns, `l17/l6` enabled and a non-white `/dev/fb0` (0 white bytes, mean 20.7). `e2fsck -fn` passed on both partitions; `debugfs` confirms all rebuilt artifacts byte-for-byte; bootfs sync, boot image check, artifact sync, six host tests and `check-rebuild.sh` pass. The standalone boot image hash is unchanged. Eyes-on confirmation of both screens after this final deployment is still pending.
- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu`; verified raw hash `3fc34741cbe9a2e68ab77e7133393bd7f93c7fec1c938680405760e8d02dfa08`, pinned by `scripts/check-rebuild.sh`.
- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu`; verified raw hash `3fc34741cbe9a2e68ab77e7133393bd7f93c7fec1c938680405760e8d02dfa08`, pinned by `scripts/check-rebuild.sh` Superseded by the flicker-free rebuild below.
### Vendor-init kernel cover path and persistent flip lock