Handle active-low cover backlight and restore internal panel

This commit is contained in:
Luxferre committed 2026-11-11 07:57:38 +02:00
1 parent b389120328
commit d61f2848db
11 files changed
+412 -106

No files matched your search

+9 -1
View File
@@ -13,13 +13,21 @@ 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.
### 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`.
### Vendor-init kernel cover path and persistent flip lock
- **Root cause of the dark cover**: the KaiOS 3.10 downstream DTS (`0004-dts-adaptations.patch`) shows that both GC9305s share CS0, gpio110 D/C and one PMIC MPP2 PWM backlight; gpio13 selects the panel, gpio23 is the external reset and gpio21 is TE. The previous kernel backend left that shared backlight at zero, never pulsed gpio23, and replayed the internal 240x320 init instead of the stock 240x240 stream. A DPMS off/on cycle alone cannot initialise the external panel. The earlier open transition also removed the lock flag and returned straight to the unlocked desktop.
- **Switch**: `nokia,beatles-gc9305-ext-panel.bin` now contains the exact vendor `fe ef 3a 05 ... 2a/2b 0..239, 11, 29` stream. While closed, `bananarchy-cover-idle` claims gpio13/gpio23, pulses reset, sends that stream through the kernel driver's `/sys/kernel/debug/dri/0/command` hook, publishes `/run/bananarchy/cover-backlight` before enabling the shared backlight, and renders a 240x240 `/dev/fb0` damage rect once per second so Xorg repaints cannot erase it. `bananarchy-display-power-sync` skips the closed-lid hard-off gate only while that marker and `lid-state=closed` are both present. `bananarchy-lid` now keeps `/tmp/bananarchy_screen_locked`, writes `sxmo.state=lock`, sends `LOCK` to `locker.so` and runs `sxmo_state.sh set lock` on open instead of auto-unlocking.
- **Guards**: `scripts/test-cover-kernel.py`, `scripts/test-lid-gate.py`, `scripts/check-rebuild.sh`, `bananarchy-cover-diagnose.sh`, README, MANUAL and `AGENTS.md` now guard the vendor firmware, debugfs command hook, shared-backlight marker, 1 s repaint, DPMS-off initial gate, lock-on-open and both mux-polarity runtime knobs. The legacy `spidev`/`fb`/`none`, 8/9-bit and PROBE rollback paths remain.
- **Live verification**: with the flip state injected closed and DPMS off, `BUTTON` produced `backend=kernel`, marker present, brightness 14, `bl_power=0`, DPMS On, 172800 non-zero bytes in the top 240x240 of `/dev/fb0`, 460919 extra kernel `spi0.0` bytes and zero SPI errors/timeouts. A gpiochip TE scan proved the bus routing objectively: blank had `ext(gpio21)=0 int(gpio24)=0` transitions, `mux_closed_level=0` had `ext=0 int=78`, and `mux_closed_level=1` had `ext=52 int=0`; high is the cover and low is the internal panel. A controlled close→open transition left `state=lock`, the lock flag present, the cover marker absent, `mux=free`, brightness 14, keypad 1 and DPMS On; it stayed locked after 1 s. The phone was restored to open/unlocked with all services started and zero `SPI transfer failed` messages. Eyes-on illumination still needs a human look, but the external panel's TE, shared backlight and kernel SPI traffic are now confirmed.
- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu`; verified raw hash `e2ec6a35d1e7db698f929fa0ebdbed94ffd941a55fc50ceff7a223e82896e985`, pinned by `scripts/check-rebuild.sh`. `e2fsck -fn` passed on both partitions, `debugfs` confirms the rebuilt daemons, firmware, config, helper and scripts byte-for-byte, and the bootfs sync, boot image check, artifact sync, host tests and rebuild preflight pass. The standalone boot image hash is unchanged.
- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu`; verified raw hash `e2ec6a35d1e7db698f929fa0ebdbed94ffd941a55fc50ceff7a223e82896e985`, pinned by `scripts/check-rebuild.sh`. `e2fsck -fn` passed on both partitions, `debugfs` confirms the rebuilt daemons, firmware, config, helper and scripts byte-for-byte, and the bootfs sync, boot image check, artifact sync, host tests and rebuild preflight pass. The standalone boot image hash is unchanged Superseded by the active-low backlight rebuild below.
### Kernel-owned cover panel path (option b)