card.c (874b8d422e26e21dd432657e25f679c75440c1bc) | card.c (0ba41d917eeb87f608cf147f870ff2f4c1056bab) |
---|---|
1/* 2 * (Tentative) USB Audio Driver for ALSA 3 * 4 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de> 5 * 6 * Many codes borrowed from audio.c by 7 * Alan Cox (alan@lxorguk.ukuu.org.uk) 8 * Thomas Sailer (sailer@ife.ee.ethz.ch) --- 125 unchanged lines hidden (view full) --- 134static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int interface) 135{ 136 struct usb_device *dev = chip->dev; 137 struct usb_host_interface *alts; 138 struct usb_interface_descriptor *altsd; 139 struct usb_interface *iface = usb_ifnum_to_if(dev, interface); 140 141 if (!iface) { | 1/* 2 * (Tentative) USB Audio Driver for ALSA 3 * 4 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de> 5 * 6 * Many codes borrowed from audio.c by 7 * Alan Cox (alan@lxorguk.ukuu.org.uk) 8 * Thomas Sailer (sailer@ife.ee.ethz.ch) --- 125 unchanged lines hidden (view full) --- 134static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int interface) 135{ 136 struct usb_device *dev = chip->dev; 137 struct usb_host_interface *alts; 138 struct usb_interface_descriptor *altsd; 139 struct usb_interface *iface = usb_ifnum_to_if(dev, interface); 140 141 if (!iface) { |
142 snd_printk(KERN_ERR "%d:%u:%d : does not exist\n", 143 dev->devnum, ctrlif, interface); | 142 dev_err(&dev->dev, "%u:%d : does not exist\n", 143 ctrlif, interface); |
144 return -EINVAL; 145 } 146 147 alts = &iface->altsetting[0]; 148 altsd = get_iface_desc(alts); 149 150 /* 151 * Android with both accessory and audio interfaces enabled gets the --- 8 unchanged lines hidden (view full) --- 160 iface = usb_ifnum_to_if(dev, interface); 161 if (!iface) 162 return -EINVAL; 163 alts = &iface->altsetting[0]; 164 altsd = get_iface_desc(alts); 165 } 166 167 if (usb_interface_claimed(iface)) { | 144 return -EINVAL; 145 } 146 147 alts = &iface->altsetting[0]; 148 altsd = get_iface_desc(alts); 149 150 /* 151 * Android with both accessory and audio interfaces enabled gets the --- 8 unchanged lines hidden (view full) --- 160 iface = usb_ifnum_to_if(dev, interface); 161 if (!iface) 162 return -EINVAL; 163 alts = &iface->altsetting[0]; 164 altsd = get_iface_desc(alts); 165 } 166 167 if (usb_interface_claimed(iface)) { |
168 snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n", 169 dev->devnum, ctrlif, interface); | 168 dev_dbg(&dev->dev, "%d:%d: skipping, already claimed\n", 169 ctrlif, interface); |
170 return -EINVAL; 171 } 172 173 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || 174 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && 175 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) { 176 int err = snd_usbmidi_create(chip->card, iface, 177 &chip->midi_list, NULL); 178 if (err < 0) { | 170 return -EINVAL; 171 } 172 173 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || 174 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && 175 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) { 176 int err = snd_usbmidi_create(chip->card, iface, 177 &chip->midi_list, NULL); 178 if (err < 0) { |
179 snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", 180 dev->devnum, ctrlif, interface); | 179 dev_err(&dev->dev, 180 "%u:%d: cannot create sequencer device\n", 181 ctrlif, interface); |
181 return -EINVAL; 182 } 183 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); 184 185 return 0; 186 } 187 188 if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && 189 altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || 190 altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING) { | 182 return -EINVAL; 183 } 184 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); 185 186 return 0; 187 } 188 189 if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && 190 altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || 191 altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING) { |
191 snd_printdd(KERN_ERR "%d:%u:%d: skipping non-supported interface %d\n", 192 dev->devnum, ctrlif, interface, altsd->bInterfaceClass); | 192 dev_dbg(&dev->dev, 193 "%u:%d: skipping non-supported interface %d\n", 194 ctrlif, interface, altsd->bInterfaceClass); |
193 /* skip non-supported classes */ 194 return -EINVAL; 195 } 196 197 if (snd_usb_get_speed(dev) == USB_SPEED_LOW) { | 195 /* skip non-supported classes */ 196 return -EINVAL; 197 } 198 199 if (snd_usb_get_speed(dev) == USB_SPEED_LOW) { |
198 snd_printk(KERN_ERR "low speed audio streaming not supported\n"); | 200 dev_err(&dev->dev, "low speed audio streaming not supported\n"); |
199 return -EINVAL; 200 } 201 202 if (! snd_usb_parse_audio_interface(chip, interface)) { 203 usb_set_interface(dev, interface, 0); /* reset the current interface */ 204 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); 205 return -EINVAL; 206 } --- 16 unchanged lines hidden (view full) --- 223 host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0]; 224 control_header = snd_usb_find_csint_desc(host_iface->extra, 225 host_iface->extralen, 226 NULL, UAC_HEADER); 227 altsd = get_iface_desc(host_iface); 228 protocol = altsd->bInterfaceProtocol; 229 230 if (!control_header) { | 201 return -EINVAL; 202 } 203 204 if (! snd_usb_parse_audio_interface(chip, interface)) { 205 usb_set_interface(dev, interface, 0); /* reset the current interface */ 206 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); 207 return -EINVAL; 208 } --- 16 unchanged lines hidden (view full) --- 225 host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0]; 226 control_header = snd_usb_find_csint_desc(host_iface->extra, 227 host_iface->extralen, 228 NULL, UAC_HEADER); 229 altsd = get_iface_desc(host_iface); 230 protocol = altsd->bInterfaceProtocol; 231 232 if (!control_header) { |
231 snd_printk(KERN_ERR "cannot find UAC_HEADER\n"); | 233 dev_err(&dev->dev, "cannot find UAC_HEADER\n"); |
232 return -EINVAL; 233 } 234 235 switch (protocol) { 236 default: | 234 return -EINVAL; 235 } 236 237 switch (protocol) { 238 default: |
237 snd_printdd(KERN_WARNING "unknown interface protocol %#02x, assuming v1\n", 238 protocol); | 239 dev_warn(&dev->dev, 240 "unknown interface protocol %#02x, assuming v1\n", 241 protocol); |
239 /* fall through */ 240 241 case UAC_VERSION_1: { 242 struct uac1_ac_header_descriptor *h1 = control_header; 243 244 if (!h1->bInCollection) { | 242 /* fall through */ 243 244 case UAC_VERSION_1: { 245 struct uac1_ac_header_descriptor *h1 = control_header; 246 247 if (!h1->bInCollection) { |
245 snd_printk(KERN_INFO "skipping empty audio interface (v1)\n"); | 248 dev_info(&dev->dev, "skipping empty audio interface (v1)\n"); |
246 return -EINVAL; 247 } 248 249 if (h1->bLength < sizeof(*h1) + h1->bInCollection) { | 249 return -EINVAL; 250 } 251 252 if (h1->bLength < sizeof(*h1) + h1->bInCollection) { |
250 snd_printk(KERN_ERR "invalid UAC_HEADER (v1)\n"); | 253 dev_err(&dev->dev, "invalid UAC_HEADER (v1)\n"); |
251 return -EINVAL; 252 } 253 254 for (i = 0; i < h1->bInCollection; i++) 255 snd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]); 256 257 break; 258 } --- 13 unchanged lines hidden (view full) --- 272 if (iface && 273 iface->intf_assoc && 274 iface->intf_assoc->bFunctionClass == USB_CLASS_AUDIO && 275 iface->intf_assoc->bFunctionProtocol == UAC_VERSION_2) 276 assoc = iface->intf_assoc; 277 } 278 279 if (!assoc) { | 254 return -EINVAL; 255 } 256 257 for (i = 0; i < h1->bInCollection; i++) 258 snd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]); 259 260 break; 261 } --- 13 unchanged lines hidden (view full) --- 275 if (iface && 276 iface->intf_assoc && 277 iface->intf_assoc->bFunctionClass == USB_CLASS_AUDIO && 278 iface->intf_assoc->bFunctionProtocol == UAC_VERSION_2) 279 assoc = iface->intf_assoc; 280 } 281 282 if (!assoc) { |
280 snd_printk(KERN_ERR "Audio class v2 interfaces need an interface association\n"); | 283 dev_err(&dev->dev, "Audio class v2 interfaces need an interface association\n"); |
281 return -EINVAL; 282 } 283 284 for (i = 0; i < assoc->bInterfaceCount; i++) { 285 int intf = assoc->bFirstInterface + i; 286 287 if (intf != ctrlif) 288 snd_usb_create_stream(chip, ctrlif, intf); --- 57 unchanged lines hidden (view full) --- 346 switch (snd_usb_get_speed(dev)) { 347 case USB_SPEED_LOW: 348 case USB_SPEED_FULL: 349 case USB_SPEED_HIGH: 350 case USB_SPEED_WIRELESS: 351 case USB_SPEED_SUPER: 352 break; 353 default: | 284 return -EINVAL; 285 } 286 287 for (i = 0; i < assoc->bInterfaceCount; i++) { 288 int intf = assoc->bFirstInterface + i; 289 290 if (intf != ctrlif) 291 snd_usb_create_stream(chip, ctrlif, intf); --- 57 unchanged lines hidden (view full) --- 349 switch (snd_usb_get_speed(dev)) { 350 case USB_SPEED_LOW: 351 case USB_SPEED_FULL: 352 case USB_SPEED_HIGH: 353 case USB_SPEED_WIRELESS: 354 case USB_SPEED_SUPER: 355 break; 356 default: |
354 snd_printk(KERN_ERR "unknown device speed %d\n", snd_usb_get_speed(dev)); | 357 dev_err(&dev->dev, "unknown device speed %d\n", snd_usb_get_speed(dev)); |
355 return -ENXIO; 356 } 357 358 err = snd_card_new(&intf->dev, index[idx], id[idx], THIS_MODULE, 359 0, &card); 360 if (err < 0) { | 358 return -ENXIO; 359 } 360 361 err = snd_card_new(&intf->dev, index[idx], id[idx], THIS_MODULE, 362 0, &card); 363 if (err < 0) { |
361 snd_printk(KERN_ERR "cannot create card instance %d\n", idx); | 364 dev_err(&dev->dev, "cannot create card instance %d\n", idx); |
362 return err; 363 } 364 365 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 366 if (! chip) { 367 snd_card_free(card); 368 return -ENOMEM; 369 } --- 124 unchanged lines hidden (view full) --- 494 */ 495 496 /* check whether it's already registered */ 497 chip = NULL; 498 mutex_lock(®ister_mutex); 499 for (i = 0; i < SNDRV_CARDS; i++) { 500 if (usb_chip[i] && usb_chip[i]->dev == dev) { 501 if (usb_chip[i]->shutdown) { | 365 return err; 366 } 367 368 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 369 if (! chip) { 370 snd_card_free(card); 371 return -ENOMEM; 372 } --- 124 unchanged lines hidden (view full) --- 497 */ 498 499 /* check whether it's already registered */ 500 chip = NULL; 501 mutex_lock(®ister_mutex); 502 for (i = 0; i < SNDRV_CARDS; i++) { 503 if (usb_chip[i] && usb_chip[i]->dev == dev) { 504 if (usb_chip[i]->shutdown) { |
502 snd_printk(KERN_ERR "USB device is in the shutdown state, cannot create a card instance\n"); | 505 dev_err(&dev->dev, "USB device is in the shutdown state, cannot create a card instance\n"); |
503 goto __error; 504 } 505 chip = usb_chip[i]; 506 chip->probing = 1; 507 break; 508 } 509 } 510 if (! chip) { --- 7 unchanged lines hidden (view full) --- 518 if (snd_usb_audio_create(intf, dev, i, quirk, 519 &chip) < 0) { 520 goto __error; 521 } 522 chip->pm_intf = intf; 523 break; 524 } 525 if (!chip) { | 506 goto __error; 507 } 508 chip = usb_chip[i]; 509 chip->probing = 1; 510 break; 511 } 512 } 513 if (! chip) { --- 7 unchanged lines hidden (view full) --- 521 if (snd_usb_audio_create(intf, dev, i, quirk, 522 &chip) < 0) { 523 goto __error; 524 } 525 chip->pm_intf = intf; 526 break; 527 } 528 if (!chip) { |
526 printk(KERN_ERR "no available usb audio device\n"); | 529 dev_err(&dev->dev, "no available usb audio device\n"); |
527 goto __error; 528 } 529 } 530 531 /* 532 * For devices with more than one control interface, we assume the 533 * first contains the audio controls. We might need a more specific 534 * check here in the future. --- 234 unchanged lines hidden --- | 530 goto __error; 531 } 532 } 533 534 /* 535 * For devices with more than one control interface, we assume the 536 * first contains the audio controls. We might need a more specific 537 * check here in the future. --- 234 unchanged lines hidden --- |