Handle active-low cover backlight and restore internal panel
This commit is contained in:
1 parent
b389120328
commit
d61f2848db
11 files changed
+412
-106
No files matched your search
@@ -77,16 +77,20 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
|
||||
**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.
|
||||
external reset. The shared PWM is active-low for the cover and active-high for the main panel: duty 0 lights the
|
||||
cover, duty 14 lights the internal panel. Keep the exact vendor external init firmware, the debugfs command replay,
|
||||
the gpio23 reset pulse, `/run/bananarchy/cover-backlight` (`1` = cover lit, `0` = cover dark),
|
||||
`kernel_power_sync_helper` and the `/run/bananarchy/cover-bl-force` nested-udev guard. On open, restore
|
||||
gpio13 low, duty 14, `bl_power=0`, DPMS On and re-init the internal panel. The legacy 8-bit/9-bit userspace paths, `PROBE` and `bananarchy-cover-probe.sh` remain
|
||||
rollback/sign-off tooling. `SET mux_closed_level 0` selects the internal panel, not the cover; use
|
||||
`SET kernel_backlight_invert 0|1` only if a unit's backlight polarity differs.
|
||||
- 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`: 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.
|
||||
the 240x240 `/dev/fb0` damage rect, the 1 s repaint against Xorg, `kernel_backlight_invert = 1`,
|
||||
`kernel_backlight_level = 14`, `scripts/test-cover-kernel.py`, and the `spidev`/`fb`/`none` rollback backends.
|
||||
The daemon must restore the internal panel on `LID OPEN` even after a stale high gpio13 survives a restart.
|
||||
- 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`. Closing locks
|
||||
the desktop; opening must keep the lock flag and wake to the passcode lockscreen, never auto-unlock. Every
|
||||
|
||||
+9
-1
@@ -13,13 +13,21 @@ 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.
|
||||
|
||||
### Active-low cover backlight and reliable internal-panel handover
|
||||
|
||||
- **Root cause**: eyes-on testing confirmed the outer display lights only with PWM **duty 0** while gpio13 selects the cover; the main panel uses the same PMIC PWM with the opposite polarity and needs duty 14. Leaving the cover daemon frozen with duty 0 and gpio13 high made the outer display work but left the internal panel all-white, and a daemon restart could leave gpio13 latched high because the fresh process had no linehandle to drive low. `SET mux_closed_level 0` selects the internal panel, not the cover.
|
||||
- **Switch**: `kernel_backlight_invert = 1`, `kernel_backlight_level = 14`, `kernel_backlight_power_path` and `kernel_power_sync_helper` are shipped. `/run/bananarchy/cover-backlight` contains `1` while the cover is lit (duty 0, `bl_power=0`, DPMS On) and `0` while the cover owns the bus but is dark (duty 14, `bl_power=0`, DPMS On). `bananarchy-display-power-sync` reads that marker and the invert/level keys, uses `/run/bananarchy/cover-bl-force` to suppress nested udev events during a forced two-step PWM update, and is also invoked directly by the daemon after marker changes. `cover_kernel_restore_internal()` explicitly drives gpio13 low, removes the marker, restores duty 14, `bl_power=0`, DPMS On and re-initialises the internal panel on `LID OPEN`, even after a stale high mux survives a daemon restart. `SET kernel_backlight_invert 0|1` remains a runtime rollback knob.
|
||||
- **Guards**: `scripts/test-cover-kernel.py` now checks the dark/lit marker contents, the active-low duty, the OFF duty on blank, normal brightness on open, mux restore, 1 s repaint and the DPMS gate. `scripts/check-rebuild.sh` guards the new config keys, source functions and the active-low display-power-sync paths. README, MANUAL and `AGENTS.md` document the polarity and handover.
|
||||
- **Live verification**: the user confirmed the outer display works with duty 0. The restore sequence returned the phone to `lid=open`, `state=unlock`, brightness 14, `bl_power=0`, DPMS On and all services started; a separate gpio13 probe drove the latched mux low. The rebuilt ARM daemon, config and scripts were deployed and the closed→lit→blank→open sequence was rechecked: cover lit showed `marker=1`, `br=0`, external TE toggles, 1382586 extra `spi0.0` bytes and zero SPI errors; cover dark showed `marker=0`; `LID OPEN` removed the marker and restored gpio13 low; the final open state showed `br=14`, `bl_power=0`, DPMS On, PWM duty 100000 ns, `l17/l6` enabled and a non-white `/dev/fb0` (0 white bytes, mean 20.7). `e2fsck -fn` passed on both partitions; `debugfs` confirms all rebuilt artifacts byte-for-byte; bootfs sync, boot image check, artifact sync, six host tests and `check-rebuild.sh` pass. The standalone boot image hash is unchanged. Eyes-on confirmation of both screens after this final deployment is still pending.
|
||||
- **Image persistence**: rebuilt `images/bananarchy-nokia-beatles.img` at `a1108` / `dejavu`; verified raw hash `3fc34741cbe9a2e68ab77e7133393bd7f93c7fec1c938680405760e8d02dfa08`, pinned by `scripts/check-rebuild.sh`.
|
||||
|
||||
### 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.
|
||||
- **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 Superseded by the active-low backlight rebuild below.
|
||||
|
||||
### Kernel-owned cover panel path (option b)
|
||||
|
||||
|
||||
@@ -456,7 +456,7 @@ Three native X11 games (`/usr/bin/snake`, `/usr/bin/tetris`, and `/usr/bin/scoun
|
||||
- **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` 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.
|
||||
- **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 gpio13 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`, and flushes a 240x240 `/dev/fb0` damage rect once per second. The shared PWM is active-low for the cover and active-high for the main panel: duty 0 lights the cover, duty 14 lights the internal panel. `/run/bananarchy/cover-backlight` contains `1` while the cover is lit and `0` while the cover owns the bus but is dark; `bananarchy-display-power-sync` holds the matching brightness, `bl_power` and DPMS state. `STATUS` reports `backend=kernel`, `mux=cover`; `BLANK` sends display-off and returns the external backlight to its OFF duty; `LID OPEN` restores gpio13 low, duty 14, `bl_power=0`, DPMS On 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`, `SET kernel_backlight_invert 0|1` and `SET backend none` paths remain for rollback. `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).
|
||||
|
||||
@@ -50,7 +50,7 @@ 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 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.
|
||||
- **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 gpio13 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, and flushes a 240x240 `/dev/fb0` damage rect once per second so Xorg repaints cannot erase it. The shared PWM is **active-low for the cover and active-high for the main panel**: duty 0 lights the cover, duty 14 lights the internal panel. `/run/bananarchy/cover-backlight` contains `1` while the cover is lit and `0` while the cover owns the bus but is dark; `bananarchy-display-power-sync` uses it to hold the correct duty and DPMS state instead of forcing brightness 0. The keypad stays dark. Opening the flip restores gpio13 low, duty 14, `bl_power=0`, DPMS On and the internal panel. `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; `SET kernel_backlight_invert 0|1` switches the active-low assumption if a unit differs. `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.
|
||||
|
||||
- **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.
|
||||
|
||||
@@ -7,19 +7,26 @@
|
||||
# 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.
|
||||
# 240x240 init through the kernel driver's debugfs command hook, and flushes a
|
||||
# 240x240 /dev/fb0 damage rect. Live probing showed the shared PWM is
|
||||
# active-low for the cover and active-high for the main panel: duty 0 lights
|
||||
# the cover, duty 14 lights the internal panel. The marker tells
|
||||
# bananarchy-display-power-sync which side owns the bus. Opening the flip
|
||||
# restores the mux, normal brightness and the internal 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_power_sync_helper = /usr/bin/bananarchy-display-power-sync
|
||||
kernel_command_path = /sys/kernel/debug/dri/0/command
|
||||
kernel_backlight_path = /sys/class/backlight/backlight/brightness
|
||||
kernel_backlight_power_path = /sys/class/backlight/backlight/bl_power
|
||||
kernel_backlight_marker = /run/bananarchy/cover-backlight
|
||||
# The main and cover panels share this backlight; 14 is the normal UI level.
|
||||
# 14 is the normal internal-panel level and also the external-panel OFF duty.
|
||||
kernel_backlight_level = 14
|
||||
# 1 = external backlight active-low (duty 0 ON), 0 = active-high.
|
||||
kernel_backlight_invert = 1
|
||||
fb_device = /dev/fb1
|
||||
spidev_device = /dev/spidev0.1
|
||||
gpiochip_device = /dev/gpiochip0
|
||||
|
||||
Binary file not shown.
@@ -1,54 +1,130 @@
|
||||
#!/bin/sh
|
||||
# Keep DRM DPMS and the schedutil rate limit in sync with the backlight state.
|
||||
# Invoked by the backlight udev rule (as root) and by sxmo_wm.sh display on
|
||||
# (via doas). Every blank path writes brightness=0; every wake path restores it.
|
||||
# (via doas). The 2720 Flip shares one PWM backlight between both panels:
|
||||
# it is active-low for the cover and active-high for the main panel.
|
||||
set -u
|
||||
|
||||
BR_PATH=/sys/class/backlight/backlight/brightness
|
||||
BL_POWER_PATH=/sys/class/backlight/backlight/bl_power
|
||||
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
|
||||
FORCE_MARKER=/run/bananarchy/cover-bl-force
|
||||
LID_STATE=/run/bananarchy/lid-state
|
||||
CONF=/etc/bananarchy/cover-display.conf
|
||||
COVER_BL_LEVEL=14
|
||||
COVER_BL_INVERT=1
|
||||
|
||||
# A forced PWM update rewrites brightness/bl_power itself. Ignore the nested
|
||||
# udev events so the two-step update cannot recurse.
|
||||
if [ -f "$FORCE_MARKER" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -r "$CONF" ]; then
|
||||
_level=$(awk -F= '/^[[:space:]]*kernel_backlight_level[[:space:]]*=/ {gsub(/[[:space:]]/, "", $2); print $2; exit}' "$CONF" 2>/dev/null)
|
||||
case "${_level:-}" in ''|*[!0-9]*) ;; *) COVER_BL_LEVEL="$_level" ;; esac
|
||||
_invert=$(awk -F= '/^[[:space:]]*kernel_backlight_invert[[:space:]]*=/ {gsub(/[[:space:]]/, "", $2); print $2; exit}' "$CONF" 2>/dev/null)
|
||||
case "${_invert:-}" in 0|1) COVER_BL_INVERT="$_invert" ;; esac
|
||||
fi
|
||||
|
||||
DPMS_PATH=
|
||||
for _dpms in /sys/class/drm/card*-*/dpms; do
|
||||
[ -r "$_dpms" ] && DPMS_PATH="$_dpms" && break
|
||||
done
|
||||
|
||||
br=1
|
||||
[ -r "$BR_PATH" ] && { read -r br < "$BR_PATH" 2>/dev/null || br=1; }
|
||||
read_value() {
|
||||
_path="$1"
|
||||
_value=""
|
||||
[ -r "$_path" ] && { read -r _value < "$_path" 2>/dev/null || _value=""; }
|
||||
printf '%s' "$_value"
|
||||
}
|
||||
|
||||
set_if_changed() {
|
||||
_path="$1"
|
||||
_want="$2"
|
||||
_cur="$(read_value "$_path")"
|
||||
[ "$_cur" = "$_want" ] || printf '%s\n' "$_want" > "$_path" 2>/dev/null || true
|
||||
}
|
||||
|
||||
force_backlight() {
|
||||
_want_br="$1"
|
||||
_want_blp="$2"
|
||||
printf '1\n' > "$FORCE_MARKER" 2>/dev/null || true
|
||||
set_if_changed "$BL_POWER_PATH" "4"
|
||||
printf '%s\n' "$_want_br" > "$BR_PATH" 2>/dev/null || true
|
||||
set_if_changed "$BL_POWER_PATH" "$_want_blp"
|
||||
printf '%s\n' "$_want_br" > "$BR_PATH" 2>/dev/null || true
|
||||
rm -f "$FORCE_MARKER" 2>/dev/null || true
|
||||
}
|
||||
|
||||
force_dpms() {
|
||||
_want="$1"
|
||||
_cur="$(read_value "$DPMS_PATH")"
|
||||
[ "$_cur" = "$_want" ] && return 0
|
||||
_mode="$(printf '%s' "$_want" | tr 'A-Z' 'a-z')"
|
||||
DISPLAY=:0 xset dpms force "$_mode" >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
br="$(read_value "$BR_PATH")"
|
||||
case "$br" in ''|*[!0-9]*) br=1 ;; esac
|
||||
lid="$(read_value "$LID_STATE")"
|
||||
marker=""
|
||||
[ -r "$COVER_MARKER" ] && marker="$(read_value "$COVER_MARKER")"
|
||||
|
||||
cur=On
|
||||
[ -r "$DPMS_PATH" ] && { read -r cur < "$DPMS_PATH" 2>/dev/null || cur=On; }
|
||||
if [ "$COVER_BL_INVERT" -eq 1 ]; then
|
||||
LIT_BR=0
|
||||
DARK_BR="$COVER_BL_LEVEL"
|
||||
DARK_BLP=0
|
||||
else
|
||||
LIT_BR="$COVER_BL_LEVEL"
|
||||
DARK_BR=0
|
||||
DARK_BLP=4
|
||||
fi
|
||||
|
||||
# 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
|
||||
# An open flip always wins: remove a stale cover marker and restore the
|
||||
# active-high internal-panel backlight before applying normal DPMS rules.
|
||||
if [ "$lid" = "open" ]; then
|
||||
rm -f "$COVER_MARKER" 2>/dev/null || true
|
||||
force_backlight "$COVER_BL_LEVEL" "0"
|
||||
force_dpms "On"
|
||||
if [ -w "$RL_PATH" ]; then
|
||||
printf '40000\n' > "$RL_PATH" 2>/dev/null || true
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# While the cover owns the bus, the marker content selects its state:
|
||||
# 1 = cover lit, 0 = cover dark. Never let the closed-lid hard gate force
|
||||
# brightness 0 here, because that would turn the active-low cover backlight on.
|
||||
if [ -f "$COVER_MARKER" ]; then
|
||||
set_if_changed "$KBD_PATH" "0"
|
||||
if [ "$marker" = "1" ]; then
|
||||
force_backlight "$LIT_BR" "0"
|
||||
force_dpms "On"
|
||||
else
|
||||
force_backlight "$DARK_BR" "$DARK_BLP"
|
||||
force_dpms "On"
|
||||
fi
|
||||
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.
|
||||
# the keypad backlight. The cover daemon keeps gpio13 low in this state.
|
||||
if ! "${BANANARCHY_LID_GATE:-/usr/bin/bananarchy-lid-gate.sh}"; then
|
||||
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
|
||||
set_if_changed "$KBD_PATH" "0"
|
||||
force_backlight "0" "4"
|
||||
force_dpms "Off"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$br" -eq 0 ]; then
|
||||
[ "$cur" = "Off" ] || DISPLAY=:0 xset dpms force off >/dev/null 2>&1 || true
|
||||
force_dpms "Off"
|
||||
else
|
||||
[ "$cur" = "On" ] || DISPLAY=:0 xset dpms force on >/dev/null 2>&1 || true
|
||||
force_dpms "On"
|
||||
fi
|
||||
|
||||
# Switching scaling_governor away from schedutil and back recreates this
|
||||
# kobject with the 6.44 s default, so re-apply the 40 ms value on every wake.
|
||||
if [ "$br" -ne 0 ] && [ -w "$RL_PATH" ]; then
|
||||
printf '40000\n' > "$RL_PATH" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
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" \
|
||||
"e2ec6a35d1e7db698f929fa0ebdbed94ffd941a55fc50ceff7a223e82896e985 images/bananarchy-nokia-beatles.img" \
|
||||
"3fc34741cbe9a2e68ab77e7133393bd7f93c7fec1c938680405760e8d02dfa08 images/bananarchy-nokia-beatles.img" \
|
||||
"2b5c61aba307dbbda61f3b19a2ad5770f9854f41cba4e2c97e24efb7e20879f3 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
|
||||
set -- $pair
|
||||
@@ -928,8 +928,11 @@ if [ ! -x "$LID_GATE" ] || ! sh -n "$LID_GATE" 2>/dev/null; then
|
||||
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 'kernel_backlight_invert' "$DPMS_SYNC" || \
|
||||
! grep -qF 'force_backlight' "$DPMS_SYNC" || \
|
||||
! grep -qF 'LIT_BR=0' "$DPMS_SYNC" || \
|
||||
! grep -qF 'exit 0' "$DPMS_SYNC"; then
|
||||
fail "display-power-sync no longer permits the shared cover backlight"
|
||||
fail "display-power-sync no longer handles the active-low cover backlight"
|
||||
fi
|
||||
for f in overlay/rootfs/usr/bin/sxmo_wm.sh \
|
||||
overlay/rootfs/usr/bin/sxmo_state.sh \
|
||||
@@ -1521,10 +1524,13 @@ 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_power_sync_helper = /usr/bin/bananarchy-display-power-sync' \
|
||||
'kernel_command_path = /sys/kernel/debug/dri/0/command' \
|
||||
'kernel_backlight_path = /sys/class/backlight/backlight/brightness' \
|
||||
'kernel_backlight_power_path = /sys/class/backlight/backlight/bl_power' \
|
||||
'kernel_backlight_marker = /run/bananarchy/cover-backlight' \
|
||||
'kernel_backlight_level = 14' \
|
||||
'kernel_backlight_invert = 1' \
|
||||
'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' \
|
||||
@@ -1542,7 +1548,10 @@ if ! grep -qF 'flip_open' "$COVER_SRC" || \
|
||||
fi
|
||||
for token in 'cover_kernel_draw' 'cover_kernel_command' \
|
||||
'cover_kernel_replay_firmware' 'cover_kernel_reset' \
|
||||
'cover_kernel_backlight' 'cover_kernel_display_off' \
|
||||
'cover_kernel_backlight' 'cover_kernel_open_backlight' \
|
||||
'cover_kernel_marker' 'cover_kernel_power_sync' \
|
||||
'cover_kernel_restore_internal' \
|
||||
'cover_kernel_display_off' 'kernel_bl_invert' \
|
||||
'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"
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
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.
|
||||
init, active-low cover backlight, shared-backlight marker, 240x240 frame,
|
||||
periodic repaint against Xorg, blanking, handover on open and the initial
|
||||
DPMS-off gate.
|
||||
"""
|
||||
import os
|
||||
import pathlib
|
||||
@@ -22,10 +23,11 @@ FIRMWARE = BASE / "devices/nokia-beatles/nokia,beatles-gc9305-ext-panel.bin"
|
||||
|
||||
|
||||
class Daemon:
|
||||
def __init__(self, root, exe, log, fb, bl, cmd, marker, config):
|
||||
def __init__(self, root, exe, log, fb, bl, bl_power, cmd, marker, config):
|
||||
self.log = log
|
||||
self.fb = fb
|
||||
self.bl = bl
|
||||
self.bl_power = bl_power
|
||||
self.cmd = cmd
|
||||
self.marker = marker
|
||||
self.sock = root / "cover.sock"
|
||||
@@ -37,10 +39,13 @@ class Daemon:
|
||||
"BANANARCHY_COVER_SPI_SIM": str(log),
|
||||
"BANANARCHY_COVER_MAIN_FB": str(fb),
|
||||
"BANANARCHY_COVER_DPMS_HELPER": "/bin/true",
|
||||
"BANANARCHY_COVER_KERNEL_POWER_SYNC": "/bin/true",
|
||||
"BANANARCHY_COVER_DPMS_PATH": str(root / "dpms"),
|
||||
"BANANARCHY_COVER_KERNEL_CMD": str(cmd),
|
||||
"BANANARCHY_COVER_KERNEL_BL": str(bl),
|
||||
"BANANARCHY_COVER_KERNEL_BL_POWER": str(bl_power),
|
||||
"BANANARCHY_COVER_KERNEL_MARKER": str(marker),
|
||||
"BANANARCHY_COVER_KERNEL_BL_INVERT": "1",
|
||||
})
|
||||
(root / "dpms").write_text("Off\n")
|
||||
self.proc = subprocess.Popen([str(exe), "--config", str(config)],
|
||||
@@ -100,10 +105,13 @@ def main():
|
||||
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_power_sync_helper = /usr/bin/bananarchy-display-power-sync",
|
||||
"kernel_command_path = /sys/kernel/debug/dri/0/command",
|
||||
"kernel_backlight_path = /sys/class/backlight/backlight/brightness",
|
||||
"kernel_backlight_power_path = /sys/class/backlight/backlight/bl_power",
|
||||
"kernel_backlight_marker = /run/bananarchy/cover-backlight",
|
||||
"kernel_backlight_level = 14"):
|
||||
"kernel_backlight_level = 14",
|
||||
"kernel_backlight_invert = 1"):
|
||||
if token not in conf:
|
||||
return fail("shipping config lost %s" % token)
|
||||
helper = HELPER.read_text(encoding="utf-8")
|
||||
@@ -113,9 +121,11 @@ def main():
|
||||
for token in ("cover_kernel_draw", "cover_kernel_frame",
|
||||
"cover_kernel_command", "cover_kernel_replay_firmware",
|
||||
"cover_kernel_reset", "cover_kernel_backlight",
|
||||
"cover_kernel_display_off", "cover_bus_release",
|
||||
"cover_kernel_open_backlight", "cover_kernel_marker",
|
||||
"cover_kernel_power_sync", "cover_kernel_restore_internal",
|
||||
"cover_bus_release",
|
||||
"cover_main_panel_is_off", "KERNEL_REDRAW_MS 1000",
|
||||
"reinit"):
|
||||
"kernel_bl_invert", "reinit"):
|
||||
if token not in source:
|
||||
return fail("cover daemon lost the kernel backend: %s" % token)
|
||||
firmware = FIRMWARE.read_bytes()
|
||||
@@ -137,6 +147,8 @@ def main():
|
||||
fb.write_bytes(b"\x00" * (240 * 320 * 4))
|
||||
bl = root / "brightness"
|
||||
bl.write_text("0\n")
|
||||
bl_power = root / "bl_power"
|
||||
bl_power.write_text("4\n")
|
||||
cmd = root / "command"
|
||||
cmd.write_text("")
|
||||
marker = root / "marker"
|
||||
@@ -147,37 +159,50 @@ def main():
|
||||
"socket_path = %s\nfb_device = %s\nbacklight_path = %s\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"
|
||||
"kernel_backlight_path = %s\nkernel_backlight_power_path = %s\n"
|
||||
"kernel_backlight_marker = %s\nkernel_backlight_level = 14\n"
|
||||
"kernel_backlight_invert = 1\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 / "legacy-backlight",
|
||||
fb, FIRMWARE))
|
||||
daemon = Daemon(root, exe, log, fb, bl, cmd, marker, config)
|
||||
fb, FIRMWARE, bl, bl_power, marker))
|
||||
daemon = Daemon(root, exe, log, fb, bl, bl_power, cmd, marker, config)
|
||||
try:
|
||||
time.sleep(0.3)
|
||||
if daemon.events():
|
||||
return fail("an open flip claimed the mux or touched DPMS: %s" %
|
||||
daemon.events()[:4])
|
||||
print("[ok] open flip: no mux claim, no DPMS, no frame")
|
||||
startup = daemon.events()
|
||||
allowed = ("claim", "gpio 0", "kernel restore internal",
|
||||
"kernel power sync", "dpms reinit", "dpms on")
|
||||
if any(not line.startswith(allowed) for line in startup):
|
||||
return fail("an open flip claimed the cover bus or drew a frame: %s" %
|
||||
startup[:8])
|
||||
if not daemon.wait("kernel restore internal"):
|
||||
return fail("startup did not restore the internal mux")
|
||||
if bl.read_text().strip() != "14" or bl_power.read_text().strip() != "0":
|
||||
return fail("startup did not restore the internal backlight")
|
||||
print("[ok] open flip: internal mux and backlight restored, no cover frame")
|
||||
|
||||
daemon.send("LID CLOSED")
|
||||
if not daemon.wait("dpms off"):
|
||||
if not daemon.wait("kernel marker 0") or not daemon.wait("dpms reinit"):
|
||||
return fail("closing the flip did not blank the cover")
|
||||
if not any(e == "gpio 1 1" for e in daemon.events()):
|
||||
return fail("the mux was not switched to the external panel")
|
||||
print("[ok] closed flip: mux to cover, panel blanked")
|
||||
if marker.read_text().strip() != "0" or bl.read_text().strip() != "14" \
|
||||
or bl_power.read_text().strip() != "0":
|
||||
return fail("the active-low cover backlight was not held off")
|
||||
print("[ok] closed flip: mux to cover, external backlight held off")
|
||||
|
||||
daemon.send("BUTTON")
|
||||
expected = ("dpms reinit", "kernel reset", "kernel cmd fe",
|
||||
"kernel cmd 29", "kernel backlight 14",
|
||||
"kernel frame lit=1")
|
||||
expected = ("kernel marker 1", "dpms reinit", "kernel reset",
|
||||
"kernel cmd fe", "kernel cmd 29",
|
||||
"kernel backlight 0 power=0", "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 marker.read_text().strip() != "1" or bl.read_text().strip() != "0" \
|
||||
or bl_power.read_text().strip() != "0":
|
||||
return fail("the active-low cover backlight was not enabled")
|
||||
if "kernel" not in daemon.send("STATUS"):
|
||||
return fail("STATUS does not report the kernel backend")
|
||||
print("[ok] BUTTON: vendor init, shared backlight and cover UI")
|
||||
print("[ok] BUTTON: vendor init, active-low cover backlight and UI")
|
||||
|
||||
frames = daemon.count("kernel frame lit=1")
|
||||
time.sleep(1.2)
|
||||
@@ -186,21 +211,24 @@ def main():
|
||||
print("[ok] kernel UI is repainted every second")
|
||||
|
||||
daemon.send("BLANK")
|
||||
if not daemon.wait("kernel cmd 28") or not daemon.wait("dpms off") or \
|
||||
not daemon.wait("kernel backlight 0"):
|
||||
if not daemon.wait("kernel cmd 28") or not daemon.wait("dpms reinit") or \
|
||||
not daemon.wait("kernel marker 0") or \
|
||||
not daemon.wait("kernel backlight 14 power=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")
|
||||
if marker.read_text().strip() != "0" or bl.read_text().strip() != "14":
|
||||
return fail("the cover backlight was not returned to the OFF duty")
|
||||
print("[ok] BLANK: display-off, external backlight OFF duty")
|
||||
|
||||
daemon.send("LID OPEN")
|
||||
if not daemon.wait("release"):
|
||||
return fail("opening the flip did not release the mux")
|
||||
if not daemon.wait("release") or not daemon.wait("kernel restore internal"):
|
||||
return fail("opening the flip did not restore the internal panel")
|
||||
if not any(e == "gpio 0 1" for e in daemon.events()):
|
||||
return fail("the mux was not restored to the internal panel")
|
||||
if marker.exists():
|
||||
return fail("opening the flip left the cover backlight marker")
|
||||
print("[ok] LID OPEN: panel off, mux restored")
|
||||
if bl.read_text().strip() != "14" or bl_power.read_text().strip() != "0":
|
||||
return fail("opening the flip did not restore normal backlight")
|
||||
print("[ok] LID OPEN: internal panel backlight and mux restored")
|
||||
|
||||
# A live main panel must still block the initial shared-bus takeover.
|
||||
(root / "dpms").write_text("On\n")
|
||||
|
||||
@@ -141,12 +141,16 @@ struct cover_hw {
|
||||
char probe_desc[96];
|
||||
char kernel_fb[128];
|
||||
char kernel_dpms[128];
|
||||
char kernel_sync[128];
|
||||
char kernel_cmd[128];
|
||||
char kernel_bl[128];
|
||||
char kernel_bl_power[128];
|
||||
char kernel_marker[128];
|
||||
unsigned int kernel_bl_level;
|
||||
int kernel_bl_invert;
|
||||
int kernel_lit;
|
||||
int kernel_owned;
|
||||
int kernel_restored;
|
||||
int sim;
|
||||
int spi_enabled;
|
||||
int fd_spi;
|
||||
@@ -849,7 +853,7 @@ static int cover_spi_draw(struct cover_hw *hw, const struct state *state)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void cover_kernel_release(struct cover_hw *hw);
|
||||
static void cover_kernel_release(struct cover_hw *hw, int open);
|
||||
|
||||
/* 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
|
||||
@@ -858,7 +862,7 @@ static void cover_hw_release(struct cover_hw *hw)
|
||||
{
|
||||
unsigned char mux_value[1];
|
||||
if(hw->kernel_owned) {
|
||||
cover_kernel_release(hw);
|
||||
cover_kernel_release(hw, 0);
|
||||
return;
|
||||
}
|
||||
if(!hw->mux_claimed)
|
||||
@@ -878,7 +882,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);
|
||||
cover_kernel_release(hw, 0);
|
||||
if(!hw->sim) {
|
||||
if(hw->fd_mux >= 0)
|
||||
close(hw->fd_mux);
|
||||
@@ -921,15 +925,16 @@ static int cover_main_panel_is_off(void)
|
||||
}
|
||||
|
||||
/* --- Kernel-owned cover path ----------------------------------------------
|
||||
* 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.
|
||||
* The KaiOS 3.10 DTS 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. Live probing showed that the shared PWM is
|
||||
* active-low for the cover backlight and active-high for the main backlight:
|
||||
* duty 0 lights the cover, duty 14 lights the internal panel. The daemon
|
||||
* therefore publishes a cover marker and owns the backlight state while the
|
||||
* kernel driver owns CS0 and gpio110.
|
||||
*/
|
||||
static void cover_kernel_release(struct cover_hw *hw, int open);
|
||||
|
||||
static void hw_dpms(struct cover_hw *hw, const char *mode)
|
||||
{
|
||||
char line[64];
|
||||
@@ -946,6 +951,48 @@ static void hw_dpms(struct cover_hw *hw, const char *mode)
|
||||
}
|
||||
}
|
||||
|
||||
static void cover_kernel_power_sync(struct cover_hw *hw)
|
||||
{
|
||||
char line[64];
|
||||
if(hw->sim) {
|
||||
snprintf(line, sizeof(line), "kernel power sync");
|
||||
hw_event(hw, line);
|
||||
return;
|
||||
}
|
||||
if(!hw->kernel_sync[0])
|
||||
return;
|
||||
{
|
||||
char *const argv[] = { hw->kernel_sync, NULL };
|
||||
daemon_spawn_env(argv, (char *const *)session_env);
|
||||
}
|
||||
}
|
||||
|
||||
static int cover_text_equals(const char *path, const char *value)
|
||||
{
|
||||
char buf[64];
|
||||
ssize_t got;
|
||||
size_t len;
|
||||
int fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||
if(fd < 0)
|
||||
return 0;
|
||||
got = read(fd, buf, sizeof(buf) - 1);
|
||||
close(fd);
|
||||
if(got <= 0)
|
||||
return 0;
|
||||
buf[got] = '\0';
|
||||
while(got > 0 && (buf[got - 1] == '\n' || buf[got - 1] == '\r' ||
|
||||
buf[got - 1] == ' '))
|
||||
buf[--got] = '\0';
|
||||
len = strlen(value);
|
||||
return strlen(buf) == len && memcmp(buf, value, len) == 0;
|
||||
}
|
||||
|
||||
static void write_cover_text_once(const char *path, const char *value)
|
||||
{
|
||||
if(!cover_text_equals(path, value))
|
||||
write_cover_text(path, value);
|
||||
}
|
||||
|
||||
static int cover_kernel_command(struct cover_hw *hw, unsigned char cmd,
|
||||
const unsigned char *params,
|
||||
unsigned int count)
|
||||
@@ -1026,21 +1073,59 @@ static void cover_kernel_reset(struct cover_hw *hw)
|
||||
hw_event(hw, "kernel reset");
|
||||
}
|
||||
|
||||
static void cover_kernel_backlight(struct cover_hw *hw, int on)
|
||||
static void cover_kernel_marker(struct cover_hw *hw, const char *value)
|
||||
{
|
||||
char line[64];
|
||||
if(value)
|
||||
write_cover_text_once(hw->kernel_marker, value);
|
||||
else
|
||||
unlink(hw->kernel_marker);
|
||||
snprintf(line, sizeof(line), "kernel marker %s",
|
||||
value ? value : "absent");
|
||||
hw_event(hw, line);
|
||||
}
|
||||
|
||||
static void cover_kernel_backlight(struct cover_hw *hw, int lit)
|
||||
{
|
||||
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);
|
||||
unsigned int level;
|
||||
if(lit) {
|
||||
level = hw->kernel_bl_invert ? 0 : hw->kernel_bl_level;
|
||||
cover_kernel_marker(hw, "1");
|
||||
} else {
|
||||
level = hw->kernel_bl_invert ? hw->kernel_bl_level : 0;
|
||||
cover_kernel_marker(hw, "0");
|
||||
}
|
||||
snprintf(value, sizeof(value), "%u", level);
|
||||
/* Writing bl_power first and brightness unconditionally forces the PWM
|
||||
* duty to update even when the numeric value is unchanged. The udev helper
|
||||
* skips writes once both files already match, so this cannot loop. */
|
||||
write_cover_text_once(hw->kernel_bl_power, "0");
|
||||
write_cover_text(hw->kernel_bl, value);
|
||||
snprintf(line, sizeof(line), "kernel backlight %u", level);
|
||||
snprintf(line, sizeof(line), "kernel backlight %u power=0", level);
|
||||
hw_event(hw, line);
|
||||
cover_kernel_power_sync(hw);
|
||||
}
|
||||
|
||||
static void cover_kernel_open_backlight(struct cover_hw *hw)
|
||||
{
|
||||
char value[32];
|
||||
unlink(hw->kernel_marker);
|
||||
snprintf(value, sizeof(value), "%u", hw->kernel_bl_level);
|
||||
write_cover_text_once(hw->kernel_bl_power, "0");
|
||||
write_cover_text(hw->kernel_bl, value);
|
||||
hw_event(hw, "kernel restore internal");
|
||||
cover_kernel_power_sync(hw);
|
||||
}
|
||||
|
||||
static int cover_kernel_mux(struct cover_hw *hw, int closed)
|
||||
{
|
||||
unsigned char values[2];
|
||||
values[0] = (unsigned char)(closed ? hw->mux_closed_level :
|
||||
hw->mux_open_level);
|
||||
values[1] = (unsigned char)hw->reset_idle_level;
|
||||
return hw_gpio_set(hw, hw->fd_mux, values, 2);
|
||||
}
|
||||
|
||||
static void cover_kernel_display_off(struct cover_hw *hw)
|
||||
@@ -1052,7 +1137,6 @@ static int cover_kernel_claim(struct cover_hw *hw)
|
||||
{
|
||||
unsigned int offsets[2];
|
||||
unsigned char defaults[2];
|
||||
unsigned char values[2];
|
||||
int fd;
|
||||
if(hw->fd_mux >= 0 || hw->mux_claimed)
|
||||
return 1;
|
||||
@@ -1066,20 +1150,30 @@ static int cover_kernel_claim(struct cover_hw *hw)
|
||||
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);
|
||||
hw->kernel_restored = 0;
|
||||
return cover_kernel_mux(hw, 1);
|
||||
}
|
||||
|
||||
static void cover_kernel_release(struct cover_hw *hw)
|
||||
static void cover_kernel_release(struct cover_hw *hw, int open)
|
||||
{
|
||||
unsigned char values[2];
|
||||
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);
|
||||
if(!open)
|
||||
cover_kernel_backlight(hw, 0);
|
||||
cover_kernel_mux(hw, 0);
|
||||
unlink(hw->kernel_marker);
|
||||
if(open) {
|
||||
hw_dpms(hw, "reinit");
|
||||
cover_kernel_open_backlight(hw);
|
||||
hw_dpms(hw, "on");
|
||||
cover_kernel_power_sync(hw);
|
||||
hw->kernel_restored = 1;
|
||||
} else {
|
||||
write_cover_text_once(hw->kernel_bl_power, "4");
|
||||
write_cover_text(hw->kernel_bl, "0");
|
||||
hw_dpms(hw, "off");
|
||||
hw->kernel_restored = 0;
|
||||
}
|
||||
hw_event(hw, "release");
|
||||
if(!hw->sim && hw->fd_mux >= 0)
|
||||
close(hw->fd_mux);
|
||||
@@ -1092,7 +1186,7 @@ static void cover_kernel_release(struct cover_hw *hw)
|
||||
static void cover_bus_release(struct cover_hw *hw)
|
||||
{
|
||||
if(hw->kernel_owned) {
|
||||
cover_kernel_release(hw);
|
||||
cover_kernel_release(hw, 0);
|
||||
return;
|
||||
}
|
||||
if(!hw->mux_claimed)
|
||||
@@ -1102,6 +1196,39 @@ static void cover_bus_release(struct cover_hw *hw)
|
||||
close(hw->fd_mux);
|
||||
hw->fd_mux = -1;
|
||||
hw->mux_claimed = 0;
|
||||
hw->kernel_restored = 0;
|
||||
}
|
||||
|
||||
static void cover_kernel_restore_internal(struct cover_hw *hw)
|
||||
{
|
||||
unsigned int offsets[1];
|
||||
unsigned char defaults[1];
|
||||
unsigned char values[1];
|
||||
int fd;
|
||||
if(hw->kernel_restored)
|
||||
return;
|
||||
if(hw->kernel_owned) {
|
||||
cover_kernel_release(hw, 1);
|
||||
return;
|
||||
}
|
||||
if(hw->mux_claimed || hw->fd_mux >= 0) {
|
||||
cover_bus_release(hw);
|
||||
} else {
|
||||
offsets[0] = hw->mux_gpio;
|
||||
defaults[0] = (unsigned char)hw->mux_open_level;
|
||||
fd = hw_gpio_request(hw, offsets, defaults, 1);
|
||||
if(fd >= 0) {
|
||||
values[0] = (unsigned char)hw->mux_open_level;
|
||||
hw_gpio_set(hw, fd, values, 1);
|
||||
if(!hw->sim)
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
hw_dpms(hw, "reinit");
|
||||
cover_kernel_open_backlight(hw);
|
||||
hw_dpms(hw, "on");
|
||||
cover_kernel_power_sync(hw);
|
||||
hw->kernel_restored = 1;
|
||||
}
|
||||
|
||||
static int cover_kernel_frame(struct cover_hw *hw, const struct state *state)
|
||||
@@ -1116,9 +1243,6 @@ static int cover_kernel_frame(struct cover_hw *hw, const struct state *state)
|
||||
struct frame fb;
|
||||
int fd;
|
||||
char line[96];
|
||||
/* Match the DRM fbdev stride: 240x320 XR24 is padded to 1024 bytes/row.
|
||||
* Writing a 240x240 damage rect makes mipi_dbi set a 240x240 address
|
||||
* window, which is exactly the cover panel's native geometry. */
|
||||
snprintf(sysfs, sizeof(sysfs), "/sys/class/graphics/fb0/stride");
|
||||
if(read_uint_file(sysfs, &parsed) && parsed >= width * 4)
|
||||
stride = parsed;
|
||||
@@ -1159,22 +1283,38 @@ static const char *cover_kernel_draw(struct cover_hw *hw,
|
||||
return "none";
|
||||
if(lit != hw->kernel_lit) {
|
||||
if(lit) {
|
||||
cover_kernel_backlight(hw, 1);
|
||||
hw_dpms(hw, "on");
|
||||
hw_dpms(hw, "reinit");
|
||||
if(!hw->sim)
|
||||
poll(NULL, 0, 180);
|
||||
cover_kernel_mux(hw, 1);
|
||||
cover_kernel_reset(hw);
|
||||
if(!cover_kernel_replay_firmware(hw))
|
||||
return "none";
|
||||
/* DPMS off/on can rewrite bl_power, so force the active-low duty again. */
|
||||
cover_kernel_backlight(hw, 1);
|
||||
hw_dpms(hw, "on");
|
||||
cover_kernel_power_sync(hw);
|
||||
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_dpms(hw, "reinit");
|
||||
if(!hw->sim)
|
||||
poll(NULL, 0, 180);
|
||||
cover_kernel_display_off(hw);
|
||||
cover_kernel_backlight(hw, 0);
|
||||
hw_dpms(hw, "on");
|
||||
cover_kernel_power_sync(hw);
|
||||
}
|
||||
hw->kernel_lit = lit;
|
||||
} else if(lit) {
|
||||
cover_kernel_backlight(hw, 1);
|
||||
hw_dpms(hw, "on");
|
||||
cover_kernel_power_sync(hw);
|
||||
}
|
||||
if(lit && !cover_kernel_frame(hw, state))
|
||||
return "none";
|
||||
@@ -1189,8 +1329,12 @@ static const char *cover_draw(struct cover_hw *hw, const char *fb_path,
|
||||
int prefer_fb = strcmp(hw->backend, "spidev") != 0 &&
|
||||
strcmp(hw->backend, "none") != 0 && fb_present;
|
||||
if(flip_open) {
|
||||
cover_hw_release(hw);
|
||||
cover_kernel_release(hw);
|
||||
if(strcmp(hw->backend, "kernel") == 0)
|
||||
cover_kernel_restore_internal(hw);
|
||||
else {
|
||||
cover_hw_release(hw);
|
||||
cover_kernel_release(hw, 0);
|
||||
}
|
||||
if(prefer_fb)
|
||||
return draw_frame(fb_path, state) ? "fb" : "none";
|
||||
return "idle";
|
||||
@@ -1207,7 +1351,7 @@ static const char *cover_draw(struct cover_hw *hw, const char *fb_path,
|
||||
* 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);
|
||||
cover_kernel_release(hw, 0);
|
||||
return "pending";
|
||||
}
|
||||
return cover_kernel_draw(hw, state);
|
||||
@@ -1311,6 +1455,7 @@ static void cover_hw_init(struct cover_hw *hw)
|
||||
hw->panel_lines = 1;
|
||||
hw->probe_index = -1;
|
||||
hw->kernel_lit = -1;
|
||||
hw->kernel_restored = 0;
|
||||
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),
|
||||
@@ -1318,13 +1463,18 @@ static void cover_hw_init(struct cover_hw *hw)
|
||||
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_sync, sizeof(hw->kernel_sync),
|
||||
"/usr/bin/bananarchy-display-power-sync");
|
||||
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_bl_power, sizeof(hw->kernel_bl_power),
|
||||
"/sys/class/backlight/backlight/bl_power");
|
||||
safe_copy(hw->kernel_marker, sizeof(hw->kernel_marker),
|
||||
"/run/bananarchy/cover-backlight");
|
||||
hw->kernel_bl_level = 14;
|
||||
hw->kernel_bl_invert = 1;
|
||||
safe_copy(hw->probe_desc, sizeof(hw->probe_desc), "none");
|
||||
hw->fd_spi = -1;
|
||||
hw->fd_chip = -1;
|
||||
@@ -1334,18 +1484,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 *sync = getenv("BANANARCHY_COVER_KERNEL_POWER_SYNC");
|
||||
const char *cmd = getenv("BANANARCHY_COVER_KERNEL_CMD");
|
||||
const char *bl = getenv("BANANARCHY_COVER_KERNEL_BL");
|
||||
const char *power = getenv("BANANARCHY_COVER_KERNEL_BL_POWER");
|
||||
const char *marker = getenv("BANANARCHY_COVER_KERNEL_MARKER");
|
||||
const char *level = getenv("BANANARCHY_COVER_KERNEL_BL_LEVEL");
|
||||
const char *invert = getenv("BANANARCHY_COVER_KERNEL_BL_INVERT");
|
||||
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(sync && *sync)
|
||||
safe_copy(hw->kernel_sync, sizeof(hw->kernel_sync), sync);
|
||||
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(power && *power)
|
||||
safe_copy(hw->kernel_bl_power, sizeof(hw->kernel_bl_power), power);
|
||||
if(marker && *marker)
|
||||
safe_copy(hw->kernel_marker, sizeof(hw->kernel_marker), marker);
|
||||
if(level && *level) {
|
||||
@@ -1353,6 +1510,8 @@ static void cover_hw_init(struct cover_hw *hw)
|
||||
if(parsed > 0 && parsed <= 255)
|
||||
hw->kernel_bl_level = (unsigned int)parsed;
|
||||
}
|
||||
if(invert && *invert)
|
||||
hw->kernel_bl_invert = strtol(invert, NULL, 10) != 0;
|
||||
}
|
||||
sim = getenv("BANANARCHY_COVER_SPI_SIM");
|
||||
if(sim && *sim) {
|
||||
@@ -1417,16 +1576,24 @@ 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_power_sync_helper") == 0)
|
||||
safe_copy(hw->kernel_sync, sizeof(hw->kernel_sync), 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_power_path") == 0)
|
||||
safe_copy(hw->kernel_bl_power, sizeof(hw->kernel_bl_power), 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, "kernel_backlight_invert") == 0) {
|
||||
v = strtol(value, NULL, 10);
|
||||
if(v == 0 || v == 1)
|
||||
hw->kernel_bl_invert = (int)v;
|
||||
}
|
||||
else if(strcmp(key, "gpiochip_device") == 0)
|
||||
safe_copy(hw->gpio_path, sizeof(hw->gpio_path), value);
|
||||
@@ -1628,9 +1795,16 @@ static void handle_command(char *buffer, struct state *state,
|
||||
hw->kernel_bl_level = (unsigned int)level;
|
||||
else
|
||||
return;
|
||||
} else if(strcmp(key, "kernel_backlight_invert") == 0) {
|
||||
long invert = strtol(value, NULL, 10);
|
||||
if(invert == 0 || invert == 1)
|
||||
hw->kernel_bl_invert = (int)invert;
|
||||
else
|
||||
return;
|
||||
} else
|
||||
return;
|
||||
cover_bus_release(hw);
|
||||
hw->kernel_restored = 0;
|
||||
*redraw = 1;
|
||||
} else if(strcmp(command, "PROBE") == 0) {
|
||||
const struct probe_case *p;
|
||||
|
||||
Reference in new issue
Block a user