diff options
Diffstat (limited to 'sound/usb/endpoint.c')
-rw-r--r-- | sound/usb/endpoint.c | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 4887342cae27..28ee1ce3971a 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c | |||
@@ -149,6 +149,47 @@ int snd_usb_add_audio_endpoint(struct snd_usb_audio *chip, int stream, struct au | |||
149 | return 0; | 149 | return 0; |
150 | } | 150 | } |
151 | 151 | ||
152 | static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip, | ||
153 | struct usb_host_interface *alts, | ||
154 | int protocol, int iface_no) | ||
155 | { | ||
156 | /* parsed with a v1 header here. that's ok as we only look at the | ||
157 | * header first which is the same for both versions */ | ||
158 | struct uac_iso_endpoint_descriptor *csep; | ||
159 | struct usb_interface_descriptor *altsd = get_iface_desc(alts); | ||
160 | int attributes = 0; | ||
161 | |||
162 | csep = snd_usb_find_desc(alts->endpoint[0].extra, alts->endpoint[0].extralen, NULL, USB_DT_CS_ENDPOINT); | ||
163 | |||
164 | /* Creamware Noah has this descriptor after the 2nd endpoint */ | ||
165 | if (!csep && altsd->bNumEndpoints >= 2) | ||
166 | csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT); | ||
167 | |||
168 | if (!csep || csep->bLength < 7 || | ||
169 | csep->bDescriptorSubtype != UAC_EP_GENERAL) { | ||
170 | snd_printk(KERN_WARNING "%d:%u:%d : no or invalid" | ||
171 | " class specific endpoint descriptor\n", | ||
172 | chip->dev->devnum, iface_no, | ||
173 | altsd->bAlternateSetting); | ||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | if (protocol == UAC_VERSION_1) { | ||
178 | attributes = csep->bmAttributes; | ||
179 | } else { | ||
180 | struct uac2_iso_endpoint_descriptor *csep2 = | ||
181 | (struct uac2_iso_endpoint_descriptor *) csep; | ||
182 | |||
183 | attributes = csep->bmAttributes & UAC_EP_CS_ATTR_FILL_MAX; | ||
184 | |||
185 | /* emulate the endpoint attributes of a v1 device */ | ||
186 | if (csep2->bmControls & UAC2_CONTROL_PITCH) | ||
187 | attributes |= UAC_EP_CS_ATTR_PITCH_CONTROL; | ||
188 | } | ||
189 | |||
190 | return attributes; | ||
191 | } | ||
192 | |||
152 | int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | 193 | int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) |
153 | { | 194 | { |
154 | struct usb_device *dev; | 195 | struct usb_device *dev; |
@@ -158,7 +199,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
158 | int i, altno, err, stream; | 199 | int i, altno, err, stream; |
159 | int format = 0, num_channels = 0; | 200 | int format = 0, num_channels = 0; |
160 | struct audioformat *fp = NULL; | 201 | struct audioformat *fp = NULL; |
161 | unsigned char *csep; | ||
162 | int num, protocol; | 202 | int num, protocol; |
163 | struct uac_format_type_i_continuous_descriptor *fmt; | 203 | struct uac_format_type_i_continuous_descriptor *fmt; |
164 | 204 | ||
@@ -279,17 +319,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
279 | fp->maxpacksize * 2) | 319 | fp->maxpacksize * 2) |
280 | continue; | 320 | continue; |
281 | 321 | ||
282 | csep = snd_usb_find_desc(alts->endpoint[0].extra, alts->endpoint[0].extralen, NULL, USB_DT_CS_ENDPOINT); | ||
283 | /* Creamware Noah has this descriptor after the 2nd endpoint */ | ||
284 | if (!csep && altsd->bNumEndpoints >= 2) | ||
285 | csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT); | ||
286 | if (!csep || csep[0] < 7 || csep[2] != UAC_EP_GENERAL) { | ||
287 | snd_printk(KERN_WARNING "%d:%u:%d : no or invalid" | ||
288 | " class specific endpoint descriptor\n", | ||
289 | dev->devnum, iface_no, altno); | ||
290 | csep = NULL; | ||
291 | } | ||
292 | |||
293 | fp = kzalloc(sizeof(*fp), GFP_KERNEL); | 322 | fp = kzalloc(sizeof(*fp), GFP_KERNEL); |
294 | if (! fp) { | 323 | if (! fp) { |
295 | snd_printk(KERN_ERR "cannot malloc\n"); | 324 | snd_printk(KERN_ERR "cannot malloc\n"); |
@@ -308,7 +337,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
308 | if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) | 337 | if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) |
309 | fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) | 338 | fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) |
310 | * (fp->maxpacksize & 0x7ff); | 339 | * (fp->maxpacksize & 0x7ff); |
311 | fp->attributes = csep ? csep[3] : 0; | 340 | fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol, iface_no); |
312 | 341 | ||
313 | /* some quirks for attributes here */ | 342 | /* some quirks for attributes here */ |
314 | 343 | ||