Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: Re-read descriptors for Xiaomi 2717:d005
@ 2026-09-23 15:25 Xucheng Pan
  2026-09-29  9:35 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Xucheng Pan @ 2026-09-23 15:25 UTC (permalink / raw)
  To: linux-sound; +Cc: tiwai, perex, linux-usb, Xucheng Pan

The Xiaomi 2717:d005 USB audio transmitter supports Sound 2 Pro and
Sound 2 Max speakers. This issue was reproduced with two Sound 2 Pro
speakers paired in stereo. After a USB replug, Linux detects the
transmitter and exposes a hardware volume control, but moving the volume
slider changes neither the audible level nor the speakers' volume LEDs.
Windows controls the same speakers with its in-box USB Audio driver.
USB captures show standard UAC2 volume SET_CUR requests on both systems.

Re-reading the device descriptor (18 bytes), configuration header
(9 bytes), and full configuration descriptor (184 bytes on the tested
unit) after 2717:d005 is configured restores hardware volume control.
The USBFS sequence recovered the device after multiple replug tests.
Reading only the device descriptor did not restore volume control.

Perform these reads when snd-usb-audio first probes 2717:d005. Use the
configuration header's wTotalLength for the final read. If a read fails,
warn and continue probing so that playback remains available.

Tested on 7.2.6-zen2-1-zen with the existing userspace workaround
disabled. After a physical USB replug, the quirk ran when 2717:d005
appeared, and both audible volume and the speakers' LEDs followed the
KDE volume slider.

Signed-off-by: Xucheng Pan <panxucc@gmail.com>
---
 sound/usb/quirks.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index c587090..f9b7036 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -870,6 +870,49 @@ static int snd_usb_cm1a_boot_quirk(struct usb_device *dev)
 	return 0;
 }
 
+/*
+ * The Xiaomi audio connector ignores UAC2 volume changes after reconnecting
+ * until the device and configuration descriptors have been read again.
+ */
+#define XIAOMI_AUDIO_MAX_CONFIG_SIZE 1024
+
+static void snd_usb_xiaomi_boot_quirk(struct usb_device *dev)
+{
+	u8 *buf __free(kfree) = kmalloc(XIAOMI_AUDIO_MAX_CONFIG_SIZE, GFP_KERNEL);
+	struct usb_config_descriptor *config;
+	unsigned int length;
+	int ret;
+
+	if (!buf)
+		return;
+
+	ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, buf,
+				 USB_DT_DEVICE_SIZE);
+	if (ret != USB_DT_DEVICE_SIZE) {
+		dev_warn(&dev->dev, "device descriptor re-read failed: %d\n", ret);
+		return;
+	}
+
+	ret = usb_get_descriptor(dev, USB_DT_CONFIG, 0, buf,
+				 USB_DT_CONFIG_SIZE);
+	if (ret != USB_DT_CONFIG_SIZE) {
+		dev_warn(&dev->dev, "configuration header re-read failed: %d\n", ret);
+		return;
+	}
+
+	config = (struct usb_config_descriptor *)buf;
+	length = le16_to_cpu(config->wTotalLength);
+	if (length < USB_DT_CONFIG_SIZE ||
+	    length > XIAOMI_AUDIO_MAX_CONFIG_SIZE) {
+		dev_warn(&dev->dev, "unexpected configuration length: %u\n", length);
+		return;
+	}
+
+	ret = usb_get_descriptor(dev, USB_DT_CONFIG, 0, buf, length);
+	if (ret != (int)length)
+		dev_warn(&dev->dev, "configuration descriptor re-read failed: %d\n", ret);
+}
+
 /*
  * Some sound cards from Native Instruments are in fact compliant to the USB
  * audio standard of version 2 and other approved USB standards, even though
@@ -1704,6 +1747,9 @@ int snd_usb_apply_boot_quirk_once(struct usb_device *dev,
 		return snd_usb_motu_m_series_boot_quirk(dev);
 	case USB_ID(0x1397, 0x1234): /* Behringer CM1A */
 		return snd_usb_cm1a_boot_quirk(dev);
+	case USB_ID(0x2717, 0xd005): /* Xiaomi audio connector */
+		snd_usb_xiaomi_boot_quirk(dev);
+		return 0;
 	}
 
 	return 0;
-- 
2.55.0


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

* Re: [PATCH] ALSA: usb-audio: Re-read descriptors for Xiaomi 2717:d005
  2026-09-23 15:25 [PATCH] ALSA: usb-audio: Re-read descriptors for Xiaomi 2717:d005 Xucheng Pan
@ 2026-09-29  9:35 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-09-29  9:35 UTC (permalink / raw)
  To: Xucheng Pan; +Cc: linux-sound, tiwai, perex, linux-usb

On Wed, 23 Sep 2026 17:25:52 +0200,
Xucheng Pan wrote:
> 
> The Xiaomi 2717:d005 USB audio transmitter supports Sound 2 Pro and
> Sound 2 Max speakers. This issue was reproduced with two Sound 2 Pro
> speakers paired in stereo. After a USB replug, Linux detects the
> transmitter and exposes a hardware volume control, but moving the volume
> slider changes neither the audible level nor the speakers' volume LEDs.
> Windows controls the same speakers with its in-box USB Audio driver.
> USB captures show standard UAC2 volume SET_CUR requests on both systems.
> 
> Re-reading the device descriptor (18 bytes), configuration header
> (9 bytes), and full configuration descriptor (184 bytes on the tested
> unit) after 2717:d005 is configured restores hardware volume control.
> The USBFS sequence recovered the device after multiple replug tests.
> Reading only the device descriptor did not restore volume control.
> 
> Perform these reads when snd-usb-audio first probes 2717:d005. Use the
> configuration header's wTotalLength for the final read. If a read fails,
> warn and continue probing so that playback remains available.
> 
> Tested on 7.2.6-zen2-1-zen with the existing userspace workaround
> disabled. After a physical USB replug, the quirk ran when 2717:d005
> appeared, and both audible volume and the speakers' LEDs followed the
> KDE volume slider.
> 
> Signed-off-by: Xucheng Pan <panxucc@gmail.com>

Applied to for-next branch now.  Thanks.


Takashi

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

end of thread, other threads:[~2026-09-29  9:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-23 15:25 [PATCH] ALSA: usb-audio: Re-read descriptors for Xiaomi 2717:d005 Xucheng Pan
2026-09-29  9:35 ` Takashi Iwai

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