samsung-a6lte: cellular support via samsungipcd (MR 3585)

[ci:skip-build]: already built successfully in CI
This commit is contained in:
Sergey Lisov 2023-01-18 19:59:25 +03:00 committed by Oliver Smith
parent b658b886b8
commit b7c3d41b9a
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
7 changed files with 204 additions and 6 deletions

View file

@ -1,8 +1,8 @@
# Reference: <https://postmarketos.org/devicepkg> # Reference: <https://postmarketos.org/devicepkg>
pkgname=device-samsung-a6lte pkgname=device-samsung-a6lte
pkgdesc="Samsung Galaxy A6 2018" pkgdesc="Samsung Galaxy A6 2018"
pkgver=0.1 pkgver=0.2
pkgrel=1 pkgrel=0
url="https://postmarketos.org" url="https://postmarketos.org"
license="MIT" license="MIT"
arch="aarch64" arch="aarch64"
@ -15,6 +15,9 @@ depends="
pipewire pipewire
pipewire-pulse pipewire-pulse
postmarketos-base postmarketos-base
samsungipcd
samsungipcd-openrc
util-linux
" "
replaces=" replaces="
lightdm lightdm
@ -22,13 +25,17 @@ replaces="
udev-init-scripts-openrc udev-init-scripts-openrc
" "
makedepends="devicepkg-dev" makedepends="devicepkg-dev"
install="$pkgname.post-install"
source=" source="
deviceinfo deviceinfo
etc-conf.d-samsungipcd
etc-init.d-udev-settle etc-init.d-udev-settle
etc-lightdm-lightdm.conf etc-lightdm-lightdm.conf
etc-NetworkManager-conf.d-swlan0-unmanaged.conf etc-NetworkManager-conf.d-swlan0-unmanaged.conf
usr-libexec-samsungipcd-voicecall.sh
usr-share-alsa-ucm2-conf.d-Universal7870-I-HiFi.conf usr-share-alsa-ucm2-conf.d-Universal7870-I-HiFi.conf
usr-share-alsa-ucm2-conf.d-Universal7870-I-Universal7870-I.conf usr-share-alsa-ucm2-conf.d-Universal7870-I-Universal7870-I.conf
usr-share-alsa-ucm2-conf.d-Universal7870-I-VoiceCall.conf
usr-share-pipewire-media-session.d-alsa-monitor.conf usr-share-pipewire-media-session.d-alsa-monitor.conf
" "
subpackages="$pkgname-nonfree-firmware:nonfree_firmware" subpackages="$pkgname-nonfree-firmware:nonfree_firmware"
@ -41,11 +48,14 @@ build() {
package() { package() {
devicepkg_package $startdir $pkgname devicepkg_package $startdir $pkgname
install -Dm644 etc-conf.d-samsungipcd "$pkgdir"/etc/conf.d/samsungipcd
install -Dm755 etc-init.d-udev-settle "$pkgdir"/etc/init.d/udev-settle install -Dm755 etc-init.d-udev-settle "$pkgdir"/etc/init.d/udev-settle
install -Dm644 etc-lightdm-lightdm.conf "$pkgdir"/etc/lightdm/lightdm.conf install -Dm644 etc-lightdm-lightdm.conf "$pkgdir"/etc/lightdm/lightdm.conf
install -Dm644 etc-NetworkManager-conf.d-swlan0-unmanaged.conf "$pkgdir"/etc/NetworkManager/conf.d/swlan0-unmanaged.conf install -Dm644 etc-NetworkManager-conf.d-swlan0-unmanaged.conf "$pkgdir"/etc/NetworkManager/conf.d/swlan0-unmanaged.conf
install -Dm755 usr-libexec-samsungipcd-voicecall.sh "$pkgdir"/usr/libexec/samsungipcd/voicecall.sh
install -Dm644 usr-share-alsa-ucm2-conf.d-Universal7870-I-HiFi.conf "$pkgdir"/usr/share/alsa/ucm2/conf.d/Universal7870-I/HiFi.conf install -Dm644 usr-share-alsa-ucm2-conf.d-Universal7870-I-HiFi.conf "$pkgdir"/usr/share/alsa/ucm2/conf.d/Universal7870-I/HiFi.conf
install -Dm644 usr-share-alsa-ucm2-conf.d-Universal7870-I-Universal7870-I.conf "$pkgdir"/usr/share/alsa/ucm2/conf.d/Universal7870-I/Universal7870-I.conf install -Dm644 usr-share-alsa-ucm2-conf.d-Universal7870-I-Universal7870-I.conf "$pkgdir"/usr/share/alsa/ucm2/conf.d/Universal7870-I/Universal7870-I.conf
install -Dm644 usr-share-alsa-ucm2-conf.d-Universal7870-I-VoiceCall.conf "$pkgdir"/usr/share/alsa/ucm2/conf.d/Universal7870-I/VoiceCall.conf
install -Dm644 usr-share-pipewire-media-session.d-alsa-monitor.conf "$pkgdir"/usr/share/pipewire/media-session.d/alsa-monitor.conf install -Dm644 usr-share-pipewire-media-session.d-alsa-monitor.conf "$pkgdir"/usr/share/pipewire/media-session.d/alsa-monitor.conf
} }
@ -57,10 +67,13 @@ nonfree_firmware() {
sha512sums=" sha512sums="
63be7d1b44093c2d892a92ad788a9a6a9d510c9ca0aac1f249213458402c546560827aaaa23c88497efee4675b15bf47481e551e5de043abaf5ae65e3de9c10a deviceinfo 63be7d1b44093c2d892a92ad788a9a6a9d510c9ca0aac1f249213458402c546560827aaaa23c88497efee4675b15bf47481e551e5de043abaf5ae65e3de9c10a deviceinfo
3e5bb764529010d2b6b1f2759a7799f665d140aebcee2dd63433e68cd4282e09b5d3b34fb7c21e737595b406501e7f02ece4592651c60e4c2b9419de4aedb438 etc-conf.d-samsungipcd
203b832a7080d5f1351c5e024e444f9fe509f6e0fd4b376a60c7d73359b7e356863a4f15caf9b2e4e733dc44d2971722083e7c69ca94a012eb004b4b8ded9d09 etc-init.d-udev-settle 203b832a7080d5f1351c5e024e444f9fe509f6e0fd4b376a60c7d73359b7e356863a4f15caf9b2e4e733dc44d2971722083e7c69ca94a012eb004b4b8ded9d09 etc-init.d-udev-settle
861270c6bc0b2a3e6cd389c21c8c895e62de8cf8bec6fcf23c178f8cbaae855d62b0ee98692671ab4f518d84cb43dd0b2fe46f5a609f65af6a6c06e0fdbb6d0c etc-lightdm-lightdm.conf 861270c6bc0b2a3e6cd389c21c8c895e62de8cf8bec6fcf23c178f8cbaae855d62b0ee98692671ab4f518d84cb43dd0b2fe46f5a609f65af6a6c06e0fdbb6d0c etc-lightdm-lightdm.conf
ef24527b13e48a9153643f3713167d3d08486e7de8b4c94d7c446ff380396115890573d8cd4aa5448766d9e779e189833a83e7921081679bd348c3f8a59410af etc-NetworkManager-conf.d-swlan0-unmanaged.conf ef24527b13e48a9153643f3713167d3d08486e7de8b4c94d7c446ff380396115890573d8cd4aa5448766d9e779e189833a83e7921081679bd348c3f8a59410af etc-NetworkManager-conf.d-swlan0-unmanaged.conf
80ea4968be09dec3deac4d6c5c58b7848f6ea297f2fe2e09f58dec5ba78c0a39060a7d86410a52414f615a0fef9ae9506e12d492d700eb168793433ea7691155 usr-share-alsa-ucm2-conf.d-Universal7870-I-HiFi.conf abe1c4a2f59fe862cebef75c54b8806bd86ce06aeb15d8c0699ab1338c9d575cb72a4d5b099f94272b1d9c9c3f4960af209a9e058ea9e57733b7d905dad0d33f usr-libexec-samsungipcd-voicecall.sh
fe527672d5e52a1b074e7e3613a6321f987270ececfdfaf49d1fde9fcd4f4dc93f37374c80ee3d539e4079a5c6e07ffddc648a1544bccbe4810e1bc30d0c2112 usr-share-alsa-ucm2-conf.d-Universal7870-I-Universal7870-I.conf 2169590d10d6123575d43e8ff7dc0d2ba824f8266d9fa75a5b59a4cc5753e47e327368b777082930d6b7a7aed6f57fa6ac2c5a2e816e1e12cd1032a8bb1822b5 usr-share-alsa-ucm2-conf.d-Universal7870-I-HiFi.conf
dc528deb556906adfb89b02b6faa04a8b21358706bb60e2fa51c8a3c909b680fcc02fa425b0cb5d6273595f27dfc9b640e1a8d455657fd6b47652af9e8ec295a usr-share-alsa-ucm2-conf.d-Universal7870-I-Universal7870-I.conf
3e74de3504f134a2726ee87740c5803bbd578352674d1d7de8b9460e57553100e9c4d322143ee83d3d584884c52eef47762bed41814ff1fca8cd9c4552f39b73 usr-share-alsa-ucm2-conf.d-Universal7870-I-VoiceCall.conf
5e87452f4cd70bbbcfb3e69bae73f2690ba328e7ccde55c47482e8fb1583d807de5bd3d328b1fe6a8733b4de78b2ed0c6ae8cdb60f6bf51ed4362c2174671b3e usr-share-pipewire-media-session.d-alsa-monitor.conf 5e87452f4cd70bbbcfb3e69bae73f2690ba328e7ccde55c47482e8fb1583d807de5bd3d328b1fe6a8733b4de78b2ed0c6ae8cdb60f6bf51ed4362c2174671b3e usr-share-pipewire-media-session.d-alsa-monitor.conf
" "

View file

@ -0,0 +1,7 @@
#!/bin/sh
# Create mount point and /efs mount point in fstab
if ! grep -q /efs /etc/fstab; then
mkdir -p /efs
echo "/dev/disk/by-partlabel/EFS /efs auto ro 0 0" >> /etc/fstab
fi

View file

@ -0,0 +1 @@
IPC_DEVICE_NAME="herolte"

View file

@ -0,0 +1,61 @@
#!/bin/sh
# This script sets up the audio subsystem to route audio to and from the modem.
# Called by samsungipcd when the call starts. When the call ends, we receive a
# newline and terminate ourselves.
# Note: as a side effect, software on the phone cannot access the microphone
# during a call.
# Put ourselves into a PID namespace. This is an easy and non-racey way to
# ensure that all child processes get killed on our exit.
if [ "$$" != 1 ]; then
unshare -p sh "$0"
exitcode="$?"
# Restore MIC1 state to normal. We should be the only entity fiddling
# with that.
amixer -D sysdefault cset name='MIC1 MIC1 On' 1
exit "$exitcode"
fi
# callaudiod has already changed the UCM verb, no need to do it manually
#alsaucm set _verb 'Voice Call'
# In order for sound to be forwarded, there must be applictions that are
# currently playing and recording audio. To ensure that they exists, we
# connect to each user's PipeWire and start ones.
# Playback
for i in /run/user/*/; do
# To avoid vulnerabilities in PulseAudio becoming LPEs, setuid to the
# user running PipeWire.
XDG_RUNTIME_DIR="$i" su -c 'aplay /dev/zero' "$(grep "^[^:]*:[^:]*:$(basename "$i"):" /etc/passwd | cut -d : -f 1-1)" &
done
# Same for recording
for i in /run/user/*/; do
XDG_RUNTIME_DIR="$i" su -c 'arecord /dev/null' "$(grep "^[^:]*:[^:]*:$(basename "$i"):" /etc/passwd | cut -d : -f 1-1)" &
done
# Microphone switching logic
for i in /run/user/*/; do
XDG_RUNTIME_DIR="$i" su -c '
# Set locale to C to avoid parsing localized command output
export LANG=C
# Report microphone mute events
( echo; pactl subscribe; ) | while read; do pactl get-source-mute @DEFAULT_SOURCE@; done
' "$(grep "^[^:]*:[^:]*:$(basename "$i"):" /etc/passwd | cut -d : -f 1-1)" &
done | while read line; do
if [[ "$line" == "Mute: yes" ]]; then
amixer -D sysdefault cset name='MIC1 MIC1 On' 0
elif [[ "$line" == "Mute: no" ]]; then
amixer -D sysdefault cset name='MIC1 MIC1 On' 1
fi
done &
# Wait for newline from samsungipcd. This means that the call has ended.
read
# No need to clean up, closing the PID namespace will kill all children
#jobs -p | xargs kill
# Again, callaudiod will switch UCM verbs for us
#alsaucm set _verb 'HiFi'

View file

@ -3,24 +3,32 @@ SectionVerb {
] ]
} }
SectionDevice."Headphones" { SectionDevice."Speaker" {
Comment "Internal speaker"
EnableSequence [ EnableSequence [
cset 'name="AMP Enable Switch" 1'
] ]
DisableSequence [ DisableSequence [
cset 'name="AMP Enable Switch" 0'
] ]
Value { Value {
PlaybackPriority 100 PlaybackPriority 101
PlaybackPCM "hw:${CardId}" PlaybackPCM "hw:${CardId}"
} }
} }
SectionDevice."Mic" { SectionDevice."Mic" {
Comment "Internal microphone"
EnableSequence [ EnableSequence [
cset 'name="MIC1 MIC1 On" 1'
] ]
DisableSequence [ DisableSequence [
cset 'name="MIC1 MIC1 On" 0'
] ]
Value { Value {
@ -28,3 +36,24 @@ SectionDevice."Mic" {
CapturePCM "hw:${CardId}" CapturePCM "hw:${CardId}"
} }
} }
SectionDevice."Earpiece" {
Comment "Earpiece"
EnableSequence [
cset 'name="EP EP On" 1'
cset 'name="EP Mixer DACL Switch" 1'
cset 'name="EP Mixer DACR Switch" 1'
]
DisableSequence [
cset 'name="EP Mixer DACR Switch" 0'
cset 'name="EP Mixer DACL Switch" 0'
cset 'name="EP EP On" 0'
]
Value {
PlaybackPriority 100
PlaybackPCM "hw:${CardId}"
}
}

View file

@ -1,9 +1,15 @@
Syntax 2 Syntax 2
SectionUseCase."HiFi" { SectionUseCase."HiFi" {
Comment "Hi-Fi"
File "HiFi.conf" File "HiFi.conf"
} }
SectionUseCase."Voice Call" {
Comment "Voice Call"
File "VoiceCall.conf"
}
SectionDefaults [ SectionDefaults [
cset "name='AudioMixer Mixer En' 1" cset "name='AudioMixer Mixer En' 1"
cset "name='AudioMixer CH1 Mixer En' 1" cset "name='AudioMixer CH1 Mixer En' 1"

View file

@ -0,0 +1,81 @@
SectionVerb {
EnableSequence [
cset 'name="AudioMixer SRC2 En" 1'
cset 'name="AudioMixer CH2 Mixer En" 1'
cset 'name="AudioMixer CH1 DOUT Select" 2'
cset 'name="AudioMixer CH2 DOUT Select" 1'
cset 'name="AudioMixer CH1 I2S Data Length" 0'
cset 'name="AudioMixer CH1 XFS" 1'
cset 'name="AudioMixer CH2 I2S Data Length" 0'
cset 'name="AudioMixer CH2 XFS" 0'
cset 'name="AMP Enable Switch" 0'
cset 'name="EP EP On" 1'
cset 'name="EP Mixer DACL Switch" 1'
cset 'name="EP Mixer DACR Switch" 1'
]
DisableSequence [
cset 'name="EP Mixer DACR Switch" 0'
cset 'name="EP Mixer DACL Switch" 0'
cset 'name="EP EP On" 0'
cset 'name="AMP Enable Switch" 1'
cset 'name="AudioMixer CH2 DOUT Select" 0'
cset 'name="AudioMixer CH1 DOUT Select" 1'
cset 'name="AudioMixer CH2 Mixer En" 0'
cset 'name="AudioMixer SRC2 En" 0'
]
}
SectionDevice."Speaker" {
Comment "Internal speaker"
EnableSequence [
cset 'name="AMP Enable Switch" 1'
]
DisableSequence [
cset 'name="AMP Enable Switch" 0'
]
Value {
PlaybackPriority 100
PlaybackPCM "hw:${CardId}"
}
}
SectionDevice."Mic" {
Comment "Internal microphone"
EnableSequence [
cset "name='MIC1 MIC1 On' 1"
]
DisableSequence [
cset "name='MIC1 MIC1 On' 0"
]
Value {
CapturePriority 100
CapturePCM "hw:${CardId}"
}
}
SectionDevice."Earpiece" {
Comment "Earpiece"
EnableSequence [
cset 'name="EP EP On" 1'
cset 'name="EP Mixer DACL Switch" 1'
cset 'name="EP Mixer DACR Switch" 1'
]
DisableSequence [
cset 'name="EP Mixer DACR Switch" 0'
cset 'name="EP Mixer DACL Switch" 0'
cset 'name="EP EP On" 0'
]
Value {
PlaybackPriority 101
PlaybackPCM "hw:${CardId}"
}
}