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.
44 lines
1.6 KiB
Bash
Executable File
44 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# Keep DRM DPMS and the schedutil rate limit in sync with the backlight state.
|
|
# Invoked by the backlight udev rule (as root) and by sxmo_wm.sh display on
|
|
# (via doas). Every blank path writes brightness=0; every wake path restores it.
|
|
|
|
BR_PATH=/sys/class/backlight/backlight/brightness
|
|
RL_PATH=/sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us
|
|
|
|
DPMS_PATH=
|
|
for _dpms in /sys/class/drm/card*-*/dpms; do
|
|
[ -r "$_dpms" ] && DPMS_PATH="$_dpms" && break
|
|
done
|
|
|
|
br=1
|
|
[ -r "$BR_PATH" ] && { read -r br < "$BR_PATH" 2>/dev/null || br=1; }
|
|
case "$br" in ''|*[!0-9]*) br=1 ;; esac
|
|
|
|
cur=On
|
|
[ -r "$DPMS_PATH" ] && { read -r cur < "$DPMS_PATH" 2>/dev/null || cur=On; }
|
|
|
|
# Hard gate: while the flip is closed no path may relight the main panel or
|
|
# the keypad backlight. This also enforces DPMS-off, which is the condition
|
|
# the cover daemon needs before it takes the shared QUP5 SPI bus.
|
|
if ! "${BANANARCHY_LID_GATE:-/usr/bin/bananarchy-lid-gate.sh}"; then
|
|
printf '0\n' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true
|
|
[ "$br" -eq 0 ] || printf '0\n' > "$BR_PATH" 2>/dev/null || true
|
|
[ "$cur" = "Off" ] || DISPLAY=:0 xset dpms force off >/dev/null 2>&1 || true
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$br" -eq 0 ]; then
|
|
[ "$cur" = "Off" ] || DISPLAY=:0 xset dpms force off >/dev/null 2>&1 || true
|
|
else
|
|
[ "$cur" = "On" ] || DISPLAY=:0 xset dpms force on >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
# Switching scaling_governor away from schedutil and back recreates this
|
|
# kobject with the 6.44 s default, so re-apply the 40 ms value on every wake.
|
|
if [ "$br" -ne 0 ] && [ -w "$RL_PATH" ]; then
|
|
printf '40000\n' > "$RL_PATH" 2>/dev/null || true
|
|
fi
|
|
|
|
exit 0
|