2 * (Tentative) USB Audio Driver for ALSA
6 * Many codes borrowed from audio.c by
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 * - the linked URBs would be preferred but not used so far because of
30 * the instability of unlinking.
31 * - type II is not supported properly. there is no device which supports
32 * this type *correctly*. SB extigy looks as if it supports, but it's
33 * indeed an AC3 stream packed in SPDIF frames (i.e. no real AC3 stream).
37 #include <linux/bitops.h>
38 #include <linux/init.h>
39 #include <linux/list.h>
40 #include <linux/slab.h>
41 #include <linux/string.h>
42 #include <linux/ctype.h>
43 #include <linux/usb.h>
44 #include <linux/moduleparam.h>
45 #include <linux/mutex.h>
46 #include <linux/usb/audio.h>
47 #include <linux/usb/audio-v2.h>
48 #include <linux/usb/audio-v3.h>
49 #include <linux/module.h>
51 #include <sound/control.h>
52 #include <sound/core.h>
53 #include <sound/info.h>
54 #include <sound/pcm.h>
55 #include <sound/pcm_params.h>
56 #include <sound/initval.h>
73 MODULE_DESCRIPTION("USB Audio");
74 MODULE_LICENSE("GPL");
75 MODULE_SUPPORTED_DEVICE("{{Generic,USB Audio}}");
78 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
79 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
80 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
81 /* Vendor/product IDs for this card */
82 static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
83 static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
84 static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
85 static bool ignore_ctl_error;
86 static bool autoclock = true;
87 static char *quirk_alias[SNDRV_CARDS];
89 bool snd_usb_use_vmalloc = true;
91 module_param_array(index, int, NULL, 0444);
92 MODULE_PARM_DESC(index, "Index value for the USB audio adapter.");
93 module_param_array(id, charp, NULL, 0444);
94 MODULE_PARM_DESC(id, "ID string for the USB audio adapter.");
95 module_param_array(enable, bool, NULL, 0444);
96 MODULE_PARM_DESC(enable, "Enable USB audio adapter.");
97 module_param_array(vid, int, NULL, 0444);
98 MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device.");
99 module_param_array(pid, int, NULL, 0444);
100 MODULE_PARM_DESC(pid, "Product ID for the USB audio device.");
101 module_param_array(device_setup, int, NULL, 0444);
102 MODULE_PARM_DESC(device_setup, "Specific device setup (if needed).");
103 module_param(ignore_ctl_error, bool, 0444);
104 MODULE_PARM_DESC(ignore_ctl_error,
105 "Ignore errors from USB controller for mixer interfaces.");
106 module_param(autoclock, bool, 0444);
107 MODULE_PARM_DESC(autoclock, "Enable auto-clock selection for UAC2 devices (default: yes).");
108 module_param_array(quirk_alias, charp, NULL, 0444);
109 MODULE_PARM_DESC(quirk_alias, "Quirk aliases, e.g. 0123abcd:5678beef.");
110 module_param_named(use_vmalloc, snd_usb_use_vmalloc, bool, 0444);
111 MODULE_PARM_DESC(use_vmalloc, "Use vmalloc for PCM intermediate buffers (default: yes).");
114 * we keep the snd_usb_audio_t instances by ourselves for merging
115 * the all interfaces on the same card as one sound device.
118 static DEFINE_MUTEX(register_mutex);
119 static struct snd_usb_audio *usb_chip[SNDRV_CARDS];
120 static struct usb_driver usb_audio_driver;
124 * called from usb_audio_disconnect()
126 static void snd_usb_stream_disconnect(struct snd_usb_stream *as)
129 struct snd_usb_substream *subs;
131 for (idx = 0; idx < 2; idx++) {
132 subs = &as->substream[idx];
133 if (!subs->num_formats)
135 subs->interface = -1;
136 subs->data_endpoint = NULL;
137 subs->sync_endpoint = NULL;
141 static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int interface)
143 struct usb_device *dev = chip->dev;
144 struct usb_host_interface *alts;
145 struct usb_interface_descriptor *altsd;
146 struct usb_interface *iface = usb_ifnum_to_if(dev, interface);
149 dev_err(&dev->dev, "%u:%d : does not exist\n",
154 alts = &iface->altsetting[0];
155 altsd = get_iface_desc(alts);
158 * Android with both accessory and audio interfaces enabled gets the
159 * interface numbers wrong.
161 if ((chip->usb_id == USB_ID(0x18d1, 0x2d04) ||
162 chip->usb_id == USB_ID(0x18d1, 0x2d05)) &&
164 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
165 altsd->bInterfaceSubClass == USB_SUBCLASS_VENDOR_SPEC) {
167 iface = usb_ifnum_to_if(dev, interface);
170 alts = &iface->altsetting[0];
171 altsd = get_iface_desc(alts);
174 if (usb_interface_claimed(iface)) {
175 dev_dbg(&dev->dev, "%d:%d: skipping, already claimed\n",
180 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO ||
181 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) &&
182 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) {
183 int err = __snd_usbmidi_create(chip->card, iface,
184 &chip->midi_list, NULL,
188 "%u:%d: cannot create sequencer device\n",
192 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
197 if ((altsd->bInterfaceClass != USB_CLASS_AUDIO &&
198 altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) ||
199 altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING) {
201 "%u:%d: skipping non-supported interface %d\n",
202 ctrlif, interface, altsd->bInterfaceClass);
203 /* skip non-supported classes */
207 if (snd_usb_get_speed(dev) == USB_SPEED_LOW) {
208 dev_err(&dev->dev, "low speed audio streaming not supported\n");
212 if (! snd_usb_parse_audio_interface(chip, interface)) {
213 usb_set_interface(dev, interface, 0); /* reset the current interface */
214 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
221 * parse audio control descriptor and create pcm/midi streams
223 static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
225 struct usb_device *dev = chip->dev;
226 struct usb_host_interface *host_iface;
227 struct usb_interface_descriptor *altsd;
230 /* find audiocontrol interface */
231 host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0];
232 altsd = get_iface_desc(host_iface);
233 protocol = altsd->bInterfaceProtocol;
238 "unknown interface protocol %#02x, assuming v1\n",
242 case UAC_VERSION_1: {
243 struct uac1_ac_header_descriptor *h1;
246 h1 = snd_usb_find_csint_desc(host_iface->extra,
247 host_iface->extralen,
250 dev_err(&dev->dev, "cannot find UAC_HEADER\n");
254 rest_bytes = (void *)(host_iface->extra +
255 host_iface->extralen) - (void *)h1;
257 /* just to be sure -- this shouldn't hit at all */
258 if (rest_bytes <= 0) {
259 dev_err(&dev->dev, "invalid control header\n");
263 if (rest_bytes < sizeof(*h1)) {
264 dev_err(&dev->dev, "too short v1 buffer descriptor\n");
268 if (!h1->bInCollection) {
269 dev_info(&dev->dev, "skipping empty audio interface (v1)\n");
273 if (rest_bytes < h1->bLength) {
274 dev_err(&dev->dev, "invalid buffer length (v1)\n");
278 if (h1->bLength < sizeof(*h1) + h1->bInCollection) {
279 dev_err(&dev->dev, "invalid UAC_HEADER (v1)\n");
283 for (i = 0; i < h1->bInCollection; i++)
284 snd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]);
290 case UAC_VERSION_3: {
291 struct usb_interface_assoc_descriptor *assoc =
292 usb_ifnum_to_if(dev, ctrlif)->intf_assoc;
296 * Firmware writers cannot count to three. So to find
297 * the IAD on the NuForce UDH-100, also check the next
300 struct usb_interface *iface =
301 usb_ifnum_to_if(dev, ctrlif + 1);
304 iface->intf_assoc->bFunctionClass == USB_CLASS_AUDIO &&
305 iface->intf_assoc->bFunctionProtocol == UAC_VERSION_2)
306 assoc = iface->intf_assoc;
310 dev_err(&dev->dev, "Audio class v2/v3 interfaces need an interface association\n");
314 if (protocol == UAC_VERSION_3) {
315 int badd = assoc->bFunctionSubClass;
317 if (badd != UAC3_FUNCTION_SUBCLASS_FULL_ADC_3_0 &&
318 (badd < UAC3_FUNCTION_SUBCLASS_GENERIC_IO ||
319 badd > UAC3_FUNCTION_SUBCLASS_SPEAKERPHONE)) {
321 "Unsupported UAC3 BADD profile\n");
325 chip->badd_profile = badd;
328 for (i = 0; i < assoc->bInterfaceCount; i++) {
329 int intf = assoc->bFirstInterface + i;
332 snd_usb_create_stream(chip, ctrlif, intf);
343 * free the chip instance
345 * here we have to do not much, since pcm and controls are already freed
349 static void snd_usb_audio_free(struct snd_card *card)
351 struct snd_usb_audio *chip = card->private_data;
352 struct snd_usb_endpoint *ep, *n;
354 list_for_each_entry_safe(ep, n, &chip->ep_list, list)
355 snd_usb_endpoint_free(ep);
357 mutex_destroy(&chip->mutex);
358 if (!atomic_read(&chip->shutdown))
359 dev_set_drvdata(&chip->dev->dev, NULL);
362 static void usb_audio_make_shortname(struct usb_device *dev,
363 struct snd_usb_audio *chip,
364 const struct snd_usb_audio_quirk *quirk)
366 struct snd_card *card = chip->card;
368 if (quirk && quirk->product_name && *quirk->product_name) {
369 strlcpy(card->shortname, quirk->product_name,
370 sizeof(card->shortname));
374 /* retrieve the device string as shortname */
375 if (!dev->descriptor.iProduct ||
376 usb_string(dev, dev->descriptor.iProduct,
377 card->shortname, sizeof(card->shortname)) <= 0) {
378 /* no name available from anywhere, so use ID */
379 sprintf(card->shortname, "USB Device %#04x:%#04x",
380 USB_ID_VENDOR(chip->usb_id),
381 USB_ID_PRODUCT(chip->usb_id));
384 strim(card->shortname);
387 static void usb_audio_make_longname(struct usb_device *dev,
388 struct snd_usb_audio *chip,
389 const struct snd_usb_audio_quirk *quirk)
391 struct snd_card *card = chip->card;
394 /* shortcut - if any pre-defined string is given, use it */
395 if (quirk && quirk->profile_name && *quirk->profile_name) {
396 strlcpy(card->longname, quirk->profile_name,
397 sizeof(card->longname));
401 if (quirk && quirk->vendor_name && *quirk->vendor_name) {
402 len = strlcpy(card->longname, quirk->vendor_name, sizeof(card->longname));
404 /* retrieve the vendor and device strings as longname */
405 if (dev->descriptor.iManufacturer)
406 len = usb_string(dev, dev->descriptor.iManufacturer,
407 card->longname, sizeof(card->longname));
410 /* we don't really care if there isn't any vendor string */
413 strim(card->longname);
415 strlcat(card->longname, " ", sizeof(card->longname));
418 strlcat(card->longname, card->shortname, sizeof(card->longname));
420 len = strlcat(card->longname, " at ", sizeof(card->longname));
422 if (len < sizeof(card->longname))
423 usb_make_path(dev, card->longname + len, sizeof(card->longname) - len);
425 switch (snd_usb_get_speed(dev)) {
427 strlcat(card->longname, ", low speed", sizeof(card->longname));
430 strlcat(card->longname, ", full speed", sizeof(card->longname));
433 strlcat(card->longname, ", high speed", sizeof(card->longname));
435 case USB_SPEED_SUPER:
436 strlcat(card->longname, ", super speed", sizeof(card->longname));
438 case USB_SPEED_SUPER_PLUS:
439 strlcat(card->longname, ", super speed plus", sizeof(card->longname));
447 * create a chip instance and set its names.
449 static int snd_usb_audio_create(struct usb_interface *intf,
450 struct usb_device *dev, int idx,
451 const struct snd_usb_audio_quirk *quirk,
453 struct snd_usb_audio **rchip)
455 struct snd_card *card;
456 struct snd_usb_audio *chip;
462 switch (snd_usb_get_speed(dev)) {
466 case USB_SPEED_WIRELESS:
467 case USB_SPEED_SUPER:
468 case USB_SPEED_SUPER_PLUS:
471 dev_err(&dev->dev, "unknown device speed %d\n", snd_usb_get_speed(dev));
475 err = snd_card_new(&intf->dev, index[idx], id[idx], THIS_MODULE,
476 sizeof(*chip), &card);
478 dev_err(&dev->dev, "cannot create card instance %d\n", idx);
482 chip = card->private_data;
483 mutex_init(&chip->mutex);
484 init_waitqueue_head(&chip->shutdown_wait);
488 chip->setup = device_setup[idx];
489 chip->autoclock = autoclock;
490 atomic_set(&chip->active, 1); /* avoid autopm during probing */
491 atomic_set(&chip->usage_count, 0);
492 atomic_set(&chip->shutdown, 0);
494 chip->usb_id = usb_id;
495 INIT_LIST_HEAD(&chip->pcm_list);
496 INIT_LIST_HEAD(&chip->ep_list);
497 INIT_LIST_HEAD(&chip->midi_list);
498 INIT_LIST_HEAD(&chip->mixer_list);
500 card->private_free = snd_usb_audio_free;
502 strcpy(card->driver, "USB-Audio");
503 sprintf(component, "USB%04x:%04x",
504 USB_ID_VENDOR(chip->usb_id), USB_ID_PRODUCT(chip->usb_id));
505 snd_component_add(card, component);
507 usb_audio_make_shortname(dev, chip, quirk);
508 usb_audio_make_longname(dev, chip, quirk);
510 snd_usb_audio_create_proc(chip);
516 /* look for a matching quirk alias id */
517 static bool get_alias_id(struct usb_device *dev, unsigned int *id)
520 unsigned int src, dst;
522 for (i = 0; i < ARRAY_SIZE(quirk_alias); i++) {
523 if (!quirk_alias[i] ||
524 sscanf(quirk_alias[i], "%x:%x", &src, &dst) != 2 ||
528 "device (%04x:%04x): applying quirk alias %04x:%04x\n",
529 USB_ID_VENDOR(*id), USB_ID_PRODUCT(*id),
530 USB_ID_VENDOR(dst), USB_ID_PRODUCT(dst));
538 static const struct usb_device_id usb_audio_ids[]; /* defined below */
540 /* look for the corresponding quirk */
541 static const struct snd_usb_audio_quirk *
542 get_alias_quirk(struct usb_device *dev, unsigned int id)
544 const struct usb_device_id *p;
546 for (p = usb_audio_ids; p->match_flags; p++) {
547 /* FIXME: this checks only vendor:product pair in the list */
548 if ((p->match_flags & USB_DEVICE_ID_MATCH_DEVICE) ==
549 USB_DEVICE_ID_MATCH_DEVICE &&
550 p->idVendor == USB_ID_VENDOR(id) &&
551 p->idProduct == USB_ID_PRODUCT(id))
552 return (const struct snd_usb_audio_quirk *)p->driver_info;
559 * probe the active usb device
561 * note that this can be called multiple times per a device, when it
562 * includes multiple audio control interfaces.
564 * thus we check the usb device pointer and creates the card instance
565 * only at the first time. the successive calls of this function will
566 * append the pcm interface to the corresponding card.
568 static int usb_audio_probe(struct usb_interface *intf,
569 const struct usb_device_id *usb_id)
571 struct usb_device *dev = interface_to_usbdev(intf);
572 const struct snd_usb_audio_quirk *quirk =
573 (const struct snd_usb_audio_quirk *)usb_id->driver_info;
574 struct snd_usb_audio *chip;
576 struct usb_host_interface *alts;
580 alts = &intf->altsetting[0];
581 ifnum = get_iface_desc(alts)->bInterfaceNumber;
582 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
583 le16_to_cpu(dev->descriptor.idProduct));
584 if (get_alias_id(dev, &id))
585 quirk = get_alias_quirk(dev, id);
586 if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum)
589 err = snd_usb_apply_boot_quirk(dev, intf, quirk, id);
594 * found a config. now register to ALSA
597 /* check whether it's already registered */
599 mutex_lock(®ister_mutex);
600 for (i = 0; i < SNDRV_CARDS; i++) {
601 if (usb_chip[i] && usb_chip[i]->dev == dev) {
602 if (atomic_read(&usb_chip[i]->shutdown)) {
603 dev_err(&dev->dev, "USB device is in the shutdown state, cannot create a card instance\n");
608 atomic_inc(&chip->active); /* avoid autopm */
614 * now look for an empty slot and create a new card instance
616 for (i = 0; i < SNDRV_CARDS; i++)
618 (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) &&
619 (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) {
621 err = snd_usb_audio_create(intf, dev, i, quirk,
625 chip->pm_intf = intf;
627 } else if (vid[i] != -1 || pid[i] != -1) {
629 "device (%04x:%04x) is disabled\n",
637 dev_err(&dev->dev, "no available usb audio device\n");
642 dev_set_drvdata(&dev->dev, chip);
645 * For devices with more than one control interface, we assume the
646 * first contains the audio controls. We might need a more specific
647 * check here in the future.
649 if (!chip->ctrl_intf)
650 chip->ctrl_intf = alts;
652 chip->txfr_quirk = 0;
653 err = 1; /* continue */
654 if (quirk && quirk->ifnum != QUIRK_NO_INTERFACE) {
655 /* need some special handlings */
656 err = snd_usb_create_quirk(chip, intf, &usb_audio_driver, quirk);
662 /* create normal USB audio interfaces */
663 err = snd_usb_create_streams(chip, ifnum);
666 err = snd_usb_create_mixer(chip, ifnum, ignore_ctl_error);
671 /* we are allowed to call snd_card_register() many times */
672 err = snd_card_register(chip->card);
676 usb_chip[chip->index] = chip;
677 chip->num_interfaces++;
678 usb_set_intfdata(intf, chip);
679 atomic_dec(&chip->active);
680 mutex_unlock(®ister_mutex);
685 if (!chip->num_interfaces)
686 snd_card_free(chip->card);
687 atomic_dec(&chip->active);
689 mutex_unlock(®ister_mutex);
694 * we need to take care of counter, since disconnection can be called also
695 * many times as well as usb_audio_probe().
697 static void usb_audio_disconnect(struct usb_interface *intf)
699 struct snd_usb_audio *chip = usb_get_intfdata(intf);
700 struct snd_card *card;
703 if (chip == (void *)-1L)
708 mutex_lock(®ister_mutex);
709 if (atomic_inc_return(&chip->shutdown) == 1) {
710 struct snd_usb_stream *as;
711 struct snd_usb_endpoint *ep;
712 struct usb_mixer_interface *mixer;
714 /* wait until all pending tasks done;
715 * they are protected by snd_usb_lock_shutdown()
717 wait_event(chip->shutdown_wait,
718 !atomic_read(&chip->usage_count));
719 snd_card_disconnect(card);
720 /* release the pcm resources */
721 list_for_each_entry(as, &chip->pcm_list, list) {
722 snd_usb_stream_disconnect(as);
724 /* release the endpoint resources */
725 list_for_each_entry(ep, &chip->ep_list, list) {
726 snd_usb_endpoint_release(ep);
728 /* release the midi resources */
729 list_for_each(p, &chip->midi_list) {
730 snd_usbmidi_disconnect(p);
732 /* release mixer resources */
733 list_for_each_entry(mixer, &chip->mixer_list, list) {
734 snd_usb_mixer_disconnect(mixer);
738 chip->num_interfaces--;
739 if (chip->num_interfaces <= 0) {
740 usb_chip[chip->index] = NULL;
741 mutex_unlock(®ister_mutex);
742 snd_card_free_when_closed(card);
744 mutex_unlock(®ister_mutex);
748 /* lock the shutdown (disconnect) task and autoresume */
749 int snd_usb_lock_shutdown(struct snd_usb_audio *chip)
753 atomic_inc(&chip->usage_count);
754 if (atomic_read(&chip->shutdown)) {
758 err = snd_usb_autoresume(chip);
764 if (atomic_dec_and_test(&chip->usage_count))
765 wake_up(&chip->shutdown_wait);
769 /* autosuspend and unlock the shutdown */
770 void snd_usb_unlock_shutdown(struct snd_usb_audio *chip)
772 snd_usb_autosuspend(chip);
773 if (atomic_dec_and_test(&chip->usage_count))
774 wake_up(&chip->shutdown_wait);
779 int snd_usb_autoresume(struct snd_usb_audio *chip)
781 if (atomic_read(&chip->shutdown))
783 if (atomic_inc_return(&chip->active) == 1)
784 return usb_autopm_get_interface(chip->pm_intf);
788 void snd_usb_autosuspend(struct snd_usb_audio *chip)
790 if (atomic_read(&chip->shutdown))
792 if (atomic_dec_and_test(&chip->active))
793 usb_autopm_put_interface(chip->pm_intf);
796 static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
798 struct snd_usb_audio *chip = usb_get_intfdata(intf);
799 struct snd_usb_stream *as;
800 struct usb_mixer_interface *mixer;
803 if (chip == (void *)-1L)
806 chip->autosuspended = !!PMSG_IS_AUTO(message);
807 if (!chip->autosuspended)
808 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
809 if (!chip->num_suspended_intf++) {
810 list_for_each_entry(as, &chip->pcm_list, list) {
811 snd_pcm_suspend_all(as->pcm);
812 snd_usb_pcm_suspend(as);
813 as->substream[0].need_setup_ep =
814 as->substream[1].need_setup_ep = true;
816 list_for_each(p, &chip->midi_list)
817 snd_usbmidi_suspend(p);
818 list_for_each_entry(mixer, &chip->mixer_list, list)
819 snd_usb_mixer_suspend(mixer);
825 static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume)
827 struct snd_usb_audio *chip = usb_get_intfdata(intf);
828 struct snd_usb_stream *as;
829 struct usb_mixer_interface *mixer;
833 if (chip == (void *)-1L)
835 if (--chip->num_suspended_intf)
838 atomic_inc(&chip->active); /* avoid autopm */
840 list_for_each_entry(as, &chip->pcm_list, list) {
841 err = snd_usb_pcm_resume(as);
847 * ALSA leaves material resumption to user space
848 * we just notify and restart the mixers
850 list_for_each_entry(mixer, &chip->mixer_list, list) {
851 err = snd_usb_mixer_resume(mixer, reset_resume);
856 list_for_each(p, &chip->midi_list) {
857 snd_usbmidi_resume(p);
860 if (!chip->autosuspended)
861 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
862 chip->autosuspended = 0;
865 atomic_dec(&chip->active); /* allow autopm after this point */
869 static int usb_audio_resume(struct usb_interface *intf)
871 return __usb_audio_resume(intf, false);
874 static int usb_audio_reset_resume(struct usb_interface *intf)
876 return __usb_audio_resume(intf, true);
879 #define usb_audio_suspend NULL
880 #define usb_audio_resume NULL
881 #define usb_audio_reset_resume NULL
882 #endif /* CONFIG_PM */
884 static const struct usb_device_id usb_audio_ids [] = {
885 #include "quirks-table.h"
886 { .match_flags = (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS),
887 .bInterfaceClass = USB_CLASS_AUDIO,
888 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL },
889 { } /* Terminating entry */
891 MODULE_DEVICE_TABLE(usb, usb_audio_ids);
894 * entry point for linux usb interface
897 static struct usb_driver usb_audio_driver = {
898 .name = "snd-usb-audio",
899 .probe = usb_audio_probe,
900 .disconnect = usb_audio_disconnect,
901 .suspend = usb_audio_suspend,
902 .resume = usb_audio_resume,
903 .reset_resume = usb_audio_reset_resume,
904 .id_table = usb_audio_ids,
905 .supports_autosuspend = 1,
908 module_usb_driver(usb_audio_driver);