diff options
Diffstat (limited to 'sound/usb/endpoint.c')
-rw-r--r-- | sound/usb/endpoint.c | 64 |
1 files changed, 48 insertions, 16 deletions
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index ef07a6d0dd5f..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,8 +199,8 @@ 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 *fmt, *csep; | ||
162 | int num, protocol; | 202 | int num, protocol; |
203 | struct uac_format_type_i_continuous_descriptor *fmt; | ||
163 | 204 | ||
164 | dev = chip->dev; | 205 | dev = chip->dev; |
165 | 206 | ||
@@ -256,8 +297,8 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
256 | dev->devnum, iface_no, altno); | 297 | dev->devnum, iface_no, altno); |
257 | continue; | 298 | continue; |
258 | } | 299 | } |
259 | if (((protocol == UAC_VERSION_1) && (fmt[0] < 8)) || | 300 | if (((protocol == UAC_VERSION_1) && (fmt->bLength < 8)) || |
260 | ((protocol == UAC_VERSION_2) && (fmt[0] != 6))) { | 301 | ((protocol == UAC_VERSION_2) && (fmt->bLength != 6))) { |
261 | snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n", | 302 | snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n", |
262 | dev->devnum, iface_no, altno); | 303 | dev->devnum, iface_no, altno); |
263 | continue; | 304 | continue; |
@@ -268,7 +309,9 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
268 | * with the previous one, except for a larger packet size, but | 309 | * with the previous one, except for a larger packet size, but |
269 | * is actually a mislabeled two-channel setting; ignore it. | 310 | * is actually a mislabeled two-channel setting; ignore it. |
270 | */ | 311 | */ |
271 | if (fmt[4] == 1 && fmt[5] == 2 && altno == 2 && num == 3 && | 312 | if (fmt->bNrChannels == 1 && |
313 | fmt->bSubframeSize == 2 && | ||
314 | altno == 2 && num == 3 && | ||
272 | fp && fp->altsetting == 1 && fp->channels == 1 && | 315 | fp && fp->altsetting == 1 && fp->channels == 1 && |
273 | fp->formats == SNDRV_PCM_FMTBIT_S16_LE && | 316 | fp->formats == SNDRV_PCM_FMTBIT_S16_LE && |
274 | protocol == UAC_VERSION_1 && | 317 | protocol == UAC_VERSION_1 && |
@@ -276,17 +319,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
276 | fp->maxpacksize * 2) | 319 | fp->maxpacksize * 2) |
277 | continue; | 320 | continue; |
278 | 321 | ||
279 | csep = snd_usb_find_desc(alts->endpoint[0].extra, alts->endpoint[0].extralen, NULL, USB_DT_CS_ENDPOINT); | ||
280 | /* Creamware Noah has this descriptor after the 2nd endpoint */ | ||
281 | if (!csep && altsd->bNumEndpoints >= 2) | ||
282 | csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT); | ||
283 | if (!csep || csep[0] < 7 || csep[2] != UAC_EP_GENERAL) { | ||
284 | snd_printk(KERN_WARNING "%d:%u:%d : no or invalid" | ||
285 | " class specific endpoint descriptor\n", | ||
286 | dev->devnum, iface_no, altno); | ||
287 | csep = NULL; | ||
288 | } | ||
289 | |||
290 | fp = kzalloc(sizeof(*fp), GFP_KERNEL); | 322 | fp = kzalloc(sizeof(*fp), GFP_KERNEL); |
291 | if (! fp) { | 323 | if (! fp) { |
292 | snd_printk(KERN_ERR "cannot malloc\n"); | 324 | snd_printk(KERN_ERR "cannot malloc\n"); |
@@ -305,7 +337,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
305 | if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) | 337 | if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) |
306 | fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) | 338 | fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) |
307 | * (fp->maxpacksize & 0x7ff); | 339 | * (fp->maxpacksize & 0x7ff); |
308 | fp->attributes = csep ? csep[3] : 0; | 340 | fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol, iface_no); |
309 | 341 | ||
310 | /* some quirks for attributes here */ | 342 | /* some quirks for attributes here */ |
311 | 343 | ||