From: Takashi Iwai <tiwai@suse.de>
To: Rong Zhang <i@rong.moe>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Takashi Iwai <tiwai@suse.de>, Steve Smith <tarkasteve@gmail.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: usb-audio: Set the value of potential sticky mixers to maximum
Date: Sun, 31 May 2026 15:23:27 +0200 [thread overview]
Message-ID: <877bojpvao.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260531-uac-sticky-error-path-v1-1-12c2329d17ef@rong.moe>
On Sat, 30 May 2026 21:52:49 +0200,
Rong Zhang wrote:
>
> It makes no sense to restore the saved value for a sticky mixer, since
> setting any value is a no-op.
>
> However, in some rare cases, SET_CUR is effective despite GET_CUR always
> returns a constant value. These mixers are not sticky, but there's no
> way to distinguish them. Without any additional information, the best
> thing we can do is to set the mixer value to the maximum before bailing
> out, so that a soft mixer can still reach the maximum hardware volume if
> the mixer turns out to be non-sticky. Meanwhile, all channels must be
> synchronized to prevent imbalance volume.
>
> Fixes: 86aa1ea1f15c ("ALSA: usb-audio: Do not expose sticky mixers")
> Signed-off-by: Rong Zhang <i@rong.moe>
> ---
> sound/usb/mixer.c | 33 +++++++++++++++++++++++++++++----
> 1 file changed, 29 insertions(+), 4 deletions(-)
>
> diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
> index 5fba456eb4a9..fb37bb8ad9a9 100644
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c
> @@ -1371,10 +1371,8 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,
> goto no_checks;
>
> ret = check_sticky_volume_control(cval, minchn, saved);
> - if (ret < 0) {
> - snd_usb_set_cur_mix_value(cval, minchn, 0, saved);
> - return ret;
> - }
> + if (ret < 0)
> + goto sticky;
>
> if (cval->min + cval->res < cval->max)
> check_volume_control_res(cval, minchn, saved);
> @@ -1431,6 +1429,33 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,
> }
>
> return 0;
> +
> +sticky:
> + /*
> + * It makes no sense to restore the saved value for a sticky mixer,
> + * since setting any value is a no-op.
> + *
> + * However, in some rare cases, SET_CUR is effective despite GET_CUR
> + * always returns a constant value. These mixers are not sticky, but
> + * there's no way to distinguish them. Without any additional
> + * information, the best thing we can do is to set the mixer value to
> + * the maximum before bailing out, so that a soft mixer can still reach
> + * the maximum hardware volume if the mixer turns out to be non-sticky.
> + * Meanwhile, all channels must be synchronized to prevent imbalance
> + * volume.
> + */
> + if (!cval->cmask) {
> + snd_usb_set_cur_mix_value(cval, 0, 0, cval->max);
> + } else {
> + for (i = 0; i < MAX_CHANNELS; i++) {
> + idx = 0;
> + if (cval->cmask & BIT(i)) {
> + snd_usb_set_cur_mix_value(cval, i + 1, idx, cval->max);
> + idx++;
> + }
> + }
> + }
> + return ret;
This change is supposed to be applied only to 7.1, and 7.2 should take
another your series ("ALSA: usb-audio: MIXER_GET_CUR_BROKEN related
changes for 7.2") instead, right? If so, at merging the latter, I'll
revert this one as a preliminary.
thanks,
Takashi
next prev parent reply other threads:[~2026-05-31 13:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-30 19:52 [PATCH] ALSA: usb-audio: Set the value of potential sticky mixers to maximum Rong Zhang
2026-05-31 5:12 ` Steve Smith
2026-05-31 13:23 ` Takashi Iwai [this message]
2026-05-31 13:55 ` Rong Zhang
2026-05-31 14:07 ` Takashi Iwai
2026-05-31 14:19 ` Rong Zhang
2026-05-31 14:50 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877bojpvao.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=i@rong.moe \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tarkasteve@gmail.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox