power: fix LBC charger FSM, BMS-VM fuel gauge, WCN36xx BMPS, WCD clock gating, and battery UI

This commit is contained in:
Luxferre committed 2026-11-03 12:44:17 +02:00
1 parent ebdb0f8ee2
commit 06d991d4fa
47 files changed
+727 -45

No files matched your search

+8 -3
View File
@@ -30,11 +30,16 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
- Updated `dwm`, `dmenu`, `xdrawer`, `libneoui.so`, `sxmo_multikey.sh`, all standalone Xlib DWM plugins, and standalone games (`scoundrel`, `gambatte`, `remedy`) so pressing **End / Power (red)** (`XF86PowerOff`, keycode `124`) from any active window or menu immediately opens (or toggles) the system **Power menu (`dmenu power`)** while mapped **Call (green)** (`XF86Phone` / `XF86PickupPhone`) and `500 ms` **Right softkey** hold in `remedy` open the **ReMEdy Pause Menu**.
- Updated `locker.so` (`xlocker`) and `dwm` to preempt active X11 keyboard grabs and window stacking over any running fullscreen application or game (`webarchy`, `remedy`, `gambatte`, `scoundrel`, `snake`, `tetris`, and all NeoUI plugins) when the screen locks, cleanly restoring the previously focused application upon unlock.
- Upgraded **ReMEdy (`remedy` / `j2me`)** with a `64 MB` heap budget and mark-and-sweep garbage collector (`System.gc()` / `Runtime.gc()`, `freeSlots_` object reuse, and full heap/JAR release on MIDlet exit), synchronous `Canvas.serviceRepaints()`, `Thread.yield()` / `Thread.sleep()` background thread stepping, synthetic native static field storage (`System.out`, `System.err`, `List.SELECT_COMMAND`, `AlertType.*`, `Boolean.TRUE/FALSE`), exact `String` reference preservation in `List.getString()` and `ChoiceGroup.getString()` (for `MeBoy` / `GTA 2` GBC-to-J2ME cartridges), `java.io.InputStreamReader` / `OutputStreamWriter`, `java.lang.Float` / `Double` / `Character`, **JSR-75** (`FileSystemRegistry` / `FileConnection`), **JSR-82** (`javax.bluetooth.*`), **JSR-120** (`javax.wireless.messaging.*`), **JSR-135** (`MIDIControl`), full **Nokia `DirectGraphics`** (`drawPixels`, `getPixels`, `fillPolygon`, `drawPolygon`, `fillTriangle`, `drawTriangle`, `setARGBColor`), and automatic/configurable sub-QVGA (`128x128`, `128x160`, `176x208`, `176x220`) canvas scaling (`Asphalt 6: Adrenaline`).
- **Kernel-to-userspace battery and idle power optimizations**:
- **Kernel-to-userspace battery, charging, fuel-gauge, and idle power optimizations**:
- Fixed PM8909/PM8916 linear battery charger (`pm8916_lbc.ko.zst`) hardware state-machine engagement by writing `MISC_BOOT_DONE` (`0x1642 = 0x80`), overriding the internal charger comparator (`0x10d0 = 0xa5`, `0x10ee = 0x02`), stopping the USB enumeration watchdog timer (`0x134e = 0x00`, `0x104e = 0x00`), clearing `USB_SUSP` (`0x1347 = 0x00`) and `CHG_FAILED` (`0x104a = 0x80`), enabling `BAT_IF` thermistor pull-ups (`0x1248`, `0x124a`), re-arming `CHG_CTRL = 0x81` on every `usb_vbus` plug event, and setting `qcom,fast-charge-safe-current = 540 mA` (`4.375 V`) across all 5 device trees (`nokia-argon`, `nokia-beatles`, `nokia-tough`, `nokia-sparkler`, `nokia-leo`) so USB charging engages `FAST_CHG_ON` (`0x1010 = 0x20`) instead of idling at `90 mA`.
- Fixed PM8909/PM8916 voltage-mode BMS fuel gauge (`pm8916_bms_vm.ko.zst`) calibration (`raw * 292969ULL / 1000ULL`), averaged all valid `S2` FIFO samples, seeded `vbat_now` and `fake_ocv` immediately during module probe, replaced the sticky `300 uV`/tick filter with a responsive bidirectional EMA filter with CC/CV charging IR compensation and idle discharge compensation, and added `POWER_SUPPLY_STATUS_FULL` reporting when `PM8916_LBC_CHGR_CHG_DONE` asserts.
- Fixed `wcn36xx` (`wcn36xx.ko.zst`) Wi-Fi Beacon Mode Power Save (`BMPS`) by deferring `wcn36xx_pmc_enter_bmps()` until `vif->bss_conf.sync_tsf` is synchronized after the 4-way WPA handshake, removing the destructive `ieee80211_connection_loss()` disconnect call on transient pre-beacon BMPS errors, and setting `WIPHY_FLAG_PS_ON_BY_DEFAULT` (`dynamic_ps_timeout = 200 ms`) with `wifi.powersave = 3` in NetworkManager so `wlan0` enters hardware beacon-filtering sleep instead of waking the CPU on every `102.4 ms` beacon.
- Switched the digital audio codec (`snd-soc-msm8916-digital.ko.zst`, `771c000.audio-codec`) to `devm_regmap_init_mmio_clk(..., "ahbix-clk", ...)` and gated both `mclk` and `ahbclk` whenever `active_streams == 0` so `LPASS_CLK_ID_INTERNAL_DIGITAL_CODEC_CORE` and the `19.2 MHz` `xo-board` root clock drop to `enable_cnt = 0` when audio is idle.
- Added `msm8905_cam_hw_deinit()` to the rear camera kernel driver (`src/msm8905-cam/msm8905-cam.c`) and wired it into `streamoff`, last-file-handle `release`, and module `exit` so closing `xcamera` (or stopping V4L2 streaming) immediately stops the CSI-2 stream, asserts sensor hardware standby (`GPIO_CAM_RESET=0`, `GPIO_CAM_STANDBY=0`, `GPIO_CAM_VDIG=0`, `GPIO_CAM_MCLK0=0x0001`), gates all 20 `CAMSS` `CBCR` branch clocks and 6 `RCG` roots (`200 MHz` `vfe0` / `csi0` / `camss_top_ahb` and `24 MHz` `mclk0`), releases `SMMU` vote clocks, and powers down the `VFE GDSC` domain.
- Enabled `workqueue.power_efficient=Y` and `printk.console_suspend=Y` in `/etc/local.d/10-power-save.start`, lowered `78b9000.spi` runtime PM `autosuspend_delay_ms` from `1000 ms` to `50 ms`, enabled runtime PM (`power/control=auto`) across `1c00000.gpu`, `*.spi`, `*.sdhci`, and `*.serial`, switched the `7864900.sdhci` microSD host controller from driver unbinding to kernel runtime PM (`runtime_status = suspended`) with hardware GPIO 38 hotplug detection, and removed the legacy `ttyMSM0` serial `getty` rule from `scripts/configure-rootfs-from-scratch.sh`.
- Enabled `workqueue.power_efficient=Y` and `printk.console_suspend=Y` in `/etc/local.d/10-power-save.start`, tuned `schedutil` governor rate limits (`up_rate_limit_us = 40000`, `down_rate_limit_us = 10000`), automatically switched `scaling_governor` to `powersave` (`200 MHz` floor with zero RPM `vdd_dig`/`vdd_mx` voltage-scaling interrupts) whenever the screen backlight is off and back to `schedutil` on wake, lowered `78b9000.spi` runtime PM `autosuspend_delay_ms` from `1000 ms` to `50 ms`, enabled runtime PM (`power/control=auto`) across `1c00000.gpu`, `*.spi`, `*.sdhci`, and `*.serial`, switched the `7864900.sdhci` microSD host controller from driver unbinding to kernel runtime PM (`runtime_status = suspended`) with hardware GPIO 38 hotplug detection, and removed the legacy `ttyMSM0` serial `getty` rule from `scripts/configure-rootfs-from-scratch.sh`.
- Fixed battery status display and udev hook permissions (`85-bananarchy-battery.rules` running `sxmo_hook_battery.sh` as `user`, `sxmo_hook_battery.sh force` bypassing the 60s throttle on wake/unlock while updating `040-battery-icon-pm8916-bms-vm` even while the screen is dark), added a live battery icon and percentage indicator plus a `30s` lockscreen-only inactivity screen-blanking timeout to `locker.so` (`xlocker`) while keeping unlocked auto-locking disabled, and removed the redundant `doas -n true` gate before `msm-modem-uim-selection dsds-daemon` in `sxmo_modemmonitor.sh`.
- Set the DSDS `msm-modem-uim-selection` `select()` timeout to infinite (`None`, pure `AF_QIPCRTR` event-driven wait) while the screen is locked and `600s` when unlocked, added `neoui_next_timeout_ms()` to `libneoui.so`, wired GLib `GMainContext` file descriptors and `"load-failed"` / `closeWindow()` load-stop handling into `webarchy.so` (along with `NO_AT_BRIDGE=1` and `GTK_A11Y=none`), added `inotify` directory watching to `sms.so`, and eliminated idle periodic `poll()` timers across `dialer.so`, `calllog.so`, `contacts.so`, `sms.so`, `xdrawer.so`, `locker.so`, `email.so`, `irc.so`, `smallweb.so`, `tox.so`, `sip.so`, and `webarchy.so` so visible and background plugins sleep at `0%` CPU unless a transient timer (`softkey` chord, multi-tap window, or toast expiry) is active.
- Skipped `dwm` `drawbar()` Xorg/Glamor/SPI redraws and `sxmo_hook_statusbar.sh` process spawns whenever `bl_power != 0` or `/tmp/bananarchy_screen_locked` exists (with immediate bar refresh on wake/unlock) and wrapped background spawns in double-fork subshells `( ... & )` across `bananarchy-x11-session.sh`, `sxmo_modemmonitor.sh`, `sxmo_hook_start.sh`, `sxmo_hook_postwake.sh`, and `msm-modem-uim-selection` to eliminate zombie child accumulation.
- Skipped `dwm` `drawbar()` Xorg/Glamor/SPI redraws and `sxmo_hook_statusbar.sh` process spawns whenever `bl_power != 0`, `brightness == 0`, or `/tmp/bananarchy_screen_locked` exists (with immediate bar refresh on wake/unlock) and wrapped background spawns in double-fork subshells `( ... & )` across `bananarchy-x11-session.sh`, `sxmo_modemmonitor.sh`, `sxmo_hook_start.sh`, `sxmo_hook_postwake.sh`, and `msm-modem-uim-selection` to eliminate zombie child accumulation.
- **Literal caller ID contact matching (`sxmo_contacts.sh`, `sxmo_common.sh`, `sxmo_modemsendsms.sh`)**:
- Replaced unescaped `grep -i "$NUMBER"` contact lookups with literal matching so carrier service numbers containing regex metacharacters (such as `*121#`) never match arbitrary contact entries.
- **Yabasic Bulls and Cows example (`~/Projects/bulls_cows.yab`)**: