mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] ASoC: SOF: control: fix volume, switch and enum value handling
@ 2026-11-17 10:59 Arnav Kapoor
  2026-11-17 10:59 ` [PATCH 1/4] ASoC: SOF: control: reject out-of-range volume values Arnav Kapoor
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Arnav Kapoor @ 2026-11-17 10:59 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Peter Ujfalusi, Bard Liao, Daniel Baluta
  Cc: Ranjani Sridharan, Kai Vehmanen, Pierre-Louis Bossart,
	Jaroslav Kysela, Takashi Iwai, sound-open-firmware, linux-sound,
	linux-kernel, Arnav Kapoor

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-17 12:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 10:59 [PATCH 0/4] ASoC: SOF: control: fix volume, switch and enum value handling Arnav Kapoor
2026-11-17 10:59 ` [PATCH 1/4] ASoC: SOF: control: reject out-of-range volume values Arnav Kapoor
2026-11-17 10:59 ` [PATCH 2/4] ASoC: SOF: control: reject invalid switch values Arnav Kapoor
2026-11-17 10:59 ` [PATCH 3/4] ASoC: SOF: report volume changes in mixer steps Arnav Kapoor
2026-11-17 10:59 ` [PATCH 4/4] ASoC: SOF: control: reject out-of-range enum values Arnav Kapoor
2026-11-17 12:24 ` [PATCH 0/4] ASoC: SOF: control: fix volume, switch and enum value handling HyeongJun An

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®