Make 2720 Flip lid switching instant and route closed-flip events to the cover

The lid daemon re-derived "observed" from a stale EV_SW mask on every 100 ms
iteration and only read the raw hall lines every 200 ms, so the candidate
oscillated and the 80 ms debounce almost never completed. A controlled hall
transition on the live phone took over 2.2 s to blank and lock the main panel.
The hall reading is now sticky, every EV_SW edge forces an immediate hall
re-read, the loop and debounce are 20 ms, and the daemon writes the lid state,
lock flag, Sxmo state and both backlights synchronously in C before spawning
hooks. A direct xset DPMS off/on stops or resumes Xorg's SPI flushes at once.
bananarchy-lid-state.sh guards the asynchronous hooks by lid state and a
transition generation counter, so a late screenoff cannot re-lock a flip that
was just opened.

bananarchy-lid-gate.sh now gates sxmo_wm.sh display on, the screen-wake
helper, the backlight udev helper, sxmo_state.sh set unlock (dwm calls it
directly) and both input handler copies. While the flip is closed it blocks
the main panel and keypad backlight, forces brightness/kbd/DPMS off against
stray writes, and forwards a WAKE datagram to the cover display. Ring,
notification and call-state hooks publish to the cover, and the cover daemon
gained WAKE, event wakes, immunity to repeated LID CLOSED rebroadcasts and a
bounded retry for a DPMS-deferred draw.

Live verification with controlled hall transitions and uinput switch/key
injection: close blanks and locks in ~45-90 ms (hall-poll fallback
~100-220 ms), open restores brightness, keypad backlight, unlock and DPMS in
~10-130 ms with no stale-hook re-lock. All three external keys and an
incoming call leave brightness=0, kbd_backlight=0 and DPMS=Off while the
cover reports backend=spidev visible=1; opening returns mux=open.

Rebuilt the a1108/dejavu nokia-beatles image and pinned the verified hash
0f33aa6e9fc70022574b453aaafb9307c4d185431d3be272782c8403dd0fb291 in
check-rebuild.sh. e2fsck -fn passed on both partitions, debugfs confirms
twelve updated rootfs files byte-for-byte, and the bootfs sync, boot image
check, artifact sync, host tests and rebuild preflight all pass.

This is an intermediate checkpoint: eyes-on cover illumination and the
remaining polarity/CS fixes are still required.
This commit is contained in:
Luxferre committed 2026-11-10 20:23:06 +02:00
1 parent 40a840b49b
commit 2857ef4374
29 files changed
+567 -49

No files matched your search

+40
View File
@@ -139,6 +139,7 @@ def main():
for token in ("cover_hw_release", "cover_spi_draw", "hw_init_panel",
"mux_closed_level", "spi_speed_hz", "FBIOBLANK",
"BANANARCHY_COVER_SPI_SIM", "cover_main_panel_is_off",
"cover_wake", "pending_until",
"0x28", "0x29"):
if token not in source:
sys.stderr.write("FAIL: cover daemon lost %s\n" % token)
@@ -273,6 +274,45 @@ def main():
finally:
off.close()
# A forwarded main-panel wake lights the outer panel only.
wake, _ = run_case(root, exe, {})
try:
wake.send("LID CLOSED")
if "visible=1" in wake.send("STATUS"):
return not check(False, "a closed flip lit the cover without an event")
wake.send("WAKE")
if not wake.wait_event("frame lit=1 size=115200"):
return not check(False, "WAKE did not light the cover panel")
if "visible=1" not in wake.send("STATUS"):
return not check(False, "WAKE did not mark the cover visible")
# The lid daemon rebroadcasts LID CLOSED every 2 s; it must not undo it.
lit = [e for e in wake.events() if e.startswith("frame lit=1")]
wake.send("LID CLOSED")
time.sleep(0.3)
if "visible=0" in wake.send("STATUS"):
return not check(False, "a repeated LID CLOSED cleared the cover wake")
if len([e for e in wake.events() if e.startswith("frame lit=1")]) != len(lit):
return not check(False, "a repeated LID CLOSED redrew the cover")
print("[ok] WAKE lights the outer panel; repeated LID CLOSED is ignored")
finally:
wake.close()
# A pending DPMS-off must be retried without another event.
pend, pendcase = run_case(root, exe, {}, dpms="On")
try:
pend.send("LID CLOSED")
pend.send("WAKE")
if "backend=pending" not in pend.send("STATUS"):
return not check(False, "a live main panel did not defer the cover")
(pendcase / "dpms").write_text("Off\n")
if not pend.wait_event("frame lit=1 size=115200", timeout=1.5):
return not check(False, "a deferred cover draw was not retried")
if "backend=spidev" not in pend.send("STATUS"):
return not check(False, "the retried draw did not switch to spidev")
print("[ok] deferred cover draw is retried once DPMS goes off")
finally:
pend.close()
# A transient lid flap must never steal the bus from a live main panel.
live, _ = run_case(root, exe, {}, dpms="On")
try: