Re: [PATCH] USB Audio Class 2 Mixer unit support for GET_CUR, SET_CUR and RANGE
From: Takashi Iwai
Date: Thu Sep 17 2026 - 12:55:58 EST
On Thu, 17 Sep 2026 16:54:50 +0200,
Zipdox wrote:
>
> On 9/17/26 4:23 PM, Zipdox wrote:
> >
> >
> > 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.
> >
> If you fix the code like this:
>
> static unsigned int to_mcn(const struct usb_mixer_elem_info *cval,
> unsigned int validx)
> {
> unsigned char icn = (validx >> 8) & 0xff;
> unsigned char ocn = validx & 0xff;
>
> return (icn - 1) * cval->num_outputs + (ocn - 1);
> }
>
> then it works correctly. As far as I'm concerned you can merge that
> as-is. It would be good to try on some other hardware as well to check
> for regressions though.
Good to hear. If you have a chance to test my last series of patches,
it'd be appreciated.
BTW, I'll be off from tomorrow, and the issue is no new bug to be
urgently fixed, so I'll handle after back to work again :)
thanks,
Takashi