Lines Matching +full:accessory +full:- +full:mode +full:- +full:audio
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * (Tentative) USB Audio Driver for ALSA
7 * Many codes borrowed from audio.c by
11 * Audio Class 3.0 support by Ruslan Bilovol <ruslan.bilovol@gmail.com>
15 * - the linked URBs would be preferred but not used so far because of
17 * - type II is not supported properly. there is no device which supports
32 #include <linux/usb/audio.h>
33 #include <linux/usb/audio-v2.h>
34 #include <linux/usb/audio-v3.h>
60 MODULE_DESCRIPTION("USB Audio");
63 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
67 static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
68 static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
82 MODULE_PARM_DESC(index, "Index value for the USB audio adapter.");
84 MODULE_PARM_DESC(id, "ID string for the USB audio adapter.");
86 MODULE_PARM_DESC(enable, "Enable USB audio adapter.");
88 MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device.");
90 MODULE_PARM_DESC(pid, "Product ID for the USB audio device.");
97 MODULE_PARM_DESC(autoclock, "Enable auto-clock selection for UAC2 devices (default: yes).");
105 MODULE_PARM_DESC(implicit_fb, "Apply generic implicit feedback sync mode.");
132 subs = &as->substream[idx]; in snd_usb_stream_disconnect()
133 if (!subs->num_formats) in snd_usb_stream_disconnect()
135 subs->data_endpoint = NULL; in snd_usb_stream_disconnect()
136 subs->sync_endpoint = NULL; in snd_usb_stream_disconnect()
142 struct usb_device *dev = chip->dev; in snd_usb_create_stream()
148 dev_err(&dev->dev, "%u:%d : does not exist\n", in snd_usb_create_stream()
150 return -EINVAL; in snd_usb_create_stream()
153 alts = &iface->altsetting[0]; in snd_usb_create_stream()
157 * Android with both accessory and audio interfaces enabled gets the in snd_usb_create_stream()
160 if ((chip->usb_id == USB_ID(0x18d1, 0x2d04) || in snd_usb_create_stream()
161 chip->usb_id == USB_ID(0x18d1, 0x2d05)) && in snd_usb_create_stream()
163 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC && in snd_usb_create_stream()
164 altsd->bInterfaceSubClass == USB_SUBCLASS_VENDOR_SPEC) { in snd_usb_create_stream()
168 return -EINVAL; in snd_usb_create_stream()
169 alts = &iface->altsetting[0]; in snd_usb_create_stream()
174 dev_dbg(&dev->dev, "%d:%d: skipping, already claimed\n", in snd_usb_create_stream()
176 return -EINVAL; in snd_usb_create_stream()
179 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || in snd_usb_create_stream()
180 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && in snd_usb_create_stream()
181 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) { in snd_usb_create_stream()
183 chip->usb_id); in snd_usb_create_stream()
185 dev_err(&dev->dev, in snd_usb_create_stream()
188 return -EINVAL; in snd_usb_create_stream()
194 if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && in snd_usb_create_stream()
195 altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || in snd_usb_create_stream()
196 altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING) { in snd_usb_create_stream()
197 dev_dbg(&dev->dev, in snd_usb_create_stream()
198 "%u:%d: skipping non-supported interface %d\n", in snd_usb_create_stream()
199 ctrlif, interface, altsd->bInterfaceClass); in snd_usb_create_stream()
200 /* skip non-supported classes */ in snd_usb_create_stream()
201 return -EINVAL; in snd_usb_create_stream()
205 dev_err(&dev->dev, "low speed audio streaming not supported\n"); in snd_usb_create_stream()
206 return -EINVAL; in snd_usb_create_stream()
221 * parse audio control descriptor and create pcm/midi streams
225 struct usb_device *dev = chip->dev; in snd_usb_create_streams()
231 host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0]; in snd_usb_create_streams()
233 protocol = altsd->bInterfaceProtocol; in snd_usb_create_streams()
237 dev_warn(&dev->dev, in snd_usb_create_streams()
246 h1 = snd_usb_find_csint_desc(host_iface->extra, in snd_usb_create_streams()
247 host_iface->extralen, in snd_usb_create_streams()
249 if (!h1 || h1->bLength < sizeof(*h1)) { in snd_usb_create_streams()
250 dev_err(&dev->dev, "cannot find UAC_HEADER\n"); in snd_usb_create_streams()
251 return -EINVAL; in snd_usb_create_streams()
254 rest_bytes = (void *)(host_iface->extra + in snd_usb_create_streams()
255 host_iface->extralen) - (void *)h1; in snd_usb_create_streams()
257 /* just to be sure -- this shouldn't hit at all */ in snd_usb_create_streams()
259 dev_err(&dev->dev, "invalid control header\n"); in snd_usb_create_streams()
260 return -EINVAL; in snd_usb_create_streams()
264 dev_err(&dev->dev, "too short v1 buffer descriptor\n"); in snd_usb_create_streams()
265 return -EINVAL; in snd_usb_create_streams()
268 if (!h1->bInCollection) { in snd_usb_create_streams()
269 dev_info(&dev->dev, "skipping empty audio interface (v1)\n"); in snd_usb_create_streams()
270 return -EINVAL; in snd_usb_create_streams()
273 if (rest_bytes < h1->bLength) { in snd_usb_create_streams()
274 dev_err(&dev->dev, "invalid buffer length (v1)\n"); in snd_usb_create_streams()
275 return -EINVAL; in snd_usb_create_streams()
278 if (h1->bLength < sizeof(*h1) + h1->bInCollection) { in snd_usb_create_streams()
279 dev_err(&dev->dev, "invalid UAC_HEADER (v1)\n"); in snd_usb_create_streams()
280 return -EINVAL; in snd_usb_create_streams()
283 for (i = 0; i < h1->bInCollection; i++) in snd_usb_create_streams()
284 snd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]); in snd_usb_create_streams()
292 usb_ifnum_to_if(dev, ctrlif)->intf_assoc; in snd_usb_create_streams()
297 * the IAD on the NuForce UDH-100, also check the next in snd_usb_create_streams()
303 iface->intf_assoc && in snd_usb_create_streams()
304 iface->intf_assoc->bFunctionClass == USB_CLASS_AUDIO && in snd_usb_create_streams()
305 iface->intf_assoc->bFunctionProtocol == UAC_VERSION_2) in snd_usb_create_streams()
306 assoc = iface->intf_assoc; in snd_usb_create_streams()
310 dev_err(&dev->dev, "Audio class v2/v3 interfaces need an interface association\n"); in snd_usb_create_streams()
311 return -EINVAL; in snd_usb_create_streams()
315 int badd = assoc->bFunctionSubClass; in snd_usb_create_streams()
320 dev_err(&dev->dev, in snd_usb_create_streams()
322 return -EINVAL; in snd_usb_create_streams()
325 chip->badd_profile = badd; in snd_usb_create_streams()
328 for (i = 0; i < assoc->bInterfaceCount; i++) { in snd_usb_create_streams()
329 int intf = assoc->bFirstInterface + i; in snd_usb_create_streams()
349 const char *profile_name; /* override card->longname */
360 /* HP Thunderbolt Dock Audio Headset */
361 PROFILE_NAME(0x03f0, 0x0269, "HP", "Thunderbolt Dock Audio Headset",
362 "HP-Thunderbolt-Dock-Audio-Headset"),
363 /* HP Thunderbolt Dock Audio Module */
364 PROFILE_NAME(0x03f0, 0x0567, "HP", "Thunderbolt Dock Audio Module",
365 "HP-Thunderbolt-Dock-Audio-Module"),
368 * TRX40 Aorus Master has two USB-audio devices, one for the front
370 * I/O (the rear panel and the front mic) with Realtek ALC1220-VB.
374 "Gigabyte-Aorus-Master-Front-Headphone"),
375 PROFILE_NAME(0x0414, 0xa001, "Gigabyte", "Aorus Master Main Audio",
376 "Gigabyte-Aorus-Master-Main-Audio"),
380 "Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"),
382 /* Creative/E-Mu devices */
384 /* Creative/Toshiba Multimedia Center SB-0500 */
385 DEVICE_NAME(0x041e, 0x3048, "Toshiba", "SB-0500"),
387 /* Logitech Audio Devices */
388 DEVICE_NAME(0x046d, 0x0867, "Logitech, Inc.", "Logi-MeetUp"),
389 DEVICE_NAME(0x046d, 0x0874, "Logitech, Inc.", "Logi-Tap-Audio"),
390 DEVICE_NAME(0x046d, 0x087c, "Logitech, Inc.", "Logi-Huddle"),
391 DEVICE_NAME(0x046d, 0x0898, "Logitech, Inc.", "Logi-RB-Audio"),
392 DEVICE_NAME(0x046d, 0x08d2, "Logitech, Inc.", "Logi-RBM-Audio"),
402 "Zenith-II-Front-Headphone"),
403 PROFILE_NAME(0x0b05, 0x1916, "ASUS", "Zenith II Main Audio",
404 "Zenith-II-Main-Audio"),
408 "Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"),
409 /* ASUS PRIME TRX40 PRO-S */
411 "Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"),
414 PROFILE_NAME(0x0bda, 0x4014, "Dell", "WD15 Dock", "Dell-WD15-Dock"),
416 PROFILE_NAME(0x0bda, 0x402e, "Dell", "WD19 Dock", "Dell-WD15-Dock"),
425 DEVICE_NAME(0x0d8c, 0x0103, NULL, "Audio Advantage MicroII"),
429 "Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"),
432 "Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"),
434 DEVICE_NAME(0x0fd9, 0x0008, "Hauppauge", "HVR-950Q"),
438 "HP-Engage-Go-Dock"),
445 DEVICE_NAME(0x13e5, 0x0001, "Rane", "SL-1"),
447 /* Lenovo ThinkStation P620 Rear Line-in, Line-out and Microphone */
449 "Lenovo-ThinkStation-P620-Rear"),
452 "Lenovo-ThinkStation-P620-Main"),
456 "Realtek", "ALC1220-VB-DT", "Realtek-ALC1220-VB-Desktop"),
458 DEVICE_NAME(0x2040, 0x7200, "Hauppauge", "HVR-950Q"),
459 DEVICE_NAME(0x2040, 0x7201, "Hauppauge", "HVR-950Q-MXL"),
460 DEVICE_NAME(0x2040, 0x7210, "Hauppauge", "HVR-950Q"),
461 DEVICE_NAME(0x2040, 0x7211, "Hauppauge", "HVR-950Q-MXL"),
462 DEVICE_NAME(0x2040, 0x7213, "Hauppauge", "HVR-950Q"),
463 DEVICE_NAME(0x2040, 0x7217, "Hauppauge", "HVR-950Q"),
464 DEVICE_NAME(0x2040, 0x721b, "Hauppauge", "HVR-950Q"),
465 DEVICE_NAME(0x2040, 0x721e, "Hauppauge", "HVR-950Q"),
466 DEVICE_NAME(0x2040, 0x721f, "Hauppauge", "HVR-950Q"),
467 DEVICE_NAME(0x2040, 0x7240, "Hauppauge", "HVR-850"),
468 DEVICE_NAME(0x2040, 0x7260, "Hauppauge", "HVR-950Q"),
469 DEVICE_NAME(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
470 DEVICE_NAME(0x2040, 0x7280, "Hauppauge", "HVR-950Q"),
471 DEVICE_NAME(0x2040, 0x7281, "Hauppauge", "HVR-950Q-MXL"),
482 for (p = usb_audio_names; p->id; p++) in lookup_device_name()
483 if (p->id == id) in lookup_device_name()
497 struct snd_usb_audio *chip = card->private_data; in snd_usb_audio_free()
502 mutex_destroy(&chip->mutex); in snd_usb_audio_free()
503 if (!atomic_read(&chip->shutdown)) in snd_usb_audio_free()
504 dev_set_drvdata(&chip->dev->dev, NULL); in snd_usb_audio_free()
511 struct snd_card *card = chip->card; in usb_audio_make_shortname()
515 preset = lookup_device_name(chip->usb_id); in usb_audio_make_shortname()
516 if (preset && preset->product_name) in usb_audio_make_shortname()
517 s = preset->product_name; in usb_audio_make_shortname()
518 else if (quirk && quirk->product_name) in usb_audio_make_shortname()
519 s = quirk->product_name; in usb_audio_make_shortname()
521 strscpy(card->shortname, s, sizeof(card->shortname)); in usb_audio_make_shortname()
526 if (!dev->descriptor.iProduct || in usb_audio_make_shortname()
527 usb_string(dev, dev->descriptor.iProduct, in usb_audio_make_shortname()
528 card->shortname, sizeof(card->shortname)) <= 0) { in usb_audio_make_shortname()
530 sprintf(card->shortname, "USB Device %#04x:%#04x", in usb_audio_make_shortname()
531 USB_ID_VENDOR(chip->usb_id), in usb_audio_make_shortname()
532 USB_ID_PRODUCT(chip->usb_id)); in usb_audio_make_shortname()
535 strim(card->shortname); in usb_audio_make_shortname()
542 struct snd_card *card = chip->card; in usb_audio_make_longname()
547 preset = lookup_device_name(chip->usb_id); in usb_audio_make_longname()
549 /* shortcut - if any pre-defined string is given, use it */ in usb_audio_make_longname()
550 if (preset && preset->profile_name) in usb_audio_make_longname()
551 s = preset->profile_name; in usb_audio_make_longname()
553 strscpy(card->longname, s, sizeof(card->longname)); in usb_audio_make_longname()
557 if (preset && preset->vendor_name) in usb_audio_make_longname()
558 s = preset->vendor_name; in usb_audio_make_longname()
559 else if (quirk && quirk->vendor_name) in usb_audio_make_longname()
560 s = quirk->vendor_name; in usb_audio_make_longname()
561 *card->longname = 0; in usb_audio_make_longname()
563 strscpy(card->longname, s, sizeof(card->longname)); in usb_audio_make_longname()
566 if (dev->descriptor.iManufacturer) in usb_audio_make_longname()
567 usb_string(dev, dev->descriptor.iManufacturer, in usb_audio_make_longname()
568 card->longname, sizeof(card->longname)); in usb_audio_make_longname()
571 if (*card->longname) { in usb_audio_make_longname()
572 strim(card->longname); in usb_audio_make_longname()
573 if (*card->longname) in usb_audio_make_longname()
574 strlcat(card->longname, " ", sizeof(card->longname)); in usb_audio_make_longname()
577 strlcat(card->longname, card->shortname, sizeof(card->longname)); in usb_audio_make_longname()
579 len = strlcat(card->longname, " at ", sizeof(card->longname)); in usb_audio_make_longname()
581 if (len < sizeof(card->longname)) in usb_audio_make_longname()
582 usb_make_path(dev, card->longname + len, sizeof(card->longname) - len); in usb_audio_make_longname()
586 strlcat(card->longname, ", low speed", sizeof(card->longname)); in usb_audio_make_longname()
589 strlcat(card->longname, ", full speed", sizeof(card->longname)); in usb_audio_make_longname()
592 strlcat(card->longname, ", high speed", sizeof(card->longname)); in usb_audio_make_longname()
595 strlcat(card->longname, ", super speed", sizeof(card->longname)); in usb_audio_make_longname()
598 strlcat(card->longname, ", super speed plus", sizeof(card->longname)); in usb_audio_make_longname()
629 dev_err(&dev->dev, "unknown device speed %d\n", snd_usb_get_speed(dev)); in snd_usb_audio_create()
630 return -ENXIO; in snd_usb_audio_create()
633 err = snd_card_new(&intf->dev, index[idx], id[idx], THIS_MODULE, in snd_usb_audio_create()
636 dev_err(&dev->dev, "cannot create card instance %d\n", idx); in snd_usb_audio_create()
640 chip = card->private_data; in snd_usb_audio_create()
641 mutex_init(&chip->mutex); in snd_usb_audio_create()
642 init_waitqueue_head(&chip->shutdown_wait); in snd_usb_audio_create()
643 chip->index = idx; in snd_usb_audio_create()
644 chip->dev = dev; in snd_usb_audio_create()
645 chip->card = card; in snd_usb_audio_create()
646 chip->setup = device_setup[idx]; in snd_usb_audio_create()
647 chip->generic_implicit_fb = implicit_fb[idx]; in snd_usb_audio_create()
648 chip->autoclock = autoclock; in snd_usb_audio_create()
649 chip->lowlatency = lowlatency; in snd_usb_audio_create()
650 atomic_set(&chip->active, 1); /* avoid autopm during probing */ in snd_usb_audio_create()
651 atomic_set(&chip->usage_count, 0); in snd_usb_audio_create()
652 atomic_set(&chip->shutdown, 0); in snd_usb_audio_create()
654 chip->usb_id = usb_id; in snd_usb_audio_create()
655 INIT_LIST_HEAD(&chip->pcm_list); in snd_usb_audio_create()
656 INIT_LIST_HEAD(&chip->ep_list); in snd_usb_audio_create()
657 INIT_LIST_HEAD(&chip->iface_ref_list); in snd_usb_audio_create()
658 INIT_LIST_HEAD(&chip->clock_ref_list); in snd_usb_audio_create()
659 INIT_LIST_HEAD(&chip->midi_list); in snd_usb_audio_create()
660 INIT_LIST_HEAD(&chip->midi_v2_list); in snd_usb_audio_create()
661 INIT_LIST_HEAD(&chip->mixer_list); in snd_usb_audio_create()
664 chip->quirk_flags = quirk_flags[idx]; in snd_usb_audio_create()
668 card->private_free = snd_usb_audio_free; in snd_usb_audio_create()
670 strcpy(card->driver, "USB-Audio"); in snd_usb_audio_create()
672 USB_ID_VENDOR(chip->usb_id), USB_ID_PRODUCT(chip->usb_id)); in snd_usb_audio_create()
695 dev_info(&dev->dev, in get_alias_id()
714 id == chip->usb_id) in check_delayed_register_option()
718 return -1; in check_delayed_register_option()
726 struct usb_host_config *config = chip->dev->actconfig; in find_last_interface()
732 for (i = 0; i < config->desc.bNumInterfaces; i++) { in find_last_interface()
733 intf = config->interface[i]; in find_last_interface()
735 chip->last_iface = intf->altsetting[0].desc.bInterfaceNumber; in find_last_interface()
737 usb_audio_dbg(chip, "Found last interface = %d\n", chip->last_iface); in find_last_interface()
746 for (p = usb_audio_ids; p->match_flags; p++) { in get_alias_quirk()
748 if ((p->match_flags & USB_DEVICE_ID_MATCH_DEVICE) == in get_alias_quirk()
750 p->idVendor == USB_ID_VENDOR(id) && in get_alias_quirk()
751 p->idProduct == USB_ID_PRODUCT(id)) in get_alias_quirk()
752 return (const struct snd_usb_audio_quirk *)p->driver_info; in get_alias_quirk()
764 chip->last_iface == ifnum || in try_to_register_card()
765 usb_interface_claimed(usb_ifnum_to_if(chip->dev, chip->last_iface))) in try_to_register_card()
766 return snd_card_register(chip->card); in try_to_register_card()
774 * includes multiple audio control interfaces.
785 (const struct snd_usb_audio_quirk *)usb_id->driver_info; in usb_audio_probe()
792 alts = &intf->altsetting[0]; in usb_audio_probe()
793 ifnum = get_iface_desc(alts)->bInterfaceNumber; in usb_audio_probe()
794 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor), in usb_audio_probe()
795 le16_to_cpu(dev->descriptor.idProduct)); in usb_audio_probe()
798 if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum) in usb_audio_probe()
799 return -ENXIO; in usb_audio_probe()
800 if (quirk && quirk->ifnum == QUIRK_NODEV_INTERFACE) in usb_audio_probe()
801 return -ENODEV; in usb_audio_probe()
815 if (usb_chip[i] && usb_chip[i]->dev == dev) { in usb_audio_probe()
816 if (atomic_read(&usb_chip[i]->shutdown)) { in usb_audio_probe()
817 dev_err(&dev->dev, "USB device is in the shutdown state, cannot create a card instance\n"); in usb_audio_probe()
818 err = -EIO; in usb_audio_probe()
822 atomic_inc(&chip->active); /* avoid autopm */ in usb_audio_probe()
836 (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) && in usb_audio_probe()
837 (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) { in usb_audio_probe()
844 } else if (vid[i] != -1 || pid[i] != -1) { in usb_audio_probe()
845 dev_info(&dev->dev, in usb_audio_probe()
849 err = -ENOENT; in usb_audio_probe()
854 dev_err(&dev->dev, "no available usb audio device\n"); in usb_audio_probe()
855 err = -ENODEV; in usb_audio_probe()
861 if (chip->num_interfaces >= MAX_CARD_INTERFACES) { in usb_audio_probe()
862 dev_info(&dev->dev, "Too many interfaces assigned to the single USB-audio card\n"); in usb_audio_probe()
863 err = -EINVAL; in usb_audio_probe()
867 dev_set_drvdata(&dev->dev, chip); in usb_audio_probe()
870 chip->quirk_flags |= QUIRK_FLAG_IGNORE_CTL_ERROR; in usb_audio_probe()
872 if (chip->quirk_flags & QUIRK_FLAG_DISABLE_AUTOSUSPEND) in usb_audio_probe()
877 * first contains the audio controls. We might need a more specific in usb_audio_probe()
880 if (!chip->ctrl_intf) in usb_audio_probe()
881 chip->ctrl_intf = alts; in usb_audio_probe()
884 if (quirk && quirk->ifnum != QUIRK_NO_INTERFACE) { in usb_audio_probe()
892 /* create normal USB audio interfaces */ in usb_audio_probe()
901 if (chip->need_delayed_register) { in usb_audio_probe()
902 dev_info(&dev->dev, in usb_audio_probe()
903 "Found post-registration device assignment: %08x:%02x\n", in usb_audio_probe()
904 chip->usb_id, ifnum); in usb_audio_probe()
905 chip->need_delayed_register = false; /* clear again */ in usb_audio_probe()
912 if (chip->quirk_flags & QUIRK_FLAG_SHARE_MEDIA_DEVICE) { in usb_audio_probe()
918 chip->quirk_type = quirk->type; in usb_audio_probe()
920 usb_chip[chip->index] = chip; in usb_audio_probe()
921 chip->intf[chip->num_interfaces] = intf; in usb_audio_probe()
922 chip->num_interfaces++; in usb_audio_probe()
924 atomic_dec(&chip->active); in usb_audio_probe()
935 /* chip->active is inside the chip->card object, in usb_audio_probe()
938 atomic_dec(&chip->active); in usb_audio_probe()
939 if (!chip->num_interfaces) in usb_audio_probe()
940 snd_card_free(chip->card); in usb_audio_probe()
959 card = chip->card; in usb_audio_disconnect()
962 if (atomic_inc_return(&chip->shutdown) == 1) { in usb_audio_disconnect()
970 wait_event(chip->shutdown_wait, in usb_audio_disconnect()
971 !atomic_read(&chip->usage_count)); in usb_audio_disconnect()
974 list_for_each_entry(as, &chip->pcm_list, list) { in usb_audio_disconnect()
978 list_for_each_entry(ep, &chip->ep_list, list) { in usb_audio_disconnect()
982 list_for_each(p, &chip->midi_list) { in usb_audio_disconnect()
987 * Nice to check quirk && quirk->shares_media_device and in usb_audio_disconnect()
995 list_for_each_entry(mixer, &chip->mixer_list, list) { in usb_audio_disconnect()
1000 if (chip->quirk_flags & QUIRK_FLAG_DISABLE_AUTOSUSPEND) in usb_audio_disconnect()
1003 chip->num_interfaces--; in usb_audio_disconnect()
1004 if (chip->num_interfaces <= 0) { in usb_audio_disconnect()
1005 usb_chip[chip->index] = NULL; in usb_audio_disconnect()
1018 atomic_inc(&chip->usage_count); in snd_usb_lock_shutdown()
1019 if (atomic_read(&chip->shutdown)) { in snd_usb_lock_shutdown()
1020 err = -EIO; in snd_usb_lock_shutdown()
1029 if (atomic_dec_and_test(&chip->usage_count)) in snd_usb_lock_shutdown()
1030 wake_up(&chip->shutdown_wait); in snd_usb_lock_shutdown()
1038 if (atomic_dec_and_test(&chip->usage_count)) in snd_usb_unlock_shutdown()
1039 wake_up(&chip->shutdown_wait); in snd_usb_unlock_shutdown()
1046 if (atomic_read(&chip->shutdown)) in snd_usb_autoresume()
1047 return -EIO; in snd_usb_autoresume()
1048 if (atomic_inc_return(&chip->active) != 1) in snd_usb_autoresume()
1051 for (i = 0; i < chip->num_interfaces; i++) { in snd_usb_autoresume()
1052 err = usb_autopm_get_interface(chip->intf[i]); in snd_usb_autoresume()
1055 while (--i >= 0) in snd_usb_autoresume()
1056 usb_autopm_put_interface(chip->intf[i]); in snd_usb_autoresume()
1057 atomic_dec(&chip->active); in snd_usb_autoresume()
1068 if (atomic_read(&chip->shutdown)) in snd_usb_autosuspend()
1070 if (!atomic_dec_and_test(&chip->active)) in snd_usb_autosuspend()
1073 for (i = 0; i < chip->num_interfaces; i++) in snd_usb_autosuspend()
1074 usb_autopm_put_interface(chip->intf[i]); in snd_usb_autosuspend()
1088 if (!chip->num_suspended_intf++) { in usb_audio_suspend()
1089 list_for_each_entry(as, &chip->pcm_list, list) in usb_audio_suspend()
1091 list_for_each_entry(ep, &chip->ep_list, list) in usb_audio_suspend()
1093 list_for_each(p, &chip->midi_list) in usb_audio_suspend()
1095 list_for_each_entry(mixer, &chip->mixer_list, list) in usb_audio_suspend()
1100 if (!PMSG_IS_AUTO(message) && !chip->system_suspend) { in usb_audio_suspend()
1101 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); in usb_audio_suspend()
1102 chip->system_suspend = chip->num_suspended_intf; in usb_audio_suspend()
1119 atomic_inc(&chip->active); /* avoid autopm */ in usb_audio_resume()
1120 if (chip->num_suspended_intf > 1) in usb_audio_resume()
1123 list_for_each_entry(as, &chip->pcm_list, list) { in usb_audio_resume()
1133 list_for_each_entry(mixer, &chip->mixer_list, list) { in usb_audio_resume()
1139 list_for_each(p, &chip->midi_list) { in usb_audio_resume()
1146 if (chip->num_suspended_intf == chip->system_suspend) { in usb_audio_resume()
1147 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); in usb_audio_resume()
1148 chip->system_suspend = 0; in usb_audio_resume()
1150 chip->num_suspended_intf--; in usb_audio_resume()
1153 atomic_dec(&chip->active); /* allow autopm after this point */ in usb_audio_resume()
1158 #include "quirks-table.h"
1171 .name = "snd-usb-audio",