From 3ca081f4ddcc1457e9d54f83faa30b7b46ed0208 Mon Sep 17 00:00:00 2001 From: Mayeul Cantan Date: Fri, 21 Feb 2020 14:47:07 +0100 Subject: [PATCH] pine64-pinephone: reset modem after applying configuration (!978) The datasheet says that the AT+QDAI audio routing configuration is saved to non-volatile memory directly, and therefore needs a modem reset to be applied. This commits changes the audio routing configuration script to first check for the current configuration, and only change it if it is different from the one wanted. The new configuration is then sent, and modem is reset to apply configuration. --- .../testing/device-pine64-pinephone/APKBUILD | 4 +- .../setup-modem-audio.sh | 45 ++++++++++++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/device/testing/device-pine64-pinephone/APKBUILD b/device/testing/device-pine64-pinephone/APKBUILD index c4f1562ea..798f58791 100644 --- a/device/testing/device-pine64-pinephone/APKBUILD +++ b/device/testing/device-pine64-pinephone/APKBUILD @@ -3,7 +3,7 @@ pkgname="device-pine64-pinephone" pkgdesc="PINE64 PinePhone" pkgver=0.2 -pkgrel=3 +pkgrel=4 url="https://postmarketos.org" license="MIT" arch="aarch64" @@ -89,5 +89,5 @@ aa0b7191548e89ddfc6cf5b1f637c7ee7ab4c2025cbfc6328e7e482e5b179ea072779ca332a18094 3cf0f2b0d463c1cf79156facfbddfa7e5bb9dffc54c364e0aa27e4f5e4778ec889febe8aecc819782db4f8423ac3cff2264c8e96c7e4f327519a4c403e087ce1 HiFi 7071765039f282185d5a5f64912f41f96562785436018b4391f87e68bd9636addac496ebec239f7d82f7ef55401ac0cfe03ec1aebb454bd2eedf5b1251da758f VoiceCall 5a1a9c774253e8211cc54f4b3961c4bdc35427726d037b0ecad099915e856590e8267a4a47943ab753772d57261eef89924b407b305b1099a9c4ecd7b5f00b35 eg25.initd -78f353cfe59657614ad5629435dc72a529b052986d646e29193645dcfd3663f5704542afd9a43f8b4ea65d1614ad32598a5434409ac524559ff66a9ab9b60856 setup-modem-audio.sh +dc110f617efe28df3001630836c7df0cab20e74e99c4bb9d2c2f86367ae024dd30060e8c051c7be0e66e86f4656bef345189a6c13276808c4301d1a6deb8be7d setup-modem-audio.sh 1b244cc6bfda4ff6c719c2dc077a2600376301d995607d15840994885b9044335d92d085282566a8baa0c2deb090ce958c586ea1e5950baf0e13686aef257b20 setup-modem-audio.initd" diff --git a/device/testing/device-pine64-pinephone/setup-modem-audio.sh b/device/testing/device-pine64-pinephone/setup-modem-audio.sh index d70b7b293..3cc363229 100644 --- a/device/testing/device-pine64-pinephone/setup-modem-audio.sh +++ b/device/testing/device-pine64-pinephone/setup-modem-audio.sh @@ -1,10 +1,51 @@ #!/bin/sh -RET=$(echo "AT+QDAI=1,0,0,2,0,1,1,1" | atinout - /dev/EG25.AT -) +# Current modem routing +# +# 1 - Digital PCM +# 0 - I2S master +# 0 - Primary mode (short sync) +# 2 - 512kHz clock (512kHz / 16bit = 32k samples/s) +# 0 - 16bit linear format +# 1 - 16k sample/s +# 1 - 1 slot +# 1 - map to first slot (the only slot) +# +QDAI_CONFIG="1,0,0,2,0,1,1,1" -if echo $RET | grep -q OK; then +DEV=/dev/EG25.AT + +# Read current config +RET=$(echo "AT+QDAI?" | atinout - $DEV -) + +if echo $RET | grep -q $QDAI_CONFIG +then + echo "Modem audio already configured" + exit 0 +fi + + +# Modem not configured, we need to send it the digital interface configuration, +# then reboot it +RET=$(echo "AT+QDAI=$QDAI_CONFIG" | atinout - $DEV -) + +if echo $RET | grep -q OK +then echo "Successfully configured modem audio" else echo "Failed to set modem audio up: $RET" exit 1 fi + +# Reset module +# 1 Set the mode to full functionality (vs 4: no RF, and 1: min functionality) +# 1 Reset the modem before changing mode (only available with 1 above) +# +RET=$(echo "AT+CFUN=1,1" | atinout - $DEV -) + +if echo $RET | grep -q OK +then + echo "Successfully reset the modem to apply audio configuration" +else + echo "Failed to reset the modem to apply audio configuration: $RET" +fi