|
| 1 | +# ALSA settings |
| 2 | + |
| 3 | +SOF test case execution requires certain DSP and mixer configurations being set |
| 4 | +on the DUT (Device Under Test). An important part of this configuration is the |
| 5 | +signal levels adjusted to the hardware setup which runs the tests, including its |
| 6 | +codec and loopback devices. |
| 7 | + |
| 8 | +The `./alsa_settings/` directory contains custom ALSA configurations which |
| 9 | +are currently applied at the SOF CI pipeline's hardware platforms. |
| 10 | + |
| 11 | + |
| 12 | +## How it works |
| 13 | + |
| 14 | +When a test case calls `set_alsa()` function, its task is to apply the DUT's |
| 15 | +default ALSA configuration file as the baseline to ensure the expected ALSA |
| 16 | +settings are active the same way as after the DUT's reboot, so to avoid |
| 17 | +after-effects possible from the previous test's execution - either it was |
| 18 | +success, or failure, or any other unexpected change due to the DUT's power |
| 19 | +reset, the test case error, manual re-configuration, etc. |
| 20 | + |
| 21 | +After `alsactl init` and `alsa restore` calls by `set_alsa()` function, |
| 22 | +two optional custom settings are applied in the following order (assuming |
| 23 | +the DUT belongs to a `PLATFORM` hardware configuration, and the configuration |
| 24 | +files are in `./alsa_settings/` directory): |
| 25 | + |
| 26 | + 1. `PLATFORM.state` - an ALSA driver state file in `alsactl` format. |
| 27 | + |
| 28 | + 2. `PLATFROM.sh` - a shell script to configure the ALSA driver parameters, |
| 29 | + e.g. calling `amixer` tool. |
| 30 | + |
| 31 | +The custom state should be compatible with the platform's default state. |
| 32 | + |
| 33 | +Currently, the custom settings include all these default ALSA settings the SOF |
| 34 | +tests are expecting at the appropriate DUT. |
| 35 | +In the future most of them should be moved to the DUT's default config |
| 36 | +out of the test case scope, so only the test-specific settings will remain here. |
| 37 | + |
| 38 | +It is important to avoid linking configuration files to 'reuse' them for |
| 39 | +different HW configurations: the `.state` files have platform specific control |
| 40 | +id's, whereas `amixer` refers to the sound card control by its name. |
| 41 | + |
| 42 | +For some platforms their USB audio card settings are also included in |
| 43 | +the configuration files: it is needed to adjust loopback volume levels on the DUT. |
| 44 | + |
| 45 | + |
| 46 | +## DUT host configuration |
| 47 | + |
| 48 | +The DUT host should NOT run `alsa-state.service`. |
| 49 | + |
| 50 | +The `alsa-restore.service` shoudl work only in 'restore' mode (on start) - |
| 51 | +the 'store' mode (on shutdown) should be OFF to keep the default ALSA driver |
| 52 | +settings not changed. |
| 53 | + |
| 54 | +It is NOT allowed to change the DUT's default state with `alsactl store` unless |
| 55 | +it is a special part of the test case, or a DUT recovery procedure. |
| 56 | + |
| 57 | +For more details see [ALSA and systemd](https://wiki.archlinux.org/title/Advanced_Linux_Sound_Architecture#ALSA_and_systemd) |
| 58 | + |
| 59 | + |
| 60 | +## How to create a custom .state file |
| 61 | + |
| 62 | +1. Check contents of the DUT's default ALSA driver configuration `asound.state`. |
| 63 | + Usually, it is in `/var/lib/alsa/`, and under control of `alsa-restore.service`, |
| 64 | + or `alsa-state.service`. Make sure you have a backup copy of this file: |
| 65 | + the ALSA `.service`-s are in charge of keeping your current custom ALSA settings |
| 66 | + as the DUT's default, so it might unexpectedly affect your DUT normal operations, |
| 67 | + unless it is your goal. |
| 68 | + |
| 69 | +2. Copy the controls you need to change with the new values into the appropriate |
| 70 | + platform's `PLATFORM.state` file in `./alsa_settings/`, or create a shell script |
| 71 | + `PLATFORM.sh` there with the appropriate `amixer` calls. |
| 72 | + Both these methods can be applied simultaneously. |
| 73 | + |
0 commit comments