[PATCH 0/3] ALSA: usb-audio: Refactor mixer checks and add check for sticky mixers

Rong Zhang posted 3 patches 2 months ago
sound/usb/mixer.c | 138 ++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 103 insertions(+), 35 deletions(-)
[PATCH 0/3] ALSA: usb-audio: Refactor mixer checks and add check for sticky mixers
Posted by Rong Zhang 2 months ago
All callers of get_min_max*() ignore the latter's return code
completely. This means to ignore temporary errors at the probe time.
However, it is not optimal and leads to some maintenance burdens.
Besides, get_min_max_with_quirks() is too lengthy and hard to read.

Some devices' mixers are sticky, which accept SET_CUR but do absolutely
nothing. Registering these mixers confuses userspace and results in
ineffective volume control.

Patch 1 makes get_min_max*() return -EAGAIN for temporary errors, and
check against it in the callers of get_min_max*(). If any other error
occurs, bail out of the caller early.

Patch 2 moves the volume control resolution check code into a function
as it's relatively self-contained.

Patch 3 checks if a mixer is sticky by setting the volume to the maximum
or minimum value and checking for effectiveness afterward, and prevents
the mixer from being registered if it turns out to be sticky.

Quirky device sample:

  usb 7-1: New USB device found, idVendor=0e0b, idProduct=fa01, bcdDevice= 1.00
  usb 7-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
  usb 7-1: Product: Feaulle Rainbow
  usb 7-1: Manufacturer: Generic
  usb 7-1: SerialNumber: 20210726905926
  (Mic Capture Volume)

This series is separated from https://lore.kernel.org/r/20260409-feaulle-rainbow-v1-2-09179e09000d@rong.moe

Signed-off-by: Rong Zhang <i@rong.moe>
---
Rong Zhang (3):
      ALSA: usb-audio: Add error checks against get_min_max*()
      ALSA: usb-audio: Move volume control resolution check into a function
      ALSA: usb-audio: Do not expose sticky mixers

 sound/usb/mixer.c | 138 ++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 103 insertions(+), 35 deletions(-)
---
base-commit: 5a5fea9a0d663da182e04f4a4c7a35bd935a14c2
change-id: 20260409-uac-sticky-mixer-627528939d83

Thanks,
Rong
Re: [PATCH 0/3] ALSA: usb-audio: Refactor mixer checks and add check for sticky mixers
Posted by Takashi Iwai 2 months ago
On Fri, 10 Apr 2026 19:49:01 +0200,
Rong Zhang wrote:
> 
> All callers of get_min_max*() ignore the latter's return code
> completely. This means to ignore temporary errors at the probe time.
> However, it is not optimal and leads to some maintenance burdens.
> Besides, get_min_max_with_quirks() is too lengthy and hard to read.
> 
> Some devices' mixers are sticky, which accept SET_CUR but do absolutely
> nothing. Registering these mixers confuses userspace and results in
> ineffective volume control.
> 
> Patch 1 makes get_min_max*() return -EAGAIN for temporary errors, and
> check against it in the callers of get_min_max*(). If any other error
> occurs, bail out of the caller early.
> 
> Patch 2 moves the volume control resolution check code into a function
> as it's relatively self-contained.
> 
> Patch 3 checks if a mixer is sticky by setting the volume to the maximum
> or minimum value and checking for effectiveness afterward, and prevents
> the mixer from being registered if it turns out to be sticky.
> 
> Quirky device sample:
> 
>   usb 7-1: New USB device found, idVendor=0e0b, idProduct=fa01, bcdDevice= 1.00
>   usb 7-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
>   usb 7-1: Product: Feaulle Rainbow
>   usb 7-1: Manufacturer: Generic
>   usb 7-1: SerialNumber: 20210726905926
>   (Mic Capture Volume)
> 
> This series is separated from https://lore.kernel.org/r/20260409-feaulle-rainbow-v1-2-09179e09000d@rong.moe
> 
> Signed-off-by: Rong Zhang <i@rong.moe>
> ---
> Rong Zhang (3):
>       ALSA: usb-audio: Add error checks against get_min_max*()
>       ALSA: usb-audio: Move volume control resolution check into a function
>       ALSA: usb-audio: Do not expose sticky mixers

Applied all three patches now.  Thanks.


Takashi