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