soc-qcom-sdm845: shutdown when battery is critical (MR 3287)

UPower defaults to HybridSleep mode when battery is critical.
Since we allow suspending the device in regular use, this approach
won't help in a critical battery case scenario. When the battery
level is critical, shutdown the device instead.

Moreover, adjust the default levels for battery low, critical, critical
action since they are too high for SDM845 devices.
This commit is contained in:
Dylan Van Assche 2022-07-16 11:46:20 +02:00 committed by Oliver Smith
parent feb91937c1
commit 47c6d4995a
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 107 additions and 1 deletions

View file

@ -1,7 +1,7 @@
# Maintainer: Caleb Connolly (kalube) <caleb@connolly.tech> # Maintainer: Caleb Connolly (kalube) <caleb@connolly.tech>
pkgname=soc-qcom-sdm845 pkgname=soc-qcom-sdm845
pkgdesc="Common package for Qualcomm SDM845 devices" pkgdesc="Common package for Qualcomm SDM845 devices"
pkgver=7 pkgver=8
pkgrel=0 pkgrel=0
url="https://postmarketos.org" url="https://postmarketos.org"
license="BSD-3-Clause" license="BSD-3-Clause"
@ -16,6 +16,7 @@ subpackages="
$pkgname-nonfree-firmware:nonfree_firmware $pkgname-nonfree-firmware:nonfree_firmware
$pkgname-ucm $pkgname-ucm
$pkgname-qbootctl $pkgname-qbootctl
$pkgname-upower
" "
_ucm_commit="621c71fd5f5742c60d38766ebb2d1bd3b863a2a4" _ucm_commit="621c71fd5f5742c60d38766ebb2d1bd3b863a2a4"
@ -23,6 +24,7 @@ source="
alsa-ucm-conf-$_ucm_commit.tar.gz::https://gitlab.com/sdm845-mainline/alsa-ucm-conf/-/archive/$_ucm_commit/alsa-ucm-conf-$_ucm_commit.tar.gz alsa-ucm-conf-$_ucm_commit.tar.gz::https://gitlab.com/sdm845-mainline/alsa-ucm-conf/-/archive/$_ucm_commit/alsa-ucm-conf-$_ucm_commit.tar.gz
90-feedbackd-pmi8998.rules 90-feedbackd-pmi8998.rules
modemmanager.conf modemmanager.conf
UPower.conf
" "
package() { package() {
@ -49,6 +51,15 @@ ucm() {
cp -r "$srcdir/alsa-ucm-conf-$_ucm_commit"/ucm2 "$subpkgdir"/usr/share/alsa/ cp -r "$srcdir/alsa-ucm-conf-$_ucm_commit"/ucm2 "$subpkgdir"/usr/share/alsa/
} }
upower() {
install_if="$pkgname=$pkgver-r$pkgrel upower"
replaces="upower"
# Shutdown when battery is critical instead of sleep
install -Dm644 "$srcdir"/UPower.conf \
"$subpkgdir"/etc/UPower/UPower.conf
}
qbootctl() { qbootctl() {
pkgdesc="Enable qbootctl mark-boot-successful service" pkgdesc="Enable qbootctl mark-boot-successful service"
depends="qbootctl" depends="qbootctl"
@ -60,4 +71,5 @@ sha512sums="
a1a6c6f5a6156e76e5a15b0078e3baedf07fa02b354cb025b1124ed688434a620d80aa8c0069b2d7ded1a29e2bb9318ab6e8f8a85af33a9dd2478a7b7ec6b494 alsa-ucm-conf-621c71fd5f5742c60d38766ebb2d1bd3b863a2a4.tar.gz a1a6c6f5a6156e76e5a15b0078e3baedf07fa02b354cb025b1124ed688434a620d80aa8c0069b2d7ded1a29e2bb9318ab6e8f8a85af33a9dd2478a7b7ec6b494 alsa-ucm-conf-621c71fd5f5742c60d38766ebb2d1bd3b863a2a4.tar.gz
4f2c22a3a3fc7d380e200ad977578107d81f0e7ade7918e03bdb15b60a564e8db5f47e13cce22f636d38fd3722696bb46076b8872dae0ca2d8a3838522a1f025 90-feedbackd-pmi8998.rules 4f2c22a3a3fc7d380e200ad977578107d81f0e7ade7918e03bdb15b60a564e8db5f47e13cce22f636d38fd3722696bb46076b8872dae0ca2d8a3838522a1f025 90-feedbackd-pmi8998.rules
e33f41360ccc4900bb76a26cc7b46bde1fb90facdf45c4fbcebc80499386939948401cacd6df9f779eafab10f4ee77ee1fef3e7bd06f483f8c2a4a644c84f327 modemmanager.conf e33f41360ccc4900bb76a26cc7b46bde1fb90facdf45c4fbcebc80499386939948401cacd6df9f779eafab10f4ee77ee1fef3e7bd06f483f8c2a4a644c84f327 modemmanager.conf
9d455b56558d453d501a1ad869ffa79f9952ed43485a9847d506db6a78bfcd9f9c9d855660ee1d368eb74f4429385ec166addc30d802261c75562e785fe84c52 UPower.conf
" "

View file

@ -0,0 +1,94 @@
# Only the system vendor should modify this file, ordinary users
# should not have to change anything.
[UPower]
# Enable the Watts Up Pro device.
#
# The Watts Up Pro contains a generic FTDI USB device without a specific
# vendor and product ID. When we probe for WUP devices, we can cause
# the user to get a perplexing "Device or resource busy" error when
# attempting to use their non-WUP device.
#
# The generic FTDI device is known to also be used on:
#
# - Sparkfun FT232 breakout board
# - Parallax Propeller
#
# default=false
EnableWattsUpPro=false
# Don't poll the kernel for battery level changes.
#
# Some hardware will send us battery level changes through
# events, rather than us having to poll for it. This option
# allows disabling polling for hardware that sends out events.
#
# default=false
NoPollBatteries=false
# Do we ignore the lid state
#
# Some laptops are broken. The lid state is either inverted, or stuck
# on or off. We can't do much to fix these problems, but this is a way
# for users to make the laptop panel vanish, a state that might be used
# by a couple of user-space daemons. On Linux systems, see also
# logind.conf(5).
#
# default=false
IgnoreLid=false
# Policy for warnings and action based on battery levels
#
# Whether battery percentage based policy should be used. The default
# is to use the time left, change to true to use the percentage, which
# should work around broken firmwares. It is also more reliable than
# the time left (frantically saving all your files is going to use more
# battery than letting it rest for example).
# default=true
UsePercentageForPolicy=true
# When UsePercentageForPolicy is true, the levels at which UPower will
# consider the battery low, critical, or take action for the critical
# battery level.
#
# This will also be used for batteries which don't have time information
# such as that of peripherals.
#
# If any value is invalid, or not in descending order, the defaults
# will be used.
#
# Defaults:
# PercentageLow=20
# PercentageCritical=5
# PercentageAction=2
PercentageLow=10
PercentageCritical=5
PercentageAction=3
# When UsePercentageForPolicy is false, the time remaining in seconds at
# which UPower will consider the battery low, critical, or take action for
# the critical battery level.
#
# If any value is invalid, or not in descending order, the defaults
# will be used.
#
# Defaults:
# TimeLow=1200
# TimeCritical=300
# TimeAction=120
TimeLow=1200
TimeCritical=300
TimeAction=120
# The action to take when "TimeAction" or "PercentageAction" above has been
# reached for the batteries (UPS or laptop batteries) supplying the computer
#
# Possible values are:
# PowerOff
# Hibernate
# HybridSleep
#
# If HybridSleep isn't available, Hibernate will be used
# If Hibernate isn't available, PowerOff will be used
CriticalPowerAction=PowerOff