diff --git a/.ci/shellcheck.sh b/.ci/shellcheck.sh index c1aa617cb..a6c0490b7 100755 --- a/.ci/shellcheck.sh +++ b/.ci/shellcheck.sh @@ -24,7 +24,7 @@ sh_files=" ./main/postmarketos-mkinitfs-hook-netboot/netboot.sh ./main/ttyescape/*.post-install ./main/unl0kr/unlock.sh - ./device/community/soc-qcom-sdm845/call_audio_idle_suspend_workaround.sh + ./device/community/soc-qcom/call_audio_idle_suspend_workaround.sh $(find . -path './main/postmarketos-ui-*/*.sh') $(find . -path './main/postmarketos-ui-*/*.pre-install') diff --git a/CODEOWNERS b/CODEOWNERS index 28df4b0c5..7a872a344 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -36,6 +36,7 @@ device/*/*-qcom-sdm670/ @flamingradian device/*/*-qcom-sdm845/ @sdm845-mainline device/*/*-qcom-sm6350/ @z3ntu device/*/*-qcom-sm8250/ @jianhua +device/*/*-qcom/ @calebccff device/*/*-samsung-a3/ @Mis012 @TravMurav @Minecrell device/*/*-samsung-a5/ @Minecrell @minlexx device/*/*-samsung-a51/ @manoedinata diff --git a/device/community/soc-qcom/51-qcom.conf b/device/community/soc-qcom/51-qcom.conf new file mode 100644 index 000000000..e92726f64 --- /dev/null +++ b/device/community/soc-qcom/51-qcom.conf @@ -0,0 +1,26 @@ +monitor.alsa.rules = [ + { + matches = [ + { + # Matches all sources + node.name = "~alsa_input.*" + }, + { + # Matches all sinks + node.name = "~alsa_output.*" + } + ] + actions = { + update-props = { + audio.format = "S16LE" + audio.rate = 48000 + api.alsa.period-size = 4096 + api.alsa.period-num = 6 + api.alsa.headroom = 512, + # session.suspend-timeout-seconds = 0 + # dither.method = "wannamaker3", # add dither of desired shape + # dither.noise = 2, # add additional bits of noise + } + } + } +] diff --git a/device/community/soc-qcom/90-feedbackd-pmi8998.rules b/device/community/soc-qcom/90-feedbackd-pmi8998.rules new file mode 100644 index 000000000..739c0ac03 --- /dev/null +++ b/device/community/soc-qcom/90-feedbackd-pmi8998.rules @@ -0,0 +1 @@ +SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT}=="1", SUBSYSTEMS=="input", ATTRS{name}=="spmi_haptics", TAG+="uaccess", ENV{FEEDBACKD_TYPE}="vibra" diff --git a/device/community/soc-qcom/APKBUILD b/device/community/soc-qcom/APKBUILD new file mode 100644 index 000000000..86422eb9d --- /dev/null +++ b/device/community/soc-qcom/APKBUILD @@ -0,0 +1,161 @@ +# Maintainer: Caleb Connolly +pkgname=soc-qcom +pkgdesc="Common package for Qualcomm devices" +pkgver=1 +pkgrel=0 +url="https://postmarketos.org" +license="BSD-3-Clause" +arch="aarch64" +options="!check !archcheck !tracedeps" +depends=" + bootmac + msm-modem + pd-mapper + swclock-offset + tqftpserv +" +replaces=" + soc-qcom-sdm845 + soc-qcom-sdm845-nonfree-firmware + upower +" +subpackages=" + $pkgname-gstreamer-openrc:gstreamer_openrc + $pkgname-gstreamer-systemd:gstreamer_systemd + $pkgname-modem + $pkgname-modem-openrc:modem_openrc + $pkgname-openrc + $pkgname-pulseaudio + $pkgname-pulseaudio-openrc:pulseaudio_openrc + $pkgname-qbootctl + $pkgname-qbootctl-openrc:qbootctl_openrc + $pkgname-vulkan +" + +source=" + 51-qcom.conf + 90-feedbackd-pmi8998.rules + UPower.conf + call_audio_idle_suspend_workaround.confd + call_audio_idle_suspend_workaround.initd + call_audio_idle_suspend_workaround.sh + gstreamer.conf + gstreamer.sh + modemmanager.conf +" + +package() { + mkdir -p "$pkgdir" + install -Dm644 "$srcdir"/90-feedbackd-pmi8998.rules \ + "$pkgdir"/usr/lib/udev/rules.d/90-feedbackd-pmi8998.rules + + # Shutdown when battery is critical instead of sleep + install -Dm644 "$srcdir"/UPower.conf \ + "$pkgdir"/etc/UPower/UPower.conf + + install -Dm644 "$srcdir"/51-qcom.conf \ + -t "$pkgdir"/usr/share/wireplumber/wireplumber.conf.d +} + +gstreamer_openrc() { + install_if="$pkgname=$pkgver-r$pkgrel openrc" + replaces="soc-qcom-sdm845-gstreamer-openrc" + + install -Dm755 "$srcdir"/gstreamer.sh \ + "$subpkgdir"/etc/profile.d/50-soc-qcom-gstreamer.sh +} + +gstreamer_systemd() { + install_if="$pkgname=$pkgver-r$pkgrel systemd" + replaces="soc-qcom-sdm845-gstreamer-systemd" + + install -Dm644 "$srcdir"/gstreamer.conf \ + "$subpkgdir"/etc/environment.d/50-soc-qcom-gstreamer.conf +} + +modem() { + pkgdesc="Modem services and configuration" + depends=" + q6voiced + msm-modem-uim-selection + 81voltd + " + + mkdir -p "$subpkgdir" +} + +modem_openrc() { + install_if="$pkgname-modem=$pkgver-r$pkgrel openrc" + depends="q6voiced-openrc" + replaces="soc-qcom-sdm845-modem-openrc" + install="$subpkgname.post-install $subpkgname.post-upgrade" + + install -Dm644 "$srcdir"/modemmanager.conf \ + "$subpkgdir"/etc/conf.d/modemmanager +} + +openrc() { + install_if="$pkgname=$pkgver-r$pkgrel openrc" + depends=" + pd-mapper-openrc + tqftpserv-openrc + " + install="$subpkgname.post-install $subpkgname.post-upgrade" + + mkdir "$subpkgdir" +} + +qbootctl() { + pkgdesc="Enable qbootctl mark-boot-successful service" + depends="qbootctl" + + mkdir "$subpkgdir" +} + +qbootctl_openrc() { + install_if="$pkgname-qbootctl=$pkgver-r$pkgrel openrc" + install="$subpkgname.post-install $subpkgname.post-upgrade" + + mkdir "$subpkgdir" +} + +vulkan() { + pkgdesc="Vulkan support for freedreno" + install_if="$pkgname vulkan-loader" + depends="mesa-vulkan-freedreno" + mkdir "$subpkgdir" +} + +pulseaudio() { + install_if="$pkgname=$pkgver-r$pkgrel pulseaudio" + replaces="soc-qcom-sdm845-pulseaudio" + + # Call Audio idle suspend workaround code + install -Dm755 "$srcdir"/call_audio_idle_suspend_workaround.sh \ + "$subpkgdir"/usr/sbin/call_audio_idle_suspend_workaround +} + +pulseaudio_openrc() { + install_if="$pkgname-pulseaudio=$pkgver-r$pkgrel openrc" + install="$subpkgname.post-install $subpkgname.post-upgrade" + replaces="soc-qcom-sdm845-pulseaudio-openrc" + + # 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 + + install -Dm644 "$srcdir"/call_audio_idle_suspend_workaround.confd \ + "$subpkgdir"/etc/conf.d/call_audio_idle_suspend_workaround +} + +sha512sums=" +28c14f47eaedec577d152001c51753537c98f267ac4a0acf78a304efebe5f6a1b4dc6d501497da9a0a925806a1d9c80b25e001cf9b1eb21efa22cd6a41ff753b 51-qcom.conf +4f2c22a3a3fc7d380e200ad977578107d81f0e7ade7918e03bdb15b60a564e8db5f47e13cce22f636d38fd3722696bb46076b8872dae0ca2d8a3838522a1f025 90-feedbackd-pmi8998.rules +9d455b56558d453d501a1ad869ffa79f9952ed43485a9847d506db6a78bfcd9f9c9d855660ee1d368eb74f4429385ec166addc30d802261c75562e785fe84c52 UPower.conf +6fb4c0bd8b7ed534d855a6732ccff783960e3cfa0e0cc7effcbb93afa00798dec15361a37a3200081bc114c8d266b7a0851cc4e819ad36eabdb47a50c72620d9 call_audio_idle_suspend_workaround.confd +5a58475b6e2ee1d655f3f23d8dc19e1cb2f32f1dfff3b9a9337d9c5baad1ec24bfaec0fb9cc03f00e5a291bee27c6b8bffbc65157e2bee5d65ef6d1adcb0910b call_audio_idle_suspend_workaround.initd +6da0a9209f114354aa2aa1185ec3896a8e0bb1bfce0dc3fc4c0de339cf1389feaa2d724e733c251ff032a5e86d37d9549e94f8f7c7a5accfedbd8a4d6316bbfd call_audio_idle_suspend_workaround.sh +f86ebf68bb7e41b531e5cd8fc3e54d8fafad314fb80950277e41004303b3bf75b2ae96f0228bdf4ed67645aee8ceaf247140b4843c66365259d2908b8991b877 gstreamer.conf +471583b91bc35608cb75d0b3ceb88fa793a4e763ea228703c50ffb1b45c0e9054646c46f710164ec3ef65a882a204fd59546f3a0ebb94b8d6c6f08c4043bcfd3 gstreamer.sh +e33f41360ccc4900bb76a26cc7b46bde1fb90facdf45c4fbcebc80499386939948401cacd6df9f779eafab10f4ee77ee1fef3e7bd06f483f8c2a4a644c84f327 modemmanager.conf +" diff --git a/device/community/soc-qcom/UPower.conf b/device/community/soc-qcom/UPower.conf new file mode 100644 index 000000000..a9bea9c14 --- /dev/null +++ b/device/community/soc-qcom/UPower.conf @@ -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 diff --git a/device/community/soc-qcom/call_audio_idle_suspend_workaround.confd b/device/community/soc-qcom/call_audio_idle_suspend_workaround.confd new file mode 100644 index 000000000..c1f508aef --- /dev/null +++ b/device/community/soc-qcom/call_audio_idle_suspend_workaround.confd @@ -0,0 +1,10 @@ +userid=10000 # Default User ID in pmOS +command_user=$(getent passwd $userid | cut -d: -f1) + +# Sxmo's XDG_RUNTIME_DIR is different than what is used in phosh +[ -f "/etc/profile.d/sxmo_init.sh" ] && XDG_RUNTIME_DIR="/dev/shm/user/$userid" + +# If the XDG_RUNTIME_DIR env variable is not set for a specific ui, set it to default for phosh +[ -z "$XDG_RUNTIME_DIR" ] && XDG_RUNTIME_DIR="/run/user/$userid" + +env_var="XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR" diff --git a/device/community/soc-qcom/call_audio_idle_suspend_workaround.initd b/device/community/soc-qcom/call_audio_idle_suspend_workaround.initd new file mode 100644 index 000000000..2bcfcf9d2 --- /dev/null +++ b/device/community/soc-qcom/call_audio_idle_suspend_workaround.initd @@ -0,0 +1,14 @@ +#!/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" +command="/usr/sbin/call_audio_idle_suspend_workaround" +supervisor=supervise-daemon +respawn_delay=1 +respawn_max=10 +start_stop_daemon_args="--env $env_var" + +depend() { + need dbus +} diff --git a/device/community/soc-qcom/call_audio_idle_suspend_workaround.sh b/device/community/soc-qcom/call_audio_idle_suspend_workaround.sh new file mode 100644 index 000000000..8b72ee8c9 --- /dev/null +++ b/device/community/soc-qcom/call_audio_idle_suspend_workaround.sh @@ -0,0 +1,39 @@ +#!/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 + pidof pulseaudio && pactl unload-module module-suspend-on-idle + + # With Wireplumber audio, the Pulseaudio + # compatibility layer doesn't support + # loading/unloading the suspend module. Add + # loopback sinks and sources instead. + sleep 1 + pw-loopback -m '[FL FR]' --capture-props='media.class=Audio/Sink' & + pw-loopback -m '[FL FR]' --playback-props='media.class=Audio/Source' & + fi + + if [ "$state" -eq '7' ]; then + echo "Call Ended" + killall -9 pw-loopback & + + # Reload module-suspend-on-idle after call ends + pidof pulseaudio && pactl load-module module-suspend-on-idle + fi + fi + done & + +wait diff --git a/device/community/soc-qcom/gstreamer.conf b/device/community/soc-qcom/gstreamer.conf new file mode 100644 index 000000000..be3ae7a7b --- /dev/null +++ b/device/community/soc-qcom/gstreamer.conf @@ -0,0 +1 @@ +GST_PLUGIN_FEATURE_RANK=v4l2vp8dec:SECONDARY,v4l2vp8enc:NONE,v4l2vp9dec:SECONDARY,v4l2h264dec:SECONDARY,v4l2h264enc:NONE,v4l2h265dec:SECONDARY,v4l2h265enc:NONE,v4l2mpeg2dec:SECONDARY diff --git a/device/community/soc-qcom/gstreamer.sh b/device/community/soc-qcom/gstreamer.sh new file mode 100644 index 000000000..533e7e830 --- /dev/null +++ b/device/community/soc-qcom/gstreamer.sh @@ -0,0 +1 @@ +export GST_PLUGIN_FEATURE_RANK=v4l2vp8dec:SECONDARY,v4l2vp8enc:NONE,v4l2vp9dec:SECONDARY,v4l2h264dec:SECONDARY,v4l2h264enc:NONE,v4l2h265dec:SECONDARY,v4l2h265enc:NONE,v4l2mpeg2dec:SECONDARY diff --git a/device/community/soc-qcom/modemmanager.conf b/device/community/soc-qcom/modemmanager.conf new file mode 100644 index 000000000..3938840a4 --- /dev/null +++ b/device/community/soc-qcom/modemmanager.conf @@ -0,0 +1,6 @@ +# /etc/conf.d/modemmanager: config file for modemmanager + +# Add extra command line options to modemmanager, use with care +# ModemManager --help for possible values +# Use quick suspend/resume hooks +modemmanager_opts="--test-quick-suspend-resume" diff --git a/device/community/soc-qcom/soc-qcom-modem-openrc.post-install b/device/community/soc-qcom/soc-qcom-modem-openrc.post-install new file mode 100644 index 000000000..05e660bde --- /dev/null +++ b/device/community/soc-qcom/soc-qcom-modem-openrc.post-install @@ -0,0 +1,2 @@ +#!/bin/sh +rc-update add q6voiced default diff --git a/device/community/soc-qcom/soc-qcom-modem-openrc.post-upgrade b/device/community/soc-qcom/soc-qcom-modem-openrc.post-upgrade new file mode 120000 index 000000000..4baf8c988 --- /dev/null +++ b/device/community/soc-qcom/soc-qcom-modem-openrc.post-upgrade @@ -0,0 +1 @@ +soc-qcom-modem-openrc.post-install \ No newline at end of file diff --git a/device/community/soc-qcom/soc-qcom-openrc.post-install b/device/community/soc-qcom/soc-qcom-openrc.post-install new file mode 100644 index 000000000..70b9e0efe --- /dev/null +++ b/device/community/soc-qcom/soc-qcom-openrc.post-install @@ -0,0 +1,3 @@ +#!/bin/sh +rc-update add tqftpserv boot +rc-update add pd-mapper boot diff --git a/device/community/soc-qcom/soc-qcom-openrc.post-upgrade b/device/community/soc-qcom/soc-qcom-openrc.post-upgrade new file mode 120000 index 000000000..0e26ccf6a --- /dev/null +++ b/device/community/soc-qcom/soc-qcom-openrc.post-upgrade @@ -0,0 +1 @@ +soc-qcom-openrc.post-install \ No newline at end of file diff --git a/device/community/soc-qcom/soc-qcom-pulseaudio-openrc.post-install b/device/community/soc-qcom/soc-qcom-pulseaudio-openrc.post-install new file mode 100644 index 000000000..c318fe7e8 --- /dev/null +++ b/device/community/soc-qcom/soc-qcom-pulseaudio-openrc.post-install @@ -0,0 +1,3 @@ +#!/bin/sh + +rc-update add call_audio_idle_suspend_workaround default diff --git a/device/community/soc-qcom/soc-qcom-pulseaudio-openrc.post-upgrade b/device/community/soc-qcom/soc-qcom-pulseaudio-openrc.post-upgrade new file mode 120000 index 000000000..266083fdd --- /dev/null +++ b/device/community/soc-qcom/soc-qcom-pulseaudio-openrc.post-upgrade @@ -0,0 +1 @@ +soc-qcom-pulseaudio-openrc.post-install \ No newline at end of file diff --git a/device/community/soc-qcom/soc-qcom-qbootctl-openrc.post-install b/device/community/soc-qcom/soc-qcom-qbootctl-openrc.post-install new file mode 100644 index 000000000..1ce77a594 --- /dev/null +++ b/device/community/soc-qcom/soc-qcom-qbootctl-openrc.post-install @@ -0,0 +1,2 @@ +#!/bin/sh +rc-update add qbootctl default diff --git a/device/community/soc-qcom/soc-qcom-qbootctl-openrc.post-upgrade b/device/community/soc-qcom/soc-qcom-qbootctl-openrc.post-upgrade new file mode 120000 index 000000000..ca288d826 --- /dev/null +++ b/device/community/soc-qcom/soc-qcom-qbootctl-openrc.post-upgrade @@ -0,0 +1 @@ +soc-qcom-qbootctl-openrc.post-install \ No newline at end of file