Implement 0012 72h standby battery optimizations and initramfs depmod hook
- Add patches/kernel/0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch, rebuild affected kernel/module artifacts and all six device DTS/DTB files (msm8916-wcd-analog s2/bias gating, wcn36xx offload_sync_work and healthy-RSSI screen_off_offload scan short-circuit, pm8916_bms_vm screen_off FORCE_S3 OCV mode, panel-mipi-dbi dc/reset low on blank, spi-qup runtime PM sleep pinctrl, PM8909 l1/l4 LDO seeding, and sdhci-msm vmmc/vqmmc set_load with regulator-allow-set-load on l8/l12), and switch msm8905-cam from direct APSS SPMI LDO6/LDO17 writes to RPM regulator consumer voting.
- Update standby power policy and compiled C daemons (WIFI_LISTEN_INTERVAL=8, WIFI_STANDBY_RAT=gsm with CS verification and fallback, 10-bananarchy-dpm.sh wifi-up/unpark-rat dispatch, 25 s boot QRTR wait and QMI DMS online recovery, pm8916_bms_vm screen_off sync, bananarchy-run-aligned dark-screen skip, bananarchy-dsds --sig-hysteresis, bananarchy-cover-idle wake_blank_timeout = 8, and scripts/test-standby-power-policy.py).
- Add overlay/rootfs/etc/boot-deploy/hooks/10-initramfs-depmod.sh to run depmod -b per staged initramfs cpio archive and eliminate Stage 2 udevd missing-module boot console errors, enforce .ko.zst-only module installs in apply-bananarchy-overlay.sh, stage Alpine 3.24 /usr/lib/{libz,libcrypto}.so* in rebuild-image.sh chroot with failure cleanup, and add initramfs cpio guards plus verified image hashes in scripts/check-rebuild.sh.
- Document all changes under Unreleased in CHANGELOG.md and synchronize AGENTS.md, MANUAL.md, and BATTERY-OPTIMIZATION-ANALYSIS.md.
This commit is contained in:
1 parent
9700949b28
commit
fc5c4282f5
67 files changed
+67482
-65598
No files matched your search
@@ -67,7 +67,13 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
|
|||||||
`bananarchy-volume-keys`, `bananarchy-dsds`, `bananarchy-modemmonitor`, `bananarchy-soundmonitor`,
|
`bananarchy-volume-keys`, `bananarchy-dsds`, `bananarchy-modemmonitor`, `bananarchy-soundmonitor`,
|
||||||
`bananarchy-notifmonitor`, `bananarchy-run-aligned`, `bananarchy-session-loop`), not Python or `/bin/sh` loops.
|
`bananarchy-notifmonitor`, `bananarchy-run-aligned`, `bananarchy-session-loop`), not Python or `/bin/sh` loops.
|
||||||
Preserve `/run/bananarchy/lid-state`, the cover socket protocol, `FBIOBLANK`, cover diagnostics,
|
Preserve `/run/bananarchy/lid-state`, the cover socket protocol, `FBIOBLANK`, cover diagnostics,
|
||||||
`scripts/test-cover-idle.py`, and `scripts/test-dsds-daemon.py`.
|
`should_skip_while_dark()`, `bananarchy-dsds --sig-hysteresis`, `scripts/test-cover-idle.py`,
|
||||||
|
`scripts/test-dsds-daemon.py`, and `scripts/test-standby-power-policy.py`.
|
||||||
|
- Keep standby battery invariants from `0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch` and
|
||||||
|
`bananarchy-power-policy.conf`: `CPU_RPM_SLEEP=0`, `CPU_L2_SLEEP=0`, `MODEM_DRX_MODE=0`, `WIFI_LISTEN_INTERVAL=8`,
|
||||||
|
`WIFI_STANDBY_RAT=gsm`, `msm8916-wcd-analog` `s2` gating, `pm8916_bms_vm` `screen_off` S3 OCV mode, `sdhci-msm`
|
||||||
|
`vmmc`/`vqmmc` `set_load` (`regulator-allow-set-load;` on `l8`/`l12` across DTS), and `msm8905-cam.c` RPM `l6`/`l17`
|
||||||
|
regulator consumer voting (`regulator_get_optional`, never raw APSS SPMI writes on RPM LDOs).
|
||||||
- Keep the zero-lag plugin model: preloaded resident daemons guarded by lock/FIFO, `poll()` at 0% CPU, offscreen
|
- Keep the zero-lag plugin model: preloaded resident daemons guarded by lock/FIFO, `poll()` at 0% CPU, offscreen
|
||||||
`240x296` Pixmaps at `Y=24`, `PluginTheme`, `RELOAD_THEME`, idle blank/lock helpers, the 350 ms `dwm` wake guard, and
|
`240x296` Pixmaps at `Y=24`, `PluginTheme`, `RELOAD_THEME`, idle blank/lock helpers, the 350 ms `dwm` wake guard, and
|
||||||
startup keyboard-grab cleanup without a background poller.
|
startup keyboard-grab cleanup without a background poller.
|
||||||
@@ -98,11 +104,12 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
|
|||||||
internal panel, not the cover; `SET kernel_backlight_invert 0|1` and `SET kernel_internal_sleep 0|1` remain runtime
|
internal panel, not the cover; `SET kernel_backlight_invert 0|1` and `SET kernel_internal_sleep 0|1` remain runtime
|
||||||
knobs.
|
knobs.
|
||||||
- Keep the internal beatles panel at 25 MHz, `dc_gpio = -1` for the spidev fallback, external-panel firmware and
|
- 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
|
initramfs module lists, `/etc/boot-deploy/hooks/10-initramfs-depmod.sh` (per-initramfs `depmod -b`), `.ko.zst`-only
|
||||||
|
module installs, the Xorg `card0` pin, `bananarchy-cover-diagnose.sh`, and the
|
||||||
`scripts/test-cover-dt.py` / `scripts/test-cover-spidev.py` guards.
|
`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 shipping cover backend is `backend = kernel`: keep `bananarchy-cover-dpms.sh reinit`, the gpio13 mux claim,
|
||||||
the centered 240x240 X11/`/dev/fb0` cover frame, the 1 s repaint against Xorg, `kernel_backlight_invert = 0`,
|
the centered 240x240 X11/`/dev/fb0` cover frame, the 1 s repaint against Xorg, `kernel_backlight_invert = 0`,
|
||||||
`kernel_internal_sleep = 0`, `kernel_backlight_level = 14`, shared **Config -> Screen blank** timeout reload,
|
`kernel_internal_sleep = 0`, `kernel_backlight_level = 14`, shared **Config -> Screen blank** timeout reload (`wake_blank_timeout = 8` for passive wakes),
|
||||||
closed-flip `CALL` cover UI (`cover_hold_awake`, `BUTTON VOLUP`/`VOLDOWN` -> `mute-ring`, `BUTTON POWER` -> `hangup-call`,
|
closed-flip `CALL` cover UI (`cover_hold_awake`, `BUTTON VOLUP`/`VOLDOWN` -> `mute-ring`, `BUTTON POWER` -> `hangup-call`,
|
||||||
delayed `CALL muted` guard), clean `SIGTERM` cover blanking, live timezone refresh (`ba_refresh_tz` / `REFRESH`),
|
delayed `CALL muted` guard), clean `SIGTERM` cover blanking, live timezone refresh (`ba_refresh_tz` / `REFRESH`),
|
||||||
`scripts/test-cover-kernel.py`, `scripts/test-time-timezone-sync.py`, and the `spidev`/`fb`/`none` rollback backends.
|
`scripts/test-cover-kernel.py`, `scripts/test-time-timezone-sync.py`, and the `spidev`/`fb`/`none` rollback backends.
|
||||||
|
|||||||
@@ -1510,3 +1510,106 @@ vMPM timer programming or last-man L2 SAW2 shutdown.
|
|||||||
`bananarchy-x11-session.sh` tail loop with 0%-CPU compiled C11 ARM ELF
|
`bananarchy-x11-session.sh` tail loop with 0%-CPU compiled C11 ARM ELF
|
||||||
binaries (`poll(..., -1)` / `inotify` / `nanosleep`) built by
|
binaries (`poll(..., -1)` / `inotify` / `nanosleep`) built by
|
||||||
`scripts/build-bananarchy-daemons.sh`.
|
`scripts/build-bananarchy-daemons.sh`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 23. 72-hour DSDS + Wi-Fi standby optimizations & live hardware verification
|
||||||
|
|
||||||
|
Following measured standby of 60% drain in 24h on a `nokia-beatles` (`2720 Flip`)
|
||||||
|
with DSDS active, Wi-Fi connected, and no microSD inserted, the following kernel,
|
||||||
|
driver, DTS, daemon, and power-policy changes were implemented toward the 72h
|
||||||
|
standby baseline (`<= 20.8 mA` on the 1,500 mAh cell) without re-enabling
|
||||||
|
`CONFIG_SUSPEND` or regressing `nokia-argon`:
|
||||||
|
|
||||||
|
1. **Kernel standby patch
|
||||||
|
(`patches/kernel/0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch`)**:
|
||||||
|
- **Analog audio codec (`sound/soc/codecs/msm8916-wcd-analog.c`)**: switched
|
||||||
|
`pm8916_wcd_analog` to `.idle_bias_on = 0` with `.set_bias_level` and
|
||||||
|
`pm8916_wcd_analog_update_power_locked()` (`power_lock`, `audio_active`,
|
||||||
|
`jack_inserted`, `s2_enabled`), disabling `s2` (`vdd-cdc-tx-rx-cx`,
|
||||||
|
1.85 V) and master bias whenever playback/capture and headset insertion are
|
||||||
|
both idle, and masking `MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET`
|
||||||
|
while no jack is inserted.
|
||||||
|
- **WCN3620 Wi-Fi (`drivers/net/wireless/ath/wcn36xx/{main.c,smd.c,wcn36xx.h}`)**:
|
||||||
|
added `offload_sync_work` (`wcn36xx_schedule_offload_sync()`) to re-sync
|
||||||
|
`HOST_SUSPEND_IND` / NS offload after scans and IPv6 address updates, and
|
||||||
|
short-circuited associated multi-channel `wcn36xx_hw_scan()` requests when
|
||||||
|
`screen_off_offload` is enabled and `wcn36xx_operating_rssi_healthy()` shows
|
||||||
|
RSSI `>= -75 dBm`.
|
||||||
|
- **Fuel gauge (`drivers/power/supply/pm8916_bms_vm.c`)**: added the
|
||||||
|
`screen_off` module parameter (`pm8916_bms_screen_off_ops`) and
|
||||||
|
`pm8916_bms_vm_sync_mode()` so the BMS enters `PM8916_BMS_VM_MODE_FORCE_S3`
|
||||||
|
while the panel is off and discharging, sampling
|
||||||
|
`PM8916_BMS_VM_S3_S7_OCV_DATA0` when returning to
|
||||||
|
`PM8916_BMS_VM_MODE_NORMAL`. `bananarchy-display-power-sync` drives
|
||||||
|
`/sys/module/pm8916_bms_vm/parameters/screen_off`.
|
||||||
|
- **MIPI DBI panel + SPI QUP (`panel-mipi-dbi.c`, `spi-qup.c`)**:
|
||||||
|
`panel_mipi_dbi_disable()` drives `dc` and `reset` GPIOs low on blank/DPMS
|
||||||
|
Off, and `spi_qup_pm_suspend_runtime()` / `spi_qup_pm_resume_runtime()`
|
||||||
|
toggle `pinctrl_pm_select_sleep_state()` and
|
||||||
|
`pinctrl_pm_select_default_state()` around QUP runtime PM.
|
||||||
|
- **Unused RPM LDO seeding (`drivers/regulator/qcom_smd-regulator.c`)**:
|
||||||
|
extended `rpm_regulator_init_vreg()` seeding (`vreg->is_enabled = 1`) to
|
||||||
|
PM8909 `l1` and `l4` alongside `l14`, `l15`, and `l18` so unreferenced
|
||||||
|
rails power down cleanly after late regulator cleanup.
|
||||||
|
- **microSD LPM preparation (`drivers/mmc/host/sdhci-msm.c` + device DTS)**:
|
||||||
|
`sdhci_msm_runtime_suspend()` and `sdhci_msm_runtime_resume()` scale
|
||||||
|
`vmmc`/`vqmmc` regulator load between `0` and `200000` / `20000` uA,
|
||||||
|
paired with `regulator-allow-set-load;` on `l8`/`l12` in all six device
|
||||||
|
DTS files (`nokia-argon`, `nokia-beatles`, `nokia-beatles-cover`,
|
||||||
|
`nokia-coconut`, `nokia-sparkler`, `nokia-leo`). Physical microSD rundown
|
||||||
|
testing remains to be run once a card is inserted.
|
||||||
|
|
||||||
|
2. **Camera driver RPM regulator fix (`src/msm8905-cam/msm8905-cam.c`)**:
|
||||||
|
- Closed-flip (`DPMS Off`) camera capture testing exposed a kernel Oops in
|
||||||
|
`pmic_arb_write_cmd()` when `msm8905-cam` wrote `LDO6` (`0x4546`) directly
|
||||||
|
over APSS SPMI (`usid1_regmap`); `LDO6` and `LDO17` belong to RPM
|
||||||
|
(`qcom_smd-regulator`), which only went unnoticed previously when `display@0`
|
||||||
|
was powered on.
|
||||||
|
- Replaced direct `LDO6`/`LDO17` SPMI writes with Linux regulator consumer
|
||||||
|
voting (`regulator_get_optional(&cam->pdev->dev, "l6"|"l17")`,
|
||||||
|
`msm8905_cam_regulators_enable()`, and
|
||||||
|
`msm8905_cam_regulators_disable()`), keeping `msm8905_cam_spmi_restore()`
|
||||||
|
solely for codec analog `PPID 0xf1`. Verified `bananarchy-photo` during
|
||||||
|
`DPMS Off` on rebuilt `6.12.1-msm8916` with zero warnings or Oopses and
|
||||||
|
`l6`/`l17` returning to `use=0` after capture.
|
||||||
|
|
||||||
|
3. **Userspace daemons, boot readiness, and standby power policy**:
|
||||||
|
- `/etc/bananarchy-power-policy.conf` defaults updated to
|
||||||
|
`WIFI_LISTEN_INTERVAL=8` and `WIFI_STANDBY_RAT=gsm` (keeps `CPU_RPM_SLEEP=0`,
|
||||||
|
`CPU_L2_SLEEP=0`, `MODEM_DRX_MODE=0`, `DSDS_SECONDARY_MODE=active`,
|
||||||
|
`WIFI_SCREEN_OFF_IPV6_MUTE=1`).
|
||||||
|
- `/etc/NetworkManager/conf.d/10-power.conf` keeps `wifi.powersave=3` and
|
||||||
|
`[connectivity] enabled=false` without an overriding `wifi.scan-interval`.
|
||||||
|
- `/etc/NetworkManager/dispatcher.d/10-bananarchy-dpm.sh` dispatches
|
||||||
|
`bananarchy-power-policy.sh unpark-rat` on `wlan0` `down|pre-down` and
|
||||||
|
`bananarchy-power-policy.sh wifi-up` on `up|dhcp4-change`.
|
||||||
|
- `bananarchy-power-policy.sh`, `etc/init.d/msm8909-modem-wwan-port`,
|
||||||
|
`etc/init.d/msm-modem-uim-selection`, and
|
||||||
|
`usr/libexec/msm-modem-uim-selection` raise boot QRTR waits from 15 s to
|
||||||
|
25 s, recover QMI DMS from low-power/offline to `online` inside
|
||||||
|
`provision_slot()`, redirect background timer subshell FDs in
|
||||||
|
`arm_rat_park_timer()`, and apply `screenoff` on boot when dark.
|
||||||
|
- `bananarchy-run-aligned.c` (`should_skip_while_dark()`), `sxmo_wm.sh`
|
||||||
|
(`killall -USR1 bananarchy-run-aligned`, `bananarchy-power-policy.sh`),
|
||||||
|
`bananarchy-dsds.c` (`--sig-hysteresis`), and `bananarchy-cover-idle.c` /
|
||||||
|
`cover-display.conf` (`wake_blank_timeout = 8` for passive closed-flip
|
||||||
|
wakes) suppress unnecessary idle wakeups.
|
||||||
|
|
||||||
|
4. **Verified live `nokia-beatles` telemetry & image checks (before multi-day rundown)**:
|
||||||
|
- Closed-flip Wi-Fi + DSDS standby (`lid=closed`, `dpms=Off`, `blp=4`,
|
||||||
|
`br=0`, `bms_off=Y`): `spi_runtime=suspended`, `gpio13=out low`,
|
||||||
|
`gpio25=out low`, `gpio110=out low`, `s2 use=0`, `l6 use=0`, `l12 use=0`,
|
||||||
|
`l17 use=0`, `wcn36xx_param=8`, `wcn36xx_screen_off_offload=Y`,
|
||||||
|
`wlan0_accept_ra=0`, `rat_parked=yes` (`Mode preference: 'gsm'`, both SIM
|
||||||
|
slots `registered`), `MPSS` `XO shutdown count: 605`, `PRONTO`
|
||||||
|
`XO shutdown count: 296`, and codec `dapm/bias_level` = `Off`.
|
||||||
|
- Post-rebuild `6.12.1-msm8916` boot verification (`Sun Nov 15 11:56:20 UTC
|
||||||
|
2026`): automatic QMI DMS `Mode: 'online'`, `DUAL_SIM_ACTIVE=1` (`lifecell`
|
||||||
|
Slot 1 `gsm` + Slot 2 `umts` `registered`), `spi_runtime=suspended`,
|
||||||
|
`l12 use=0`, and clean `DPMS Off` camera capture (`31K` JPEG).
|
||||||
|
- Both rebuilt `nokia-argon` and `nokia-beatles` release images passed
|
||||||
|
`e2fsck -fn`, `debugfs`, `scripts/test-standby-power-policy.py`, and
|
||||||
|
`scripts/check-rebuild.sh` zero-regression checks.
|
||||||
|
- Physical 24h and 72h unplugged discharge measurements (without and with a
|
||||||
|
microSD card installed) remain to be measured against the rebuilt image.
|
||||||
@@ -10,6 +10,25 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### 72-hour DSDS and Wi-Fi standby battery optimizations (`0012`)
|
||||||
|
|
||||||
|
- **Kernel standby patch (`patches/kernel/0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch`)**:
|
||||||
|
- **Analog audio codec (`msm8916-wcd-analog.c` / `snd-soc-msm8916-analog.ko.zst`)**: set `.idle_bias_on = 0` with `.set_bias_level` and `pm8916_wcd_analog_update_power_locked()` (`power_lock`, `audio_active`, `jack_inserted`, `s2_enabled`), gating `s2` (`vdd-cdc-tx-rx-cx`, `1.85 V`) and master bias off whenever playback/capture and headset insertion are both idle, and masking `MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET` while no jack is inserted.
|
||||||
|
- **WCN3620 Wi-Fi (`wcn36xx`)**: added `offload_sync_work` (`wcn36xx_schedule_offload_sync()`) to re-assert `HOST_SUSPEND_IND` and IPv6 NS offload after scans and IPv6 address changes, and short-circuited associated multi-channel `wcn36xx_hw_scan()` requests when `screen_off_offload` is active and operating RSSI is `>= -75 dBm`.
|
||||||
|
- **PM8916 BMS fuel gauge (`pm8916_bms_vm.c`)**: added the `screen_off` module parameter (`pm8916_bms_vm_sync_mode()`) so the BMS enters `PM8916_BMS_VM_MODE_FORCE_S3` while dark and discharging and samples `PM8916_BMS_VM_S3_S7_OCV_DATA0` on return to `PM8916_BMS_VM_MODE_NORMAL`, driven by `bananarchy-display-power-sync`.
|
||||||
|
- **MIPI DBI panel, SPI QUP, RPM LDO seeding, and microSD LPM (`panel-mipi-dbi.c`, `spi-qup.c`, `qcom_smd-regulator.c`, `sdhci-msm.c`, device DTS)**: drove `dc` and `reset` GPIOs low in `panel_mipi_dbi_disable()`, selected sleep/default pinctrl around `spi-qup` runtime PM, seeded `vreg->is_enabled = 1` on PM8909 `l1` and `l4` so unreferenced boot rails power down cleanly, and added `vmmc`/`vqmmc` `regulator_set_load()` in `sdhci-msm` runtime suspend/resume paired with `regulator-allow-set-load;` on `l8`/`l12` across all six device DTS files.
|
||||||
|
- **Camera driver RPM regulator consumer voting (`src/msm8905-cam/msm8905-cam.c`)**: replaced direct APSS SPMI writes to RPM-owned `LDO6`/`LDO17` (`0x4546`/`0x5046`, which caused a `pmic_arb_write_cmd()` Oops during `DPMS Off` captures when `display@0` was powered off) with `regulator_get_optional()` consumer voting on `"l6"` and `"l17"`, keeping SPMI restore solely for codec analog `PPID 0xf1`.
|
||||||
|
- **Userspace standby policy, boot QRTR readiness, and C daemon wakeup reductions**: updated `/etc/bananarchy-power-policy.conf` and `/etc/modprobe.d/10-bananarchy-power.conf` defaults to `WIFI_LISTEN_INTERVAL=8` and `WIFI_STANDBY_RAT=gsm` (45 s dark Wi-Fi GSM parking with CS registration verification and auto-fallback on 2G-sunset networks, wired to `10-bananarchy-dpm.sh` `wifi-up`/`unpark-rat`), kept `wifi.powersave=3` and `[connectivity] enabled=false` without an overriding `wifi.scan-interval` in `/etc/NetworkManager/conf.d/10-power.conf`, raised boot QRTR waits to `25 s` and recovered QMI DMS to `online` in `msm8909-modem-wwan-port` / `msm-modem-uim-selection` / `bananarchy-power-policy.sh`, skipped dark periodic statusbar ticks in `bananarchy-run-aligned` (`should_skip_while_dark()`), added `--sig-hysteresis` in `bananarchy-dsds`, capped passive closed-flip cover wakes to `wake_blank_timeout = 8` in `bananarchy-cover-idle` / `cover-display.conf`, and added `scripts/test-standby-power-policy.py`.
|
||||||
|
|
||||||
|
### Initramfs per-archive `depmod` hook and `.ko.zst`-only module hygiene
|
||||||
|
|
||||||
|
- **Eliminate Stage 2 `udevd` missing-module console errors**: added executable hook `overlay/rootfs/etc/boot-deploy/hooks/10-initramfs-depmod.sh` so `boot-deploy` unpacks each staged `initramfs` cpio archive, runs `depmod -b` against its `6.12.1-msm8916` module subset (`27` modules on `nokia-argon`, `30` on `nokia-beatles`), verifies every `modules.dep` entry exists in the archive, and repacks it before creating `boot.img` or copying `/boot/initramfs`. This eliminates the `<27>` `udevd` `No such file or directory` boot console errors on `qcom_pil_info.ko.zst` and `snd-soc-qcom-common.ko.zst`.
|
||||||
|
- **Module install hygiene, Alpine 3.24 chroot `depmod` libs, and image verification**: updated `scripts/apply-bananarchy-overlay.sh` to remove stale uncompressed `.ko` files and copy only `*.ko.zst` across all prebuilt module directories; updated `rebuild-image.sh` to stage `libz.so*` and `libcrypto.so*` from both `/lib/` and `/usr/lib/` (`-aL`) into `/tmp/hostbin/` with guaranteed chroot failure cleanup; added initramfs cpio `modules.dep`/`modules.alias` and `.ko*` guards in `scripts/check-rebuild.sh`; and rebuilt and verified local `a1114` / `carbonara` images (`images/bananarchy-nokia-argon.img` SHA-256 `753c186db1fa5e7d58f3252ad344004bcb0d6fb26eb810ae9427d572cd7d94ca`, `images/bananarchy-nokia-beatles.img` SHA-256 `12eb7e589a40c3935fcf283f3771b1e7e65d04b08b6d632c23b0f290304dd673`, and `images/boot-bananarchy-nokia-beatles.img` SHA-256 `d6b82239f80038c1bd916c36d4c674dc1e36996b3d52c65efdd545ff320a08d8`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Build `a1114` — codename `carbonara` (2026-11-14)
|
## Build `a1114` — codename `carbonara` (2026-11-14)
|
||||||
|
|
||||||
This build ships MSM8909 interconnect/Wi-Fi/USB/panel deep-standby power optimizations (`0008`–`0011`), compiled C11 zero-CPU autostart and idle daemons, 2720 Flip closed-flip call wakeups, call preservation on flip-open, and external cover call controls, live network/manual timezone propagation without reboot, and fresh `a1114` / `carbonara` images for both **Nokia 8110 4G (`nokia-argon`)** and **Nokia 2720 Flip (`nokia-beatles`)**.
|
This build ships MSM8909 interconnect/Wi-Fi/USB/panel deep-standby power optimizations (`0008`–`0011`), compiled C11 zero-CPU autostart and idle daemons, 2720 Flip closed-flip call wakeups, call preservation on flip-open, and external cover call controls, live network/manual timezone propagation without reboot, and fresh `a1114` / `carbonara` images for both **Nokia 8110 4G (`nokia-argon`)** and **Nokia 2720 Flip (`nokia-beatles`)**.
|
||||||
|
|||||||
@@ -107,14 +107,14 @@ sudo dd if=./images/bananarchy-<device>.img of=/dev/sdX bs=4M status=progress co
|
|||||||
| **D-Pad left / right** | `Left` / `Right` | On empty desktop: switch workspace tags (`-1` / `+1`); in T9 preedit: step back 1 candidate (`Left`) or commit candidate (`Right`); in idle `Ctl` mode: `Home` / `End` |
|
| **D-Pad left / right** | `Left` / `Right` | On empty desktop: switch workspace tags (`-1` / `+1`); in T9 preedit: step back 1 candidate (`Left`) or commit candidate (`Right`); in idle `Ctl` mode: `Home` / `End` |
|
||||||
| **Center OK** | `Return` (`KEY_OK`) | Confirm / Enter, or commit active T9 preedit candidate immediately |
|
| **Center OK** | `Return` (`KEY_OK`) | Confirm / Enter, or commit active T9 preedit candidate immediately |
|
||||||
| **Slider / flip close & open** | `SW_LID` (`lid:on` / `lid:off`) | **Close**: close open menu, turn off main/keypad backlights, and lock phone with passcode (`xlocker`); **Open**: restore screen and keypad backlight and show passcode lock screen |
|
| **Slider / flip close & open** | `SW_LID` (`lid:on` / `lid:off`) | **Close**: close open menu, turn off main/keypad backlights, and lock phone with passcode (`xlocker`); **Open**: restore screen and keypad backlight and show passcode lock screen |
|
||||||
| **2720 Flip outer side keys (closed)** | `KEY_VOLUMEUP` / `KEY_VOLUMEDOWN` / `KEY_POWER` | While the flip is closed, wake the external `240x240` cover display (centered clock, date, battery, and network indicators) for the configured **Screen blank** duration while keeping the internal panel dark |
|
| **2720 Flip outer side keys (closed)** | `KEY_VOLUMEUP` / `KEY_VOLUMEDOWN` / `KEY_POWER` | While the flip is closed, wake the external `240x240` cover display (centered clock, date, battery, and network indicators) for `8 s` (`wake_blank_timeout = 8`, capped below **Config -> Screen blank**) while keeping the internal panel dark |
|
||||||
|
|
||||||
> **Screen blanking, idle blanking, RPM idle standby, passcode locking (`xlocker`), waking, and brightness persistence**:
|
> **Screen blanking, idle blanking, RPM idle standby, passcode locking (`xlocker`), waking, and brightness persistence**:
|
||||||
> While unlocked (and with the lid open), the display blanks automatically after the configured **Screen blank** timeout — **5 minutes by default** — via `dwm`'s own evdev input timer and `bananarchy-idle-blank.sh`. Change it in **Config -> Screen blank** (`Off`, 30 s, 1/5/10/30 min), which writes `~/.config/sxmo/idle_blank_timeout`; `bananarchy-idle-timeout.sh get|label|set <seconds>` does the same from the shell, and `SXMO_UNLOCK_IDLE_TIME` or `~/.cache/sxmo/sxmo.noidle` still override/disable it. Closing the slider/lid or locking from the **Power** menu blanks the panel **immediately** (both `Lock` and `Lock (Screen off)` now use `xlocker screenoff`), and an incoming call or SMS/notification turns it back on **immediately** via `bananarchy-screen-wake.sh`, which also resets `dwm`'s idle timer so it cannot blank again right away. Any keypad, lid or power key also restores the display; if it arrives before the idle-lock delay elapses, the desktop stays unlocked. Blanking now arms the screenlock daemon: `bananarchy-idle-blank.sh` calls `bananarchy-idle-lock.sh arm`, which starts the trusted `sxmo_state.sh set screenoff` transition (`xlocker screenoff` -> `LOCK_BLANK` on `locker.so`) after **30 seconds** of dark panel by default. Set `~/.config/sxmo/idle_lock_delay` with `bananarchy-idle-lock.sh set 0` to lock immediately on blank, any other number of seconds to change the grace period, or `set off` to keep the old blank-without-passcode behaviour. `bananarchy-idle-lock.sh get|label|cancel` reports and cancels the pending lock; `bananarchy-screen-wake.sh`, `bananarchy-idle-blank.sh on` and `sxmo_hook_unlock.sh` cancel it on every wake, and the transition only fires while the panel is still dark. X11 screensaver timeouts stay at `0 0 0`; DPMS is driven by the backlight state. Traditional Linux **`mem` suspend (`/sys/power/state`)** stays disabled (`# CONFIG_SUSPEND is not set` + `/etc/bananarchy-no-deep-standby`) to keep the pmaports module ABI and instant hardware wakeups (stock firmware lacks PSCI `SYSTEM_SUSPEND`); instead, per-core `cpuidle_qcom_spm` Standalone Power Collapse (`L2_ON`) stays active with `< 0.2 ms` wakeup on all GIC SPIs while `serial@78af000` (`console=ttyMSM0`) is disabled so UART clocks never pin XO or `gpll0`. Locking the phone (`Power -> Lock`, `Power -> Lock (Screen off)`, `2x End / Power`, or closing the physical slider) activates the fullscreen `240x320` **Passcode Locker (`xlocker` / `locker.so`)**, which verifies your numeric system password (`147147` by default, checked against `/etc/shadow` via `/usr/bin/bananarchy-verify-passcode`). While locked, there is no keypad, softkey, slider, or power-button bypass (`dmenu`, `xdrawer`, terminal spawning, and desktop shortcuts are blocked, and only incoming calls can temporarily overlay `xcallscreen`). Screen and keypad brightness levels configured in **XDrawer** or **Config -> Brightness** are persisted in `~/.config/sxmo/brightness` and `/tmp/sxmo_saved_brightness` and restored on every wake.
|
> While unlocked (and with the lid open), the display blanks automatically after the configured **Screen blank** timeout — **5 minutes by default** — via `dwm`'s own evdev input timer and `bananarchy-idle-blank.sh`. Change it in **Config -> Screen blank** (`Off`, 30 s, 1/5/10/30 min), which writes `~/.config/sxmo/idle_blank_timeout`; `bananarchy-idle-timeout.sh get|label|set <seconds>` does the same from the shell, and `SXMO_UNLOCK_IDLE_TIME` or `~/.cache/sxmo/sxmo.noidle` still override/disable it. Closing the slider/lid or locking from the **Power** menu blanks the panel **immediately** (both `Lock` and `Lock (Screen off)` now use `xlocker screenoff`), and an incoming call or SMS/notification turns it back on **immediately** via `bananarchy-screen-wake.sh`, which also resets `dwm`'s idle timer so it cannot blank again right away. Any keypad, lid or power key also restores the display; if it arrives before the idle-lock delay elapses, the desktop stays unlocked. Blanking now arms the screenlock daemon: `bananarchy-idle-blank.sh` calls `bananarchy-idle-lock.sh arm`, which starts the trusted `sxmo_state.sh set screenoff` transition (`xlocker screenoff` -> `LOCK_BLANK` on `locker.so`) after **30 seconds** of dark panel by default. Set `~/.config/sxmo/idle_lock_delay` with `bananarchy-idle-lock.sh set 0` to lock immediately on blank, any other number of seconds to change the grace period, or `set off` to keep the old blank-without-passcode behaviour. `bananarchy-idle-lock.sh get|label|cancel` reports and cancels the pending lock; `bananarchy-screen-wake.sh`, `bananarchy-idle-blank.sh on` and `sxmo_hook_unlock.sh` cancel it on every wake, and the transition only fires while the panel is still dark. X11 screensaver timeouts stay at `0 0 0`; DPMS is driven by the backlight state. Traditional Linux **`mem` suspend (`/sys/power/state`)** stays disabled (`# CONFIG_SUSPEND is not set` + `/etc/bananarchy-no-deep-standby`) to keep the pmaports module ABI and instant hardware wakeups (stock firmware lacks PSCI `SYSTEM_SUSPEND`); instead, per-core `cpuidle_qcom_spm` Standalone Power Collapse (`L2_ON`) stays active with `< 0.2 ms` wakeup on all GIC SPIs while `serial@78af000` (`console=ttyMSM0`) is disabled so UART clocks never pin XO or `gpll0`. Locking the phone (`Power -> Lock`, `Power -> Lock (Screen off)`, `2x End / Power`, or closing the physical slider) activates the fullscreen `240x320` **Passcode Locker (`xlocker` / `locker.so`)**, which verifies your numeric system password (`147147` by default, checked against `/etc/shadow` via `/usr/bin/bananarchy-verify-passcode`). While locked, there is no keypad, softkey, slider, or power-button bypass (`dmenu`, `xdrawer`, terminal spawning, and desktop shortcuts are blocked, and only incoming calls can temporarily overlay `xcallscreen`). Screen and keypad brightness levels configured in **XDrawer** or **Config -> Brightness** are persisted in `~/.config/sxmo/brightness` and `/tmp/sxmo_saved_brightness` and restored on every wake.
|
||||||
|
|
||||||
|
|
||||||
> **Runtime power policy (`/etc/bananarchy-power-policy.conf`)**:
|
> **Runtime power policy (`/etc/bananarchy-power-policy.conf`)**:
|
||||||
> `WIFI_LISTEN_INTERVAL` (1-10, default 5) sets the `wcn36xx` beacon listen interval (`max_listen_interval` and `conf.listen_interval`) via `/etc/modprobe.d/10-bananarchy-power.conf`, while `bananarchy-display-power-sync` toggles `/sys/module/wcn36xx/parameters/screen_off_offload` to enable WCN3620 ARP/IPv6-NS/GTK, BET, and DTIM offloads (`HOST_SUSPEND_IND`) while the main panel is dark without suspending host RX. `WIFI_SCREEN_OFF_IPV6_MUTE=1` (default) mutes unsolicited IPv6 router advertisements (`accept_ra=0`) on `wlan0` while dark if `wlan0` already holds an IPv4 address and restores the previous value on wake. `WIFI_STANDBY_RAT=keep` (default; set `gsm` to opt in) optionally parks QMI NAS mode preference to GSM after 30 s of darkness while `wlan0` is `up`, restoring the saved RAT preference on wake. `CPU_RPM_SLEEP=0` and `CPU_L2_SLEEP=0` (both default `0`) control opt-in runtime `/sys/module/cpuidle_qcom_spm/parameters/{rpm_sleep,l2_sleep}` cluster RPM (`vMPM`) and L2 SAW2 sleep handoff; keep `0` by default because per-core SPC with L2 retention already wakes in `< 0.2 ms` on every GIC SPI without collapsing APSS GIC and dropping `smd-edge` modem wakeups during closed-flip standby. `MODEM_DRX_MODE` (default `0`) leaves the firmware's native DSDS paging scheduler untouched without contending with `ModemManager` on open `/dev/wwan0at*` ports; values `6-9` remain opt-in to apply Qualcomm `AT$QCDRX` across all `/dev/wwan0at*` channels (`6` enables ~1.28 s DRX, and `7-9` are progressively longer undocumented paging cycles). The standard `AT+CPSMS` / `AT+CEDRXS` PSM/eDRX commands are not supported by this modem firmware. `DSDS_SECONDARY_MODE=eco` (default `active`) deactivates the secondary SIM's GW provisioning session after `DSDS_PARK_DELAY` seconds (default 300) of a dark panel and restores it on wake; **SIM2 is unreachable while parked**. This uses QMI provisioning sessions, not SIM power-off, so a PIN-locked SIM stays locked. Edit the file as root and run `doas /usr/bin/bananarchy-power-policy.sh apply`, or reboot; `doas /usr/bin/bananarchy-power-policy.sh status` reports the effective values across AT ports, `wcn36xx`, `cpuidle_qcom_spm`, `/sys/kernel/debug/qcom_stats`, and `/sys/kernel/debug/qcom_rpm_master_stats`. See `BATTERY-OPTIMIZATION-ANALYSIS.md` §§15, 20-22.
|
> `WIFI_LISTEN_INTERVAL` (1-10, default 8) sets the `wcn36xx` beacon listen interval (`max_listen_interval` and `conf.listen_interval`) via `/etc/modprobe.d/10-bananarchy-power.conf`, while `bananarchy-display-power-sync` toggles `/sys/module/wcn36xx/parameters/screen_off_offload` (enabling WCN3620 ARP/IPv6-NS/GTK, BET, and DTIM offloads via `HOST_SUSPEND_IND` and suppressing healthy-RSSI background multi-channel roam scans while dark) alongside `/sys/module/pm8916_bms_vm/parameters/screen_off` (hardware S3 OCV sleep while dark and discharging). `WIFI_SCREEN_OFF_IPV6_MUTE=1` (default) mutes unsolicited IPv6 router advertisements (`accept_ra=0`) on `wlan0` while dark if `wlan0` already holds an IPv4 address and restores the previous value on wake. `WIFI_STANDBY_RAT=gsm` (default; set `keep` to disable) parks QMI NAS mode preference to GSM after 45 s of darkness while `wlan0` is `up` (verifying CS registration with automatic fallback on 2G-sunset networks) and restores the saved RAT preference on wake. `CPU_RPM_SLEEP=0` and `CPU_L2_SLEEP=0` (both default `0`) control opt-in runtime `/sys/module/cpuidle_qcom_spm/parameters/{rpm_sleep,l2_sleep}` cluster RPM (`vMPM`) and L2 SAW2 sleep handoff; keep `0` by default because per-core SPC with L2 retention already wakes in `< 0.2 ms` on every GIC SPI without collapsing APSS GIC and dropping `smd-edge` modem wakeups during closed-flip standby. `MODEM_DRX_MODE` (default `0`) leaves the firmware's native DSDS paging scheduler untouched without contending with `ModemManager` on open `/dev/wwan0at*` ports; values `6-9` remain opt-in to apply Qualcomm `AT$QCDRX` across all `/dev/wwan0at*` channels (`6` enables ~1.28 s DRX, and `7-9` are progressively longer undocumented paging cycles). The standard `AT+CPSMS` / `AT+CEDRXS` PSM/eDRX commands are not supported by this modem firmware. `DSDS_SECONDARY_MODE=eco` (default `active`) deactivates the secondary SIM's GW provisioning session after `DSDS_PARK_DELAY` seconds (default 300) of a dark panel and restores it on wake; **SIM2 is unreachable while parked**. This uses QMI provisioning sessions, not SIM power-off, so a PIN-locked SIM stays locked. Edit the file as root and run `doas /usr/bin/bananarchy-power-policy.sh apply`, or reboot; `doas /usr/bin/bananarchy-power-policy.sh status` reports the effective values across AT ports, `wcn36xx`, `cpuidle_qcom_spm`, `/sys/kernel/debug/qcom_stats`, and `/sys/kernel/debug/qcom_rpm_master_stats`. See `BATTERY-OPTIMIZATION-ANALYSIS.md` §§15, 20-23.
|
||||||
|
|
||||||
#### 3.1.1 Window tiling modes and switching combos
|
#### 3.1.1 Window tiling modes and switching combos
|
||||||
By default, `dwm` uses the **vertical bottom-stack (`bstack`, `TTT`)** layout so multiple `st` terminals stack **vertically (one under another)** to preserve full line width on the `240x320` portrait screen.
|
By default, `dwm` uses the **vertical bottom-stack (`bstack`, `TTT`)** layout so multiple `st` terminals stack **vertically (one under another)** to preserve full line width on the `240x320` portrait screen.
|
||||||
@@ -459,7 +459,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`.
|
- **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'`.
|
- **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`, runs `sxmo_state.sh set lock`, and sends `RAISE` to `callscreen.so` when `/tmp/sxmo_call_ringing` or `/tmp/sxmo_active_call` is present. `sxmo_hook_lock.sh` and `locker.so` preserve active calls without triggering `HANGUP_CLOSE` when activating on lock or flip open, so opening the flip during an incoming or active call brings up `callscreen` above the locked desktop without hanging up. 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.
|
- **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`, runs `sxmo_state.sh set lock`, and sends `RAISE` to `callscreen.so` when `/tmp/sxmo_call_ringing` or `/tmp/sxmo_active_call` is present. `sxmo_hook_lock.sh` and `locker.so` preserve active calls without triggering `HANGUP_CLOSE` when activating on lock or flip open, so opening the flip during an incoming or active call brings up `callscreen` above the locked desktop without hanging up. 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`, `CALL`, `REFRESH`, `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 requires `card0-SPI-1/dpms = Off`. When a call arrives while closed (`CALL incoming|...|...|...`), the cover wakes automatically and stays lit past the normal blank timeout showing caller name/number, SIM tag, and side-key hints; pressing external **Volume Up/Down** (`BUTTON VOLUP`/`VOLDOWN` -> `bananarchy-cover-event.sh mute-ring`) mutes the ringer while keeping call state visible, and pressing external **Power**/camera (`BUTTON POWER` -> `bananarchy-cover-event.sh hangup-call`) hangs up without opening the flip. The shipping single-panel DTB uses `backend = kernel`: the KaiOS 3.10 DTS and kernel driver show that the two GC9305s share CS0, gpio110 D/C and one active-high PMIC MPP2 PWM backlight (`kernel_backlight_invert = 0`, `kernel_backlight_level = 14`), while gpio13 selects the panel (high = cover, low = internal), gpio23 is the external reset and gpio21 is TE. Because the internal 240x320 TN panel is normally-white while the external 240x240 panel is normally-black, a closed-flip button event wakes DRM with gpio13 low, paints an X11 `override_redirect` cover window and `/dev/fb0` solid black while leaving the internal GC9305 scanning black GRAM (`kernel_internal_sleep = 0`) so it blocks the shared backlight, switches gpio13 high, pulses gpio23, replays the exact vendor 240x240 init through `/sys/kernel/debug/dri/0/command`, and presents a centered 240x240 clock/date/status or call frame once per second (with live timezone reloads via `ba_refresh_tz()`). `/run/bananarchy/cover-backlight` contains `0` during dark GRAM preparation, `1` while the cover is lit, and is unlinked when dark; `bananarchy-display-power-sync` holds the matching brightness, `bl_power` and DPMS state (honouring `/run/bananarchy/cover-runtime.conf` for runtime `SET` overrides). `STATUS` reports `backend=kernel`, `mux=cover`; `BLANK` (and clean `SIGTERM` shutdown) turns the shared backlight off, sleeps both controllers, parks gpio13 low and forces DPMS Off; `LID OPEN` sleeps the external panel, restores gpio13 low, brightness 14, `bl_power=0`, DPMS On and re-initialises the internal panel to the passcode lockscreen (raising `callscreen` above it if a call is active or ringing). The outer panel stays off until a trusted side-key `BUTTON` / `WAKE` or incoming `CALL` arrives, and blanks dynamically after the same **Config -> Screen blank** timeout (`blank_timeout = auto`, reading `~/.config/sxmo/idle_blank_timeout` and `sxmo.noidle`). The legacy `spidev`, 8/9-bit, `PROBE`, `SET mux_closed_level 0|1`, `SET kernel_backlight_invert 0|1`, `SET kernel_internal_sleep 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`, `scripts/test-lid-gate.py` and `scripts/test-time-timezone-sync.py` guard the state machine, both backends, DT layouts, lid gate and live timezone/network sync 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`, `CALL`, `REFRESH`, `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 requires `card0-SPI-1/dpms = Off`. When a call arrives while closed (`CALL incoming|...|...|...`), the cover wakes automatically and stays lit past the normal blank timeout showing caller name/number, SIM tag, and side-key hints; pressing external **Volume Up/Down** (`BUTTON VOLUP`/`VOLDOWN` -> `bananarchy-cover-event.sh mute-ring`) mutes the ringer while keeping call state visible, and pressing external **Power**/camera (`BUTTON POWER` -> `bananarchy-cover-event.sh hangup-call`) hangs up without opening the flip. The shipping single-panel DTB uses `backend = kernel`: the KaiOS 3.10 DTS and kernel driver show that the two GC9305s share CS0, gpio110 D/C and one active-high PMIC MPP2 PWM backlight (`kernel_backlight_invert = 0`, `kernel_backlight_level = 14`), while gpio13 selects the panel (high = cover, low = internal), gpio23 is the external reset and gpio21 is TE. Because the internal 240x320 TN panel is normally-white while the external 240x240 panel is normally-black, a closed-flip button event wakes DRM with gpio13 low, paints an X11 `override_redirect` cover window and `/dev/fb0` solid black while leaving the internal GC9305 scanning black GRAM (`kernel_internal_sleep = 0`) so it blocks the shared backlight, switches gpio13 high, pulses gpio23, replays the exact vendor 240x240 init through `/sys/kernel/debug/dri/0/command`, and presents a centered 240x240 clock/date/status or call frame once per second (with live timezone reloads via `ba_refresh_tz()`). `/run/bananarchy/cover-backlight` contains `0` during dark GRAM preparation, `1` while the cover is lit, and is unlinked when dark; `bananarchy-display-power-sync` holds the matching brightness, `bl_power` and DPMS state (honouring `/run/bananarchy/cover-runtime.conf` for runtime `SET` overrides). `STATUS` reports `backend=kernel`, `mux=cover`; `BLANK` (and clean `SIGTERM` shutdown) turns the shared backlight off, sleeps both controllers, parks gpio13 low and forces DPMS Off; `LID OPEN` sleeps the external panel, restores gpio13 low, brightness 14, `bl_power=0`, DPMS On and re-initialises the internal panel to the passcode lockscreen (raising `callscreen` above it if a call is active or ringing). The outer panel stays off until a trusted side-key `BUTTON` / `WAKE` or incoming `CALL` arrives: passive closed-flip wakes (`BUTTON` / `WAKE` / `NOTIFY` / `SMS`) auto-blank after `wake_blank_timeout = 8` s, active calls stay awake until hung up or opened, and explicit `UNBLANK` wakes follow **Config -> Screen blank** (`blank_timeout = auto`, reading `~/.config/sxmo/idle_blank_timeout` and `sxmo.noidle`). The legacy `spidev`, 8/9-bit, `PROBE`, `SET mux_closed_level 0|1`, `SET kernel_backlight_invert 0|1`, `SET kernel_internal_sleep 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`, `scripts/test-lid-gate.py` and `scripts/test-time-timezone-sync.py` guard the state machine, both backends, DT layouts, lid gate and live timezone/network sync 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 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).
|
- **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).
|
||||||
|
|||||||
Binary file not shown.
@@ -383,6 +383,7 @@
|
|||||||
l8 {
|
l8 {
|
||||||
regulator-min-microvolt = <0x2b7cd0>;
|
regulator-min-microvolt = <0x2b7cd0>;
|
||||||
regulator-max-microvolt = <0x2c4020>;
|
regulator-max-microvolt = <0x2c4020>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x49>;
|
phandle = <0x49>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -409,6 +410,7 @@
|
|||||||
l12 {
|
l12 {
|
||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x51>;
|
phandle = <0x51>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -384,6 +384,7 @@
|
|||||||
l8 {
|
l8 {
|
||||||
regulator-min-microvolt = <0x2b7cd0>;
|
regulator-min-microvolt = <0x2b7cd0>;
|
||||||
regulator-max-microvolt = <0x2c4020>;
|
regulator-max-microvolt = <0x2c4020>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x49>;
|
phandle = <0x49>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -410,6 +411,7 @@
|
|||||||
l12 {
|
l12 {
|
||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x51>;
|
phandle = <0x51>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -384,6 +384,7 @@
|
|||||||
l8 {
|
l8 {
|
||||||
regulator-min-microvolt = <0x2b7cd0>;
|
regulator-min-microvolt = <0x2b7cd0>;
|
||||||
regulator-max-microvolt = <0x2c4020>;
|
regulator-max-microvolt = <0x2c4020>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x49>;
|
phandle = <0x49>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -410,6 +411,7 @@
|
|||||||
l12 {
|
l12 {
|
||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x51>;
|
phandle = <0x51>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -387,6 +387,7 @@
|
|||||||
l8 {
|
l8 {
|
||||||
regulator-min-microvolt = <0x2b7cd0>;
|
regulator-min-microvolt = <0x2b7cd0>;
|
||||||
regulator-max-microvolt = <0x2c4020>;
|
regulator-max-microvolt = <0x2c4020>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x3c>;
|
phandle = <0x3c>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -413,6 +414,7 @@
|
|||||||
l12 {
|
l12 {
|
||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x45>;
|
phandle = <0x45>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -387,6 +387,7 @@
|
|||||||
l8 {
|
l8 {
|
||||||
regulator-min-microvolt = <0x2b7cd0>;
|
regulator-min-microvolt = <0x2b7cd0>;
|
||||||
regulator-max-microvolt = <0x2c4020>;
|
regulator-max-microvolt = <0x2c4020>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x3c>;
|
phandle = <0x3c>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -413,6 +414,7 @@
|
|||||||
l12 {
|
l12 {
|
||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x45>;
|
phandle = <0x45>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -383,6 +383,7 @@
|
|||||||
l8 {
|
l8 {
|
||||||
regulator-min-microvolt = <0x2b7cd0>;
|
regulator-min-microvolt = <0x2b7cd0>;
|
||||||
regulator-max-microvolt = <0x2c4020>;
|
regulator-max-microvolt = <0x2c4020>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x49>;
|
phandle = <0x49>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -409,6 +410,7 @@
|
|||||||
l12 {
|
l12 {
|
||||||
regulator-min-microvolt = <0x1b7740>;
|
regulator-min-microvolt = <0x1b7740>;
|
||||||
regulator-max-microvolt = <0x2d0370>;
|
regulator-max-microvolt = <0x2d0370>;
|
||||||
|
regulator-allow-set-load;
|
||||||
phandle = <0x51>;
|
phandle = <0x51>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+32740
-32740
File diff suppressed because it is too large.
Load diff
Binary file not shown.
Binary file not shown.
@@ -4,9 +4,7 @@ level=OFF
|
|||||||
[connection]
|
[connection]
|
||||||
wifi.powersave=3
|
wifi.powersave=3
|
||||||
|
|
||||||
[device]
|
# Associated multi-channel background roam scans are suppressed in kernel
|
||||||
# U8: roam scans are expensive on wcn36xx; 10 min while associated.
|
# wcn36xx while screen_off_offload=Y and RSSI is healthy.
|
||||||
wifi.scan-interval=600
|
|
||||||
|
|
||||||
[connectivity]
|
[connectivity]
|
||||||
enabled=false
|
enabled=false
|
||||||
@@ -2,6 +2,14 @@
|
|||||||
# Ensure the QMI BAM-DMUX data port is open on cellular up; never close it on
|
# Ensure the QMI BAM-DMUX data port is open on cellular up; never close it on
|
||||||
# down because unregistering net/wwan0 causes ModemManager (qcom-soc) to drop
|
# down because unregistering net/wwan0 causes ModemManager (qcom-soc) to drop
|
||||||
# the modem object, and bam-dmux already runtime-suspends in 1000 ms when idle.
|
# the modem object, and bam-dmux already runtime-suspends in 1000 ms when idle.
|
||||||
|
# Unpark standby RAT immediately if Wi-Fi drops while the flip is closed.
|
||||||
|
if [ "$1" = "wlan0" ]; then
|
||||||
|
case "$2" in
|
||||||
|
down|pre-down) /usr/bin/bananarchy-power-policy.sh unpark-rat >/dev/null 2>&1 & ;;
|
||||||
|
up|dhcp4-change) /usr/bin/bananarchy-power-policy.sh wifi-up >/dev/null 2>&1 & ;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
[ "$1" = "qrtr0" ] || [ "$1" = "wwan0" ] || exit 0
|
[ "$1" = "qrtr0" ] || [ "$1" = "wwan0" ] || exit 0
|
||||||
case "$2" in
|
case "$2" in
|
||||||
up|vpn-up) /usr/bin/bananarchy-dpm.sh open ;;
|
up|vpn-up) /usr/bin/bananarchy-dpm.sh open ;;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# wakeups but delay inbound packets. 0 removes the module option and uses
|
# wakeups but delay inbound packets. 0 removes the module option and uses
|
||||||
# the driver default. Applied at module load, so changes need a reboot or
|
# the driver default. Applied at module load, so changes need a reboot or
|
||||||
# a wcn36xx module reload.
|
# a wcn36xx module reload.
|
||||||
WIFI_LISTEN_INTERVAL=5
|
WIFI_LISTEN_INTERVAL=8
|
||||||
|
|
||||||
# Qualcomm modem DRX mode via AT$QCDRX (0, 6-9). 0 = firmware DSDS paging
|
# Qualcomm modem DRX mode via AT$QCDRX (0, 6-9). 0 = firmware DSDS paging
|
||||||
# default (avoids competing with ModemManager on open /dev/wwan0at* ports).
|
# default (avoids competing with ModemManager on open /dev/wwan0at* ports).
|
||||||
@@ -39,5 +39,6 @@ WIFI_SCREEN_OFF_IPV6_MUTE=1
|
|||||||
|
|
||||||
# Opt-in modem RAT parking while the screen is off and wlan0 is up:
|
# Opt-in modem RAT parking while the screen is off and wlan0 is up:
|
||||||
# keep = keep current RAT preference (default)
|
# keep = keep current RAT preference (default)
|
||||||
# gsm = park NAS mode preference to GSM after 30 s dark on Wi-Fi, restore on wake
|
# gsm = park NAS mode preference to GSM after 45 s dark on Wi-Fi (with CS
|
||||||
WIFI_STANDBY_RAT=keep
|
# registration verification and auto-fallback on 2G-sunset networks)
|
||||||
|
WIFI_STANDBY_RAT=gsm
|
||||||
@@ -81,6 +81,9 @@ brightness = 160
|
|||||||
# Follow Config -> Screen blank (~/.config/sxmo/idle_blank_timeout, default
|
# Follow Config -> Screen blank (~/.config/sxmo/idle_blank_timeout, default
|
||||||
# 300 s, 0 = never). A numeric value here overrides it for the cover panel.
|
# 300 s, 0 = never). A numeric value here overrides it for the cover panel.
|
||||||
blank_timeout = auto
|
blank_timeout = auto
|
||||||
|
# Cap passive closed-flip wakes (BUTTON/WAKE/NOTIFY/SMS) to 8 s so checking
|
||||||
|
# the outer clock never burns 30+ s of display + X11 power.
|
||||||
|
wake_blank_timeout = 8
|
||||||
# Optional sysfs node for a separate legacy cover backlight. Empty on the
|
# Optional sysfs node for a separate legacy cover backlight. Empty on the
|
||||||
# shipping image: the kernel backend uses kernel_backlight_path above.
|
# shipping image: the kernel backend uses kernel_backlight_path above.
|
||||||
backlight_path =
|
backlight_path =
|
||||||
+166
@@ -0,0 +1,166 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Rebuild modules.dep* and modules.alias* inside each initramfs cpio archive
|
||||||
|
# so udevd does not try to load modules absent from the initramfs image.
|
||||||
|
|
||||||
|
resolve_depmod() {
|
||||||
|
for cand in /tmp/hostbin/depmod /sbin/depmod /usr/sbin/depmod; do
|
||||||
|
if [ -x "$cand" ]; then
|
||||||
|
printf '%s\n' "$cand"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if command -v depmod >/dev/null 2>&1; then
|
||||||
|
command -v depmod
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
DEPMOD_BIN=$(resolve_depmod || true)
|
||||||
|
if [ -z "$DEPMOD_BIN" ]; then
|
||||||
|
echo "10-initramfs-depmod: depmod not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
collect_targets() {
|
||||||
|
if [ "$#" -gt 0 ]; then
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [ -f "$arg" ]; then
|
||||||
|
printf '%s\n' "$arg"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${work_dir:-}" ] && [ -d "${work_dir:-}" ]; then
|
||||||
|
name="${initfs_filename:-initramfs}"
|
||||||
|
if [ -f "$work_dir/$name" ]; then
|
||||||
|
printf '%s\n' "$work_dir/$name"
|
||||||
|
fi
|
||||||
|
if [ -f "$work_dir/${name}-extra" ]; then
|
||||||
|
printf '%s\n' "$work_dir/${name}-extra"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for search_root in "${TMPDIR:-/tmp}" /tmp; do
|
||||||
|
[ -d "$search_root" ] || continue
|
||||||
|
for dir in "$search_root"/*; do
|
||||||
|
[ -d "$dir" ] && [ ! -L "$dir" ] || continue
|
||||||
|
case "$dir" in
|
||||||
|
*/hostbin|*/initramfs-depmod.*)
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
[ -f "$dir/initramfs" ] || continue
|
||||||
|
has_vmlinuz=0
|
||||||
|
for kern in "$dir"/vmlinuz*; do
|
||||||
|
if [ -f "$kern" ]; then
|
||||||
|
has_vmlinuz=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ "$has_vmlinuz" -eq 1 ] || continue
|
||||||
|
printf '%s\n' "$dir/initramfs"
|
||||||
|
if [ -f "$dir/initramfs-extra" ]; then
|
||||||
|
printf '%s\n' "$dir/initramfs-extra"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ "$search_root" = "/tmp" ] && break
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
verify_modules_dep() {
|
||||||
|
moddir="$1"
|
||||||
|
depfile="$moddir/modules.dep"
|
||||||
|
if [ ! -s "$depfile" ]; then
|
||||||
|
echo "10-initramfs-depmod: empty modules.dep in $moddir" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
while IFS= read -r line; do
|
||||||
|
[ -n "$line" ] || continue
|
||||||
|
for tok in $line; do
|
||||||
|
tok="${tok%:}"
|
||||||
|
[ -n "$tok" ] || continue
|
||||||
|
if [ ! -e "$moddir/$tok" ]; then
|
||||||
|
echo "10-initramfs-depmod: missing module in initramfs: $tok" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done < "$depfile"
|
||||||
|
}
|
||||||
|
|
||||||
|
process_archive() {
|
||||||
|
case "$1" in
|
||||||
|
/*)
|
||||||
|
archive="$1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
archive="$(pwd)/$1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
[ -f "$archive" ] || return 0
|
||||||
|
|
||||||
|
work=$(mktemp -d /tmp/initramfs-depmod.XXXXXX)
|
||||||
|
stage="$work/stage"
|
||||||
|
out="$work/initramfs.new"
|
||||||
|
mkdir -p "$stage"
|
||||||
|
|
||||||
|
if ! (cd "$stage" && gzip -dc "$archive" | cpio -idm 2>/dev/null); then
|
||||||
|
rm -rf "$work"
|
||||||
|
echo "10-initramfs-depmod: failed to unpack $archive" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
repacked=0
|
||||||
|
for base in "$stage/usr/lib/modules" "$stage/lib/modules"; do
|
||||||
|
[ -d "$base" ] && [ ! -L "$base" ] || continue
|
||||||
|
for moddir in "$base"/*; do
|
||||||
|
[ -d "$moddir/kernel" ] || continue
|
||||||
|
kver="${moddir##*/}"
|
||||||
|
if ! "$DEPMOD_BIN" -b "$stage" "$kver"; then
|
||||||
|
rm -rf "$work"
|
||||||
|
echo "10-initramfs-depmod: depmod failed for $kver in $archive" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if ! verify_modules_dep "$moddir"; then
|
||||||
|
rm -rf "$work"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
repacked=1
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$repacked" -eq 1 ]; then
|
||||||
|
if ! (
|
||||||
|
cd "$stage" &&
|
||||||
|
find . | sed -e '/^\.$/d' -e 's|^\./||' | LC_ALL=C sort |
|
||||||
|
cpio -o -H newc 2>/dev/null | gzip -n -6 > "$out"
|
||||||
|
); then
|
||||||
|
rm -rf "$work"
|
||||||
|
echo "10-initramfs-depmod: failed to repack $archive" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
chmod 0644 "$out"
|
||||||
|
mv -f "$out" "$archive"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "$work"
|
||||||
|
}
|
||||||
|
|
||||||
|
targets=$(collect_targets "$@")
|
||||||
|
if [ -z "$targets" ]; then
|
||||||
|
if [ "$#" -gt 0 ]; then
|
||||||
|
echo "10-initramfs-depmod: no readable target archive in arguments" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "10-initramfs-depmod: no initramfs staging archive found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%s\n' "$targets" | while IFS= read -r target; do
|
||||||
|
[ -n "$target" ] || continue
|
||||||
|
process_archive "$target"
|
||||||
|
done
|
||||||
@@ -12,6 +12,6 @@ depend() {
|
|||||||
|
|
||||||
start() {
|
start() {
|
||||||
ebegin "Selecting UIM slot"
|
ebegin "Selecting UIM slot"
|
||||||
SIM_WAIT_TIME="${sim_wait_time:-4}" timeout 15 /usr/libexec/msm-modem-uim-selection boot >/dev/null 2>&1 || true
|
SIM_WAIT_TIME="${sim_wait_time:-4}" timeout 25 /usr/libexec/msm-modem-uim-selection boot >/dev/null 2>&1 || true
|
||||||
eend 0
|
eend 0
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ start() {
|
|||||||
|
|
||||||
QMICLI_MODEM=""
|
QMICLI_MODEM=""
|
||||||
count=0
|
count=0
|
||||||
while [ -z "$QMICLI_MODEM" ] && [ "$count" -lt 15 ]; do
|
while [ -z "$QMICLI_MODEM" ] && [ "$count" -lt 25 ]; do
|
||||||
if timeout 3 qmicli --silent -pd qrtr://0 --uim-noop >/dev/null 2>&1; then
|
if timeout 3 qmicli --silent -pd qrtr://0 --uim-noop >/dev/null 2>&1; then
|
||||||
QMICLI_MODEM="timeout 4 qmicli --silent -pd qrtr://0"
|
QMICLI_MODEM="timeout 4 qmicli --silent -pd qrtr://0"
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
# Generated by bananarchy-power-policy.sh from /etc/bananarchy-power-policy.conf
|
# Generated by bananarchy-power-policy.sh from /etc/bananarchy-power-policy.conf
|
||||||
options wcn36xx listen_interval=5
|
options wcn36xx listen_interval=8
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -18,6 +18,7 @@ GPU_GOV_PATH=/sys/class/devfreq/1c00000.gpu/governor
|
|||||||
WIFI_OFFLOAD_PATH=/sys/module/wcn36xx/parameters/screen_off_offload
|
WIFI_OFFLOAD_PATH=/sys/module/wcn36xx/parameters/screen_off_offload
|
||||||
SPM_SCREEN_OFF_PATH=/sys/module/cpuidle_qcom_spm/parameters/screen_off
|
SPM_SCREEN_OFF_PATH=/sys/module/cpuidle_qcom_spm/parameters/screen_off
|
||||||
SPM_RPM_SLEEP_PATH=/sys/module/cpuidle_qcom_spm/parameters/rpm_sleep
|
SPM_RPM_SLEEP_PATH=/sys/module/cpuidle_qcom_spm/parameters/rpm_sleep
|
||||||
|
BMS_SCREEN_OFF_PATH=/sys/module/pm8916_bms_vm/parameters/screen_off
|
||||||
COVER_MARKER=/run/bananarchy/cover-backlight
|
COVER_MARKER=/run/bananarchy/cover-backlight
|
||||||
FORCE_MARKER=/run/bananarchy/cover-bl-force
|
FORCE_MARKER=/run/bananarchy/cover-bl-force
|
||||||
STATE_CACHE=/run/bananarchy/cover-power-state
|
STATE_CACHE=/run/bananarchy/cover-power-state
|
||||||
@@ -58,6 +59,7 @@ done
|
|||||||
[ -n "${BANANARCHY_WIFI_OFFLOAD_PATH:-}" ] && WIFI_OFFLOAD_PATH="$BANANARCHY_WIFI_OFFLOAD_PATH"
|
[ -n "${BANANARCHY_WIFI_OFFLOAD_PATH:-}" ] && WIFI_OFFLOAD_PATH="$BANANARCHY_WIFI_OFFLOAD_PATH"
|
||||||
[ -n "${BANANARCHY_SPM_SCREEN_OFF_PATH:-}" ] && SPM_SCREEN_OFF_PATH="$BANANARCHY_SPM_SCREEN_OFF_PATH"
|
[ -n "${BANANARCHY_SPM_SCREEN_OFF_PATH:-}" ] && SPM_SCREEN_OFF_PATH="$BANANARCHY_SPM_SCREEN_OFF_PATH"
|
||||||
[ -n "${BANANARCHY_SPM_RPM_SLEEP_PATH:-}" ] && SPM_RPM_SLEEP_PATH="$BANANARCHY_SPM_RPM_SLEEP_PATH"
|
[ -n "${BANANARCHY_SPM_RPM_SLEEP_PATH:-}" ] && SPM_RPM_SLEEP_PATH="$BANANARCHY_SPM_RPM_SLEEP_PATH"
|
||||||
|
[ -n "${BANANARCHY_BMS_SCREEN_OFF_PATH:-}" ] && BMS_SCREEN_OFF_PATH="$BANANARCHY_BMS_SCREEN_OFF_PATH"
|
||||||
[ -n "${BANANARCHY_LID_STATE:-}" ] && LID_STATE="$BANANARCHY_LID_STATE"
|
[ -n "${BANANARCHY_LID_STATE:-}" ] && LID_STATE="$BANANARCHY_LID_STATE"
|
||||||
[ -n "${BANANARCHY_COVER_MARKER:-}" ] && COVER_MARKER="$BANANARCHY_COVER_MARKER"
|
[ -n "${BANANARCHY_COVER_MARKER:-}" ] && COVER_MARKER="$BANANARCHY_COVER_MARKER"
|
||||||
[ -n "${BANANARCHY_FORCE_MARKER:-}" ] && FORCE_MARKER="$BANANARCHY_FORCE_MARKER"
|
[ -n "${BANANARCHY_FORCE_MARKER:-}" ] && FORCE_MARKER="$BANANARCHY_FORCE_MARKER"
|
||||||
@@ -98,6 +100,12 @@ sync_spm_screen_off() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sync_bms_screen_off() {
|
||||||
|
_want="$1"
|
||||||
|
[ -w "$BMS_SCREEN_OFF_PATH" ] || return 0
|
||||||
|
set_if_changed "$BMS_SCREEN_OFF_PATH" "$_want"
|
||||||
|
}
|
||||||
|
|
||||||
cleanup_force() {
|
cleanup_force() {
|
||||||
rm -f "$FORCE_MARKER" 2>/dev/null || true
|
rm -f "$FORCE_MARKER" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
@@ -119,12 +127,14 @@ if [ "$(read_value "$LID_PROFILE")" != "flip" ]; then
|
|||||||
if [ "$br" -eq 0 ]; then
|
if [ "$br" -eq 0 ]; then
|
||||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "powersave"
|
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "powersave"
|
||||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "Y"
|
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "Y"
|
||||||
|
sync_bms_screen_off "Y"
|
||||||
force_dpms "Off"
|
force_dpms "Off"
|
||||||
sync_spm_screen_off "Y"
|
sync_spm_screen_off "Y"
|
||||||
else
|
else
|
||||||
sync_spm_screen_off "N"
|
sync_spm_screen_off "N"
|
||||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
|
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
|
||||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
|
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
|
||||||
|
sync_bms_screen_off "N"
|
||||||
force_dpms "On"
|
force_dpms "On"
|
||||||
sync_schedutil_rate_limit "40000"
|
sync_schedutil_rate_limit "40000"
|
||||||
fi
|
fi
|
||||||
@@ -226,6 +236,11 @@ if [ "$DESIRED_DPMS" = "Off" ] || [ "$marker" = "0" ] || [ "$marker" = "1" ]; th
|
|||||||
else
|
else
|
||||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
|
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
|
||||||
fi
|
fi
|
||||||
|
if [ "$DESIRED_DPMS" = "Off" ] && [ "$marker" != "0" ] && [ "$marker" != "1" ]; then
|
||||||
|
sync_bms_screen_off "Y"
|
||||||
|
else
|
||||||
|
sync_bms_screen_off "N"
|
||||||
|
fi
|
||||||
if [ "$DESIRED_DPMS" != "Off" ]; then
|
if [ "$DESIRED_DPMS" != "Off" ]; then
|
||||||
sync_spm_screen_off "N"
|
sync_spm_screen_off "N"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Binary file not shown.
@@ -3,9 +3,9 @@
|
|||||||
# Runs as root; re-execs through doas -n when called from the X session.
|
# Runs as root; re-execs through doas -n when called from the X session.
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
CONF=/etc/bananarchy-power-policy.conf
|
CONF="${BANANARCHY_POWER_CONF:-/etc/bananarchy-power-policy.conf}"
|
||||||
MODPROBE=/etc/modprobe.d/10-bananarchy-power.conf
|
MODPROBE="${BANANARCHY_MODPROBE_CONF:-/etc/modprobe.d/10-bananarchy-power.conf}"
|
||||||
RUNDIR=/run/bananarchy-power-policy
|
RUNDIR="${BANANARCHY_POWER_RUNDIR:-/run/bananarchy-power-policy}"
|
||||||
PARKED="$RUNDIR/parked"
|
PARKED="$RUNDIR/parked"
|
||||||
AIDFILE="$RUNDIR/secondary.aid"
|
AIDFILE="$RUNDIR/secondary.aid"
|
||||||
SLOTFILE="$RUNDIR/secondary.slot"
|
SLOTFILE="$RUNDIR/secondary.slot"
|
||||||
@@ -13,26 +13,32 @@ TOKEN="$RUNDIR/token"
|
|||||||
RAT_PARKED="$RUNDIR/rat_parked"
|
RAT_PARKED="$RUNDIR/rat_parked"
|
||||||
RAT_SAVED="$RUNDIR/saved_rat"
|
RAT_SAVED="$RUNDIR/saved_rat"
|
||||||
RAT_TOKEN="$RUNDIR/rat.token"
|
RAT_TOKEN="$RUNDIR/rat.token"
|
||||||
|
GSM_UNSUPPORTED="$RUNDIR/gsm_unsupported"
|
||||||
IPV6_RA_SAVED="$RUNDIR/wlan0_accept_ra"
|
IPV6_RA_SAVED="$RUNDIR/wlan0_accept_ra"
|
||||||
BOOTTOKEN="$RUNDIR/boot.token"
|
BOOTTOKEN="$RUNDIR/boot.token"
|
||||||
READYSTAMP="$RUNDIR/modem_ready.stamp"
|
READYSTAMP="$RUNDIR/modem_ready.stamp"
|
||||||
DRXLOCK="$RUNDIR/lock.drx"
|
DRXLOCK="$RUNDIR/lock.drx"
|
||||||
ACCEPT_RA=/proc/sys/net/ipv6/conf/wlan0/accept_ra
|
ACCEPT_RA="${BANANARCHY_ACCEPT_RA_PATH:-/proc/sys/net/ipv6/conf/wlan0/accept_ra}"
|
||||||
SPM_PARAM_DIR=/sys/module/cpuidle_qcom_spm/parameters
|
SPM_PARAM_DIR="${BANANARCHY_SPM_PARAM_DIR:-/sys/module/cpuidle_qcom_spm/parameters}"
|
||||||
QMI="timeout 8 qmicli --silent -pd qrtr://0"
|
WLAN_OPERSTATE_PATH="${BANANARCHY_WLAN_OPERSTATE_PATH:-/sys/class/net/wlan0/operstate}"
|
||||||
|
WIFI_OFFLOAD_PATH="${BANANARCHY_WIFI_OFFLOAD_PATH:-/sys/module/wcn36xx/parameters/screen_off_offload}"
|
||||||
|
WIFI_LISTEN_SYSFS="${BANANARCHY_WIFI_LISTEN_SYSFS:-/sys/module/wcn36xx/parameters/listen_interval}"
|
||||||
|
CALLS_DIR="${BANANARCHY_CALLS_DIR:-/run/user/10000/sxmo_calls}"
|
||||||
|
DSDS_BIN="${BANANARCHY_DSDS_BIN:-/usr/bin/bananarchy-dsds}"
|
||||||
|
QMI="${BANANARCHY_QMICLI_BIN:-timeout 8 qmicli --silent -pd qrtr://0}"
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "${BANANARCHY_POWER_NO_ROOT:-0}" != "1" ] && [ "$(id -u)" != "0" ]; then
|
||||||
exec doas -n "$0" "$@"
|
exec doas -n "$0" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
WIFI_LISTEN_INTERVAL=5
|
WIFI_LISTEN_INTERVAL=8
|
||||||
MODEM_DRX_MODE=0
|
MODEM_DRX_MODE=0
|
||||||
DSDS_SECONDARY_MODE=active
|
DSDS_SECONDARY_MODE=active
|
||||||
DSDS_PARK_DELAY=300
|
DSDS_PARK_DELAY=300
|
||||||
CPU_RPM_SLEEP=0
|
CPU_RPM_SLEEP=0
|
||||||
CPU_L2_SLEEP=0
|
CPU_L2_SLEEP=0
|
||||||
WIFI_SCREEN_OFF_IPV6_MUTE=1
|
WIFI_SCREEN_OFF_IPV6_MUTE=1
|
||||||
WIFI_STANDBY_RAT=keep
|
WIFI_STANDBY_RAT=gsm
|
||||||
[ -r "$CONF" ] && . "$CONF"
|
[ -r "$CONF" ] && . "$CONF"
|
||||||
|
|
||||||
mkdir -p "$RUNDIR" 2>/dev/null || true
|
mkdir -p "$RUNDIR" 2>/dev/null || true
|
||||||
@@ -44,7 +50,7 @@ log() {
|
|||||||
write_modprobe() {
|
write_modprobe() {
|
||||||
n="$WIFI_LISTEN_INTERVAL"
|
n="$WIFI_LISTEN_INTERVAL"
|
||||||
case "$n" in ''|*[!0-9]*) n=0 ;; esac
|
case "$n" in ''|*[!0-9]*) n=0 ;; esac
|
||||||
if [ "$n" -lt 1 ] || [ "$n" -gt 10 ]; then
|
if [ "$n" -lt 1 ] || [ "$n" -gt 20 ]; then
|
||||||
n=0
|
n=0
|
||||||
fi
|
fi
|
||||||
if [ "$n" = "0" ]; then
|
if [ "$n" = "0" ]; then
|
||||||
@@ -54,6 +60,7 @@ write_modprobe() {
|
|||||||
mkdir -p "$(dirname "$MODPROBE")" 2>/dev/null || true
|
mkdir -p "$(dirname "$MODPROBE")" 2>/dev/null || true
|
||||||
printf '# Generated by bananarchy-power-policy.sh from %s\n' "$CONF" > "$MODPROBE" || return 1
|
printf '# Generated by bananarchy-power-policy.sh from %s\n' "$CONF" > "$MODPROBE" || return 1
|
||||||
printf 'options wcn36xx listen_interval=%s\n' "$n" >> "$MODPROBE" || return 1
|
printf 'options wcn36xx listen_interval=%s\n' "$n" >> "$MODPROBE" || return 1
|
||||||
|
[ -w "$WIFI_LISTEN_SYSFS" ] && printf '%s\n' "$n" > "$WIFI_LISTEN_SYSFS" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_modem_drx() {
|
apply_modem_drx() {
|
||||||
@@ -206,11 +213,38 @@ restore_wifi_ipv6_ra() {
|
|||||||
rm -f "$IPV6_RA_SAVED" 2>/dev/null || true
|
rm -f "$IPV6_RA_SAVED" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
has_active_call() {
|
||||||
|
[ -d "$CALLS_DIR" ] || return 1
|
||||||
|
for _cf in "$CALLS_DIR"/*; do
|
||||||
|
[ -f "$_cf" ] || continue
|
||||||
|
case "${_cf##*/}" in
|
||||||
|
*ended*|*hangedup*|*terminated*) continue ;;
|
||||||
|
esac
|
||||||
|
if [ -s "$_cf" ] && grep -qiE 'ended|hangedup|terminated' "$_cf" 2>/dev/null; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
is_screen_off_standby() {
|
||||||
|
if [ -r "$WIFI_OFFLOAD_PATH" ]; then
|
||||||
|
_wo=""
|
||||||
|
IFS= read -r _wo < "$WIFI_OFFLOAD_PATH" 2>/dev/null || _wo=""
|
||||||
|
[ "$_wo" = "Y" ] || [ "$_wo" = "1" ]
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
[ -f /tmp/bananarchy_screen_blanked ] || [ -f /tmp/bananarchy_screen_locked ]
|
||||||
|
}
|
||||||
|
|
||||||
park_wifi_rat() {
|
park_wifi_rat() {
|
||||||
[ "$WIFI_STANDBY_RAT" = "gsm" ] || return 0
|
[ "$WIFI_STANDBY_RAT" = "gsm" ] || return 0
|
||||||
[ -f "$RAT_PARKED" ] && return 0
|
[ -f "$RAT_PARKED" ] && return 0
|
||||||
|
[ -f "$GSM_UNSUPPORTED" ] && return 0
|
||||||
|
has_active_call && return 0
|
||||||
oper=""
|
oper=""
|
||||||
[ -r /sys/class/net/wlan0/operstate ] && { IFS= read -r oper < /sys/class/net/wlan0/operstate 2>/dev/null || oper=""; }
|
[ -r "$WLAN_OPERSTATE_PATH" ] && { IFS= read -r oper < "$WLAN_OPERSTATE_PATH" 2>/dev/null || oper=""; }
|
||||||
[ "$oper" = "up" ] || return 0
|
[ "$oper" = "up" ] || return 0
|
||||||
saved_rat="$($QMI --nas-get-system-selection-preference 2>/dev/null | awk -F"'" '
|
saved_rat="$($QMI --nas-get-system-selection-preference 2>/dev/null | awk -F"'" '
|
||||||
/Mode preference:/ { gsub(/[[:space:]]*,[[:space:]]*/, "|", $2); print $2; exit }
|
/Mode preference:/ { gsub(/[[:space:]]*,[[:space:]]*/, "|", $2); print $2; exit }
|
||||||
@@ -218,14 +252,47 @@ park_wifi_rat() {
|
|||||||
[ -n "$saved_rat" ] || saved_rat="gsm|umts|lte"
|
[ -n "$saved_rat" ] || saved_rat="gsm|umts|lte"
|
||||||
[ "$saved_rat" = "gsm" ] && return 0
|
[ "$saved_rat" = "gsm" ] && return 0
|
||||||
printf '%s\n' "$saved_rat" > "$RAT_SAVED" 2>/dev/null || true
|
printf '%s\n' "$saved_rat" > "$RAT_SAVED" 2>/dev/null || true
|
||||||
if $QMI --nas-set-system-selection-preference='gsm' >/dev/null 2>&1; then
|
if ! $QMI --nas-set-system-selection-preference='gsm' >/dev/null 2>&1; then
|
||||||
|
rm -f "$RAT_SAVED" 2>/dev/null || true
|
||||||
|
log "failed to park Wi-Fi standby RAT to gsm"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
poll_sec="${BANANARCHY_RAT_REG_POLL_SEC:-3}"
|
||||||
|
reg_ok=0
|
||||||
|
aborted=0
|
||||||
|
i=0
|
||||||
|
while [ "$i" -lt 5 ]; do
|
||||||
|
[ "$poll_sec" = "0" ] || sleep "$poll_sec"
|
||||||
|
cur_oper=""
|
||||||
|
[ -r "$WLAN_OPERSTATE_PATH" ] && { IFS= read -r cur_oper < "$WLAN_OPERSTATE_PATH" 2>/dev/null || cur_oper=""; }
|
||||||
|
if [ "$cur_oper" != "up" ] || ! is_screen_off_standby || has_active_call; then
|
||||||
|
aborted=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
srv="$($QMI --nas-get-serving-system 2>/dev/null || true)"
|
||||||
|
if printf '%s\n' "$srv" | grep -q "Registration state: 'registered'"; then
|
||||||
|
reg_ok=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
|
if [ "$aborted" -eq 1 ]; then
|
||||||
|
$QMI --nas-set-system-selection-preference="$saved_rat" >/dev/null 2>&1 || true
|
||||||
|
rm -f "$RAT_PARKED" "$RAT_SAVED" 2>/dev/null || true
|
||||||
|
log "Wi-Fi standby RAT parking aborted before registration (restored $saved_rat)"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [ "$reg_ok" -eq 1 ]; then
|
||||||
: > "$RAT_PARKED"
|
: > "$RAT_PARKED"
|
||||||
log "Wi-Fi standby RAT parked to gsm (saved: $saved_rat)"
|
log "Wi-Fi standby RAT parked to gsm (saved: $saved_rat)"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
rm -f "$RAT_SAVED" 2>/dev/null || true
|
$QMI --nas-set-system-selection-preference="$saved_rat" >/dev/null 2>&1 || true
|
||||||
log "failed to park Wi-Fi standby RAT to gsm"
|
rm -f "$RAT_PARKED" "$RAT_SAVED" 2>/dev/null || true
|
||||||
return 1
|
: > "$GSM_UNSUPPORTED" 2>/dev/null || true
|
||||||
|
logger -t bananarchy-power "GSM standby registration failed; falling back to $saved_rat" 2>/dev/null || true
|
||||||
|
log "GSM registration unavailable; falling back to $saved_rat"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
unpark_wifi_rat() {
|
unpark_wifi_rat() {
|
||||||
@@ -241,21 +308,27 @@ unpark_wifi_rat() {
|
|||||||
rm -f "$RAT_PARKED" "$RAT_SAVED" 2>/dev/null || true
|
rm -f "$RAT_PARKED" "$RAT_SAVED" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
screenoff() {
|
arm_rat_park_timer() {
|
||||||
apply_cpu_lpm
|
if [ "$WIFI_STANDBY_RAT" = "gsm" ] && [ ! -f "$GSM_UNSUPPORTED" ] && [ ! -f "$RAT_PARKED" ]; then
|
||||||
mute_wifi_ipv6_ra
|
|
||||||
apply_modem_drx cached || true
|
|
||||||
if [ "$WIFI_STANDBY_RAT" = "gsm" ]; then
|
|
||||||
rtok="$(date +%s)-$$"
|
rtok="$(date +%s)-$$"
|
||||||
printf '%s\n' "$rtok" > "$RAT_TOKEN"
|
printf '%s\n' "$rtok" > "$RAT_TOKEN"
|
||||||
(
|
(
|
||||||
sleep 30
|
settle_sec="${BANANARCHY_RAT_SETTLE_SEC:-45}"
|
||||||
|
[ "$settle_sec" = "0" ] || sleep "$settle_sec"
|
||||||
cur=""
|
cur=""
|
||||||
[ -r "$RAT_TOKEN" ] && { read -r cur < "$RAT_TOKEN" 2>/dev/null || cur=""; }
|
[ -r "$RAT_TOKEN" ] && { read -r cur < "$RAT_TOKEN" 2>/dev/null || cur=""; }
|
||||||
[ "$cur" = "$rtok" ] || exit 0
|
[ "$cur" = "$rtok" ] || exit 0
|
||||||
"$0" _park_rat >/dev/null 2>&1
|
"$0" _park_rat >/dev/null 2>&1
|
||||||
) &
|
) </dev/null >/dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
screenoff() {
|
||||||
|
apply_cpu_lpm
|
||||||
|
mute_wifi_ipv6_ra
|
||||||
|
apply_modem_drx cached || true
|
||||||
|
[ -x "$DSDS_BIN" ] && "$DSDS_BIN" --sig-hysteresis dark >/dev/null 2>&1 || true
|
||||||
|
arm_rat_park_timer
|
||||||
[ "$DSDS_SECONDARY_MODE" = "eco" ] || return 0
|
[ "$DSDS_SECONDARY_MODE" = "eco" ] || return 0
|
||||||
token="$(date +%s)-$$"
|
token="$(date +%s)-$$"
|
||||||
printf '%s\n' "$token" > "$TOKEN"
|
printf '%s\n' "$token" > "$TOKEN"
|
||||||
@@ -265,7 +338,13 @@ screenoff() {
|
|||||||
[ -r "$TOKEN" ] && { read -r cur < "$TOKEN" 2>/dev/null || cur=""; }
|
[ -r "$TOKEN" ] && { read -r cur < "$TOKEN" 2>/dev/null || cur=""; }
|
||||||
[ "$cur" = "$token" ] || exit 0
|
[ "$cur" = "$token" ] || exit 0
|
||||||
"$0" _park >/dev/null 2>&1
|
"$0" _park >/dev/null 2>&1
|
||||||
) &
|
) </dev/null >/dev/null 2>&1 &
|
||||||
|
}
|
||||||
|
|
||||||
|
wifi_up() {
|
||||||
|
is_screen_off_standby || return 0
|
||||||
|
mute_wifi_ipv6_ra
|
||||||
|
arm_rat_park_timer
|
||||||
}
|
}
|
||||||
|
|
||||||
screenon() {
|
screenon() {
|
||||||
@@ -274,6 +353,7 @@ screenon() {
|
|||||||
apply_cpu_lpm
|
apply_cpu_lpm
|
||||||
restore_wifi_ipv6_ra
|
restore_wifi_ipv6_ra
|
||||||
unpark_wifi_rat
|
unpark_wifi_rat
|
||||||
|
[ -x "$DSDS_BIN" ] && "$DSDS_BIN" --sig-hysteresis wake >/dev/null 2>&1 || true
|
||||||
unpark
|
unpark
|
||||||
apply_modem_drx cached || true
|
apply_modem_drx cached || true
|
||||||
}
|
}
|
||||||
@@ -306,7 +386,7 @@ modem_ready() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boot() {
|
boot() {
|
||||||
rm -f "$TOKEN" "$RAT_TOKEN" "$PARKED" "$AIDFILE" "$SLOTFILE" "$RAT_PARKED" "$RAT_SAVED" "$IPV6_RA_SAVED" "$READYSTAMP" "$RUNDIR"/drx.wwan* 2>/dev/null || true
|
rm -f "$TOKEN" "$RAT_TOKEN" "$PARKED" "$AIDFILE" "$SLOTFILE" "$RAT_PARKED" "$RAT_SAVED" "$GSM_UNSUPPORTED" "$IPV6_RA_SAVED" "$READYSTAMP" "$RUNDIR"/drx.wwan* 2>/dev/null || true
|
||||||
write_modprobe || true
|
write_modprobe || true
|
||||||
apply_cpu_lpm
|
apply_cpu_lpm
|
||||||
if [ "$MODEM_DRX_MODE" != "0" ]; then
|
if [ "$MODEM_DRX_MODE" != "0" ]; then
|
||||||
@@ -332,6 +412,9 @@ boot() {
|
|||||||
done
|
done
|
||||||
) >/dev/null 2>&1 &
|
) >/dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
if is_screen_off_standby; then
|
||||||
|
screenoff
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
debugfs_summary() {
|
debugfs_summary() {
|
||||||
@@ -396,10 +479,12 @@ case "${1:-}" in
|
|||||||
screenon) screenon ;;
|
screenon) screenon ;;
|
||||||
_park) park ;;
|
_park) park ;;
|
||||||
_park_rat) park_wifi_rat ;;
|
_park_rat) park_wifi_rat ;;
|
||||||
|
wifi-up) wifi_up ;;
|
||||||
|
unpark-rat) unpark_wifi_rat ;;
|
||||||
unpark) restore_wifi_ipv6_ra; unpark_wifi_rat; unpark ;;
|
unpark) restore_wifi_ipv6_ra; unpark_wifi_rat; unpark ;;
|
||||||
status) status ;;
|
status) status ;;
|
||||||
*)
|
*)
|
||||||
printf 'Usage: %s [boot|apply|modem-ready|screenoff|screenon|unpark|status]\n' "${0##*/}" >&2
|
printf 'Usage: %s [boot|apply|modem-ready|screenoff|screenon|wifi-up|unpark-rat|unpark|status]\n' "${0##*/}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Binary file not shown.
@@ -126,6 +126,8 @@ xorgdisplay() {
|
|||||||
printf '%s\n' "${_restore_kbd:-255}" > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true
|
printf '%s\n' "${_restore_kbd:-255}" > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
doas -n /usr/bin/bananarchy-display-power-sync >/dev/null 2>&1 || true
|
doas -n /usr/bin/bananarchy-display-power-sync >/dev/null 2>&1 || true
|
||||||
|
# Wake aligned statusbar clock loop immediately after skipping dark ticks.
|
||||||
|
killall -USR1 bananarchy-run-aligned >/dev/null 2>&1 || true
|
||||||
# U1: record every wake so the idle-blank grace guard can suppress an
|
# U1: record every wake so the idle-blank grace guard can suppress an
|
||||||
# immediate re-blank (also covers dwm's wake_phone() path).
|
# immediate re-blank (also covers dwm's wake_phone() path).
|
||||||
date +%s > /tmp/bananarchy_last_wake 2>/dev/null || true
|
date +%s > /tmp/bananarchy_last_wake 2>/dev/null || true
|
||||||
|
|||||||
@@ -631,12 +631,21 @@ provision_slot() {
|
|||||||
else
|
else
|
||||||
echo "Slot $other_slot already bound to secondary-gw-provisioning ($other_app_state)."
|
echo "Slot $other_slot already bound to secondary-gw-provisioning ($other_app_state)."
|
||||||
fi
|
fi
|
||||||
ensure_dsds_nas_registration
|
|
||||||
printf '1\n' > /tmp/sxmo_dsds_active 2>/dev/null || true
|
|
||||||
else
|
else
|
||||||
if [ "${SECONDARY_GW_SLOT:-0}" != "0" ]; then
|
if [ "${SECONDARY_GW_SLOT:-0}" != "0" ]; then
|
||||||
$QMICLI_MODEM --uim-change-provisioning-session='activate=no,session-type=secondary-gw-provisioning' >/dev/null 2>&1 || true
|
$QMICLI_MODEM --uim-change-provisioning-session='activate=no,session-type=secondary-gw-provisioning' >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
_dms_mode="$($QMICLI_MODEM --dms-get-operating-mode 2>/dev/null | awk -F"'" '/Mode:/ {print $2; exit}' || true)"
|
||||||
|
case "$_dms_mode" in
|
||||||
|
low-power|offline|shutting-down|persistent-low-power)
|
||||||
|
$QMICLI_MODEM --dms-set-operating-mode=online >/dev/null 2>&1 || true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ "$other_state" = "present" ]; then
|
||||||
|
ensure_dsds_nas_registration
|
||||||
|
printf '1\n' > /tmp/sxmo_dsds_active 2>/dev/null || true
|
||||||
|
else
|
||||||
printf '0\n' > /tmp/sxmo_dsds_active 2>/dev/null || true
|
printf '0\n' > /tmp/sxmo_dsds_active 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -0,0 +1,659 @@
|
|||||||
|
diff --git a/drivers/gpu/drm/tiny/panel-mipi-dbi.c b/drivers/gpu/drm/tiny/panel-mipi-dbi.c
|
||||||
|
index f5d66cc5d..feaed79f1 100644
|
||||||
|
--- a/drivers/gpu/drm/tiny/panel-mipi-dbi.c
|
||||||
|
+++ b/drivers/gpu/drm/tiny/panel-mipi-dbi.c
|
||||||
|
@@ -272,6 +272,11 @@ static void panel_mipi_dbi_disable(struct drm_simple_display_pipe *pipe)
|
||||||
|
}
|
||||||
|
|
||||||
|
mipi_dbi_pipe_disable(pipe);
|
||||||
|
+
|
||||||
|
+ if (dbi->dc)
|
||||||
|
+ gpiod_set_value_cansleep(dbi->dc, 0);
|
||||||
|
+ if (dbi->reset)
|
||||||
|
+ gpiod_set_value_cansleep(dbi->reset, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct drm_simple_display_pipe_funcs panel_mipi_dbi_pipe_funcs = {
|
||||||
|
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
|
||||||
|
index e113b99a3..4dd967439 100644
|
||||||
|
--- a/drivers/mmc/host/sdhci-msm.c
|
||||||
|
+++ b/drivers/mmc/host/sdhci-msm.c
|
||||||
|
@@ -10,6 +10,7 @@
|
||||||
|
#include <linux/mmc/mmc.h>
|
||||||
|
#include <linux/pm_runtime.h>
|
||||||
|
#include <linux/pm_opp.h>
|
||||||
|
+#include <linux/regulator/consumer.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
#include <linux/iopoll.h>
|
||||||
|
#include <linux/regulator/consumer.h>
|
||||||
|
@@ -2704,6 +2705,10 @@ static __maybe_unused int sdhci_msm_runtime_suspend(struct device *dev)
|
||||||
|
dev_pm_opp_set_rate(dev, 0);
|
||||||
|
clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks),
|
||||||
|
msm_host->bulk_clks);
|
||||||
|
+ if (!IS_ERR(host->mmc->supply.vmmc))
|
||||||
|
+ regulator_set_load(host->mmc->supply.vmmc, 0);
|
||||||
|
+ if (!IS_ERR(host->mmc->supply.vqmmc))
|
||||||
|
+ regulator_set_load(host->mmc->supply.vqmmc, 0);
|
||||||
|
|
||||||
|
return sdhci_msm_ice_suspend(msm_host);
|
||||||
|
}
|
||||||
|
@@ -2716,6 +2721,11 @@ static __maybe_unused int sdhci_msm_runtime_resume(struct device *dev)
|
||||||
|
unsigned long flags;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
+ if (!IS_ERR(host->mmc->supply.vmmc))
|
||||||
|
+ regulator_set_load(host->mmc->supply.vmmc, 200000);
|
||||||
|
+ if (!IS_ERR(host->mmc->supply.vqmmc))
|
||||||
|
+ regulator_set_load(host->mmc->supply.vqmmc, 20000);
|
||||||
|
+
|
||||||
|
ret = clk_bulk_prepare_enable(ARRAY_SIZE(msm_host->bulk_clks),
|
||||||
|
msm_host->bulk_clks);
|
||||||
|
if (ret)
|
||||||
|
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
|
||||||
|
index 9e6853eda..6836b8eed 100644
|
||||||
|
--- a/drivers/net/wireless/ath/wcn36xx/main.c
|
||||||
|
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
|
||||||
|
@@ -46,6 +46,32 @@ static bool screen_off_offload;
|
||||||
|
static void wcn36xx_sync_screen_off_offload(struct wcn36xx *wcn, bool enable);
|
||||||
|
static void wcn36xx_exit_host_standby(struct wcn36xx *wcn, bool send_rpc);
|
||||||
|
|
||||||
|
+static void wcn36xx_offload_sync_work(struct work_struct *work)
|
||||||
|
+{
|
||||||
|
+ struct wcn36xx *wcn = container_of(work, struct wcn36xx,
|
||||||
|
+ offload_sync_work);
|
||||||
|
+ struct wcn36xx_vif *vif_priv;
|
||||||
|
+
|
||||||
|
+ if (!READ_ONCE(screen_off_offload))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ mutex_lock(&wcn->conf_mutex);
|
||||||
|
+ if (wcn->started && READ_ONCE(screen_off_offload)) {
|
||||||
|
+ wcn->host_suspend_ind_sent = false;
|
||||||
|
+ wcn->power_params_offload = false;
|
||||||
|
+ list_for_each_entry(vif_priv, &wcn->vif_list, list)
|
||||||
|
+ vif_priv->ns_offload_active = false;
|
||||||
|
+ wcn36xx_sync_screen_off_offload(wcn, true);
|
||||||
|
+ }
|
||||||
|
+ mutex_unlock(&wcn->conf_mutex);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void wcn36xx_schedule_offload_sync(struct wcn36xx *wcn)
|
||||||
|
+{
|
||||||
|
+ if (READ_ONCE(screen_off_offload))
|
||||||
|
+ schedule_work(&wcn->offload_sync_work);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int wcn36xx_screen_off_offload_set(const char *val,
|
||||||
|
const struct kernel_param *kp)
|
||||||
|
{
|
||||||
|
@@ -335,6 +361,8 @@ static void wcn36xx_stop(struct ieee80211_hw *hw, bool suspend)
|
||||||
|
|
||||||
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac stop\n");
|
||||||
|
|
||||||
|
+ cancel_work_sync(&wcn->offload_sync_work);
|
||||||
|
+
|
||||||
|
mutex_lock(&wcn->scan_lock);
|
||||||
|
if (wcn->scan_req) {
|
||||||
|
struct cfg80211_scan_info scan_info = {
|
||||||
|
@@ -689,11 +717,65 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static bool wcn36xx_operating_rssi_healthy(struct wcn36xx *wcn)
|
||||||
|
+{
|
||||||
|
+ struct ieee80211_supported_band *sband;
|
||||||
|
+ int band, freq, i, idx = 0;
|
||||||
|
+ unsigned long flags;
|
||||||
|
+ bool found = false;
|
||||||
|
+ s8 rssi = 0;
|
||||||
|
+
|
||||||
|
+ if (!wcn->hw->conf.chandef.chan || !wcn->chan_survey)
|
||||||
|
+ return true;
|
||||||
|
+
|
||||||
|
+ band = WCN36XX_BAND(wcn);
|
||||||
|
+ freq = WCN36XX_CENTER_FREQ(wcn);
|
||||||
|
+ if (band < 0 || band >= NUM_NL80211_BANDS)
|
||||||
|
+ return true;
|
||||||
|
+
|
||||||
|
+ sband = wcn->hw->wiphy->bands[band];
|
||||||
|
+ if (!sband)
|
||||||
|
+ return true;
|
||||||
|
+
|
||||||
|
+ if (band == NL80211_BAND_5GHZ &&
|
||||||
|
+ wcn->hw->wiphy->bands[NL80211_BAND_2GHZ])
|
||||||
|
+ idx = wcn->hw->wiphy->bands[NL80211_BAND_2GHZ]->n_channels;
|
||||||
|
+
|
||||||
|
+ for (i = 0; i < sband->n_channels; i++) {
|
||||||
|
+ if (sband->channels[i].center_freq == freq) {
|
||||||
|
+ idx += i;
|
||||||
|
+ found = true;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!found)
|
||||||
|
+ return true;
|
||||||
|
+
|
||||||
|
+ spin_lock_irqsave(&wcn->survey_lock, flags);
|
||||||
|
+ rssi = wcn->chan_survey[idx].rssi;
|
||||||
|
+ spin_unlock_irqrestore(&wcn->survey_lock, flags);
|
||||||
|
+
|
||||||
|
+ return rssi == 0 || rssi >= -75;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int wcn36xx_hw_scan(struct ieee80211_hw *hw,
|
||||||
|
struct ieee80211_vif *vif,
|
||||||
|
struct ieee80211_scan_request *hw_req)
|
||||||
|
{
|
||||||
|
struct wcn36xx *wcn = hw->priv;
|
||||||
|
+ struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
|
||||||
|
+
|
||||||
|
+ if (READ_ONCE(screen_off_offload) && vif_priv->sta_assoc &&
|
||||||
|
+ hw_req->req.n_channels > 1 &&
|
||||||
|
+ wcn36xx_operating_rssi_healthy(wcn)) {
|
||||||
|
+ struct cfg80211_scan_info scan_info = {
|
||||||
|
+ .aborted = false,
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ ieee80211_scan_completed(wcn->hw, &scan_info);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (!wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
|
||||||
|
/* fallback to mac80211 software scan */
|
||||||
|
@@ -782,6 +864,7 @@ static void wcn36xx_sw_scan_complete(struct ieee80211_hw *hw,
|
||||||
|
}
|
||||||
|
wcn->sw_scan = false;
|
||||||
|
wcn->sw_scan_opchannel = 0;
|
||||||
|
+ wcn36xx_schedule_offload_sync(wcn);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wcn36xx_update_allowed_rates(struct ieee80211_sta *sta,
|
||||||
|
@@ -1470,6 +1553,8 @@ static void wcn36xx_ipv6_addr_change(struct ieee80211_hw *hw,
|
||||||
|
read_unlock_bh(&idev->lock);
|
||||||
|
|
||||||
|
vif_priv->num_target_ipv6_addrs = idx;
|
||||||
|
+ if (vif_priv->sta_assoc)
|
||||||
|
+ wcn36xx_schedule_offload_sync(hw->priv);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@@ -1783,6 +1868,7 @@ static int wcn36xx_probe(struct platform_device *pdev)
|
||||||
|
wcn->first_boot = true;
|
||||||
|
INIT_LIST_HEAD(&wcn->vif_list);
|
||||||
|
INIT_LIST_HEAD(&wcn->dev_node);
|
||||||
|
+ INIT_WORK(&wcn->offload_sync_work, wcn36xx_offload_sync_work);
|
||||||
|
mutex_init(&wcn->conf_mutex);
|
||||||
|
mutex_init(&wcn->hal_mutex);
|
||||||
|
mutex_init(&wcn->scan_lock);
|
||||||
|
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
|
||||||
|
index a46a4e330..5383f7a4f 100644
|
||||||
|
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
|
||||||
|
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
|
||||||
|
@@ -2752,6 +2752,7 @@ static int wcn36xx_smd_hw_scan_ind(struct wcn36xx *wcn, void *buf, size_t len)
|
||||||
|
scan_info.aborted = true;
|
||||||
|
mutex_unlock(&wcn->scan_lock);
|
||||||
|
ieee80211_scan_completed(wcn->hw, &scan_info);
|
||||||
|
+ wcn36xx_schedule_offload_sync(wcn);
|
||||||
|
break;
|
||||||
|
case WCN36XX_HAL_SCAN_IND_STARTED:
|
||||||
|
case WCN36XX_HAL_SCAN_IND_FOREIGN_CHANNEL:
|
||||||
|
diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
|
||||||
|
index 31348ab86..527f82ca2 100644
|
||||||
|
--- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
|
||||||
|
+++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
|
||||||
|
@@ -21,6 +21,7 @@
|
||||||
|
#include <linux/in6.h>
|
||||||
|
#include <linux/printk.h>
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
+#include <linux/workqueue.h>
|
||||||
|
#include <net/mac80211.h>
|
||||||
|
|
||||||
|
#include "hal.h"
|
||||||
|
@@ -308,8 +309,11 @@ struct wcn36xx {
|
||||||
|
|
||||||
|
spinlock_t survey_lock; /* protects chan_survey */
|
||||||
|
struct wcn36xx_chan_survey *chan_survey;
|
||||||
|
+ struct work_struct offload_sync_work;
|
||||||
|
};
|
||||||
|
|
||||||
|
+void wcn36xx_schedule_offload_sync(struct wcn36xx *wcn);
|
||||||
|
+
|
||||||
|
static inline bool wcn36xx_is_fw_version(struct wcn36xx *wcn,
|
||||||
|
u8 major,
|
||||||
|
u8 minor,
|
||||||
|
diff --git a/drivers/power/supply/pm8916_bms_vm.c b/drivers/power/supply/pm8916_bms_vm.c
|
||||||
|
index 2420699bc..eec73f8ab 100644
|
||||||
|
--- a/drivers/power/supply/pm8916_bms_vm.c
|
||||||
|
+++ b/drivers/power/supply/pm8916_bms_vm.c
|
||||||
|
@@ -14,7 +14,10 @@
|
||||||
|
#include <linux/interrupt.h>
|
||||||
|
#include <linux/math64.h>
|
||||||
|
#include <linux/timekeeping.h>
|
||||||
|
+#include <linux/list.h>
|
||||||
|
#include <linux/mod_devicetable.h>
|
||||||
|
+#include <linux/moduleparam.h>
|
||||||
|
+#include <linux/mutex.h>
|
||||||
|
|
||||||
|
#define PM8916_PERPH_TYPE 0x04
|
||||||
|
#define PM8916_BMS_VM_TYPE 0x020D
|
||||||
|
@@ -63,8 +66,15 @@ struct pm8916_bms_vm_battery {
|
||||||
|
time64_t last_ocv_time;
|
||||||
|
unsigned int vbat_now;
|
||||||
|
unsigned int fake_ocv;
|
||||||
|
+ struct list_head node;
|
||||||
|
+ struct mutex mode_lock;
|
||||||
|
+ bool in_s3;
|
||||||
|
};
|
||||||
|
|
||||||
|
+static bool bms_screen_off;
|
||||||
|
+static DEFINE_MUTEX(pm8916_bms_list_lock);
|
||||||
|
+static LIST_HEAD(pm8916_bms_devices);
|
||||||
|
+
|
||||||
|
/* VADC raw codes outside this window are uninitialised reads (0xffff) or
|
||||||
|
* out-of-range samples; 16000 ~= 4.69 V, above any Li-ion VBAT. */
|
||||||
|
#define PM8916_BMS_VM_RAW_MIN 8000
|
||||||
|
@@ -253,12 +263,112 @@ static irqreturn_t pm8916_bms_vm_fifo_update_done_irq(int irq, void *data)
|
||||||
|
return IRQ_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void pm8916_bms_vm_sync_mode(struct pm8916_bms_vm_battery *bat)
|
||||||
|
+{
|
||||||
|
+ int supplied, ret;
|
||||||
|
+ bool want_s3, notify = false;
|
||||||
|
+ unsigned int tmp = 0;
|
||||||
|
+
|
||||||
|
+ if (!bat->battery)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ supplied = power_supply_am_i_supplied(bat->battery);
|
||||||
|
+ if (supplied == -ENODEV)
|
||||||
|
+ supplied = 0;
|
||||||
|
+
|
||||||
|
+ mutex_lock(&bat->mode_lock);
|
||||||
|
+ want_s3 = READ_ONCE(bms_screen_off) && (supplied <= 0);
|
||||||
|
+ if (want_s3 && !bat->in_s3) {
|
||||||
|
+ ret = regmap_write(bat->regmap,
|
||||||
|
+ bat->reg + PM8916_SEC_ACCESS, PM8916_SEC_MAGIC);
|
||||||
|
+ if (!ret)
|
||||||
|
+ ret = regmap_write(bat->regmap,
|
||||||
|
+ bat->reg + PM8916_BMS_VM_MODE_CTL,
|
||||||
|
+ PM8916_BMS_VM_MODE_FORCE_S3);
|
||||||
|
+ if (!ret)
|
||||||
|
+ bat->in_s3 = true;
|
||||||
|
+ } else if (!want_s3 && bat->in_s3) {
|
||||||
|
+ ret = regmap_bulk_read(bat->regmap,
|
||||||
|
+ bat->reg + PM8916_BMS_VM_S3_S7_OCV_DATA0,
|
||||||
|
+ &tmp, 2);
|
||||||
|
+ if (!ret) {
|
||||||
|
+ u16 raw = (u16)(tmp & 0xffff);
|
||||||
|
+
|
||||||
|
+ if (raw > PM8916_BMS_VM_RAW_MIN && raw <= PM8916_BMS_VM_RAW_MAX) {
|
||||||
|
+ unsigned int ocv_uv = pm8916_bms_vm_raw_to_uv(raw);
|
||||||
|
+
|
||||||
|
+ bat->last_ocv_time = ktime_get_seconds();
|
||||||
|
+ bat->last_ocv = ocv_uv;
|
||||||
|
+ bat->fake_ocv = ocv_uv;
|
||||||
|
+ notify = true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ ret = regmap_write(bat->regmap,
|
||||||
|
+ bat->reg + PM8916_SEC_ACCESS, PM8916_SEC_MAGIC);
|
||||||
|
+ if (!ret)
|
||||||
|
+ ret = regmap_write(bat->regmap,
|
||||||
|
+ bat->reg + PM8916_BMS_VM_MODE_CTL,
|
||||||
|
+ PM8916_BMS_VM_MODE_NORMAL);
|
||||||
|
+ if (!ret)
|
||||||
|
+ bat->in_s3 = false;
|
||||||
|
+ }
|
||||||
|
+ mutex_unlock(&bat->mode_lock);
|
||||||
|
+
|
||||||
|
+ if (notify)
|
||||||
|
+ power_supply_changed(bat->battery);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void pm8916_bms_vm_battery_external_power_changed(struct power_supply *psy)
|
||||||
|
+{
|
||||||
|
+ struct pm8916_bms_vm_battery *bat = power_supply_get_drvdata(psy);
|
||||||
|
+
|
||||||
|
+ pm8916_bms_vm_sync_mode(bat);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int pm8916_bms_screen_off_set(const char *val,
|
||||||
|
+ const struct kernel_param *kp)
|
||||||
|
+{
|
||||||
|
+ struct pm8916_bms_vm_battery *bat;
|
||||||
|
+ bool enable;
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ ret = kstrtobool(val, &enable);
|
||||||
|
+ if (ret)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+ mutex_lock(&pm8916_bms_list_lock);
|
||||||
|
+ WRITE_ONCE(bms_screen_off, enable);
|
||||||
|
+ list_for_each_entry(bat, &pm8916_bms_devices, node)
|
||||||
|
+ pm8916_bms_vm_sync_mode(bat);
|
||||||
|
+ mutex_unlock(&pm8916_bms_list_lock);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static const struct kernel_param_ops pm8916_bms_screen_off_ops = {
|
||||||
|
+ .set = pm8916_bms_screen_off_set,
|
||||||
|
+ .get = param_get_bool,
|
||||||
|
+};
|
||||||
|
+module_param_cb(screen_off, &pm8916_bms_screen_off_ops, &bms_screen_off, 0644);
|
||||||
|
+MODULE_PARM_DESC(screen_off,
|
||||||
|
+ "Put BMS-VM into S3 sleep OCV mode while panel is off and discharging");
|
||||||
|
+
|
||||||
|
+static void pm8916_bms_vm_unregister_dev(void *data)
|
||||||
|
+{
|
||||||
|
+ struct pm8916_bms_vm_battery *bat = data;
|
||||||
|
+
|
||||||
|
+ mutex_lock(&pm8916_bms_list_lock);
|
||||||
|
+ list_del_init(&bat->node);
|
||||||
|
+ mutex_unlock(&pm8916_bms_list_lock);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static const struct power_supply_desc pm8916_bms_vm_battery_psy_desc = {
|
||||||
|
.name = "pm8916-bms-vm",
|
||||||
|
.type = POWER_SUPPLY_TYPE_BATTERY,
|
||||||
|
.properties = pm8916_bms_vm_battery_properties,
|
||||||
|
.num_properties = ARRAY_SIZE(pm8916_bms_vm_battery_properties),
|
||||||
|
.get_property = pm8916_bms_vm_battery_get_property,
|
||||||
|
+ .external_power_changed = pm8916_bms_vm_battery_external_power_changed,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int pm8916_bms_vm_battery_probe(struct platform_device *pdev)
|
||||||
|
@@ -274,6 +384,12 @@ static int pm8916_bms_vm_battery_probe(struct platform_device *pdev)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
bat->dev = dev;
|
||||||
|
+ INIT_LIST_HEAD(&bat->node);
|
||||||
|
+ mutex_init(&bat->mode_lock);
|
||||||
|
+
|
||||||
|
+ ret = devm_add_action_or_reset(dev, pm8916_bms_vm_unregister_dev, bat);
|
||||||
|
+ if (ret)
|
||||||
|
+ return ret;
|
||||||
|
|
||||||
|
bat->regmap = dev_get_regmap(pdev->dev.parent, NULL);
|
||||||
|
if (!bat->regmap)
|
||||||
|
@@ -353,6 +469,12 @@ static int pm8916_bms_vm_battery_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, bat);
|
||||||
|
|
||||||
|
+ mutex_lock(&pm8916_bms_list_lock);
|
||||||
|
+ list_add_tail(&bat->node, &pm8916_bms_devices);
|
||||||
|
+ if (READ_ONCE(bms_screen_off))
|
||||||
|
+ pm8916_bms_vm_sync_mode(bat);
|
||||||
|
+ mutex_unlock(&pm8916_bms_list_lock);
|
||||||
|
+
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
comm_error:
|
||||||
|
diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c
|
||||||
|
index 83bd81948..f78dd03e7 100644
|
||||||
|
--- a/drivers/regulator/qcom_smd-regulator.c
|
||||||
|
+++ b/drivers/regulator/qcom_smd-regulator.c
|
||||||
|
@@ -1428,7 +1428,9 @@ static int rpm_regulator_init_vreg(struct qcom_rpm_reg *vreg, struct device *dev
|
||||||
|
* send RPM_KEY_SWEN = 0 when no consumer claims them.
|
||||||
|
*/
|
||||||
|
if (pmic_rpm_data == rpm_pm8909_regulators &&
|
||||||
|
- (!strcmp(rpm_data->name, "l14") ||
|
||||||
|
+ (!strcmp(rpm_data->name, "l1") ||
|
||||||
|
+ !strcmp(rpm_data->name, "l4") ||
|
||||||
|
+ !strcmp(rpm_data->name, "l14") ||
|
||||||
|
!strcmp(rpm_data->name, "l15") ||
|
||||||
|
!strcmp(rpm_data->name, "l18")))
|
||||||
|
vreg->is_enabled = 1;
|
||||||
|
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
|
||||||
|
index 1a2f9cd92..d2d57149c 100644
|
||||||
|
--- a/drivers/spi/spi-qup.c
|
||||||
|
+++ b/drivers/spi/spi-qup.c
|
||||||
|
@@ -16,6 +16,7 @@
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/pm_opp.h>
|
||||||
|
+#include <linux/pinctrl/consumer.h>
|
||||||
|
#include <linux/pm_runtime.h>
|
||||||
|
#include <linux/spi/spi.h>
|
||||||
|
#include "internals.h"
|
||||||
|
@@ -1227,6 +1228,7 @@ static int spi_qup_pm_suspend_runtime(struct device *device)
|
||||||
|
clk_disable_unprepare(controller->cclk);
|
||||||
|
spi_qup_vote_bw(controller, 0);
|
||||||
|
clk_disable_unprepare(controller->iclk);
|
||||||
|
+ pinctrl_pm_select_sleep_state(device);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -1238,6 +1240,8 @@ static int spi_qup_pm_resume_runtime(struct device *device)
|
||||||
|
u32 config;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
+ pinctrl_pm_select_default_state(device);
|
||||||
|
+
|
||||||
|
ret = clk_prepare_enable(controller->iclk);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
|
||||||
|
index b0934faa7..257f78057 100644
|
||||||
|
--- a/sound/soc/codecs/msm8916-wcd-analog.c
|
||||||
|
+++ b/sound/soc/codecs/msm8916-wcd-analog.c
|
||||||
|
@@ -5,6 +5,7 @@
|
||||||
|
#include <linux/err.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
+#include <linux/mutex.h>
|
||||||
|
#include <linux/regulator/consumer.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
@@ -19,6 +20,7 @@
|
||||||
|
|
||||||
|
#define CDC_D_REVISION1 (0xf000)
|
||||||
|
#define CDC_D_PERPH_SUBTYPE (0xf005)
|
||||||
|
+#define CDC_D_INT_RT_STS (0xf010)
|
||||||
|
#define CDC_D_INT_EN_SET (0xf015)
|
||||||
|
#define CDC_D_INT_EN_CLR (0xf016)
|
||||||
|
#define MBHC_SWITCH_INT BIT(7)
|
||||||
|
@@ -308,6 +310,10 @@ struct pm8916_wcd_analog_priv {
|
||||||
|
unsigned int micbias1_cap_mode;
|
||||||
|
unsigned int micbias2_cap_mode;
|
||||||
|
unsigned int micbias_mv;
|
||||||
|
+ struct mutex power_lock;
|
||||||
|
+ bool audio_active;
|
||||||
|
+ bool jack_inserted;
|
||||||
|
+ bool s2_enabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *const adc2_mux_text[] = { "ZERO", "INP2", "INP3" };
|
||||||
|
@@ -429,6 +435,66 @@ static int pm8916_wcd_analog_enable_micbias2(struct snd_soc_dapm_widget *w,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int pm8916_wcd_analog_update_power_locked(struct snd_soc_component *component)
|
||||||
|
+{
|
||||||
|
+ struct pm8916_wcd_analog_priv *priv = snd_soc_component_get_drvdata(component);
|
||||||
|
+ bool need_s2 = priv->audio_active || priv->jack_inserted;
|
||||||
|
+ int ret = 0;
|
||||||
|
+
|
||||||
|
+ if (need_s2 && !priv->s2_enabled) {
|
||||||
|
+ ret = regulator_enable(priv->supplies[1].consumer);
|
||||||
|
+ if (!ret) {
|
||||||
|
+ priv->s2_enabled = true;
|
||||||
|
+ usleep_range(1000, 1500);
|
||||||
|
+ snd_soc_component_write(component, CDC_A_MASTER_BIAS_CTL, 0x30);
|
||||||
|
+ } else {
|
||||||
|
+ dev_err(component->dev, "failed to enable vdd-cdc-tx-rx-cx (%d)\n", ret);
|
||||||
|
+ }
|
||||||
|
+ } else if (!need_s2 && priv->s2_enabled) {
|
||||||
|
+ snd_soc_component_update_bits(component, CDC_A_MBHC_FSM_CTL,
|
||||||
|
+ CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK |
|
||||||
|
+ CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK,
|
||||||
|
+ 0);
|
||||||
|
+ snd_soc_component_update_bits(component, CDC_D_CDC_DIG_CLK_CTL,
|
||||||
|
+ DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
|
||||||
|
+ 0);
|
||||||
|
+ snd_soc_component_write(component, CDC_A_MASTER_BIAS_CTL, 0x00);
|
||||||
|
+ regulator_disable(priv->supplies[1].consumer);
|
||||||
|
+ priv->s2_enabled = false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int pm8916_wcd_analog_set_bias_level(struct snd_soc_component *component,
|
||||||
|
+ enum snd_soc_bias_level level)
|
||||||
|
+{
|
||||||
|
+ struct pm8916_wcd_analog_priv *priv = snd_soc_component_get_drvdata(component);
|
||||||
|
+ int ret = 0;
|
||||||
|
+
|
||||||
|
+ switch (level) {
|
||||||
|
+ case SND_SOC_BIAS_PREPARE:
|
||||||
|
+ if (snd_soc_component_get_bias_level(component) <= SND_SOC_BIAS_STANDBY) {
|
||||||
|
+ mutex_lock(&priv->power_lock);
|
||||||
|
+ priv->audio_active = true;
|
||||||
|
+ ret = pm8916_wcd_analog_update_power_locked(component);
|
||||||
|
+ mutex_unlock(&priv->power_lock);
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ case SND_SOC_BIAS_STANDBY:
|
||||||
|
+ case SND_SOC_BIAS_OFF:
|
||||||
|
+ mutex_lock(&priv->power_lock);
|
||||||
|
+ priv->audio_active = false;
|
||||||
|
+ ret = pm8916_wcd_analog_update_power_locked(component);
|
||||||
|
+ mutex_unlock(&priv->power_lock);
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
|
||||||
|
bool micbias2_enabled)
|
||||||
|
{
|
||||||
|
@@ -436,6 +502,9 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
|
||||||
|
u32 coarse, fine, reg_val, reg_addr;
|
||||||
|
int *vrefs, i;
|
||||||
|
|
||||||
|
+ if (!priv->jack_inserted && !micbias2_enabled)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
if (!micbias2_enabled) { /* use internal 100uA Current source */
|
||||||
|
/* Enable internal 2.2k Internal Rbias Resistor */
|
||||||
|
snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS,
|
||||||
|
@@ -728,6 +797,9 @@ static int pm8916_wcd_analog_probe(struct snd_soc_component *component)
|
||||||
|
dev_err(component->dev, "failed to enable regulators (%d)\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
+ mutex_lock(&priv->power_lock);
|
||||||
|
+ priv->s2_enabled = true;
|
||||||
|
+ mutex_unlock(&priv->power_lock);
|
||||||
|
|
||||||
|
snd_soc_component_init_regmap(component,
|
||||||
|
dev_get_regmap(component->dev->parent, NULL));
|
||||||
|
@@ -752,6 +824,24 @@ static int pm8916_wcd_analog_probe(struct snd_soc_component *component)
|
||||||
|
RST_CTL_DIG_SW_RST_N_REMOVE_RESET);
|
||||||
|
|
||||||
|
pm8916_wcd_setup_mbhc(priv);
|
||||||
|
+ usleep_range(1000, 1500);
|
||||||
|
+
|
||||||
|
+ mutex_lock(&priv->power_lock);
|
||||||
|
+ if (!priv->jack_inserted) {
|
||||||
|
+ u32 det_ctl = snd_soc_component_read(component, CDC_A_MBHC_DET_CTL_1);
|
||||||
|
+ u32 rt_sts = snd_soc_component_read(component, CDC_D_INT_RT_STS);
|
||||||
|
+
|
||||||
|
+ if (!(det_ctl & CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK) ||
|
||||||
|
+ (rt_sts & MBHC_SWITCH_INT))
|
||||||
|
+ priv->jack_inserted = true;
|
||||||
|
+ }
|
||||||
|
+ if (!priv->jack_inserted && priv->mbhc_btn_enabled)
|
||||||
|
+ snd_soc_component_write(component, CDC_D_INT_EN_CLR,
|
||||||
|
+ MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET);
|
||||||
|
+ err = pm8916_wcd_analog_update_power_locked(component);
|
||||||
|
+ mutex_unlock(&priv->power_lock);
|
||||||
|
+ if (err)
|
||||||
|
+ dev_warn(component->dev, "failed initial wcd power sync (%d)\n", err);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -763,8 +853,13 @@ static void pm8916_wcd_analog_remove(struct snd_soc_component *component)
|
||||||
|
snd_soc_component_update_bits(component, CDC_D_CDC_RST_CTL,
|
||||||
|
RST_CTL_DIG_SW_RST_N_MASK, 0);
|
||||||
|
|
||||||
|
- regulator_bulk_disable(ARRAY_SIZE(priv->supplies),
|
||||||
|
- priv->supplies);
|
||||||
|
+ mutex_lock(&priv->power_lock);
|
||||||
|
+ if (priv->s2_enabled) {
|
||||||
|
+ regulator_disable(priv->supplies[1].consumer);
|
||||||
|
+ priv->s2_enabled = false;
|
||||||
|
+ }
|
||||||
|
+ mutex_unlock(&priv->power_lock);
|
||||||
|
+ regulator_disable(priv->supplies[0].consumer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct snd_soc_dapm_route pm8916_wcd_analog_audio_map[] = {
|
||||||
|
@@ -1073,6 +1168,21 @@ static int pm8916_wcd_analog_switch_check(struct pm8916_wcd_analog_priv *priv, b
|
||||||
|
if (ins) { /* hs insertion */
|
||||||
|
bool micbias_enabled = false;
|
||||||
|
|
||||||
|
+ mutex_lock(&priv->power_lock);
|
||||||
|
+ priv->jack_inserted = true;
|
||||||
|
+ pm8916_wcd_analog_update_power_locked(component);
|
||||||
|
+ mutex_unlock(&priv->power_lock);
|
||||||
|
+
|
||||||
|
+ snd_soc_component_update_bits(component, CDC_D_CDC_DIG_CLK_CTL,
|
||||||
|
+ DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
|
||||||
|
+ DIG_CLK_CTL_D_MBHC_CLK_EN);
|
||||||
|
+ if (priv->mbhc_btn_enabled)
|
||||||
|
+ snd_soc_component_update_bits(component, CDC_D_INT_EN_SET,
|
||||||
|
+ MBHC_BUTTON_PRESS_DET |
|
||||||
|
+ MBHC_BUTTON_RELEASE_DET,
|
||||||
|
+ MBHC_BUTTON_PRESS_DET |
|
||||||
|
+ MBHC_BUTTON_RELEASE_DET);
|
||||||
|
+
|
||||||
|
if (snd_soc_component_read(component, CDC_A_MICB_2_EN) &
|
||||||
|
CDC_A_MICB_2_EN_ENABLE)
|
||||||
|
micbias_enabled = true;
|
||||||
|
@@ -1096,6 +1206,14 @@ static int pm8916_wcd_analog_switch_check(struct pm8916_wcd_analog_priv *priv, b
|
||||||
|
report = 0;
|
||||||
|
priv->detect_accessory_type = true;
|
||||||
|
priv->mbhc_btn0_released = false;
|
||||||
|
+ if (priv->mbhc_btn_enabled)
|
||||||
|
+ snd_soc_component_write(component, CDC_D_INT_EN_CLR,
|
||||||
|
+ MBHC_BUTTON_PRESS_DET |
|
||||||
|
+ MBHC_BUTTON_RELEASE_DET);
|
||||||
|
+ mutex_lock(&priv->power_lock);
|
||||||
|
+ priv->jack_inserted = false;
|
||||||
|
+ pm8916_wcd_analog_update_power_locked(component);
|
||||||
|
+ mutex_unlock(&priv->power_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return report;
|
||||||
|
@@ -1155,13 +1273,14 @@ static const struct snd_soc_component_driver pm8916_wcd_analog = {
|
||||||
|
.probe = pm8916_wcd_analog_probe,
|
||||||
|
.remove = pm8916_wcd_analog_remove,
|
||||||
|
.set_jack = pm8916_wcd_analog_set_jack,
|
||||||
|
+ .set_bias_level = pm8916_wcd_analog_set_bias_level,
|
||||||
|
.controls = pm8916_wcd_analog_snd_controls,
|
||||||
|
.num_controls = ARRAY_SIZE(pm8916_wcd_analog_snd_controls),
|
||||||
|
.dapm_widgets = pm8916_wcd_analog_dapm_widgets,
|
||||||
|
.num_dapm_widgets = ARRAY_SIZE(pm8916_wcd_analog_dapm_widgets),
|
||||||
|
.dapm_routes = pm8916_wcd_analog_audio_map,
|
||||||
|
.num_dapm_routes = ARRAY_SIZE(pm8916_wcd_analog_audio_map),
|
||||||
|
- .idle_bias_on = 1,
|
||||||
|
+ .idle_bias_on = 0,
|
||||||
|
.use_pmdown_time = 1,
|
||||||
|
.endianness = 1,
|
||||||
|
};
|
||||||
|
@@ -1230,6 +1349,8 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev)
|
||||||
|
if (!priv)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
+ mutex_init(&priv->power_lock);
|
||||||
|
+
|
||||||
|
ret = pm8916_wcd_analog_parse_dt(dev, priv);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+32740
-32740
File diff suppressed because it is too large.
Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6
-2
@@ -387,17 +387,21 @@ EOF
|
|||||||
mkdir -p "$ROOTFS/proc/1/root"
|
mkdir -p "$ROOTFS/proc/1/root"
|
||||||
cp /lib/ld-musl-x86_64.so.1 "$ROOTFS/lib/"
|
cp /lib/ld-musl-x86_64.so.1 "$ROOTFS/lib/"
|
||||||
cp -a /usr/lib/libgcc_s.so* "$ROOTFS/tmp/hostbin/" 2>/dev/null || true
|
cp -a /usr/lib/libgcc_s.so* "$ROOTFS/tmp/hostbin/" 2>/dev/null || true
|
||||||
cp -a /lib/libz.so* /usr/lib/libzstd.so* /usr/lib/liblzma.so* /lib/libcrypto.so* "$ROOTFS/tmp/hostbin/" 2>/dev/null || true
|
cp -aL /lib/libz.so* /usr/lib/libz.so* /usr/lib/libzstd.so* /usr/lib/liblzma.so* /lib/libcrypto.so* /usr/lib/libcrypto.so* "$ROOTFS/tmp/hostbin/" 2>/dev/null || true
|
||||||
ln -sf /tmp/hostbin/busybox.static "$ROOTFS/bin/sh"
|
ln -sf /tmp/hostbin/busybox.static "$ROOTFS/bin/sh"
|
||||||
|
|
||||||
|
chroot_rc=0
|
||||||
chroot "$ROOTFS" /tmp/hostbin/busybox.static sh -e -c "
|
chroot "$ROOTFS" /tmp/hostbin/busybox.static sh -e -c "
|
||||||
export PATH=/tmp/hostbin:/usr/sbin:/usr/bin:/sbin:/bin
|
export PATH=/tmp/hostbin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
export LD_LIBRARY_PATH=/tmp/hostbin:/lib:/usr/lib
|
export LD_LIBRARY_PATH=/tmp/hostbin:/lib:/usr/lib
|
||||||
/tmp/hostbin/mkinitfs
|
/tmp/hostbin/mkinitfs
|
||||||
"
|
" || chroot_rc=$?
|
||||||
|
|
||||||
ln -sf /bin/busybox "$ROOTFS/bin/sh"
|
ln -sf /bin/busybox "$ROOTFS/bin/sh"
|
||||||
rm -rf "$ROOTFS/tmp/hostbin" "$ROOTFS/lib/ld-musl-x86_64.so.1" "$ROOTFS/proc/1"
|
rm -rf "$ROOTFS/tmp/hostbin" "$ROOTFS/lib/ld-musl-x86_64.so.1" "$ROOTFS/proc/1"
|
||||||
|
if [ "$chroot_rc" -ne 0 ]; then
|
||||||
|
exit "$chroot_rc"
|
||||||
|
fi
|
||||||
echo "$TARGET_DEVICE" > "$LAST_DEV_FILE"
|
echo "$TARGET_DEVICE" > "$LAST_DEV_FILE"
|
||||||
else
|
else
|
||||||
echo "[2/5] Using existing $ROOTFS/boot/initramfs (pass --mkinitfs to regenerate)..."
|
echo "[2/5] Using existing $ROOTFS/boot/initramfs (pass --mkinitfs to regenerate)..."
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ chown 0:0 "$TARGET_ROOTFS/etc/chrony/chrony.conf" \
|
|||||||
"$TARGET_ROOTFS/usr/bin/bananarchy-dpm.sh" \
|
"$TARGET_ROOTFS/usr/bin/bananarchy-dpm.sh" \
|
||||||
"$TARGET_ROOTFS/usr/bin/sxmo_run_aligned.sh" \
|
"$TARGET_ROOTFS/usr/bin/sxmo_run_aligned.sh" \
|
||||||
"$TARGET_ROOTFS/etc/init.d/bananarchy-time-sync" \
|
"$TARGET_ROOTFS/etc/init.d/bananarchy-time-sync" \
|
||||||
|
"$TARGET_ROOTFS/etc/boot-deploy/hooks/10-initramfs-depmod.sh" \
|
||||||
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/10-bananarchy-dpm.sh" \
|
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/10-bananarchy-dpm.sh" \
|
||||||
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \
|
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \
|
||||||
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh" \
|
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh" \
|
||||||
@@ -242,6 +243,7 @@ chmod 0755 "$TARGET_ROOTFS/usr/bin/bananarchy-idle-blank.sh" \
|
|||||||
"$TARGET_ROOTFS/usr/bin/bananarchy-dpm.sh" \
|
"$TARGET_ROOTFS/usr/bin/bananarchy-dpm.sh" \
|
||||||
"$TARGET_ROOTFS/usr/bin/sxmo_run_aligned.sh" \
|
"$TARGET_ROOTFS/usr/bin/sxmo_run_aligned.sh" \
|
||||||
"$TARGET_ROOTFS/etc/init.d/bananarchy-time-sync" \
|
"$TARGET_ROOTFS/etc/init.d/bananarchy-time-sync" \
|
||||||
|
"$TARGET_ROOTFS/etc/boot-deploy/hooks/10-initramfs-depmod.sh" \
|
||||||
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/10-bananarchy-dpm.sh" \
|
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/10-bananarchy-dpm.sh" \
|
||||||
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \
|
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \
|
||||||
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh" \
|
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh" \
|
||||||
@@ -310,42 +312,54 @@ if [ -f "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/drm/panel-mipi-dbi.ko.zst" ];
|
|||||||
fi
|
fi
|
||||||
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/leds" ] && \
|
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/leds" ] && \
|
||||||
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/leds" ]; then
|
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/leds" ]; then
|
||||||
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/leds/"*.ko* \
|
rm -f "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/leds/leds-msm8905-torch.ko"
|
||||||
|
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/leds/"*.ko.zst \
|
||||||
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/leds/"
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/leds/"
|
||||||
fi
|
fi
|
||||||
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/camera" ] && \
|
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/camera" ] && \
|
||||||
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers" ]; then
|
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers" ]; then
|
||||||
mkdir -p "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/media/platform/qcom/camss"
|
mkdir -p "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/media/platform/qcom/camss"
|
||||||
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/camera/"*.ko* \
|
rm -f "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/media/platform/qcom/camss/msm8905-cam.ko"
|
||||||
|
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/camera/"*.ko.zst \
|
||||||
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/media/platform/qcom/camss/"
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/media/platform/qcom/camss/"
|
||||||
fi
|
fi
|
||||||
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/netfilter" ] && \
|
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/netfilter" ] && \
|
||||||
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/net/netfilter" ]; then
|
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/net/netfilter" ]; then
|
||||||
|
rm -f "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/net/netfilter/nft_redir.ko" \
|
||||||
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/net/netfilter/xt_owner.ko"
|
||||||
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/netfilter/"*.ko.zst \
|
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/netfilter/"*.ko.zst \
|
||||||
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/net/netfilter/"
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/net/netfilter/"
|
||||||
fi
|
fi
|
||||||
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/power" ] && \
|
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/power" ] && \
|
||||||
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/power/supply" ]; then
|
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/power/supply" ]; then
|
||||||
|
rm -f "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/power/supply/pm8916_bms_vm.ko" \
|
||||||
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/power/supply/pm8916_lbc.ko"
|
||||||
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/power/"*.ko.zst \
|
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/power/"*.ko.zst \
|
||||||
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/power/supply/"
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/power/supply/"
|
||||||
fi
|
fi
|
||||||
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/wcn36xx" ] && \
|
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/wcn36xx" ] && \
|
||||||
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/net/wireless/ath/wcn36xx" ]; then
|
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/net/wireless/ath/wcn36xx" ]; then
|
||||||
|
rm -f "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/net/wireless/ath/wcn36xx/wcn36xx.ko"
|
||||||
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/wcn36xx/"*.ko.zst \
|
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/wcn36xx/"*.ko.zst \
|
||||||
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/net/wireless/ath/wcn36xx/"
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/net/wireless/ath/wcn36xx/"
|
||||||
fi
|
fi
|
||||||
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/mux" ]; then
|
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/mux" ]; then
|
||||||
mkdir -p "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/mux"
|
mkdir -p "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/mux"
|
||||||
|
rm -f "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/mux/mux-core.ko" \
|
||||||
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/mux/mux-gpio.ko"
|
||||||
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/mux/"*.ko.zst \
|
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/mux/"*.ko.zst \
|
||||||
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/mux/"
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/mux/"
|
||||||
fi
|
fi
|
||||||
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/spi" ]; then
|
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/spi" ]; then
|
||||||
mkdir -p "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/spi"
|
mkdir -p "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/spi"
|
||||||
|
rm -f "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/spi/spi-mux.ko"
|
||||||
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/spi/"*.ko.zst \
|
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/spi/"*.ko.zst \
|
||||||
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/spi/"
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/drivers/spi/"
|
||||||
fi
|
fi
|
||||||
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/codecs" ] && \
|
if [ -d "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/codecs" ] && \
|
||||||
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/sound/soc/codecs" ]; then
|
[ -d "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/sound/soc/codecs" ]; then
|
||||||
|
rm -f "$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/sound/soc/codecs/snd-soc-msm8916-analog.ko" \
|
||||||
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/sound/soc/codecs/snd-soc-msm8916-digital.ko"
|
||||||
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/codecs/"*.ko.zst \
|
cp -af "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/codecs/"*.ko.zst \
|
||||||
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/sound/soc/codecs/"
|
"$TARGET_ROOTFS/lib/modules/6.12.1-msm8916/kernel/sound/soc/codecs/"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -99,6 +99,11 @@ EOF
|
|||||||
echo "[2j/5] Applying MSM8909 boot ICC, OPP, USB PHY, and Q6ASM/MultiMedia3 fixes..."
|
echo "[2j/5] Applying MSM8909 boot ICC, OPP, USB PHY, and Q6ASM/MultiMedia3 fixes..."
|
||||||
patch -p1 < /bananarchy/patches/kernel/0011-msm8909-boot-icc-opp-usb-audio-fixes.patch
|
patch -p1 < /bananarchy/patches/kernel/0011-msm8909-boot-icc-opp-usb-audio-fixes.patch
|
||||||
fi
|
fi
|
||||||
|
if ! grep -q "offload_sync_work" drivers/net/wireless/ath/wcn36xx/wcn36xx.h 2>/dev/null || \
|
||||||
|
! grep -q "pm8916_wcd_analog_update_power_locked" sound/soc/codecs/msm8916-wcd-analog.c 2>/dev/null; then
|
||||||
|
echo "[2k/5] Applying MSM8909 72h standby Wi-Fi, WCD analog, panel, LDO, and BMS patch..."
|
||||||
|
patch -p1 < /bananarchy/patches/kernel/0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch
|
||||||
|
fi
|
||||||
if [ ! -f include/config/auto.conf ] || \
|
if [ ! -f include/config/auto.conf ] || \
|
||||||
! grep -q "CONFIG_NETFILTER_XT_MATCH_OWNER=m" .config 2>/dev/null || \
|
! grep -q "CONFIG_NETFILTER_XT_MATCH_OWNER=m" .config 2>/dev/null || \
|
||||||
! grep -q "CONFIG_INTERCONNECT_QCOM_MSM8909=y" .config 2>/dev/null || \
|
! grep -q "CONFIG_INTERCONNECT_QCOM_MSM8909=y" .config 2>/dev/null || \
|
||||||
@@ -143,6 +148,8 @@ EOF
|
|||||||
patch -p1 < /bananarchy/patches/kernel/0010-msm8909-rpm-lpm-bimc-wcd-ldo-uart.patch
|
patch -p1 < /bananarchy/patches/kernel/0010-msm8909-rpm-lpm-bimc-wcd-ldo-uart.patch
|
||||||
echo "[2j/5] Applying MSM8909 boot ICC, OPP, USB PHY, and Q6ASM/MultiMedia3 fixes..."
|
echo "[2j/5] Applying MSM8909 boot ICC, OPP, USB PHY, and Q6ASM/MultiMedia3 fixes..."
|
||||||
patch -p1 < /bananarchy/patches/kernel/0011-msm8909-boot-icc-opp-usb-audio-fixes.patch
|
patch -p1 < /bananarchy/patches/kernel/0011-msm8909-boot-icc-opp-usb-audio-fixes.patch
|
||||||
|
echo "[2k/5] Applying MSM8909 72h standby Wi-Fi, WCD analog, panel, LDO, and BMS patch..."
|
||||||
|
patch -p1 < /bananarchy/patches/kernel/0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch
|
||||||
|
|
||||||
echo "[3/5] Preparing kernel configuration and Module.symvers..."
|
echo "[3/5] Preparing kernel configuration and Module.symvers..."
|
||||||
cp /bananarchy/patches/kernel/config-bananarchy-msm8909.armv7 .config
|
cp /bananarchy/patches/kernel/config-bananarchy-msm8909.armv7 .config
|
||||||
@@ -214,6 +221,7 @@ EOF
|
|||||||
cp -a sound/soc/qcom/snd-soc-qcom-common.ko sound/soc/qcom/snd-soc-apq8016-sbc.ko \
|
cp -a sound/soc/qcom/snd-soc-qcom-common.ko sound/soc/qcom/snd-soc-apq8016-sbc.ko \
|
||||||
/bananarchy/prebuilt/kernel-6.12.1-msm8916/qcom/
|
/bananarchy/prebuilt/kernel-6.12.1-msm8916/qcom/
|
||||||
cp -a sound/soc/codecs/snd-soc-msm8916-digital.ko \
|
cp -a sound/soc/codecs/snd-soc-msm8916-digital.ko \
|
||||||
|
sound/soc/codecs/snd-soc-msm8916-analog.ko \
|
||||||
/bananarchy/prebuilt/kernel-6.12.1-msm8916/codecs/
|
/bananarchy/prebuilt/kernel-6.12.1-msm8916/codecs/
|
||||||
cp -a drivers/bluetooth/btqcomsmd.ko \
|
cp -a drivers/bluetooth/btqcomsmd.ko \
|
||||||
/bananarchy/prebuilt/kernel-6.12.1-msm8916/bluetooth/
|
/bananarchy/prebuilt/kernel-6.12.1-msm8916/bluetooth/
|
||||||
|
|||||||
+154
-4
@@ -397,9 +397,9 @@ fi
|
|||||||
|
|
||||||
echo "[check] Known-good flashable image set..."
|
echo "[check] Known-good flashable image set..."
|
||||||
for pair in \
|
for pair in \
|
||||||
"7b39e0ef4cbfc169a4fa0eeda5641ed59df7644b5e5265f8f3f5b25e7f3a8e41 images/bananarchy-nokia-argon.img" \
|
"753c186db1fa5e7d58f3252ad344004bcb0d6fb26eb810ae9427d572cd7d94ca images/bananarchy-nokia-argon.img" \
|
||||||
"19f605dbb5a80ca073895a7ed41149a1a7692c79f12f399bff1e61d497daf069 images/bananarchy-nokia-beatles.img" \
|
"12eb7e589a40c3935fcf283f3771b1e7e65d04b08b6d632c23b0f290304dd673 images/bananarchy-nokia-beatles.img" \
|
||||||
"7920fae28fa3389602be16a02ad7311b50e61c9c205be48f160307d594f65eb6 images/boot-bananarchy-nokia-beatles.img" \
|
"d6b82239f80038c1bd916c36d4c674dc1e36996b3d52c65efdd545ff320a08d8 images/boot-bananarchy-nokia-beatles.img" \
|
||||||
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
|
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
|
||||||
set -- $pair
|
set -- $pair
|
||||||
want=$1
|
want=$1
|
||||||
@@ -893,6 +893,109 @@ if ! grep -q 'MODULES_INITFS' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh" ||
|
|||||||
! grep -q 'initramfs.load' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
|
! grep -q 'initramfs.load' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
|
||||||
fail "apply-bananarchy-overlay.sh no longer installs the device initramfs module list"
|
fail "apply-bananarchy-overlay.sh no longer installs the device initramfs module list"
|
||||||
fi
|
fi
|
||||||
|
if [ ! -x "$BASE_DIR/overlay/rootfs/etc/boot-deploy/hooks/10-initramfs-depmod.sh" ] || \
|
||||||
|
! sh -n "$BASE_DIR/overlay/rootfs/etc/boot-deploy/hooks/10-initramfs-depmod.sh" 2>/dev/null || \
|
||||||
|
! grep -q -- 'DEPMOD_BIN' "$BASE_DIR/overlay/rootfs/etc/boot-deploy/hooks/10-initramfs-depmod.sh" || \
|
||||||
|
! grep -q -- '-b' "$BASE_DIR/overlay/rootfs/etc/boot-deploy/hooks/10-initramfs-depmod.sh"; then
|
||||||
|
fail "10-initramfs-depmod.sh hook is missing, not executable, or invalid"
|
||||||
|
fi
|
||||||
|
if ! grep -q '10-initramfs-depmod.sh' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
|
||||||
|
fail "apply-bananarchy-overlay.sh no longer sets permissions on 10-initramfs-depmod.sh"
|
||||||
|
fi
|
||||||
|
if grep -qE '"\$\{?BASE_DIR\}?/prebuilt/kernel-6\.12\.1-msm8916/(leds|camera)/"\*\.ko\*' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
|
||||||
|
fail "apply-bananarchy-overlay.sh still copies uncompressed .ko files via *.ko* wildcard"
|
||||||
|
fi
|
||||||
|
for dev_img in images/bananarchy-nokia-argon.img images/bananarchy-nokia-beatles.img; do
|
||||||
|
if [ ! -f "$BASE_DIR/$dev_img" ]; then
|
||||||
|
echo "[skip] local build output $dev_img is absent; skipping initramfs depmod check"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if ! python3 - "$BASE_DIR/$dev_img" <<'PYEOF'
|
||||||
|
import gzip, os, shutil, struct, subprocess, sys, tempfile
|
||||||
|
|
||||||
|
img = sys.argv[1]
|
||||||
|
debugfs_bin = shutil.which("debugfs") or "/sbin/debugfs"
|
||||||
|
with open(img, "rb") as f:
|
||||||
|
mbr = f.read(512)
|
||||||
|
start_lba, sectors = struct.unpack_from("<II", mbr, 446 + 8)
|
||||||
|
if start_lba == 0 or sectors == 0:
|
||||||
|
sys.stderr.write(f"invalid MBR partition 1 in {img}\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
boot_part = os.path.join(tmp, "boot.ext2")
|
||||||
|
initramfs_gz = os.path.join(tmp, "initramfs")
|
||||||
|
with open(img, "rb") as src, open(boot_part, "wb") as dst:
|
||||||
|
src.seek(start_lba * 512)
|
||||||
|
remaining = sectors * 512
|
||||||
|
while remaining > 0:
|
||||||
|
chunk = src.read(min(remaining, 1024 * 1024))
|
||||||
|
if not chunk:
|
||||||
|
break
|
||||||
|
dst.write(chunk)
|
||||||
|
remaining -= len(chunk)
|
||||||
|
subprocess.run(
|
||||||
|
[debugfs_bin, "-R", f"dump /initramfs {initramfs_gz}", boot_part],
|
||||||
|
check=True,
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
)
|
||||||
|
with open(initramfs_gz, "rb") as f:
|
||||||
|
raw = gzip.decompress(f.read())
|
||||||
|
|
||||||
|
files = {}
|
||||||
|
pos = 0
|
||||||
|
n = len(raw)
|
||||||
|
while pos + 110 <= n:
|
||||||
|
if raw[pos:pos + 6] not in (b"070701", b"070702"):
|
||||||
|
sys.stderr.write(f"bad cpio header at {pos} in {img}\n")
|
||||||
|
sys.exit(1)
|
||||||
|
namesize = int(raw[pos + 94:pos + 102], 16)
|
||||||
|
filesize = int(raw[pos + 54:pos + 62], 16)
|
||||||
|
name_start = pos + 110
|
||||||
|
name_end = name_start + namesize
|
||||||
|
name = raw[name_start:name_end - 1].decode("utf-8", errors="replace")
|
||||||
|
if name.startswith("./"):
|
||||||
|
name = name[2:]
|
||||||
|
elif name == ".":
|
||||||
|
name = ""
|
||||||
|
data_start = (name_end + 3) & ~3
|
||||||
|
data_end = data_start + filesize
|
||||||
|
if name == "TRAILER!!!":
|
||||||
|
break
|
||||||
|
files[name] = raw[data_start:data_end] if name.startswith("usr/lib/modules/") else b""
|
||||||
|
pos = (data_end + 3) & ~3
|
||||||
|
|
||||||
|
mod_base = "usr/lib/modules/6.12.1-msm8916"
|
||||||
|
dep_key = f"{mod_base}/modules.dep"
|
||||||
|
alias_key = f"{mod_base}/modules.alias"
|
||||||
|
if dep_key not in files or not files[dep_key]:
|
||||||
|
sys.stderr.write(f"missing or empty {dep_key} in {img}\n")
|
||||||
|
sys.exit(1)
|
||||||
|
if alias_key not in files or not files[alias_key]:
|
||||||
|
sys.stderr.write(f"missing or empty {alias_key} in {img}\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
dep_text = files[dep_key].decode("utf-8", errors="replace")
|
||||||
|
alias_text = files[alias_key].decode("utf-8", errors="replace")
|
||||||
|
for line in dep_text.splitlines():
|
||||||
|
for tok in line.split():
|
||||||
|
tok = tok.rstrip(":")
|
||||||
|
if not tok:
|
||||||
|
continue
|
||||||
|
if f"{mod_base}/{tok}" not in files:
|
||||||
|
sys.stderr.write(f"initramfs {img} modules.dep references missing {tok}\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for stale in ("qcom_pil_info", "snd-soc-qcom-common"):
|
||||||
|
if stale in dep_text or stale in alias_text:
|
||||||
|
sys.stderr.write(f"initramfs {img} contains stale metadata for {stale}\n")
|
||||||
|
sys.exit(1)
|
||||||
|
PYEOF
|
||||||
|
then
|
||||||
|
fail "$dev_img initramfs depmod validation failed"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "[check] Network time synchronisation..."
|
echo "[check] Network time synchronisation..."
|
||||||
for f in overlay/rootfs/etc/chrony/chrony.conf \
|
for f in overlay/rootfs/etc/chrony/chrony.conf \
|
||||||
@@ -1237,8 +1340,9 @@ if ! grep -qxF 'MODEM_DRX_MODE=0' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power
|
|||||||
! grep -qxF 'DSDS_SECONDARY_MODE=active' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
! grep -qxF 'DSDS_SECONDARY_MODE=active' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
||||||
! grep -qxF 'CPU_RPM_SLEEP=0' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
! grep -qxF 'CPU_RPM_SLEEP=0' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
||||||
! grep -qxF 'CPU_L2_SLEEP=0' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
! grep -qxF 'CPU_L2_SLEEP=0' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
||||||
|
! grep -qxF 'WIFI_LISTEN_INTERVAL=8' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
||||||
! grep -qxF 'WIFI_SCREEN_OFF_IPV6_MUTE=1' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
! grep -qxF 'WIFI_SCREEN_OFF_IPV6_MUTE=1' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
||||||
! grep -qxF 'WIFI_STANDBY_RAT=keep' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
! grep -qxF 'WIFI_STANDBY_RAT=gsm' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power-policy.conf" || \
|
||||||
! grep -qF 'if [ "$port" = "all" ]; then' "$BASE_DIR/overlay/rootfs/usr/libexec/msm-modem-uim-selection" || \
|
! grep -qF 'if [ "$port" = "all" ]; then' "$BASE_DIR/overlay/rootfs/usr/libexec/msm-modem-uim-selection" || \
|
||||||
! grep -qF 'exec /usr/bin/bananarchy-dsds' "$BASE_DIR/overlay/rootfs/usr/libexec/msm-modem-uim-selection" || \
|
! grep -qF 'exec /usr/bin/bananarchy-dsds' "$BASE_DIR/overlay/rootfs/usr/libexec/msm-modem-uim-selection" || \
|
||||||
grep -qF 'dsds-daemon <<' "$BASE_DIR/overlay/rootfs/usr/libexec/msm-modem-uim-selection" || \
|
grep -qF 'dsds-daemon <<' "$BASE_DIR/overlay/rootfs/usr/libexec/msm-modem-uim-selection" || \
|
||||||
@@ -1250,6 +1354,9 @@ if ! grep -qxF 'MODEM_DRX_MODE=0' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power
|
|||||||
! grep -qF 'exec /usr/bin/bananarchy-session-loop' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-x11-session.sh" || \
|
! grep -qF 'exec /usr/bin/bananarchy-session-loop' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-x11-session.sh" || \
|
||||||
! grep -qF 'for dev in /dev/wwan0at*;' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-power-policy.sh" || \
|
! grep -qF 'for dev in /dev/wwan0at*;' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-power-policy.sh" || \
|
||||||
! grep -qF 'modem-ready) modem_ready ;;' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-power-policy.sh" || \
|
! grep -qF 'modem-ready) modem_ready ;;' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-power-policy.sh" || \
|
||||||
|
! grep -qF 'wifi-up) wifi_up ;;' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-power-policy.sh" || \
|
||||||
|
! grep -qF '/usr/bin/bananarchy-power-policy.sh wifi-up' "$BASE_DIR/overlay/rootfs/etc/NetworkManager/dispatcher.d/10-bananarchy-dpm.sh" || \
|
||||||
|
! grep -qF '/usr/bin/bananarchy-power-policy.sh unpark-rat' "$BASE_DIR/overlay/rootfs/etc/NetworkManager/dispatcher.d/10-bananarchy-dpm.sh" || \
|
||||||
! grep -qF '/usr/bin/bananarchy-power-policy.sh modem-ready' "$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_modem.sh" || \
|
! grep -qF '/usr/bin/bananarchy-power-policy.sh modem-ready' "$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_modem.sh" || \
|
||||||
! grep -qF 'WIFI_OFFLOAD_PATH=/sys/module/wcn36xx/parameters/screen_off_offload' \
|
! grep -qF 'WIFI_OFFLOAD_PATH=/sys/module/wcn36xx/parameters/screen_off_offload' \
|
||||||
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
@@ -1257,6 +1364,10 @@ if ! grep -qxF 'MODEM_DRX_MODE=0' "$BASE_DIR/overlay/rootfs/etc/bananarchy-power
|
|||||||
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
! grep -qF 'SPM_RPM_SLEEP_PATH=/sys/module/cpuidle_qcom_spm/parameters/rpm_sleep' \
|
! grep -qF 'SPM_RPM_SLEEP_PATH=/sys/module/cpuidle_qcom_spm/parameters/rpm_sleep' \
|
||||||
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
|
! grep -qF 'BMS_SCREEN_OFF_PATH=/sys/module/pm8916_bms_vm/parameters/screen_off' \
|
||||||
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
|
! grep -qF 'sync_bms_screen_off' \
|
||||||
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
! grep -qF 'sync_spm_screen_off' \
|
! grep -qF 'sync_spm_screen_off' \
|
||||||
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-display-power-sync" || \
|
||||||
! grep -qF 'sync_schedutil_rate_limit' \
|
! grep -qF 'sync_schedutil_rate_limit' \
|
||||||
@@ -1745,6 +1856,7 @@ for token in 'cover_button' 'lid_is_closed' 'KEY_POWER'; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if ! grep -qF 'blank_timeout = auto' "$COVER_CONF" || \
|
if ! grep -qF 'blank_timeout = auto' "$COVER_CONF" || \
|
||||||
|
! grep -qF 'wake_blank_timeout = 8' "$COVER_CONF" || \
|
||||||
! grep -qF 'backlight_path' "$COVER_CONF"; then
|
! grep -qF 'backlight_path' "$COVER_CONF"; then
|
||||||
fail "cover display config no longer shares the Screen blank timeout"
|
fail "cover display config no longer shares the Screen blank timeout"
|
||||||
fi
|
fi
|
||||||
@@ -1948,6 +2060,44 @@ if ! grep -qF 'isLiveSxmoCallFile' "$BASE_DIR/src/dwm-plugins/phone_data.h" || \
|
|||||||
fail "one or more sxmo_calls readers lost post-call marker filtering"
|
fail "one or more sxmo_calls readers lost post-call marker filtering"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "[check] 72-hour standby battery optimizations (patch 0012, codec analog, DTS set-load, policy)..."
|
||||||
|
if [ ! -f "$BASE_DIR/patches/kernel/0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch" ] || \
|
||||||
|
! grep -qF '0012-msm8909-standby-wifi-wcd-panel-ldo-bms.patch' "$BASE_DIR/scripts/build-kernel-audio.sh"; then
|
||||||
|
fail "kernel patch 0012 or its build-kernel-audio.sh wiring is missing"
|
||||||
|
fi
|
||||||
|
for ko in "$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/codecs/snd-soc-msm8916-analog.ko.zst" \
|
||||||
|
"$BASE_DIR/overlay/rootfs/lib/modules/6.12.1-msm8916/kernel/sound/soc/codecs/snd-soc-msm8916-analog.ko.zst"; do
|
||||||
|
if [ ! -f "$ko" ]; then
|
||||||
|
fail "${ko#"$BASE_DIR/"} is missing; rebuild with scripts/build-kernel-audio.sh"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for dts in \
|
||||||
|
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
|
||||||
|
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
|
||||||
|
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
|
||||||
|
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts" \
|
||||||
|
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
|
||||||
|
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
|
||||||
|
if [ "$(grep -c 'regulator-allow-set-load;' "$dts" 2>/dev/null || echo 0)" -lt 3 ]; then
|
||||||
|
fail "${dts#"$BASE_DIR/"} is missing regulator-allow-set-load on l8/l12"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if ! grep -qF 'msm8905_cam_spmi_restore' "$BASE_DIR/src/msm8905-cam/msm8905-cam.c" || \
|
||||||
|
! grep -qF 'regulator_get_optional' "$BASE_DIR/src/msm8905-cam/msm8905-cam.c" || \
|
||||||
|
grep -qF 'PM8909_LDO6_EN_CTL' "$BASE_DIR/src/msm8905-cam/msm8905-cam.c" || \
|
||||||
|
! grep -qF 'should_skip_while_dark' "$BASE_DIR/src/bananarchy-daemons/bananarchy-run-aligned.c" || \
|
||||||
|
! grep -qF -- '--sig-hysteresis' "$BASE_DIR/src/bananarchy-daemons/bananarchy-dsds.c" || \
|
||||||
|
! grep -qF 'effective_blank_ms' "$BASE_DIR/src/bananarchy-daemons/bananarchy-cover-idle.c" || \
|
||||||
|
! grep -qF 'unpark-rat' "$BASE_DIR/overlay/rootfs/etc/NetworkManager/dispatcher.d/10-bananarchy-dpm.sh" || \
|
||||||
|
grep -qF 'wifi.scan-interval' "$BASE_DIR/overlay/rootfs/etc/NetworkManager/conf.d/10-power.conf"; then
|
||||||
|
fail "one or more 72h standby optimization guards failed"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$BASE_DIR/scripts/test-standby-power-policy.py" ]; then
|
||||||
|
fail "missing host test scripts/test-standby-power-policy.py"
|
||||||
|
elif ! "$BASE_DIR/scripts/test-standby-power-policy.py" >/dev/null 2>&1; then
|
||||||
|
fail "host standby power policy test failed"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$FAILURES" -ne 0 ]; then
|
if [ "$FAILURES" -ne 0 ]; then
|
||||||
echo "[check] $FAILURES check(s) failed."
|
echo "[check] $FAILURES check(s) failed."
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Executable
+357
@@ -0,0 +1,357 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Host regression tests for the 72-hour standby battery optimizations."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
BASE = Path(__file__).resolve().parent.parent
|
||||||
|
RUN_ALIGNED_SRC = BASE / "src/bananarchy-daemons/bananarchy-run-aligned.c"
|
||||||
|
POWER_POLICY_SH = BASE / "overlay/rootfs/usr/bin/bananarchy-power-policy.sh"
|
||||||
|
DISPLAY_SYNC_SH = BASE / "overlay/rootfs/usr/bin/bananarchy-display-power-sync"
|
||||||
|
|
||||||
|
|
||||||
|
def fail(msg):
|
||||||
|
sys.stderr.write(f"[fail] {msg}\n")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
def write_text(path, text):
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_text(text)
|
||||||
|
|
||||||
|
|
||||||
|
def read_lines(path):
|
||||||
|
if not path.exists():
|
||||||
|
return []
|
||||||
|
return [line.rstrip("\n") for line in path.read_text().splitlines() if line.strip()]
|
||||||
|
|
||||||
|
|
||||||
|
def test_run_aligned(tmp):
|
||||||
|
if not shutil.which("gcc"):
|
||||||
|
print("[skip] gcc not present; skipping bananarchy-run-aligned host build")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
bin_path = tmp / "bananarchy-run-aligned"
|
||||||
|
comp = subprocess.run(
|
||||||
|
["gcc", "-O2", "-Wall", "-Wextra", "-Werror",
|
||||||
|
str(RUN_ALIGNED_SRC), "-o", str(bin_path)],
|
||||||
|
capture_output=True, text=True
|
||||||
|
)
|
||||||
|
if comp.returncode != 0:
|
||||||
|
return fail(f"failed to compile bananarchy-run-aligned.c:\n{comp.stderr}")
|
||||||
|
|
||||||
|
tick_log = tmp / "ticks.log"
|
||||||
|
helper = tmp / "tick_helper.sh"
|
||||||
|
write_text(helper, f"#!/bin/sh\necho tick >> '{tick_log}'\n")
|
||||||
|
helper.chmod(0o755)
|
||||||
|
|
||||||
|
lid_file = tmp / "lid-state"
|
||||||
|
bl_power = tmp / "bl_power"
|
||||||
|
bl_bright = tmp / "brightness"
|
||||||
|
|
||||||
|
# 1) Initial tick always runs even if dark; subsequent tick while closed skips.
|
||||||
|
write_text(lid_file, "closed\n")
|
||||||
|
write_text(bl_power, "4\n")
|
||||||
|
write_text(bl_bright, "0\n")
|
||||||
|
env = os.environ.copy()
|
||||||
|
env["BANANARCHY_LID_STATE_PATH"] = str(lid_file)
|
||||||
|
env["BANANARCHY_BL_POWER_PATH"] = str(bl_power)
|
||||||
|
env["BANANARCHY_BL_BRIGHTNESS_PATH"] = str(bl_bright)
|
||||||
|
env.pop("BANANARCHY_RUN_ALIGNED_ALWAYS", None)
|
||||||
|
|
||||||
|
proc = subprocess.Popen([str(bin_path), "1", str(helper)], env=env)
|
||||||
|
try:
|
||||||
|
deadline = time.monotonic() + 2.5
|
||||||
|
while time.monotonic() < deadline and not tick_log.exists():
|
||||||
|
time.sleep(0.05)
|
||||||
|
# Wait past at least two 1s wall-clock boundaries while closed/dark.
|
||||||
|
time.sleep(2.2)
|
||||||
|
finally:
|
||||||
|
proc.terminate()
|
||||||
|
proc.wait(timeout=5)
|
||||||
|
|
||||||
|
closed_ticks = read_lines(tick_log)
|
||||||
|
if len(closed_ticks) != 1:
|
||||||
|
return fail(f"expected exactly 1 startup tick while closed/dark, got {len(closed_ticks)}: {closed_ticks}")
|
||||||
|
|
||||||
|
# 2) While open and lit, periodic ticks execute normally.
|
||||||
|
tick_log.unlink()
|
||||||
|
write_text(lid_file, "open\n")
|
||||||
|
write_text(bl_power, "0\n")
|
||||||
|
write_text(bl_bright, "80\n")
|
||||||
|
proc = subprocess.Popen([str(bin_path), "1", str(helper)], env=env)
|
||||||
|
try:
|
||||||
|
deadline = time.monotonic() + 4.5
|
||||||
|
while time.monotonic() < deadline and len(read_lines(tick_log)) < 2:
|
||||||
|
time.sleep(0.05)
|
||||||
|
finally:
|
||||||
|
proc.terminate()
|
||||||
|
proc.wait(timeout=5)
|
||||||
|
|
||||||
|
open_ticks = read_lines(tick_log)
|
||||||
|
if len(open_ticks) < 2:
|
||||||
|
return fail(f"expected >= 2 ticks while open/lit, got {len(open_ticks)}")
|
||||||
|
|
||||||
|
# 3) Even with lid open, bl_power=4 skips periodic ticks after initial run.
|
||||||
|
tick_log.unlink()
|
||||||
|
write_text(bl_power, "4\n")
|
||||||
|
write_text(bl_bright, "0\n")
|
||||||
|
proc = subprocess.Popen([str(bin_path), "1", str(helper)], env=env)
|
||||||
|
try:
|
||||||
|
time.sleep(2.2)
|
||||||
|
finally:
|
||||||
|
proc.terminate()
|
||||||
|
proc.wait(timeout=5)
|
||||||
|
|
||||||
|
dim_ticks = read_lines(tick_log)
|
||||||
|
if len(dim_ticks) != 1:
|
||||||
|
return fail(f"expected exactly 1 startup tick when bl_power=4/brightness=0, got {len(dim_ticks)}")
|
||||||
|
|
||||||
|
print("[ok] bananarchy-run-aligned skips dark periodic ticks while running startup tick")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def make_mock_qmicli(tmp, reg_state_file):
|
||||||
|
qmi_log = tmp / "qmi.log"
|
||||||
|
pref_file = tmp / "pref.state"
|
||||||
|
write_text(pref_file, "gsm|umts|lte\n")
|
||||||
|
mock = tmp / "mock_qmicli"
|
||||||
|
write_text(mock, f"""#!/bin/sh
|
||||||
|
echo "$*" >> '{qmi_log}'
|
||||||
|
case "$1" in
|
||||||
|
--nas-get-system-selection-preference)
|
||||||
|
pref="$(cat '{pref_file}' 2>/dev/null || echo 'gsm|umts|lte')"
|
||||||
|
echo "Mode preference: '$pref'"
|
||||||
|
;;
|
||||||
|
--nas-set-system-selection-preference=*)
|
||||||
|
val="${{1#--nas-set-system-selection-preference=}}"
|
||||||
|
printf '%s\n' "$val" > '{pref_file}'
|
||||||
|
;;
|
||||||
|
--nas-get-serving-system)
|
||||||
|
st="$(cat '{reg_state_file}' 2>/dev/null || echo 'registered')"
|
||||||
|
echo "Registration state: '$st'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
|
""")
|
||||||
|
mock.chmod(0o755)
|
||||||
|
return mock, qmi_log, pref_file
|
||||||
|
|
||||||
|
|
||||||
|
def run_policy(env, arg):
|
||||||
|
return subprocess.run(
|
||||||
|
[str(POWER_POLICY_SH), arg],
|
||||||
|
env=env, capture_output=True, text=True, timeout=15
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_power_policy_rat(tmp):
|
||||||
|
reg_file = tmp / "reg.state"
|
||||||
|
mock_qmi, qmi_log, pref_file = make_mock_qmicli(tmp, reg_file)
|
||||||
|
conf = tmp / "power-policy.conf"
|
||||||
|
rundir = tmp / "rundir"
|
||||||
|
calls_dir = tmp / "sxmo_calls"
|
||||||
|
calls_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
oper = tmp / "wlan0.operstate"
|
||||||
|
offload = tmp / "screen_off_offload"
|
||||||
|
listen_sysfs = tmp / "listen_interval"
|
||||||
|
fake_dsds = tmp / "fake-dsds"
|
||||||
|
dsds_log = tmp / "dsds.log"
|
||||||
|
write_text(fake_dsds, f"#!/bin/sh\necho \"$*\" >> '{dsds_log}'\n")
|
||||||
|
fake_dsds.chmod(0o755)
|
||||||
|
|
||||||
|
write_text(conf, "WIFI_STANDBY_RAT=gsm\nWIFI_LISTEN_INTERVAL=8\nCPU_RPM_SLEEP=0\nCPU_L2_SLEEP=0\n")
|
||||||
|
write_text(oper, "up\n")
|
||||||
|
write_text(offload, "Y\n")
|
||||||
|
write_text(listen_sysfs, "1\n")
|
||||||
|
|
||||||
|
env = os.environ.copy()
|
||||||
|
env.update({
|
||||||
|
"BANANARCHY_POWER_NO_ROOT": "1",
|
||||||
|
"BANANARCHY_POWER_CONF": str(conf),
|
||||||
|
"BANANARCHY_POWER_RUNDIR": str(rundir),
|
||||||
|
"BANANARCHY_QMICLI_BIN": str(mock_qmi),
|
||||||
|
"BANANARCHY_CALLS_DIR": str(calls_dir),
|
||||||
|
"BANANARCHY_WLAN_OPERSTATE_PATH": str(oper),
|
||||||
|
"BANANARCHY_WIFI_OFFLOAD_PATH": str(offload),
|
||||||
|
"BANANARCHY_WIFI_LISTEN_SYSFS": str(listen_sysfs),
|
||||||
|
"BANANARCHY_RAT_REG_POLL_SEC": "0",
|
||||||
|
"BANANARCHY_RAT_SETTLE_SEC": "0",
|
||||||
|
"BANANARCHY_DSDS_BIN": str(fake_dsds),
|
||||||
|
"BANANARCHY_ACCEPT_RA_PATH": str(tmp / "nonexistent_ra"),
|
||||||
|
"BANANARCHY_SPM_PARAM_DIR": str(tmp / "nonexistent_spm"),
|
||||||
|
"BANANARCHY_MODPROBE_CONF": str(tmp / "modprobe.conf"),
|
||||||
|
})
|
||||||
|
|
||||||
|
# 1) GSM registered -> parks to gsm and unpark-rat restores gsm|umts|lte.
|
||||||
|
write_text(reg_file, "registered\n")
|
||||||
|
res = run_policy(env, "_park_rat")
|
||||||
|
if res.returncode != 0:
|
||||||
|
return fail(f"_park_rat failed: {res.stderr}")
|
||||||
|
if not (rundir / "rat_parked").exists():
|
||||||
|
return fail("expected rat_parked marker when GSM registered")
|
||||||
|
if pref_file.read_text().strip() != "gsm":
|
||||||
|
return fail(f"expected pref gsm while parked, got {pref_file.read_text().strip()}")
|
||||||
|
|
||||||
|
res = run_policy(env, "unpark-rat")
|
||||||
|
if res.returncode != 0:
|
||||||
|
return fail(f"unpark-rat failed: {res.stderr}")
|
||||||
|
if (rundir / "rat_parked").exists():
|
||||||
|
return fail("expected rat_parked cleared after unpark-rat")
|
||||||
|
if pref_file.read_text().strip() != "gsm|umts|lte":
|
||||||
|
return fail(f"expected pref restored to gsm|umts|lte, got {pref_file.read_text().strip()}")
|
||||||
|
|
||||||
|
# 2) Active call guard blocks parking; incoming_ended does not.
|
||||||
|
active_call = calls_dir / "voice_1.active"
|
||||||
|
write_text(active_call, "")
|
||||||
|
res = run_policy(env, "_park_rat")
|
||||||
|
if res.returncode != 0 or (rundir / "rat_parked").exists():
|
||||||
|
return fail("active call must block GSM RAT parking")
|
||||||
|
active_call.unlink()
|
||||||
|
write_text(calls_dir / "voice_1.incoming_ended", "")
|
||||||
|
res = run_policy(env, "_park_rat")
|
||||||
|
if res.returncode != 0 or not (rundir / "rat_parked").exists():
|
||||||
|
return fail("incoming_ended post-call marker must not block GSM RAT parking")
|
||||||
|
run_policy(env, "unpark-rat")
|
||||||
|
|
||||||
|
# 3) 2G-sunset carrier (not-registered-searching) auto-restores & sets gsm_unsupported.
|
||||||
|
write_text(reg_file, "not-registered-searching\n")
|
||||||
|
res = run_policy(env, "_park_rat")
|
||||||
|
if res.returncode != 0:
|
||||||
|
return fail(f"_park_rat fallback failed: {res.stderr}")
|
||||||
|
if (rundir / "rat_parked").exists():
|
||||||
|
return fail("rat_parked must not remain when GSM registration fails")
|
||||||
|
if not (rundir / "gsm_unsupported").exists():
|
||||||
|
return fail("gsm_unsupported must be touched when GSM registration fails")
|
||||||
|
if pref_file.read_text().strip() != "gsm|umts|lte":
|
||||||
|
return fail(f"expected fallback restore to gsm|umts|lte, got {pref_file.read_text().strip()}")
|
||||||
|
|
||||||
|
# Subsequent _park_rat must skip QMI immediately because gsm_unsupported exists.
|
||||||
|
qmi_log.unlink()
|
||||||
|
write_text(reg_file, "registered\n")
|
||||||
|
res = run_policy(env, "_park_rat")
|
||||||
|
if res.returncode != 0 or qmi_log.exists():
|
||||||
|
return fail("expected no QMI calls once gsm_unsupported exists")
|
||||||
|
|
||||||
|
# 4) screenoff / screenon invoke bananarchy-dsds --sig-hysteresis dark / wake.
|
||||||
|
res = run_policy(env, "screenoff")
|
||||||
|
if res.returncode != 0:
|
||||||
|
return fail(f"screenoff failed: {res.stderr}")
|
||||||
|
res = run_policy(env, "screenon")
|
||||||
|
if res.returncode != 0:
|
||||||
|
return fail(f"screenon failed: {res.stderr}")
|
||||||
|
dsds_calls = read_lines(dsds_log)
|
||||||
|
if dsds_calls != ["--sig-hysteresis dark", "--sig-hysteresis wake"]:
|
||||||
|
return fail(f"unexpected DSDS hysteresis calls: {dsds_calls}")
|
||||||
|
|
||||||
|
# boot clears gsm_unsupported so reboot/policy reset can re-test 2G and syncs listen_interval sysfs.
|
||||||
|
write_text(offload, "N\n")
|
||||||
|
res = run_policy(env, "boot")
|
||||||
|
if res.returncode != 0 or (rundir / "gsm_unsupported").exists():
|
||||||
|
return fail("boot must clear gsm_unsupported")
|
||||||
|
if listen_sysfs.read_text().strip() != "8":
|
||||||
|
return fail(f"expected listen_interval sysfs=8 after boot, got {listen_sysfs.read_text().strip()}")
|
||||||
|
|
||||||
|
# 5) wifi-up while lit does nothing; while dark it arms and parks RAT.
|
||||||
|
res = run_policy(env, "wifi-up")
|
||||||
|
if res.returncode != 0 or (rundir / "rat.token").exists() or (rundir / "rat_parked").exists():
|
||||||
|
return fail("wifi-up must not arm RAT parking while screen is lit")
|
||||||
|
write_text(offload, "Y\n")
|
||||||
|
write_text(reg_file, "registered\n")
|
||||||
|
res = run_policy(env, "wifi-up")
|
||||||
|
if res.returncode != 0:
|
||||||
|
return fail(f"wifi-up dark failed: {res.stderr}")
|
||||||
|
deadline = time.monotonic() + 2.0
|
||||||
|
while time.monotonic() < deadline and not (rundir / "rat_parked").exists():
|
||||||
|
time.sleep(0.05)
|
||||||
|
time.sleep(0.05)
|
||||||
|
if not (rundir / "rat_parked").exists():
|
||||||
|
return fail("wifi-up dark did not park RAT")
|
||||||
|
res = run_policy(env, "unpark-rat")
|
||||||
|
if res.returncode != 0 or (rundir / "rat_parked").exists():
|
||||||
|
return fail("unpark-rat failed after wifi-up")
|
||||||
|
|
||||||
|
print("[ok] bananarchy-power-policy.sh GSM verification, fallback, call guard, wifi-up, unpark-rat, and DSDS hysteresis")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_bms_screen_off_sync(tmp):
|
||||||
|
br = tmp / "brightness"
|
||||||
|
blp = tmp / "bl_power"
|
||||||
|
dpms = tmp / "dpms"
|
||||||
|
offload = tmp / "screen_off_offload"
|
||||||
|
bms = tmp / "bms_screen_off"
|
||||||
|
spm_off = tmp / "spm_screen_off"
|
||||||
|
spm_rpm = tmp / "spm_rpm_sleep"
|
||||||
|
lid_profile = tmp / "lid-profile"
|
||||||
|
lid_state = tmp / "lid-state"
|
||||||
|
cover_marker = tmp / "cover-backlight"
|
||||||
|
|
||||||
|
write_text(lid_profile, "flip\n")
|
||||||
|
write_text(lid_state, "closed\n")
|
||||||
|
write_text(br, "0\n")
|
||||||
|
write_text(blp, "4\n")
|
||||||
|
write_text(dpms, "Off\n")
|
||||||
|
write_text(offload, "N\n")
|
||||||
|
write_text(bms, "N\n")
|
||||||
|
write_text(spm_off, "N\n")
|
||||||
|
write_text(spm_rpm, "N\n")
|
||||||
|
|
||||||
|
env = os.environ.copy()
|
||||||
|
env.update({
|
||||||
|
"BANANARCHY_LID_PROFILE": str(lid_profile),
|
||||||
|
"BANANARCHY_LID_STATE": str(lid_state),
|
||||||
|
"BANANARCHY_BR_PATH": str(br),
|
||||||
|
"BANANARCHY_BL_POWER_PATH": str(blp),
|
||||||
|
"BANANARCHY_DPMS_PATH": str(dpms),
|
||||||
|
"BANANARCHY_WIFI_OFFLOAD_PATH": str(offload),
|
||||||
|
"BANANARCHY_BMS_SCREEN_OFF_PATH": str(bms),
|
||||||
|
"BANANARCHY_SPM_SCREEN_OFF_PATH": str(spm_off),
|
||||||
|
"BANANARCHY_SPM_RPM_SLEEP_PATH": str(spm_rpm),
|
||||||
|
"BANANARCHY_COVER_MARKER": str(cover_marker),
|
||||||
|
"BANANARCHY_FORCE_MARKER": str(tmp / "cover-bl-force"),
|
||||||
|
"BANANARCHY_STATE_CACHE": str(tmp / "cover-power-state"),
|
||||||
|
"BANANARCHY_KBD_PATH": str(tmp / "kbd"),
|
||||||
|
"BANANARCHY_RL_PATH": str(tmp / "rl"),
|
||||||
|
"BANANARCHY_GPU_GOV_PATH": str(tmp / "gpu_gov"),
|
||||||
|
})
|
||||||
|
|
||||||
|
# Dark closed-flip -> both Wi-Fi offload and pm8916_bms_vm screen_off = Y.
|
||||||
|
res = subprocess.run([str(DISPLAY_SYNC_SH)], env=env, capture_output=True, text=True)
|
||||||
|
if res.returncode != 0:
|
||||||
|
return fail(f"display-power-sync dark failed: {res.stderr}")
|
||||||
|
if offload.read_text().strip() != "Y" or bms.read_text().strip() != "Y":
|
||||||
|
return fail(f"expected offload=Y and bms=Y, got offload={offload.read_text().strip()} bms={bms.read_text().strip()}")
|
||||||
|
|
||||||
|
# Open flip with lit panel -> both revert to N.
|
||||||
|
write_text(lid_state, "open\n")
|
||||||
|
write_text(br, "80\n")
|
||||||
|
write_text(blp, "0\n")
|
||||||
|
write_text(dpms, "On\n")
|
||||||
|
res = subprocess.run([str(DISPLAY_SYNC_SH)], env=env, capture_output=True, text=True)
|
||||||
|
if res.returncode != 0:
|
||||||
|
return fail(f"display-power-sync wake failed: {res.stderr}")
|
||||||
|
if offload.read_text().strip() != "N" or bms.read_text().strip() != "N":
|
||||||
|
return fail(f"expected offload=N and bms=N on wake, got offload={offload.read_text().strip()} bms={bms.read_text().strip()}")
|
||||||
|
|
||||||
|
print("[ok] bananarchy-display-power-sync toggles pm8916_bms_vm screen_off alongside Wi-Fi offload")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
with tempfile.TemporaryDirectory(prefix="bananarchy-standby-test-") as td:
|
||||||
|
tmp = Path(td)
|
||||||
|
for fn in (test_run_aligned, test_power_policy_rat, test_bms_screen_off_sync):
|
||||||
|
rc = fn(tmp)
|
||||||
|
if rc != 0:
|
||||||
|
return rc
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -611,6 +611,8 @@ struct state {
|
|||||||
long long last_input_ms;
|
long long last_input_ms;
|
||||||
long long closed_since_ms;
|
long long closed_since_ms;
|
||||||
long long blank_ms;
|
long long blank_ms;
|
||||||
|
long long wake_blank_ms;
|
||||||
|
int wake_capped;
|
||||||
char blank_cfg[32];
|
char blank_cfg[32];
|
||||||
char backlight_path[128];
|
char backlight_path[128];
|
||||||
int backlight_level;
|
int backlight_level;
|
||||||
@@ -1946,7 +1948,6 @@ static const char *cover_kernel_draw(struct cover_hw *hw,
|
|||||||
return "kernel";
|
return "kernel";
|
||||||
}
|
}
|
||||||
cover_kernel_backlight(hw, 0);
|
cover_kernel_backlight(hw, 0);
|
||||||
cover_x11_show_black(hw);
|
|
||||||
if(hw->kernel_lit > 0)
|
if(hw->kernel_lit > 0)
|
||||||
cover_kernel_display_off(hw, 1, 120);
|
cover_kernel_display_off(hw, 1, 120);
|
||||||
cover_kernel_display_off(hw, 0, 120);
|
cover_kernel_display_off(hw, 0, 120);
|
||||||
@@ -2095,6 +2096,19 @@ static void refresh_blank_timeout(struct state *state)
|
|||||||
state->blank_ms = blank_timeout_ms(state->blank_cfg);
|
state->blank_ms = blank_timeout_ms(state->blank_cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static long long effective_blank_ms(const struct state *state)
|
||||||
|
{
|
||||||
|
const char *noidle = getenv("BANANARCHY_COVER_NOIDLE_PATH");
|
||||||
|
if(!noidle || !noidle[0])
|
||||||
|
noidle = MAIN_NOIDLE_PATH;
|
||||||
|
if(state->wake_capped && state->wake_blank_ms > 0 &&
|
||||||
|
access(noidle, F_OK) != 0 &&
|
||||||
|
(state->blank_ms == 0 || state->blank_ms > state->wake_blank_ms)) {
|
||||||
|
return state->wake_blank_ms;
|
||||||
|
}
|
||||||
|
return state->blank_ms;
|
||||||
|
}
|
||||||
|
|
||||||
static int config_level(const char *value, int fallback)
|
static int config_level(const char *value, int fallback)
|
||||||
{
|
{
|
||||||
long v = strtol(value, NULL, 10);
|
long v = strtol(value, NULL, 10);
|
||||||
@@ -2206,6 +2220,8 @@ static void read_config(const char *path, char *socket_path, size_t splen,
|
|||||||
safe_copy(socket_path, splen, DEFAULT_SOCKET);
|
safe_copy(socket_path, splen, DEFAULT_SOCKET);
|
||||||
safe_copy(fb_path, fblen, DEFAULT_FB);
|
safe_copy(fb_path, fblen, DEFAULT_FB);
|
||||||
safe_copy(state->blank_cfg, sizeof(state->blank_cfg), "auto");
|
safe_copy(state->blank_cfg, sizeof(state->blank_cfg), "auto");
|
||||||
|
state->wake_blank_ms = 0;
|
||||||
|
state->wake_capped = 0;
|
||||||
state->backlight_path[0] = '\0';
|
state->backlight_path[0] = '\0';
|
||||||
state->backlight_level = 160;
|
state->backlight_level = 160;
|
||||||
if(!handle) {
|
if(!handle) {
|
||||||
@@ -2240,7 +2256,12 @@ static void read_config(const char *path, char *socket_path, size_t splen,
|
|||||||
state->backlight_level = (int)v;
|
state->backlight_level = (int)v;
|
||||||
} else if(strcmp(key, "blank_timeout") == 0)
|
} else if(strcmp(key, "blank_timeout") == 0)
|
||||||
safe_copy(state->blank_cfg, sizeof(state->blank_cfg), value);
|
safe_copy(state->blank_cfg, sizeof(state->blank_cfg), value);
|
||||||
else if(strcmp(key, "backend") == 0)
|
else if(strcmp(key, "wake_blank_timeout") == 0) {
|
||||||
|
char *end = NULL;
|
||||||
|
v = strtol(value, &end, 10);
|
||||||
|
if(end != value && v >= 0 && v <= 86400)
|
||||||
|
state->wake_blank_ms = (long long)v * 1000LL;
|
||||||
|
} else if(strcmp(key, "backend") == 0)
|
||||||
safe_copy(hw->backend, sizeof(hw->backend), value);
|
safe_copy(hw->backend, sizeof(hw->backend), value);
|
||||||
else if(strcmp(key, "spi_device") == 0)
|
else if(strcmp(key, "spi_device") == 0)
|
||||||
safe_copy(hw->spi_path, sizeof(hw->spi_path), value);
|
safe_copy(hw->spi_path, sizeof(hw->spi_path), value);
|
||||||
@@ -2373,6 +2394,7 @@ static void cover_wake(struct state *state, int *redraw)
|
|||||||
refresh_blank_timeout(state);
|
refresh_blank_timeout(state);
|
||||||
if(strcmp(state->lid, "closed") == 0 && state->enabled && !state->test) {
|
if(strcmp(state->lid, "closed") == 0 && state->enabled && !state->test) {
|
||||||
state->visible = 1;
|
state->visible = 1;
|
||||||
|
state->wake_capped = 1;
|
||||||
state->last_input_ms = now_ms();
|
state->last_input_ms = now_ms();
|
||||||
*redraw = 1;
|
*redraw = 1;
|
||||||
}
|
}
|
||||||
@@ -2430,6 +2452,7 @@ static void handle_command(char *buffer, struct state *state,
|
|||||||
long long now = now_ms();
|
long long now = now_ms();
|
||||||
refresh_blank_timeout(state);
|
refresh_blank_timeout(state);
|
||||||
state->visible = 0;
|
state->visible = 0;
|
||||||
|
state->wake_capped = 0;
|
||||||
state->last_input_ms = now;
|
state->last_input_ms = now;
|
||||||
state->closed_since_ms = new_closed ? now : 0;
|
state->closed_since_ms = new_closed ? now : 0;
|
||||||
*redraw = 1;
|
*redraw = 1;
|
||||||
@@ -2615,6 +2638,13 @@ static void handle_command(char *buffer, struct state *state,
|
|||||||
refresh_blank_timeout(state);
|
refresh_blank_timeout(state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(strcmp(key, "wake_blank_timeout") == 0) {
|
||||||
|
char *end = NULL;
|
||||||
|
long wv = strtol(value, &end, 10);
|
||||||
|
if(end != value && wv >= 0 && wv <= 86400)
|
||||||
|
state->wake_blank_ms = (long long)wv * 1000LL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
/* Runtime polarity knobs and a one-command rollback for the physical
|
/* Runtime polarity knobs and a one-command rollback for the physical
|
||||||
* sign-off. Releasing forces the next draw to re-init the panel. */
|
* sign-off. Releasing forces the next draw to re-init the panel. */
|
||||||
if(strcmp(key, "backend") == 0) {
|
if(strcmp(key, "backend") == 0) {
|
||||||
@@ -2691,6 +2721,7 @@ static void handle_command(char *buffer, struct state *state,
|
|||||||
cover_bus_release(hw);
|
cover_bus_release(hw);
|
||||||
state->test = 2;
|
state->test = 2;
|
||||||
state->visible = 1;
|
state->visible = 1;
|
||||||
|
state->wake_capped = 0;
|
||||||
state->last_input_ms = now_ms();
|
state->last_input_ms = now_ms();
|
||||||
*redraw = 1;
|
*redraw = 1;
|
||||||
} else if(strcmp(command, "TEST") == 0) {
|
} else if(strcmp(command, "TEST") == 0) {
|
||||||
@@ -2701,11 +2732,13 @@ static void handle_command(char *buffer, struct state *state,
|
|||||||
*redraw = 1;
|
*redraw = 1;
|
||||||
} else if(strcmp(command, "BLANK") == 0) {
|
} else if(strcmp(command, "BLANK") == 0) {
|
||||||
state->visible = 0;
|
state->visible = 0;
|
||||||
|
state->wake_capped = 0;
|
||||||
*redraw = 1;
|
*redraw = 1;
|
||||||
} else if(strcmp(command, "UNBLANK") == 0) {
|
} else if(strcmp(command, "UNBLANK") == 0) {
|
||||||
refresh_blank_timeout(state);
|
refresh_blank_timeout(state);
|
||||||
if(strcmp(state->lid, "closed") == 0) {
|
if(strcmp(state->lid, "closed") == 0) {
|
||||||
state->visible = 1;
|
state->visible = 1;
|
||||||
|
state->wake_capped = 0;
|
||||||
state->last_input_ms = now_ms();
|
state->last_input_ms = now_ms();
|
||||||
}
|
}
|
||||||
*redraw = 1;
|
*redraw = 1;
|
||||||
@@ -2846,12 +2879,14 @@ int main(int argc, char **argv)
|
|||||||
refresh_blank_timeout(&state);
|
refresh_blank_timeout(&state);
|
||||||
if(next < 1)
|
if(next < 1)
|
||||||
next = 1;
|
next = 1;
|
||||||
|
long long eff_blank = effective_blank_ms(&state);
|
||||||
if(cover_hold_awake(&state)) {
|
if(cover_hold_awake(&state)) {
|
||||||
state.last_input_ms = now;
|
state.last_input_ms = now;
|
||||||
} else if(state.blank_ms > 0) {
|
} else if(eff_blank > 0) {
|
||||||
long long remaining = state.blank_ms - (now - state.last_input_ms);
|
long long remaining = eff_blank - (now - state.last_input_ms);
|
||||||
if(remaining <= 0) {
|
if(remaining <= 0) {
|
||||||
state.visible = 0;
|
state.visible = 0;
|
||||||
|
state.wake_capped = 0;
|
||||||
redraw = 1;
|
redraw = 1;
|
||||||
} else if(remaining < next) {
|
} else if(remaining < next) {
|
||||||
next = remaining;
|
next = remaining;
|
||||||
@@ -2877,10 +2912,11 @@ int main(int argc, char **argv)
|
|||||||
long long interval = strcmp(hw.backend, "kernel") == 0 ?
|
long long interval = strcmp(hw.backend, "kernel") == 0 ?
|
||||||
KERNEL_REDRAW_MS : CLOCK_REDRAW_MS;
|
KERNEL_REDRAW_MS : CLOCK_REDRAW_MS;
|
||||||
long long next = interval;
|
long long next = interval;
|
||||||
|
long long eff_blank = effective_blank_ms(&state);
|
||||||
if(cover_hold_awake(&state)) {
|
if(cover_hold_awake(&state)) {
|
||||||
state.last_input_ms = now;
|
state.last_input_ms = now;
|
||||||
} else if(state.blank_ms > 0) {
|
} else if(eff_blank > 0) {
|
||||||
long long remaining = state.blank_ms - (now - state.last_input_ms);
|
long long remaining = eff_blank - (now - state.last_input_ms);
|
||||||
if(remaining < 1)
|
if(remaining < 1)
|
||||||
remaining = 1;
|
remaining = 1;
|
||||||
if(remaining < next)
|
if(remaining < next)
|
||||||
|
|||||||
@@ -1950,13 +1950,70 @@ int main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int main(void)
|
static int apply_sig_hysteresis(const char *mode)
|
||||||
|
{
|
||||||
|
struct sockaddr_qrtr nas_addr;
|
||||||
|
int dark, ns, sub;
|
||||||
|
uint16_t txn = 1;
|
||||||
|
|
||||||
|
if(strcmp(mode, "dark") == 0)
|
||||||
|
dark = 1;
|
||||||
|
else if(strcmp(mode, "wake") == 0)
|
||||||
|
dark = 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if(lookup_srv(3, &nas_addr) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ns = socket(AF_QIPCRTR, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||||
|
if(ns < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for(sub = 0; sub <= 1; sub++) {
|
||||||
|
uint8_t bind_tlv[7] = { 0x01, 0x04, 0x00, (uint8_t)sub, 0x00, 0x00, 0x00 };
|
||||||
|
uint8_t resp[256];
|
||||||
|
size_t rlen = 0;
|
||||||
|
|
||||||
|
qmi_req(ns, &nas_addr, txn++, 0x006F, bind_tlv, sizeof(bind_tlv), 150,
|
||||||
|
resp, sizeof(resp), &rlen);
|
||||||
|
|
||||||
|
if(dark) {
|
||||||
|
/* Thresholds: RSSI (-105, -75 dBm), LTE RSRP (-120, -90 dBm) to suppress
|
||||||
|
* minor standby radio fluctuations from waking APSS over QRTR. */
|
||||||
|
uint8_t sig_tlvs[] = {
|
||||||
|
0x10, 0x03, 0x00, 0x02, (uint8_t)(int8_t)-105, (uint8_t)(int8_t)-75,
|
||||||
|
0x13, 0x05, 0x00, 0x02, 0x88, 0xff, 0xa6, 0xff
|
||||||
|
};
|
||||||
|
qmi_req(ns, &nas_addr, txn++, 0x004F, sig_tlvs, sizeof(sig_tlvs), 150,
|
||||||
|
resp, sizeof(resp), &rlen);
|
||||||
|
} else {
|
||||||
|
uint8_t sig_tlvs[] = {
|
||||||
|
0x10, 0x06, 0x00, 0x05,
|
||||||
|
(uint8_t)(int8_t)-108, (uint8_t)(int8_t)-98, (uint8_t)(int8_t)-88,
|
||||||
|
(uint8_t)(int8_t)-78, (uint8_t)(int8_t)-68,
|
||||||
|
0x13, 0x0b, 0x00, 0x05,
|
||||||
|
0x88, 0xff, 0x92, 0xff, 0x9c, 0xff, 0xa6, 0xff, 0xb0, 0xff
|
||||||
|
};
|
||||||
|
qmi_req(ns, &nas_addr, txn++, 0x004F, sig_tlvs, sizeof(sig_tlvs), 150,
|
||||||
|
resp, sizeof(resp), &rlen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(ns);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int lock_fd;
|
int lock_fd;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
if(argc >= 3 && strcmp(argv[1], "--sig-hysteresis") == 0)
|
||||||
|
return apply_sig_hysteresis(argv[2]);
|
||||||
|
|
||||||
lock_fd = lock_singleton(LOCK_PATH);
|
lock_fd = lock_singleton(LOCK_PATH);
|
||||||
if(lock_fd < 0)
|
if(lock_fd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -67,11 +67,76 @@ static void aligned_sleep(long interval)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int read_small_file(const char *path, char *buf, size_t len)
|
||||||
|
{
|
||||||
|
FILE *f = fopen(path, "r");
|
||||||
|
size_t n;
|
||||||
|
if(!f)
|
||||||
|
return 0;
|
||||||
|
n = fread(buf, 1, len - 1, f);
|
||||||
|
fclose(f);
|
||||||
|
buf[n] = '\0';
|
||||||
|
return n > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip periodic background ticks while the device is dark or the flip is closed
|
||||||
|
* so idle statusbar/helper forks do not wake APSS every minute in standby. */
|
||||||
|
static int should_skip_while_dark(void)
|
||||||
|
{
|
||||||
|
const char *always = getenv("BANANARCHY_RUN_ALIGNED_ALWAYS");
|
||||||
|
const char *lid_path = getenv("BANANARCHY_LID_STATE_PATH");
|
||||||
|
const char *blp_path = getenv("BANANARCHY_BL_POWER_PATH");
|
||||||
|
const char *br_path = getenv("BANANARCHY_BL_BRIGHTNESS_PATH");
|
||||||
|
char buf[64];
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if(always && strcmp(always, "1") == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(!lid_path || !lid_path[0])
|
||||||
|
lid_path = "/run/bananarchy/lid-state";
|
||||||
|
if(read_small_file(lid_path, buf, sizeof(buf))) {
|
||||||
|
p = buf;
|
||||||
|
while(*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r')
|
||||||
|
p++;
|
||||||
|
if(strncmp(p, "closed", 6) == 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!blp_path || !blp_path[0])
|
||||||
|
blp_path = "/sys/class/backlight/backlight/bl_power";
|
||||||
|
if(read_small_file(blp_path, buf, sizeof(buf))) {
|
||||||
|
p = buf;
|
||||||
|
while(*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r')
|
||||||
|
p++;
|
||||||
|
if(*p >= '1' && *p <= '9')
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!br_path || !br_path[0])
|
||||||
|
br_path = "/sys/class/backlight/backlight/brightness";
|
||||||
|
if(read_small_file(br_path, buf, sizeof(buf))) {
|
||||||
|
char *end = NULL;
|
||||||
|
long v;
|
||||||
|
p = buf;
|
||||||
|
while(*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r')
|
||||||
|
p++;
|
||||||
|
if(*p != '\0') {
|
||||||
|
v = strtol(p, &end, 10);
|
||||||
|
if(end != p && v <= 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
long interval;
|
long interval;
|
||||||
|
int first_run = 1;
|
||||||
|
|
||||||
if(argc < 3) {
|
if(argc < 3) {
|
||||||
fprintf(stderr, "Usage: %s <interval_sec> <cmd> [args...]\n", argv[0]);
|
fprintf(stderr, "Usage: %s <interval_sec> <cmd> [args...]\n", argv[0]);
|
||||||
@@ -94,28 +159,31 @@ int main(int argc, char **argv)
|
|||||||
sigaction(SIGUSR1, &sa, NULL);
|
sigaction(SIGUSR1, &sa, NULL);
|
||||||
|
|
||||||
while(!stop_requested) {
|
while(!stop_requested) {
|
||||||
pid_t pid = fork();
|
if(first_run || !should_skip_while_dark()) {
|
||||||
if(pid == 0) {
|
pid_t pid = fork();
|
||||||
sigset_t empty;
|
if(pid == 0) {
|
||||||
sigemptyset(&empty);
|
sigset_t empty;
|
||||||
sigprocmask(SIG_SETMASK, &empty, NULL);
|
sigemptyset(&empty);
|
||||||
sa.sa_handler = SIG_DFL;
|
sigprocmask(SIG_SETMASK, &empty, NULL);
|
||||||
sa.sa_flags = 0;
|
sa.sa_handler = SIG_DFL;
|
||||||
sigaction(SIGTERM, &sa, NULL);
|
sa.sa_flags = 0;
|
||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGTERM, &sa, NULL);
|
||||||
sigaction(SIGUSR1, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
execvp(argv[2], &argv[2]);
|
sigaction(SIGUSR1, &sa, NULL);
|
||||||
_exit(127);
|
execvp(argv[2], &argv[2]);
|
||||||
}
|
_exit(127);
|
||||||
if(pid > 0) {
|
}
|
||||||
int status;
|
if(pid > 0) {
|
||||||
active_child = pid;
|
int status;
|
||||||
while(waitpid(pid, &status, 0) < 0) {
|
active_child = pid;
|
||||||
if(errno != EINTR)
|
while(waitpid(pid, &status, 0) < 0) {
|
||||||
break;
|
if(errno != EINTR)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
active_child = -1;
|
||||||
}
|
}
|
||||||
active_child = -1;
|
|
||||||
}
|
}
|
||||||
|
first_run = 0;
|
||||||
if(stop_requested)
|
if(stop_requested)
|
||||||
break;
|
break;
|
||||||
aligned_sleep(interval);
|
aligned_sleep(interval);
|
||||||
|
|||||||
+143
-40
@@ -21,6 +21,7 @@
|
|||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/poll.h>
|
#include <linux/poll.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
|
#include <linux/regulator/consumer.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/vmalloc.h>
|
||||||
@@ -51,11 +52,6 @@
|
|||||||
#define CAM_OUT_FRAME_BYTES (CAM_OUT_STRIDE * CAM_OUT_HEIGHT)
|
#define CAM_OUT_FRAME_BYTES (CAM_OUT_STRIDE * CAM_OUT_HEIGHT)
|
||||||
#define CAM_MAX_MMAP_BUFS 4U
|
#define CAM_MAX_MMAP_BUFS 4U
|
||||||
|
|
||||||
/* PM8909 USID 1 LDO6 (1.8V VIO/CSI) and LDO17 (2.85V VANA) enable registers */
|
|
||||||
#define PM8909_LDO6_EN_CTL 0x4546U
|
|
||||||
#define PM8909_LDO17_EN_CTL 0x5046U
|
|
||||||
#define PM8909_REG_EN_BIT 0x80U
|
|
||||||
|
|
||||||
/* PM8909 USID 1 WCD analog codec micbias1 (2.8V) and earpiece PA (+6 dB) */
|
/* PM8909 USID 1 WCD analog codec micbias1 (2.8V) and earpiece PA (+6 dB) */
|
||||||
#define PM8909_CDC_A_MICB_1_VAL 0xf141U
|
#define PM8909_CDC_A_MICB_1_VAL 0xf141U
|
||||||
#define PM8909_CDC_A_RX_EAR_CTL 0xf1c0U
|
#define PM8909_CDC_A_RX_EAR_CTL 0xf1c0U
|
||||||
@@ -160,6 +156,8 @@ struct msm8905_cam_dev {
|
|||||||
void __iomem *camss_base;
|
void __iomem *camss_base;
|
||||||
void __iomem *vbif_base;
|
void __iomem *vbif_base;
|
||||||
struct regmap *usid1_regmap;
|
struct regmap *usid1_regmap;
|
||||||
|
struct regulator *vdd_l6;
|
||||||
|
struct regulator *vdd_l17;
|
||||||
|
|
||||||
u8 *raw_dma_buf;
|
u8 *raw_dma_buf;
|
||||||
dma_addr_t raw_dma_phys;
|
dma_addr_t raw_dma_phys;
|
||||||
@@ -172,6 +170,12 @@ struct msm8905_cam_dev {
|
|||||||
bool streaming;
|
bool streaming;
|
||||||
bool hw_initialized;
|
bool hw_initialized;
|
||||||
bool rotate_180;
|
bool rotate_180;
|
||||||
|
bool l6_enabled;
|
||||||
|
bool l17_enabled;
|
||||||
|
bool spmi_saved;
|
||||||
|
bool micb1_val_saved;
|
||||||
|
u32 saved_ear_ctl;
|
||||||
|
u32 saved_micb1_val;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct msm8905_cam_dev *g_cam;
|
static struct msm8905_cam_dev *g_cam;
|
||||||
@@ -401,10 +405,114 @@ static void msm8905_cam_enable_clocks(struct msm8905_cam_dev *cam)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void msm8905_cam_hw_deinit(struct msm8905_cam_dev *cam)
|
static void msm8905_cam_ensure_regulators(struct msm8905_cam_dev *cam)
|
||||||
|
{
|
||||||
|
struct regulator *reg;
|
||||||
|
|
||||||
|
if (!cam->vdd_l6) {
|
||||||
|
reg = regulator_get_optional(&cam->pdev->dev, "l6");
|
||||||
|
if (!IS_ERR(reg))
|
||||||
|
cam->vdd_l6 = reg;
|
||||||
|
}
|
||||||
|
if (!cam->vdd_l17) {
|
||||||
|
reg = regulator_get_optional(&cam->pdev->dev, "l17");
|
||||||
|
if (!IS_ERR(reg))
|
||||||
|
cam->vdd_l17 = reg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int msm8905_cam_regulators_enable(struct msm8905_cam_dev *cam)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
msm8905_cam_ensure_regulators(cam);
|
||||||
|
if (cam->vdd_l6 && !cam->l6_enabled) {
|
||||||
|
ret = regulator_enable(cam->vdd_l6);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
cam->l6_enabled = true;
|
||||||
|
}
|
||||||
|
if (cam->vdd_l17 && !cam->l17_enabled) {
|
||||||
|
ret = regulator_enable(cam->vdd_l17);
|
||||||
|
if (ret) {
|
||||||
|
if (cam->l6_enabled) {
|
||||||
|
regulator_disable(cam->vdd_l6);
|
||||||
|
cam->l6_enabled = false;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
cam->l17_enabled = true;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void msm8905_cam_regulators_disable(struct msm8905_cam_dev *cam)
|
||||||
|
{
|
||||||
|
if (cam->vdd_l17 && cam->l17_enabled) {
|
||||||
|
regulator_disable(cam->vdd_l17);
|
||||||
|
cam->l17_enabled = false;
|
||||||
|
}
|
||||||
|
if (cam->vdd_l6 && cam->l6_enabled) {
|
||||||
|
regulator_disable(cam->vdd_l6);
|
||||||
|
cam->l6_enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void msm8905_cam_spmi_restore(struct msm8905_cam_dev *cam)
|
||||||
|
{
|
||||||
|
if (!cam->usid1_regmap || !cam->spmi_saved)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cam->micb1_val_saved) {
|
||||||
|
regmap_write(cam->usid1_regmap, PM8909_CDC_A_MICB_1_VAL,
|
||||||
|
cam->saved_micb1_val);
|
||||||
|
cam->micb1_val_saved = false;
|
||||||
|
}
|
||||||
|
regmap_update_bits(cam->usid1_regmap, PM8909_CDC_A_RX_EAR_CTL,
|
||||||
|
0x20U, cam->saved_ear_ctl);
|
||||||
|
cam->spmi_saved = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Shared power-down path for both hw_deinit and early hw_init failure */
|
||||||
|
static void msm8905_cam_hw_teardown_common(struct msm8905_cam_dev *cam)
|
||||||
{
|
{
|
||||||
ssize_t i;
|
ssize_t i;
|
||||||
|
|
||||||
|
/* Place sensor in hardware power-down and disable MCLK0 output */
|
||||||
|
cam_gpio_out(cam, GPIO_CAM_RESET, false);
|
||||||
|
cam_gpio_out(cam, GPIO_CAM_STANDBY, false);
|
||||||
|
cam_gpio_out(cam, GPIO_CAM_VDIG, false);
|
||||||
|
cam_gpio_cfg(cam, GPIO_CAM_MCLK0, 0x0001U);
|
||||||
|
|
||||||
|
/* Gate CAMSS branch clocks in reverse order */
|
||||||
|
for (i = (ssize_t)ARRAY_SIZE(camss_cbcr_offsets) - 1; i >= 0; i--) {
|
||||||
|
u32 off = camss_cbcr_offsets[i];
|
||||||
|
cam_w32(cam->gcc_base, off, cam_r32(cam->gcc_base, off) & ~1U);
|
||||||
|
}
|
||||||
|
wmb();
|
||||||
|
|
||||||
|
/* Gate CAMSS RCG roots (MCLK0 and CSI/VFE RCGs) */
|
||||||
|
cam_w32(cam->gcc_base, 0x52000U, 0x0U);
|
||||||
|
cam_w32(cam->gcc_base, 0x4e000U, 0x0U);
|
||||||
|
cam_w32(cam->gcc_base, 0x4f020U, 0x0U);
|
||||||
|
cam_w32(cam->gcc_base, 0x4e020U, 0x0U);
|
||||||
|
cam_w32(cam->gcc_base, 0x58000U, 0x0U);
|
||||||
|
cam_w32(cam->gcc_base, 0x5a000U, 0x0U);
|
||||||
|
|
||||||
|
/* Release SMMU vote clocks and power down VFE GDSC */
|
||||||
|
cam_w32(cam->gcc_base, 0x4500cU, cam_r32(cam->gcc_base, 0x4500cU) & ~0x3202U);
|
||||||
|
cam_w32(cam->gcc_base, 0x58034U, cam_r32(cam->gcc_base, 0x58034U) | 1U);
|
||||||
|
wmb();
|
||||||
|
|
||||||
|
msm8905_cam_spmi_restore(cam);
|
||||||
|
msm8905_cam_regulators_disable(cam);
|
||||||
|
|
||||||
|
cam->hw_initialized = false;
|
||||||
|
cam->streaming = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void msm8905_cam_hw_deinit(struct msm8905_cam_dev *cam)
|
||||||
|
{
|
||||||
if (!cam->hw_initialized)
|
if (!cam->hw_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -414,34 +522,8 @@ static void msm8905_cam_hw_deinit(struct msm8905_cam_dev *cam)
|
|||||||
gc23xx_stream_off(cam);
|
gc23xx_stream_off(cam);
|
||||||
usleep_range(600, 900);
|
usleep_range(600, 900);
|
||||||
|
|
||||||
/* 2. Place sensor in hardware power-down and disable MCLK0 output */
|
/* 2. Power down GPIOs, clocks, VFE GDSC, and RPM/SPMI regulators */
|
||||||
cam_gpio_out(cam, GPIO_CAM_RESET, false);
|
msm8905_cam_hw_teardown_common(cam);
|
||||||
cam_gpio_out(cam, GPIO_CAM_STANDBY, false);
|
|
||||||
cam_gpio_out(cam, GPIO_CAM_VDIG, false);
|
|
||||||
cam_gpio_cfg(cam, GPIO_CAM_MCLK0, 0x0001U);
|
|
||||||
|
|
||||||
/* 3. Gate CAMSS branch clocks in reverse order */
|
|
||||||
for (i = (ssize_t)ARRAY_SIZE(camss_cbcr_offsets) - 1; i >= 0; i--) {
|
|
||||||
u32 off = camss_cbcr_offsets[i];
|
|
||||||
cam_w32(cam->gcc_base, off, cam_r32(cam->gcc_base, off) & ~1U);
|
|
||||||
}
|
|
||||||
wmb();
|
|
||||||
|
|
||||||
/* 4. Gate CAMSS RCG roots (MCLK0 and CSI/VFE RCGs) */
|
|
||||||
cam_w32(cam->gcc_base, 0x52000U, 0x0U);
|
|
||||||
cam_w32(cam->gcc_base, 0x4e000U, 0x0U);
|
|
||||||
cam_w32(cam->gcc_base, 0x4f020U, 0x0U);
|
|
||||||
cam_w32(cam->gcc_base, 0x4e020U, 0x0U);
|
|
||||||
cam_w32(cam->gcc_base, 0x58000U, 0x0U);
|
|
||||||
cam_w32(cam->gcc_base, 0x5a000U, 0x0U);
|
|
||||||
|
|
||||||
/* 5. Release SMMU vote clocks and power down VFE GDSC */
|
|
||||||
cam_w32(cam->gcc_base, 0x4500cU, cam_r32(cam->gcc_base, 0x4500cU) & ~0x3202U);
|
|
||||||
cam_w32(cam->gcc_base, 0x58034U, cam_r32(cam->gcc_base, 0x58034U) | 1U);
|
|
||||||
wmb();
|
|
||||||
|
|
||||||
cam->hw_initialized = false;
|
|
||||||
cam->streaming = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
|
static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
|
||||||
@@ -449,22 +531,37 @@ static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
|
|||||||
size_t i;
|
size_t i;
|
||||||
u16 chip_id;
|
u16 chip_id;
|
||||||
u32 r;
|
u32 r;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (cam->hw_initialized) {
|
if (cam->hw_initialized) {
|
||||||
msm8905_cam_enable_clocks(cam);
|
msm8905_cam_enable_clocks(cam);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 1. Ensure PM8909 LDO6 (1.8V) and LDO17 (2.85V) are enabled */
|
/* 1. Enable RPM-owned PM8909 LDO6 (1.8V) and LDO17 (2.85V) plus codec rails */
|
||||||
|
ret = msm8905_cam_regulators_enable(cam);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (cam->usid1_regmap) {
|
if (cam->usid1_regmap) {
|
||||||
regmap_update_bits(cam->usid1_regmap, PM8909_LDO6_EN_CTL,
|
unsigned int val = 0;
|
||||||
PM8909_REG_EN_BIT, PM8909_REG_EN_BIT);
|
|
||||||
regmap_update_bits(cam->usid1_regmap, PM8909_LDO17_EN_CTL,
|
cam->saved_ear_ctl =
|
||||||
PM8909_REG_EN_BIT, PM8909_REG_EN_BIT);
|
(regmap_read(cam->usid1_regmap, PM8909_CDC_A_RX_EAR_CTL, &val) == 0)
|
||||||
|
? (val & 0x20U)
|
||||||
|
: 0U;
|
||||||
|
if (regmap_read(cam->usid1_regmap, PM8909_CDC_A_MICB_1_VAL, &val) == 0) {
|
||||||
|
cam->saved_micb1_val = val;
|
||||||
|
cam->micb1_val_saved = true;
|
||||||
|
} else {
|
||||||
|
cam->micb1_val_saved = false;
|
||||||
|
}
|
||||||
|
cam->spmi_saved = true;
|
||||||
|
|
||||||
regmap_write(cam->usid1_regmap, PM8909_CDC_A_MICB_1_VAL, 0x60U);
|
regmap_write(cam->usid1_regmap, PM8909_CDC_A_MICB_1_VAL, 0x60U);
|
||||||
regmap_update_bits(cam->usid1_regmap, PM8909_CDC_A_RX_EAR_CTL, 0x20U, 0x20U);
|
regmap_update_bits(cam->usid1_regmap, PM8909_CDC_A_RX_EAR_CTL, 0x20U, 0x20U);
|
||||||
usleep_range(2000, 3000);
|
|
||||||
}
|
}
|
||||||
|
usleep_range(2000, 3000);
|
||||||
|
|
||||||
/* 2. Power on VFE GDSC and SMMU vote clocks */
|
/* 2. Power on VFE GDSC and SMMU vote clocks */
|
||||||
cam_w32(cam->gcc_base, 0x58034U, cam_r32(cam->gcc_base, 0x58034U) & ~1U);
|
cam_w32(cam->gcc_base, 0x58034U, cam_r32(cam->gcc_base, 0x58034U) & ~1U);
|
||||||
@@ -502,6 +599,7 @@ static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
|
|||||||
dev_err(&cam->pdev->dev,
|
dev_err(&cam->pdev->dev,
|
||||||
"GalaxyCore chip ID mismatch: 0x%04x (expected 0x2395/0x2385/0x2365)\n",
|
"GalaxyCore chip ID mismatch: 0x%04x (expected 0x2395/0x2385/0x2365)\n",
|
||||||
chip_id);
|
chip_id);
|
||||||
|
msm8905_cam_hw_teardown_common(cam);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
cam->chip_id = chip_id;
|
cam->chip_id = chip_id;
|
||||||
@@ -1213,6 +1311,11 @@ static void __exit msm8905_cam_exit(void)
|
|||||||
video_unregister_device(&cam->vdev);
|
video_unregister_device(&cam->vdev);
|
||||||
v4l2_device_unregister(&cam->v4l2_dev);
|
v4l2_device_unregister(&cam->v4l2_dev);
|
||||||
msm8905_cam_hw_deinit(cam);
|
msm8905_cam_hw_deinit(cam);
|
||||||
|
msm8905_cam_regulators_disable(cam);
|
||||||
|
if (cam->vdd_l17)
|
||||||
|
regulator_put(cam->vdd_l17);
|
||||||
|
if (cam->vdd_l6)
|
||||||
|
regulator_put(cam->vdd_l6);
|
||||||
iounmap(cam->vbif_base);
|
iounmap(cam->vbif_base);
|
||||||
iounmap(cam->camss_base);
|
iounmap(cam->camss_base);
|
||||||
iounmap(cam->tlmm_base);
|
iounmap(cam->tlmm_base);
|
||||||
|
|||||||
Reference in new issue
Block a user