Lines Matching +full:pcm +full:- +full:interface +full:- +full:rate

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Edirol UA-101/UA-1000 driver
14 #include <sound/pcm.h>
19 MODULE_DESCRIPTION("Edirol UA-101/1000 driver");
32 * This magic value optimizes memory usage efficiency for the UA-101's packet
55 __stringify(MIN_QUEUE_LENGTH)"-"__stringify(MAX_QUEUE_LENGTH));
83 struct snd_pcm *pcm;
86 unsigned int rate;
92 /* FIFO to synchronize playback rate to capture rate */
134 case -ENODEV:
136 case -ENOENT:
138 case -EPIPE:
140 case -ENOSPC:
142 case -ESHUTDOWN:
144 case -EHOSTUNREACH:
146 case -EINVAL:
147 case -EAGAIN:
148 case -EFBIG:
149 case -EMSGSIZE:
158 if (test_and_clear_bit(USB_CAPTURE_RUNNING, &ua->states)) {
159 wake_up(&ua->alsa_capture_wait);
160 wake_up(&ua->rate_feedback_wait);
166 if (test_and_clear_bit(USB_PLAYBACK_RUNNING, &ua->states))
167 wake_up(&ua->alsa_playback_wait);
173 struct ua101 *ua = urb->urb.context;
175 if (unlikely(urb->urb.status == -ENOENT || /* unlinked */
176 urb->urb.status == -ENODEV || /* device removed */
177 urb->urb.status == -ECONNRESET || /* unlinked */
178 urb->urb.status == -ESHUTDOWN)) { /* device disabled */
184 if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) {
186 guard(spinlock_irqsave)(&ua->lock);
187 list_add_tail(&urb->ready_list, &ua->ready_playback_urbs);
188 if (ua->rate_feedback_count > 0)
189 queue_work(system_highpri_wq, &ua->playback_work);
190 ua->playback.substream->runtime->delay -=
191 urb->urb.iso_frame_desc[0].length /
192 ua->playback.frame_bytes;
198 struct ua101 *ua = urb->context;
200 urb->complete = playback_urb_complete;
203 set_bit(PLAYBACK_URB_COMPLETED, &ua->states);
204 wake_up(&ua->alsa_playback_wait);
215 runtime = stream->substream->runtime;
216 frame_bytes = stream->frame_bytes;
217 source = runtime->dma_area + stream->buffer_pos * frame_bytes;
218 if (stream->buffer_pos + frames <= runtime->buffer_size) {
219 memcpy(urb->transfer_buffer, source, frames * frame_bytes);
222 frames1 = runtime->buffer_size - stream->buffer_pos;
223 memcpy(urb->transfer_buffer, source, frames1 * frame_bytes);
224 memcpy(urb->transfer_buffer + frames1 * frame_bytes,
225 runtime->dma_area, (frames - frames1) * frame_bytes);
228 stream->buffer_pos += frames;
229 if (stream->buffer_pos >= runtime->buffer_size)
230 stream->buffer_pos -= runtime->buffer_size;
231 stream->period_pos += frames;
232 if (stream->period_pos >= runtime->period_size) {
233 stream->period_pos -= runtime->period_size;
243 if (*value >= ua->playback.queue_length)
244 *value -= ua->playback.queue_length;
255 if (unlikely(!test_bit(USB_PLAYBACK_RUNNING, &ua->states)))
259 * Synchronizing the playback rate to the capture rate is done by using
269 scoped_guard(spinlock_irqsave, &ua->lock) {
270 while (ua->rate_feedback_count > 0 &&
271 !list_empty(&ua->ready_playback_urbs)) {
273 frames = ua->rate_feedback[ua->rate_feedback_start];
274 add_with_wraparound(ua, &ua->rate_feedback_start, 1);
275 ua->rate_feedback_count--;
278 urb = list_first_entry(&ua->ready_playback_urbs,
280 list_del(&urb->ready_list);
283 urb->urb.iso_frame_desc[0].length =
284 frames * ua->playback.frame_bytes;
285 if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states))
286 do_period_elapsed |= copy_playback_data(&ua->playback,
287 &urb->urb,
290 memset(urb->urb.transfer_buffer, 0,
291 urb->urb.iso_frame_desc[0].length);
294 err = usb_submit_urb(&urb->urb, GFP_ATOMIC);
298 dev_err(&ua->dev->dev, "USB request error %d: %s\n",
302 ua->playback.substream->runtime->delay += frames;
307 snd_pcm_period_elapsed(ua->playback.substream);
318 runtime = stream->substream->runtime;
319 frame_bytes = stream->frame_bytes;
320 dest = runtime->dma_area + stream->buffer_pos * frame_bytes;
321 if (stream->buffer_pos + frames <= runtime->buffer_size) {
322 memcpy(dest, urb->transfer_buffer, frames * frame_bytes);
325 frames1 = runtime->buffer_size - stream->buffer_pos;
326 memcpy(dest, urb->transfer_buffer, frames1 * frame_bytes);
327 memcpy(runtime->dma_area,
328 urb->transfer_buffer + frames1 * frame_bytes,
329 (frames - frames1) * frame_bytes);
332 stream->buffer_pos += frames;
333 if (stream->buffer_pos >= runtime->buffer_size)
334 stream->buffer_pos -= runtime->buffer_size;
335 stream->period_pos += frames;
336 if (stream->period_pos >= runtime->period_size) {
337 stream->period_pos -= runtime->period_size;
345 struct ua101 *ua = urb->context;
346 struct ua101_stream *stream = &ua->capture;
351 if (unlikely(urb->status == -ENOENT || /* unlinked */
352 urb->status == -ENODEV || /* device removed */
353 urb->status == -ECONNRESET || /* unlinked */
354 urb->status == -ESHUTDOWN)) /* device disabled */
357 if (urb->status >= 0 && urb->iso_frame_desc[0].status >= 0)
358 frames = urb->iso_frame_desc[0].actual_length /
359 stream->frame_bytes;
363 scoped_guard(spinlock_irqsave, &ua->lock) {
365 if (frames > 0 && test_bit(ALSA_CAPTURE_RUNNING, &ua->states))
370 if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) {
373 dev_err(&ua->dev->dev, "USB request error %d: %s\n",
379 write_ptr = ua->rate_feedback_start;
380 add_with_wraparound(ua, &write_ptr, ua->rate_feedback_count);
381 ua->rate_feedback[write_ptr] = frames;
382 if (ua->rate_feedback_count < ua->playback.queue_length) {
383 ua->rate_feedback_count++;
384 if (ua->rate_feedback_count ==
385 ua->playback.queue_length)
386 wake_up(&ua->rate_feedback_wait);
394 add_with_wraparound(ua, &ua->rate_feedback_start, 1);
396 if (test_bit(USB_PLAYBACK_RUNNING, &ua->states) &&
397 !list_empty(&ua->ready_playback_urbs))
398 queue_work(system_highpri_wq, &ua->playback_work);
403 snd_pcm_period_elapsed(stream->substream);
416 struct ua101 *ua = urb->context;
418 urb->complete = capture_urb_complete;
421 set_bit(CAPTURE_URB_COMPLETED, &ua->states);
422 wake_up(&ua->alsa_capture_wait);
429 for (i = 0; i < stream->queue_length; ++i) {
430 int err = usb_submit_urb(&stream->urbs[i]->urb, GFP_KERNEL);
432 dev_err(&ua->dev->dev, "USB request error %d: %s\n",
444 for (i = 0; i < stream->queue_length; ++i)
445 if (stream->urbs[i])
446 usb_kill_urb(&stream->urbs[i]->urb);
453 alts = ua->intf[intf_index]->cur_altsetting;
454 if (alts->desc.bAlternateSetting != 1) {
455 int err = usb_set_interface(ua->dev,
456 alts->desc.bInterfaceNumber, 1);
458 dev_err(&ua->dev->dev,
459 "cannot initialize interface; error %d: %s\n",
471 if (!ua->intf[intf_index])
474 alts = ua->intf[intf_index]->cur_altsetting;
475 if (alts->desc.bAlternateSetting != 0) {
476 int err = usb_set_interface(ua->dev,
477 alts->desc.bInterfaceNumber, 0);
478 if (err < 0 && !test_bit(DISCONNECTED, &ua->states))
479 dev_warn(&ua->dev->dev,
480 "interface reset failed; error %d: %s\n",
487 clear_bit(USB_CAPTURE_RUNNING, &ua->states);
489 kill_stream_urbs(&ua->capture);
498 if (test_bit(DISCONNECTED, &ua->states))
499 return -ENODEV;
501 if (test_bit(USB_CAPTURE_RUNNING, &ua->states))
504 kill_stream_urbs(&ua->capture);
510 clear_bit(CAPTURE_URB_COMPLETED, &ua->states);
511 ua->capture.urbs[0]->urb.complete = first_capture_urb_complete;
512 ua->rate_feedback_start = 0;
513 ua->rate_feedback_count = 0;
515 set_bit(USB_CAPTURE_RUNNING, &ua->states);
516 err = submit_stream_urbs(ua, &ua->capture);
524 clear_bit(USB_PLAYBACK_RUNNING, &ua->states);
526 kill_stream_urbs(&ua->playback);
528 cancel_work_sync(&ua->playback_work);
539 if (test_bit(DISCONNECTED, &ua->states))
540 return -ENODEV;
542 if (test_bit(USB_PLAYBACK_RUNNING, &ua->states))
545 kill_stream_urbs(&ua->playback);
546 cancel_work_sync(&ua->playback_work);
552 clear_bit(PLAYBACK_URB_COMPLETED, &ua->states);
553 ua->playback.urbs[0]->urb.complete =
555 scoped_guard(spinlock_irq, &ua->lock) {
556 INIT_LIST_HEAD(&ua->ready_playback_urbs);
563 wait_event(ua->rate_feedback_wait,
564 ua->rate_feedback_count >= ua->playback.queue_length ||
565 !test_bit(USB_CAPTURE_RUNNING, &ua->states) ||
566 test_bit(DISCONNECTED, &ua->states));
567 if (test_bit(DISCONNECTED, &ua->states)) {
569 return -ENODEV;
571 if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) {
573 return -EIO;
576 for (i = 0; i < ua->playback.queue_length; ++i) {
578 scoped_guard(spinlock_irq, &ua->lock) {
579 frames = ua->rate_feedback[ua->rate_feedback_start];
580 add_with_wraparound(ua, &ua->rate_feedback_start, 1);
581 ua->rate_feedback_count--;
583 urb = &ua->playback.urbs[i]->urb;
584 urb->iso_frame_desc[0].length =
585 frames * ua->playback.frame_bytes;
586 memset(urb->transfer_buffer, 0,
587 urb->iso_frame_desc[0].length);
590 set_bit(USB_PLAYBACK_RUNNING, &ua->states);
591 err = submit_stream_urbs(ua, &ua->playback);
599 if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states))
600 snd_pcm_stop_xrun(ua->capture.substream);
605 if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states))
606 snd_pcm_stop_xrun(ua->playback.substream);
614 substream->runtime->hw.info =
621 substream->runtime->hw.formats = ua->format_bit;
622 substream->runtime->hw.rates = snd_pcm_rate_to_rate_bit(ua->rate);
623 substream->runtime->hw.rate_min = ua->rate;
624 substream->runtime->hw.rate_max = ua->rate;
625 substream->runtime->hw.channels_min = channels;
626 substream->runtime->hw.channels_max = channels;
627 substream->runtime->hw.buffer_bytes_max = 45000 * 1024;
628 substream->runtime->hw.period_bytes_min = 1;
629 substream->runtime->hw.period_bytes_max = UINT_MAX;
630 substream->runtime->hw.periods_min = 2;
631 substream->runtime->hw.periods_max = UINT_MAX;
632 err = snd_pcm_hw_constraint_minmax(substream->runtime,
634 1500000 / ua->packets_per_second,
638 err = snd_pcm_hw_constraint_msbits(substream->runtime, 0, 32, 24);
644 struct ua101 *ua = substream->private_data;
647 ua->capture.substream = substream;
648 err = set_stream_hw(ua, substream, ua->capture.channels);
651 substream->runtime->hw.fifo_size =
652 DIV_ROUND_CLOSEST(ua->rate, ua->packets_per_second);
653 substream->runtime->delay = substream->runtime->hw.fifo_size;
655 guard(mutex)(&ua->mutex);
658 set_bit(ALSA_CAPTURE_OPEN, &ua->states);
664 struct ua101 *ua = substream->private_data;
667 ua->playback.substream = substream;
668 err = set_stream_hw(ua, substream, ua->playback.channels);
671 substream->runtime->hw.fifo_size =
672 DIV_ROUND_CLOSEST(ua->rate * ua->playback.queue_length,
673 ua->packets_per_second);
675 guard(mutex)(&ua->mutex);
681 if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states))
685 set_bit(ALSA_PLAYBACK_OPEN, &ua->states);
691 struct ua101 *ua = substream->private_data;
693 guard(mutex)(&ua->mutex);
694 clear_bit(ALSA_CAPTURE_OPEN, &ua->states);
695 if (!test_bit(ALSA_PLAYBACK_OPEN, &ua->states))
702 struct ua101 *ua = substream->private_data;
704 guard(mutex)(&ua->mutex);
706 clear_bit(ALSA_PLAYBACK_OPEN, &ua->states);
707 if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states))
715 struct ua101 *ua = substream->private_data;
717 guard(mutex)(&ua->mutex);
724 struct ua101 *ua = substream->private_data;
727 guard(mutex)(&ua->mutex);
736 struct ua101 *ua = substream->private_data;
739 scoped_guard(mutex, &ua->mutex) {
751 wait_event(ua->alsa_capture_wait,
752 test_bit(CAPTURE_URB_COMPLETED, &ua->states) ||
753 !test_bit(USB_CAPTURE_RUNNING, &ua->states));
754 if (test_bit(DISCONNECTED, &ua->states))
755 return -ENODEV;
756 if (!test_bit(USB_CAPTURE_RUNNING, &ua->states))
757 return -EIO;
759 ua->capture.period_pos = 0;
760 ua->capture.buffer_pos = 0;
766 struct ua101 *ua = substream->private_data;
769 scoped_guard(mutex, &ua->mutex) {
778 wait_event(ua->alsa_playback_wait,
779 test_bit(PLAYBACK_URB_COMPLETED, &ua->states) ||
780 !test_bit(USB_PLAYBACK_RUNNING, &ua->states));
781 if (test_bit(DISCONNECTED, &ua->states))
782 return -ENODEV;
783 if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states))
784 return -EIO;
786 substream->runtime->delay = 0;
787 ua->playback.period_pos = 0;
788 ua->playback.buffer_pos = 0;
794 struct ua101 *ua = substream->private_data;
798 if (!test_bit(USB_CAPTURE_RUNNING, &ua->states))
799 return -EIO;
800 set_bit(ALSA_CAPTURE_RUNNING, &ua->states);
803 clear_bit(ALSA_CAPTURE_RUNNING, &ua->states);
806 return -EINVAL;
812 struct ua101 *ua = substream->private_data;
816 if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states))
817 return -EIO;
818 set_bit(ALSA_PLAYBACK_RUNNING, &ua->states);
821 clear_bit(ALSA_PLAYBACK_RUNNING, &ua->states);
824 return -EINVAL;
831 guard(spinlock_irqsave)(&ua->lock);
832 return stream->buffer_pos;
837 struct ua101 *ua = subs->private_data;
839 return ua101_pcm_pointer(ua, &ua->capture);
844 struct ua101 *ua = subs->private_data;
846 return ua101_pcm_pointer(ua, &ua->playback);
868 find_format_descriptor(struct usb_interface *interface)
874 if (interface->num_altsetting != 2) {
875 dev_err(&interface->dev, "invalid num_altsetting\n");
879 alt = &interface->altsetting[0];
880 if (alt->desc.bNumEndpoints != 0) {
881 dev_err(&interface->dev, "invalid bNumEndpoints\n");
885 alt = &interface->altsetting[1];
886 if (alt->desc.bNumEndpoints != 1) {
887 dev_err(&interface->dev, "invalid bNumEndpoints\n");
891 extra = alt->extra;
892 extralen = alt->extralen;
897 if (desc->bLength > extralen) {
898 dev_err(&interface->dev, "descriptor overflow\n");
901 if (desc->bLength == UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(1) &&
902 desc->bDescriptorType == USB_DT_CS_INTERFACE &&
903 desc->bDescriptorSubtype == UAC_FORMAT_TYPE) {
904 if (desc->bFormatType != UAC_FORMAT_TYPE_I_PCM ||
905 desc->bSamFreqType != 1) {
906 dev_err(&interface->dev,
912 extralen -= desc->bLength;
913 extra += desc->bLength;
915 dev_err(&interface->dev, "sample format descriptor not found\n");
926 fmt_capture = find_format_descriptor(ua->intf[INTF_CAPTURE]);
927 fmt_playback = find_format_descriptor(ua->intf[INTF_PLAYBACK]);
929 return -ENXIO;
931 switch (fmt_capture->bSubframeSize) {
933 ua->format_bit = SNDRV_PCM_FMTBIT_S24_3LE;
936 ua->format_bit = SNDRV_PCM_FMTBIT_S32_LE;
939 dev_err(&ua->dev->dev, "sample width is not 24 or 32 bits\n");
940 return -ENXIO;
942 if (fmt_capture->bSubframeSize != fmt_playback->bSubframeSize) {
943 dev_err(&ua->dev->dev,
945 return -ENXIO;
948 if (fmt_capture->bBitResolution != 24 ||
949 fmt_playback->bBitResolution != 24) {
950 dev_err(&ua->dev->dev, "sample width is not 24 bits\n");
951 return -ENXIO;
954 ua->rate = combine_triple(fmt_capture->tSamFreq[0]);
955 rate2 = combine_triple(fmt_playback->tSamFreq[0]);
956 if (ua->rate != rate2) {
957 dev_err(&ua->dev->dev,
959 rate2, ua->rate);
960 return -ENXIO;
963 switch (ua->dev->speed) {
965 ua->packets_per_second = 1000;
968 ua->packets_per_second = 8000;
971 dev_err(&ua->dev->dev, "unknown device speed\n");
972 return -ENXIO;
975 ua->capture.channels = fmt_capture->bNrChannels;
976 ua->playback.channels = fmt_playback->bNrChannels;
977 ua->capture.frame_bytes =
978 fmt_capture->bSubframeSize * ua->capture.channels;
979 ua->playback.frame_bytes =
980 fmt_playback->bSubframeSize * ua->playback.channels;
982 epd = &ua->intf[INTF_CAPTURE]->altsetting[1].endpoint[0].desc;
984 dev_err(&ua->dev->dev, "invalid capture endpoint\n");
985 return -ENXIO;
987 ua->capture.usb_pipe = usb_rcvisocpipe(ua->dev, usb_endpoint_num(epd));
988 ua->capture.max_packet_bytes = usb_endpoint_maxp(epd);
990 epd = &ua->intf[INTF_PLAYBACK]->altsetting[1].endpoint[0].desc;
992 dev_err(&ua->dev->dev, "invalid playback endpoint\n");
993 return -ENXIO;
995 ua->playback.usb_pipe = usb_sndisocpipe(ua->dev, usb_endpoint_num(epd));
996 ua->playback.max_packet_bytes = usb_endpoint_maxp(epd);
1005 stream->queue_length = queue_length;
1006 stream->queue_length = max(stream->queue_length,
1008 stream->queue_length = min(stream->queue_length,
1017 remaining_packets = stream->queue_length;
1018 packets_per_page = PAGE_SIZE / stream->max_packet_bytes;
1019 for (i = 0; i < ARRAY_SIZE(stream->buffers); ++i) {
1021 size = packets * stream->max_packet_bytes;
1022 stream->buffers[i].addr =
1023 usb_alloc_coherent(ua->dev, size, GFP_KERNEL,
1024 &stream->buffers[i].dma);
1025 if (!stream->buffers[i].addr)
1026 return -ENOMEM;
1027 stream->buffers[i].size = size;
1028 remaining_packets -= packets;
1033 dev_err(&ua->dev->dev, "too many packets\n");
1034 return -ENXIO;
1043 for (i = 0; i < ARRAY_SIZE(stream->buffers); ++i)
1044 usb_free_coherent(ua->dev,
1045 stream->buffers[i].size,
1046 stream->buffers[i].addr,
1047 stream->buffers[i].dma);
1053 unsigned max_packet_size = stream->max_packet_bytes;
1057 for (b = 0; b < ARRAY_SIZE(stream->buffers); ++b) {
1058 unsigned int size = stream->buffers[b].size;
1059 u8 *addr = stream->buffers[b].addr;
1060 dma_addr_t dma = stream->buffers[b].dma;
1063 if (u >= stream->queue_length)
1067 return -ENOMEM;
1068 usb_init_urb(&urb->urb);
1069 urb->urb.dev = ua->dev;
1070 urb->urb.pipe = stream->usb_pipe;
1071 urb->urb.transfer_flags = URB_NO_TRANSFER_DMA_MAP;
1072 urb->urb.transfer_buffer = addr;
1073 urb->urb.transfer_dma = dma;
1074 urb->urb.transfer_buffer_length = max_packet_size;
1075 urb->urb.number_of_packets = 1;
1076 urb->urb.interval = 1;
1077 urb->urb.context = ua;
1078 urb->urb.complete = urb_complete;
1079 urb->urb.iso_frame_desc[0].offset = 0;
1080 urb->urb.iso_frame_desc[0].length = max_packet_size;
1081 stream->urbs[u++] = urb;
1082 size -= max_packet_size;
1087 if (u == stream->queue_length)
1090 dev_err(&ua->dev->dev, "internal buffer size error\n");
1091 return -ENXIO;
1098 for (i = 0; i < stream->queue_length; ++i) {
1099 kfree(stream->urbs[i]);
1100 stream->urbs[i] = NULL;
1105 struct usb_interface *interface)
1110 scoped_guard(mutex, &ua->mutex) {
1111 free_stream_urbs(&ua->capture);
1112 free_stream_urbs(&ua->playback);
1114 free_stream_buffers(ua, &ua->capture);
1115 free_stream_buffers(ua, &ua->playback);
1117 for (i = 0; i < ARRAY_SIZE(ua->intf); ++i) {
1118 scoped_guard(mutex, &ua->mutex) {
1119 intf = ua->intf[i];
1120 ua->intf[i] = NULL;
1124 if (intf != interface)
1133 struct ua101 *ua = card->private_data;
1135 mutex_destroy(&ua->mutex);
1138 static int ua101_probe(struct usb_interface *interface,
1150 { /* UA-101 */
1155 { /* UA-1000 */
1169 is_ua1000 = usb_id->idProduct == 0x0044;
1171 if (interface->altsetting->desc.bInterfaceNumber !=
1173 return -ENODEV;
1181 return -ENOENT;
1182 err = snd_card_new(&interface->dev,
1187 card->private_free = ua101_card_free;
1188 ua = card->private_data;
1189 ua->dev = interface_to_usbdev(interface);
1190 ua->card = card;
1191 ua->card_index = card_index;
1192 INIT_LIST_HEAD(&ua->midi_list);
1193 spin_lock_init(&ua->lock);
1194 mutex_init(&ua->mutex);
1195 INIT_LIST_HEAD(&ua->ready_playback_urbs);
1196 INIT_WORK(&ua->playback_work, playback_work);
1197 init_waitqueue_head(&ua->alsa_capture_wait);
1198 init_waitqueue_head(&ua->rate_feedback_wait);
1199 init_waitqueue_head(&ua->alsa_playback_wait);
1201 ua->intf[0] = interface;
1202 for (i = 1; i < ARRAY_SIZE(ua->intf); ++i) {
1203 ua->intf[i] = usb_ifnum_to_if(ua->dev,
1205 if (!ua->intf[i]) {
1206 dev_err(&ua->dev->dev, "interface %u not found\n",
1208 err = -ENXIO;
1212 ua->intf[i], ua);
1214 ua->intf[i] = NULL;
1215 err = -EBUSY;
1224 name = usb_id->idProduct == 0x0044 ? "UA-1000" : "UA-101";
1225 strscpy(card->driver, "UA-101");
1226 strscpy(card->shortname, name);
1227 usb_make_path(ua->dev, usb_path, sizeof(usb_path));
1228 snprintf(ua->card->longname, sizeof(ua->card->longname),
1230 ua->dev->serial ? ua->dev->serial : "?", ua->rate, usb_path,
1231 ua->dev->speed == USB_SPEED_HIGH ? "high" : "full");
1233 err = alloc_stream_buffers(ua, &ua->capture);
1236 err = alloc_stream_buffers(ua, &ua->playback);
1240 err = alloc_stream_urbs(ua, &ua->capture, capture_urb_complete);
1243 err = alloc_stream_urbs(ua, &ua->playback, playback_urb_complete);
1247 err = snd_pcm_new(card, name, 0, 1, 1, &ua->pcm);
1250 ua->pcm->private_data = ua;
1251 strscpy(ua->pcm->name, name);
1252 snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_pcm_ops);
1253 snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_pcm_ops);
1254 snd_pcm_set_managed_buffer_all(ua->pcm, SNDRV_DMA_TYPE_VMALLOC,
1257 err = snd_usbmidi_create(card, ua->intf[INTF_MIDI],
1258 &ua->midi_list, &midi_quirk);
1266 usb_set_intfdata(interface, ua);
1272 free_usb_related_resources(ua, interface);
1277 static void ua101_disconnect(struct usb_interface *interface)
1279 struct ua101 *ua = usb_get_intfdata(interface);
1287 set_bit(DISCONNECTED, &ua->states);
1288 wake_up(&ua->rate_feedback_wait);
1291 snd_card_disconnect(ua->card);
1294 list_for_each(midi, &ua->midi_list)
1298 scoped_guard(mutex, &ua->mutex) {
1303 free_usb_related_resources(ua, interface);
1305 devices_used &= ~(1 << ua->card_index);
1307 snd_card_free_when_closed(ua->card);
1311 { USB_DEVICE(0x0582, 0x0044) }, /* UA-1000 high speed */
1312 { USB_DEVICE(0x0582, 0x007d) }, /* UA-101 high speed */
1313 { USB_DEVICE(0x0582, 0x008d) }, /* UA-101 full speed */
1319 .name = "snd-ua101",