From a4cde890b66fd247f1c6cc67c820a93ac52b1a56 Mon Sep 17 00:00:00 2001 From: Lukasz Mrugala Date: Thu, 8 May 2025 14:15:01 +0000 Subject: [PATCH 1/5] alsactl: Implementation for LNL, MTL, PTL set_alsa_settings function now shall use the alsactl restore command, which allows for ALSA control restoration based on a configuration file, rather than a bash script. New .state files are equivalent to the old .sh files. Incorporates LNL, MTL and PTL families, save for the nocodecs. Previously-used switch-case statement checks whether a relevant .state file exists, based on the $MODEL variable and uses it if it exists. If not, it uses the previous method as a fallback. Before the aforementioned switch-case, alsactl init is called, so that a common starting point, specific for each machine is achieved. Automatically generated comments inside of the .state files removed for readability. Signed-off-by: Lukasz Mrugala --- alsa_settings/LNLM_RVP_HDA.sh | 11 ----- alsa_settings/LNLM_SDW_AIOC.sh | 16 ------ alsa_settings/MTLP_RVP_HDA.sh | 11 ----- alsa_settings/MTLP_RVP_SDW.sh | 17 ------- alsa_settings/MTLP_SDW_AIOC.sh | 1 - alsa_settings/PTLH_HDA_AIOC.sh | 12 ----- alsa_settings/PTLH_SDW_RT712.sh | 10 ---- alsa_settings/PTLP_RVP_SDW.sh | 16 ------ alsa_settings/alsactl/LNLM_RVP_HDA.state | 19 ++++++++ alsa_settings/alsactl/LNLM_SDW_AIOC.state | 14 ++++++ alsa_settings/alsactl/MTLP_RVP_HDA.state | 19 ++++++++ alsa_settings/alsactl/MTLP_RVP_SDW.state | 14 ++++++ alsa_settings/alsactl/MTLP_SDW_AIOC.state | 1 + alsa_settings/alsactl/PTLH_HDA_AIOC.state | 8 +++ alsa_settings/alsactl/PTLH_SDW_RT712.state | 36 ++++++++++++++ alsa_settings/alsactl/PTLP_RVP_SDW.state | 14 ++++++ alsa_settings/alsactl/README.md | 7 +++ case-lib/lib.sh | 57 +++++++++++++++++++++- 18 files changed, 187 insertions(+), 96 deletions(-) delete mode 100755 alsa_settings/LNLM_RVP_HDA.sh delete mode 100755 alsa_settings/LNLM_SDW_AIOC.sh delete mode 100755 alsa_settings/MTLP_RVP_HDA.sh delete mode 100755 alsa_settings/MTLP_RVP_SDW.sh delete mode 120000 alsa_settings/MTLP_SDW_AIOC.sh delete mode 100755 alsa_settings/PTLH_HDA_AIOC.sh delete mode 100755 alsa_settings/PTLH_SDW_RT712.sh delete mode 100755 alsa_settings/PTLP_RVP_SDW.sh create mode 100644 alsa_settings/alsactl/LNLM_RVP_HDA.state create mode 100644 alsa_settings/alsactl/LNLM_SDW_AIOC.state create mode 100644 alsa_settings/alsactl/MTLP_RVP_HDA.state create mode 100644 alsa_settings/alsactl/MTLP_RVP_SDW.state create mode 120000 alsa_settings/alsactl/MTLP_SDW_AIOC.state create mode 100644 alsa_settings/alsactl/PTLH_HDA_AIOC.state create mode 100644 alsa_settings/alsactl/PTLH_SDW_RT712.state create mode 100644 alsa_settings/alsactl/PTLP_RVP_SDW.state create mode 100644 alsa_settings/alsactl/README.md 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_SDW_AIOC.sh b/alsa_settings/LNLM_SDW_AIOC.sh deleted file mode 100755 index 108e400e..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' 30 -amixer -c sofsoundwire cset name='rt711 FU1E Capture Volume' 30 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_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_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/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_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/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/alsactl/LNLM_RVP_HDA.state b/alsa_settings/alsactl/LNLM_RVP_HDA.state new file mode 100644 index 00000000..90df83e4 --- /dev/null +++ b/alsa_settings/alsactl/LNLM_RVP_HDA.state @@ -0,0 +1,19 @@ +state.sofhdadsp { + control.1 { + iface MIXER + name 'Headphone Playback Volume' + value.0 60 + value.1 60 + } + control.6 { + iface MIXER + name 'Capture Volume' + value.0 30 + value.1 30 + } + control.9 { + iface MIXER + name 'Master Playback Volume' + value 87 + } +} \ No newline at end of file diff --git a/alsa_settings/alsactl/LNLM_SDW_AIOC.state b/alsa_settings/alsactl/LNLM_SDW_AIOC.state new file mode 100644 index 00000000..4fff8024 --- /dev/null +++ b/alsa_settings/alsactl/LNLM_SDW_AIOC.state @@ -0,0 +1,14 @@ +state.sofsoundwire { + control.1 { + iface MIXER + name 'rt711 FU05 Playback Volume' + value.0 80 + value.1 80 + } + control.5 { + iface MIXER + name 'rt711 FU0F Capture Volume' + value.0 30 + value.1 30 + } +} \ No newline at end of file diff --git a/alsa_settings/alsactl/MTLP_RVP_HDA.state b/alsa_settings/alsactl/MTLP_RVP_HDA.state new file mode 100644 index 00000000..90df83e4 --- /dev/null +++ b/alsa_settings/alsactl/MTLP_RVP_HDA.state @@ -0,0 +1,19 @@ +state.sofhdadsp { + control.1 { + iface MIXER + name 'Headphone Playback Volume' + value.0 60 + value.1 60 + } + control.6 { + iface MIXER + name 'Capture Volume' + value.0 30 + value.1 30 + } + control.9 { + iface MIXER + name 'Master Playback Volume' + value 87 + } +} \ No newline at end of file diff --git a/alsa_settings/alsactl/MTLP_RVP_SDW.state b/alsa_settings/alsactl/MTLP_RVP_SDW.state new file mode 100644 index 00000000..4fff8024 --- /dev/null +++ b/alsa_settings/alsactl/MTLP_RVP_SDW.state @@ -0,0 +1,14 @@ +state.sofsoundwire { + control.1 { + iface MIXER + name 'rt711 FU05 Playback Volume' + value.0 80 + value.1 80 + } + control.5 { + iface MIXER + name 'rt711 FU0F Capture Volume' + value.0 30 + value.1 30 + } +} \ No newline at end of file diff --git a/alsa_settings/alsactl/MTLP_SDW_AIOC.state b/alsa_settings/alsactl/MTLP_SDW_AIOC.state new file mode 120000 index 00000000..f10c7738 --- /dev/null +++ b/alsa_settings/alsactl/MTLP_SDW_AIOC.state @@ -0,0 +1 @@ +./MTLP_RVP_SDW.state \ No newline at end of file diff --git a/alsa_settings/alsactl/PTLH_HDA_AIOC.state b/alsa_settings/alsactl/PTLH_HDA_AIOC.state new file mode 100644 index 00000000..54cc9bb3 --- /dev/null +++ b/alsa_settings/alsactl/PTLH_HDA_AIOC.state @@ -0,0 +1,8 @@ +state.sofhdadsp { + control.1 { + iface MIXER + name 'Headphone Playback Volume' + value.0 60 + value.1 60 + } +} diff --git a/alsa_settings/alsactl/PTLH_SDW_RT712.state b/alsa_settings/alsactl/PTLH_SDW_RT712.state new file mode 100644 index 00000000..b8388a6a --- /dev/null +++ b/alsa_settings/alsactl/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 on + value.1 on + } + control.4 { + iface MIXER + name 'rt712 FU0F Capture Volume' + value.0 46 + value.1 46 + } + control.14 { + iface MIXER + name 'Headphone Switch' + value.0 on + } + control.15 { + iface MIXER + name 'Headset Mic Switch' + value.0 on + } +} diff --git a/alsa_settings/alsactl/PTLP_RVP_SDW.state b/alsa_settings/alsactl/PTLP_RVP_SDW.state new file mode 100644 index 00000000..bfe562be --- /dev/null +++ b/alsa_settings/alsactl/PTLP_RVP_SDW.state @@ -0,0 +1,14 @@ +state.sofsoundwire { + 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 + } +} diff --git a/alsa_settings/alsactl/README.md b/alsa_settings/alsactl/README.md new file mode 100644 index 00000000..6a95dd74 --- /dev/null +++ b/alsa_settings/alsactl/README.md @@ -0,0 +1,7 @@ +# Creating a .state file + +1. Gain access to a machine you'd like to create a state file for. +2. Run `alsa-info` or use the print_alsa_info from the lib.sh file. +3. Copy the `!!Alsactl output` part of the `alsa-info` file to your `.state` file. +4. Modify values you'd like to set at a specific amount and delete the rest. +5. Name the file .state diff --git a/case-lib/lib.sh b/case-lib/lib.sh index d60b9ca9..13a551dc 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -1184,13 +1184,64 @@ re_enable_ntp_sync() sudo timedatectl set-ntp true } +# Get alsa-info of DUTs in CI +print_alsa_info() +{ + dlogi "----------- ↓ alsa-info ↓ ------------" + alsa-info --stdout --with-aplay --with-amixer --with-alsactl --with-configs --no-upload + dlogi "----------- ↑ alsa-info ↑ ------------" +} + +# Check whether a relevant .state file exists +# If not, save current state for future use +# param1: script home path +# param2: platform name +get_alsactl_state_or_create() +{ + ALSACTL_STATE_FILE_PATH="$1"/alsa_settings/alsactl/"$2".state + # .state file does not exist. Creating one from current setup. + if [ ! -f "$ALSACTL_STATE_FILE_PATH" ]; then + alsactl store --file="$ALSACTL_STATE_FILE_PATH" + fi + echo "$ALSACTL_STATE_FILE_PATH" +} + +# Check whether a relevant .state file exists +# and return its file path +# param1: script home path +# param2: platform name +get_alsactl_state() +{ + ALSACTL_STATE_FILE_PATH="$1"/alsa_settings/alsactl/"$2".state + # .state file does not exist. + if [ ! -f "$ALSACTL_STATE_FILE_PATH" ]; then + return 1; + fi + echo "$ALSACTL_STATE_FILE_PATH" +} + +# Use `alsactl restore` to restore the alsa settings. +# param1: platform name +restore_settings_via_alsactl() +{ + dlogi "Using experimental ALSACTL method" + + ALSACTL_STATE_FILE_PATH=$(get_alsactl_state "$SCRIPT_HOME" "$1") + + alsactl restore --file="$ALSACTL_STATE_FILE_PATH" --pedantic --no-init-fallback --no-ucm +} + # check-alsabat.sh need to run optimum alsa control settings # param1: platform name set_alsa_settings() { + # This will bring the machine ALSA state to a common known point - a good baseline + alsactl init + # ZEPHYR platform shares same tplg, remove '_ZEPHYR' from platform name local PNAME="${1%_ZEPHYR}" dlogi "Run alsa setting for $PNAME" + # Apply configuration on top of the default init 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 @@ -1202,10 +1253,12 @@ 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 + if get_alsactl_state "$SCRIPT_HOME" "$PNAME"; then + restore_settings_via_alsactl "$PNAME" + elif [ -f "$SCRIPT_HOME"/alsa_settings/"$PNAME".sh ]; then "$SCRIPT_HOME"/alsa_settings/"$PNAME".sh else dlogw "alsa setting for $PNAME is not available" From f9f24013668de12d7c115c17191aa0e79bdccdb2 Mon Sep 17 00:00:00 2001 From: Lukasz Mrugala Date: Fri, 4 Jul 2025 08:38:03 +0000 Subject: [PATCH 2/5] log: Add dlogi at set_alsa_settings start Addition of alsactl init made it appear before the initial dlogi call, so we add one before it. Signed-off-by: Lukasz Mrugala --- case-lib/lib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 13a551dc..df46c249 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -1236,6 +1236,7 @@ restore_settings_via_alsactl() set_alsa_settings() { # This will bring the machine ALSA state to a common known point - a good baseline + dlogi "Initialising ALSA configuration for $PNAME with alsactl" alsactl init # ZEPHYR platform shares same tplg, remove '_ZEPHYR' from platform name From 107aeb3ccb407ece8fd49c9ef7038fd844aa7411 Mon Sep 17 00:00:00 2001 From: Lukasz Mrugala Date: Fri, 4 Jul 2025 08:53:53 +0000 Subject: [PATCH 3/5] alsa: Add common setup_alsa in ALSA tests All tests using ALSA now use a common setup function, setup_alsa, which checks locale, resets volume to 0dB, verifies whether $MODEL has been set and runs set_alsa_settings. Signed-off-by: Lukasz Mrugala --- case-lib/lib.sh | 18 ++++++++++++++++++ test-case/check-alsabat.sh | 14 +------------- test-case/check-audio-equalizer.sh | 1 + test-case/check-capture.sh | 1 + test-case/check-fw-echo-reference.sh | 2 +- test-case/check-keyword-detection.sh | 2 ++ .../check-kmod-load-unload-after-playback.sh | 2 ++ test-case/check-kmod-load-unload.sh | 2 ++ .../check-pause-release-suspend-resume.sh | 2 ++ test-case/check-pause-resume.sh | 2 ++ test-case/check-performance.sh | 1 + test-case/check-playback.sh | 3 +++ test-case/check-runtime-pm-double-active.sh | 3 +++ test-case/check-runtime-pm-status.sh | 3 +++ test-case/check-signal-stop-start.sh | 2 ++ test-case/check-smart-amplifier.sh | 2 ++ test-case/check-sof-logger.sh | 3 ++- test-case/check-suspend-resume-with-audio.sh | 2 ++ test-case/check-suspend-resume.sh | 2 ++ test-case/check-userspace-cardinfo.sh | 2 ++ test-case/check-userspace-paplay.sh | 2 ++ test-case/check-userspace-parecord.sh | 2 ++ test-case/check-volume-levels.sh | 2 ++ test-case/check-xrun-injection.sh | 2 ++ test-case/latency-metrics.sh | 14 +------------- test-case/multiple-pipeline.sh | 2 ++ test-case/simultaneous-playback-capture.sh | 2 ++ test-case/test-speaker.sh | 2 ++ test-case/verify-bootsequence.sh | 2 ++ test-case/verify-pcm-list.sh | 2 ++ test-case/verify-sof-firmware-load.sh | 2 ++ test-case/verify-ucm-config.sh | 2 ++ test-case/volume-basic-test.sh | 2 ++ 33 files changed, 79 insertions(+), 28 deletions(-) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index df46c249..060f672d 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -1231,6 +1231,24 @@ restore_settings_via_alsactl() alsactl restore --file="$ALSACTL_STATE_FILE_PATH" --pedantic --no-init-fallback --no-ucm } +# One-stop shop to initialise alsa-related stuff for tests using it. +setup_alsa() +{ + check_locale_for_alsabat + + # reset sof volume to 0dB + reset_sof_volume + + # If MODEL is defined, set proper gain for the platform + if [ -z "$MODEL" ]; then + # treat as warning only + dlogw "NO MODEL is defined. Please define MODEL to run MODEL-based settings configuration" + else + #dlogi "apply alsa settings for alsa_settings/MODEL.sh" + set_alsa_settings "$MODEL" + fi +} + # check-alsabat.sh need to run optimum alsa control settings # param1: platform name set_alsa_settings() diff --git a/test-case/check-alsabat.sh b/test-case/check-alsabat.sh index 9aadb863..b988d727 100755 --- a/test-case/check-alsabat.sh +++ b/test-case/check-alsabat.sh @@ -81,19 +81,7 @@ then exit 2 fi -check_locale_for_alsabat - -# reset sof volume to 0dB -reset_sof_volume - -# If MODEL is defined, set proper gain for the platform -if [ -z "$MODEL" ]; then - # treat as warning only - dlogw "NO MODEL is defined. Please define MODEL to run alsa_settings/MODEL.sh" -else - #dlogi "apply alsa settings for alsa_settings/MODEL.sh" - set_alsa_settings "$MODEL" -fi +setup_alsa logger_disabled || func_lib_start_log_collect diff --git a/test-case/check-audio-equalizer.sh b/test-case/check-audio-equalizer.sh index 1b4a4ad3..2866ba60 100755 --- a/test-case/check-audio-equalizer.sh +++ b/test-case/check-audio-equalizer.sh @@ -44,6 +44,7 @@ sofcard=${SOFCARD:-0} start_test setup_kernel_check_point +setup_alsa # Test equalizer func_test_eq() diff --git a/test-case/check-capture.sh b/test-case/check-capture.sh index 444e5d4c..3a96ba62 100755 --- a/test-case/check-capture.sh +++ b/test-case/check-capture.sh @@ -61,6 +61,7 @@ start_test logger_disabled || func_lib_start_log_collect setup_kernel_check_point +setup_alsa func_lib_check_sudo func_pipeline_export "$tplg" "type:capture & ${OPT_VAL['S']}" diff --git a/test-case/check-fw-echo-reference.sh b/test-case/check-fw-echo-reference.sh index 1e8ace9f..2a0b899c 100755 --- a/test-case/check-fw-echo-reference.sh +++ b/test-case/check-fw-echo-reference.sh @@ -50,7 +50,7 @@ if [ "$PIPELINE_COUNT" != "2" ]; then die "Only detect $PIPELINE_COUNT pipeline(s) from topology, but two are needed" fi -check_locale_for_alsabat +setup_alsa for idx in $(seq 0 $((PIPELINE_COUNT - 1))) do diff --git a/test-case/check-keyword-detection.sh b/test-case/check-keyword-detection.sh index ebcad8fd..532994f0 100755 --- a/test-case/check-keyword-detection.sh +++ b/test-case/check-keyword-detection.sh @@ -56,6 +56,8 @@ duration=${OPT_VAL['d']} start_test logger_disabled || func_lib_start_log_collect +setup_alsa + func_pipeline_export "$tplg" "kpb:any" if test "$PIPELINE_COUNT" != "1"; then diff --git a/test-case/check-kmod-load-unload-after-playback.sh b/test-case/check-kmod-load-unload-after-playback.sh index e7aa542b..05ce46a7 100755 --- a/test-case/check-kmod-load-unload-after-playback.sh +++ b/test-case/check-kmod-load-unload-after-playback.sh @@ -56,6 +56,8 @@ pb_duration=${OPT_VAL['d']} start_test +setup_alsa + func_pipeline_export "$tplg" "type:playback" func_lib_check_sudo diff --git a/test-case/check-kmod-load-unload.sh b/test-case/check-kmod-load-unload.sh index 9e51729a..51d479f6 100755 --- a/test-case/check-kmod-load-unload.sh +++ b/test-case/check-kmod-load-unload.sh @@ -40,6 +40,8 @@ setup_kernel_check_point start_test +setup_alsa + loop_cnt=${OPT_VAL['l']} PATH="${PATH%%:*}/kmod:$PATH" diff --git a/test-case/check-pause-release-suspend-resume.sh b/test-case/check-pause-release-suspend-resume.sh index db2c804d..c5f5363a 100755 --- a/test-case/check-pause-release-suspend-resume.sh +++ b/test-case/check-pause-release-suspend-resume.sh @@ -117,6 +117,8 @@ logger_disabled || func_lib_start_log_collect setup_kernel_check_point +setup_alsa + dlogi "Entering audio stream expect script with: $cmd -D $pcm -r $rate -c $channel -f $fmt -vv -i $dummy_file -q" dlogi "Will enter suspend-resume cycle during paused period of audio stream process" diff --git a/test-case/check-pause-resume.sh b/test-case/check-pause-resume.sh index 17c49ffc..9a41f381 100755 --- a/test-case/check-pause-resume.sh +++ b/test-case/check-pause-resume.sh @@ -80,6 +80,8 @@ esac logger_disabled || func_lib_start_log_collect +setup_alsa + [[ -z $file_name ]] && file_name=$dummy_file func_pipeline_export "$tplg" "type:$test_mode & ${OPT_VAL['S']}" diff --git a/test-case/check-performance.sh b/test-case/check-performance.sh index 2b0eecfc..4e745ae6 100755 --- a/test-case/check-performance.sh +++ b/test-case/check-performance.sh @@ -45,6 +45,7 @@ start_test logger_disabled || func_lib_start_log_collect setup_kernel_check_point +setup_alsa func_lib_check_sudo func_pipeline_export "$tplg" "type:any" diff --git a/test-case/check-playback.sh b/test-case/check-playback.sh index 0958647b..239f699b 100755 --- a/test-case/check-playback.sh +++ b/test-case/check-playback.sh @@ -68,6 +68,9 @@ else fi setup_kernel_check_point + +setup_alsa + func_lib_check_sudo func_pipeline_export "$tplg" "type:playback & ${OPT_VAL['S']}" diff --git a/test-case/check-runtime-pm-double-active.sh b/test-case/check-runtime-pm-double-active.sh index 51b99b86..f72f7996 100755 --- a/test-case/check-runtime-pm-double-active.sh +++ b/test-case/check-runtime-pm-double-active.sh @@ -73,6 +73,9 @@ APP_LST['capture']='arecord' DEV_LST['capture']='/dev/null' logger_disabled || func_lib_start_log_collect + +setup_alsa + func_pipeline_export "$tplg" "type:any" for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) diff --git a/test-case/check-runtime-pm-status.sh b/test-case/check-runtime-pm-status.sh index f9b83fa4..2101c94c 100755 --- a/test-case/check-runtime-pm-status.sh +++ b/test-case/check-runtime-pm-status.sh @@ -69,6 +69,9 @@ APP_LST['capture']='arecord' DEV_LST['capture']='/dev/null' logger_disabled || func_lib_start_log_collect + +setup_alsa + func_pipeline_export "$tplg" "type:any" for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) diff --git a/test-case/check-signal-stop-start.sh b/test-case/check-signal-stop-start.sh index 0aa79fb0..778255e4 100755 --- a/test-case/check-signal-stop-start.sh +++ b/test-case/check-signal-stop-start.sh @@ -62,6 +62,8 @@ esac setup_kernel_check_point +setup_alsa + func_stop_start_pipeline() { local i=1 diff --git a/test-case/check-smart-amplifier.sh b/test-case/check-smart-amplifier.sh index 41a9b345..760d4910 100755 --- a/test-case/check-smart-amplifier.sh +++ b/test-case/check-smart-amplifier.sh @@ -59,6 +59,8 @@ tplg=${OPT_VAL['t']} start_test logger_disabled || func_lib_start_log_collect +setup_alsa + func_pipeline_export "$tplg" "smart_amp:any" setup_kernel_check_point diff --git a/test-case/check-sof-logger.sh b/test-case/check-sof-logger.sh index 23c9a5d5..5d8ba048 100755 --- a/test-case/check-sof-logger.sh +++ b/test-case/check-sof-logger.sh @@ -33,6 +33,7 @@ start_test type -a sof-logger || die "sof-logger Not Installed!" +setup_alsa # Checksum a list of files, one filename per stdin line. # Whitespace-safe and shellcheck-approved. @@ -72,7 +73,7 @@ sof_alsa_card_found() # - /proc/asound/sofsoundwire/id # - /proc/asound/sofhdadsp/id # - https://github.com/thesofproject/sof-test/issues/1243 - # Designed to support multiple SOF instances with SOF probes + # Designed to support multiple SOF instances with SOF probes for i in /proc/asound/sof*/id; do if test -e "$i"; then return 0; fi done diff --git a/test-case/check-suspend-resume-with-audio.sh b/test-case/check-suspend-resume-with-audio.sh index 40397a54..10a52a4a 100755 --- a/test-case/check-suspend-resume-with-audio.sh +++ b/test-case/check-suspend-resume-with-audio.sh @@ -65,6 +65,8 @@ tplg=${OPT_VAL['t']} start_test logger_disabled || func_lib_start_log_collect +setup_alsa + # overwrite the subscript: test-case LOG_ROOT environment # so when load the test-case in current script # the test-case will write the log to the store folder LOG_ROOT diff --git a/test-case/check-suspend-resume.sh b/test-case/check-suspend-resume.sh index a1f59764..d4b2e7e2 100755 --- a/test-case/check-suspend-resume.sh +++ b/test-case/check-suspend-resume.sh @@ -53,6 +53,8 @@ func_lib_check_sudo start_test +setup_alsa + type=${OPT_VAL['T']} # switch type if [ "$type" ]; then diff --git a/test-case/check-userspace-cardinfo.sh b/test-case/check-userspace-cardinfo.sh index 1a1c36c8..6e2c232d 100755 --- a/test-case/check-userspace-cardinfo.sh +++ b/test-case/check-userspace-cardinfo.sh @@ -24,6 +24,8 @@ setup_kernel_check_point start_test +setup_alsa + # check pulseaudio runs properly or not func_lib_check_pa || die "Please check whether pulseaudio runs correctly or not" diff --git a/test-case/check-userspace-paplay.sh b/test-case/check-userspace-paplay.sh index 4bfc158f..7b77ee90 100755 --- a/test-case/check-userspace-paplay.sh +++ b/test-case/check-userspace-paplay.sh @@ -46,6 +46,8 @@ setup_kernel_check_point start_test +setup_alsa + round_cnt=${OPT_VAL['r']} duration=${OPT_VAL['d']} file=${OPT_VAL['f']} diff --git a/test-case/check-userspace-parecord.sh b/test-case/check-userspace-parecord.sh index 2b660a49..63171b8f 100755 --- a/test-case/check-userspace-parecord.sh +++ b/test-case/check-userspace-parecord.sh @@ -53,6 +53,8 @@ channel=${OPT_VAL['C']} start_test +setup_alsa + [[ -e $file ]] || { dlogw "$file does not exist, use /dev/zero as dummy playback source" && file=/dev/null; } # TODO: check the parameter is valid or not diff --git a/test-case/check-volume-levels.sh b/test-case/check-volume-levels.sh index b421dff1..fcb9239d 100755 --- a/test-case/check-volume-levels.sh +++ b/test-case/check-volume-levels.sh @@ -289,6 +289,8 @@ do_preparations () { dlogi "Capture device is $CAP_HW" dlogi "Capture PGA is $CAP_PGA" + setup_alsa + # Find amixer controls for capture, error if more than one PGA numpga=${#CAP_PGA[@]} test "$numpga" = 1 || die "Error: more than one capture PGA found." diff --git a/test-case/check-xrun-injection.sh b/test-case/check-xrun-injection.sh index 30a2b045..98fe3e8b 100755 --- a/test-case/check-xrun-injection.sh +++ b/test-case/check-xrun-injection.sh @@ -45,6 +45,8 @@ interval=${OPT_VAL['i']} start_test logger_disabled || func_lib_start_log_collect +setup_alsa + setup_kernel_check_point func_lib_check_sudo diff --git a/test-case/latency-metrics.sh b/test-case/latency-metrics.sh index c8c6bd0c..ca7de5e6 100755 --- a/test-case/latency-metrics.sh +++ b/test-case/latency-metrics.sh @@ -142,18 +142,6 @@ check_latency_options() fi } -set_alsa() -{ - reset_sof_volume - - # 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" - else - set_alsa_settings "$MODEL" - fi -} - # set/update commands in case the test iterates or sweep over a range compose_commands() { @@ -280,7 +268,7 @@ main() logger_disabled || func_lib_start_log_collect - set_alsa + setup_alsa check_jackd_configured diff --git a/test-case/multiple-pipeline.sh b/test-case/multiple-pipeline.sh index b7dd22d0..bf5d603b 100755 --- a/test-case/multiple-pipeline.sh +++ b/test-case/multiple-pipeline.sh @@ -63,6 +63,8 @@ f_arg=${OPT_VAL['f']} start_test logger_disabled || func_lib_start_log_collect +setup_alsa + # skip the Echo Reference pipeline MULTI_PIPELINE_FILTER='~pcm:Amplifier Reference' max_count=0 diff --git a/test-case/simultaneous-playback-capture.sh b/test-case/simultaneous-playback-capture.sh index d1e3189f..bad090df 100755 --- a/test-case/simultaneous-playback-capture.sh +++ b/test-case/simultaneous-playback-capture.sh @@ -42,6 +42,8 @@ loop_cnt=${OPT_VAL['l']} start_test +setup_alsa + # get 'both' pcm, it means pcm have same id with different type declare -A tmp_id_lst id_lst_str="" diff --git a/test-case/test-speaker.sh b/test-case/test-speaker.sh index 6e0df8ab..f5f8d342 100755 --- a/test-case/test-speaker.sh +++ b/test-case/test-speaker.sh @@ -34,6 +34,8 @@ tplg=${OPT_VAL['t']} start_test logger_disabled || func_lib_start_log_collect +setup_alsa + func_pipeline_export "$tplg" "type:playback" tcnt=${OPT_VAL['l']} setup_kernel_check_point diff --git a/test-case/verify-bootsequence.sh b/test-case/verify-bootsequence.sh index 5fd77b3d..fc8e2c04 100755 --- a/test-case/verify-bootsequence.sh +++ b/test-case/verify-bootsequence.sh @@ -34,6 +34,8 @@ setup_kernel_check_point start_test +setup_alsa + main() { local tmp diff --git a/test-case/verify-pcm-list.sh b/test-case/verify-pcm-list.sh index 88abb8d4..4c438220 100755 --- a/test-case/verify-pcm-list.sh +++ b/test-case/verify-pcm-list.sh @@ -28,6 +28,8 @@ tplg=${OPT_VAL['t']} start_test +setup_alsa + tplg_path=$(func_lib_get_tplg_path "$tplg") || die "No available topology for this test case" diff --git a/test-case/verify-sof-firmware-load.sh b/test-case/verify-sof-firmware-load.sh index d6866a44..cf26257b 100755 --- a/test-case/verify-sof-firmware-load.sh +++ b/test-case/verify-sof-firmware-load.sh @@ -23,6 +23,8 @@ disable_kernel_check_point start_test +setup_alsa + cmd="journalctl_cmd" dlogi "Checking SOF Firmware load info in kernel log" diff --git a/test-case/verify-ucm-config.sh b/test-case/verify-ucm-config.sh index 1d7e7f09..b7bd4c24 100755 --- a/test-case/verify-ucm-config.sh +++ b/test-case/verify-ucm-config.sh @@ -29,6 +29,8 @@ setup_kernel_check_point start_test +setup_alsa + declare -A verb_array # get the cards all verbs. The verbs are the items of SectionUseCase in diff --git a/test-case/volume-basic-test.sh b/test-case/volume-basic-test.sh index b1ed73aa..453a337b 100755 --- a/test-case/volume-basic-test.sh +++ b/test-case/volume-basic-test.sh @@ -39,6 +39,8 @@ maxloop=${OPT_VAL['l']} start_test +setup_alsa + [[ -z $tplg ]] && die "Missing tplg file needed to run" func_pipeline_export "$tplg" "type:playback" logger_disabled || func_lib_start_log_collect From 0c76c008eba3cb391164a5092a2ac27cc334576f Mon Sep 17 00:00:00 2001 From: Lukasz Mrugala Date: Fri, 11 Jul 2025 09:46:48 +0000 Subject: [PATCH 4/5] alsa: remove crash on init If alsactl init does not recognise the device, it will return error code 99 and bring down the whole test. We do not care for unrecognised devices and will ignore it instead. Signed-off-by: Lukasz Mrugala --- case-lib/lib.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 060f672d..a634d518 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -1255,7 +1255,16 @@ set_alsa_settings() { # This will bring the machine ALSA state to a common known point - a good baseline dlogi "Initialising ALSA configuration for $PNAME with alsactl" + + # If alsactl init does not recognise the device, it will return error code 99 and bring down the whole test. + # We do not care for unrecognised devices and will ignore it instead. + E_FLAG=0 + [[ "$-" == *e* ]] || E_FLAG=$? + set +e alsactl init + if [ "$E_FLAG" -eq 0 ] then + set -e + fi # ZEPHYR platform shares same tplg, remove '_ZEPHYR' from platform name local PNAME="${1%_ZEPHYR}" From e20883869de8577def1769ab783ad32740c2515b Mon Sep 17 00:00:00 2001 From: Lukasz Mrugala Date: Fri, 11 Jul 2025 09:59:03 +0000 Subject: [PATCH 5/5] Fix typo Signed-off-by: Lukasz Mrugala --- case-lib/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index a634d518..d0b40029 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -1262,7 +1262,7 @@ set_alsa_settings() [[ "$-" == *e* ]] || E_FLAG=$? set +e alsactl init - if [ "$E_FLAG" -eq 0 ] then + if [ "$E_FLAG" -eq 0 ]; then set -e fi