From e2b114a94c119c6372431beece128573ae84dd1d Mon Sep 17 00:00:00 2001 From: Lukasz Mrugala Date: Thu, 8 May 2025 14:15:01 +0000 Subject: [PATCH 1/7] lib.sh: Set ALSA settings from a state file set_alsa_settings() function now uses `alsactl restore` command, to change ALSA controls from a custom state file first, if it is present, and next - execute a bash script with amixer commands if it is also present. The state file is expected as `./alsa_settings/${PLATFORM}.state` whereas the bash script remains as `./alsa_settings/${PLATFORM}.sh` The custom state should be compatible with the platform's default state, see set_alsa() function. Co-authored-by: Lukasz Mrugala Co-authored-by: Dmitrii Golovanov --- case-lib/lib.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index d2f2f82f..6bd0312d 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -1206,7 +1206,7 @@ set_alsa_settings() { # ZEPHYR platform shares same tplg, remove '_ZEPHYR' from platform name local PNAME="${1%_ZEPHYR}" - dlogi "Run alsa setting for $PNAME" + dlogi "Apply ALSA settings for $PNAME" case $PNAME in APL_UP2_NOCODEC | CML_RVP_NOCODEC | JSL_RVP_NOCODEC | TGLU_RVP_NOCODEC | ADLP_RVP_NOCODEC | TGLH_RVP_NOCODEC | ADLP_RVP_NOCODEC-ipc3 | CML_RVP_NOCODEC-ipc3 | JSL_RVP_NOCODEC-ipc3) # common nocodec alsa settings @@ -1218,13 +1218,25 @@ set_alsa_settings() ;; TGLU_RVP_NOCODEC_IPC4ZPH | ADLP_RVP_NOCODEC_IPC4ZPH | ADLP_RVP_NOCODEC-ipc4 | TGLU_RVP_NOCODEC-ipc4 | MTLP_RVP_NOCODEC | MTLP_RVP_NOCODEC-multicore-2cores | MTLP_RVP_NOCODEC-multicore-3cores | LNLM_RVP_NOCODEC) dlogi "Use reset_sof_volume function to set amixer setting." - ;; + ;; *) # if script name is same as platform name, default case will handle all - if [ -f "$SCRIPT_HOME"/alsa_settings/"$PNAME".sh ]; then - "$SCRIPT_HOME"/alsa_settings/"$PNAME".sh - else - dlogw "alsa setting for $PNAME is not available" + local ALSA_SETTINGS_FILE="$SCRIPT_HOME"/alsa_settings/"$PNAME" + local rc=0 + if [ -f "${ALSA_SETTINGS_FILE}.state" ]; then + dlogc "alsactl restore --file=${ALSA_SETTINGS_FILE}.state --no-init-fallback --no-ucm" + alsactl restore --file="${ALSA_SETTINGS_FILE}".state --no-init-fallback --no-ucm 2>&1 || rc=$? + [[ "${rc}" -ne 0 ]] && dloge "alsactl restore error=${rc}" + # With `--pedantic` alsactl returns error=2, e.g. "No state is present for card CODEC" + fi + if [ -f "${ALSA_SETTINGS_FILE}.sh" ]; then + dlogc "${ALSA_SETTINGS_FILE}.sh" + rc=0 + "${ALSA_SETTINGS_FILE}".sh 2>&1 || rc=$? + [[ "${rc}" -ne 0 ]] && dloge "ALSA settings error=${rc}" + fi + if [ ! -f "${ALSA_SETTINGS_FILE}.state" ] && [ ! -f "${ALSA_SETTINGS_FILE}.sh" ]; then + dlogw "ALSA settings for $PNAME are not available" fi ;; esac @@ -1294,7 +1306,7 @@ set_alsa() # If MODEL is defined, set proper gain for the platform if [ -z "$MODEL" ]; then - dlogw "NO MODEL is defined. Please define MODEL to run alsa_settings/\${MODEL}.sh" + dlogw "NO MODEL is defined. Please define MODEL to apply additional settings from ./alsa_settings" else set_alsa_settings "$MODEL" fi From 97b1aaf09a13ce6a32b9eb7d701c8074e4cc4a05 Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Thu, 7 Aug 2025 18:13:15 +0200 Subject: [PATCH 2/7] lib.sh: set_alsa: Log ALSA state difference Log difference between the current ALSA state and the restored ALSA state. Signed-off-by: Dmitrii Golovanov --- case-lib/lib.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 6bd0312d..d4f95883 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -1313,6 +1313,10 @@ set_alsa() alsactl store -f "${asound_state}.txt" 2>&1 || rc=$? [[ "${rc}" -ne 0 ]] && dlogw "alsactl store error=${rc}" + + printf '%s\n' '-vv------- Check ALSA state difference -------vv-' >> "${alsa_log}" + diff -u --report-identical-files "${asound_state}_old.txt" "${asound_state}.txt" >> "${alsa_log}" 2>&1 || rc=$? + dlogi "ALSA state difference check result=${rc}" } DO_PERF_ANALYSIS=0 From 1d91eda3f4ef4c43d54136a8e86eef5746710afd Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Thu, 7 Aug 2025 17:57:52 +0200 Subject: [PATCH 3/7] alsa_settings: PTL platform settings move to state Replace PTL platform ALSA settings done as bash script commands by their equivalent ALSA state files for: * PTLH_HDA_AIOC * PTLH_SDW_RT712 * PTLP_RVP_SDW The parameters in the state files are explicitly set even if the default values at the appropriate DUT are currently the same. Signed-off-by: Dmitrii Golovanov Co-authored-by: Lukasz Mrugala --- alsa_settings/PTLH_HDA_AIOC.sh | 12 --------- alsa_settings/PTLH_HDA_AIOC.state | 36 +++++++++++++++++++++++++ alsa_settings/PTLH_SDW_RT712.sh | 10 ------- alsa_settings/PTLH_SDW_RT712.state | 36 +++++++++++++++++++++++++ alsa_settings/PTLP_RVP_SDW.sh | 16 ----------- alsa_settings/PTLP_RVP_SDW.state | 43 ++++++++++++++++++++++++++++++ 6 files changed, 115 insertions(+), 38 deletions(-) delete mode 100755 alsa_settings/PTLH_HDA_AIOC.sh create mode 100644 alsa_settings/PTLH_HDA_AIOC.state delete mode 100755 alsa_settings/PTLH_SDW_RT712.sh create mode 100644 alsa_settings/PTLH_SDW_RT712.state delete mode 100755 alsa_settings/PTLP_RVP_SDW.sh create mode 100644 alsa_settings/PTLP_RVP_SDW.state diff --git a/alsa_settings/PTLH_HDA_AIOC.sh b/alsa_settings/PTLH_HDA_AIOC.sh deleted file mode 100755 index 19627123..00000000 --- a/alsa_settings/PTLH_HDA_AIOC.sh +++ /dev/null @@ -1,12 +0,0 @@ -set -e - -# enable headset playback -amixer -c sofhdadsp cset name='Master Playback Switch' 1 -amixer -c sofhdadsp cset name='Master Playback Volume' 87 -amixer -c sofhdadsp cset name='Headphone Playback Switch' 1 -amixer -c sofhdadsp cset name='Headphone Playback Volume' 60 - -# enable headset capture -amixer -c sofhdadsp cset name='Capture Switch' on -amixer -c sofhdadsp cset name='Capture Volume' 30 -amixer -c sofhdadsp cset name='Capture Source' 2 diff --git a/alsa_settings/PTLH_HDA_AIOC.state b/alsa_settings/PTLH_HDA_AIOC.state new file mode 100644 index 00000000..c3775026 --- /dev/null +++ b/alsa_settings/PTLH_HDA_AIOC.state @@ -0,0 +1,36 @@ +state.sofhdadsp { + control.1 { + iface MIXER + name 'Headphone Playback Volume' + value.0 60 + value.1 60 + } + control.2 { + iface MIXER + name 'Headphone Playback Switch' + value.0 true + value.1 true + } + control.6 { + iface MIXER + name 'Capture Volume' + value.0 30 + value.1 30 + } + control.7 { + iface MIXER + name 'Capture Switch' + value.0 true + value.1 true + } + control.9 { + iface MIXER + name 'Master Playback Volume' + value 87 + } + control.10 { + iface MIXER + name 'Master Playback Switch' + value true + } +} diff --git a/alsa_settings/PTLH_SDW_RT712.sh b/alsa_settings/PTLH_SDW_RT712.sh deleted file mode 100755 index 059af52a..00000000 --- a/alsa_settings/PTLH_SDW_RT712.sh +++ /dev/null @@ -1,10 +0,0 @@ -set -e - -amixer -c sofsoundwire cset name='Headphone Switch' on -amixer -c sofsoundwire cset name='rt712 FU05 Playback Volume' 60 -amixer -c sofsoundwire cset name='rt712 FU06 Playback Volume' 60 - -# enable headset playback and capture -amixer -c sofsoundwire cset name='Headset Mic Switch' on -amixer -c sofsoundwire cset name='rt712 FU0F Capture Switch' on -amixer -c sofsoundwire cset name='rt712 FU0F Capture Volume' 46 diff --git a/alsa_settings/PTLH_SDW_RT712.state b/alsa_settings/PTLH_SDW_RT712.state new file mode 100644 index 00000000..35e456b4 --- /dev/null +++ b/alsa_settings/PTLH_SDW_RT712.state @@ -0,0 +1,36 @@ +state.sofsoundwire { + control.1 { + iface MIXER + name 'rt712 FU06 Playback Volume' + value.0 60 + value.1 60 + } + control.2 { + iface MIXER + name 'rt712 FU05 Playback Volume' + value.0 60 + value.1 60 + } + control.3 { + iface MIXER + name 'rt712 FU0F Capture Switch' + value.0 true + value.1 true + } + control.4 { + iface MIXER + name 'rt712 FU0F Capture Volume' + value.0 46 + value.1 46 + } + control.14 { + iface MIXER + name 'Headphone Switch' + value true + } + control.15 { + iface MIXER + name 'Headset Mic Switch' + value true + } +} diff --git a/alsa_settings/PTLP_RVP_SDW.sh b/alsa_settings/PTLP_RVP_SDW.sh deleted file mode 100755 index 28a609ff..00000000 --- a/alsa_settings/PTLP_RVP_SDW.sh +++ /dev/null @@ -1,16 +0,0 @@ -set -e - -#Enable "SoundWire microphones" -amixer -c sofsoundwire cset name='rt722 FU1E Capture Switch' 1 - -#Enable Speaker Switch -amixer -c sofsoundwire cset name='Speaker Switch' on -amixer -c sofsoundwire cset name='rt722 FU06 Playback Volume' 50 - -#Enable Headphone switch -amixer -c sofsoundwire cset name='Headphone Switch' on - -# enable headset playback and capture -amixer -c sofsoundwire cset name='Headset Mic Switch' on -amixer -c sofsoundwire cset name='rt722 FU0F Capture Switch' 1 -amixer -c sofsoundwire cset name='rt722 FU0F Capture Volume' 15 diff --git a/alsa_settings/PTLP_RVP_SDW.state b/alsa_settings/PTLP_RVP_SDW.state new file mode 100644 index 00000000..8a234963 --- /dev/null +++ b/alsa_settings/PTLP_RVP_SDW.state @@ -0,0 +1,43 @@ +state.sofsoundwire { + control.2 { + iface MIXER + name 'rt722 FU0F Capture Switch' + value.0 true + value.1 true + } + control.3 { + iface MIXER + name 'rt722 FU0F Capture Volume' + value.0 15 + value.1 15 + } + control.5 { + iface MIXER + name 'rt722 FU06 Playback Volume' + value.0 50 + value.1 50 + } + control.6 { + iface MIXER + name 'rt722 FU1E Capture Switch' + value.0 true + value.1 true + value.2 true + value.3 true + } + control.9 { + iface MIXER + name 'Headphone Switch' + value true + } + control.10 { + iface MIXER + name 'Headset Mic Switch' + value true + } + control.13 { + iface MIXER + name 'Speaker Switch' + value true + } +} From 55842f1172e04ff23b98de566a51445155e95bee Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Mon, 11 Aug 2025 11:44:32 +0200 Subject: [PATCH 4/7] alsa_settings: MTL platform settings move to state Replace MTL platform ALSA settings done as bash script commands by their equivalent ALSA state files for: * MTLP_RVP_HDA * MTLP_SDW_AIOC * MTLP_RVP_SDW The parameters in the state files are explicitly set even if the default values at the appropriate DUT are currently the same. Because of that, we can't 'reuse' MTLP_RVP_SDW state for MTLP_SDW_AIOC as before: these configurations have different id's whereas `amixer` had changed them referencing by name. In some cases, USB audio card settings are also included: it is needed to adjust loopback volume levels on a CI DUT. In the future these settings (actually most of the ALSA settings) should be migrated to the DUT's default configs and out of the test case scope, so only test-specific settings remain here. Signed-off-by: Dmitrii Golovanov Co-authored-by: Lukasz Mrugala --- alsa_settings/MTLP_RVP_HDA.sh | 11 --------- alsa_settings/MTLP_RVP_HDA.state | 36 +++++++++++++++++++++++++++++ alsa_settings/MTLP_RVP_SDW.sh | 17 -------------- alsa_settings/MTLP_RVP_SDW.state | 35 ++++++++++++++++++++++++++++ alsa_settings/MTLP_SDW_AIOC.sh | 1 - alsa_settings/MTLP_SDW_AIOC.state | 38 +++++++++++++++++++++++++++++++ 6 files changed, 109 insertions(+), 29 deletions(-) delete mode 100755 alsa_settings/MTLP_RVP_HDA.sh create mode 100644 alsa_settings/MTLP_RVP_HDA.state delete mode 100755 alsa_settings/MTLP_RVP_SDW.sh create mode 100644 alsa_settings/MTLP_RVP_SDW.state delete mode 120000 alsa_settings/MTLP_SDW_AIOC.sh create mode 100644 alsa_settings/MTLP_SDW_AIOC.state diff --git a/alsa_settings/MTLP_RVP_HDA.sh b/alsa_settings/MTLP_RVP_HDA.sh deleted file mode 100755 index 6978c6cc..00000000 --- a/alsa_settings/MTLP_RVP_HDA.sh +++ /dev/null @@ -1,11 +0,0 @@ -set -e - -# enable headset playback -amixer -c sofhdadsp cset name='Master Playback Switch' 1 -amixer -c sofhdadsp cset name='Master Playback Volume' 87 -amixer -c sofhdadsp cset name='Headphone Playback Switch' 1 -amixer -c sofhdadsp cset name='Headphone Playback Volume' 60 - -# enable headset capture -amixer -c sofhdadsp cset name='Capture Switch' on -amixer -c sofhdadsp cset name='Capture Volume' 30 diff --git a/alsa_settings/MTLP_RVP_HDA.state b/alsa_settings/MTLP_RVP_HDA.state new file mode 100644 index 00000000..c3775026 --- /dev/null +++ b/alsa_settings/MTLP_RVP_HDA.state @@ -0,0 +1,36 @@ +state.sofhdadsp { + control.1 { + iface MIXER + name 'Headphone Playback Volume' + value.0 60 + value.1 60 + } + control.2 { + iface MIXER + name 'Headphone Playback Switch' + value.0 true + value.1 true + } + control.6 { + iface MIXER + name 'Capture Volume' + value.0 30 + value.1 30 + } + control.7 { + iface MIXER + name 'Capture Switch' + value.0 true + value.1 true + } + control.9 { + iface MIXER + name 'Master Playback Volume' + value 87 + } + control.10 { + iface MIXER + name 'Master Playback Switch' + value true + } +} diff --git a/alsa_settings/MTLP_RVP_SDW.sh b/alsa_settings/MTLP_RVP_SDW.sh deleted file mode 100755 index ecfc39ab..00000000 --- a/alsa_settings/MTLP_RVP_SDW.sh +++ /dev/null @@ -1,17 +0,0 @@ -#This file is duplicated to MTLP_SDW_AIOC.sh since we only set rt711 mixer -#controls for the AIOC board. - -set -e - -# override jack detection mode to headset -# related linux pr: https://github.com/thesofproject/linux/pull/4969 -amixer -c sofsoundwire cset name='rt711 GE49 Selected Mode' 2 || true - -# enable headset playback -amixer -c sofsoundwire cset name='Headphone Switch' on -amixer -c sofsoundwire cset name='rt711 FU05 Playback Volume' 80 - -# enable headset capture -amixer -c sofsoundwire cset name='Headset Mic Switch' on -amixer -c sofsoundwire cset name='rt711 FU0F Capture Switch' on -amixer -c sofsoundwire cset name='rt711 FU0F Capture Volume' 30 diff --git a/alsa_settings/MTLP_RVP_SDW.state b/alsa_settings/MTLP_RVP_SDW.state new file mode 100644 index 00000000..defd2982 --- /dev/null +++ b/alsa_settings/MTLP_RVP_SDW.state @@ -0,0 +1,35 @@ +state.sofsoundwire { + control.1 { + iface MIXER + name 'rt711 FU05 Playback Volume' + value.0 80 + value.1 80 + } + control.3 { + iface MIXER + name 'rt711 FU0F Capture Switch' + value.0 true + value.1 true + } + control.5 { + iface MIXER + name 'rt711 FU0F Capture Volume' + value.0 26 + value.1 26 + } + control.8 { + iface MIXER + name 'rt711 GE49 Selected Mode' + value Headset + } + control.9 { + iface MIXER + name 'Headphone Switch' + value true + } + control.10 { + iface MIXER + name 'Headset Mic Switch' + value true + } +} diff --git a/alsa_settings/MTLP_SDW_AIOC.sh b/alsa_settings/MTLP_SDW_AIOC.sh deleted file mode 120000 index 933fb450..00000000 --- a/alsa_settings/MTLP_SDW_AIOC.sh +++ /dev/null @@ -1 +0,0 @@ -MTLP_RVP_SDW.sh \ No newline at end of file diff --git a/alsa_settings/MTLP_SDW_AIOC.state b/alsa_settings/MTLP_SDW_AIOC.state new file mode 100644 index 00000000..83dfc243 --- /dev/null +++ b/alsa_settings/MTLP_SDW_AIOC.state @@ -0,0 +1,38 @@ +state.sofsoundwire { + control.1 { + iface MIXER + name 'rt711 FU05 Playback Volume' + value.0 80 + value.1 80 + } + control.3 { + iface MIXER + name 'rt711 FU0F Capture Switch' + value.0 true + value.1 true + } + control.5 { + iface MIXER + name 'rt711 FU0F Capture Volume' + value.0 30 + value.1 30 + } + control.8 { + iface MIXER + name 'rt711 GE49 Selected Mode' + value Headset + } + control.36 { + iface MIXER + name 'Headset Mic Switch' + value true + } +} +state.CODEC { + control.4 { + iface MIXER + name 'PCM Playback Volume' + value.0 120 + value.1 120 + } +} From b7bd44868570d7f2fc1e27cd52c00a60193d462a Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Tue, 12 Aug 2025 11:44:31 +0200 Subject: [PATCH 5/7] alsa_settings: LNLM platform settings move to state Replace LNLM platform ALSA settings done as bash script commands by their equivalent ALSA state files for: * LNLM_RVP_HDA * LNLM_SDW_AIOC The parameters in the state files are explicitly set even if the default values at the appropriate DUT are currently the same. Signed-off-by: Dmitrii Golovanov Co-authored-by: Lukasz Mrugala --- alsa_settings/LNLM_RVP_HDA.sh | 11 -------- alsa_settings/LNLM_RVP_HDA.state | 36 +++++++++++++++++++++++ alsa_settings/LNLM_SDW_AIOC.sh | 16 ----------- alsa_settings/LNLM_SDW_AIOC.state | 47 +++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 27 deletions(-) delete mode 100755 alsa_settings/LNLM_RVP_HDA.sh create mode 100644 alsa_settings/LNLM_RVP_HDA.state delete mode 100755 alsa_settings/LNLM_SDW_AIOC.sh create mode 100644 alsa_settings/LNLM_SDW_AIOC.state diff --git a/alsa_settings/LNLM_RVP_HDA.sh b/alsa_settings/LNLM_RVP_HDA.sh deleted file mode 100755 index 6978c6cc..00000000 --- a/alsa_settings/LNLM_RVP_HDA.sh +++ /dev/null @@ -1,11 +0,0 @@ -set -e - -# enable headset playback -amixer -c sofhdadsp cset name='Master Playback Switch' 1 -amixer -c sofhdadsp cset name='Master Playback Volume' 87 -amixer -c sofhdadsp cset name='Headphone Playback Switch' 1 -amixer -c sofhdadsp cset name='Headphone Playback Volume' 60 - -# enable headset capture -amixer -c sofhdadsp cset name='Capture Switch' on -amixer -c sofhdadsp cset name='Capture Volume' 30 diff --git a/alsa_settings/LNLM_RVP_HDA.state b/alsa_settings/LNLM_RVP_HDA.state new file mode 100644 index 00000000..c3775026 --- /dev/null +++ b/alsa_settings/LNLM_RVP_HDA.state @@ -0,0 +1,36 @@ +state.sofhdadsp { + control.1 { + iface MIXER + name 'Headphone Playback Volume' + value.0 60 + value.1 60 + } + control.2 { + iface MIXER + name 'Headphone Playback Switch' + value.0 true + value.1 true + } + control.6 { + iface MIXER + name 'Capture Volume' + value.0 30 + value.1 30 + } + control.7 { + iface MIXER + name 'Capture Switch' + value.0 true + value.1 true + } + control.9 { + iface MIXER + name 'Master Playback Volume' + value 87 + } + control.10 { + iface MIXER + name 'Master Playback Switch' + value true + } +} diff --git a/alsa_settings/LNLM_SDW_AIOC.sh b/alsa_settings/LNLM_SDW_AIOC.sh deleted file mode 100755 index 515151d1..00000000 --- a/alsa_settings/LNLM_SDW_AIOC.sh +++ /dev/null @@ -1,16 +0,0 @@ -set -e - -# enable headset playback -amixer -c sofsoundwire cset name='Headphone Switch' on -amixer -c sofsoundwire cset name='rt711 FU05 Playback Volume' 80 - -# override jack detection mode to headset -# related linux pr: https://github.com/thesofproject/linux/pull/4969 -amixer -c sofsoundwire cset name='rt711 GE49 Selected Mode' 2 || true - -# enable headset capture -amixer -c sofsoundwire cset name='Headset Mic Switch' on -amixer -c sofsoundwire cset name='rt711 FU0F Capture Switch' on -amixer -c sofsoundwire cset name='rt711 FU1E Capture Switch' on -amixer -c sofsoundwire cset name='rt711 FU0F Capture Volume' 25 -amixer -c sofsoundwire cset name='rt711 FU1E Capture Volume' 25 diff --git a/alsa_settings/LNLM_SDW_AIOC.state b/alsa_settings/LNLM_SDW_AIOC.state new file mode 100644 index 00000000..7557375c --- /dev/null +++ b/alsa_settings/LNLM_SDW_AIOC.state @@ -0,0 +1,47 @@ +state.sofsoundwire { + control.1 { + iface MIXER + name 'rt711 FU05 Playback Volume' + value.0 80 + value.1 80 + } + control.2 { + iface MIXER + name 'rt711 FU1E Capture Switch' + value.0 true + value.1 true + } + control.3 { + iface MIXER + name 'rt711 FU0F Capture Switch' + value.0 true + value.1 true + } + control.4 { + iface MIXER + name 'rt711 FU1E Capture Volume' + value.0 25 + value.1 25 + } + control.5 { + iface MIXER + name 'rt711 FU0F Capture Volume' + value.0 25 + value.1 25 + } + control.8 { + iface MIXER + name 'rt711 GE49 Selected Mode' + value Headset + } + control.35 { + iface MIXER + name 'Headphone Switch' + value true + } + control.36 { + iface MIXER + name 'Headset Mic Switch' + value true + } +} From ccf21e5c90f5409e9ad5a8103e8c88478a6c9e5b Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Tue, 12 Aug 2025 14:10:49 +0200 Subject: [PATCH 6/7] alsa_settings: Add README.md Add README.md documentation for SOF test ALSA settings. Signed-off-by: Dmitrii Golovanov --- alsa_settings/README.md | 79 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 alsa_settings/README.md diff --git a/alsa_settings/README.md b/alsa_settings/README.md new file mode 100644 index 00000000..3abf6f5f --- /dev/null +++ b/alsa_settings/README.md @@ -0,0 +1,79 @@ +# ALSA settings + +SOF test case execution requires certain DSP and mixer configurations being set +on the DUT (Device Under Test). An important part of this configuration is the +signal levels adjusted to the hardware setup which runs the tests, including its +codec and loopback devices. + +The `./alsa_settings/` directory contains custom ALSA configurations which +are currently applied at the SOF CI pipeline's hardware platforms. +When the SOF tests run in other environment, these confugurations can serve +as a reference. + +These configurations include ALSA settings which are considered essential +for the SOF tests and expected at the appropriate DUT by default. They allow +ALSA settings tweaking in along with SOF and test developmnent, if needed. + +Please note that in some cases the settings are tuned to CI DUT 'harnesses': +external codecs with their versions, audio cards at loopback connections, etc. +In the future, most of these settings should be moved to the DUT's default config +out of the test case scope, so only the test-specific settings will remain here. +For example, some platforms have their external USB audio card settings included +in the configuration files: it is needed to adjust loopback volume levels on +the appropriate DUT and harness setup. + + +## How it works + +When a test case calls `set_alsa()` function, its task is to apply the DUT's +default ALSA configuration file as the baseline to ensure the expected ALSA +settings are active the same way as after the DUT's reboot, so to avoid +after-effects possible from the previous test's execution - either it was +success, or failure, or any other unexpected change due to the DUT's power +reset, the test case error, manual re-configuration, etc. + +After `alsactl init` and `alsa restore` calls by `set_alsa()` function, +two optional custom settings are applied in the following order (assuming +the DUT belongs to a `PLATFORM` hardware configuration, and the configuration +files are in `./alsa_settings/` directory): + +1. `PLATFORM.state` - an ALSA driver state file in `alsactl` format. + +2. `PLATFROM.sh` - a shell script to configure the ALSA driver parameters, + e.g. calling `amixer` tool. + +The custom state should be compatible with the platform's default state. + +It is important to avoid linking configuration files to 'reuse' them for +different HW configurations: the `.state` files have platform specific control +id's, whereas `amixer` command line tool refers to the sound card control by its name. + + +## DUT host expected configuration + +The DUT host should NOT run `alsa-state.service` + +The `alsa-restore.service` should work only in 'restore' mode (on start). +The 'store' mode (on shutdown) should be OFF to keep the default ALSA driver +settings not changed. + +It is NOT allowed to change the DUT's default state with `alsactl store` unless +it is a special part of the test case, or a DUT recovery procedure. + +For more details see [ALSA and systemd](https://wiki.archlinux.org/title/Advanced_Linux_Sound_Architecture#ALSA_and_systemd) + + +## How to create a custom .state file + +1. Check contents of the DUT's default ALSA driver configuration `asound.state`. + Usually, it is in `/var/lib/alsa/`, and under control of `alsa-restore.service`, + or `alsa-state.service`. Make sure you have a backup copy of this file: + the ALSA `.service`-s are in charge of keeping your current custom ALSA settings + as the DUT's default, so it might unexpectedly affect your DUT's normal operations, + unless it is your legitimate goal. + +2. Copy the ALSA controls you need to change with their new values into the appropriate + platform's `PLATFORM.state` file in `./alsa_settings/`, or create a shell script + `PLATFORM.sh` there with the appropriate `amixer` calls. + Both these methods can be applied simultaneously, although in the above mentioned order. + From 8f201d15a2b3754649c950ed7fd5fa0ec8ff4904 Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Wed, 13 Aug 2025 11:39:56 +0200 Subject: [PATCH 7/7] alsa_settings: Keep comments from removed scripts Keep comments from the removed shell scripts adding them to the appropriate .state files: LNLM_SDW_AIOC.state MTLP_SWD_AIOC.state WARNING: these comments might be incompatible with `alsactl` tool in the future. Signed-off-by: Dmitrii Golovanov --- alsa_settings/LNLM_SDW_AIOC.state | 2 ++ alsa_settings/MTLP_SDW_AIOC.state | 2 ++ 2 files changed, 4 insertions(+) diff --git a/alsa_settings/LNLM_SDW_AIOC.state b/alsa_settings/LNLM_SDW_AIOC.state index 7557375c..7eef34ba 100644 --- a/alsa_settings/LNLM_SDW_AIOC.state +++ b/alsa_settings/LNLM_SDW_AIOC.state @@ -33,6 +33,8 @@ state.sofsoundwire { iface MIXER name 'rt711 GE49 Selected Mode' value Headset + # override jack detection mode to headset + # related to https://github.com/thesofproject/linux/pull/4969 } control.35 { iface MIXER diff --git a/alsa_settings/MTLP_SDW_AIOC.state b/alsa_settings/MTLP_SDW_AIOC.state index 83dfc243..79701088 100644 --- a/alsa_settings/MTLP_SDW_AIOC.state +++ b/alsa_settings/MTLP_SDW_AIOC.state @@ -21,6 +21,8 @@ state.sofsoundwire { iface MIXER name 'rt711 GE49 Selected Mode' value Headset + # override jack detection mode to headset + # related to https://github.com/thesofproject/linux/pull/4969 } control.36 { iface MIXER