Drive the 2720 Flip cover panel through the kernel panel driver
Autonomous testing (clean reboot, kernel SPI statistics, kHz GPIO sweeps, CS0/CS1 register reads, battery/ALS/hwmon checks, host webcam differential imaging) showed all twelve userspace PROBE cases delivered complete, error-free SPI traffic while the cover stayed dark. The QUP5 pinctrl group has one CS line and gpio110 (the kernel panel-mipi-dbi-spi driver's D/C) is shared behind the gpio13 bus switch, so no userspace D/C framing can work. backend = kernel is now the default. While the flip is closed the compiled cover daemon claims only gpio13 (mux) and gpio23 (cover reset), switches the bus to the cover and forces a DPMS off/on cycle through bananarchy-cover-dpms.sh reinit; mipi_dbi_enable() then replays the kernel's firmware init sequence onto the external panel with CS0 and gpio110 D/C. The cover UI is rendered as a 240x240 XR24 damage rect at the top of /dev/fb0 using the fbdev stride, which makes mipi_dbi set a 240x240 address window. The main backlight and keypad stay at 0, so only the outer panel can light. On open the mux returns to the internal panel and the lid daemon requests a reinit after an 80 ms settle. Live verification: closed -> backend=kernel-dark (DPMS off); BUTTON -> backend=kernel, dpms=On, gpio13 high, 172800 non-zero bytes of cover UI in /dev/fb0, kernel spi0.0 +460899 bytes and userspace spi0.1 +0, zero SPI errors; BLANK -> kernel-dark/DPMS off; LID OPEN -> mux=free, gpio13 low. Main backlight and keypad stayed at 0 throughout. All spidev/8-bit/9-bit paths, PROBE, bananarchy-cover-probe.sh and backend = fb|spidev|none remain as runtime rollback paths. New host test scripts/test-cover-kernel.py plus check-rebuild.sh guards. Rebuilt the a1108/dejavu nokia-beatles image and pinned the verified hash ce0542321990a8cff8ab122c0a47c0684fcc7e3d5f6fc97e74b3b0ea4c4826b5 in check-rebuild.sh. e2fsck -fn passed on both partitions, debugfs confirms the rebuilt daemons, helper and config byte-for-byte, and the bootfs sync, boot image check, artifact sync, host tests and rebuild preflight all pass. Limitation: Xorg shares /dev/fb0, so its repaints can still overwrite part of the cover UI; a dedicated override-redirect cover compositor is next. Physical illumination is still unverified from the host.
This commit is contained in:
1 parent
5f8b7c88ac
commit
c939687138
15 files changed
+468
-21
No files matched your search
@@ -373,7 +373,7 @@ fi
|
||||
echo "[check] Known-good flashable image set..."
|
||||
for pair in \
|
||||
"69a44f60eb123ebddf600be927155dc4a599ec35b7a0cf80060f4ba01f599f08 images/bananarchy-nokia-argon.img" \
|
||||
"57d140e9cdf05631a6620b639d143350b9984b2170592fb927c93bfb18f67a2b images/bananarchy-nokia-beatles.img" \
|
||||
"ce0542321990a8cff8ab122c0a47c0684fcc7e3d5f6fc97e74b3b0ea4c4826b5 images/bananarchy-nokia-beatles.img" \
|
||||
"2b5c61aba307dbbda61f3b19a2ad5770f9854f41cba4e2c97e24efb7e20879f3 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
|
||||
set -- $pair
|
||||
@@ -1510,7 +1510,9 @@ for token in 'cover_hw_release' 'cover_spi_draw' 'hw_init_panel' \
|
||||
fail "bananarchy-cover-idle.c lost the closed-flip spidev backend: $token"
|
||||
fi
|
||||
done
|
||||
for token in 'backend = auto' 'spi_device = /dev/spidev0.1' \
|
||||
for token in 'backend = kernel' 'main_fb_device = /dev/fb0' \
|
||||
'kernel_dpms_helper = /usr/bin/bananarchy-cover-dpms.sh' \
|
||||
'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' \
|
||||
'dc_command_level = 0' 'dc_data_level = 1' \
|
||||
@@ -1525,6 +1527,21 @@ if ! grep -qF 'flip_open' "$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' \
|
||||
"$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"
|
||||
fi
|
||||
if ! grep -qF 'bananarchy-cover-dpms.sh' \
|
||||
"$BASE_DIR/src/bananarchy-daemons/bananarchy-lid.c"; then
|
||||
fail "the lid daemon no longer re-initialises the kernel panel on open"
|
||||
fi
|
||||
if [ ! -x "$BASE_DIR/scripts/test-cover-kernel.py" ] || \
|
||||
! "$BASE_DIR/scripts/test-cover-kernel.py" >/dev/null 2>&1; then
|
||||
fail "host kernel-owned cover panel test failed"
|
||||
fi
|
||||
if [ ! -x "$BASE_DIR/scripts/test-cover-spidev.py" ]; then
|
||||
fail "missing host test scripts/test-cover-spidev.py"
|
||||
fi
|
||||
|
||||
Executable
+183
@@ -0,0 +1,183 @@
|
||||
#!/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.
|
||||
"""
|
||||
import os
|
||||
import pathlib
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
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"
|
||||
|
||||
|
||||
class Daemon:
|
||||
def __init__(self, root, exe, log, fb, bl, config):
|
||||
self.log = log
|
||||
self.fb = fb
|
||||
self.bl = bl
|
||||
self.sock = root / "cover.sock"
|
||||
self.client_path = root / "client.sock"
|
||||
env = dict(os.environ)
|
||||
env.update({
|
||||
"BANANARCHY_COVER_LOCK": str(root / "daemon.lock"),
|
||||
"BANANARCHY_COVER_MAIN_BLANK_CFG": str(root / "idle_blank"),
|
||||
"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"),
|
||||
})
|
||||
(root / "dpms").write_text("Off\n")
|
||||
self.proc = subprocess.Popen([str(exe), "--config", str(config)],
|
||||
env=env, stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL)
|
||||
self.client = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
||||
self.client.bind(str(self.client_path))
|
||||
self.client.settimeout(2)
|
||||
end = time.time() + 3
|
||||
while time.time() < end and not self.sock.exists():
|
||||
time.sleep(0.05)
|
||||
|
||||
def send(self, command):
|
||||
self.client.sendto(command.encode(), str(self.sock))
|
||||
try:
|
||||
return self.client.recv(512).decode().strip()
|
||||
except socket.timeout:
|
||||
return ""
|
||||
|
||||
def events(self):
|
||||
return self.log.read_text(encoding="utf-8", errors="replace").splitlines() \
|
||||
if self.log.is_file() else []
|
||||
|
||||
def wait(self, text, timeout=3.0):
|
||||
end = time.time() + timeout
|
||||
while time.time() < end:
|
||||
if any(text in line for line in self.events()):
|
||||
return True
|
||||
time.sleep(0.05)
|
||||
return False
|
||||
|
||||
def close(self):
|
||||
try:
|
||||
self.send("QUIT")
|
||||
except OSError:
|
||||
pass
|
||||
self.client.close()
|
||||
try:
|
||||
self.proc.wait(timeout=3)
|
||||
except subprocess.TimeoutExpired:
|
||||
self.proc.kill()
|
||||
self.proc.wait()
|
||||
|
||||
|
||||
def fail(message):
|
||||
sys.stderr.write("FAIL: %s\n" % message)
|
||||
return 1
|
||||
|
||||
|
||||
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")
|
||||
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"):
|
||||
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")
|
||||
source = SRC.read_text(encoding="utf-8")
|
||||
for token in ("cover_kernel_draw", "cover_kernel_frame",
|
||||
"cover_main_backlight_is_off", "reinit"):
|
||||
if token not in source:
|
||||
return fail("cover daemon lost the kernel backend: %s" % token)
|
||||
print("[ok] kernel backend wiring is present")
|
||||
with tempfile.TemporaryDirectory(prefix="bananarchy-cover-kernel-") as tmp:
|
||||
root = pathlib.Path(tmp)
|
||||
exe = root / "cover-idle"
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c11", "-O2", "-Wall", "-Wextra", "-Werror",
|
||||
"-I" + str(SRC.parent), str(SRC), "-o", str(exe)],
|
||||
capture_output=True, text=True)
|
||||
if build.returncode:
|
||||
sys.stderr.write(build.stderr)
|
||||
return 1
|
||||
print("[ok] host build of the compiled cover daemon")
|
||||
fb = root / "fb0"
|
||||
fb.write_bytes(b"\x00" * (240 * 320 * 4))
|
||||
bl = root / "brightness"
|
||||
bl.write_text("0\n")
|
||||
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"
|
||||
"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)
|
||||
try:
|
||||
time.sleep(0.3)
|
||||
if daemon.events():
|
||||
return fail("an open flip claimed the mux or touched DPMS: %s" %
|
||||
daemon.events()[:4])
|
||||
print("[ok] open flip: no mux claim, no DPMS, no frame")
|
||||
|
||||
daemon.send("LID CLOSED")
|
||||
if not daemon.wait("dpms off"):
|
||||
return fail("closing the flip did not blank the cover")
|
||||
if not any(e == "gpio 1 1" for e in daemon.events()):
|
||||
return fail("the mux was not switched to the external panel")
|
||||
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")
|
||||
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")
|
||||
|
||||
daemon.send("BLANK")
|
||||
if not daemon.wait("dpms off"):
|
||||
return fail("blanking did not power the cover down")
|
||||
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")
|
||||
|
||||
# A lit main backlight must block the whole kernel path.
|
||||
tail = len(daemon.events())
|
||||
daemon.send("LID CLOSED")
|
||||
bl.write_text("14\n")
|
||||
daemon.send("BUTTON")
|
||||
time.sleep(0.3)
|
||||
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")
|
||||
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")
|
||||
finally:
|
||||
daemon.close()
|
||||
print("kernel-owned cover panel: all checks passed")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -42,8 +42,8 @@ class Cover:
|
||||
self.client_path.unlink()
|
||||
self.client = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
||||
self.client.bind(str(self.client_path))
|
||||
self.client.settimeout(2)
|
||||
deadline = time.time() + 3
|
||||
self.client.settimeout(3)
|
||||
deadline = time.time() + 5
|
||||
while time.time() < deadline and not self.sock_path.exists():
|
||||
time.sleep(0.05)
|
||||
|
||||
@@ -59,7 +59,7 @@ class Cover:
|
||||
return []
|
||||
return self.log.read_text(encoding="utf-8", errors="replace").splitlines()
|
||||
|
||||
def wait_event(self, text, timeout=3.0):
|
||||
def wait_event(self, text, timeout=5.0):
|
||||
end = time.time() + timeout
|
||||
while time.time() < end:
|
||||
if any(text in line for line in self.events()):
|
||||
@@ -146,7 +146,8 @@ def main():
|
||||
sys.stderr.write("FAIL: cover daemon lost %s\n" % token)
|
||||
return 1
|
||||
conf = CONFIG.read_text(encoding="utf-8")
|
||||
for token in ("backend = auto", "spi_device = /dev/spidev0.1",
|
||||
for token in ("backend = kernel", "main_fb_device = /dev/fb0",
|
||||
"spi_device = /dev/spidev0.1",
|
||||
"spi_mux_gpio", "spi_dc_gpio", "spi_reset_gpio",
|
||||
"mux_closed_level", "spi_speed_hz = 25000000", "dc_gpio = -1"):
|
||||
if token not in conf:
|
||||
|
||||
Reference in new issue
Block a user