Skip to content

Conversation

@golowanow
Copy link
Member

@golowanow golowanow commented Aug 8, 2025

This PR is to continue with #1284 and PoC #1270


Set ALSA settings from a state file and migrate PTL configurations to the new mechanism:

  1. 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.

  2. 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
  • MTLP_RVP_HDA
  • MTLP_SDW_AIOC
  • MTLP_RVP_SDW
  • 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.

  1. Log difference between the current ALSA state and the restored ALSA state.

  2. Add README.md documentation for the SOF test ALSA settings.

@golowanow golowanow force-pushed the alsa_state_20250807 branch from 780038d to 018d22b Compare August 8, 2025 07:10
@golowanow golowanow added the improvement The issue or pull request improves already existing functionalities label Aug 8, 2025
@golowanow golowanow force-pushed the alsa_state_20250807 branch 2 times, most recently from 2851a8c to ed8ff16 Compare August 11, 2025 18:17
Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No time to review and it's still a draft but this looks very useful!

@golowanow golowanow force-pushed the alsa_state_20250807 branch 2 times, most recently from c7b32b6 to 6ad42fa Compare August 12, 2025 12:21
@golowanow golowanow changed the title [SKIP SOF-TEST] lib.sh: Set ALSA settings from a state file lib.sh: Set ALSA settings from a state file Aug 12, 2025
@golowanow golowanow marked this pull request as ready for review August 12, 2025 12:25
@golowanow golowanow requested review from a team and lgirdwood as code owners August 12, 2025 12:25
@golowanow
Copy link
Member Author

SOFCI TEST

@@ -0,0 +1,35 @@
state.sofsoundwire {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File MTLP_RVP_SDW.sh contain comment's why we set something, we should keep them

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, the ALSA state file format has no custom comments, although alsactl seems to ignore them, if added carefully.
I think better to avoid parsing issues and just rely on the git log history to track changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, comments should be move to README file to preserve info why specific config was set

Copy link
Member Author

@golowanow golowanow Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, comments should be move to README file to preserve info why specific config was set

in README it will be quickly out of sync .. let's try to add it to the .state file directly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good git log is important but it should be focused and explaining why things CHANGED. It should ideally not be required to explain why things ARE the way they are.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, git log should focus on explaining why something was changed. But there are cases where leaving comment in code is also important, for changes that could rise questions in future, or like here proposing whole new approach, comment in file can be quicker to find and understand than digging in git history.

@golowanow golowanow requested a review from majunkier August 12, 2025 17:56
@marc-hb
Copy link
Collaborator

marc-hb commented Aug 13, 2025

For some unknown reason I just remembered that UCM was supposed to be tested interface, not ALSA states...

Quoting internal issue sof-framework 635:

Please stop using asound.state and start using UCM files.
If there are no UCM files let's create them
We have to stop the duplication of work, and asound.state files are EVIL.

:-)

@golowanow
Copy link
Member Author

Please stop using asound.state and start using UCM files.
If there are no UCM files let's create them

@marc-hb, AFAIK this choice (state vs. ucm) has been discussed several months ago, and #1270 PoC was started focusing on the state method. At this point we need to sort out the currently used mechanism first, with its limitations known.
The UCM method needs its attention too as a next step.

@golowanow
Copy link
Member Author

golowanow commented Aug 13, 2025

btw, this PR has been already used to identify issues with misaligned configurations, so its merge will improve test execution on our CI.

@golowanow golowanow force-pushed the alsa_state_20250807 branch from 6ad42fa to 7cc12cc Compare August 13, 2025 09:43
@golowanow
Copy link
Member Author

SOFCI TEST

@golowanow
Copy link
Member Author

@majunkier - do you have any other blocking comments ?

codec and loopback devices.

The `./alsa_settings/` directory contains custom ALSA configurations which
are currently applied at the SOF CI pipeline's hardware platforms.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the default hardware configuration different and not enough? If this is by design (in other words, testing requires some "special sauce"), very briefly state why. If this is not design, clearly state that all these files are really "workarounds".

Either way, it's not good to be testing something different from regular users. So this deserves a bit of justification in either case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, It is a really good question what a 'regular user' can (or should) have as an environment to execute the tests.
I've changed the text a bit, hopefully it becomes more clear why we need these settings here as they currently are.

@golowanow golowanow force-pushed the alsa_state_20250807 branch from 7cc12cc to 4786a83 Compare August 14, 2025 05:58
@golowanow golowanow requested a review from marc-hb August 14, 2025 06:05
if [ -f "${ALSA_SETTINGS_FILE}.sh" ]; then
dlogc "${ALSA_SETTINGS_FILE}.sh"
"${ALSA_SETTINGS_FILE}".sh 2>&1 || rc=$?
[[ "${rc}" -ne 0 ]] && dloge "ALSA settings error=${rc}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should reset rc to zero first, otherwise this .sh message could be triggered by the previous . .state error despite the .sh running fine...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, added

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a simple way to identify which setting is part of which category in each file using using some "standardized" comment convention and/or sections.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, good idea for future clean-up changes there.

LukaszMrugala and others added 5 commits August 19, 2025 06:32
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 <lukaszx.mrugala@intel.com>
Co-authored-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
Log difference between the current ALSA state
and the restored ALSA state.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
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 <dmitrii.golovaniov@intel.com>
Co-authored-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
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 <dmitrii.golovaniov@intel.com>
Co-authored-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
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 <dmitrii.golovaniov@intel.com>
Co-authored-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
Add README.md documentation for SOF test ALSA settings.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
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 <dmitrii.golovanov@intel.com>
@golowanow golowanow force-pushed the alsa_state_20250807 branch from 4786a83 to 8f201d1 Compare August 19, 2025 04:38
@golowanow golowanow requested a review from marc-hb August 19, 2025 04:41
@golowanow
Copy link
Member Author

check-alsabat- test cases are passed on all CI configurations

Copy link
Collaborator

@SzymonRichert SzymonRichert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lgirdwood lgirdwood merged commit b5e7bc2 into thesofproject:main Aug 19, 2025
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement The issue or pull request improves already existing functionalities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants