From e95d28a6e72feadf446cb33d48333b1bd216f851 Mon Sep 17 00:00:00 2001 From: Joel Selvaraj Date: Sun, 20 Nov 2022 19:04:27 -0600 Subject: [PATCH] community/soc-qcom-sdm845: update ucm confs and add call audio idle suspend workaround (MR 3639) In SDM845, the q6voice kernel driver connects modem and audio backends. Callaudiod seems to switch to correct audio device and prepares it, however, the audio device get's closed since no one from the userspace is actively listening to it. This cuts the audio in call. As a workaround, I have added to script to disable the suspend-on-idle pulseaudio module during calls, so the audio devices don't close automatically. --- device/community/soc-qcom-sdm845/APKBUILD | 19 ++++++++++-- .../call_audio_idle_suspend_workaround.initd | 28 +++++++++++++++++ .../call_audio_idle_suspend_workaround.sh | 30 +++++++++++++++++++ ...-qcom-sdm845-nonfree-firmware.post-install | 1 + 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.initd create mode 100644 device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.sh diff --git a/device/community/soc-qcom-sdm845/APKBUILD b/device/community/soc-qcom-sdm845/APKBUILD index 5cf6af3b1..809c0ed19 100644 --- a/device/community/soc-qcom-sdm845/APKBUILD +++ b/device/community/soc-qcom-sdm845/APKBUILD @@ -2,7 +2,7 @@ # Co-Maintainer: Joel Selvaraj pkgname=soc-qcom-sdm845 pkgdesc="Common package for Qualcomm SDM845 devices" -pkgver=12 +pkgver=13 pkgrel=0 url="https://postmarketos.org" license="BSD-3-Clause" @@ -19,12 +19,14 @@ subpackages=" $pkgname-vulkan " -_ucm_commit="f2a9fad117c2c86d693623fd47dee5b6f7385fe2" +_ucm_commit="3cece34e28f0a04daec2cf39a7830dd8043f614b" 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 90-feedbackd-pmi8998.rules modemmanager.conf UPower.conf + call_audio_idle_suspend_workaround.sh + call_audio_idle_suspend_workaround.initd " package() { @@ -49,12 +51,21 @@ nonfree_firmware() { msm-modem msm-modem-uim-selection bootmac + alsa-utils " install="$subpkgname.post-install $subpkgname.post-upgrade" mkdir "$subpkgdir" install -Dm644 "$srcdir"/modemmanager.conf \ "$subpkgdir"/etc/conf.d/modemmanager + + # Call Audio idle suspend workaround code + install -Dm755 "$srcdir"/call_audio_idle_suspend_workaround.sh \ + "$subpkgdir"/usr/sbin/call_audio_idle_suspend_workaround + + # Call Audio idle suspend workaround init script + install -Dm755 "$srcdir"/call_audio_idle_suspend_workaround.initd \ + "$subpkgdir"/etc/init.d/call_audio_idle_suspend_workaround } ucm() { @@ -81,8 +92,10 @@ vulkan() { } sha512sums=" -92fa44327488d8deca17be50c3e37538e7e25875b7da8d921058a732ce2dbe8bf6a4d88b2052eea56ffd9a54212babbae10e94fe5e8eed04cce7ce3a37c03833 alsa-ucm-conf-f2a9fad117c2c86d693623fd47dee5b6f7385fe2.tar.gz +22daa3477890d24b0410216cf483204dd6b35875bdc954c5092f8492ce389255d54aee4dbafe0cf1a2f7d08fd153364e18097391b3d8ceecd59ef2ef525bef02 alsa-ucm-conf-3cece34e28f0a04daec2cf39a7830dd8043f614b.tar.gz 4f2c22a3a3fc7d380e200ad977578107d81f0e7ade7918e03bdb15b60a564e8db5f47e13cce22f636d38fd3722696bb46076b8872dae0ca2d8a3838522a1f025 90-feedbackd-pmi8998.rules e33f41360ccc4900bb76a26cc7b46bde1fb90facdf45c4fbcebc80499386939948401cacd6df9f779eafab10f4ee77ee1fef3e7bd06f483f8c2a4a644c84f327 modemmanager.conf 9d455b56558d453d501a1ad869ffa79f9952ed43485a9847d506db6a78bfcd9f9c9d855660ee1d368eb74f4429385ec166addc30d802261c75562e785fe84c52 UPower.conf +aa5cdb138a3cdd0b15d2bbb60c7f67ae0280ddc7d0488cfe2fc44680095a43c1cdacc54d70a689f2117538e9bf1e42758d8c3ac542c9cb8e8dc6d6f3161b7577 call_audio_idle_suspend_workaround.sh +1111d28b6e23163fb47fcfadc2ed3f83543ce0435c6be187a38d418cfe7821fe7905ac103969f3f7c115bd522d99c43efd52409835e292270a6ac9c34b5bee75 call_audio_idle_suspend_workaround.initd " diff --git a/device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.initd b/device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.initd new file mode 100644 index 000000000..632d9b346 --- /dev/null +++ b/device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.initd @@ -0,0 +1,28 @@ +#!/sbin/openrc-run + +name="call_audio_idle_suspend_workaround" +description="Disable pulseaudio suspend-on-idle module during call" +pid="/run/call_audio_idle_suspend_workaround.pid" + +depend() { + need dbus +} + +start() { + ebegin "Starting call audio idle suspend workaround" + + userid=10000 # Default User ID in pmOS + user=$(getent passwd $userid | cut -d: -f1) + env_var="XDG_RUNTIME_DIR=/run/user/$userid" + cmd="/usr/sbin/call_audio_idle_suspend_workaround" + + start-stop-daemon --start --exec "$cmd" --env "$env_var" --background --user $user --pidfile "$pid" --make-pidfile + eend $? +} + +stop() { + ebegin "Stopping call audio idle suspend workaround" + + start-stop-daemon --stop --pidfile "$pid" + eend $? +} diff --git a/device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.sh b/device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.sh new file mode 100644 index 000000000..4d8baa8ce --- /dev/null +++ b/device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# dbus-monitor is run as a child process to this script. Kill child process too when the script terminates. +trap 'pkill -9 -P $$ && exit 0' INT TERM + +interface=org.freedesktop.ModemManager1.Call +member=StateChanged + +dbus-monitor --system "type='signal',interface='$interface',member='$member'" | + while read -r line; do + state=$(echo "$line" | awk '/\/ {print $2}') + if [ -n "$state" ]; then + # Call State is based on https://www.freedesktop.org/software/ModemManager/doc/latest/ModemManager/ModemManager-Flags-and-Enumerations.html#MMCallState + if [ "$state" -eq '0' ] || [ "$state" -eq '3' ]; then + echo "Call Started" + + # Unload module-suspend-on-idle when call begins + pactl unload-module module-suspend-on-idle + fi + + if [ "$state" -eq '7' ]; then + echo "Call Ended" + + # Reload module-suspend-on-idle after call ends + pactl load-module module-suspend-on-idle + fi + fi + done & + +wait diff --git a/device/community/soc-qcom-sdm845/soc-qcom-sdm845-nonfree-firmware.post-install b/device/community/soc-qcom-sdm845/soc-qcom-sdm845-nonfree-firmware.post-install index 36fb71c57..11eb098bd 100644 --- a/device/community/soc-qcom-sdm845/soc-qcom-sdm845-nonfree-firmware.post-install +++ b/device/community/soc-qcom-sdm845/soc-qcom-sdm845-nonfree-firmware.post-install @@ -2,3 +2,4 @@ rc-update add tqftpserv boot rc-update add pd-mapper boot rc-update add q6voiced default +rc-update add call_audio_idle_suspend_workaround default