-
Notifications
You must be signed in to change notification settings - Fork 59
alsactl DUT restoration #1270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
alsactl DUT restoration #1270
Changes from all commits
a4cde89
f9f2401
107aeb3
0c76c00
e208838
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ./MTLP_RVP_SDW.state |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| state.sofhdadsp { | ||
| control.1 { | ||
| iface MIXER | ||
| name 'Headphone Playback Volume' | ||
| value.0 60 | ||
| value.1 60 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <MODEL_NAME>.state | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1184,13 +1184,92 @@ 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 ↑ ------------" | ||||||||
golowanow marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| } | ||||||||
|
|
||||||||
| # 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" | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That shouldn't be a problem, right?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will look different to what is in the handcrafted *.state files which are for only one card at the moment.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It will look different, but that specific function is unused in the automatic code and is left as a tool for new
The current code does not touch NOCODEC DUTs. The run No. 53589 contains a NOCODEC platform. |
||||||||
| 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 | ||||||||
| } | ||||||||
|
|
||||||||
| # 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() | ||||||||
| { | ||||||||
| # 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 | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently https://github.com/thesofproject/sof-test/blob/main/test-case/check-alsabat.sh#L87-L96 both have it after I think we should move
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that we even need it this way to reset before applying MODEL.state or MODEL.sh:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion, we should first have a good With that, all ALSA tests should be pretty much guaranteed to have a common, reproducible state. I've previously verified which tests use ALSA - I've used that list in the PR #1279 and I'll be able to reuse it here.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR will already affect two tests, so the changes need to be aligned.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've created a consisted
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
IMO it is essential to execute |
||||||||
| if [ "$E_FLAG" -eq 0 ]; then | ||||||||
| set -e | ||||||||
| fi | ||||||||
|
|
||||||||
| # 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 +1281,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 | ||||||||
|
Comment on lines
+1287
to
+1289
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This statement -
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There's no need to overcomplicate - anyone confused by the commit message can verify that the mentioned switch-case does not have any try-catch mechanism. Additionally, "if able" connects with the previous line's "checks whether a relevant .state file exists".
New .state files are supposed to replace the old .sh files. We should not assume that
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
right, let's remove alss_settings/*.sh files describing the change as
We should consider it is possible for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There hasn't been such a mechanism in the |
||||||||
| "$SCRIPT_HOME"/alsa_settings/"$PNAME".sh | ||||||||
| else | ||||||||
| dlogw "alsa setting for $PNAME is not available" | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How all the *.state files in this PR were obtained ? (context: platform in default state, kernel, version, topology, whatever else what's matter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sof and linux builds were taken from that day's CI relevant run. Then I've run the PR with alsa-info print added in. This gave me the full .state file I could then adjust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I understand the idea behind this PoC proposal, these
*.statefiles are transitional having their content specific to the SOF/Linux components currently deployed on a DUT, thus in most cases they should be explicitly created at some early stage of a test plan execution to keep the appropriate defaults to reset before each test case, where it is important.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks like a great catch, I feel bad I missed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not seem to understand. They necessarily cannot be transitional (temporary in their existence), as they are the definition of the DUT state we want to achieve, just as the previously-used
.shfiles. I would not call the.shfiles transitional as I wouldn't call the.statefiles transitional.I also do not understand had would we create the
.statefiles during testplan execution, given that those files are our source of truth when it comes to out desired state. It would be akin to creating a MAVEN file in Java for every compilation - the benefits would be slim and the process unnecessarily onerous.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, my question is about these *.state files which are included into this PR, and what the 'desired state' they set.
If the basic goal is to reset the state before each test to defaults, then there is no need to keep these files in the sof-test repo as a 'golden source', but call
get_alsactl_state_or_create()once at the test plan beginning right after the DUT deployment stage, and then callrestore_settings_via_alsactl()before each test it needs. Isn't it enough ? Did you try/consider to callalsactl initfor the same purpose ?When there is a need to do some custom/experimental state change, it can be done e.g. by a CI script deploying a .state file here from some other repo/source with the platform-specific BKC, or a state file placed here by some test case script during its test plan execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You wrote in #1270 (comment)
But then in #1270 (comment)
When you write "adjust", do you mean "trimmed down to an incremental change, strictly equivalent to the .sh files removed"?
If that's what you meant then that looks OK to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marc-hb Yes, that's exactly what I do - full
.statefiles can have over 60 controls specified, while we oftentimes need less than 10, we I trim them to just what the.shhad specified.@golowanow The full
.statefile has all the controls and their current values. However, the current.shfiles specify only some controls to some values that can be different from what currently exist on the machine. That's why we do not create them during the runs - we'd be restoring the current machine state rather than restoring the desired machine state.alsactl initis justalsactl restoreon a specific file in a predetermined place. Why obfuscate the files to use rather than keep them in the same repo that uses them? Those aren't multi-gigabyte behemoths to be wary of downloading them unnecessarily.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we expect that after
alsactl initthe DUT's state is wrong and we need some handmade *.state file to set correct defaults ?I think this PR should evolve from its current 'proof-of-concept' to some runnable test case, then it will be easier to see how it solves the problem and ready for merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we have experienced tests failing in our current CI operation and we have never used
alsactl init's files contained by default in/usr/share/alsa/init/to restore the DUT state to our liking, why should we assume thatalsactl initwill bring the DUT to a state we desire? We have no information that would indicate that ALSA's default state is congruent with our desired state. Thusly, we are to use custom.statefiles, as that's the status quo.In my understanding, this repo houses tests for ALSA configurations and tools to that end. Separate tests for the tools inside the
sof-testrepo seem missing and it would be awkward to task this PR specifically with establishing a base for tests ofsof-testitself.