Files
bananarchy/overlay/rootfs/etc/local.d/10-power-save.start
T
Luxferre 5d427e39ab Implement 0014 keypad debouncer, Sparkler LRA filter, standby fixes, and stage a1125 (ampere)
- Extend 0012 standby optimizations with removable-SD-only MMC_CAP_AGGRESSIVE_PM | MMC_CAP2_FULL_PWR_CYCLE in sdhci-msm, proxy mem clock and BIMC XO re-parenting + 0x45000 BIT(2) early-vote clear in qcom_q6v5_mss / gcc-msm8909, 100 MHz opp-99999975 floor across qcom-msm8909.dtsi and all 6 device DTS/DTBs, disabled-by-default Bluetooth with bt_enabled persistence, NM ipv6.method=ignore + standby wlan0/disable_ipv6 muting, and post-park DSDS signal hysteresis

- Add ABI-preserving system-core keypad debouncer patch 0014 (drivers/input/input.c key_debounce_ms + pm8941-pwrkey press/release chatter holdoff), replace ignored col-scan-delay-ms with col-scan-delay-us = <0x32> and raise DT debounce intervals across all 6 DTS/DTBs, configure per-target key_debounce_ms at boot and xset r rate 300 25, and add C/DTS verification in scripts/test-keypad-debouncer.py

- Isolate Nokia 8000 4G (nokia-sparkler / nokia-leo) media playback from the shared 157 Hz SPK_DRV vibrator channel via dynamic Speaker-only filtering in music.so, files.so, and ringtones.so, explicit RX3/SPK mixer zeroing on Earpiece/Headphones/Bluetooth routes in sxmo_audio.sh and preview plugins, and Sparkler/Leo-only /etc/mpv/mpv.conf provisioning

- Register upcoming build a1125 (ampere) in scripts/version.sh, scripts/check-rebuild.sh, AGENTS.md, and CHANGELOG.md, fix --for-rebuild pre-rebuild stale output checks in check-rebuild.sh/test-cover-dt.py, rebuild vmlinuz/DTBs/plugins and all 4 --mkinitfs target images stamped a1125 (ampere), and pin their verified SHA-256 checksums
2026-11-23 15:26:56 +02:00

123 lines
5.8 KiB
Bash
Executable File

#!/bin/sh
# Bananarchy kernel and runtime power management optimizations
chmod 0755 / 2>/dev/null || true
# Disable fbcon cursor blinking (eliminates 5 Hz fb_flashcursor + drm_fb_helper_damage_work wakeups)
if [ -w /sys/class/graphics/fbcon/cursor_blink ]; then
echo 0 > /sys/class/graphics/fbcon/cursor_blink 2>/dev/null || true
fi
# Reduce periodic VM stat shepherd and dirty writeback timer wakeups
{ echo 30 > /proc/sys/vm/stat_interval; } 2>/dev/null || true
{ echo 6000 > /proc/sys/vm/dirty_writeback_centisecs; } 2>/dev/null || true
{ echo 6000 > /proc/sys/vm/dirty_expire_centisecs; } 2>/dev/null || true
# Disable proactive compaction: kcompactd0 otherwise wakes ~2/s.
{ echo 0 > /proc/sys/vm/compaction_proactiveness; } 2>/dev/null || true
{ echo 0 > /proc/sys/kernel/nmi_watchdog; } 2>/dev/null || true
{ echo "1 4 1 1" > /proc/sys/kernel/printk; } 2>/dev/null || true
{ echo Y > /sys/module/workqueue/parameters/power_efficient; } 2>/dev/null || true
{ echo Y > /sys/module/printk/parameters/console_suspend; } 2>/dev/null || true
# Lower SPI controller (78b9000.spi) runtime PM autosuspend from 1000 ms to 50 ms
# and ensure runtime PM auto-suspend is enabled across SoC buses
for spi_dev in /sys/devices/platform/soc@0/*.spi; do
if [ -d "$spi_dev/power" ]; then
{ echo 50 > "$spi_dev/power/autosuspend_delay_ms"; } 2>/dev/null || true
{ echo auto > "$spi_dev/power/control"; } 2>/dev/null || true
fi
done
for pm_dev in /sys/devices/platform/soc@0/1c00000.gpu /sys/devices/platform/soc@0/*.sdhci /sys/devices/platform/soc@0/*.serial /sys/devices/platform/soc@0/*.serial/*; do
if [ -w "$pm_dev/power/control" ]; then
{ echo auto > "$pm_dev/power/control"; } 2>/dev/null || true
fi
done
# Keep schedutil rate_limit_us at 40 ms instead of the 6.44 s default that
# qcom-cpufreq derives from its UINT_MAX transition latency. Only rate_limit_us
# exists on this kernel: up_rate_limit_us and down_rate_limit_us do not.
# Switching scaling_governor away from schedutil and back destroys/recreates
# this kobject, so bananarchy-display-power-sync re-applies the value on wake.
for gov_dir in /sys/devices/system/cpu/cpufreq/schedutil /sys/devices/system/cpu/cpufreq/policy*/schedutil /sys/devices/system/cpu/cpu*/cpufreq/schedutil; do
if [ -d "$gov_dir" ]; then
{ echo 40000 > "$gov_dir/rate_limit_us"; } 2>/dev/null || true
fi
done
for gov_file in /sys/devices/system/cpu/cpufreq/policy*/scaling_governor /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
if [ -e "$gov_file" ]; then
chgrp video "$gov_file" 2>/dev/null || true
chmod 0664 "$gov_file" 2>/dev/null || true
fi
done
if [ -e /sys/class/devfreq/1c00000.gpu/governor ]; then
chgrp video /sys/class/devfreq/1c00000.gpu/governor 2>/dev/null || true
chmod 0664 /sys/class/devfreq/1c00000.gpu/governor 2>/dev/null || true
fi
if [ -e /sys/module/cpuidle_qcom_spm/parameters/screen_off ]; then
chgrp video /sys/module/cpuidle_qcom_spm/parameters/screen_off 2>/dev/null || true
chmod 0664 /sys/module/cpuidle_qcom_spm/parameters/screen_off 2>/dev/null || true
fi
# Ensure rootfs pm8916_lbc and pm8916_bms_vm modules are active if initramfs loaded an older build
if [ -r /sys/class/power_supply/pm8916-lbc-chgr/constant_charge_current ]; then
_chg_cur=0
read -r _chg_cur < /sys/class/power_supply/pm8916-lbc-chgr/constant_charge_current 2>/dev/null || _chg_cur=0
if [ "${_chg_cur:-0}" -lt 500000 ] 2>/dev/null; then
modprobe -r pm8916_bms_vm pm8916_lbc 2>/dev/null || true
modprobe pm8916_lbc 2>/dev/null || true
modprobe pm8916_bms_vm 2>/dev/null || true
fi
fi
# K5: the kernel patch raises the GPU devfreq sampling interval to 100 ms;
# this also fixes devices that already loaded the older module.
if [ -w /sys/class/devfreq/1c00000.gpu/polling_interval ]; then
printf '100\n' > /sys/class/devfreq/1c00000.gpu/polling_interval 2>/dev/null || true
fi
# K10: no IPv6 on interfaces created after boot (also in sysctl.d).
{ printf '1\n' > /proc/sys/net/ipv6/conf/default/disable_ipv6; } 2>/dev/null || true
# Configure system-core physical keypad bounce debounce window (in ms).
if [ -w /sys/module/input_core/parameters/key_debounce_ms ]; then
_kdb_ms=45
if [ -r /sys/firmware/devicetree/base/compatible ] && \
tr '\0' '\n' < /sys/firmware/devicetree/base/compatible 2>/dev/null | \
grep -qxE 'nokia,(argon|sparkler|leo)'; then
_kdb_ms=55
fi
if [ -r /etc/bananarchy/key-debounce.conf ]; then
_kdb_cfg="$(sed -n 's/^[[:space:]]*KEY_DEBOUNCE_MS=\([0-9][0-9]*\).*/\1/p' /etc/bananarchy/key-debounce.conf | tail -n 1)"
[ -n "$_kdb_cfg" ] && _kdb_ms="$_kdb_cfg"
fi
printf '%s\n' "$_kdb_ms" > /sys/module/input_core/parameters/key_debounce_ms 2>/dev/null || true
fi
# Wi-Fi power save is enabled by NetworkManager (wifi.powersave=3) and by the
# wcn36xx WIPHY_FLAG_PS_ON_BY_DEFAULT / dynamic_ps_timeout=200 kernel patch.
# Verified on-device: "iw dev wlan0 get power_save" reports "Power save: on".
# No iw binary is shipped, so no userspace iw call belongs here.
# Keep Bluetooth RF-killed and stopped at boot unless explicitly enabled
bt_want=0
if [ -r /home/user/.config/sxmo/bt_enabled ]; then
IFS= read -r bt_val < /home/user/.config/sxmo/bt_enabled 2>/dev/null || bt_val=""
case "$bt_val" in 1|on|ON|yes|YES|true|TRUE) bt_want=1 ;; esac
fi
if [ "$bt_want" = "0" ]; then
rfkill block bluetooth >/dev/null 2>&1 || true
rc-service bluetooth status >/dev/null 2>&1 && rc-service bluetooth stop >/dev/null 2>&1 || true
rc-update del bluetooth default >/dev/null 2>&1 || true
fi
# Restore any persistent Engineering Menu Wi-Fi/BT MAC and IMEI override state
if [ -x /usr/bin/bananarchy-engmenu-ctl ]; then
/usr/bin/bananarchy-engmenu-ctl apply-boot >/dev/null 2>&1 || true
fi
# Automount microSD card if present at boot (sdhci-msm runtime-suspends when idle/empty)
if [ -x /usr/bin/sxmo_sdcard.sh ]; then
/usr/bin/sxmo_sdcard.sh automount boot >/dev/null 2>&1 &
fi