The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Agustin Luzardo <agustinluzardo09@gmail.com>
To: perex@perex.cz, tiwai@suse.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	Agustin Luzardo <agustinluzardo09@gmail.com>
Subject: [PATCH] ALSA: usb-audio: Do not drop per-channel feature controls marked get_cur_broken
Date: Tue,  7 Jul 2026 15:31:33 -0300	[thread overview]
Message-ID: <20260707183133.8113-1-agustinluzardo09@gmail.com> (raw)
In-Reply-To: <20260705184227.113588-1-agustinluzardo09@gmail.com>

When a per-channel Feature Unit control (e.g. a stereo PCM Playback
Volume control) hits the sticky-mixer check during get_min_max_with_quirks(),
and the device carries QUIRK_FLAG_MIXER_GET_CUR_BROKEN, the sticky
check marks the control as cval->get_cur_broken and returns -ENXIO
instead of disabling it outright.

However, __build_feature_ctl() does not know about this and treats
any negative return other than -EAGAIN as fatal, discarding the
kcontrol entirely:

	if ((ret < 0 && ret != -EAGAIN) || cval->max <= cval->min) {
		...
		snd_ctl_free_one(kctl);
		return;
	}

For a stereo device where only some channels trip the sticky check,
this silently drops the per-channel (stereo) control while the
master-only control (built separately, without going through the
same channel-specific GET_CUR negotiation) survives. The result is
that the user is left with a single mono/master volume control
instead of the independent per-channel controls the device actually
supports, with no visible error (usb_audio_dbg is typically compiled
out).

This was observed on a Weltrend Semiconductor 040b:0897 device (sold
as the Redragon H510-PRO Wireless headset), which reports a genuine
stereo Feature Unit (bNrChannels = 2, bmaControls with Volume set for
both channels) but ends up exposing only a single-channel "PCM
Playback Volume" control once QUIRK_FLAG_MIXER_GET_CUR_BROKEN is
applied for that device.

Skip the discard when the control was already marked get_cur_broken,
as long as a sane range was otherwise established.

Signed-off-by: Agustin Luzardo <agustinluzardo09@gmail.com>
---
 sound/usb/mixer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 0000000..0000000 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1970,8 +1970,10 @@ static void __build_feature_ctl(struct usb_mixer_interface *mixer,
 	/* get min/max values */
 	ret = get_min_max_with_quirks(cval, 0, kctl);
 
-	/* skip a bogus volume range */
-	if ((ret < 0 && ret != -EAGAIN) || cval->max <= cval->min) {
+	/* skip a bogus volume range, unless the sticky check already
+	 * marked this control as usable via the driver's cached value
+	 * (QUIRK_FLAG_MIXER_GET_CUR_BROKEN) */
+	if ((ret < 0 && ret != -EAGAIN && !cval->get_cur_broken) ||
+	    cval->max <= cval->min) {
 		usb_audio_dbg(mixer->chip,
 			      "[%d] FU [%s] skipped due to invalid volume\n",
 			      cval->head.id, kctl->id.name);
-- 
2.46.1

  reply	other threads:[~2026-07-07 18:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-05 18:42 [PATCH] ALSA: usb-audio: Add quirk for Redragon H510-PRO Wireless headset Agustin Luzardo
2026-07-07 18:31 ` Agustin Luzardo [this message]
2026-07-08 10:40   ` [PATCH] ALSA: usb-audio: Do not drop per-channel feature controls marked get_cur_broken Takashi Iwai
2026-07-08 18:35   ` Agustin Luzardo
2026-07-08 10:39 ` [PATCH] ALSA: usb-audio: Add quirk for Redragon H510-PRO Wireless headset 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=20260707183133.8113-1-agustinluzardo09@gmail.com \
    --to=agustinluzardo09@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --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