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
@@ -71,19 +71,27 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
|
||||
|
||||
- The shipping 2720 Flip DTS/DTB is single-panel. The two-panel `/dev/fb1` layout is opt-in via
|
||||
`scripts/build-beatles-cover-panel.py`; rollback is `scripts/build-beatles-no-cover-dtb.py`. Do not make it default
|
||||
until gpio13 mux polarity and gpio21/gpio23 D/C/reset polarity are physically probed: a live test darkened both
|
||||
screens. The shipping image drives the external GC9305 from userspace over `/dev/spidev0.1` while the flip is
|
||||
**closed only** (`bananarchy-cover-idle`); never claim gpio13/21/23 or send SPI traffic while the flip is open, and
|
||||
gate activation on the main panel being DPMS-off; always restore the mux to the internal panel on `LID OPEN`.
|
||||
- The cover panel's D/C wiring is unsigned-off: gpio21 is TE in the KaiOS DTS, not necessarily D/C. Keep both 8-bit (`spi_word_bits = 8`) and 9-bit MIPI DBI (`9`) paths, `bananarchy-coverctl PROBE` and `bananarchy-cover-probe.sh`. Do not claim a winner without eyes-on confirmation.
|
||||
until gpio13 mux polarity and gpio21/gpio23 routing are physically probed: a live test darkened both screens.
|
||||
gpio13 polarity is now TE-probed (high = cover, low = internal), but the two-panel DT remains opt-in.
|
||||
The shipping image drives the external GC9305 through the kernel `panel-mipi-dbi-spi` driver while the flip is
|
||||
**closed only** (`bananarchy-cover-idle`); never claim gpio13/23 or send cover SPI traffic while the flip is open,
|
||||
gate initial activation on the main panel being DPMS-off, and always restore the mux on `LID OPEN`.
|
||||
- The KaiOS 3.10 DTS gives both panels shared CS0, gpio110 D/C and one PWM backlight; gpio21 is TE and gpio23 is the
|
||||
external reset. Keep the exact vendor external init firmware, the debugfs command replay, the gpio23 reset pulse,
|
||||
`/run/bananarchy/cover-backlight` and the `bananarchy-display-power-sync` marker exemption. The legacy 8-bit/9-bit
|
||||
userspace paths, `PROBE` and `bananarchy-cover-probe.sh` remain rollback/sign-off tooling. If the cover stays dark,
|
||||
`SET mux_closed_level 0` switches gpio13 polarity at runtime.
|
||||
- Keep the internal beatles panel at 25 MHz, `dc_gpio = -1` for the spidev fallback, external-panel firmware and
|
||||
initramfs module lists, the Xorg `card0` pin, `bananarchy-cover-diagnose.sh`, and the
|
||||
`scripts/test-cover-dt.py` / `scripts/test-cover-spidev.py` guards.
|
||||
- The shipping cover backend is `backend = kernel`: the kernel `panel-mipi-dbi-spi` driver owns CS0 and the shared gpio110 D/C. Keep `bananarchy-cover-dpms.sh reinit`, the gpio13 mux claim, the 240x240 `/dev/fb0` damage rect, the main-backlight-off gate and `scripts/test-cover-kernel.py`. Keep `spidev`/`fb`/`none` and PROBE as rollback paths.
|
||||
- The shipping cover backend is `backend = kernel`: keep `bananarchy-cover-dpms.sh reinit`, the gpio13 mux claim,
|
||||
the 240x240 `/dev/fb0` damage rect, the 1 s repaint against Xorg, `scripts/test-cover-kernel.py`, and the
|
||||
`spidev`/`fb`/`none` rollback backends.
|
||||
- Keep the 2720 Flip lid handling event-driven and instant: sticky hall state, immediate hall re-read on `EV_SW`
|
||||
edges, 20 ms debounce, and synchronous lid-state/lock/backlight/DPMS writes in `bananarchy-lid.c`. Every main-panel
|
||||
wake path must call `bananarchy-lid-gate.sh`; a closed flip may only light the cover. `sxmo_state.sh set unlock` is
|
||||
gated too because `dwm` calls it directly. Guard `scripts/test-lid-gate.py`.
|
||||
edges, 20 ms debounce, and synchronous lid-state/lock/backlight/DPMS writes in `bananarchy-lid.c`. Closing locks
|
||||
the desktop; opening must keep the lock flag and wake to the passcode lockscreen, never auto-unlock. Every
|
||||
main-panel wake path must call `bananarchy-lid-gate.sh`; a closed flip may only light the cover.
|
||||
`sxmo_state.sh set unlock` is gated too because `dwm` calls it directly. Guard `scripts/test-lid-gate.py`.
|
||||
- Build the lk2nd display image from pinned `bootloader/lk2nd/nokia-beatles.patch`. Exact stock IDs, 512 MiB memory
|
||||
fallback, appended DTB, `quiet splash`, and the low-bit reboot cookie matter. `check-lk2nd-beatles.py`,
|
||||
`test-lk2nd-beatles-port.py`, `check-beatles-bootimg.py`, `sync-beatles-bootfs.py --check`, and `check-rebuild.sh`
|
||||
|
||||
+9
-1
@@ -13,6 +13,14 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
|
||||
|
||||
Work since `a1108` has focused on reliable 2720 Flip hardware support and a reproducible boot/flash path. Earlier incremental and superseded diagnostic entries are consolidated here.
|
||||
|
||||
### Vendor-init kernel cover path and persistent flip lock
|
||||
|
||||
- **Root cause of the dark cover**: the KaiOS 3.10 downstream DTS (`0004-dts-adaptations.patch`) shows that both GC9305s share CS0, gpio110 D/C and one PMIC MPP2 PWM backlight; gpio13 selects the panel, gpio23 is the external reset and gpio21 is TE. The previous kernel backend left that shared backlight at zero, never pulsed gpio23, and replayed the internal 240x320 init instead of the stock 240x240 stream. A DPMS off/on cycle alone cannot initialise the external panel. The earlier open transition also removed the lock flag and returned straight to the unlocked desktop.
|
||||
- **Switch**: `nokia,beatles-gc9305-ext-panel.bin` now contains the exact vendor `fe ef 3a 05 ... 2a/2b 0..239, 11, 29` stream. While closed, `bananarchy-cover-idle` claims gpio13/gpio23, pulses reset, sends that stream through the kernel driver's `/sys/kernel/debug/dri/0/command` hook, publishes `/run/bananarchy/cover-backlight` before enabling the shared backlight, and renders a 240x240 `/dev/fb0` damage rect once per second so Xorg repaints cannot erase it. `bananarchy-display-power-sync` skips the closed-lid hard-off gate only while that marker and `lid-state=closed` are both present. `bananarchy-lid` now keeps `/tmp/bananarchy_screen_locked`, writes `sxmo.state=lock`, sends `LOCK` to `locker.so` and runs `sxmo_state.sh set lock` on open instead of auto-unlocking.
|
||||
- **Guards**: `scripts/test-cover-kernel.py`, `scripts/test-lid-gate.py`, `scripts/check-rebuild.sh`, `bananarchy-cover-diagnose.sh`, README, MANUAL and `AGENTS.md` now guard the vendor firmware, debugfs command hook, shared-backlight marker, 1 s repaint, DPMS-off initial gate, lock-on-open and both mux-polarity runtime knobs. The legacy `spidev`/`fb`/`none`, 8/9-bit and PROBE rollback paths remain.
|
||||
- **Live verification**: with the flip state injected closed and DPMS off, `BUTTON` produced `backend=kernel`, marker present, brightness 14, `bl_power=0`, DPMS On, 172800 non-zero bytes in the top 240x240 of `/dev/fb0`, 460919 extra kernel `spi0.0` bytes and zero SPI errors/timeouts. A gpiochip TE scan proved the bus routing objectively: blank had `ext(gpio21)=0 int(gpio24)=0` transitions, `mux_closed_level=0` had `ext=0 int=78`, and `mux_closed_level=1` had `ext=52 int=0`; high is the cover and low is the internal panel. A controlled close→open transition left `state=lock`, the lock flag present, the cover marker absent, `mux=free`, brightness 14, keypad 1 and DPMS On; it stayed locked after 1 s. The phone was restored to open/unlocked with all services started and zero `SPI transfer failed` messages. Eyes-on illumination still needs a human look, but the external panel's TE, shared backlight and kernel SPI traffic are now confirmed.
|
||||
- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu`; verified raw hash `e2ec6a35d1e7db698f929fa0ebdbed94ffd941a55fc50ceff7a223e82896e985`, pinned by `scripts/check-rebuild.sh`. `e2fsck -fn` passed on both partitions, `debugfs` confirms the rebuilt daemons, firmware, config, helper and scripts byte-for-byte, and the bootfs sync, boot image check, artifact sync, host tests and rebuild preflight pass. The standalone boot image hash is unchanged.
|
||||
|
||||
### Kernel-owned cover panel path (option b)
|
||||
|
||||
- **Why**: after a clean reboot, the kernel's own SPI statistics showed all twelve userspace PROBE cases delivered complete, error-free transfers (230558 B per 9-bit frame, 115279 B per 8-bit frame, zero `errors`/`timedout` and zero dmesg failures) while the cover stayed dark. MISO reads return zeros (write-only panels), no TE toggles on any of 64 TLMM lines at kHz sampling, battery voltage is frozen, there is no current/ALS sensor and only one PWM backlight. The QUP5 pinctrl group has a single CS line and gpio110 (the kernel panel driver's D/C) is shared behind the gpio13 bus switch, so no userspace D/C framing can work.
|
||||
@@ -21,7 +29,7 @@ Work since `a1108` has focused on reliable 2720 Flip hardware support and a repr
|
||||
- **Guards**: `scripts/test-cover-kernel.py` runs the daemon in simulation against a fake fbdev/backlight/DPMS helper and verifies open-flip silence, mux claim/restore, reinit-on-BUTTON, frame rendering, blanking and the lit-main-backlight block. `scripts/check-rebuild.sh` guards the source, config, helper and lid-daemon reinit.
|
||||
- **Limitation**: Xorg shares `/dev/fb0`, so its repaints can still overwrite part of the cover UI; a dedicated override-redirect cover compositor is the next step. Physical illumination remains unverified from the host.
|
||||
- **Live verification**: with the flip closed, `backend=kernel-dark` blanked the cover; `BUTTON` switched to `backend=kernel`, `dpms=On`, gpio13 high (mux on cover), rendered 172800 non-zero bytes of cover UI into the top 240x240 of `/dev/fb0`, and made the **kernel** `spi0.0` push 460899 bytes while the userspace `spi0.1` pushed 0 — zero SPI errors. `BLANK` returned `kernel-dark`/DPMS off; `LID OPEN` released the mux (gpio13 low, `mux=free`). Main backlight and keypad stayed at 0 throughout.
|
||||
- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu`; verified raw hash `ce0542321990a8cff8ab122c0a47c0684fcc7e3d5f6fc97e74b3b0ea4c4826b5`, pinned by `scripts/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 pass. The standalone boot image hash is unchanged.
|
||||
- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu`; verified raw hash `ce0542321990a8cff8ab122c0a47c0684fcc7e3d5f6fc97e74b3b0ea4c4826b5`, pinned by `scripts/check-rebuild.sh` at that point. `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 pass. The standalone boot image hash is unchanged. Superseded by the vendor-init rebuild below.
|
||||
|
||||
### Cover panel hardware sign-off path after the button regression
|
||||
|
||||
|
||||
@@ -455,8 +455,9 @@ Three native X11 games (`/usr/bin/snake`, `/usr/bin/tetris`, and `/usr/bin/scoun
|
||||
- **Wi-Fi and Bluetooth missing**: both radios depend on the shared WCNSS remote processor. `msm-firmware-loader` must start in sysinit before udev and mount the stock `modem` and `persist` partitions under `/run/msm-firmware-loader/mnt`; it then exposes `wcnss.mdt` and the factory `WCNSS_qcom_wlan_nv.bin` through the kernel firmware path. Check `rc-service msm-firmware-loader status`, `cat /sys/class/remoteproc/remoteproc1/state`, and `dmesg | grep -Ei 'wcnss|remoteproc|firmware'`. A `Direct firmware load for wcnss.mdt failed` message means the loader package or its sysinit link is missing, not that the Wi-Fi and Bluetooth drivers are absent. After a successful boot, `wlan0` and `hci0` enumerate automatically; Bluetooth userspace still starts on demand from the Networks/Bluetooth UI to save power.
|
||||
- **X startup and keypad**: OpenRC starts independent services in parallel; `etc/init.d/local` replaces its stock `after *` dependency, which deadlocked with parallel startup on this image. `udev_settle_timeout=2` stops missing modem firmware from holding the display manager behind a long `udevadm settle`, and `bananarchy-sshd-debug` starts independently of `local.d`. A boot-open flip reads `/run/bananarchy/lid-state` and starts in `state=unlock` with no passcode screen, so the keypad is live as soon as `dwm` starts. If the keypad is dead, check `rc-service bananarchy-lid status`, `cat /run/bananarchy/lid-state`, `sxmo_state.sh get`, `/tmp/bananarchy_screen_locked`, `DISPLAY=:0 xwininfo -id 0xa00001` and `DISPLAY=:0 xinput list`.
|
||||
- **Display distortion above 71% brightness**: the internal panel uses 25 MHz SPI on `nokia-beatles`, rather than the 50 MHz timing used by the other targets. This keeps the link stable when the MPP2 backlight PWM duty rises above the level-10/14 operating point. The brightness range remains 1–14 with no artificial cap, and panel offsets/init registers are unchanged. The timing can be checked with `dtc -I dtb -O dts /boot/qcom-msm8905-nokia-beatles.dtb | grep -A8 'display@0'`.
|
||||
- **Closing the flip**: `bananarchy-lid` reads the current `EV_SW` switch mask from `/dev/input/event2`, follows hall edge events with an 80 ms stability window, and reconciles the raw gpio36/gpio92 debugfs levels every 200 ms even while evdev is present. This covers missed edges and stale `EVIOCGSW` state without a busy-polling loop. On close it blanks the main panel and keypad LED immediately, runs `sxmo_state.sh set screenoff` and tells the cover daemon `LID CLOSED`; on open it clears the lock flag, restores both backlights, sends a trusted `CLOSE` to `locker.so` and runs `sxmo_state.sh set unlock`. Check `rc-service bananarchy-lid status`, `sxmo_state.sh get` and `grep -E " gpio(36|92) " /sys/kernel/debug/gpio`. If the hall polarity is inverted on your unit, set `BANANARCHY_LID_GPIO_FILE` to a different debugfs GPIO file for the fallback path. **Lag fix**: the hall reading is sticky and every `EV_SW` edge forces an immediate re-read, with a 20 ms debounce and 20 ms loop; the daemon writes `/run/bananarchy/lid-state`, `/tmp/bananarchy_screen_locked`, `sxmo.state`, both backlights and DPMS synchronously before spawning any hook. A close is now ~45-90 ms (was over 2 s) and an open ~10-130 ms. `bananarchy-lid-state.sh` drops stale hook spawns by lid state and a generation counter, so a late screenoff cannot re-lock a freshly opened flip.
|
||||
- **Cover display status and behaviour**: `bananarchy-cover-idle` is the compiled 0%-CPU default daemon and answers `bananarchy-coverctl` (`PING`, `STATUS`, `LID CLOSED|OPEN`, `BUTTON`, `NETWORK`, `BATTERY`, `NOTIFY`, `BLANK`/`UNBLANK`, `TEST`, `SET`); the native `bananarchy-coverd` is retained only for diagnostics. With the flip **open** the external panel is fully off and the daemon does not touch the shared QUP5 SPI bus at all; activation also requires `card0-SPI-1/dpms = Off`, so a transient lid-state flap cannot steal the bus from a live main panel. With the flip **closed** the daemon claims gpio13 (SPI bus mux), gpio21 (external D/C) and gpio23 (external reset) via `/dev/gpiochip0`, drives the mux to the cover panel, resets the GC9305, replays `/lib/firmware/nokia,beatles-gc9305-ext-panel.bin` over `/dev/spidev0.1` at 25 MHz and writes 240x240 RGB565 frames. `STATUS` reports `backend=spidev` and `mux=closed` while the cover owns the bus, and `mux=open` after `LID OPEN`, which sends display-off, restores the mux to the internal panel and releases the D/C and reset lines before Xorg flushes another frame. This is why the shipping image can use the cover screen without registering a second panel in the DT: both GC9305s share one SPI bus and the main panel is DPMS-off whenever the flip is closed. The panel stays off until an external side key is pressed: `bananarchy-volume-keys` reads `/run/bananarchy/lid-state` and sends the trusted `BUTTON` datagram instead of changing the volume, which shows the live clock, date, battery percentage and the compact main network indicators (`4G SIG75 WIFI`-style, published by `bananarchy-cover-status.sh` from the NetworkManager dispatcher and at service start). No further button blanks the cover after exactly the same **Config -> Screen blank** timeout that `dwm` uses (`~/.config/sxmo/idle_blank_timeout`, default 300 s, `0` = never; `blank_timeout = auto` in `/etc/bananarchy/cover-display.conf` selects it, a numeric value overrides it). The daemon blocks in `poll()` with no timer while off, so idle CPU stays at 0%. `backend = auto` prefers `/dev/fb1` when the opt-in two-panel DT is installed, using the 32-bpp fbdev `write()` path (not `mmap()`, which raises `SIGBUS`) and `FBIOBLANK`/`FB_BLANK_POWERDOWN` for "fully off". `backend = spidev` forces the userspace path, `backend = fb` forces the fbdev path and `backend = none` releases the bus; `SET backend none` is a live rollback. The external D/C, reset and mux polarities are config keys (`mux_closed_level`, `mux_open_level`, `dc_command_level`, `dc_data_level`, `reset_assert_level`, `reset_idle_level`) and runtime `SET` knobs, so physical sign-off needs no rebuild: close the flip (or hold `LID CLOSED` with the lid broadcaster stopped), run `bananarchy-coverctl TEST bars`, then try `SET mux_closed_level 0|1`, `SET reset_assert_level 0|1` and `SET dc_command_level 0|1` until the bars appear. The shipping DTS deliberately keeps the verified single-panel layout, so `/dev/fb1` is normally absent. A live test with two panels registered produced a working 240x240 external framebuffer but made the main panel go dark, so the two-panel `spi-mux` wiring is opt-in in `devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts`: build it with `scripts/build-beatles-cover-panel.py`, install the resulting DTB/boot.img into `pmOS_boot`, and verify the main panel before keeping it. `scripts/build-beatles-no-cover-dtb.py` builds the single-panel rollback DTB. The external firmware and `mux-core`/`mux-gpio`/`spi-mux` modules are already provisioned in the initramfs; `scripts/test-cover-idle.py`, `scripts/test-cover-spidev.py` and `scripts/test-cover-dt.py` verify the state machine, the closed-flip bus handover and both DT layouts on the host. Physical sign-off of the external D/C and reset polarity and of the cover backlight is still required with eyes on a live 2720 Flip; `devices/nokia-beatles/cover-panel.dtsi` remains a compile-checked reference for older DTBs. Run `bananarchy-cover-diagnose.sh` on the phone to check `/dev/fb1`, `/dev/spidev0.1`, the GPIO lines, the mux/panel modules, the firmware, the lid state and `bananarchy-coverctl STATUS` in one report. If the external panel disturbs the main display during sign-off, `SET backend none` releases the bus immediately and `scripts/build-beatles-no-cover-dtb.py --install` rebuilds the verified single-panel DTB/boot image for `pmOS_boot`.
|
||||
- **Closing the flip**: `bananarchy-lid` keeps a sticky hall reading, re-reads gpio36/gpio92 immediately on every `EV_SW` edge, and uses a 20 ms debounce/loop. On close it writes `/run/bananarchy/lid-state`, `/tmp/bananarchy_screen_locked`, `sxmo.state`, both backlights and DPMS synchronously before spawning any hook, then runs `sxmo_state.sh set screenoff` through a generation-guarded wrapper. On open it releases the cover's shared SPI bus, restores the main panel and **keeps the desktop locked**: it writes state `lock`, sends `LOCK` to `locker.so` and runs `sxmo_state.sh set lock`, so the passcode lockscreen appears instead of an auto-unlocked desktop. A close is ~45-90 ms and an open ~10-130 ms. `bananarchy-lid-state.sh` drops stale hook spawns by lid state and generation. Check `rc-service bananarchy-lid status`, `sxmo_state.sh get`, `/tmp/bananarchy_screen_locked` and `grep -E " gpio(36|92) " /sys/kernel/debug/gpio`. If the hall polarity is inverted, set `BANANARCHY_LID_GPIO_FILE` to a different debugfs GPIO file.
|
||||
- **Cover display status and behaviour**: `bananarchy-cover-idle` is the compiled 0%-CPU default daemon and answers `bananarchy-coverctl` (`PING`, `STATUS`, `LID CLOSED|OPEN`, `BUTTON`, `NETWORK`, `BATTERY`, `NOTIFY`, `BLANK`/`UNBLANK`, `TEST`, `SET`, `PROBE`); the native `bananarchy-coverd` is retained only for diagnostics. With the flip open the daemon does not touch the shared QUP5 SPI bus; initial closed-flip activation still requires `card0-SPI-1/dpms = Off`. The shipping single-panel DTB uses `backend = kernel`: the KaiOS 3.10 DTS shows that the two GC9305s share CS0, gpio110 D/C and one PWM backlight, while gpio13 selects the panel, gpio23 is the external reset and gpio21 is TE; a live TE scan proved high = cover and low = internal. On a closed-flip button event the daemon claims gpio13/gpio23, pulses reset, replays the exact vendor 240x240 init through `/sys/kernel/debug/dri/0/command`, publishes `/run/bananarchy/cover-backlight`, turns on the shared backlight and flushes a 240x240 `/dev/fb0` damage rect once per second. `bananarchy-display-power-sync` permits that backlight only while the marker and closed-lid state are both present; the keypad stays dark. `STATUS` reports `backend=kernel`, `mux=cover`; `BLANK` sends display-off and removes the marker; `LID OPEN` restores the mux and re-initialises the internal panel. The outer panel stays off until a trusted side-key `BUTTON` / `WAKE` arrives; it blanks after the same **Config -> Screen blank** timeout (`blank_timeout = auto`). The legacy `spidev`, 8/9-bit, `PROBE`, `SET mux_closed_level 0|1` and `SET backend none` paths remain for rollback. If the cover stays dark, try `SET mux_closed_level 0` with the flip closed and press an outer button; the runtime knob forces a fresh reset/init cycle. `bananarchy-cover-diagnose.sh` reports the debugfs hook, backlight marker, GPIO lines, DPMS, firmware and daemon state. `scripts/test-cover-idle.py`, `scripts/test-cover-spidev.py`, `scripts/test-cover-kernel.py`, `scripts/test-cover-dt.py` and `scripts/test-lid-gate.py` guard the state machine, both backends, DT layouts and lid gate on the host. The opt-in two-panel `spi-mux` DT remains experimental because its separate gpio21 D/C wiring contradicts the vendor DTS and a live test darkened the main panel; `scripts/build-beatles-no-cover-dtb.py` builds the shipping rollback DTB.
|
||||
|
||||
- **Camera app frozen / UI unresponsive**: check `top` for `bananarchy-volume-keys`. The daemon must be a single instance at 0% CPU; stale evdev fds are pruned by `prune_devices()`/`drop_device()` and guarded by `flock`. `rc-service bananarchy-volume-keys status` and `bananarchy-keypad-diagnose.sh` report its state. `xcamera` should return immediately and `bananarchy-photo <file>` should write a 600x800 JPEG.
|
||||
- **Camera**: `/dev/video0` is provided by the out-of-tree `msm8905-cam` module, loaded at boot by `/etc/modules-load.d/bananarchy-hardware.conf` and `etc/local.d/10-bananarchy-hardware.start`. Check with `v4l2-ctl --list-devices`; a missing node means the module did not load (previously caused by a missing `/bin/sed` breaking the `modules` service).
|
||||
- **Side volume keys**: the compiled evdev daemon `bananarchy-volume-keys` reads `KEY_VOLUMEUP`/`KEY_VOLUMEDOWN` directly and calls `sxmo_audio.sh vol up/down 5`; `sxmo_audio.sh` mirrors that percentage into the live PipeWire sink (the MSM8905 mainline kernel has no ALSA card yet). Press a side button and check `wpctl get-volume <sink-id>`; `bananarchy-keypad-diagnose.sh` reports the XKB mapping and both volume values.
|
||||
|
||||
@@ -50,9 +50,8 @@ Instead of spawning slow shell scripts for everyday phone tasks, Bananarchy runs
|
||||
- **Kopher SmallWeb browser (`xkopher` / `kopher` / `xsmallweb` / `smallweb.so`)**: multi-protocol SmallWeb client for **Gopher** (`gopher://`) with optional TLS (`gophers://`), **Gemini** (`gemini://`), **Spartan** (`spartan://`), and **Nex** (`nex://`), featuring WAP-style default keypad controls from [Kopher](https://code.luxferre.top/luxferre/kopher.git), user-adjustable keybindings (`~/.config/sxmo/smallweb_controls.tsv`), 10 bookmarks, custom homepage support, and link focus that always scrolls the viewport to the focused link in both wrapped and unwrapped modes.
|
||||
- **Webarchy Web browser (`webarchy` / `xwebarchy` / `webarchy.so`)**: full-featured HTML5/CSS3/JS web browser built on WPE / WebKit (`webkit2gtk-4.1` + `libwpe-1.0`) with Adreno 304 hardware acceleration (`WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS`, WebGL, accelerated 2D canvas, and 512 MB RAM pressure tuning), default KaiOS 4.0 User-Agent (`Mozilla/5.0 (Mobile; rv:123.0) Gecko/123.0 Firefox/123.0 KAIOS/4.0`) with preset and custom User-Agent override (`~/.config/sxmo/webarchy_ua.txt`), `UTF-8` default encoding fallback, `Noto Sans` / `Noto Serif` (`font-noto` + `font-noto-emoji`) as the default non-monospace browser fonts and `Fira Code` with OpenType ligatures as the monospace font, full GStreamer multimedia (`MediaSource` / MSE, WebAudio, inline HTML5 `<video>`/`<audio>` autoplay without user gesture requirements), unobtrusive bookmarking (`*HTTPS`/`*HTTP` header badge, `*`+`0-9` save / `#`+`0-9` load chords, and bookmark manager), and dual navigation modes (keypad link-stepping mode with NeoUI multi-tap form input by default, plus an optional `*#` accelerated mouse cursor emulation mode), and a device-aware renderer profile: the 2720 Flip uses the WebKit CPU renderer (with automatic software fallback after a WebProcess crash) while the 8110 4G keeps Adreno 304 acceleration; `~/.config/sxmo/webarchy_software_renderer` forces the CPU profile on any target. The image build also compiles the installed GSettings schema XML into `usr/share/glib-2.0/schemas/gschemas.compiled`; without that database WebKit's network process aborts with an internal error before any renderer policy can help.
|
||||
- **GPS-only system time**: **Config -> Time source** switches from NTP to GNSS only (stopping `chronyd` and disabling every network-up NTP burst) and **Config -> Sync GPS time** steps the clock from a ModemManager GPS UTC value or a valid RMC fix, writes the RTC and refreshes the status bar. All GPS queries now resolve the GNSS-capable modem through `bananarchy-gps-modem.sh` instead of the ambiguous `mmcli -m any`, which fixes empty GPS data on the dual-SIM 2720 Flip. See `MANUAL.md` sections 5.6 and 5.8.
|
||||
- **2720 Flip cover display behaviour**: the compiled `bananarchy-cover-idle` renderer keeps the external panel fully off while the flip is open, waits for a side-button `BUTTON` event when closed, then shows the clock, battery and compact main network indicators until the same **Config -> Screen blank** timeout expires with no further button press. `bananarchy-volume-keys` turns the external keys into trusted cover wake events, `bananarchy-cover-status.sh` publishes modem/Wi-Fi indicators from network events, and the daemon blocks in `poll()` with no timer while off. **The external 240x240 GC9305 is now driven on the shipping single-panel image**: with the flip closed the daemon claims gpio13 (SPI mux), gpio21 (D/C) and gpio23 (reset) through `/dev/gpiochip0`, replays `/lib/firmware/nokia,beatles-gc9305-ext-panel.bin` over `/dev/spidev0.1` at the verified 25 MHz, and pushes RGB565 frames, but only while the main panel is DPMS-off; on open it sends display-off, restores the mux to the internal panel and releases the panel lines before Xorg can flush another main-panel frame. `backend = auto` prefers `/dev/fb1` when the opt-in two-panel DT is installed. All mux/D-C/reset polarities are config keys plus live `bananarchy-coverctl SET` knobs, and `SET backend none` is a one-command rollback. The two-panel `spi-mux` DT (`devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts`, built with `scripts/build-beatles-cover-panel.py`) stays **opt-in**: a live test produced `/dev/fb1` (240x240, 32bpp) but darkened the main panel, so the shipping DTB keeps the verified single-panel layout until gpio13 and the external D/C/reset polarities are probed with eyes on the phone. `FBIOBLANK` powers the cover fbdev down when it is off, `bananarchy-cover-diagnose.sh` reports the live panel state, `scripts/test-cover-idle.py`, `scripts/test-cover-spidev.py` and `scripts/test-cover-dt.py` validate the renderer, the closed-flip backend and both DT layouts on the host, and `scripts/build-beatles-no-cover-dtb.py` builds the single-panel rollback. **Closing the flip now blanks and locks the main panel in tens of milliseconds**: an `EV_SW` edge triggers an immediate hall re-read, and the compiled lid daemon writes the lid state, lock flag, Sxmo state and backlights synchronously before any shell hook runs. While closed, `bananarchy-lid-gate.sh` blocks every main-panel wake (dwm, Sxmo hooks, incoming calls, external keys) and forwards it as a cover `WAKE`, so the three side buttons and any event can only light the outer panel; opening the flip instantly hands the shared bus back to the main panel. See `scripts/test-lid-gate.py`. The external panel wiring is still pending physical sign-off: `bananarchy-cover-idle` defaults to 9-bit MIPI DBI (D/C in bit 8, no DC GPIO) and also supports the old 8-bit D/C-on-gpio21 path (`spi_word_bits`), and `bananarchy-cover-probe.sh` walks twelve polarity/clock/word-width cases with `TEST bars` while the flip is closed; `STATUS probe=case N/12` identifies the working one.
|
||||
- **2720 Flip cover display behaviour**: the compiled `bananarchy-cover-idle` renderer keeps the external panel fully off while the flip is open, waits for a side-button `BUTTON` event when closed, then shows the clock, battery and compact network indicators until the same **Config -> Screen blank** timeout expires. `bananarchy-volume-keys` turns all three outer keys into trusted cover wake events; `bananarchy-cover-status.sh` publishes modem/Wi-Fi indicators; and the daemon blocks in `poll()` with no timer while off. The shipping single-panel DTB drives the cover through the **kernel** `panel-mipi-dbi-spi` driver (`backend = kernel`). The KaiOS 3.10 DTS shows that both GC9305s share CS0, gpio110 D/C and one PWM backlight: gpio13 selects the panel, gpio23 is the external reset and gpio21 is TE. A live TE scan proved high = cover and low = internal. While closed, the daemon claims gpio13/gpio23, pulses reset, replays the exact stock 240x240 init through the driver's `/sys/kernel/debug/dri/0/command` hook, publishes `/run/bananarchy/cover-backlight` before enabling the shared backlight, and flushes a 240x240 `/dev/fb0` damage rect once per second so Xorg repaints cannot erase it. `bananarchy-display-power-sync` leaves that shared backlight on only while the marker and closed-lid state are both present; the keypad stays dark. Opening the flip releases the bus, re-initialises the main panel and **keeps the desktop locked**, waking to the visible passcode lockscreen instead of auto-unlocking. `bananarchy-lid-gate.sh` still blocks every main-panel wake while closed and forwards it as a cover `WAKE`. The legacy `spidev`, 8/9-bit, `PROBE` and `SET backend none` rollback paths remain; if the outer panel stays dark, `SET mux_closed_level 0` forces a fresh reset/init cycle with the opposite mux polarity. `bananarchy-cover-diagnose.sh` reports the debugfs hook, backlight marker, GPIO lines and daemon state; `scripts/test-cover-idle.py`, `scripts/test-cover-spidev.py`, `scripts/test-cover-kernel.py`, `scripts/test-cover-dt.py` and `scripts/test-lid-gate.py` validate the renderer, both backends, DT layouts and lid gate on the host. The opt-in two-panel `spi-mux` DT remains experimental because its separate gpio21 D/C wiring contradicts the vendor DTS and a live test darkened the main panel.
|
||||
|
||||
On the shipping single-panel image the cover is driven by the **kernel** `panel-mipi-dbi-spi` driver (`backend = kernel`): closing the flip switches the gpio13 bus mux to the external GC9305 and a DPMS off/on cycle makes the kernel replay its init sequence with CS0 and the shared gpio110 D/C, while the cover UI is drawn into a 240x240 region of `/dev/fb0`. The main backlight and keypad stay dark; opening the flip restores the mux and re-initialises the main panel. The userspace `spidev` backend, 9-bit MIPI DBI mode and `bananarchy-cover-probe.sh` are retained as rollback paths.
|
||||
- **GPS reception test utility (`bananarchy-gps`) and OpenStreetMap navigator (`xgps` / `xmaps` / `xnav` / `gps.so`)**: CLI GNSS/GPS diagnostic tool (`bananarchy-gps status|enable|disable|nmea|watch`) and 3-tab NeoUI GPS navigator (`1:GPS Status`, `2:OSM Map`, `3:Nav/Search`) with live NMEA/QMI PDS satellite and 3GPP cell telemetry, interactive `240x212` OpenStreetMap slippy-map tile viewer with offline PNG tile cache (`~/.cache/sxmo/osm_tiles/`), Nominatim place search, saved waypoints, and OSRM turn-by-turn route geometry and step navigation.
|
||||
- **Themes (`xthemes`), wallpapers (`xwallpapers`), and ringtones (`xringtones`)**: installable `.Xresources` color and font themes (`~/.xthemes/*.xth`, 21 preinstalled schemes including `LynxLair.xth`) with live zero-restart reload across the entire UI, `dunst` notification popups (`bananarchy-sync-dunst-theme`), and terminal, alongside dedicated managers for desktop wallpapers and 3-tab call ringtones & notification/SMS alerts (`1:Ringtone`, `2:Notif/SMS`, `3:Settings`, supporting standard audio, tracker modules, and Nokia RTTTL `.nrt`/`.rtttl`/`.rtx`, Ericsson eMelody `.emy`, and IrDA iMelody `.imy` monophonic ringtones via `/usr/bin/bananarchy-melody`, wired into `sxmo_notifs.sh` and `sxmo_hook_notification.sh`) with 3-level vibration control.
|
||||
|
||||
@@ -203,7 +202,7 @@ sudo ./flash-edl.sh nokia-argon
|
||||
|
||||
The patched EDL client library is vendored under `vendor/edl/` (MIT), so a clean clone flashes without any manual download. `flash-edl.sh` also installs `pyusb` and `pyserial` into the gitignored `.flash-deps/` directory when the host lacks them; set `BANANARCHY_EDL_DIR` to use a different library checkout.
|
||||
|
||||
After a successful flash the phone boots lk2nd's branded boot splash, then the Plymouth boot splash, then X. Log in over the USB network with `ssh user@172.16.42.1` (password `147147`); if the main sshd's PAM stack is ever broken, a USB-only fallback listener accepts the same credentials on `ssh -p 2222 user@172.16.42.1`. Selecting **Reboot to loader** from the Power menu shows the visible lk2nd Fastboot menu; **Bootloader** stays in fastboot, **EDL** enters Sahara, and `fastboot reboot` returns to Linux. On the 2720 Flip, OpenRC starts independent services in parallel with a patched `local` service, a bounded `udevadm settle` and an independent USB fallback sshd keep X from waiting on modem firmware, a boot-open lid starts unlocked with a live keypad, and the external cover panel is driven only while the flip is closed by the compiled userspace spidev backend; the two-panel `spi-mux` DT stays opt-in pending gpio13 mux / reset polarity sign-off and the shipping DTS keeps the known-good single internal panel. See `MANUAL.md` section 4.1 for first-boot troubleshooting of the boot splash, keypad input and the external cover display.
|
||||
After a successful flash the phone boots lk2nd's branded boot splash, then the Plymouth boot splash, then X. Log in over the USB network with `ssh user@172.16.42.1` (password `147147`); if the main sshd's PAM stack is ever broken, a USB-only fallback listener accepts the same credentials on `ssh -p 2222 user@172.16.42.1`. Selecting **Reboot to loader** from the Power menu shows the visible lk2nd Fastboot menu; **Bootloader** stays in fastboot, **EDL** enters Sahara, and `fastboot reboot` returns to Linux. On the 2720 Flip, OpenRC starts independent services in parallel with a patched `local` service, a bounded `udevadm settle` and an independent USB fallback sshd keep X from waiting on modem firmware, a boot-open lid starts unlocked with a live keypad, a later close locks the desktop and opening shows the passcode lockscreen, and the external cover panel is driven only while the flip is closed by the compiled kernel-owned backend; the two-panel `spi-mux` DT stays opt-in pending gpio13 mux / reset polarity sign-off and the shipping DTS keeps the known-good single internal panel. See `MANUAL.md` section 4.1 for first-boot troubleshooting of the boot splash, keypad input and the external cover display.
|
||||
|
||||
See [MANUAL.md](MANUAL.md) for complete EDL, Fastboot, and microSD installation instructions, keypad navigation shortcuts, and the multi-mode T9 reference.
|
||||
|
||||
|
||||
@@ -8,10 +8,12 @@
|
||||
// scripts/build-beatles-cover-panel.py). A live 2720 Flip test produced
|
||||
// /dev/fb1 (240x240, 32bpp) and the full cover state machine, but the main
|
||||
// 240x320 panel went dark with both panels registered; the gpio13 mux select
|
||||
// and gpio21/gpio23 external DC/reset routing therefore still need physical
|
||||
// probing before the opt-in DT can become the default. This file documents
|
||||
// the wiring for older/stock DTBs; do not apply it to the current shipping
|
||||
// DTB (it would duplicate the mux).
|
||||
// and gpio21/gpio23 routing therefore still need physical probing before the
|
||||
// opt-in DT can become the default. The KaiOS 3.10 DTS labels gpio21 TE and
|
||||
// gives the external panel the same gpio110 D/C line as the internal panel,
|
||||
// so this reference overlay's separate gpio21 D/C is an unverified guess.
|
||||
// This file documents the wiring for older/stock DTBs; do not apply it to the
|
||||
// current shipping DTB (it would duplicate the mux).
|
||||
//
|
||||
// Both panels share BLSP1 QUP5 SPI; gpio13 selects which one the bus reaches.
|
||||
// spi-mux selects the mux state from the child chip-select number, so
|
||||
|
||||
Binary file not shown.
@@ -1,41 +1,30 @@
|
||||
# Nokia 2720 Flip (nokia-beatles) 1.3-inch 240x240 external GC9305 panel.
|
||||
#
|
||||
# Derived from the KaiOS 3.10 downstream DTS in the archived postmarketOS
|
||||
# linux-nokia-beatles package (0004-dts-adaptations.patch):
|
||||
# spi_gc9305_v2_qvga_ext_cmd, qcom,mdss-spi-on-command:
|
||||
# fe, ef, 3a 05, 35 00, 2a 00 00 00 ef, 2b 00 00 00 ef, 2c,
|
||||
# delay 120, 11, 29, 2c
|
||||
# Exact qcom,mdss-spi-on-command stream from the KaiOS 3.10 downstream DTS
|
||||
# (spi_gc9305_v2_qvga_ext_cmd) in pmaports' 0004-dts-adaptations.patch:
|
||||
# fe, ef, 3a 05, 35 00, 2a 00 00 00 ef, 2b 00 00 00 ef, 2c,
|
||||
# delay 120, 11, 29, 2c
|
||||
# qcom,mdss-spi-panel-width = 240, height = 240, bpp = 16.
|
||||
#
|
||||
# The register/gamma block below is the one already proven on this device's
|
||||
# internal GC9305 panel (nokia,beatles-gc9305-panel.txt); the two column/page
|
||||
# windows are set to 0..239 for the square cover panel. The blob is consumed
|
||||
# by panel-mipi-dbi-spi (kernel) or by bananarchy-coverd's spidev backend.
|
||||
# The stock panel node uses qcom,platform-spi-dc-gpio = gpio110 (the same
|
||||
# D/C line as the internal panel), qcom,platform-te-gpio = gpio21,
|
||||
# qcom,platform-reset-gpio = gpio23 and qcom,platform-spi-switch-gpio =
|
||||
# gpio13. gpio21 is TE, not D/C. Both panels share PMIC MPP2 PWM backlight.
|
||||
#
|
||||
# This init sequence is derived from vendor sources but has NOT yet been
|
||||
# verified on 2720 Flip hardware; see NOKIA-2720-FLIP.md.
|
||||
|
||||
# This MIPI DBI firmware is replayed by the shipping kernel backend through
|
||||
# /sys/kernel/debug/dri/0/command after gpio23 is pulsed and the gpio13 bus
|
||||
# switch is set to the cover. The obsolete userspace spidev rollback also
|
||||
# parses this file.
|
||||
#
|
||||
# MIPI DBI firmware records below (command, parameter count, parameters):
|
||||
command 0xfe
|
||||
command 0xef
|
||||
command 0x36 0x00 # MADCTL
|
||||
command 0x3a 0x55 # 65K 16-bit RGB565
|
||||
command 0x3a 0x05 # 16-bit RGB565
|
||||
command 0x35 0x00 # TE v-blanking
|
||||
command 0xb2 0x0c 0x0c 0x00 0x33 0x33 # porch setting
|
||||
command 0xb7 0x75 # gate control VGH/VGL
|
||||
command 0xbb 0x34 # Vcoms
|
||||
command 0xc0 0x2c # LCM control
|
||||
command 0xc2 0x01 # VDV/VRH enable
|
||||
command 0xc3 0x0d # VRH set
|
||||
command 0xc4 0x20 # VDV set
|
||||
command 0xc6 0xef # frame rate
|
||||
command 0x44 0x00 0x00 # tearing scan line
|
||||
command 0xd0 0xa4 0xa1 # power control 1
|
||||
command 0xe0 0xd0 0x02 0x09 0x0d 0x0e 0x19 0x30 0x51 0x43 0x09 0x14 0x13 0x18 0x21
|
||||
command 0xe1 0xd0 0x02 0x09 0x0d 0x0d 0x18 0x32 0x46 0x42 0x09 0x13 0x13 0x17 0x21
|
||||
command 0x2a 0x00 0x00 0x00 0xef # column address 0..239
|
||||
command 0x2b 0x00 0x00 0x00 0xef # page address 0..239
|
||||
command 0x2c # memory write
|
||||
command 0x11 # sleep out
|
||||
delay 120
|
||||
command 0x11 # sleep out
|
||||
command 0x29 # display on
|
||||
command 0x2c
|
||||
command 0x2c # memory write
|
||||
@@ -1901,8 +1901,9 @@
|
||||
display@1 {
|
||||
compatible = "nokia,beatles-gc9305-ext-panel", "panel-mipi-dbi-spi";
|
||||
reg = <0x01>;
|
||||
/* gpio21 is the external D/C line: 8-bit SPI works on QUP
|
||||
* and gpio110 stays owned by the internal panel. */
|
||||
/* Experimental: the KaiOS 3.10 DTS labels gpio21 TE
|
||||
* and shares gpio110 D/C. This separate D/C wiring is
|
||||
* unverified and is why the layout remains opt-in. */
|
||||
dc-gpios = <0x27 0x15 0x00>;
|
||||
reset-gpios = <0x27 0x17 0x00>;
|
||||
/* Same verified 25 MHz clock as the internal panel. */
|
||||
|
||||
@@ -3,17 +3,23 @@
|
||||
# /home/user/.config/bananarchy/cover-display.conf and are applied by
|
||||
# the xcover DWM plugin at session start.
|
||||
|
||||
# kernel = the default: the kernel panel-mipi-dbi-spi driver drives whichever
|
||||
# GC9305 is behind the gpio13 bus switch, using CS0 and its own gpio110 D/C.
|
||||
# While the flip is closed the daemon switches the mux to the cover, forces a
|
||||
# DPMS re-init so the kernel replays its init sequence there, and renders the
|
||||
# cover UI into /dev/fb0; the main backlight and keypad stay dark. On open the
|
||||
# mux returns to the internal panel and the kernel re-initialises it.
|
||||
# auto = /dev/fb1 when the opt-in two-panel DT is present, otherwise spidev;
|
||||
# fb/spidev force those legacy paths, none keeps the bus untouched (rollback).
|
||||
# kernel = the default shipping path. The KaiOS 3.10 DTS shows that both
|
||||
# GC9305s share CS0, gpio110 D/C and one PMIC PWM backlight; gpio13 selects
|
||||
# the panel, gpio23 is the external reset, and gpio21 is TE. While the flip is
|
||||
# closed the daemon claims gpio13/gpio23, pulses reset, replays the stock
|
||||
# 240x240 init through the kernel driver's debugfs command hook, enables the
|
||||
# shared backlight and flushes a 240x240 /dev/fb0 damage rect. The keypad
|
||||
# stays dark. Opening the flip releases the bus and re-initialises the main
|
||||
# panel. auto = /dev/fb1 with the opt-in two-panel DT, otherwise spidev;
|
||||
# fb/spidev force those legacy paths; none keeps the bus untouched.
|
||||
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
|
||||
# The main and cover panels share this backlight; 14 is the normal UI level.
|
||||
kernel_backlight_level = 14
|
||||
fb_device = /dev/fb1
|
||||
spidev_device = /dev/spidev0.1
|
||||
gpiochip_device = /dev/gpiochip0
|
||||
@@ -25,39 +31,33 @@ input_dir = /dev/input
|
||||
# GPIO offsets on MSM8909 TLMM (from the KaiOS downstream DTS)
|
||||
mux_gpio = 13
|
||||
reset_gpio = 23
|
||||
# gpio110 (the internal panel's DC line) is claimed exclusively by
|
||||
# panel-mipi-dbi-spi, so the daemon cannot request it through gpiochip0.
|
||||
# The gpio13 switch routes the shared DC/CS lines; -1 lets the spidev
|
||||
# backend open without fighting the kernel driver. Set this back to 110
|
||||
# only when the spi-mux kernel modules own both panels instead.
|
||||
# gpio110 is the shared D/C line owned by panel-mipi-dbi-spi; the daemon
|
||||
# cannot request it through gpiochip0. -1 lets the legacy spidev backend open
|
||||
# without fighting the kernel driver. Set it back to 110 only with a DT where
|
||||
# spi-mux owns both panels.
|
||||
dc_gpio = -1
|
||||
|
||||
# Closed-flip userspace GC9305 backend. gpio13 is held low by the boot chain
|
||||
# while the main panel is active, so low = internal, high = cover. The 240x240
|
||||
# panel has its own D/C (gpio21) and reset (gpio23) lines. All polarities are
|
||||
# config knobs for the physical sign-off: change them here, restart the
|
||||
# service, and use bananarchy-coverctl TEST bars with LID CLOSED.
|
||||
# Closed-flip kernel path. gpio13 is low while the main panel is active, so
|
||||
# high is assumed to select the cover. If the outer panel stays dark, run
|
||||
# bananarchy-coverctl SET mux_closed_level 0 while closed and press a button;
|
||||
# the runtime knob forces a fresh reset/init cycle.
|
||||
mux_open_level = 0
|
||||
mux_closed_level = 1
|
||||
reset_assert_level = 0
|
||||
reset_idle_level = 1
|
||||
|
||||
# Legacy userspace spidev rollback. gpio21 is TE in the stock DTS, not D/C;
|
||||
# these polarity/word-width knobs and PROBE are retained only for sign-off.
|
||||
spi_device = /dev/spidev0.1
|
||||
spi_mux_gpio = 13
|
||||
spi_dc_gpio = 21
|
||||
spi_reset_gpio = 23
|
||||
mux_open_level = 0
|
||||
mux_closed_level = 1
|
||||
dc_command_level = 0
|
||||
dc_data_level = 1
|
||||
reset_assert_level = 0
|
||||
reset_idle_level = 1
|
||||
# Keep the verified internal-panel clock on the shared bus.
|
||||
spi_speed_hz = 25000000
|
||||
# Legacy userspace spidev backend, retained as a rollback path. The KaiOS
|
||||
# downstream DTS labels gpio21 "TE" and Qualcomm MDSS SPI sends D/C as the
|
||||
# ninth bit, so the cover panel may be 8-bit (D/C on gpio21) or
|
||||
# 9-bit MIPI DBI (D/C in bit 8, no DC GPIO). 8 keeps the current wiring;
|
||||
# 9 releases gpio21 and sends every byte as a 9-bit word. Until the physical
|
||||
# sign-off is done, use "bananarchy-coverctl PROBE" repeatedly while the flip
|
||||
# is closed: it draws TEST bars and walks the polarity/word-bit/speed cases,
|
||||
# reporting the active one in STATUS as probe=case N/12. 9-bit is the default
|
||||
# because the vendor DTS has no external D/C GPIO; set 8 for the old wiring.
|
||||
# 9-bit MIPI DBI puts D/C in bit 8; 8-bit uses gpio21 as D/C. PROBE walks
|
||||
# twelve polarity/clock/word-width cases and switches the backend to spidev.
|
||||
spi_word_bits = 9
|
||||
|
||||
# Privacy defaults: no caller name, no notification body, no text in logs.
|
||||
@@ -70,6 +70,6 @@ brightness = 160
|
||||
# Follow Config -> Screen blank (~/.config/sxmo/idle_blank_timeout, default
|
||||
# 300 s, 0 = never). A numeric value here overrides it for the cover panel.
|
||||
blank_timeout = auto
|
||||
# Optional sysfs node for the external panel backlight. Empty: the daemon
|
||||
# writes an all-black frame and sends GC9305 display-off (0x28) instead.
|
||||
# Optional sysfs node for a separate legacy cover backlight. Empty on the
|
||||
# shipping image: the kernel backend uses kernel_backlight_path above.
|
||||
backlight_path =
|
||||
Binary file not shown.
@@ -1,41 +1,30 @@
|
||||
# Nokia 2720 Flip (nokia-beatles) 1.3-inch 240x240 external GC9305 panel.
|
||||
#
|
||||
# Derived from the KaiOS 3.10 downstream DTS in the archived postmarketOS
|
||||
# linux-nokia-beatles package (0004-dts-adaptations.patch):
|
||||
# spi_gc9305_v2_qvga_ext_cmd, qcom,mdss-spi-on-command:
|
||||
# fe, ef, 3a 05, 35 00, 2a 00 00 00 ef, 2b 00 00 00 ef, 2c,
|
||||
# delay 120, 11, 29, 2c
|
||||
# Exact qcom,mdss-spi-on-command stream from the KaiOS 3.10 downstream DTS
|
||||
# (spi_gc9305_v2_qvga_ext_cmd) in pmaports' 0004-dts-adaptations.patch:
|
||||
# fe, ef, 3a 05, 35 00, 2a 00 00 00 ef, 2b 00 00 00 ef, 2c,
|
||||
# delay 120, 11, 29, 2c
|
||||
# qcom,mdss-spi-panel-width = 240, height = 240, bpp = 16.
|
||||
#
|
||||
# The register/gamma block below is the one already proven on this device's
|
||||
# internal GC9305 panel (nokia,beatles-gc9305-panel.txt); the two column/page
|
||||
# windows are set to 0..239 for the square cover panel. The blob is consumed
|
||||
# by panel-mipi-dbi-spi (kernel) or by bananarchy-coverd's spidev backend.
|
||||
# The stock panel node uses qcom,platform-spi-dc-gpio = gpio110 (the same
|
||||
# D/C line as the internal panel), qcom,platform-te-gpio = gpio21,
|
||||
# qcom,platform-reset-gpio = gpio23 and qcom,platform-spi-switch-gpio =
|
||||
# gpio13. gpio21 is TE, not D/C. Both panels share PMIC MPP2 PWM backlight.
|
||||
#
|
||||
# This init sequence is derived from vendor sources but has NOT yet been
|
||||
# verified on 2720 Flip hardware; see NOKIA-2720-FLIP.md.
|
||||
|
||||
# This MIPI DBI firmware is replayed by the shipping kernel backend through
|
||||
# /sys/kernel/debug/dri/0/command after gpio23 is pulsed and the gpio13 bus
|
||||
# switch is set to the cover. The obsolete userspace spidev rollback also
|
||||
# parses this file.
|
||||
#
|
||||
# MIPI DBI firmware records below (command, parameter count, parameters):
|
||||
command 0xfe
|
||||
command 0xef
|
||||
command 0x36 0x00 # MADCTL
|
||||
command 0x3a 0x55 # 65K 16-bit RGB565
|
||||
command 0x3a 0x05 # 16-bit RGB565
|
||||
command 0x35 0x00 # TE v-blanking
|
||||
command 0xb2 0x0c 0x0c 0x00 0x33 0x33 # porch setting
|
||||
command 0xb7 0x75 # gate control VGH/VGL
|
||||
command 0xbb 0x34 # Vcoms
|
||||
command 0xc0 0x2c # LCM control
|
||||
command 0xc2 0x01 # VDV/VRH enable
|
||||
command 0xc3 0x0d # VRH set
|
||||
command 0xc4 0x20 # VDV set
|
||||
command 0xc6 0xef # frame rate
|
||||
command 0x44 0x00 0x00 # tearing scan line
|
||||
command 0xd0 0xa4 0xa1 # power control 1
|
||||
command 0xe0 0xd0 0x02 0x09 0x0d 0x0e 0x19 0x30 0x51 0x43 0x09 0x14 0x13 0x18 0x21
|
||||
command 0xe1 0xd0 0x02 0x09 0x0d 0x0d 0x18 0x32 0x46 0x42 0x09 0x13 0x13 0x17 0x21
|
||||
command 0x2a 0x00 0x00 0x00 0xef # column address 0..239
|
||||
command 0x2b 0x00 0x00 0x00 0xef # page address 0..239
|
||||
command 0x2c # memory write
|
||||
command 0x11 # sleep out
|
||||
delay 120
|
||||
command 0x11 # sleep out
|
||||
command 0x29 # display on
|
||||
command 0x2c
|
||||
command 0x2c # memory write
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Report the live state of the 2720 Flip external panel (closed-flip backend).
|
||||
# Intended for the physical gpio13/reset/DC sign-off: it never changes state.
|
||||
# Read-only: it never changes the mux, backlight, DPMS or panel state.
|
||||
set -u
|
||||
|
||||
FB=/dev/fb1
|
||||
@@ -8,6 +8,9 @@ SYSFS=/sys/class/graphics/fb1
|
||||
SPI=/dev/spidev0.1
|
||||
GPIOCHIP=/dev/gpiochip0
|
||||
FW=/lib/firmware/nokia,beatles-gc9305-ext-panel.bin
|
||||
CMD=/sys/kernel/debug/dri/0/command
|
||||
BL=/sys/class/backlight/backlight/brightness
|
||||
MARKER=/run/bananarchy/cover-backlight
|
||||
CONF=/etc/bananarchy/cover-display.conf
|
||||
COVERCTL=/usr/bin/bananarchy-coverctl
|
||||
|
||||
@@ -39,8 +42,15 @@ if [ -e "$GPIOCHIP" ]; then
|
||||
else
|
||||
printf 'gpiochip : %s MISSING\n' "$GPIOCHIP"
|
||||
fi
|
||||
if [ -w "$CMD" ]; then
|
||||
printf 'kernel command hook : %s writable\n' "$CMD"
|
||||
else
|
||||
printf 'kernel command hook : %s MISSING\n' "$CMD"
|
||||
fi
|
||||
printf 'DRM cards : %s\n' "$(ls /dev/dri/card* 2>/dev/null | tr '\n' ' ')"
|
||||
printf 'main panel dpms : %s\n' "$(cat /sys/class/drm/card0-SPI-1/dpms 2>/dev/null || printf 'unknown')"
|
||||
printf 'shared backlight : %s\n' "$(cat "$BL" 2>/dev/null || printf 'unknown')"
|
||||
printf 'cover backlight marker: %s\n' "$([ -f "$MARKER" ] && printf 'present' || printf 'absent')"
|
||||
printf 'main fbdev : %s\n' "$(cat /sys/class/graphics/fb0/virtual_size 2>/dev/null || printf 'absent')"
|
||||
printf 'fbdev nodes : %s\n' "$(ls /dev/fb* 2>/dev/null | tr '\n' ' ')"
|
||||
for mod in mux_core mux_gpio spi_mux panel_mipi_dbi spidev; do
|
||||
@@ -62,7 +72,7 @@ if [ -r /sys/kernel/debug/gpio ]; then
|
||||
fi
|
||||
if [ -r "$CONF" ]; then
|
||||
printf 'backend config :\n'
|
||||
grep -E '^(backend|main_fb_device|kernel_dpms_helper|spi_device|spi_mux_gpio|spi_dc_gpio|spi_reset_gpio|mux_open_level|mux_closed_level|dc_command_level|dc_data_level|reset_assert_level|reset_idle_level|spi_speed_hz|spi_word_bits) ' "$CONF" | sed 's/^/ /'
|
||||
grep -E '^(backend|main_fb_device|kernel_dpms_helper|kernel_command_path|kernel_backlight_path|kernel_backlight_marker|kernel_backlight_level|spi_device|spi_mux_gpio|spi_dc_gpio|spi_reset_gpio|mux_open_level|mux_closed_level|dc_command_level|dc_data_level|reset_assert_level|reset_idle_level|spi_speed_hz|spi_word_bits) ' "$CONF" | sed 's/^/ /'
|
||||
fi
|
||||
if [ -x "$COVERCTL" ]; then
|
||||
printf 'daemon : %s\n' "$("$COVERCTL" STATUS 2>/dev/null || printf 'not answering')"
|
||||
@@ -72,10 +82,8 @@ fi
|
||||
if command -v rc-service >/dev/null 2>&1; then
|
||||
rc-service bananarchy-cover-display status 2>&1 | sed 's/^/service : /'
|
||||
fi
|
||||
printf 'sign-off : bananarchy-cover-probe.sh (12 cases)\n'
|
||||
printf ' watch the cover, note STATUS probe=case N/12\n'
|
||||
printf ' bananarchy-coverctl SET mux_closed_level 0|1\n'
|
||||
printf ' bananarchy-coverctl SET reset_assert_level 0|1\n'
|
||||
printf ' bananarchy-coverctl SET dc_command_level 0|1\n'
|
||||
printf ' rollback: bananarchy-coverctl SET backend none\n'
|
||||
printf 'sign-off : close the flip, press an outer button\n'
|
||||
printf ' if the cover stays dark: SET mux_closed_level 0\n'
|
||||
printf ' legacy: bananarchy-cover-probe.sh (12 cases)\n'
|
||||
printf ' rollback: SET backend none\n'
|
||||
exit 0
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
# Replay the kernel panel-mipi-dbi-spi init sequence onto whichever GC9305 is
|
||||
# currently behind the gpio13 bus switch. A DPMS off/on cycle makes
|
||||
# mipi_dbi_enable() rerun the firmware command stack with CS0 and gpio110 D/C;
|
||||
# with the mux on the cover that initialises the 240x240 external panel.
|
||||
# Switch DRM DPMS for whichever GC9305 is behind the gpio13 bus switch.
|
||||
# The cover daemon sends the stock external init separately through the
|
||||
# panel-mipi-dbi-spi debugfs command hook; this helper only stops/restarts
|
||||
# Xorg's framebuffer flushes and the shared backlight power state.
|
||||
set -u
|
||||
export DISPLAY="${DISPLAY:-:0}"
|
||||
case "${1:-}" in
|
||||
@@ -18,8 +18,6 @@ case "${1:-}" in
|
||||
xset dpms force off >/dev/null 2>&1 || true
|
||||
;;
|
||||
*)
|
||||
printf 'Usage: %s [reinit|on|off]\n' "${0##*/}" >&2
|
||||
exit 1
|
||||
;;
|
||||
printf 'Usage: %s [reinit|on|off]\n' "${0##*/}" >&2; exit 1 ;;
|
||||
esac
|
||||
exit 0
|
||||
Binary file not shown.
@@ -4,7 +4,10 @@
|
||||
# (via doas). Every blank path writes brightness=0; every wake path restores it.
|
||||
|
||||
BR_PATH=/sys/class/backlight/backlight/brightness
|
||||
KBD_PATH=/sys/class/leds/white:kbd_backlight/brightness
|
||||
RL_PATH=/sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us
|
||||
COVER_MARKER=/run/bananarchy/cover-backlight
|
||||
LID_STATE=/run/bananarchy/lid-state
|
||||
|
||||
DPMS_PATH=
|
||||
for _dpms in /sys/class/drm/card*-*/dpms; do
|
||||
@@ -18,11 +21,21 @@ case "$br" in ''|*[!0-9]*) br=1 ;; esac
|
||||
cur=On
|
||||
[ -r "$DPMS_PATH" ] && { read -r cur < "$DPMS_PATH" 2>/dev/null || cur=On; }
|
||||
|
||||
# The main and cover panels share one PWM backlight. While the cover owns the
|
||||
# bus, its daemon publishes this marker before raising brightness; the closed
|
||||
# lid gate must not turn that shared backlight back off.
|
||||
if [ -f "$COVER_MARKER" ] &&
|
||||
[ "$(cat "$LID_STATE" 2>/dev/null)" = "closed" ]; then
|
||||
printf '0\n' > "$KBD_PATH" 2>/dev/null || true
|
||||
[ "$cur" = "On" ] || DISPLAY=:0 xset dpms force on >/dev/null 2>&1 || true
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 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
|
||||
printf '0\n' > "$KBD_PATH" 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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#define MAIN_BLANK_CFG "/home/user/.config/sxmo/idle_blank_timeout"
|
||||
#define DEFAULT_BLANK_SECS 300
|
||||
#define CLOCK_REDRAW_MS 30000
|
||||
#define KERNEL_REDRAW_MS 1000
|
||||
#define COVER_SPI_WIDTH 240
|
||||
#define COVER_SPI_HEIGHT 240
|
||||
#define COVER_SPI_CHUNK 2048
|
||||
@@ -140,7 +141,12 @@ struct cover_hw {
|
||||
char probe_desc[96];
|
||||
char kernel_fb[128];
|
||||
char kernel_dpms[128];
|
||||
char kernel_cmd[128];
|
||||
char kernel_bl[128];
|
||||
char kernel_marker[128];
|
||||
unsigned int kernel_bl_level;
|
||||
int kernel_lit;
|
||||
int kernel_owned;
|
||||
int sim;
|
||||
int spi_enabled;
|
||||
int fd_spi;
|
||||
@@ -355,6 +361,15 @@ static int write_all(int fd, const unsigned char *buffer, size_t length)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void write_cover_text(const char *path, const char *value)
|
||||
{
|
||||
int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
|
||||
if(fd < 0)
|
||||
return;
|
||||
(void)!write(fd, value, strlen(value));
|
||||
close(fd);
|
||||
}
|
||||
|
||||
struct state {
|
||||
char lid[16];
|
||||
char backend[16];
|
||||
@@ -834,12 +849,18 @@ static int cover_spi_draw(struct cover_hw *hw, const struct state *state)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void cover_kernel_release(struct cover_hw *hw);
|
||||
|
||||
/* On an open flip the daemon must not own the shared QUP5 bus at all. The
|
||||
* mux line stays claimed for the daemon's lifetime (so it is always driven
|
||||
* back to the internal panel), while the DC/reset handle is released. */
|
||||
static void cover_hw_release(struct cover_hw *hw)
|
||||
{
|
||||
unsigned char mux_value[1];
|
||||
if(hw->kernel_owned) {
|
||||
cover_kernel_release(hw);
|
||||
return;
|
||||
}
|
||||
if(!hw->mux_claimed)
|
||||
return;
|
||||
if(hw->initialized)
|
||||
@@ -857,6 +878,7 @@ static void cover_hw_release(struct cover_hw *hw)
|
||||
static void cover_hw_shutdown(struct cover_hw *hw)
|
||||
{
|
||||
cover_hw_release(hw);
|
||||
cover_kernel_release(hw);
|
||||
if(!hw->sim) {
|
||||
if(hw->fd_mux >= 0)
|
||||
close(hw->fd_mux);
|
||||
@@ -899,14 +921,14 @@ static int cover_main_panel_is_off(void)
|
||||
}
|
||||
|
||||
/* --- Kernel-owned cover path ----------------------------------------------
|
||||
* The external panel sits behind the gpio13 bus switch on the same QUP5 bus
|
||||
* as the internal panel. The kernel panel-mipi-dbi-spi driver owns CS0, the
|
||||
* shared gpio110 D/C line and the firmware init stream, so userspace cannot
|
||||
* drive the cover with its own D/C framing. Instead, while the flip is closed
|
||||
* we switch the mux to the cover, release its reset, force a DRM DPMS off/on
|
||||
* cycle (which makes the kernel driver replay its init sequence onto the panel
|
||||
* now on the bus) and render the cover UI into the main framebuffer. The main
|
||||
* backlight and keypad stay at 0, so only the outer panel can light up.
|
||||
* The KaiOS 3.10 DTS shows that both GC9305s share CS0, gpio110 D/C and the
|
||||
* PMIC MPP2 PWM backlight. gpio13 selects the panel, gpio23 is the external
|
||||
* reset, and gpio21 is TE (not D/C). The kernel panel-mipi-dbi-spi driver
|
||||
* owns CS0 and gpio110, so the cover is driven by the driver itself:
|
||||
* pulse gpio23, replay the stock 240x240 init through its debugfs command
|
||||
* hook, turn the shared backlight on and flush a 240x240 /dev/fb0 damage
|
||||
* rect. A marker lets bananarchy-display-power-sync leave that backlight on
|
||||
* while the lid is closed and the cover is lit.
|
||||
*/
|
||||
static void hw_dpms(struct cover_hw *hw, const char *mode)
|
||||
{
|
||||
@@ -924,6 +946,108 @@ static void hw_dpms(struct cover_hw *hw, const char *mode)
|
||||
}
|
||||
}
|
||||
|
||||
static int cover_kernel_command(struct cover_hw *hw, unsigned char cmd,
|
||||
const unsigned char *params,
|
||||
unsigned int count)
|
||||
{
|
||||
char line[256];
|
||||
char event[320];
|
||||
size_t used;
|
||||
unsigned int i;
|
||||
int flags = O_WRONLY | O_CLOEXEC;
|
||||
int fd;
|
||||
used = (size_t)snprintf(line, sizeof(line), "%02x", cmd);
|
||||
for(i = 0; i < count && used + 4 < sizeof(line); i++)
|
||||
used += (size_t)snprintf(line + used, sizeof(line) - used,
|
||||
" %02x", params[i]);
|
||||
snprintf(event, sizeof(event), "kernel cmd %s", line);
|
||||
hw_event(hw, event);
|
||||
if(hw->sim)
|
||||
flags |= O_TRUNC;
|
||||
fd = open(hw->kernel_cmd, flags);
|
||||
if(fd < 0)
|
||||
return hw->sim;
|
||||
if(!write_all(fd, (const unsigned char *)line, strlen(line))) {
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cover_kernel_replay_firmware(struct cover_hw *hw)
|
||||
{
|
||||
unsigned char buf[256];
|
||||
size_t len;
|
||||
size_t i = 16;
|
||||
FILE *handle = fopen(hw->firmware, "rb");
|
||||
if(!handle)
|
||||
return 0;
|
||||
len = fread(buf, 1, sizeof(buf), handle);
|
||||
fclose(handle);
|
||||
if(len < 18 || memcmp(buf, "MIPI DBI", 8) != 0 || buf[15] != 1)
|
||||
return 0;
|
||||
while(i + 1 < len) {
|
||||
unsigned char cmd = buf[i++];
|
||||
unsigned char count = buf[i++];
|
||||
if(i + count > len)
|
||||
return 0;
|
||||
if(cmd == 0x00 && count == 1) {
|
||||
char line[64];
|
||||
snprintf(line, sizeof(line), "kernel delay %u",
|
||||
(unsigned int)buf[i]);
|
||||
hw_event(hw, line);
|
||||
if(!hw->sim)
|
||||
poll(NULL, 0, (int)buf[i]);
|
||||
} else if(!cover_kernel_command(hw, cmd, buf + i, count)) {
|
||||
return 0;
|
||||
}
|
||||
i += count;
|
||||
}
|
||||
return i == len;
|
||||
}
|
||||
|
||||
static void cover_kernel_reset(struct cover_hw *hw)
|
||||
{
|
||||
unsigned char values[2];
|
||||
values[0] = (unsigned char)hw->mux_closed_level;
|
||||
values[1] = (unsigned char)hw->reset_idle_level;
|
||||
hw_gpio_set(hw, hw->fd_mux, values, 2);
|
||||
if(!hw->sim)
|
||||
poll(NULL, 0, 1);
|
||||
values[1] = (unsigned char)hw->reset_assert_level;
|
||||
hw_gpio_set(hw, hw->fd_mux, values, 2);
|
||||
if(!hw->sim)
|
||||
poll(NULL, 0, 10);
|
||||
values[1] = (unsigned char)hw->reset_idle_level;
|
||||
hw_gpio_set(hw, hw->fd_mux, values, 2);
|
||||
if(!hw->sim)
|
||||
poll(NULL, 0, 10);
|
||||
hw_event(hw, "kernel reset");
|
||||
}
|
||||
|
||||
static void cover_kernel_backlight(struct cover_hw *hw, int on)
|
||||
{
|
||||
char value[32];
|
||||
char line[64];
|
||||
unsigned int level = on ? hw->kernel_bl_level : 0;
|
||||
/* Publish the marker before changing brightness: the backlight uevent runs
|
||||
* bananarchy-display-power-sync, which must not force the cover dark. */
|
||||
if(on)
|
||||
write_cover_text(hw->kernel_marker, "1");
|
||||
else
|
||||
unlink(hw->kernel_marker);
|
||||
snprintf(value, sizeof(value), "%u", level);
|
||||
write_cover_text(hw->kernel_bl, value);
|
||||
snprintf(line, sizeof(line), "kernel backlight %u", level);
|
||||
hw_event(hw, line);
|
||||
}
|
||||
|
||||
static void cover_kernel_display_off(struct cover_hw *hw)
|
||||
{
|
||||
cover_kernel_command(hw, 0x28, NULL, 0);
|
||||
}
|
||||
|
||||
static int cover_kernel_claim(struct cover_hw *hw)
|
||||
{
|
||||
unsigned int offsets[2];
|
||||
@@ -941,6 +1065,7 @@ static int cover_kernel_claim(struct cover_hw *hw)
|
||||
return 0;
|
||||
hw->fd_mux = fd;
|
||||
hw->mux_claimed = 1;
|
||||
hw->kernel_owned = 1;
|
||||
values[0] = (unsigned char)hw->mux_closed_level;
|
||||
values[1] = (unsigned char)hw->reset_idle_level;
|
||||
return hw_gpio_set(hw, hw->fd_mux, values, 2);
|
||||
@@ -949,12 +1074,9 @@ static int cover_kernel_claim(struct cover_hw *hw)
|
||||
static void cover_kernel_release(struct cover_hw *hw)
|
||||
{
|
||||
unsigned char values[2];
|
||||
/* The spidev backend owns fd_mux too; only the kernel backend may release
|
||||
* it here, or its STATUS would lose the restored mux state. */
|
||||
if(strcmp(hw->backend, "kernel") != 0)
|
||||
return;
|
||||
if(!hw->mux_claimed)
|
||||
if(!hw->kernel_owned)
|
||||
return;
|
||||
cover_kernel_backlight(hw, 0);
|
||||
values[0] = (unsigned char)hw->mux_open_level;
|
||||
values[1] = (unsigned char)hw->reset_idle_level;
|
||||
hw_gpio_set(hw, hw->fd_mux, values, 2);
|
||||
@@ -963,9 +1085,25 @@ static void cover_kernel_release(struct cover_hw *hw)
|
||||
close(hw->fd_mux);
|
||||
hw->fd_mux = -1;
|
||||
hw->mux_claimed = 0;
|
||||
hw->kernel_owned = 0;
|
||||
hw->kernel_lit = -1;
|
||||
}
|
||||
|
||||
static void cover_bus_release(struct cover_hw *hw)
|
||||
{
|
||||
if(hw->kernel_owned) {
|
||||
cover_kernel_release(hw);
|
||||
return;
|
||||
}
|
||||
if(!hw->mux_claimed)
|
||||
return;
|
||||
cover_hw_release(hw);
|
||||
if(!hw->sim && hw->fd_mux >= 0)
|
||||
close(hw->fd_mux);
|
||||
hw->fd_mux = -1;
|
||||
hw->mux_claimed = 0;
|
||||
}
|
||||
|
||||
static int cover_kernel_frame(struct cover_hw *hw, const struct state *state)
|
||||
{
|
||||
unsigned int width = COVER_SPI_WIDTH;
|
||||
@@ -1024,8 +1162,17 @@ static const char *cover_kernel_draw(struct cover_hw *hw,
|
||||
hw_dpms(hw, "reinit");
|
||||
if(!hw->sim)
|
||||
poll(NULL, 0, 180);
|
||||
cover_kernel_reset(hw);
|
||||
if(!cover_kernel_replay_firmware(hw))
|
||||
return "none";
|
||||
cover_kernel_backlight(hw, 1);
|
||||
if(!hw->sim)
|
||||
poll(NULL, 0, 50);
|
||||
} else {
|
||||
if(hw->kernel_lit > 0)
|
||||
cover_kernel_display_off(hw);
|
||||
hw_dpms(hw, "off");
|
||||
cover_kernel_backlight(hw, 0);
|
||||
}
|
||||
hw->kernel_lit = lit;
|
||||
}
|
||||
@@ -1034,28 +1181,6 @@ static const char *cover_kernel_draw(struct cover_hw *hw,
|
||||
return lit ? "kernel" : "kernel-dark";
|
||||
}
|
||||
|
||||
/* The kernel backend keeps DPMS ON while the cover is lit (that is how the
|
||||
* DRM driver flushes to it), so its safety condition is the main backlight
|
||||
* being dark, not DPMS. */
|
||||
static int cover_main_backlight_is_off(void)
|
||||
{
|
||||
const char *path = getenv("BANANARCHY_COVER_BL_PATH");
|
||||
char buf[32];
|
||||
ssize_t got;
|
||||
int fd;
|
||||
if(!path || !*path)
|
||||
path = "/sys/class/backlight/backlight/brightness";
|
||||
fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||
if(fd < 0)
|
||||
return 1;
|
||||
got = read(fd, buf, sizeof(buf) - 1);
|
||||
close(fd);
|
||||
if(got <= 0)
|
||||
return 1;
|
||||
buf[got] = '\0';
|
||||
return atoi(buf) == 0;
|
||||
}
|
||||
|
||||
static const char *cover_draw(struct cover_hw *hw, const char *fb_path,
|
||||
const struct state *state)
|
||||
{
|
||||
@@ -1071,12 +1196,17 @@ static const char *cover_draw(struct cover_hw *hw, const char *fb_path,
|
||||
return "idle";
|
||||
}
|
||||
if(strcmp(hw->backend, "none") == 0) {
|
||||
cover_hw_release(hw);
|
||||
cover_kernel_release(hw);
|
||||
cover_bus_release(hw);
|
||||
return "none";
|
||||
}
|
||||
if(strcmp(hw->backend, "kernel") == 0) {
|
||||
if(!cover_main_backlight_is_off()) {
|
||||
/* A runtime backend switch must hand over the spidev linehandle first. */
|
||||
if(hw->mux_claimed && !hw->kernel_owned)
|
||||
cover_bus_release(hw);
|
||||
/* Take the shared bus only after the lid daemon has stopped Xorg's
|
||||
* main-panel flushes. Once the cover owns it, DPMS is intentionally On
|
||||
* so the kernel driver can send frames. */
|
||||
if(hw->kernel_lit < 0 && !cover_main_panel_is_off()) {
|
||||
cover_kernel_release(hw);
|
||||
return "pending";
|
||||
}
|
||||
@@ -1181,9 +1311,20 @@ static void cover_hw_init(struct cover_hw *hw)
|
||||
hw->panel_lines = 1;
|
||||
hw->probe_index = -1;
|
||||
hw->kernel_lit = -1;
|
||||
safe_copy(hw->spi_path, sizeof(hw->spi_path), "/dev/spidev0.1");
|
||||
safe_copy(hw->gpio_path, sizeof(hw->gpio_path), "/dev/gpiochip0");
|
||||
safe_copy(hw->firmware, sizeof(hw->firmware),
|
||||
"/lib/firmware/nokia,beatles-gc9305-ext-panel.bin");
|
||||
safe_copy(hw->kernel_fb, sizeof(hw->kernel_fb), "/dev/fb0");
|
||||
safe_copy(hw->kernel_dpms, sizeof(hw->kernel_dpms),
|
||||
"/usr/bin/bananarchy-cover-dpms.sh");
|
||||
safe_copy(hw->kernel_cmd, sizeof(hw->kernel_cmd),
|
||||
"/sys/kernel/debug/dri/0/command");
|
||||
safe_copy(hw->kernel_bl, sizeof(hw->kernel_bl),
|
||||
"/sys/class/backlight/backlight/brightness");
|
||||
safe_copy(hw->kernel_marker, sizeof(hw->kernel_marker),
|
||||
"/run/bananarchy/cover-backlight");
|
||||
hw->kernel_bl_level = 14;
|
||||
safe_copy(hw->probe_desc, sizeof(hw->probe_desc), "none");
|
||||
hw->fd_spi = -1;
|
||||
hw->fd_chip = -1;
|
||||
@@ -1193,10 +1334,25 @@ static void cover_hw_init(struct cover_hw *hw)
|
||||
{
|
||||
const char *fb = getenv("BANANARCHY_COVER_MAIN_FB");
|
||||
const char *dp = getenv("BANANARCHY_COVER_DPMS_HELPER");
|
||||
const char *cmd = getenv("BANANARCHY_COVER_KERNEL_CMD");
|
||||
const char *bl = getenv("BANANARCHY_COVER_KERNEL_BL");
|
||||
const char *marker = getenv("BANANARCHY_COVER_KERNEL_MARKER");
|
||||
const char *level = getenv("BANANARCHY_COVER_KERNEL_BL_LEVEL");
|
||||
if(fb && *fb)
|
||||
safe_copy(hw->kernel_fb, sizeof(hw->kernel_fb), fb);
|
||||
if(dp && *dp)
|
||||
safe_copy(hw->kernel_dpms, sizeof(hw->kernel_dpms), dp);
|
||||
if(cmd && *cmd)
|
||||
safe_copy(hw->kernel_cmd, sizeof(hw->kernel_cmd), cmd);
|
||||
if(bl && *bl)
|
||||
safe_copy(hw->kernel_bl, sizeof(hw->kernel_bl), bl);
|
||||
if(marker && *marker)
|
||||
safe_copy(hw->kernel_marker, sizeof(hw->kernel_marker), marker);
|
||||
if(level && *level) {
|
||||
unsigned long parsed = strtoul(level, NULL, 10);
|
||||
if(parsed > 0 && parsed <= 255)
|
||||
hw->kernel_bl_level = (unsigned int)parsed;
|
||||
}
|
||||
}
|
||||
sim = getenv("BANANARCHY_COVER_SPI_SIM");
|
||||
if(sim && *sim) {
|
||||
@@ -1261,6 +1417,17 @@ static void read_config(const char *path, char *socket_path, size_t splen,
|
||||
safe_copy(hw->kernel_fb, sizeof(hw->kernel_fb), value);
|
||||
else if(strcmp(key, "kernel_dpms_helper") == 0)
|
||||
safe_copy(hw->kernel_dpms, sizeof(hw->kernel_dpms), value);
|
||||
else if(strcmp(key, "kernel_command_path") == 0)
|
||||
safe_copy(hw->kernel_cmd, sizeof(hw->kernel_cmd), value);
|
||||
else if(strcmp(key, "kernel_backlight_path") == 0)
|
||||
safe_copy(hw->kernel_bl, sizeof(hw->kernel_bl), value);
|
||||
else if(strcmp(key, "kernel_backlight_marker") == 0)
|
||||
safe_copy(hw->kernel_marker, sizeof(hw->kernel_marker), value);
|
||||
else if(strcmp(key, "kernel_backlight_level") == 0) {
|
||||
v = strtol(value, NULL, 10);
|
||||
if(v > 0 && v <= 255)
|
||||
hw->kernel_bl_level = (unsigned int)v;
|
||||
}
|
||||
else if(strcmp(key, "gpiochip_device") == 0)
|
||||
safe_copy(hw->gpio_path, sizeof(hw->gpio_path), value);
|
||||
else if(strcmp(key, "panel_firmware") == 0)
|
||||
@@ -1455,9 +1622,15 @@ static void handle_command(char *buffer, struct state *state,
|
||||
hw->word_bits = (int)bits;
|
||||
else
|
||||
return;
|
||||
} else if(strcmp(key, "kernel_backlight_level") == 0) {
|
||||
long level = strtol(value, NULL, 10);
|
||||
if(level > 0 && level <= 255)
|
||||
hw->kernel_bl_level = (unsigned int)level;
|
||||
else
|
||||
return;
|
||||
} else
|
||||
return;
|
||||
cover_hw_release(hw);
|
||||
cover_bus_release(hw);
|
||||
*redraw = 1;
|
||||
} else if(strcmp(command, "PROBE") == 0) {
|
||||
const struct probe_case *p;
|
||||
@@ -1477,7 +1650,11 @@ static void handle_command(char *buffer, struct state *state,
|
||||
hw->probe_index + 1,
|
||||
(int)(sizeof(probe_cases) / sizeof(probe_cases[0])),
|
||||
p->bits, p->mux, p->reset, p->dc, p->speed);
|
||||
cover_hw_release(hw);
|
||||
/* PROBE is the legacy userspace sign-off path; it owns its own D/C. */
|
||||
safe_copy(hw->backend, sizeof(hw->backend), "spidev");
|
||||
hw->spi_enabled = hw->spi_path[0] && hw->gpio_path[0] &&
|
||||
hw->firmware[0];
|
||||
cover_bus_release(hw);
|
||||
state->test = 2;
|
||||
state->visible = 1;
|
||||
state->last_input_ms = now_ms();
|
||||
@@ -1595,7 +1772,9 @@ int main(int argc, char **argv)
|
||||
/* With the cover off there is no timer at all: poll blocks until IPC. */
|
||||
int timeout_ms = -1;
|
||||
if(state.visible) {
|
||||
long long next = CLOCK_REDRAW_MS - (now - last_draw);
|
||||
long long interval = strcmp(hw.backend, "kernel") == 0 ?
|
||||
KERNEL_REDRAW_MS : CLOCK_REDRAW_MS;
|
||||
long long next = interval - (now - last_draw);
|
||||
if(next < 1)
|
||||
next = 1;
|
||||
if(state.blank_ms > 0) {
|
||||
@@ -1608,7 +1787,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
timeout_ms = (int)(next > 1000000 ? 1000000 : next);
|
||||
if(state.visible && now - last_draw >= CLOCK_REDRAW_MS)
|
||||
if(state.visible && now - last_draw >= interval)
|
||||
redraw = 1;
|
||||
}
|
||||
if(redraw) {
|
||||
|
||||
@@ -214,14 +214,16 @@ static void on_transition(int closed)
|
||||
* the DPMS re-init below hits the internal panel, not the cover. */
|
||||
cover_send("OPEN");
|
||||
poll(NULL, 0, 80);
|
||||
unlink(LOCK_FLAG);
|
||||
write_session_file(state, "unlock");
|
||||
/* Closing the flip locks the desktop. Opening only wakes the panel into
|
||||
* the visible passcode lockscreen; it must not auto-unlock. */
|
||||
write_session_file(LOCK_FLAG, "1");
|
||||
write_session_file(state, "lock");
|
||||
write_text_file(BL_POWER, "0");
|
||||
write_sysfs_int(BRIGHTNESS, bl);
|
||||
write_sysfs_int(KBD_BACKLIGHT, kbd);
|
||||
run_dpms("reinit");
|
||||
locker_send("CLOSE\n");
|
||||
run_sxmo_state("unlock", "open");
|
||||
locker_send("LOCK\n");
|
||||
run_sxmo_state("lock", "open");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1096,7 +1096,7 @@ int locker_run_main(int argc, char** argv) {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// A trusted root lid daemon clears the lock flag before sending CLOSE.
|
||||
// A trusted unlock path removes the lock flag before sending CLOSE.
|
||||
// If the flag is gone, release any stale locker grab/window immediately;
|
||||
// otherwise ignore CLOSE so user scripts cannot dismiss the lockscreen.
|
||||
if(cmd == "CLOSE" || cmd == "UNLOCK") {
|
||||
|
||||
Reference in new issue
Block a user