diff mbox

[5/6] ALSA: usb: Use Class Specific EP for UAC3 devices.

Message ID 20171129105532.15420-6-jorge.sanjuan@codethink.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Jorge Sanjuan Nov. 29, 2017, 10:55 a.m. UTC
bmAtributes offset doesn't exist in the UAC3 CS_EP descriptor.
Hence, checking for pitch control as if it was UAC2 doesn't make
any sense. Use the defined UAC3 offsets instead.

Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
---
 sound/usb/stream.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Comments

Ben Hutchings Dec. 13, 2017, 10:55 p.m. UTC | #1
On Wed, 2017-11-29 at 10:55 +0000, Jorge Sanjuan wrote:
> bmAtributes offset doesn't exist in the UAC3 CS_EP descriptor.
> Hence, checking for pitch control as if it was UAC2 doesn't make
> any sense. Use the defined UAC3 offsets instead.
> 
> Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
> ---
>  sound/usb/stream.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/usb/stream.c b/sound/usb/stream.c
> index 8b3565d4ca24..fbc7e056ee88 100644
> --- a/sound/usb/stream.c
> +++ b/sound/usb/stream.c
> @@ -512,9 +512,11 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,

The check for minimum length of the EP descriptor (just above this)
should also be updated to be version-dependent.

The current check has a hardcoded minimum of 7, which I think will
still cover all the fields being accessed - but that might change in
future.

Ben.

>  		return 0;
>  	}
>  
> -	if (protocol == UAC_VERSION_1) {
> +	switch (protocol) {
> +	case UAC_VERSION_1:
>  		attributes = csep->bmAttributes;
> -	} else {
> +		break;
> +	case UAC_VERSION_2: {
>  		struct uac2_iso_endpoint_descriptor *csep2 =
>  			(struct uac2_iso_endpoint_descriptor *) csep;
>  
> @@ -523,6 +525,17 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
>  		/* emulate the endpoint attributes of a v1 device */
>  		if (csep2->bmControls & UAC2_CONTROL_PITCH)
>  			attributes |= UAC_EP_CS_ATTR_PITCH_CONTROL;
> +		break;
> +	}
> +	case UAC_VERSION_3: {
> +		struct uac3_iso_endpoint_descriptor *csep3 =
> +			(struct uac3_iso_endpoint_descriptor *) csep;
> +
> +		/* emulate the endpoint attributes of a v1 device */
> +		if (csep3->bmControls & UAC3_CONTROL_PITCH)
> +			attributes |= UAC_EP_CS_ATTR_PITCH_CONTROL;
> +		break;
> +	}
>  	}
>  
>  	return attributes;
diff mbox

Patch

diff --git a/sound/usb/stream.c b/sound/usb/stream.c
index 8b3565d4ca24..fbc7e056ee88 100644
--- a/sound/usb/stream.c
+++ b/sound/usb/stream.c
@@ -512,9 +512,11 @@  static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
 		return 0;
 	}
 
-	if (protocol == UAC_VERSION_1) {
+	switch (protocol) {
+	case UAC_VERSION_1:
 		attributes = csep->bmAttributes;
-	} else {
+		break;
+	case UAC_VERSION_2: {
 		struct uac2_iso_endpoint_descriptor *csep2 =
 			(struct uac2_iso_endpoint_descriptor *) csep;
 
@@ -523,6 +525,17 @@  static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
 		/* emulate the endpoint attributes of a v1 device */
 		if (csep2->bmControls & UAC2_CONTROL_PITCH)
 			attributes |= UAC_EP_CS_ATTR_PITCH_CONTROL;
+		break;
+	}
+	case UAC_VERSION_3: {
+		struct uac3_iso_endpoint_descriptor *csep3 =
+			(struct uac3_iso_endpoint_descriptor *) csep;
+
+		/* emulate the endpoint attributes of a v1 device */
+		if (csep3->bmControls & UAC3_CONTROL_PITCH)
+			attributes |= UAC_EP_CS_ATTR_PITCH_CONTROL;
+		break;
+	}
 	}
 
 	return attributes;