Skip to content

Instantly share code, notes, and snippets.

@arbruijn
Created August 18, 2022 21:06
Show Gist options
  • Save arbruijn/3750e2c62c7c3aaa5b316d52771c8f5a to your computer and use it in GitHub Desktop.
Save arbruijn/3750e2c62c7c3aaa5b316d52771c8f5a to your computer and use it in GitHub Desktop.

(copied from https://etherpad.gnome.org/p/hHCbgC0w4P4ZrSDiaoGB)

USB Audio on PP/PPP

Why?

  • Because USB Audio supports Bluetooth devices (and anything other, like USB-OTG, etc.)
  • Because USB Audio supports audio filters (like echo cancellation)
  • Because USB Audio supports call recording
  • Because you will experience less clicks
  • Because you may want to both have a call and listen to music?

Why not?

  • Because it's buggy and untested
  • Because there's a delay introduced
  • Because USB connection between main CPU and modem tends to disconnect
  • Because you don't want to void your 30-day warranty by replacing the modem firmware
  • Because perhaps PinePhone CPU is too slow or you want your battery to work longer (unsure)

Prerequisites

How?

  • We set our EG25-G into the state of moving audio thru the USB Gadget mode (like Librem5 does with its modem), not via the codec
  • Then we disable switching by copying over the HiFi ALSA-UCM2 config over the PhoneCall config
  • Finally we run wys from Librem5 to route audio between the codec (or any other audio device) and modem in userspace when calls start. It also does echo cancellation!

Steps

# Enable the USB audio gadget (you must have Biktorg's firmware - if you don't know if you have one, you don't!)
# Warning - this will persist across modem reboots!
echo -e "AT+EN_USBAUD\r" | sudo tee /dev/ttyUSB2 # or: /dev/EG25.AT
# Check if it worked. Type cat /proc/asound/cards, you should see the following:
#  0 [PinePhonePro   ]: simple-card - PinePhonePro
#                       PinePhonePro
#  1 [Module         ]: USB-Audio - LTE Module
#                       Quectel, Incorporated LTE Module at usb-fe3c0000.usb-1, high speed

# Install wys, may be packaged in your distro
# Fedora: 
#   Enable marcin/pine copr: https://copr.fedorainfracloud.org/coprs/marcin/pine/
#   dnf -y install wys

# Disable switching
cd /usr/share/alsa/ucm2/Pine64/PinePhonePro
# replace with PinePhone for PP
# also it may be in /usr/share/alsa/ucm2/PinePhonePro depending on your distro
# Backup the VoiceCall.conf file, important if you will want to rollback (and believe me, you will!):
cp VoiceCall.conf VoiceCall.conf.bak
# Overwrite VoiceCall.conf with HiFi.conf
cp HiFi.conf VoiceCall.conf

# Reload alsaucm config:
alsaucm reload

# Start wys for the "LTE Module" card
wys -m "LTE Module"
# (if you want to make it permanent edit your wys.service to add -m "LTE Module" and enable it)

Rollback

# Disable USB Audio gadget
echo -e "AT+DIS_USBAUD\r" | sudo tee /dev/ttyUSB2 # or: /dev/EG25.AT

# Ensure wys isn't running
killall wys

# Restore CallAudio.conf from backup
cd /usr/share/alsa/ucm2/Pine64/PinePhonePro
cp VoiceCall.conf.bak VoiceCall.conf
alsaucm reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment