Fix 2720 Flip cover init, shared backlight and flip lock

This commit is contained in:
Luxferre committed 2026-11-10 23:20:13 +02:00
1 parent c939687138
commit b389120328
24 files changed
+494 -217

No files matched your search

+35 -9
View File
@@ -373,7 +373,7 @@ fi
echo "[check] Known-good flashable image set..."
for pair in \
"69a44f60eb123ebddf600be927155dc4a599ec35b7a0cf80060f4ba01f599f08 images/bananarchy-nokia-argon.img" \
"ce0542321990a8cff8ab122c0a47c0684fcc7e3d5f6fc97e74b3b0ea4c4826b5 images/bananarchy-nokia-beatles.img" \
"e2ec6a35d1e7db698f929fa0ebdbed94ffd941a55fc50ceff7a223e82896e985 images/bananarchy-nokia-beatles.img" \
"2b5c61aba307dbbda61f3b19a2ad5770f9854f41cba4e2c97e24efb7e20879f3 images/boot-bananarchy-nokia-beatles.img" \
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
set -- $pair
@@ -901,15 +901,19 @@ echo "[check] Flip lid responsiveness..."
LID_SRC="$BASE_DIR/src/bananarchy-daemons/bananarchy-lid.c"
for token in '#define LID_DEBOUNCE_MS 20' '#define HALL_EDGE_MS 20' \
'#define LID_LOOP_MS 20' 'BA_EVIOCGSW' 'LID_STATE_FILE' \
'LOCKER_FIFO' 'unlink(LOCK_FLAG)' 'hall_observed' 'fast_until' \
'LOCKER_FIFO' 'hall_observed' 'fast_until' \
'if(edge)' 'write_session_file(state, "screenoff")' \
'write_session_file(state, "unlock")' 'cover_send("OPEN")' \
'write_session_file(state, "lock")' 'cover_send("OPEN")' \
'locker_send("LOCK\n")' 'run_sxmo_state("lock", "open")' \
'LID_GENERATION_FILE' 'run_dpms' \
'bananarchy-lid-state.sh'; do
if ! grep -qF "$token" "$LID_SRC"; then
fail "the compiled lid daemon lost the instant EV_SW/hall path ($token)"
fi
done
if grep -qF 'unlink(LOCK_FLAG)' "$LID_SRC"; then
fail "the lid daemon still auto-unlocks the desktop when the flip opens"
fi
if grep -qF 'closed != was_closed' "$LID_SRC" || \
grep -qF '#define LID_STABLE_MS 600' "$LID_SRC" || \
grep -qF '#define LID_STABLE_MS 80' "$LID_SRC" || \
@@ -922,6 +926,11 @@ LID_GATE="$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-lid-gate.sh"
if [ ! -x "$LID_GATE" ] || ! sh -n "$LID_GATE" 2>/dev/null; then
fail "bananarchy-lid-gate.sh is missing or has bad syntax"
fi
DPMS_SYNC="$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync"
if ! grep -qF 'COVER_MARKER=/run/bananarchy/cover-backlight' "$DPMS_SYNC" || \
! grep -qF 'exit 0' "$DPMS_SYNC"; then
fail "display-power-sync no longer permits the shared cover backlight"
fi
for f in overlay/rootfs/usr/bin/sxmo_wm.sh \
overlay/rootfs/usr/bin/sxmo_state.sh \
overlay/rootfs/usr/bin/bananarchy-screen-wake.sh \
@@ -1016,7 +1025,7 @@ if ! grep -qF 'cmd == "CLOSE" || cmd == "UNLOCK"' \
"$BASE_DIR/src/dwm-plugins/locker_plugin.cpp" || \
! grep -qF 'unlockPhone(false);' \
"$BASE_DIR/src/dwm-plugins/locker_plugin.cpp"; then
fail "locker.so no longer releases a stale grab on a trusted lid-open CLOSE"
fail "locker.so no longer releases a stale grab on a trusted unlock CLOSE"
fi
echo "[check] Known-good keypad wake guard..."
@@ -1512,6 +1521,10 @@ for token in 'cover_hw_release' 'cover_spi_draw' 'hw_init_panel' \
done
for token in 'backend = kernel' 'main_fb_device = /dev/fb0' \
'kernel_dpms_helper = /usr/bin/bananarchy-cover-dpms.sh' \
'kernel_command_path = /sys/kernel/debug/dri/0/command' \
'kernel_backlight_path = /sys/class/backlight/backlight/brightness' \
'kernel_backlight_marker = /run/bananarchy/cover-backlight' \
'kernel_backlight_level = 14' \
'spi_device = /dev/spidev0.1' \
'spi_mux_gpio = 13' 'spi_dc_gpio = 21' 'spi_reset_gpio = 23' \
'mux_closed_level = 1' 'mux_open_level = 0' \
@@ -1523,13 +1536,19 @@ for token in 'backend = kernel' 'main_fb_device = /dev/fb0' \
fi
done
if ! grep -qF 'flip_open' "$COVER_SRC" || \
! grep -qF 'cover_hw_release(hw)' "$COVER_SRC" || \
! grep -qF 'cover_bus_release(hw)' "$COVER_SRC" || \
! grep -qF 'cover_draw(&hw, fb_path, &state)' "$COVER_SRC"; then
fail "the cover daemon no longer gates the shared bus on the flip state"
fi
if ! grep -qF 'cover_kernel_draw' "$COVER_SRC" || \
! grep -qF 'cover_main_backlight_is_off' "$COVER_SRC" || \
! grep -qF 'reinit' \
for token in 'cover_kernel_draw' 'cover_kernel_command' \
'cover_kernel_replay_firmware' 'cover_kernel_reset' \
'cover_kernel_backlight' 'cover_kernel_display_off' \
'KERNEL_REDRAW_MS 1000' 'cover_main_panel_is_off'; do
if ! grep -qF "$token" "$COVER_SRC"; then
fail "the kernel-owned cover backend lost $token"
fi
done
if ! grep -qF 'reinit' \
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-cover-dpms.sh" || \
[ ! -x "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-cover-dpms.sh" ]; then
fail "the kernel-owned cover backend or its DPMS re-init helper is missing"
@@ -1551,7 +1570,14 @@ if command -v gcc >/dev/null 2>&1 && \
fi
for f in "$BASE_DIR/prebuilt/bananarchy-daemons/usr/bin/bananarchy-cover-idle" \
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-cover-idle"; do
if ! strings "$f" 2>/dev/null | grep -qF 'frame lit=%d size=%zu'; then
if ! strings "$f" 2>/dev/null | grep -qF 'kernel cmd %s' || \
! strings "$f" 2>/dev/null | grep -qF 'kernel backlight %u'; then
fail "${f#"$BASE_DIR/"} is stale: rebuild with scripts/build-bananarchy-daemons.sh"
fi
done
for f in "$BASE_DIR/prebuilt/bananarchy-daemons/usr/bin/bananarchy-lid" \
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-lid"; do
if ! strings "$f" 2>/dev/null | grep -qxF 'LOCK'; then
fail "${f#"$BASE_DIR/"} is stale: rebuild with scripts/build-bananarchy-daemons.sh"
fi
done
+77 -33
View File
@@ -1,11 +1,10 @@
#!/usr/bin/env python3
"""Host test for the kernel-owned 2720 Flip cover panel path.
The daemon runs in SPI simulation mode against a fake /dev/fb0, fake main
backlight and a logged DPMS helper. It verifies that the mux is only claimed
while closed, that a wake forces a kernel DPMS re-init and renders a frame,
that blanking powers the panel down, that opening restores the mux, and that
a lit main backlight blocks the whole path.
The daemon runs in simulation mode against a fake /dev/fb0, fake DPMS/backlight
and the panel-mipi-dbi-spi debugfs command hook. It verifies the stock vendor
init, shared-backlight marker, 240x240 frame, periodic repaint against Xorg,
blanking, handover on open and the initial DPMS-off gate.
"""
import os
import pathlib
@@ -19,13 +18,16 @@ BASE = pathlib.Path(__file__).resolve().parent.parent
SRC = BASE / "src/bananarchy-daemons/bananarchy-cover-idle.c"
CONF = BASE / "overlay/rootfs/etc/bananarchy/cover-display.conf"
HELPER = BASE / "overlay/rootfs/usr/bin/bananarchy-cover-dpms.sh"
FIRMWARE = BASE / "devices/nokia-beatles/nokia,beatles-gc9305-ext-panel.bin"
class Daemon:
def __init__(self, root, exe, log, fb, bl, config):
def __init__(self, root, exe, log, fb, bl, cmd, marker, config):
self.log = log
self.fb = fb
self.bl = bl
self.cmd = cmd
self.marker = marker
self.sock = root / "cover.sock"
self.client_path = root / "client.sock"
env = dict(os.environ)
@@ -35,8 +37,10 @@ class Daemon:
"BANANARCHY_COVER_SPI_SIM": str(log),
"BANANARCHY_COVER_MAIN_FB": str(fb),
"BANANARCHY_COVER_DPMS_HELPER": "/bin/true",
"BANANARCHY_COVER_BL_PATH": str(bl),
"BANANARCHY_COVER_DPMS_PATH": str(root / "dpms"),
"BANANARCHY_COVER_KERNEL_CMD": str(cmd),
"BANANARCHY_COVER_KERNEL_BL": str(bl),
"BANANARCHY_COVER_KERNEL_MARKER": str(marker),
})
(root / "dpms").write_text("Off\n")
self.proc = subprocess.Popen([str(exe), "--config", str(config)],
@@ -44,7 +48,7 @@ class Daemon:
stderr=subprocess.DEVNULL)
self.client = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
self.client.bind(str(self.client_path))
self.client.settimeout(2)
self.client.settimeout(3)
end = time.time() + 3
while time.time() < end and not self.sock.exists():
time.sleep(0.05)
@@ -68,6 +72,9 @@ class Daemon:
time.sleep(0.05)
return False
def count(self, prefix):
return sum(1 for line in self.events() if line.startswith(prefix))
def close(self):
try:
self.send("QUIT")
@@ -87,22 +94,34 @@ def fail(message):
def main():
if not SRC.is_file() or not CONF.is_file() or not HELPER.is_file():
return fail("missing cover daemon source, config or DPMS helper")
for path in (SRC, CONF, HELPER, FIRMWARE):
if not path.is_file():
return fail("missing %s" % path.relative_to(BASE))
conf = CONF.read_text(encoding="utf-8")
for token in ("backend = kernel", "main_fb_device = /dev/fb0",
"kernel_dpms_helper = /usr/bin/bananarchy-cover-dpms.sh"):
"kernel_dpms_helper = /usr/bin/bananarchy-cover-dpms.sh",
"kernel_command_path = /sys/kernel/debug/dri/0/command",
"kernel_backlight_path = /sys/class/backlight/backlight/brightness",
"kernel_backlight_marker = /run/bananarchy/cover-backlight",
"kernel_backlight_level = 14"):
if token not in conf:
return fail("shipping config lost %s" % token)
helper = HELPER.read_text(encoding="utf-8")
if "dpms force off" not in helper or "dpms force on" not in helper:
return fail("the DPMS helper no longer performs an off/on re-init")
return fail("the DPMS helper no longer performs an off/on cycle")
source = SRC.read_text(encoding="utf-8")
for token in ("cover_kernel_draw", "cover_kernel_frame",
"cover_main_backlight_is_off", "reinit"):
"cover_kernel_command", "cover_kernel_replay_firmware",
"cover_kernel_reset", "cover_kernel_backlight",
"cover_kernel_display_off", "cover_bus_release",
"cover_main_panel_is_off", "KERNEL_REDRAW_MS 1000",
"reinit"):
if token not in source:
return fail("cover daemon lost the kernel backend: %s" % token)
print("[ok] kernel backend wiring is present")
firmware = FIRMWARE.read_bytes()
if not firmware.startswith(b"MIPI DBI") or b"\xfe\x00\xef\x00" not in firmware:
return fail("the stock external panel init stream is missing")
print("[ok] kernel backend, vendor init and config wiring are present")
with tempfile.TemporaryDirectory(prefix="bananarchy-cover-kernel-") as tmp:
root = pathlib.Path(tmp)
exe = root / "cover-idle"
@@ -118,16 +137,21 @@ def main():
fb.write_bytes(b"\x00" * (240 * 320 * 4))
bl = root / "brightness"
bl.write_text("0\n")
cmd = root / "command"
cmd.write_text("")
marker = root / "marker"
log = root / "spi.log"
(root / "idle_blank").write_text("300\n")
config = root / "cover.conf"
config.write_text(
"socket_path = %s\nfb_device = %s\nbacklight_path = %s\n"
"blank_timeout = 2\nbackend = kernel\nmain_fb_device = %s\n"
"kernel_dpms_helper = /bin/true\nmux_closed_level = 1\n"
"blank_timeout = 0\nbackend = kernel\nmain_fb_device = %s\n"
"panel_firmware = %s\nkernel_dpms_helper = /bin/true\n"
"kernel_backlight_level = 14\nmux_closed_level = 1\n"
"mux_open_level = 0\nreset_assert_level = 0\nreset_idle_level = 1\n" %
(root / "cover.sock", root / "no-fb1", root / "backlight", fb))
daemon = Daemon(root, exe, log, fb, bl, config)
(root / "cover.sock", root / "no-fb1", root / "legacy-backlight",
fb, FIRMWARE))
daemon = Daemon(root, exe, log, fb, bl, cmd, marker, config)
try:
time.sleep(0.3)
if daemon.events():
@@ -143,36 +167,56 @@ def main():
print("[ok] closed flip: mux to cover, panel blanked")
daemon.send("BUTTON")
if not daemon.wait("dpms reinit") or not daemon.wait("kernel frame lit=1"):
return fail("BUTTON did not force a kernel re-init and draw a frame")
if not any(fb.read_bytes()):
return fail("the cover UI was not rendered into the main framebuffer")
expected = ("dpms reinit", "kernel reset", "kernel cmd fe",
"kernel cmd 29", "kernel backlight 14",
"kernel frame lit=1")
for text in expected:
if not daemon.wait(text):
return fail("BUTTON did not produce %s" % text)
if not marker.is_file() or bl.read_text().strip() != "14":
return fail("the shared cover backlight was not enabled")
if "kernel" not in daemon.send("STATUS"):
return fail("STATUS does not report the kernel backend")
print("[ok] BUTTON: DPMS re-init and cover UI rendered to fbdev")
print("[ok] BUTTON: vendor init, shared backlight and cover UI")
frames = daemon.count("kernel frame lit=1")
time.sleep(1.2)
if daemon.count("kernel frame lit=1") <= frames:
return fail("the kernel cover UI is not repainted against Xorg")
print("[ok] kernel UI is repainted every second")
daemon.send("BLANK")
if not daemon.wait("dpms off"):
if not daemon.wait("kernel cmd 28") or not daemon.wait("dpms off") or \
not daemon.wait("kernel backlight 0"):
return fail("blanking did not power the cover down")
if marker.exists() or bl.read_text().strip() != "0":
return fail("the shared backlight marker was not cleared")
print("[ok] BLANK: display-off, backlight off, marker removed")
daemon.send("LID OPEN")
if not daemon.wait("release"):
return fail("opening the flip did not release the mux")
if not any(e == "gpio 0 1" for e in daemon.events()):
return fail("the mux was not restored to the internal panel")
print("[ok] blank and open: panel off, mux restored")
if marker.exists():
return fail("opening the flip left the cover backlight marker")
print("[ok] LID OPEN: panel off, mux restored")
# A lit main backlight must block the whole kernel path.
# A live main panel must still block the initial shared-bus takeover.
(root / "dpms").write_text("On\n")
tail = len(daemon.events())
daemon.send("LID CLOSED")
bl.write_text("14\n")
daemon.send("BUTTON")
time.sleep(0.3)
time.sleep(0.2)
if "pending" not in daemon.send("STATUS"):
return fail("a lit main backlight did not block the kernel backend")
if any(e.startswith("kernel frame") or e.startswith("dpms reinit")
return fail("a live main panel did not block the kernel backend")
if any(e.startswith("kernel frame") or e == "dpms reinit"
for e in daemon.events()[tail:]):
return fail("the kernel backend drew with the main backlight lit")
print("[ok] lit main backlight blocks the kernel backend")
return fail("the kernel backend drew while the main panel was live")
(root / "dpms").write_text("Off\n")
daemon.send("BUTTON")
if not daemon.wait("kernel frame lit=1"):
return fail("BUTTON did not recover after DPMS went off")
print("[ok] DPMS-Off gate blocks the initial bus takeover")
finally:
daemon.close()
print("kernel-owned cover panel: all checks passed")
+12 -2
View File
@@ -63,12 +63,15 @@ def main():
for token in ("LID_DEBOUNCE_MS 20", "HALL_EDGE_MS 20", "LID_LOOP_MS 20",
"hall_observed", "fast_until", "write_session_file",
"write_lid_state(closed)", 'write_session_file(state, "screenoff")',
'write_session_file(state, "unlock")', 'cover_send("OPEN")',
'write_session_file(state, "lock")', 'cover_send("OPEN")',
'locker_send("LOCK\\n")', 'run_sxmo_state("lock", "open")',
"read_ready(&list, fds, nfds, &switch_mask, &edge)",
"LID_GENERATION_FILE", "run_dpms",
"bananarchy-lid-state.sh"):
if token not in lid:
return fail("lid daemon lost instant handling: %s" % token)
if "unlink(LOCK_FLAG)" in lid:
return fail("opening the flip still auto-unlocks the desktop")
# The cover daemon must be told to release the bus before the panel is lit.
if lid.index('cover_send("OPEN")') > lid.index('write_sysfs_int(BRIGHTNESS, bl)'):
return fail("the SPI bus is released after the main panel is relit")
@@ -76,7 +79,14 @@ def main():
if lid_close.index('write_session_file(LOCK_FLAG, "1")') > \
lid_close.index('write_text_file(BRIGHTNESS, "0")'):
return fail("the screen is locked after the panel is blanked")
print("[ok] lid daemon: sticky hall state, edge wakeup and synchronous lock")
lid_open = lid[lid.index(' } else {'):]
if 'write_session_file(LOCK_FLAG, "1")' not in lid_open or \
'write_session_file(state, "lock")' not in lid_open:
return fail("opening the flip does not keep the desktop locked")
if lid_open.index('write_session_file(state, "lock")') > \
lid_open.index('write_sysfs_int(BRIGHTNESS, bl)'):
return fail("the desktop lock is published after the panel is relit")
print("[ok] lid daemon: instant close, persistent lock and bus handover")
scratch = pathlib.Path("/tmp/bantam/9064bb701d9e9f7c6412f0ea6846d88a")
scratch.mkdir(parents=True, exist_ok=True)