Lines Matching refs:chip
140 static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int interface)
142 struct usb_device *dev = chip->dev;
160 if ((chip->usb_id == USB_ID(0x18d1, 0x2d04) ||
161 chip->usb_id == USB_ID(0x18d1, 0x2d05)) &&
182 int err = snd_usb_midi_v2_create(chip, iface, NULL,
183 chip->usb_id);
209 if (! snd_usb_parse_audio_interface(chip, interface)) {
221 static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
223 struct usb_device *dev = chip->dev;
282 snd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]);
323 chip->badd_profile = badd;
330 snd_usb_create_stream(chip, ctrlif, intf);
367 * headphone with ESS SABRE9218 DAC chip, while another for the rest
477 * free the chip instance
485 struct snd_usb_audio *chip = card->private_data;
487 snd_usb_endpoint_free_all(chip);
488 snd_usb_midi_v2_free_all(chip);
490 mutex_destroy(&chip->mutex);
491 if (!atomic_read(&chip->shutdown))
492 dev_set_drvdata(&chip->dev->dev, NULL);
496 struct snd_usb_audio *chip,
499 struct snd_card *card = chip->card;
503 preset = lookup_device_name(chip->usb_id);
519 USB_ID_VENDOR(chip->usb_id),
520 USB_ID_PRODUCT(chip->usb_id));
527 struct snd_usb_audio *chip,
530 struct snd_card *card = chip->card;
535 preset = lookup_device_name(chip->usb_id);
594 * create a chip instance and set its names.
603 struct snd_usb_audio *chip;
622 sizeof(*chip), &card);
628 chip = card->private_data;
629 mutex_init(&chip->mutex);
630 init_waitqueue_head(&chip->shutdown_wait);
631 chip->index = idx;
632 chip->dev = dev;
633 chip->card = card;
634 chip->setup = device_setup[idx];
635 chip->generic_implicit_fb = implicit_fb[idx];
636 chip->autoclock = autoclock;
637 chip->lowlatency = lowlatency;
638 atomic_set(&chip->active, 1); /* avoid autopm during probing */
639 atomic_set(&chip->usage_count, 0);
640 atomic_set(&chip->shutdown, 0);
642 chip->usb_id = usb_id;
643 INIT_LIST_HEAD(&chip->pcm_list);
644 INIT_LIST_HEAD(&chip->ep_list);
645 INIT_LIST_HEAD(&chip->iface_ref_list);
646 INIT_LIST_HEAD(&chip->clock_ref_list);
647 INIT_LIST_HEAD(&chip->midi_list);
648 INIT_LIST_HEAD(&chip->midi_v2_list);
649 INIT_LIST_HEAD(&chip->mixer_list);
652 chip->quirk_flags = quirk_flags[idx];
654 snd_usb_init_quirk_flags(chip);
660 USB_ID_VENDOR(chip->usb_id), USB_ID_PRODUCT(chip->usb_id));
663 usb_audio_make_shortname(dev, chip, quirk);
664 usb_audio_make_longname(dev, chip, quirk);
666 snd_usb_audio_create_proc(chip);
668 *rchip = chip;
694 static int check_delayed_register_option(struct snd_usb_audio *chip)
702 id == chip->usb_id)
712 static void find_last_interface(struct snd_usb_audio *chip)
714 struct usb_host_config *config = chip->dev->actconfig;
723 chip->last_iface = intf->altsetting[0].desc.bInterfaceNumber;
725 usb_audio_dbg(chip, "Found last interface = %d\n", chip->last_iface);
749 static int try_to_register_card(struct snd_usb_audio *chip, int ifnum)
751 if (check_delayed_register_option(chip) == ifnum ||
752 chip->last_iface == ifnum ||
753 usb_interface_claimed(usb_ifnum_to_if(chip->dev, chip->last_iface)))
754 return snd_card_register(chip->card);
774 struct snd_usb_audio *chip;
800 chip = NULL;
809 chip = usb_chip[i];
810 atomic_inc(&chip->active); /* avoid autopm */
814 if (! chip) {
828 id, &chip);
841 if (!chip) {
846 find_last_interface(chip);
849 if (chip->num_interfaces >= MAX_CARD_INTERFACES) {
855 dev_set_drvdata(&dev->dev, chip);
858 chip->quirk_flags |= QUIRK_FLAG_IGNORE_CTL_ERROR;
860 if (chip->quirk_flags & QUIRK_FLAG_DISABLE_AUTOSUSPEND)
868 if (!chip->ctrl_intf)
869 chip->ctrl_intf = alts;
874 err = snd_usb_create_quirk(chip, intf, &usb_audio_driver, quirk);
881 err = snd_usb_create_streams(chip, ifnum);
884 err = snd_usb_create_mixer(chip, ifnum);
889 if (chip->need_delayed_register) {
892 chip->usb_id, ifnum);
893 chip->need_delayed_register = false; /* clear again */
896 err = try_to_register_card(chip, ifnum);
900 if (chip->quirk_flags & QUIRK_FLAG_SHARE_MEDIA_DEVICE) {
902 snd_media_device_create(chip, intf);
906 chip->quirk_type = quirk->type;
908 usb_chip[chip->index] = chip;
909 chip->intf[chip->num_interfaces] = intf;
910 chip->num_interfaces++;
911 usb_set_intfdata(intf, chip);
912 atomic_dec(&chip->active);
918 if (chip)
919 try_to_register_card(chip, ifnum);
922 if (chip) {
923 /* chip->active is inside the chip->card object,
926 atomic_dec(&chip->active);
927 if (!chip->num_interfaces)
928 snd_card_free(chip->card);
940 struct snd_usb_audio *chip = usb_get_intfdata(intf);
944 if (chip == USB_AUDIO_IFACE_UNUSED)
947 card = chip->card;
950 if (atomic_inc_return(&chip->shutdown) == 1) {
958 wait_event(chip->shutdown_wait,
959 !atomic_read(&chip->usage_count));
962 list_for_each_entry(as, &chip->pcm_list, list) {
966 list_for_each_entry(ep, &chip->ep_list, list) {
970 list_for_each(p, &chip->midi_list) {
973 snd_usb_midi_v2_disconnect_all(chip);
980 snd_media_device_delete(chip);
983 list_for_each_entry(mixer, &chip->mixer_list, list) {
988 if (chip->quirk_flags & QUIRK_FLAG_DISABLE_AUTOSUSPEND)
991 chip->num_interfaces--;
992 if (chip->num_interfaces <= 0) {
993 usb_chip[chip->index] = NULL;
1002 int snd_usb_lock_shutdown(struct snd_usb_audio *chip)
1006 atomic_inc(&chip->usage_count);
1007 if (atomic_read(&chip->shutdown)) {
1011 err = snd_usb_autoresume(chip);
1017 if (atomic_dec_and_test(&chip->usage_count))
1018 wake_up(&chip->shutdown_wait);
1023 void snd_usb_unlock_shutdown(struct snd_usb_audio *chip)
1025 snd_usb_autosuspend(chip);
1026 if (atomic_dec_and_test(&chip->usage_count))
1027 wake_up(&chip->shutdown_wait);
1030 int snd_usb_autoresume(struct snd_usb_audio *chip)
1034 if (atomic_read(&chip->shutdown))
1036 if (atomic_inc_return(&chip->active) != 1)
1039 for (i = 0; i < chip->num_interfaces; i++) {
1040 err = usb_autopm_get_interface(chip->intf[i]);
1044 usb_autopm_put_interface(chip->intf[i]);
1045 atomic_dec(&chip->active);
1052 void snd_usb_autosuspend(struct snd_usb_audio *chip)
1056 if (atomic_read(&chip->shutdown))
1058 if (!atomic_dec_and_test(&chip->active))
1061 for (i = 0; i < chip->num_interfaces; i++)
1062 usb_autopm_put_interface(chip->intf[i]);
1067 struct snd_usb_audio *chip = usb_get_intfdata(intf);
1073 if (chip == USB_AUDIO_IFACE_UNUSED)
1076 if (!chip->num_suspended_intf++) {
1077 list_for_each_entry(as, &chip->pcm_list, list)
1079 list_for_each_entry(ep, &chip->ep_list, list)
1081 list_for_each(p, &chip->midi_list)
1083 list_for_each_entry(mixer, &chip->mixer_list, list)
1085 snd_usb_midi_v2_suspend_all(chip);
1088 if (!PMSG_IS_AUTO(message) && !chip->system_suspend) {
1089 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
1090 chip->system_suspend = chip->num_suspended_intf;
1098 struct snd_usb_audio *chip = usb_get_intfdata(intf);
1104 if (chip == USB_AUDIO_IFACE_UNUSED)
1107 atomic_inc(&chip->active); /* avoid autopm */
1108 if (chip->num_suspended_intf > 1)
1111 list_for_each_entry(as, &chip->pcm_list, list) {
1121 list_for_each_entry(mixer, &chip->mixer_list, list) {
1127 list_for_each(p, &chip->midi_list) {
1131 snd_usb_midi_v2_resume_all(chip);
1134 if (chip->num_suspended_intf == chip->system_suspend) {
1135 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
1136 chip->system_suspend = 0;
1138 chip->num_suspended_intf--;
1141 atomic_dec(&chip->active); /* allow autopm after this point */