Compare commits

...
Author SHA1 Message Date
Clayton Craft 67a6c836ba device-pine64-pinephone: add elogind suspend hook for managing wifi pm
This adds an elogind hook for enabling PM right before suspend, then
disabling it on resume to allow for faster wifi reconnect. When the
device is operating on battery power, pm is re-enabled after 30 seconds.

In my testing, 5 seconds was not enough time for it to reconnect to my
AP, and 30 seconds seemed like the right amount. Having PM disabled for
a few extra seconds seems like a reasonable price to pay for having a
faster reconnect without having to worry about PM being switched on
again half way through the reconnection.

I didn't see any obvious problems with having a `sleep` in the hook,
elogind seems to fork this and it didn't appear to block anything. If
more hooks are added later, it might block execution of future hooks,
but let's address that if/when the need arises.

fixes #973
2021-02-17 16:59:16 -08:00
2 changed files with 33 additions and 2 deletions

No files matched your search

+12 -2
View File
@@ -4,8 +4,8 @@
# Co-Maintainer: Bart Ribbers <bribbers@disroot.org>
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=device-pine64-pinephone
pkgver=0.20
pkgrel=2
pkgver=0.21
pkgrel=0
pkgdesc="PINE64 PinePhone"
url="https://postmarketos.org"
license="MIT"
@@ -17,6 +17,7 @@ subpackages="
$pkgname-phosh
$pkgname-shelli
$pkgname-plasma-mobile:plasma_mobile
$pkgname-elogind
"
depends="
alsa-ucm-conf
@@ -41,6 +42,7 @@ source="
70-wifi-pm.rules
90-modem-eg25.rules
deviceinfo
elogind-hook-pinephone-wifi-powersave.sh
gpsd_device-hook.sh
gpsd_pinephone.initd
hwtest.ini
@@ -155,12 +157,20 @@ shelli() {
install -Dm644 "$srcdir"/00_alsa_pinephone_dshare.conf \
"$subpkgdir"/etc/alsa/conf.d/00_alsa_pinephone_dshare.conf
}
elogind() {
install_if="$pkgname=$pkgver-r$pkgrel elogind"
install -Dm755 "$srcdir"/elogind-hook-pinephone-wifi-powersave.sh \
"$subpkgdir"/usr/libexec/elogind/system-sleep/pinephone-wifi-powersave.sh
}
sha512sums="5736444fd38ab4351d148ae96c479085f469bd1e51a692fb1827f8ac921a584389f7696985e1fba21c2deac88709910531f4ece282f45ff54e590c2b54b84ba3 00_alsa_pinephone_dshare.conf
b53cc6f2531854cc9c1e4c334185a20551d64c8675ee8a8eaa03b99d80808fad421a0f6e99e5be212a974d88c85f461a71ba59ac59c29f298c82f211e3be1ef4 10-pinephone-proximity.rules
9170da7ac869254644f2fc8d914102f2c16e917dbeb53e33b96c76936711d0540f55fa5c2526d73d5fe244500bc2728bc9d629e2524cf52c573d11e833aee666 60-flashlight.rules
8b6fa7b12c15f439c561901f3ffe24a1ef2a0c343401c0a79281060854ab29e08a1fb5e7adae8684b12aa9f535ed99e2dad993dce9724822cb0fbf2497dd86e5 70-wifi-pm.rules
7dc2b7c20b4a2b15f597a6417bd01797643dad84a3683b0dee648e030fb6326e9d020307643fdcdf1bb43fc44af9975697e417003bd359610bae2d8ce614fc00 90-modem-eg25.rules
8ae790704c77bcb62100cec4dda181d8db7ee62198271dae08b1b24205d22551bd7061bfe3dcb049589dad11fbb4448891fdfdba9e83135570a6acdf5bba9c22 deviceinfo
3195decc22a168d7b883f46b042bf61751e119104646ee1a707bf7f12965750c7b5b587c56a68e7c900cee0d5d5bd784ff41ad3ee87d904ba7c299b515df5dbd elogind-hook-pinephone-wifi-powersave.sh
ccbc83b84b5028bc2c8e526759004ce71b50b2675ecffee98f5676c70a3332197a231ff9d2fd46444dd3c0a637ec08ce6125b18240fe6bfc13f624a15192e648 gpsd_device-hook.sh
1017fc3f325227da58c77abdc59e9735288d91a7ccc63ec784fe0241c523786b617a11ce8045dab2a74ca12a7dd70aaa334af91836418db1e96a3266fecaa4fd gpsd_pinephone.initd
3dd6d612c381cb0002049d1974d8fb5aa5a53a1eb4d6bcbf62eb2ad52cfdc45f0f6ad24a699716d3513b0371aa1316f25dc72afc10d7176cc3b99d0965c3f030 hwtest.ini
@@ -0,0 +1,21 @@
#!/bin/sh
wlan_device="wlan0"
bat_dev="/sys/class/power_supply/axp20x-battery"
case $1/$2 in
pre/*)
# enable wifi power save to reduce power in suspend
iw dev "$wlan_device" set power_save on
sleep 1
;;
post/*)
# briefly disable power save when resuming to allow for faster
# reconnect
iw dev "$wlan_device" set power_save off
# re-enable power save when on battery
if [ "Discharging" = "$(cat "$bat_dev"/status)" ]; then
sleep 30
iw dev "$wlan_device" set power_save on
fi
;;
esac