Lines Matching full:ua
3 * Edirol UA-101/UA-1000 driver
19 MODULE_DESCRIPTION("Edirol UA-101/1000 driver");
22 MODULE_SUPPORTED_DEVICE("{{Edirol,UA-101},{Edirol,UA-1000}}");
33 * This magic value optimizes memory usage efficiency for the UA-101's packet
129 static void abort_alsa_playback(struct ua101 *ua);
130 static void abort_alsa_capture(struct ua101 *ua);
157 static void abort_usb_capture(struct ua101 *ua) in abort_usb_capture() argument
159 if (test_and_clear_bit(USB_CAPTURE_RUNNING, &ua->states)) { in abort_usb_capture()
160 wake_up(&ua->alsa_capture_wait); in abort_usb_capture()
161 wake_up(&ua->rate_feedback_wait); in abort_usb_capture()
165 static void abort_usb_playback(struct ua101 *ua) in abort_usb_playback() argument
167 if (test_and_clear_bit(USB_PLAYBACK_RUNNING, &ua->states)) in abort_usb_playback()
168 wake_up(&ua->alsa_playback_wait); in abort_usb_playback()
174 struct ua101 *ua = urb->urb.context; in playback_urb_complete() local
181 abort_usb_playback(ua); in playback_urb_complete()
182 abort_alsa_playback(ua); in playback_urb_complete()
186 if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) { in playback_urb_complete()
188 spin_lock_irqsave(&ua->lock, flags); in playback_urb_complete()
189 list_add_tail(&urb->ready_list, &ua->ready_playback_urbs); in playback_urb_complete()
190 if (ua->rate_feedback_count > 0) in playback_urb_complete()
191 queue_work(system_highpri_wq, &ua->playback_work); in playback_urb_complete()
192 ua->playback.substream->runtime->delay -= in playback_urb_complete()
194 ua->playback.frame_bytes; in playback_urb_complete()
195 spin_unlock_irqrestore(&ua->lock, flags); in playback_urb_complete()
201 struct ua101 *ua = urb->context; in first_playback_urb_complete() local
206 set_bit(PLAYBACK_URB_COMPLETED, &ua->states); in first_playback_urb_complete()
207 wake_up(&ua->alsa_playback_wait); in first_playback_urb_complete()
242 static inline void add_with_wraparound(struct ua101 *ua, in add_with_wraparound() argument
246 if (*value >= ua->playback.queue_length) in add_with_wraparound()
247 *value -= ua->playback.queue_length; in add_with_wraparound()
252 struct ua101 *ua = container_of(work, struct ua101, playback_work); in playback_work() local
259 if (unlikely(!test_bit(USB_PLAYBACK_RUNNING, &ua->states))) in playback_work()
273 spin_lock_irqsave(&ua->lock, flags); in playback_work()
274 while (ua->rate_feedback_count > 0 && in playback_work()
275 !list_empty(&ua->ready_playback_urbs)) { in playback_work()
277 frames = ua->rate_feedback[ua->rate_feedback_start]; in playback_work()
278 add_with_wraparound(ua, &ua->rate_feedback_start, 1); in playback_work()
279 ua->rate_feedback_count--; in playback_work()
282 urb = list_first_entry(&ua->ready_playback_urbs, in playback_work()
288 frames * ua->playback.frame_bytes; in playback_work()
289 if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) in playback_work()
290 do_period_elapsed |= copy_playback_data(&ua->playback, in playback_work()
300 spin_unlock_irqrestore(&ua->lock, flags); in playback_work()
301 abort_usb_playback(ua); in playback_work()
302 abort_alsa_playback(ua); in playback_work()
303 dev_err(&ua->dev->dev, "USB request error %d: %s\n", in playback_work()
307 ua->playback.substream->runtime->delay += frames; in playback_work()
309 spin_unlock_irqrestore(&ua->lock, flags); in playback_work()
311 snd_pcm_period_elapsed(ua->playback.substream); in playback_work()
349 struct ua101 *ua = urb->context; in capture_urb_complete() local
350 struct ua101_stream *stream = &ua->capture; in capture_urb_complete()
368 spin_lock_irqsave(&ua->lock, flags); in capture_urb_complete()
370 if (frames > 0 && test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) in capture_urb_complete()
375 if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) { in capture_urb_complete()
378 spin_unlock_irqrestore(&ua->lock, flags); in capture_urb_complete()
379 dev_err(&ua->dev->dev, "USB request error %d: %s\n", in capture_urb_complete()
385 write_ptr = ua->rate_feedback_start; in capture_urb_complete()
386 add_with_wraparound(ua, &write_ptr, ua->rate_feedback_count); in capture_urb_complete()
387 ua->rate_feedback[write_ptr] = frames; in capture_urb_complete()
388 if (ua->rate_feedback_count < ua->playback.queue_length) { in capture_urb_complete()
389 ua->rate_feedback_count++; in capture_urb_complete()
390 if (ua->rate_feedback_count == in capture_urb_complete()
391 ua->playback.queue_length) in capture_urb_complete()
392 wake_up(&ua->rate_feedback_wait); in capture_urb_complete()
400 add_with_wraparound(ua, &ua->rate_feedback_start, 1); in capture_urb_complete()
402 if (test_bit(USB_PLAYBACK_RUNNING, &ua->states) && in capture_urb_complete()
403 !list_empty(&ua->ready_playback_urbs)) in capture_urb_complete()
404 queue_work(system_highpri_wq, &ua->playback_work); in capture_urb_complete()
407 spin_unlock_irqrestore(&ua->lock, flags); in capture_urb_complete()
415 abort_usb_playback(ua); in capture_urb_complete()
416 abort_usb_capture(ua); in capture_urb_complete()
417 abort_alsa_playback(ua); in capture_urb_complete()
418 abort_alsa_capture(ua); in capture_urb_complete()
423 struct ua101 *ua = urb->context; in first_capture_urb_complete() local
428 set_bit(CAPTURE_URB_COMPLETED, &ua->states); in first_capture_urb_complete()
429 wake_up(&ua->alsa_capture_wait); in first_capture_urb_complete()
432 static int submit_stream_urbs(struct ua101 *ua, struct ua101_stream *stream) in submit_stream_urbs() argument
439 dev_err(&ua->dev->dev, "USB request error %d: %s\n", in submit_stream_urbs()
456 static int enable_iso_interface(struct ua101 *ua, unsigned int intf_index) in enable_iso_interface() argument
460 alts = ua->intf[intf_index]->cur_altsetting; in enable_iso_interface()
462 int err = usb_set_interface(ua->dev, in enable_iso_interface()
465 dev_err(&ua->dev->dev, in enable_iso_interface()
474 static void disable_iso_interface(struct ua101 *ua, unsigned int intf_index) in disable_iso_interface() argument
478 if (!ua->intf[intf_index]) in disable_iso_interface()
481 alts = ua->intf[intf_index]->cur_altsetting; in disable_iso_interface()
483 int err = usb_set_interface(ua->dev, in disable_iso_interface()
485 if (err < 0 && !test_bit(DISCONNECTED, &ua->states)) in disable_iso_interface()
486 dev_warn(&ua->dev->dev, in disable_iso_interface()
492 static void stop_usb_capture(struct ua101 *ua) in stop_usb_capture() argument
494 clear_bit(USB_CAPTURE_RUNNING, &ua->states); in stop_usb_capture()
496 kill_stream_urbs(&ua->capture); in stop_usb_capture()
498 disable_iso_interface(ua, INTF_CAPTURE); in stop_usb_capture()
501 static int start_usb_capture(struct ua101 *ua) in start_usb_capture() argument
505 if (test_bit(DISCONNECTED, &ua->states)) in start_usb_capture()
508 if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) in start_usb_capture()
511 kill_stream_urbs(&ua->capture); in start_usb_capture()
513 err = enable_iso_interface(ua, INTF_CAPTURE); in start_usb_capture()
517 clear_bit(CAPTURE_URB_COMPLETED, &ua->states); in start_usb_capture()
518 ua->capture.urbs[0]->urb.complete = first_capture_urb_complete; in start_usb_capture()
519 ua->rate_feedback_start = 0; in start_usb_capture()
520 ua->rate_feedback_count = 0; in start_usb_capture()
522 set_bit(USB_CAPTURE_RUNNING, &ua->states); in start_usb_capture()
523 err = submit_stream_urbs(ua, &ua->capture); in start_usb_capture()
525 stop_usb_capture(ua); in start_usb_capture()
529 static void stop_usb_playback(struct ua101 *ua) in stop_usb_playback() argument
531 clear_bit(USB_PLAYBACK_RUNNING, &ua->states); in stop_usb_playback()
533 kill_stream_urbs(&ua->playback); in stop_usb_playback()
535 cancel_work_sync(&ua->playback_work); in stop_usb_playback()
537 disable_iso_interface(ua, INTF_PLAYBACK); in stop_usb_playback()
540 static int start_usb_playback(struct ua101 *ua) in start_usb_playback() argument
546 if (test_bit(DISCONNECTED, &ua->states)) in start_usb_playback()
549 if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) in start_usb_playback()
552 kill_stream_urbs(&ua->playback); in start_usb_playback()
553 cancel_work_sync(&ua->playback_work); in start_usb_playback()
555 err = enable_iso_interface(ua, INTF_PLAYBACK); in start_usb_playback()
559 clear_bit(PLAYBACK_URB_COMPLETED, &ua->states); in start_usb_playback()
560 ua->playback.urbs[0]->urb.complete = in start_usb_playback()
562 spin_lock_irq(&ua->lock); in start_usb_playback()
563 INIT_LIST_HEAD(&ua->ready_playback_urbs); in start_usb_playback()
564 spin_unlock_irq(&ua->lock); in start_usb_playback()
570 wait_event(ua->rate_feedback_wait, in start_usb_playback()
571 ua->rate_feedback_count >= ua->playback.queue_length || in start_usb_playback()
572 !test_bit(USB_CAPTURE_RUNNING, &ua->states) || in start_usb_playback()
573 test_bit(DISCONNECTED, &ua->states)); in start_usb_playback()
574 if (test_bit(DISCONNECTED, &ua->states)) { in start_usb_playback()
575 stop_usb_playback(ua); in start_usb_playback()
578 if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) { in start_usb_playback()
579 stop_usb_playback(ua); in start_usb_playback()
583 for (i = 0; i < ua->playback.queue_length; ++i) { in start_usb_playback()
585 spin_lock_irq(&ua->lock); in start_usb_playback()
586 frames = ua->rate_feedback[ua->rate_feedback_start]; in start_usb_playback()
587 add_with_wraparound(ua, &ua->rate_feedback_start, 1); in start_usb_playback()
588 ua->rate_feedback_count--; in start_usb_playback()
589 spin_unlock_irq(&ua->lock); in start_usb_playback()
590 urb = &ua->playback.urbs[i]->urb; in start_usb_playback()
592 frames * ua->playback.frame_bytes; in start_usb_playback()
597 set_bit(USB_PLAYBACK_RUNNING, &ua->states); in start_usb_playback()
598 err = submit_stream_urbs(ua, &ua->playback); in start_usb_playback()
600 stop_usb_playback(ua); in start_usb_playback()
604 static void abort_alsa_capture(struct ua101 *ua) in abort_alsa_capture() argument
606 if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) in abort_alsa_capture()
607 snd_pcm_stop_xrun(ua->capture.substream); in abort_alsa_capture()
610 static void abort_alsa_playback(struct ua101 *ua) in abort_alsa_playback() argument
612 if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) in abort_alsa_playback()
613 snd_pcm_stop_xrun(ua->playback.substream); in abort_alsa_playback()
616 static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream, in set_stream_hw() argument
628 substream->runtime->hw.formats = ua->format_bit; in set_stream_hw()
629 substream->runtime->hw.rates = snd_pcm_rate_to_rate_bit(ua->rate); in set_stream_hw()
630 substream->runtime->hw.rate_min = ua->rate; in set_stream_hw()
631 substream->runtime->hw.rate_max = ua->rate; in set_stream_hw()
641 1500000 / ua->packets_per_second, in set_stream_hw()
651 struct ua101 *ua = substream->private_data; in capture_pcm_open() local
654 ua->capture.substream = substream; in capture_pcm_open()
655 err = set_stream_hw(ua, substream, ua->capture.channels); in capture_pcm_open()
659 DIV_ROUND_CLOSEST(ua->rate, ua->packets_per_second); in capture_pcm_open()
662 mutex_lock(&ua->mutex); in capture_pcm_open()
663 err = start_usb_capture(ua); in capture_pcm_open()
665 set_bit(ALSA_CAPTURE_OPEN, &ua->states); in capture_pcm_open()
666 mutex_unlock(&ua->mutex); in capture_pcm_open()
672 struct ua101 *ua = substream->private_data; in playback_pcm_open() local
675 ua->playback.substream = substream; in playback_pcm_open()
676 err = set_stream_hw(ua, substream, ua->playback.channels); in playback_pcm_open()
680 DIV_ROUND_CLOSEST(ua->rate * ua->playback.queue_length, in playback_pcm_open()
681 ua->packets_per_second); in playback_pcm_open()
683 mutex_lock(&ua->mutex); in playback_pcm_open()
684 err = start_usb_capture(ua); in playback_pcm_open()
687 err = start_usb_playback(ua); in playback_pcm_open()
689 if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states)) in playback_pcm_open()
690 stop_usb_capture(ua); in playback_pcm_open()
693 set_bit(ALSA_PLAYBACK_OPEN, &ua->states); in playback_pcm_open()
695 mutex_unlock(&ua->mutex); in playback_pcm_open()
701 struct ua101 *ua = substream->private_data; in capture_pcm_close() local
703 mutex_lock(&ua->mutex); in capture_pcm_close()
704 clear_bit(ALSA_CAPTURE_OPEN, &ua->states); in capture_pcm_close()
705 if (!test_bit(ALSA_PLAYBACK_OPEN, &ua->states)) in capture_pcm_close()
706 stop_usb_capture(ua); in capture_pcm_close()
707 mutex_unlock(&ua->mutex); in capture_pcm_close()
713 struct ua101 *ua = substream->private_data; in playback_pcm_close() local
715 mutex_lock(&ua->mutex); in playback_pcm_close()
716 stop_usb_playback(ua); in playback_pcm_close()
717 clear_bit(ALSA_PLAYBACK_OPEN, &ua->states); in playback_pcm_close()
718 if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states)) in playback_pcm_close()
719 stop_usb_capture(ua); in playback_pcm_close()
720 mutex_unlock(&ua->mutex); in playback_pcm_close()
727 struct ua101 *ua = substream->private_data; in capture_pcm_hw_params() local
730 mutex_lock(&ua->mutex); in capture_pcm_hw_params()
731 err = start_usb_capture(ua); in capture_pcm_hw_params()
732 mutex_unlock(&ua->mutex); in capture_pcm_hw_params()
739 struct ua101 *ua = substream->private_data; in playback_pcm_hw_params() local
742 mutex_lock(&ua->mutex); in playback_pcm_hw_params()
743 err = start_usb_capture(ua); in playback_pcm_hw_params()
745 err = start_usb_playback(ua); in playback_pcm_hw_params()
746 mutex_unlock(&ua->mutex); in playback_pcm_hw_params()
752 struct ua101 *ua = substream->private_data; in capture_pcm_prepare() local
755 mutex_lock(&ua->mutex); in capture_pcm_prepare()
756 err = start_usb_capture(ua); in capture_pcm_prepare()
757 mutex_unlock(&ua->mutex); in capture_pcm_prepare()
767 wait_event(ua->alsa_capture_wait, in capture_pcm_prepare()
768 test_bit(CAPTURE_URB_COMPLETED, &ua->states) || in capture_pcm_prepare()
769 !test_bit(USB_CAPTURE_RUNNING, &ua->states)); in capture_pcm_prepare()
770 if (test_bit(DISCONNECTED, &ua->states)) in capture_pcm_prepare()
772 if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) in capture_pcm_prepare()
775 ua->capture.period_pos = 0; in capture_pcm_prepare()
776 ua->capture.buffer_pos = 0; in capture_pcm_prepare()
782 struct ua101 *ua = substream->private_data; in playback_pcm_prepare() local
785 mutex_lock(&ua->mutex); in playback_pcm_prepare()
786 err = start_usb_capture(ua); in playback_pcm_prepare()
788 err = start_usb_playback(ua); in playback_pcm_prepare()
789 mutex_unlock(&ua->mutex); in playback_pcm_prepare()
794 wait_event(ua->alsa_playback_wait, in playback_pcm_prepare()
795 test_bit(PLAYBACK_URB_COMPLETED, &ua->states) || in playback_pcm_prepare()
796 !test_bit(USB_PLAYBACK_RUNNING, &ua->states)); in playback_pcm_prepare()
797 if (test_bit(DISCONNECTED, &ua->states)) in playback_pcm_prepare()
799 if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states)) in playback_pcm_prepare()
803 ua->playback.period_pos = 0; in playback_pcm_prepare()
804 ua->playback.buffer_pos = 0; in playback_pcm_prepare()
810 struct ua101 *ua = substream->private_data; in capture_pcm_trigger() local
814 if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) in capture_pcm_trigger()
816 set_bit(ALSA_CAPTURE_RUNNING, &ua->states); in capture_pcm_trigger()
819 clear_bit(ALSA_CAPTURE_RUNNING, &ua->states); in capture_pcm_trigger()
828 struct ua101 *ua = substream->private_data; in playback_pcm_trigger() local
832 if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states)) in playback_pcm_trigger()
834 set_bit(ALSA_PLAYBACK_RUNNING, &ua->states); in playback_pcm_trigger()
837 clear_bit(ALSA_PLAYBACK_RUNNING, &ua->states); in playback_pcm_trigger()
844 static inline snd_pcm_uframes_t ua101_pcm_pointer(struct ua101 *ua, in ua101_pcm_pointer() argument
850 spin_lock_irqsave(&ua->lock, flags); in ua101_pcm_pointer()
852 spin_unlock_irqrestore(&ua->lock, flags); in ua101_pcm_pointer()
858 struct ua101 *ua = subs->private_data; in capture_pcm_pointer() local
860 return ua101_pcm_pointer(ua, &ua->capture); in capture_pcm_pointer()
865 struct ua101 *ua = subs->private_data; in playback_pcm_pointer() local
867 return ua101_pcm_pointer(ua, &ua->playback); in playback_pcm_pointer()
940 static int detect_usb_format(struct ua101 *ua) in detect_usb_format() argument
947 fmt_capture = find_format_descriptor(ua->intf[INTF_CAPTURE]); in detect_usb_format()
948 fmt_playback = find_format_descriptor(ua->intf[INTF_PLAYBACK]); in detect_usb_format()
954 ua->format_bit = SNDRV_PCM_FMTBIT_S24_3LE; in detect_usb_format()
957 ua->format_bit = SNDRV_PCM_FMTBIT_S32_LE; in detect_usb_format()
960 dev_err(&ua->dev->dev, "sample width is not 24 or 32 bits\n"); in detect_usb_format()
964 dev_err(&ua->dev->dev, in detect_usb_format()
971 dev_err(&ua->dev->dev, "sample width is not 24 bits\n"); in detect_usb_format()
975 ua->rate = combine_triple(fmt_capture->tSamFreq[0]); in detect_usb_format()
977 if (ua->rate != rate2) { in detect_usb_format()
978 dev_err(&ua->dev->dev, in detect_usb_format()
980 rate2, ua->rate); in detect_usb_format()
984 switch (ua->dev->speed) { in detect_usb_format()
986 ua->packets_per_second = 1000; in detect_usb_format()
989 ua->packets_per_second = 8000; in detect_usb_format()
992 dev_err(&ua->dev->dev, "unknown device speed\n"); in detect_usb_format()
996 ua->capture.channels = fmt_capture->bNrChannels; in detect_usb_format()
997 ua->playback.channels = fmt_playback->bNrChannels; in detect_usb_format()
998 ua->capture.frame_bytes = in detect_usb_format()
999 fmt_capture->bSubframeSize * ua->capture.channels; in detect_usb_format()
1000 ua->playback.frame_bytes = in detect_usb_format()
1001 fmt_playback->bSubframeSize * ua->playback.channels; in detect_usb_format()
1003 epd = &ua->intf[INTF_CAPTURE]->altsetting[1].endpoint[0].desc; in detect_usb_format()
1005 dev_err(&ua->dev->dev, "invalid capture endpoint\n"); in detect_usb_format()
1008 ua->capture.usb_pipe = usb_rcvisocpipe(ua->dev, usb_endpoint_num(epd)); in detect_usb_format()
1009 ua->capture.max_packet_bytes = usb_endpoint_maxp(epd); in detect_usb_format()
1011 epd = &ua->intf[INTF_PLAYBACK]->altsetting[1].endpoint[0].desc; in detect_usb_format()
1013 dev_err(&ua->dev->dev, "invalid playback endpoint\n"); in detect_usb_format()
1016 ua->playback.usb_pipe = usb_sndisocpipe(ua->dev, usb_endpoint_num(epd)); in detect_usb_format()
1017 ua->playback.max_packet_bytes = usb_endpoint_maxp(epd); in detect_usb_format()
1021 static int alloc_stream_buffers(struct ua101 *ua, struct ua101_stream *stream) in alloc_stream_buffers() argument
1044 usb_alloc_coherent(ua->dev, size, GFP_KERNEL, in alloc_stream_buffers()
1054 dev_err(&ua->dev->dev, "too many packets\n"); in alloc_stream_buffers()
1060 static void free_stream_buffers(struct ua101 *ua, struct ua101_stream *stream) in free_stream_buffers() argument
1065 usb_free_coherent(ua->dev, in free_stream_buffers()
1071 static int alloc_stream_urbs(struct ua101 *ua, struct ua101_stream *stream, in alloc_stream_urbs() argument
1090 urb->urb.dev = ua->dev; in alloc_stream_urbs()
1098 urb->urb.context = ua; in alloc_stream_urbs()
1111 dev_err(&ua->dev->dev, "internal buffer size error\n"); in alloc_stream_urbs()
1125 static void free_usb_related_resources(struct ua101 *ua, in free_usb_related_resources() argument
1131 mutex_lock(&ua->mutex); in free_usb_related_resources()
1132 free_stream_urbs(&ua->capture); in free_usb_related_resources()
1133 free_stream_urbs(&ua->playback); in free_usb_related_resources()
1134 mutex_unlock(&ua->mutex); in free_usb_related_resources()
1135 free_stream_buffers(ua, &ua->capture); in free_usb_related_resources()
1136 free_stream_buffers(ua, &ua->playback); in free_usb_related_resources()
1138 for (i = 0; i < ARRAY_SIZE(ua->intf); ++i) { in free_usb_related_resources()
1139 mutex_lock(&ua->mutex); in free_usb_related_resources()
1140 intf = ua->intf[i]; in free_usb_related_resources()
1141 ua->intf[i] = NULL; in free_usb_related_resources()
1142 mutex_unlock(&ua->mutex); in free_usb_related_resources()
1154 struct ua101 *ua = card->private_data; in ua101_card_free() local
1156 mutex_destroy(&ua->mutex); in ua101_card_free()
1171 { /* UA-101 */ in ua101_probe()
1176 { /* UA-1000 */ in ua101_probe()
1183 struct ua101 *ua; in ua101_probe() local
1207 sizeof(*ua), &card); in ua101_probe()
1213 ua = card->private_data; in ua101_probe()
1214 ua->dev = interface_to_usbdev(interface); in ua101_probe()
1215 ua->card = card; in ua101_probe()
1216 ua->card_index = card_index; in ua101_probe()
1217 INIT_LIST_HEAD(&ua->midi_list); in ua101_probe()
1218 spin_lock_init(&ua->lock); in ua101_probe()
1219 mutex_init(&ua->mutex); in ua101_probe()
1220 INIT_LIST_HEAD(&ua->ready_playback_urbs); in ua101_probe()
1221 INIT_WORK(&ua->playback_work, playback_work); in ua101_probe()
1222 init_waitqueue_head(&ua->alsa_capture_wait); in ua101_probe()
1223 init_waitqueue_head(&ua->rate_feedback_wait); in ua101_probe()
1224 init_waitqueue_head(&ua->alsa_playback_wait); in ua101_probe()
1226 ua->intf[0] = interface; in ua101_probe()
1227 for (i = 1; i < ARRAY_SIZE(ua->intf); ++i) { in ua101_probe()
1228 ua->intf[i] = usb_ifnum_to_if(ua->dev, in ua101_probe()
1230 if (!ua->intf[i]) { in ua101_probe()
1231 dev_err(&ua->dev->dev, "interface %u not found\n", in ua101_probe()
1237 ua->intf[i], ua); in ua101_probe()
1239 ua->intf[i] = NULL; in ua101_probe()
1245 err = detect_usb_format(ua); in ua101_probe()
1249 name = usb_id->idProduct == 0x0044 ? "UA-1000" : "UA-101"; in ua101_probe()
1250 strcpy(card->driver, "UA-101"); in ua101_probe()
1252 usb_make_path(ua->dev, usb_path, sizeof(usb_path)); in ua101_probe()
1253 snprintf(ua->card->longname, sizeof(ua->card->longname), in ua101_probe()
1255 ua->dev->serial ? ua->dev->serial : "?", ua->rate, usb_path, in ua101_probe()
1256 ua->dev->speed == USB_SPEED_HIGH ? "high" : "full"); in ua101_probe()
1258 err = alloc_stream_buffers(ua, &ua->capture); in ua101_probe()
1261 err = alloc_stream_buffers(ua, &ua->playback); in ua101_probe()
1265 err = alloc_stream_urbs(ua, &ua->capture, capture_urb_complete); in ua101_probe()
1268 err = alloc_stream_urbs(ua, &ua->playback, playback_urb_complete); in ua101_probe()
1272 err = snd_pcm_new(card, name, 0, 1, 1, &ua->pcm); in ua101_probe()
1275 ua->pcm->private_data = ua; in ua101_probe()
1276 strcpy(ua->pcm->name, name); in ua101_probe()
1277 snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_pcm_ops); in ua101_probe()
1278 snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_pcm_ops); in ua101_probe()
1279 snd_pcm_set_managed_buffer_all(ua->pcm, SNDRV_DMA_TYPE_VMALLOC, in ua101_probe()
1282 err = snd_usbmidi_create(card, ua->intf[INTF_MIDI], in ua101_probe()
1283 &ua->midi_list, &midi_quirk); in ua101_probe()
1291 usb_set_intfdata(interface, ua); in ua101_probe()
1298 free_usb_related_resources(ua, interface); in ua101_probe()
1306 struct ua101 *ua = usb_get_intfdata(interface); in ua101_disconnect() local
1309 if (!ua) in ua101_disconnect()
1314 set_bit(DISCONNECTED, &ua->states); in ua101_disconnect()
1315 wake_up(&ua->rate_feedback_wait); in ua101_disconnect()
1318 snd_card_disconnect(ua->card); in ua101_disconnect()
1321 list_for_each(midi, &ua->midi_list) in ua101_disconnect()
1323 abort_alsa_playback(ua); in ua101_disconnect()
1324 abort_alsa_capture(ua); in ua101_disconnect()
1325 mutex_lock(&ua->mutex); in ua101_disconnect()
1326 stop_usb_playback(ua); in ua101_disconnect()
1327 stop_usb_capture(ua); in ua101_disconnect()
1328 mutex_unlock(&ua->mutex); in ua101_disconnect()
1330 free_usb_related_resources(ua, interface); in ua101_disconnect()
1332 devices_used &= ~(1 << ua->card_index); in ua101_disconnect()
1334 snd_card_free_when_closed(ua->card); in ua101_disconnect()
1340 { USB_DEVICE(0x0582, 0x0044) }, /* UA-1000 high speed */
1341 { USB_DEVICE(0x0582, 0x007d) }, /* UA-101 high speed */
1342 { USB_DEVICE(0x0582, 0x008d) }, /* UA-101 full speed */