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..7eef34ba --- /dev/null +++ b/alsa_settings/LNLM_SDW_AIOC.state @@ -0,0 +1,49 @@ +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 + # override jack detection mode to headset + # related to https://github.com/thesofproject/linux/pull/4969 + } + control.35 { + iface MIXER + name 'Headphone Switch' + value true + } + control.36 { + iface MIXER + name 'Headset Mic Switch' + value true + } +} 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..79701088 --- /dev/null +++ b/alsa_settings/MTLP_SDW_AIOC.state @@ -0,0 +1,40 @@ +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 + # override jack detection mode to headset + # related to https://github.com/thesofproject/linux/pull/4969 + } + 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 + } +} 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 + } +} 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. + diff --git a/case-lib/lib.sh b/case-lib/lib.sh index d2f2f82f..d4f95883 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,13 +1306,17 @@ 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 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