• Home
  • Raw
  • Download

Lines Matching +full:scaled +full:- +full:sync

14  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
54 * expect the payload to carry Q10.14 / Q16.16 formatted sync information
89 if (u->buffer_size) in release_urb_ctx()
90 usb_free_coherent(u->ep->chip->dev, u->buffer_size, in release_urb_ctx()
91 u->urb->transfer_buffer, in release_urb_ctx()
92 u->urb->transfer_dma); in release_urb_ctx()
93 usb_free_urb(u->urb); in release_urb_ctx()
94 u->urb = NULL; in release_urb_ctx()
100 case -ENODEV: in usb_error_string()
102 case -ENOENT: in usb_error_string()
104 case -EPIPE: in usb_error_string()
106 case -ENOSPC: in usb_error_string()
108 case -ESHUTDOWN: in usb_error_string()
110 case -EHOSTUNREACH: in usb_error_string()
112 case -EINVAL: in usb_error_string()
113 case -EAGAIN: in usb_error_string()
114 case -EFBIG: in usb_error_string()
115 case -EMSGSIZE: in usb_error_string()
132 return ep->sync_master && in snd_usb_endpoint_implicit_feedback_sink()
133 ep->sync_master->type == SND_USB_ENDPOINT_TYPE_DATA && in snd_usb_endpoint_implicit_feedback_sink()
134 ep->type == SND_USB_ENDPOINT_TYPE_DATA && in snd_usb_endpoint_implicit_feedback_sink()
135 usb_pipeout(ep->pipe); in snd_usb_endpoint_implicit_feedback_sink()
139 * For streaming based on information derived from sync endpoints,
150 if (ep->fill_max) in snd_usb_endpoint_next_packet_size()
151 return ep->maxframesize; in snd_usb_endpoint_next_packet_size()
153 spin_lock_irqsave(&ep->lock, flags); in snd_usb_endpoint_next_packet_size()
154 ep->phase = (ep->phase & 0xffff) in snd_usb_endpoint_next_packet_size()
155 + (ep->freqm << ep->datainterval); in snd_usb_endpoint_next_packet_size()
156 ret = min(ep->phase >> 16, ep->maxframesize); in snd_usb_endpoint_next_packet_size()
157 spin_unlock_irqrestore(&ep->lock, flags); in snd_usb_endpoint_next_packet_size()
165 if (ep->retire_data_urb) in retire_outbound_urb()
166 ep->retire_data_urb(ep->data_subs, urb_ctx->urb); in retire_outbound_urb()
172 struct urb *urb = urb_ctx->urb; in retire_inbound_urb()
174 if (unlikely(ep->skip_packets > 0)) { in retire_inbound_urb()
175 ep->skip_packets--; in retire_inbound_urb()
179 if (ep->sync_slave) in retire_inbound_urb()
180 snd_usb_handle_sync_urb(ep->sync_slave, ep, urb); in retire_inbound_urb()
182 if (ep->retire_data_urb) in retire_inbound_urb()
183 ep->retire_data_urb(ep->data_subs, urb); in retire_inbound_urb()
189 struct urb *urb = ctx->urb; in prepare_silent_urb()
196 if (ep->chip->tx_length_quirk) in prepare_silent_urb()
199 for (i = 0; i < ctx->packets; ++i) { in prepare_silent_urb()
204 if (ctx->packet_size[i]) in prepare_silent_urb()
205 counts = ctx->packet_size[i]; in prepare_silent_urb()
209 length = counts * ep->stride; /* number of silent bytes */ in prepare_silent_urb()
210 offset = offs * ep->stride + extra * i; in prepare_silent_urb()
211 urb->iso_frame_desc[i].offset = offset; in prepare_silent_urb()
212 urb->iso_frame_desc[i].length = length + extra; in prepare_silent_urb()
215 memcpy(urb->transfer_buffer + offset, in prepare_silent_urb()
218 memset(urb->transfer_buffer + offset + extra, in prepare_silent_urb()
219 ep->silence_value, length); in prepare_silent_urb()
223 urb->number_of_packets = ctx->packets; in prepare_silent_urb()
224 urb->transfer_buffer_length = offs * ep->stride + ctx->packets * extra; in prepare_silent_urb()
233 struct urb *urb = ctx->urb; in prepare_outbound_urb()
234 unsigned char *cp = urb->transfer_buffer; in prepare_outbound_urb()
236 urb->dev = ep->chip->dev; /* we need to set this at each time */ in prepare_outbound_urb()
238 switch (ep->type) { in prepare_outbound_urb()
240 if (ep->prepare_data_urb) { in prepare_outbound_urb()
241 ep->prepare_data_urb(ep->data_subs, urb); in prepare_outbound_urb()
249 if (snd_usb_get_speed(ep->chip->dev) >= USB_SPEED_HIGH) { in prepare_outbound_urb()
254 urb->iso_frame_desc[0].length = 4; in prepare_outbound_urb()
255 urb->iso_frame_desc[0].offset = 0; in prepare_outbound_urb()
256 cp[0] = ep->freqn; in prepare_outbound_urb()
257 cp[1] = ep->freqn >> 8; in prepare_outbound_urb()
258 cp[2] = ep->freqn >> 16; in prepare_outbound_urb()
259 cp[3] = ep->freqn >> 24; in prepare_outbound_urb()
265 urb->iso_frame_desc[0].length = 3; in prepare_outbound_urb()
266 urb->iso_frame_desc[0].offset = 0; in prepare_outbound_urb()
267 cp[0] = ep->freqn >> 2; in prepare_outbound_urb()
268 cp[1] = ep->freqn >> 10; in prepare_outbound_urb()
269 cp[2] = ep->freqn >> 18; in prepare_outbound_urb()
277 * Prepare a CAPTURE or SYNC urb for submission to the bus.
283 struct urb *urb = urb_ctx->urb; in prepare_inbound_urb()
285 urb->dev = ep->chip->dev; /* we need to set this at each time */ in prepare_inbound_urb()
287 switch (ep->type) { in prepare_inbound_urb()
290 for (i = 0; i < urb_ctx->packets; i++) { in prepare_inbound_urb()
291 urb->iso_frame_desc[i].offset = offs; in prepare_inbound_urb()
292 urb->iso_frame_desc[i].length = ep->curpacksize; in prepare_inbound_urb()
293 offs += ep->curpacksize; in prepare_inbound_urb()
296 urb->transfer_buffer_length = offs; in prepare_inbound_urb()
297 urb->number_of_packets = urb_ctx->packets; in prepare_inbound_urb()
301 urb->iso_frame_desc[0].length = min(4u, ep->syncmaxsize); in prepare_inbound_urb()
302 urb->iso_frame_desc[0].offset = 0; in prepare_inbound_urb()
309 * from ep->ready_playback_urbs and in case there there aren't any available
318 * driven by dedicated sync endpoints, URBs are immediately re-submitted
323 while (test_bit(EP_FLAG_RUNNING, &ep->flags)) { in queue_pending_output_urbs()
330 spin_lock_irqsave(&ep->lock, flags); in queue_pending_output_urbs()
331 if (ep->next_packet_read_pos != ep->next_packet_write_pos) { in queue_pending_output_urbs()
332 packet = ep->next_packet + ep->next_packet_read_pos; in queue_pending_output_urbs()
333 ep->next_packet_read_pos++; in queue_pending_output_urbs()
334 ep->next_packet_read_pos %= MAX_URBS; in queue_pending_output_urbs()
337 if (!list_empty(&ep->ready_playback_urbs)) { in queue_pending_output_urbs()
338 ctx = list_first_entry(&ep->ready_playback_urbs, in queue_pending_output_urbs()
340 list_del_init(&ctx->ready_list); in queue_pending_output_urbs()
343 spin_unlock_irqrestore(&ep->lock, flags); in queue_pending_output_urbs()
349 for (i = 0; i < packet->packets; i++) in queue_pending_output_urbs()
350 ctx->packet_size[i] = packet->packet_size[i]; in queue_pending_output_urbs()
355 err = usb_submit_urb(ctx->urb, GFP_ATOMIC); in queue_pending_output_urbs()
357 usb_audio_err(ep->chip, in queue_pending_output_urbs()
359 ctx->index, err, ctx->urb); in queue_pending_output_urbs()
361 set_bit(ctx->index, &ep->active_mask); in queue_pending_output_urbs()
370 struct snd_urb_ctx *ctx = urb->context; in snd_complete_urb()
371 struct snd_usb_endpoint *ep = ctx->ep; in snd_complete_urb()
376 if (unlikely(urb->status == -ENOENT || /* unlinked */ in snd_complete_urb()
377 urb->status == -ENODEV || /* device removed */ in snd_complete_urb()
378 urb->status == -ECONNRESET || /* unlinked */ in snd_complete_urb()
379 urb->status == -ESHUTDOWN)) /* device disabled */ in snd_complete_urb()
382 if (unlikely(atomic_read(&ep->chip->shutdown))) in snd_complete_urb()
385 if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags))) in snd_complete_urb()
388 if (usb_pipeout(ep->pipe)) { in snd_complete_urb()
391 if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags))) in snd_complete_urb()
395 spin_lock_irqsave(&ep->lock, flags); in snd_complete_urb()
396 list_add_tail(&ctx->ready_list, &ep->ready_playback_urbs); in snd_complete_urb()
397 spin_unlock_irqrestore(&ep->lock, flags); in snd_complete_urb()
405 if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags))) in snd_complete_urb()
410 if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags))) in snd_complete_urb()
420 usb_audio_err(ep->chip, "cannot submit urb (err = %d)\n", err); in snd_complete_urb()
421 if (ep->data_subs && ep->data_subs->pcm_substream) { in snd_complete_urb()
422 substream = ep->data_subs->pcm_substream; in snd_complete_urb()
427 clear_bit(ctx->index, &ep->active_mask); in snd_complete_urb()
443 * New endpoints will be added to chip->ep_list and must be freed by
459 mutex_lock(&chip->mutex); in snd_usb_add_endpoint()
461 list_for_each_entry(ep, &chip->ep_list, list) { in snd_usb_add_endpoint()
462 if (ep->ep_num == ep_num && in snd_usb_add_endpoint()
463 ep->iface == alts->desc.bInterfaceNumber && in snd_usb_add_endpoint()
464 ep->altsetting == alts->desc.bAlternateSetting) { in snd_usb_add_endpoint()
465 usb_audio_dbg(ep->chip, in snd_usb_add_endpoint()
466 "Re-using EP %x in iface %d,%d @%p\n", in snd_usb_add_endpoint()
467 ep_num, ep->iface, ep->altsetting, ep); in snd_usb_add_endpoint()
474 type == SND_USB_ENDPOINT_TYPE_DATA ? "data" : "sync", in snd_usb_add_endpoint()
481 ep->chip = chip; in snd_usb_add_endpoint()
482 spin_lock_init(&ep->lock); in snd_usb_add_endpoint()
483 ep->type = type; in snd_usb_add_endpoint()
484 ep->ep_num = ep_num; in snd_usb_add_endpoint()
485 ep->iface = alts->desc.bInterfaceNumber; in snd_usb_add_endpoint()
486 ep->altsetting = alts->desc.bAlternateSetting; in snd_usb_add_endpoint()
487 INIT_LIST_HEAD(&ep->ready_playback_urbs); in snd_usb_add_endpoint()
491 ep->pipe = usb_sndisocpipe(chip->dev, ep_num); in snd_usb_add_endpoint()
493 ep->pipe = usb_rcvisocpipe(chip->dev, ep_num); in snd_usb_add_endpoint()
496 if (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && in snd_usb_add_endpoint()
497 get_endpoint(alts, 1)->bRefresh >= 1 && in snd_usb_add_endpoint()
498 get_endpoint(alts, 1)->bRefresh <= 9) in snd_usb_add_endpoint()
499 ep->syncinterval = get_endpoint(alts, 1)->bRefresh; in snd_usb_add_endpoint()
500 else if (snd_usb_get_speed(chip->dev) == USB_SPEED_FULL) in snd_usb_add_endpoint()
501 ep->syncinterval = 1; in snd_usb_add_endpoint()
502 else if (get_endpoint(alts, 1)->bInterval >= 1 && in snd_usb_add_endpoint()
503 get_endpoint(alts, 1)->bInterval <= 16) in snd_usb_add_endpoint()
504 ep->syncinterval = get_endpoint(alts, 1)->bInterval - 1; in snd_usb_add_endpoint()
506 ep->syncinterval = 3; in snd_usb_add_endpoint()
508 ep->syncmaxsize = le16_to_cpu(get_endpoint(alts, 1)->wMaxPacketSize); in snd_usb_add_endpoint()
511 list_add_tail(&ep->list, &chip->ep_list); in snd_usb_add_endpoint()
514 mutex_unlock(&chip->mutex); in snd_usb_add_endpoint()
528 alive = bitmap_weight(&ep->active_mask, ep->nurbs); in wait_clear_urbs()
536 usb_audio_err(ep->chip, in wait_clear_urbs()
538 alive, ep->ep_num); in wait_clear_urbs()
539 clear_bit(EP_FLAG_STOPPING, &ep->flags); in wait_clear_urbs()
541 ep->data_subs = NULL; in wait_clear_urbs()
542 ep->sync_slave = NULL; in wait_clear_urbs()
543 ep->retire_data_urb = NULL; in wait_clear_urbs()
544 ep->prepare_data_urb = NULL; in wait_clear_urbs()
549 /* sync the pending stop operation;
554 if (ep && test_bit(EP_FLAG_STOPPING, &ep->flags)) in snd_usb_endpoint_sync_pending_stop()
565 if (!force && atomic_read(&ep->chip->shutdown)) /* to be sure... */ in deactivate_urbs()
566 return -EBADFD; in deactivate_urbs()
568 clear_bit(EP_FLAG_RUNNING, &ep->flags); in deactivate_urbs()
570 INIT_LIST_HEAD(&ep->ready_playback_urbs); in deactivate_urbs()
571 ep->next_packet_read_pos = 0; in deactivate_urbs()
572 ep->next_packet_write_pos = 0; in deactivate_urbs()
574 for (i = 0; i < ep->nurbs; i++) { in deactivate_urbs()
575 if (test_bit(i, &ep->active_mask)) { in deactivate_urbs()
576 if (!test_and_set_bit(i, &ep->unlink_mask)) { in deactivate_urbs()
577 struct urb *u = ep->urb[i].urb; in deactivate_urbs()
594 ep->retire_data_urb = NULL; in release_urbs()
595 ep->prepare_data_urb = NULL; in release_urbs()
601 for (i = 0; i < ep->nurbs; i++) in release_urbs()
602 release_urb_ctx(&ep->urb[i]); in release_urbs()
604 if (ep->syncbuf) in release_urbs()
605 usb_free_coherent(ep->chip->dev, SYNC_URBS * 4, in release_urbs()
606 ep->syncbuf, ep->sync_dma); in release_urbs()
608 ep->syncbuf = NULL; in release_urbs()
609 ep->nurbs = 0; in release_urbs()
628 int tx_length_quirk = (ep->chip->tx_length_quirk && in data_ep_set_params()
629 usb_pipeout(ep->pipe)); in data_ep_set_params()
631 if (pcm_format == SNDRV_PCM_FORMAT_DSD_U16_LE && fmt->dsd_dop) { in data_ep_set_params()
640 ep->datainterval = fmt->datainterval; in data_ep_set_params()
641 ep->stride = frame_bits >> 3; in data_ep_set_params()
645 ep->silence_value = 0x80; in data_ep_set_params()
652 ep->silence_value = 0x69; in data_ep_set_params()
655 ep->silence_value = 0; in data_ep_set_params()
659 ep->freqmax = ep->freqn + (ep->freqn >> 1); in data_ep_set_params()
665 * the data interval is more than 1 (i.e. ep->datainterval > 0), in data_ep_set_params()
670 * (ep->freqmax << ep->datainterval overflows at 8.192 MHz for the in data_ep_set_params()
672 * USB high speed, noting that ep->freqmax is in units of in data_ep_set_params()
675 maxsize = (((ep->freqmax << ep->datainterval) + 0xffff) >> 16) * in data_ep_set_params()
680 if (ep->maxpacksize && ep->maxpacksize < maxsize) { in data_ep_set_params()
682 unsigned int data_maxsize = maxsize = ep->maxpacksize; in data_ep_set_params()
686 data_maxsize -= sizeof(__le32); in data_ep_set_params()
687 ep->freqmax = (data_maxsize / (frame_bits >> 3)) in data_ep_set_params()
688 << (16 - ep->datainterval); in data_ep_set_params()
691 if (ep->fill_max) in data_ep_set_params()
692 ep->curpacksize = ep->maxpacksize; in data_ep_set_params()
694 ep->curpacksize = maxsize; in data_ep_set_params()
696 if (snd_usb_get_speed(ep->chip->dev) != USB_SPEED_FULL) { in data_ep_set_params()
697 packs_per_ms = 8 >> ep->datainterval; in data_ep_set_params()
705 1U << sync_ep->syncinterval); in data_ep_set_params()
706 max_packs_per_urb = max(1u, max_packs_per_urb >> ep->datainterval); in data_ep_set_params()
713 * Playback endpoints with implicit sync much use the same parameters in data_ep_set_params()
716 if (usb_pipein(ep->pipe) || in data_ep_set_params()
726 if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_WIRELESS) { in data_ep_set_params()
727 int interval = ep->datainterval; in data_ep_set_params()
737 ep->nurbs = MAX_URBS; in data_ep_set_params()
740 * Playback endpoints without implicit sync are adjusted so that in data_ep_set_params()
747 minsize = (ep->freqn >> (16 - ep->datainterval)) * in data_ep_set_params()
749 /* with sync from device, assume it can be 12% lower */ in data_ep_set_params()
751 minsize -= minsize >> 3; in data_ep_set_params()
764 ep->max_urb_frames = DIV_ROUND_UP(frames_per_period, in data_ep_set_params()
770 ep->nurbs = min(max_urbs, urbs_per_period * periods_per_buffer); in data_ep_set_params()
774 for (i = 0; i < ep->nurbs; i++) { in data_ep_set_params()
775 struct snd_urb_ctx *u = &ep->urb[i]; in data_ep_set_params()
776 u->index = i; in data_ep_set_params()
777 u->ep = ep; in data_ep_set_params()
778 u->packets = urb_packs; in data_ep_set_params()
779 u->buffer_size = maxsize * u->packets; in data_ep_set_params()
781 if (fmt->fmt_type == UAC_FORMAT_TYPE_II) in data_ep_set_params()
782 u->packets++; /* for transfer delimiter */ in data_ep_set_params()
783 u->urb = usb_alloc_urb(u->packets, GFP_KERNEL); in data_ep_set_params()
784 if (!u->urb) in data_ep_set_params()
787 u->urb->transfer_buffer = in data_ep_set_params()
788 usb_alloc_coherent(ep->chip->dev, u->buffer_size, in data_ep_set_params()
789 GFP_KERNEL, &u->urb->transfer_dma); in data_ep_set_params()
790 if (!u->urb->transfer_buffer) in data_ep_set_params()
792 u->urb->pipe = ep->pipe; in data_ep_set_params()
793 u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; in data_ep_set_params()
794 u->urb->interval = 1 << ep->datainterval; in data_ep_set_params()
795 u->urb->context = u; in data_ep_set_params()
796 u->urb->complete = snd_complete_urb; in data_ep_set_params()
797 INIT_LIST_HEAD(&u->ready_list); in data_ep_set_params()
804 return -ENOMEM; in data_ep_set_params()
808 * configure a sync endpoint
814 ep->syncbuf = usb_alloc_coherent(ep->chip->dev, SYNC_URBS * 4, in sync_ep_set_params()
815 GFP_KERNEL, &ep->sync_dma); in sync_ep_set_params()
816 if (!ep->syncbuf) in sync_ep_set_params()
817 return -ENOMEM; in sync_ep_set_params()
820 struct snd_urb_ctx *u = &ep->urb[i]; in sync_ep_set_params()
821 u->index = i; in sync_ep_set_params()
822 u->ep = ep; in sync_ep_set_params()
823 u->packets = 1; in sync_ep_set_params()
824 u->urb = usb_alloc_urb(1, GFP_KERNEL); in sync_ep_set_params()
825 if (!u->urb) in sync_ep_set_params()
827 u->urb->transfer_buffer = ep->syncbuf + i * 4; in sync_ep_set_params()
828 u->urb->transfer_dma = ep->sync_dma + i * 4; in sync_ep_set_params()
829 u->urb->transfer_buffer_length = 4; in sync_ep_set_params()
830 u->urb->pipe = ep->pipe; in sync_ep_set_params()
831 u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; in sync_ep_set_params()
832 u->urb->number_of_packets = 1; in sync_ep_set_params()
833 u->urb->interval = 1 << ep->syncinterval; in sync_ep_set_params()
834 u->urb->context = u; in sync_ep_set_params()
835 u->urb->complete = snd_complete_urb; in sync_ep_set_params()
838 ep->nurbs = SYNC_URBS; in sync_ep_set_params()
844 return -ENOMEM; in sync_ep_set_params()
858 * @sync_ep: the sync endpoint to use, if any
876 if (ep->use_count != 0) { in snd_usb_endpoint_set_params()
877 usb_audio_warn(ep->chip, in snd_usb_endpoint_set_params()
879 ep->ep_num); in snd_usb_endpoint_set_params()
880 return -EBUSY; in snd_usb_endpoint_set_params()
886 ep->datainterval = fmt->datainterval; in snd_usb_endpoint_set_params()
887 ep->maxpacksize = fmt->maxpacksize; in snd_usb_endpoint_set_params()
888 ep->fill_max = !!(fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX); in snd_usb_endpoint_set_params()
890 if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_FULL) in snd_usb_endpoint_set_params()
891 ep->freqn = get_usb_full_speed_rate(rate); in snd_usb_endpoint_set_params()
893 ep->freqn = get_usb_high_speed_rate(rate); in snd_usb_endpoint_set_params()
896 ep->freqm = ep->freqn; in snd_usb_endpoint_set_params()
897 ep->freqshift = INT_MIN; in snd_usb_endpoint_set_params()
899 ep->phase = 0; in snd_usb_endpoint_set_params()
901 switch (ep->type) { in snd_usb_endpoint_set_params()
911 err = -EINVAL; in snd_usb_endpoint_set_params()
914 usb_audio_dbg(ep->chip, in snd_usb_endpoint_set_params()
916 ep->ep_num, ep->type, ep->nurbs, err); in snd_usb_endpoint_set_params()
939 if (atomic_read(&ep->chip->shutdown)) in snd_usb_endpoint_start()
940 return -EBADFD; in snd_usb_endpoint_start()
943 if (++ep->use_count != 1) in snd_usb_endpoint_start()
949 ep->active_mask = 0; in snd_usb_endpoint_start()
950 ep->unlink_mask = 0; in snd_usb_endpoint_start()
951 ep->phase = 0; in snd_usb_endpoint_start()
962 set_bit(EP_FLAG_RUNNING, &ep->flags); in snd_usb_endpoint_start()
965 for (i = 0; i < ep->nurbs; i++) { in snd_usb_endpoint_start()
966 struct snd_urb_ctx *ctx = ep->urb + i; in snd_usb_endpoint_start()
967 list_add_tail(&ctx->ready_list, &ep->ready_playback_urbs); in snd_usb_endpoint_start()
973 for (i = 0; i < ep->nurbs; i++) { in snd_usb_endpoint_start()
974 struct urb *urb = ep->urb[i].urb; in snd_usb_endpoint_start()
979 if (usb_pipeout(ep->pipe)) { in snd_usb_endpoint_start()
980 prepare_outbound_urb(ep, urb->context); in snd_usb_endpoint_start()
982 prepare_inbound_urb(ep, urb->context); in snd_usb_endpoint_start()
987 usb_audio_err(ep->chip, in snd_usb_endpoint_start()
992 set_bit(i, &ep->active_mask); in snd_usb_endpoint_start()
998 clear_bit(EP_FLAG_RUNNING, &ep->flags); in snd_usb_endpoint_start()
999 ep->use_count--; in snd_usb_endpoint_start()
1001 return -EPIPE; in snd_usb_endpoint_start()
1023 if (snd_BUG_ON(ep->use_count == 0)) in snd_usb_endpoint_stop()
1026 if (--ep->use_count == 0) { in snd_usb_endpoint_stop()
1028 set_bit(EP_FLAG_STOPPING, &ep->flags); in snd_usb_endpoint_stop()
1047 if (ep->use_count != 0) in snd_usb_endpoint_deactivate()
1080 * snd_usb_handle_sync_urb: parse an USB sync packet
1106 ep->use_count != 0) { in snd_usb_handle_sync_urb()
1113 in_ctx = urb->context; in snd_usb_handle_sync_urb()
1116 for (i = 0; i < in_ctx->packets; i++) in snd_usb_handle_sync_urb()
1117 if (urb->iso_frame_desc[i].status == 0) in snd_usb_handle_sync_urb()
1118 bytes += urb->iso_frame_desc[i].actual_length; in snd_usb_handle_sync_urb()
1121 * skip empty packets. At least M-Audio's Fast Track Ultra stops in snd_usb_handle_sync_urb()
1122 * streaming once it received a 0-byte OUT URB in snd_usb_handle_sync_urb()
1127 spin_lock_irqsave(&ep->lock, flags); in snd_usb_handle_sync_urb()
1128 out_packet = ep->next_packet + ep->next_packet_write_pos; in snd_usb_handle_sync_urb()
1134 * IN packet we just received. Since the actual size is scaled in snd_usb_handle_sync_urb()
1137 * fed-back endpoint and the synchronizing endpoint. in snd_usb_handle_sync_urb()
1140 out_packet->packets = in_ctx->packets; in snd_usb_handle_sync_urb()
1141 for (i = 0; i < in_ctx->packets; i++) { in snd_usb_handle_sync_urb()
1142 if (urb->iso_frame_desc[i].status == 0) in snd_usb_handle_sync_urb()
1143 out_packet->packet_size[i] = in snd_usb_handle_sync_urb()
1144 urb->iso_frame_desc[i].actual_length / sender->stride; in snd_usb_handle_sync_urb()
1146 out_packet->packet_size[i] = 0; in snd_usb_handle_sync_urb()
1149 ep->next_packet_write_pos++; in snd_usb_handle_sync_urb()
1150 ep->next_packet_write_pos %= MAX_URBS; in snd_usb_handle_sync_urb()
1151 spin_unlock_irqrestore(&ep->lock, flags); in snd_usb_handle_sync_urb()
1158 * process after playback sync complete in snd_usb_handle_sync_urb()
1172 if (urb->iso_frame_desc[0].status != 0 || in snd_usb_handle_sync_urb()
1173 urb->iso_frame_desc[0].actual_length < 3) in snd_usb_handle_sync_urb()
1176 f = le32_to_cpup(urb->transfer_buffer); in snd_usb_handle_sync_urb()
1177 if (urb->iso_frame_desc[0].actual_length == 3) in snd_usb_handle_sync_urb()
1185 if (unlikely(sender->tenor_fb_quirk)) { in snd_usb_handle_sync_urb()
1187 * Devices based on Tenor 8802 chipsets (TEAC UD-H01 in snd_usb_handle_sync_urb()
1189 * by +/- 0x1.0000. in snd_usb_handle_sync_urb()
1191 if (f < ep->freqn - 0x8000) in snd_usb_handle_sync_urb()
1193 else if (f > ep->freqn + 0x8000) in snd_usb_handle_sync_urb()
1194 f -= 0xf000; in snd_usb_handle_sync_urb()
1195 } else if (unlikely(ep->freqshift == INT_MIN)) { in snd_usb_handle_sync_urb()
1200 * differ from the nominal value more than +50% or -25%. in snd_usb_handle_sync_urb()
1203 while (f < ep->freqn - ep->freqn / 4) { in snd_usb_handle_sync_urb()
1207 while (f > ep->freqn + ep->freqn / 2) { in snd_usb_handle_sync_urb()
1209 shift--; in snd_usb_handle_sync_urb()
1211 ep->freqshift = shift; in snd_usb_handle_sync_urb()
1212 } else if (ep->freqshift >= 0) in snd_usb_handle_sync_urb()
1213 f <<= ep->freqshift; in snd_usb_handle_sync_urb()
1215 f >>= -ep->freqshift; in snd_usb_handle_sync_urb()
1217 if (likely(f >= ep->freqn - ep->freqn / 8 && f <= ep->freqmax)) { in snd_usb_handle_sync_urb()
1222 spin_lock_irqsave(&ep->lock, flags); in snd_usb_handle_sync_urb()
1223 ep->freqm = f; in snd_usb_handle_sync_urb()
1224 spin_unlock_irqrestore(&ep->lock, flags); in snd_usb_handle_sync_urb()
1230 ep->freqshift = INT_MIN; in snd_usb_handle_sync_urb()