39 #include <linux/bitops.h>
41 #include <linux/list.h>
42 #include <linux/slab.h>
43 #include <linux/string.h>
44 #include <linux/ctype.h>
48 #include <linux/usb/audio.h>
50 #include <linux/module.h>
85 static int nrpacks = 8;
86 static bool async_unlink = 1;
88 static bool ignore_ctl_error;
108 "Ignore errors from USB controller for mixer interfaces.");
117 static struct usb_driver usb_audio_driver;
123 static void snd_usb_stream_disconnect(
struct list_head *
head)
130 for (idx = 0; idx < 2; idx++) {
142 struct usb_device *
dev = chip->
dev;
143 struct usb_host_interface *alts;
149 dev->devnum, ctrlif, interface);
153 if (usb_interface_claimed(iface)) {
155 dev->devnum, ctrlif, interface);
159 alts = &iface->altsetting[0];
168 dev->devnum, ctrlif, interface);
202 static int snd_usb_create_streams(
struct snd_usb_audio *chip,
int ctrlif)
204 struct usb_device *dev = chip->
dev;
205 struct usb_host_interface *host_iface;
207 void *control_header;
213 host_iface->extralen,
218 if (!control_header) {
261 snd_usb_create_stream(chip, ctrlif, intf);
288 return snd_usb_audio_free(chip);
291 static void remove_trailing_spaces(
char *
str)
297 for (p = str +
strlen(str) - 1; p >= str &&
isspace(*p); p--)
304 static int snd_usb_audio_create(
struct usb_device *dev,
int idx,
313 .dev_free = snd_usb_audio_dev_free,
354 INIT_LIST_HEAD(&chip->
ep_list);
359 snd_usb_audio_free(chip);
365 sprintf(component,
"USB%04x:%04x",
373 if (!dev->descriptor.iProduct ||
388 if (dev->descriptor.iManufacturer)
389 len =
usb_string(dev, dev->descriptor.iManufacturer,
396 remove_trailing_spaces(card->
longname);
442 snd_usb_audio_probe(
struct usb_device *dev,
449 struct usb_host_interface *alts;
453 alts = &intf->altsetting[0];
471 if (usb_chip[i] && usb_chip[i]->dev == dev) {
472 if (usb_chip[i]->shutdown) {
473 snd_printk(
KERN_ERR "USB device is in the shutdown state, cannot create a card instance\n");
486 if (
enable[i] && ! usb_chip[i] &&
489 if (snd_usb_audio_create(dev, i, quirk, &chip) < 0) {
520 if (snd_usb_create_streams(chip,
ifnum) < 0 ||
552 static void snd_usb_audio_disconnect(
struct usb_device *dev,
558 if (chip == (
void *)-1L)
572 snd_usb_stream_disconnect(p);
601 chip = snd_usb_audio_probe(interface_to_usbdev(intf), intf,
id);
603 usb_set_intfdata(intf, chip);
611 snd_usb_audio_disconnect(interface_to_usbdev(intf),
612 usb_get_intfdata(intf));
623 err = usb_autopm_get_interface(chip->
pm_intf);
633 usb_autopm_put_interface(chip->
pm_intf);
644 if (chip == (
void *)-1L)
652 snd_pcm_suspend_all(as->
pcm);
678 if (chip == (
void *)-1L)
700 #define usb_audio_suspend NULL
701 #define usb_audio_resume NULL
718 static struct usb_driver usb_audio_driver = {
719 .name =
"snd-usb-audio",
720 .probe = usb_audio_probe,
721 .disconnect = usb_audio_disconnect,
724 .id_table = usb_audio_ids,
725 .supports_autosuspend = 1,
728 static int __init snd_usb_audio_init(
void)
730 if (nrpacks < 1 || nrpacks >
MAX_PACKS) {
734 return usb_register(&usb_audio_driver);
737 static void __exit snd_usb_audio_cleanup(
void)