Re: [PATCH] USB Audio Class 2 Mixer unit support for GET_CUR, SET_CUR and RANGE

From: Zipdox

Date: Thu Sep 17 2026 - 10:51:56 EST




On 9/16/26 8:22 PM, Takashi Iwai wrote:

... or maybe a less cryptic version like below.


Takashi

-- 8< --
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 33a6a1281410..c6639a45fb24 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -335,6 +335,16 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request,
return -EINVAL;
}
+/* convert the given UAC1 wValue (ICN+1|OCN+1) to UAC2 MCN */
+static unsigned int to_mcn(const struct usb_mixer_elem_info *cval,
+ unsigned int validx)
+{
+ unsigned char m = (validx >> 8) & 0xff;
+ unsigned char v = validx & 0xff;
+
+ return (m - 1) * cval->num_outputs * (v - 1);
+}
You used multiplication instead of addition for the last part. I assume this is a mistake? Also you should probably also bitwise and that with 0xFF to make sure it's not more than one byte. The product of the number of input and output channels must be no greater than 256 according to the spec. I don't know if this is checked elsewhere. Other than that it looks good for a patch to get it working. I'll try it out and send a follow-up email shortly.