Lines Matching refs:ep

100 		usb_free_coherent(u->ep->chip->dev, u->buffer_size,
133 static inline bool ep_state_running(struct snd_usb_endpoint *ep)
135 return atomic_read(&ep->state) == EP_STATE_RUNNING;
138 static inline bool ep_state_update(struct snd_usb_endpoint *ep, int old, int new)
140 return atomic_try_cmpxchg(&ep->state, &old, new);
146 * @ep: The snd_usb_endpoint
151 int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep)
153 return ep->implicit_fb_sync && usb_pipeout(ep->pipe);
163 static int slave_next_packet_size(struct snd_usb_endpoint *ep,
170 if (ep->fill_max)
171 return ep->maxframesize;
173 spin_lock_irqsave(&ep->lock, flags);
174 phase = (ep->phase & 0xffff) + (ep->freqm << ep->datainterval);
175 ret = min(phase >> 16, ep->maxframesize);
179 ep->phase = phase;
180 spin_unlock_irqrestore(&ep->lock, flags);
189 static int next_packet_size(struct snd_usb_endpoint *ep, unsigned int avail)
194 if (ep->fill_max)
195 return ep->maxframesize;
197 sample_accum = ep->sample_accum + ep->sample_rem;
198 if (sample_accum >= ep->pps) {
199 sample_accum -= ep->pps;
200 ret = ep->packsize[1];
202 ret = ep->packsize[0];
207 ep->sample_accum = sample_accum;
219 int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep,
232 if (ep->sync_source)
233 return slave_next_packet_size(ep, avail);
235 return next_packet_size(ep, avail);
238 static void call_retire_callback(struct snd_usb_endpoint *ep,
243 data_subs = READ_ONCE(ep->data_subs);
244 if (data_subs && ep->retire_data_urb)
245 ep->retire_data_urb(data_subs, urb);
248 static void retire_outbound_urb(struct snd_usb_endpoint *ep,
251 call_retire_callback(ep, urb_ctx->urb);
254 static void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep,
258 static void retire_inbound_urb(struct snd_usb_endpoint *ep,
264 if (unlikely(ep->skip_packets > 0)) {
265 ep->skip_packets--;
269 sync_sink = READ_ONCE(ep->sync_sink);
271 snd_usb_handle_sync_urb(sync_sink, ep, urb);
273 call_retire_callback(ep, urb);
281 static void prepare_silent_urb(struct snd_usb_endpoint *ep,
291 if (has_tx_length_quirk(ep->chip))
299 counts = snd_usb_endpoint_next_packet_size(ep, ctx, i, 0);
300 length = counts * ep->stride; /* number of silent bytes */
301 offset = offs * ep->stride + extra * i;
310 ep->silence_value, length);
315 urb->transfer_buffer_length = offs * ep->stride + ctx->packets * extra;
322 static int prepare_outbound_urb(struct snd_usb_endpoint *ep,
330 urb->dev = ep->chip->dev; /* we need to set this at each time */
332 switch (ep->type) {
334 data_subs = READ_ONCE(ep->data_subs);
335 if (data_subs && ep->prepare_data_urb)
336 return ep->prepare_data_urb(data_subs, urb, in_stream_lock);
338 prepare_silent_urb(ep, ctx);
342 if (snd_usb_get_speed(ep->chip->dev) >= USB_SPEED_HIGH) {
349 cp[0] = ep->freqn;
350 cp[1] = ep->freqn >> 8;
351 cp[2] = ep->freqn >> 16;
352 cp[3] = ep->freqn >> 24;
360 cp[0] = ep->freqn >> 2;
361 cp[1] = ep->freqn >> 10;
362 cp[2] = ep->freqn >> 18;
373 static int prepare_inbound_urb(struct snd_usb_endpoint *ep,
379 urb->dev = ep->chip->dev; /* we need to set this at each time */
381 switch (ep->type) {
386 urb->iso_frame_desc[i].length = ep->curpacksize;
387 offs += ep->curpacksize;
395 urb->iso_frame_desc[0].length = min(4u, ep->syncmaxsize);
403 static void notify_xrun(struct snd_usb_endpoint *ep)
407 data_subs = READ_ONCE(ep->data_subs);
413 next_packet_fifo_enqueue(struct snd_usb_endpoint *ep)
417 p = ep->next_packet + (ep->next_packet_head + ep->next_packet_queued) %
418 ARRAY_SIZE(ep->next_packet);
419 ep->next_packet_queued++;
424 next_packet_fifo_dequeue(struct snd_usb_endpoint *ep)
428 p = ep->next_packet + ep->next_packet_head;
429 ep->next_packet_head++;
430 ep->next_packet_head %= ARRAY_SIZE(ep->next_packet);
431 ep->next_packet_queued--;
435 static void push_back_to_ready_list(struct snd_usb_endpoint *ep,
440 spin_lock_irqsave(&ep->lock, flags);
441 list_add_tail(&ctx->ready_list, &ep->ready_playback_urbs);
442 spin_unlock_irqrestore(&ep->lock, flags);
447 * from ep->ready_playback_urbs and in case there aren't any available
458 int snd_usb_queue_pending_output_urbs(struct snd_usb_endpoint *ep,
461 bool implicit_fb = snd_usb_endpoint_implicit_feedback_sink(ep);
463 while (ep_state_running(ep)) {
470 spin_lock_irqsave(&ep->lock, flags);
471 if ((!implicit_fb || ep->next_packet_queued > 0) &&
472 !list_empty(&ep->ready_playback_urbs)) {
474 ctx = list_first_entry(&ep->ready_playback_urbs,
478 packet = next_packet_fifo_dequeue(ep);
480 spin_unlock_irqrestore(&ep->lock, flags);
492 err = prepare_outbound_urb(ep, ctx, in_stream_lock);
494 if (unlikely(!ep_state_running(ep)))
499 push_back_to_ready_list(ep, ctx);
504 notify_xrun(ep);
508 if (!atomic_read(&ep->chip->shutdown))
513 if (!atomic_read(&ep->chip->shutdown)) {
514 usb_audio_err(ep->chip,
518 notify_xrun(ep);
523 set_bit(ctx->index, &ep->active_mask);
524 atomic_inc(&ep->submitted_urbs);
536 struct snd_usb_endpoint *ep = ctx->ep;
545 if (unlikely(atomic_read(&ep->chip->shutdown)))
548 if (unlikely(!ep_state_running(ep)))
551 if (usb_pipeout(ep->pipe)) {
552 retire_outbound_urb(ep, ctx);
554 if (unlikely(!ep_state_running(ep)))
560 if (ep->lowlatency_playback ||
561 snd_usb_endpoint_implicit_feedback_sink(ep)) {
562 push_back_to_ready_list(ep, ctx);
563 clear_bit(ctx->index, &ep->active_mask);
564 snd_usb_queue_pending_output_urbs(ep, false);
565 atomic_dec(&ep->submitted_urbs); /* decrement at last */
570 prepare_outbound_urb(ep, ctx, false);
572 if (unlikely(!ep_state_running(ep)))
575 retire_inbound_urb(ep, ctx);
577 if (unlikely(!ep_state_running(ep)))
580 prepare_inbound_urb(ep, ctx);
583 if (!atomic_read(&ep->chip->shutdown))
590 if (!atomic_read(&ep->chip->shutdown)) {
591 usb_audio_err(ep->chip, "cannot submit urb (err = %d)\n", err);
592 notify_xrun(ep);
596 clear_bit(ctx->index, &ep->active_mask);
597 atomic_dec(&ep->submitted_urbs);
648 struct snd_usb_endpoint *ep;
650 list_for_each_entry(ep, &chip->ep_list, list) {
651 if (ep->ep_num == ep_num)
652 return ep;
681 struct snd_usb_endpoint *ep;
684 ep = snd_usb_get_endpoint(chip, ep_num);
685 if (ep)
691 ep = kzalloc(sizeof(*ep), GFP_KERNEL);
692 if (!ep)
695 ep->chip = chip;
696 spin_lock_init(&ep->lock);
697 ep->type = type;
698 ep->ep_num = ep_num;
699 INIT_LIST_HEAD(&ep->ready_playback_urbs);
700 atomic_set(&ep->submitted_urbs, 0);
705 ep->pipe = usb_sndisocpipe(chip->dev, ep_num);
707 ep->pipe = usb_rcvisocpipe(chip->dev, ep_num);
709 list_add_tail(&ep->list, &chip->ep_list);
715 struct snd_usb_endpoint *ep)
720 alts = snd_usb_get_host_interface(chip, ep->iface, ep->altsetting);
724 desc = get_endpoint(alts, ep->ep_idx);
727 ep->syncinterval = desc->bRefresh;
729 ep->syncinterval = 1;
731 ep->syncinterval = desc->bInterval - 1;
733 ep->syncinterval = 3;
735 ep->syncmaxsize = le16_to_cpu(desc->wMaxPacketSize);
738 static bool endpoint_compatible(struct snd_usb_endpoint *ep,
742 if (!ep->opened)
744 if (ep->cur_audiofmt != fp)
746 if (ep->cur_rate != params_rate(params) ||
747 ep->cur_format != params_format(params) ||
748 ep->cur_period_frames != params_period_size(params) ||
749 ep->cur_buffer_periods != params_periods(params))
759 struct snd_usb_endpoint *ep,
766 ret = endpoint_compatible(ep, fp, params);
791 struct snd_usb_endpoint *ep;
795 ep = snd_usb_get_endpoint(chip, ep_num);
796 if (!ep) {
801 if (!ep->opened) {
803 ep->iface = fp->sync_iface;
804 ep->altsetting = fp->sync_altsetting;
805 ep->ep_idx = fp->sync_ep_idx;
807 ep->iface = fp->iface;
808 ep->altsetting = fp->altsetting;
809 ep->ep_idx = fp->ep_idx;
812 ep_num, ep->iface, ep->altsetting, ep->ep_idx);
814 ep->iface_ref = iface_ref_find(chip, ep->iface);
815 if (!ep->iface_ref) {
816 ep = NULL;
821 ep->clock_ref = clock_ref_find(chip, fp->clock);
822 if (!ep->clock_ref) {
823 ep = NULL;
826 ep->clock_ref->opened++;
829 ep->cur_audiofmt = fp;
830 ep->cur_channels = fp->channels;
831 ep->cur_rate = params_rate(params);
832 ep->cur_format = params_format(params);
833 ep->cur_frame_bytes = snd_pcm_format_physical_width(ep->cur_format) *
834 ep->cur_channels / 8;
835 ep->cur_period_frames = params_period_size(params);
836 ep->cur_period_bytes = ep->cur_period_frames * ep->cur_frame_bytes;
837 ep->cur_buffer_periods = params_periods(params);
839 if (ep->type == SND_USB_ENDPOINT_TYPE_SYNC)
840 endpoint_set_syncinterval(chip, ep);
842 ep->implicit_fb_sync = fp->implicit_fb;
843 ep->need_setup = true;
844 ep->need_prepare = true;
845 ep->fixed_rate = fixed_rate;
848 ep->cur_channels, ep->cur_rate,
849 snd_pcm_format_name(ep->cur_format),
850 ep->cur_period_bytes, ep->cur_buffer_periods,
851 ep->implicit_fb_sync);
854 if (WARN_ON(!ep->iface_ref)) {
855 ep = NULL;
859 if (!endpoint_compatible(ep, fp, params)) {
862 ep = NULL;
867 ep_num, ep->opened);
870 if (!ep->iface_ref->opened++)
871 ep->iface_ref->need_setup = true;
873 ep->opened++;
877 return ep;
898 void snd_usb_endpoint_set_callback(struct snd_usb_endpoint *ep,
906 ep->prepare_data_urb = prepare;
907 ep->retire_data_urb = retire;
909 ep->lowlatency_playback = data_subs->lowlatency_playback;
911 ep->lowlatency_playback = false;
912 WRITE_ONCE(ep->data_subs, data_subs);
916 struct snd_usb_endpoint *ep,
919 int altset = set ? ep->altsetting : 0;
922 if (ep->iface_ref->altset == altset)
926 ep->iface, altset, ep->ep_num);
927 err = usb_set_interface(chip->dev, ep->iface, altset);
931 ep->iface, altset, err);
937 ep->iface_ref->altset = altset;
947 struct snd_usb_endpoint *ep)
951 ep->ep_num, ep->opened);
953 if (!--ep->iface_ref->opened &&
955 endpoint_set_interface(chip, ep, false);
957 if (!--ep->opened) {
958 if (ep->clock_ref) {
959 if (!--ep->clock_ref->opened)
960 ep->clock_ref->rate = 0;
962 ep->iface = 0;
963 ep->altsetting = 0;
964 ep->cur_audiofmt = NULL;
965 ep->cur_rate = 0;
966 ep->iface_ref = NULL;
967 ep->clock_ref = NULL;
968 usb_audio_dbg(chip, "EP 0x%x closed\n", ep->ep_num);
974 void snd_usb_endpoint_suspend(struct snd_usb_endpoint *ep)
976 ep->need_prepare = true;
977 if (ep->iface_ref)
978 ep->iface_ref->need_setup = true;
979 if (ep->clock_ref)
980 ep->clock_ref->rate = 0;
986 static int wait_clear_urbs(struct snd_usb_endpoint *ep)
991 if (atomic_read(&ep->state) != EP_STATE_STOPPING)
995 alive = atomic_read(&ep->submitted_urbs);
1003 usb_audio_err(ep->chip,
1005 alive, ep->ep_num);
1007 if (ep_state_update(ep, EP_STATE_STOPPING, EP_STATE_STOPPED)) {
1008 ep->sync_sink = NULL;
1009 snd_usb_endpoint_set_callback(ep, NULL, NULL, NULL);
1018 void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep)
1020 if (ep)
1021 wait_clear_urbs(ep);
1029 static int stop_urbs(struct snd_usb_endpoint *ep, bool force, bool keep_pending)
1034 if (!force && atomic_read(&ep->running))
1037 if (!ep_state_update(ep, EP_STATE_RUNNING, EP_STATE_STOPPING))
1040 spin_lock_irqsave(&ep->lock, flags);
1041 INIT_LIST_HEAD(&ep->ready_playback_urbs);
1042 ep->next_packet_head = 0;
1043 ep->next_packet_queued = 0;
1044 spin_unlock_irqrestore(&ep->lock, flags);
1049 for (i = 0; i < ep->nurbs; i++) {
1050 if (test_bit(i, &ep->active_mask)) {
1051 if (!test_and_set_bit(i, &ep->unlink_mask)) {
1052 struct urb *u = ep->urb[i].urb;
1064 static int release_urbs(struct snd_usb_endpoint *ep, bool force)
1069 snd_usb_endpoint_set_callback(ep, NULL, NULL, NULL);
1072 err = stop_urbs(ep, force, false);
1076 wait_clear_urbs(ep);
1078 for (i = 0; i < ep->nurbs; i++)
1079 release_urb_ctx(&ep->urb[i]);
1081 usb_free_coherent(ep->chip->dev, SYNC_URBS * 4,
1082 ep->syncbuf, ep->sync_dma);
1084 ep->syncbuf = NULL;
1085 ep->nurbs = 0;
1092 static int data_ep_set_params(struct snd_usb_endpoint *ep)
1094 struct snd_usb_audio *chip = ep->chip;
1098 const struct audioformat *fmt = ep->cur_audiofmt;
1099 int frame_bits = ep->cur_frame_bytes * 8;
1101 usb_pipeout(ep->pipe));
1104 ep->ep_num, ep->pipe);
1106 if (ep->cur_format == SNDRV_PCM_FORMAT_DSD_U16_LE && fmt->dsd_dop) {
1112 frame_bits += ep->cur_channels << 3;
1115 ep->datainterval = fmt->datainterval;
1116 ep->stride = frame_bits >> 3;
1118 switch (ep->cur_format) {
1120 ep->silence_value = 0x80;
1127 ep->silence_value = 0x69;
1130 ep->silence_value = 0;
1134 ep->freqmax = ep->freqn + (ep->freqn >> 1);
1140 * the data interval is more than 1 (i.e. ep->datainterval > 0),
1145 * (ep->freqmax << ep->datainterval overflows at 8.192 MHz for the
1147 * USB high speed, noting that ep->freqmax is in units of
1150 maxsize = (((ep->freqmax << ep->datainterval) + 0xffff) >> 16) *
1155 if (ep->maxpacksize && ep->maxpacksize < maxsize) {
1157 unsigned int data_maxsize = maxsize = ep->maxpacksize;
1162 ep->freqmax = (data_maxsize / (frame_bits >> 3))
1163 << (16 - ep->datainterval);
1166 if (ep->fill_max)
1167 ep->curpacksize = ep->maxpacksize;
1169 ep->curpacksize = maxsize;
1172 packs_per_ms = 8 >> ep->datainterval;
1178 if (ep->sync_source && !ep->implicit_fb_sync)
1180 1U << ep->sync_source->syncinterval);
1181 max_packs_per_urb = max(1u, max_packs_per_urb >> ep->datainterval);
1191 if (usb_pipein(ep->pipe) || ep->implicit_fb_sync) {
1195 while (urb_packs > 1 && urb_packs * maxsize >= ep->cur_period_bytes)
1197 ep->nurbs = MAX_URBS;
1207 minsize = (ep->freqn >> (16 - ep->datainterval)) *
1210 if (ep->sync_source)
1215 max_packs_per_period = DIV_ROUND_UP(ep->cur_period_bytes, minsize);
1224 ep->max_urb_frames = DIV_ROUND_UP(ep->cur_period_frames,
1230 ep->nurbs = min(max_urbs, urbs_per_period * ep->cur_buffer_periods);
1234 for (i = 0; i < ep->nurbs; i++) {
1235 struct snd_urb_ctx *u = &ep->urb[i];
1237 u->ep = ep;
1252 u->urb->pipe = ep->pipe;
1254 u->urb->interval = 1 << ep->datainterval;
1263 release_urbs(ep, false);
1270 static int sync_ep_set_params(struct snd_usb_endpoint *ep)
1272 struct snd_usb_audio *chip = ep->chip;
1276 ep->ep_num, ep->pipe);
1278 ep->syncbuf = usb_alloc_coherent(chip->dev, SYNC_URBS * 4,
1279 GFP_KERNEL, &ep->sync_dma);
1280 if (!ep->syncbuf)
1283 ep->nurbs = SYNC_URBS;
1285 struct snd_urb_ctx *u = &ep->urb[i];
1287 u->ep = ep;
1292 u->urb->transfer_buffer = ep->syncbuf + i * 4;
1293 u->urb->transfer_dma = ep->sync_dma + i * 4;
1295 u->urb->pipe = ep->pipe;
1298 u->urb->interval = 1 << ep->syncinterval;
1306 release_urbs(ep, false);
1312 struct snd_usb_endpoint *ep)
1314 struct snd_usb_clock_ref *clock = ep->clock_ref;
1315 int rate = ep->cur_rate;
1324 clock->rate, rate, ep->ep_num);
1342 struct snd_usb_endpoint *ep)
1344 const struct audioformat *fmt = ep->cur_audiofmt;
1348 if (!ep->need_setup)
1352 err = release_urbs(ep, false);
1356 ep->datainterval = fmt->datainterval;
1357 ep->maxpacksize = fmt->maxpacksize;
1358 ep->fill_max = !!(fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX);
1361 ep->freqn = get_usb_full_speed_rate(ep->cur_rate);
1362 ep->pps = 1000 >> ep->datainterval;
1364 ep->freqn = get_usb_high_speed_rate(ep->cur_rate);
1365 ep->pps = 8000 >> ep->datainterval;
1368 ep->sample_rem = ep->cur_rate % ep->pps;
1369 ep->packsize[0] = ep->cur_rate / ep->pps;
1370 ep->packsize[1] = (ep->cur_rate + (ep->pps - 1)) / ep->pps;
1373 ep->freqm = ep->freqn;
1374 ep->freqshift = INT_MIN;
1376 ep->phase = 0;
1378 switch (ep->type) {
1380 err = data_ep_set_params(ep);
1383 err = sync_ep_set_params(ep);
1389 usb_audio_dbg(chip, "Set up %d URBS, ret=%d\n", ep->nurbs, err);
1395 ep->maxframesize = ep->maxpacksize / ep->cur_frame_bytes;
1396 ep->curframesize = ep->curpacksize / ep->cur_frame_bytes;
1398 err = update_clock_ref_rate(chip, ep);
1400 ep->need_setup = false;
1410 struct snd_usb_endpoint *ep)
1412 struct snd_usb_clock_ref *clock = ep->clock_ref;
1415 rate = update_clock_ref_rate(chip, ep);
1421 if (!ep->fixed_rate) {
1422 err = snd_usb_init_sample_rate(chip, ep->cur_audiofmt, rate);
1447 struct snd_usb_endpoint *ep)
1453 if (WARN_ON(!ep->iface_ref))
1455 if (!ep->need_prepare)
1459 if (!ep->iface_ref->need_setup) {
1463 if (ep->cur_audiofmt->protocol == UAC_VERSION_1) {
1464 err = init_sample_rate(chip, ep);
1472 endpoint_set_interface(chip, ep, false);
1477 iface_first = ep->cur_audiofmt->protocol == UAC_VERSION_1;
1482 err = endpoint_set_interface(chip, ep, true);
1487 err = snd_usb_init_pitch(chip, ep->cur_audiofmt);
1491 err = init_sample_rate(chip, ep);
1495 err = snd_usb_select_mode_quirk(chip, ep->cur_audiofmt);
1501 err = endpoint_set_interface(chip, ep, true);
1506 ep->iface_ref->need_setup = false;
1509 ep->need_prepare = false;
1539 * @ep: the endpoint to start
1549 int snd_usb_endpoint_start(struct snd_usb_endpoint *ep)
1551 bool is_playback = usb_pipeout(ep->pipe);
1555 if (atomic_read(&ep->chip->shutdown))
1558 if (ep->sync_source)
1559 WRITE_ONCE(ep->sync_source->sync_sink, ep);
1561 usb_audio_dbg(ep->chip, "Starting %s EP 0x%x (running %d)\n",
1562 ep_type_name(ep->type), ep->ep_num,
1563 atomic_read(&ep->running));
1566 if (atomic_inc_return(&ep->running) != 1)
1569 if (ep->clock_ref)
1570 atomic_inc(&ep->clock_ref->locked);
1572 ep->active_mask = 0;
1573 ep->unlink_mask = 0;
1574 ep->phase = 0;
1575 ep->sample_accum = 0;
1577 snd_usb_endpoint_start_quirk(ep);
1586 if (!ep_state_update(ep, EP_STATE_STOPPED, EP_STATE_RUNNING))
1589 if (snd_usb_endpoint_implicit_feedback_sink(ep) &&
1590 !(ep->chip->quirk_flags & QUIRK_FLAG_PLAYBACK_FIRST)) {
1591 usb_audio_dbg(ep->chip, "No URB submission due to implicit fb sync\n");
1596 for (i = 0; i < ep->nurbs; i++) {
1597 struct urb *urb = ep->urb[i].urb;
1603 err = prepare_outbound_urb(ep, urb->context, true);
1605 err = prepare_inbound_urb(ep, urb->context);
1610 usb_audio_dbg(ep->chip,
1612 ep->ep_num, err);
1616 if (!atomic_read(&ep->chip->shutdown))
1621 if (!atomic_read(&ep->chip->shutdown))
1622 usb_audio_err(ep->chip,
1627 set_bit(i, &ep->active_mask);
1628 atomic_inc(&ep->submitted_urbs);
1632 usb_audio_dbg(ep->chip, "XRUN at starting EP 0x%x\n",
1633 ep->ep_num);
1637 usb_audio_dbg(ep->chip, "%d URBs submitted for EP 0x%x\n",
1638 i, ep->ep_num);
1643 for (; i < ep->nurbs; i++)
1644 push_back_to_ready_list(ep, ep->urb + i);
1650 snd_usb_endpoint_stop(ep, false);
1657 * @ep: the endpoint to stop (may be NULL)
1669 void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool keep_pending)
1671 if (!ep)
1674 usb_audio_dbg(ep->chip, "Stopping %s EP 0x%x (running %d)\n",
1675 ep_type_name(ep->type), ep->ep_num,
1676 atomic_read(&ep->running));
1678 if (snd_BUG_ON(!atomic_read(&ep->running)))
1681 if (!atomic_dec_return(&ep->running)) {
1682 if (ep->sync_source)
1683 WRITE_ONCE(ep->sync_source->sync_sink, NULL);
1684 stop_urbs(ep, false, keep_pending);
1685 if (ep->clock_ref)
1686 atomic_dec(&ep->clock_ref->locked);
1688 if (ep->chip->quirk_flags & QUIRK_FLAG_FORCE_IFACE_RESET &&
1689 usb_pipeout(ep->pipe)) {
1690 ep->need_prepare = true;
1691 if (ep->iface_ref)
1692 ep->iface_ref->need_setup = true;
1700 * @ep: the endpoint to release
1705 void snd_usb_endpoint_release(struct snd_usb_endpoint *ep)
1707 release_urbs(ep, true);
1718 struct snd_usb_endpoint *ep, *en;
1722 list_for_each_entry_safe(ep, en, &chip->ep_list, list)
1723 kfree(ep);
1735 * @ep: the endpoint to handle the packet
1742 static void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep,
1750 snd_BUG_ON(ep == sender);
1758 if (snd_usb_endpoint_implicit_feedback_sink(ep) &&
1759 atomic_read(&ep->running)) {
1780 spin_lock_irqsave(&ep->lock, flags);
1781 if (ep->next_packet_queued >= ARRAY_SIZE(ep->next_packet)) {
1782 spin_unlock_irqrestore(&ep->lock, flags);
1783 usb_audio_err(ep->chip,
1785 ep->ep_num);
1786 notify_xrun(ep);
1790 out_packet = next_packet_fifo_enqueue(ep);
1811 spin_unlock_irqrestore(&ep->lock, flags);
1812 snd_usb_queue_pending_output_urbs(ep, false);
1851 if (f < ep->freqn - 0x8000)
1853 else if (f > ep->freqn + 0x8000)
1855 } else if (unlikely(ep->freqshift == INT_MIN)) {
1863 while (f < ep->freqn - ep->freqn / 4) {
1867 while (f > ep->freqn + ep->freqn / 2) {
1871 ep->freqshift = shift;
1872 } else if (ep->freqshift >= 0)
1873 f <<= ep->freqshift;
1875 f >>= -ep->freqshift;
1877 if (likely(f >= ep->freqn - ep->freqn / 8 && f <= ep->freqmax)) {
1882 spin_lock_irqsave(&ep->lock, flags);
1883 ep->freqm = f;
1884 spin_unlock_irqrestore(&ep->lock, flags);
1890 ep->freqshift = INT_MIN;