Lines Matching full:ua

3  * Edirol UA-101/UA-1000 driver
19 MODULE_DESCRIPTION("Edirol UA-101/1000 driver");
32 * This magic value optimizes memory usage efficiency for the UA-101's packet
128 static void abort_alsa_playback(struct ua101 *ua);
129 static void abort_alsa_capture(struct ua101 *ua);
156 static void abort_usb_capture(struct ua101 *ua) in abort_usb_capture() argument
158 if (test_and_clear_bit(USB_CAPTURE_RUNNING, &ua->states)) { in abort_usb_capture()
159 wake_up(&ua->alsa_capture_wait); in abort_usb_capture()
160 wake_up(&ua->rate_feedback_wait); in abort_usb_capture()
164 static void abort_usb_playback(struct ua101 *ua) in abort_usb_playback() argument
166 if (test_and_clear_bit(USB_PLAYBACK_RUNNING, &ua->states)) in abort_usb_playback()
167 wake_up(&ua->alsa_playback_wait); in abort_usb_playback()
173 struct ua101 *ua = urb->urb.context; in playback_urb_complete() local
180 abort_usb_playback(ua); in playback_urb_complete()
181 abort_alsa_playback(ua); in playback_urb_complete()
185 if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) { in playback_urb_complete()
187 spin_lock_irqsave(&ua->lock, flags); in playback_urb_complete()
188 list_add_tail(&urb->ready_list, &ua->ready_playback_urbs); in playback_urb_complete()
189 if (ua->rate_feedback_count > 0) in playback_urb_complete()
190 queue_work(system_highpri_wq, &ua->playback_work); in playback_urb_complete()
191 ua->playback.substream->runtime->delay -= in playback_urb_complete()
193 ua->playback.frame_bytes; in playback_urb_complete()
194 spin_unlock_irqrestore(&ua->lock, flags); in playback_urb_complete()
200 struct ua101 *ua = urb->context; in first_playback_urb_complete() local
205 set_bit(PLAYBACK_URB_COMPLETED, &ua->states); in first_playback_urb_complete()
206 wake_up(&ua->alsa_playback_wait); in first_playback_urb_complete()
241 static inline void add_with_wraparound(struct ua101 *ua, in add_with_wraparound() argument
245 if (*value >= ua->playback.queue_length) in add_with_wraparound()
246 *value -= ua->playback.queue_length; in add_with_wraparound()
251 struct ua101 *ua = container_of(work, struct ua101, playback_work); in playback_work() local
258 if (unlikely(!test_bit(USB_PLAYBACK_RUNNING, &ua->states))) in playback_work()
272 spin_lock_irqsave(&ua->lock, flags); in playback_work()
273 while (ua->rate_feedback_count > 0 && in playback_work()
274 !list_empty(&ua->ready_playback_urbs)) { in playback_work()
276 frames = ua->rate_feedback[ua->rate_feedback_start]; in playback_work()
277 add_with_wraparound(ua, &ua->rate_feedback_start, 1); in playback_work()
278 ua->rate_feedback_count--; in playback_work()
281 urb = list_first_entry(&ua->ready_playback_urbs, in playback_work()
287 frames * ua->playback.frame_bytes; in playback_work()
288 if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) in playback_work()
289 do_period_elapsed |= copy_playback_data(&ua->playback, in playback_work()
299 spin_unlock_irqrestore(&ua->lock, flags); in playback_work()
300 abort_usb_playback(ua); in playback_work()
301 abort_alsa_playback(ua); in playback_work()
302 dev_err(&ua->dev->dev, "USB request error %d: %s\n", in playback_work()
306 ua->playback.substream->runtime->delay += frames; in playback_work()
308 spin_unlock_irqrestore(&ua->lock, flags); in playback_work()
310 snd_pcm_period_elapsed(ua->playback.substream); in playback_work()
348 struct ua101 *ua = urb->context; in capture_urb_complete() local
349 struct ua101_stream *stream = &ua->capture; in capture_urb_complete()
367 spin_lock_irqsave(&ua->lock, flags); in capture_urb_complete()
369 if (frames > 0 && test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) in capture_urb_complete()
374 if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) { in capture_urb_complete()
377 spin_unlock_irqrestore(&ua->lock, flags); in capture_urb_complete()
378 dev_err(&ua->dev->dev, "USB request error %d: %s\n", in capture_urb_complete()
384 write_ptr = ua->rate_feedback_start; in capture_urb_complete()
385 add_with_wraparound(ua, &write_ptr, ua->rate_feedback_count); in capture_urb_complete()
386 ua->rate_feedback[write_ptr] = frames; in capture_urb_complete()
387 if (ua->rate_feedback_count < ua->playback.queue_length) { in capture_urb_complete()
388 ua->rate_feedback_count++; in capture_urb_complete()
389 if (ua->rate_feedback_count == in capture_urb_complete()
390 ua->playback.queue_length) in capture_urb_complete()
391 wake_up(&ua->rate_feedback_wait); in capture_urb_complete()
399 add_with_wraparound(ua, &ua->rate_feedback_start, 1); in capture_urb_complete()
401 if (test_bit(USB_PLAYBACK_RUNNING, &ua->states) && in capture_urb_complete()
402 !list_empty(&ua->ready_playback_urbs)) in capture_urb_complete()
403 queue_work(system_highpri_wq, &ua->playback_work); in capture_urb_complete()
406 spin_unlock_irqrestore(&ua->lock, flags); in capture_urb_complete()
414 abort_usb_playback(ua); in capture_urb_complete()
415 abort_usb_capture(ua); in capture_urb_complete()
416 abort_alsa_playback(ua); in capture_urb_complete()
417 abort_alsa_capture(ua); in capture_urb_complete()
422 struct ua101 *ua = urb->context; in first_capture_urb_complete() local
427 set_bit(CAPTURE_URB_COMPLETED, &ua->states); in first_capture_urb_complete()
428 wake_up(&ua->alsa_capture_wait); in first_capture_urb_complete()
431 static int submit_stream_urbs(struct ua101 *ua, struct ua101_stream *stream) in submit_stream_urbs() argument
438 dev_err(&ua->dev->dev, "USB request error %d: %s\n", in submit_stream_urbs()
455 static int enable_iso_interface(struct ua101 *ua, unsigned int intf_index) in enable_iso_interface() argument
459 alts = ua->intf[intf_index]->cur_altsetting; in enable_iso_interface()
461 int err = usb_set_interface(ua->dev, in enable_iso_interface()
464 dev_err(&ua->dev->dev, in enable_iso_interface()
473 static void disable_iso_interface(struct ua101 *ua, unsigned int intf_index) in disable_iso_interface() argument
477 if (!ua->intf[intf_index]) in disable_iso_interface()
480 alts = ua->intf[intf_index]->cur_altsetting; in disable_iso_interface()
482 int err = usb_set_interface(ua->dev, in disable_iso_interface()
484 if (err < 0 && !test_bit(DISCONNECTED, &ua->states)) in disable_iso_interface()
485 dev_warn(&ua->dev->dev, in disable_iso_interface()
491 static void stop_usb_capture(struct ua101 *ua) in stop_usb_capture() argument
493 clear_bit(USB_CAPTURE_RUNNING, &ua->states); in stop_usb_capture()
495 kill_stream_urbs(&ua->capture); in stop_usb_capture()
497 disable_iso_interface(ua, INTF_CAPTURE); in stop_usb_capture()
500 static int start_usb_capture(struct ua101 *ua) in start_usb_capture() argument
504 if (test_bit(DISCONNECTED, &ua->states)) in start_usb_capture()
507 if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) in start_usb_capture()
510 kill_stream_urbs(&ua->capture); in start_usb_capture()
512 err = enable_iso_interface(ua, INTF_CAPTURE); in start_usb_capture()
516 clear_bit(CAPTURE_URB_COMPLETED, &ua->states); in start_usb_capture()
517 ua->capture.urbs[0]->urb.complete = first_capture_urb_complete; in start_usb_capture()
518 ua->rate_feedback_start = 0; in start_usb_capture()
519 ua->rate_feedback_count = 0; in start_usb_capture()
521 set_bit(USB_CAPTURE_RUNNING, &ua->states); in start_usb_capture()
522 err = submit_stream_urbs(ua, &ua->capture); in start_usb_capture()
524 stop_usb_capture(ua); in start_usb_capture()
528 static void stop_usb_playback(struct ua101 *ua) in stop_usb_playback() argument
530 clear_bit(USB_PLAYBACK_RUNNING, &ua->states); in stop_usb_playback()
532 kill_stream_urbs(&ua->playback); in stop_usb_playback()
534 cancel_work_sync(&ua->playback_work); in stop_usb_playback()
536 disable_iso_interface(ua, INTF_PLAYBACK); in stop_usb_playback()
539 static int start_usb_playback(struct ua101 *ua) in start_usb_playback() argument
545 if (test_bit(DISCONNECTED, &ua->states)) in start_usb_playback()
548 if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) in start_usb_playback()
551 kill_stream_urbs(&ua->playback); in start_usb_playback()
552 cancel_work_sync(&ua->playback_work); in start_usb_playback()
554 err = enable_iso_interface(ua, INTF_PLAYBACK); in start_usb_playback()
558 clear_bit(PLAYBACK_URB_COMPLETED, &ua->states); in start_usb_playback()
559 ua->playback.urbs[0]->urb.complete = in start_usb_playback()
561 spin_lock_irq(&ua->lock); in start_usb_playback()
562 INIT_LIST_HEAD(&ua->ready_playback_urbs); in start_usb_playback()
563 spin_unlock_irq(&ua->lock); in start_usb_playback()
569 wait_event(ua->rate_feedback_wait, in start_usb_playback()
570 ua->rate_feedback_count >= ua->playback.queue_length || in start_usb_playback()
571 !test_bit(USB_CAPTURE_RUNNING, &ua->states) || in start_usb_playback()
572 test_bit(DISCONNECTED, &ua->states)); in start_usb_playback()
573 if (test_bit(DISCONNECTED, &ua->states)) { in start_usb_playback()
574 stop_usb_playback(ua); in start_usb_playback()
577 if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) { in start_usb_playback()
578 stop_usb_playback(ua); in start_usb_playback()
582 for (i = 0; i < ua->playback.queue_length; ++i) { in start_usb_playback()
584 spin_lock_irq(&ua->lock); in start_usb_playback()
585 frames = ua->rate_feedback[ua->rate_feedback_start]; in start_usb_playback()
586 add_with_wraparound(ua, &ua->rate_feedback_start, 1); in start_usb_playback()
587 ua->rate_feedback_count--; in start_usb_playback()
588 spin_unlock_irq(&ua->lock); in start_usb_playback()
589 urb = &ua->playback.urbs[i]->urb; in start_usb_playback()
591 frames * ua->playback.frame_bytes; in start_usb_playback()
596 set_bit(USB_PLAYBACK_RUNNING, &ua->states); in start_usb_playback()
597 err = submit_stream_urbs(ua, &ua->playback); in start_usb_playback()
599 stop_usb_playback(ua); in start_usb_playback()
603 static void abort_alsa_capture(struct ua101 *ua) in abort_alsa_capture() argument
605 if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) in abort_alsa_capture()
606 snd_pcm_stop_xrun(ua->capture.substream); in abort_alsa_capture()
609 static void abort_alsa_playback(struct ua101 *ua) in abort_alsa_playback() argument
611 if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) in abort_alsa_playback()
612 snd_pcm_stop_xrun(ua->playback.substream); in abort_alsa_playback()
615 static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream, in set_stream_hw() argument
627 substream->runtime->hw.formats = ua->format_bit; in set_stream_hw()
628 substream->runtime->hw.rates = snd_pcm_rate_to_rate_bit(ua->rate); in set_stream_hw()
629 substream->runtime->hw.rate_min = ua->rate; in set_stream_hw()
630 substream->runtime->hw.rate_max = ua->rate; in set_stream_hw()
640 1500000 / ua->packets_per_second, in set_stream_hw()
650 struct ua101 *ua = substream->private_data; in capture_pcm_open() local
653 ua->capture.substream = substream; in capture_pcm_open()
654 err = set_stream_hw(ua, substream, ua->capture.channels); in capture_pcm_open()
658 DIV_ROUND_CLOSEST(ua->rate, ua->packets_per_second); in capture_pcm_open()
661 mutex_lock(&ua->mutex); in capture_pcm_open()
662 err = start_usb_capture(ua); in capture_pcm_open()
664 set_bit(ALSA_CAPTURE_OPEN, &ua->states); in capture_pcm_open()
665 mutex_unlock(&ua->mutex); in capture_pcm_open()
671 struct ua101 *ua = substream->private_data; in playback_pcm_open() local
674 ua->playback.substream = substream; in playback_pcm_open()
675 err = set_stream_hw(ua, substream, ua->playback.channels); in playback_pcm_open()
679 DIV_ROUND_CLOSEST(ua->rate * ua->playback.queue_length, in playback_pcm_open()
680 ua->packets_per_second); in playback_pcm_open()
682 mutex_lock(&ua->mutex); in playback_pcm_open()
683 err = start_usb_capture(ua); in playback_pcm_open()
686 err = start_usb_playback(ua); in playback_pcm_open()
688 if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states)) in playback_pcm_open()
689 stop_usb_capture(ua); in playback_pcm_open()
692 set_bit(ALSA_PLAYBACK_OPEN, &ua->states); in playback_pcm_open()
694 mutex_unlock(&ua->mutex); in playback_pcm_open()
700 struct ua101 *ua = substream->private_data; in capture_pcm_close() local
702 mutex_lock(&ua->mutex); in capture_pcm_close()
703 clear_bit(ALSA_CAPTURE_OPEN, &ua->states); in capture_pcm_close()
704 if (!test_bit(ALSA_PLAYBACK_OPEN, &ua->states)) in capture_pcm_close()
705 stop_usb_capture(ua); in capture_pcm_close()
706 mutex_unlock(&ua->mutex); in capture_pcm_close()
712 struct ua101 *ua = substream->private_data; in playback_pcm_close() local
714 mutex_lock(&ua->mutex); in playback_pcm_close()
715 stop_usb_playback(ua); in playback_pcm_close()
716 clear_bit(ALSA_PLAYBACK_OPEN, &ua->states); in playback_pcm_close()
717 if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states)) in playback_pcm_close()
718 stop_usb_capture(ua); in playback_pcm_close()
719 mutex_unlock(&ua->mutex); in playback_pcm_close()
726 struct ua101 *ua = substream->private_data; in capture_pcm_hw_params() local
729 mutex_lock(&ua->mutex); in capture_pcm_hw_params()
730 err = start_usb_capture(ua); in capture_pcm_hw_params()
731 mutex_unlock(&ua->mutex); in capture_pcm_hw_params()
738 struct ua101 *ua = substream->private_data; in playback_pcm_hw_params() local
741 mutex_lock(&ua->mutex); in playback_pcm_hw_params()
742 err = start_usb_capture(ua); in playback_pcm_hw_params()
744 err = start_usb_playback(ua); in playback_pcm_hw_params()
745 mutex_unlock(&ua->mutex); in playback_pcm_hw_params()
751 struct ua101 *ua = substream->private_data; in capture_pcm_prepare() local
754 mutex_lock(&ua->mutex); in capture_pcm_prepare()
755 err = start_usb_capture(ua); in capture_pcm_prepare()
756 mutex_unlock(&ua->mutex); in capture_pcm_prepare()
766 wait_event(ua->alsa_capture_wait, in capture_pcm_prepare()
767 test_bit(CAPTURE_URB_COMPLETED, &ua->states) || in capture_pcm_prepare()
768 !test_bit(USB_CAPTURE_RUNNING, &ua->states)); in capture_pcm_prepare()
769 if (test_bit(DISCONNECTED, &ua->states)) in capture_pcm_prepare()
771 if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) in capture_pcm_prepare()
774 ua->capture.period_pos = 0; in capture_pcm_prepare()
775 ua->capture.buffer_pos = 0; in capture_pcm_prepare()
781 struct ua101 *ua = substream->private_data; in playback_pcm_prepare() local
784 mutex_lock(&ua->mutex); in playback_pcm_prepare()
785 err = start_usb_capture(ua); in playback_pcm_prepare()
787 err = start_usb_playback(ua); in playback_pcm_prepare()
788 mutex_unlock(&ua->mutex); in playback_pcm_prepare()
793 wait_event(ua->alsa_playback_wait, in playback_pcm_prepare()
794 test_bit(PLAYBACK_URB_COMPLETED, &ua->states) || in playback_pcm_prepare()
795 !test_bit(USB_PLAYBACK_RUNNING, &ua->states)); in playback_pcm_prepare()
796 if (test_bit(DISCONNECTED, &ua->states)) in playback_pcm_prepare()
798 if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states)) in playback_pcm_prepare()
802 ua->playback.period_pos = 0; in playback_pcm_prepare()
803 ua->playback.buffer_pos = 0; in playback_pcm_prepare()
809 struct ua101 *ua = substream->private_data; in capture_pcm_trigger() local
813 if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) in capture_pcm_trigger()
815 set_bit(ALSA_CAPTURE_RUNNING, &ua->states); in capture_pcm_trigger()
818 clear_bit(ALSA_CAPTURE_RUNNING, &ua->states); in capture_pcm_trigger()
827 struct ua101 *ua = substream->private_data; in playback_pcm_trigger() local
831 if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states)) in playback_pcm_trigger()
833 set_bit(ALSA_PLAYBACK_RUNNING, &ua->states); in playback_pcm_trigger()
836 clear_bit(ALSA_PLAYBACK_RUNNING, &ua->states); in playback_pcm_trigger()
843 static inline snd_pcm_uframes_t ua101_pcm_pointer(struct ua101 *ua, in ua101_pcm_pointer() argument
849 spin_lock_irqsave(&ua->lock, flags); in ua101_pcm_pointer()
851 spin_unlock_irqrestore(&ua->lock, flags); in ua101_pcm_pointer()
857 struct ua101 *ua = subs->private_data; in capture_pcm_pointer() local
859 return ua101_pcm_pointer(ua, &ua->capture); in capture_pcm_pointer()
864 struct ua101 *ua = subs->private_data; in playback_pcm_pointer() local
866 return ua101_pcm_pointer(ua, &ua->playback); in playback_pcm_pointer()
939 static int detect_usb_format(struct ua101 *ua) in detect_usb_format() argument
946 fmt_capture = find_format_descriptor(ua->intf[INTF_CAPTURE]); in detect_usb_format()
947 fmt_playback = find_format_descriptor(ua->intf[INTF_PLAYBACK]); in detect_usb_format()
953 ua->format_bit = SNDRV_PCM_FMTBIT_S24_3LE; in detect_usb_format()
956 ua->format_bit = SNDRV_PCM_FMTBIT_S32_LE; in detect_usb_format()
959 dev_err(&ua->dev->dev, "sample width is not 24 or 32 bits\n"); in detect_usb_format()
963 dev_err(&ua->dev->dev, in detect_usb_format()
970 dev_err(&ua->dev->dev, "sample width is not 24 bits\n"); in detect_usb_format()
974 ua->rate = combine_triple(fmt_capture->tSamFreq[0]); in detect_usb_format()
976 if (ua->rate != rate2) { in detect_usb_format()
977 dev_err(&ua->dev->dev, in detect_usb_format()
979 rate2, ua->rate); in detect_usb_format()
983 switch (ua->dev->speed) { in detect_usb_format()
985 ua->packets_per_second = 1000; in detect_usb_format()
988 ua->packets_per_second = 8000; in detect_usb_format()
991 dev_err(&ua->dev->dev, "unknown device speed\n"); in detect_usb_format()
995 ua->capture.channels = fmt_capture->bNrChannels; in detect_usb_format()
996 ua->playback.channels = fmt_playback->bNrChannels; in detect_usb_format()
997 ua->capture.frame_bytes = in detect_usb_format()
998 fmt_capture->bSubframeSize * ua->capture.channels; in detect_usb_format()
999 ua->playback.frame_bytes = in detect_usb_format()
1000 fmt_playback->bSubframeSize * ua->playback.channels; in detect_usb_format()
1002 epd = &ua->intf[INTF_CAPTURE]->altsetting[1].endpoint[0].desc; in detect_usb_format()
1004 dev_err(&ua->dev->dev, "invalid capture endpoint\n"); in detect_usb_format()
1007 ua->capture.usb_pipe = usb_rcvisocpipe(ua->dev, usb_endpoint_num(epd)); in detect_usb_format()
1008 ua->capture.max_packet_bytes = usb_endpoint_maxp(epd); in detect_usb_format()
1010 epd = &ua->intf[INTF_PLAYBACK]->altsetting[1].endpoint[0].desc; in detect_usb_format()
1012 dev_err(&ua->dev->dev, "invalid playback endpoint\n"); in detect_usb_format()
1015 ua->playback.usb_pipe = usb_sndisocpipe(ua->dev, usb_endpoint_num(epd)); in detect_usb_format()
1016 ua->playback.max_packet_bytes = usb_endpoint_maxp(epd); in detect_usb_format()
1020 static int alloc_stream_buffers(struct ua101 *ua, struct ua101_stream *stream) in alloc_stream_buffers() argument
1043 usb_alloc_coherent(ua->dev, size, GFP_KERNEL, in alloc_stream_buffers()
1053 dev_err(&ua->dev->dev, "too many packets\n"); in alloc_stream_buffers()
1059 static void free_stream_buffers(struct ua101 *ua, struct ua101_stream *stream) in free_stream_buffers() argument
1064 usb_free_coherent(ua->dev, in free_stream_buffers()
1070 static int alloc_stream_urbs(struct ua101 *ua, struct ua101_stream *stream, in alloc_stream_urbs() argument
1089 urb->urb.dev = ua->dev; in alloc_stream_urbs()
1097 urb->urb.context = ua; in alloc_stream_urbs()
1110 dev_err(&ua->dev->dev, "internal buffer size error\n"); in alloc_stream_urbs()
1124 static void free_usb_related_resources(struct ua101 *ua, in free_usb_related_resources() argument
1130 mutex_lock(&ua->mutex); in free_usb_related_resources()
1131 free_stream_urbs(&ua->capture); in free_usb_related_resources()
1132 free_stream_urbs(&ua->playback); in free_usb_related_resources()
1133 mutex_unlock(&ua->mutex); in free_usb_related_resources()
1134 free_stream_buffers(ua, &ua->capture); in free_usb_related_resources()
1135 free_stream_buffers(ua, &ua->playback); in free_usb_related_resources()
1137 for (i = 0; i < ARRAY_SIZE(ua->intf); ++i) { in free_usb_related_resources()
1138 mutex_lock(&ua->mutex); in free_usb_related_resources()
1139 intf = ua->intf[i]; in free_usb_related_resources()
1140 ua->intf[i] = NULL; in free_usb_related_resources()
1141 mutex_unlock(&ua->mutex); in free_usb_related_resources()
1153 struct ua101 *ua = card->private_data; in ua101_card_free() local
1155 mutex_destroy(&ua->mutex); in ua101_card_free()
1170 { /* UA-101 */ in ua101_probe()
1175 { /* UA-1000 */ in ua101_probe()
1182 struct ua101 *ua; in ua101_probe() local
1206 sizeof(*ua), &card); in ua101_probe()
1212 ua = card->private_data; in ua101_probe()
1213 ua->dev = interface_to_usbdev(interface); in ua101_probe()
1214 ua->card = card; in ua101_probe()
1215 ua->card_index = card_index; in ua101_probe()
1216 INIT_LIST_HEAD(&ua->midi_list); in ua101_probe()
1217 spin_lock_init(&ua->lock); in ua101_probe()
1218 mutex_init(&ua->mutex); in ua101_probe()
1219 INIT_LIST_HEAD(&ua->ready_playback_urbs); in ua101_probe()
1220 INIT_WORK(&ua->playback_work, playback_work); in ua101_probe()
1221 init_waitqueue_head(&ua->alsa_capture_wait); in ua101_probe()
1222 init_waitqueue_head(&ua->rate_feedback_wait); in ua101_probe()
1223 init_waitqueue_head(&ua->alsa_playback_wait); in ua101_probe()
1225 ua->intf[0] = interface; in ua101_probe()
1226 for (i = 1; i < ARRAY_SIZE(ua->intf); ++i) { in ua101_probe()
1227 ua->intf[i] = usb_ifnum_to_if(ua->dev, in ua101_probe()
1229 if (!ua->intf[i]) { in ua101_probe()
1230 dev_err(&ua->dev->dev, "interface %u not found\n", in ua101_probe()
1236 ua->intf[i], ua); in ua101_probe()
1238 ua->intf[i] = NULL; in ua101_probe()
1244 err = detect_usb_format(ua); in ua101_probe()
1248 name = usb_id->idProduct == 0x0044 ? "UA-1000" : "UA-101"; in ua101_probe()
1249 strcpy(card->driver, "UA-101"); in ua101_probe()
1251 usb_make_path(ua->dev, usb_path, sizeof(usb_path)); in ua101_probe()
1252 snprintf(ua->card->longname, sizeof(ua->card->longname), in ua101_probe()
1254 ua->dev->serial ? ua->dev->serial : "?", ua->rate, usb_path, in ua101_probe()
1255 ua->dev->speed == USB_SPEED_HIGH ? "high" : "full"); in ua101_probe()
1257 err = alloc_stream_buffers(ua, &ua->capture); in ua101_probe()
1260 err = alloc_stream_buffers(ua, &ua->playback); in ua101_probe()
1264 err = alloc_stream_urbs(ua, &ua->capture, capture_urb_complete); in ua101_probe()
1267 err = alloc_stream_urbs(ua, &ua->playback, playback_urb_complete); in ua101_probe()
1271 err = snd_pcm_new(card, name, 0, 1, 1, &ua->pcm); in ua101_probe()
1274 ua->pcm->private_data = ua; in ua101_probe()
1275 strcpy(ua->pcm->name, name); in ua101_probe()
1276 snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_pcm_ops); in ua101_probe()
1277 snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_pcm_ops); in ua101_probe()
1278 snd_pcm_set_managed_buffer_all(ua->pcm, SNDRV_DMA_TYPE_VMALLOC, in ua101_probe()
1281 err = snd_usbmidi_create(card, ua->intf[INTF_MIDI], in ua101_probe()
1282 &ua->midi_list, &midi_quirk); in ua101_probe()
1290 usb_set_intfdata(interface, ua); in ua101_probe()
1297 free_usb_related_resources(ua, interface); in ua101_probe()
1305 struct ua101 *ua = usb_get_intfdata(interface); in ua101_disconnect() local
1308 if (!ua) in ua101_disconnect()
1313 set_bit(DISCONNECTED, &ua->states); in ua101_disconnect()
1314 wake_up(&ua->rate_feedback_wait); in ua101_disconnect()
1317 snd_card_disconnect(ua->card); in ua101_disconnect()
1320 list_for_each(midi, &ua->midi_list) in ua101_disconnect()
1322 abort_alsa_playback(ua); in ua101_disconnect()
1323 abort_alsa_capture(ua); in ua101_disconnect()
1324 mutex_lock(&ua->mutex); in ua101_disconnect()
1325 stop_usb_playback(ua); in ua101_disconnect()
1326 stop_usb_capture(ua); in ua101_disconnect()
1327 mutex_unlock(&ua->mutex); in ua101_disconnect()
1329 free_usb_related_resources(ua, interface); in ua101_disconnect()
1331 devices_used &= ~(1 << ua->card_index); in ua101_disconnect()
1333 snd_card_free_when_closed(ua->card); in ua101_disconnect()
1339 { USB_DEVICE(0x0582, 0x0044) }, /* UA-1000 high speed */
1340 { USB_DEVICE(0x0582, 0x007d) }, /* UA-101 high speed */
1341 { USB_DEVICE(0x0582, 0x008d) }, /* UA-101 full speed */