Fix 2720 Flip cover init, shared backlight and flip lock
This commit is contained in:
1 parent
c939687138
commit
b389120328
24 files changed
+494
-217
No files matched your search
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user