[PATCH 0/4] ASoC: SOF: control: fix volume, switch and enum value handling

From: Arnav Kapoor

Date: Tue Nov 17 2026 - 06:00:06 EST


The ALSA mixer-test selftest fails on the SOF controls of a Lenovo V14
G2 ITL (Tiger Lake, sof-hda-generic-2ch.tplg). The HDA codec controls on
the same card pass. These patches fix what it found, plus one case it
doesn't catch:

1: a negative volume sets the control to its maximum, because
mixer_to_ipc() takes an unsigned int and clamps.
2: a switch accepts and stores values other than 0 and 1.
3: writing back the volume that was just read generates a change
event, because put() compares linear gains while get() reports
table steps, and the 0 dB default is not a table entry.
4: an enum accepts item indexes past its last item (IPC4 topology
only has one, "Dmic0 Capture TDFB angle set enum").

Patches 1, 2 and 4 are in the IPC-independent control.c; patch 3
touches the IPC3 and IPC4 volume_put() ops.

Tested on that laptop (7.0.14 kernel, snd-sof rebuilt with these
patches) with mixer-test:
- IPC3 (sof-tgl.ri, sof-hda-generic-2ch.tplg):
287 pass / 8 fail before, 295 pass / 0 fail after
- IPC4 (sof-ipc4/tgl, sof-ipc4-tplg/sof-hda-generic-2ch.tplg):
287 pass / 12 fail before, 296 pass / 3 fail after
The three remaining IPC4 failures are control names in the topology
(boolean controls named "... switch" instead of "... Switch").

I also wrote out-of-range values to every control with plain alsa-lib
calls (amixer clamps them before they reach the kernel). Before the
series every SOF volume and switch accepted them with IPC3; after it
every SOF volume, switch and enum rejects them with -EINVAL, with both
IPC3 and IPC4. pcm-test results are the same with and without the
patches.

Arnav Kapoor (4):
ASoC: SOF: control: reject out-of-range volume values
ASoC: SOF: control: reject invalid switch values
ASoC: SOF: report volume changes in mixer steps
ASoC: SOF: control: reject out-of-range enum values

sound/soc/sof/control.c | 26 ++++++++++++++++++++++++++
sound/soc/sof/ipc3-control.c | 4 +++-
sound/soc/sof/ipc4-control.c | 4 +++-
3 files changed, 32 insertions(+), 2 deletions(-)


base-commit: 7cd6b1fd8f9c1fcb1da1b761d502649f50b9800f
--
2.53.0