endpoint.c (825e587af2e90e9b953849f3347a01d8f383d577) endpoint.c (0ba41d917eeb87f608cf147f870ff2f4c1056bab)
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 319 unchanged lines hidden (view full) ---

328 for (i = 0; i < packet->packets; i++)
329 ctx->packet_size[i] = packet->packet_size[i];
330
331 /* call the data handler to fill in playback data */
332 prepare_outbound_urb(ep, ctx);
333
334 err = usb_submit_urb(ctx->urb, GFP_ATOMIC);
335 if (err < 0)
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of

--- 319 unchanged lines hidden (view full) ---

328 for (i = 0; i < packet->packets; i++)
329 ctx->packet_size[i] = packet->packet_size[i];
330
331 /* call the data handler to fill in playback data */
332 prepare_outbound_urb(ep, ctx);
333
334 err = usb_submit_urb(ctx->urb, GFP_ATOMIC);
335 if (err < 0)
336 snd_printk(KERN_ERR "Unable to submit urb #%d: %d (urb %p)\n",
337 ctx->index, err, ctx->urb);
336 usb_audio_err(ep->chip,
337 "Unable to submit urb #%d: %d (urb %p)\n",
338 ctx->index, err, ctx->urb);
338 else
339 set_bit(ctx->index, &ep->active_mask);
340 }
341}
342
343/*
344 * complete callback for urbs
345 */

--- 36 unchanged lines hidden (view full) ---

382
383 prepare_inbound_urb(ep, ctx);
384 }
385
386 err = usb_submit_urb(urb, GFP_ATOMIC);
387 if (err == 0)
388 return;
389
339 else
340 set_bit(ctx->index, &ep->active_mask);
341 }
342}
343
344/*
345 * complete callback for urbs
346 */

--- 36 unchanged lines hidden (view full) ---

383
384 prepare_inbound_urb(ep, ctx);
385 }
386
387 err = usb_submit_urb(urb, GFP_ATOMIC);
388 if (err == 0)
389 return;
390
390 snd_printk(KERN_ERR "cannot submit urb (err = %d)\n", err);
391 usb_audio_err(ep->chip, "cannot submit urb (err = %d)\n", err);
391 //snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
392
393exit_clear:
394 clear_bit(ctx->index, &ep->active_mask);
395}
396
397/**
398 * snd_usb_add_endpoint: Add an endpoint to an USB audio chip

--- 22 unchanged lines hidden (view full) ---

421 return NULL;
422
423 mutex_lock(&chip->mutex);
424
425 list_for_each_entry(ep, &chip->ep_list, list) {
426 if (ep->ep_num == ep_num &&
427 ep->iface == alts->desc.bInterfaceNumber &&
428 ep->altsetting == alts->desc.bAlternateSetting) {
392 //snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
393
394exit_clear:
395 clear_bit(ctx->index, &ep->active_mask);
396}
397
398/**
399 * snd_usb_add_endpoint: Add an endpoint to an USB audio chip

--- 22 unchanged lines hidden (view full) ---

422 return NULL;
423
424 mutex_lock(&chip->mutex);
425
426 list_for_each_entry(ep, &chip->ep_list, list) {
427 if (ep->ep_num == ep_num &&
428 ep->iface == alts->desc.bInterfaceNumber &&
429 ep->altsetting == alts->desc.bAlternateSetting) {
429 snd_printdd(KERN_DEBUG "Re-using EP %x in iface %d,%d @%p\n",
430 usb_audio_dbg(ep->chip,
431 "Re-using EP %x in iface %d,%d @%p\n",
430 ep_num, ep->iface, ep->altsetting, ep);
431 goto __exit_unlock;
432 }
433 }
434
432 ep_num, ep->iface, ep->altsetting, ep);
433 goto __exit_unlock;
434 }
435 }
436
435 snd_printdd(KERN_DEBUG "Creating new %s %s endpoint #%x\n",
437 usb_audio_dbg(chip, "Creating new %s %s endpoint #%x\n",
436 is_playback ? "playback" : "capture",
437 type == SND_USB_ENDPOINT_TYPE_DATA ? "data" : "sync",
438 ep_num);
439
440 ep = kzalloc(sizeof(*ep), GFP_KERNEL);
441 if (!ep)
442 goto __exit_unlock;
443

--- 47 unchanged lines hidden (view full) ---

491 alive = bitmap_weight(&ep->active_mask, ep->nurbs);
492 if (!alive)
493 break;
494
495 schedule_timeout_uninterruptible(1);
496 } while (time_before(jiffies, end_time));
497
498 if (alive)
438 is_playback ? "playback" : "capture",
439 type == SND_USB_ENDPOINT_TYPE_DATA ? "data" : "sync",
440 ep_num);
441
442 ep = kzalloc(sizeof(*ep), GFP_KERNEL);
443 if (!ep)
444 goto __exit_unlock;
445

--- 47 unchanged lines hidden (view full) ---

493 alive = bitmap_weight(&ep->active_mask, ep->nurbs);
494 if (!alive)
495 break;
496
497 schedule_timeout_uninterruptible(1);
498 } while (time_before(jiffies, end_time));
499
500 if (alive)
499 snd_printk(KERN_ERR "timeout: still %d active urbs on EP #%x\n",
500 alive, ep->ep_num);
501 usb_audio_err(ep->chip,
502 "timeout: still %d active urbs on EP #%x\n",
503 alive, ep->ep_num);
501 clear_bit(EP_FLAG_STOPPING, &ep->flags);
502
503 return 0;
504}
505
506/* sync the pending stop operation;
507 * this function itself doesn't trigger the stop operation
508 */

--- 280 unchanged lines hidden (view full) ---

789 unsigned int buffer_periods,
790 unsigned int rate,
791 struct audioformat *fmt,
792 struct snd_usb_endpoint *sync_ep)
793{
794 int err;
795
796 if (ep->use_count != 0) {
504 clear_bit(EP_FLAG_STOPPING, &ep->flags);
505
506 return 0;
507}
508
509/* sync the pending stop operation;
510 * this function itself doesn't trigger the stop operation
511 */

--- 280 unchanged lines hidden (view full) ---

792 unsigned int buffer_periods,
793 unsigned int rate,
794 struct audioformat *fmt,
795 struct snd_usb_endpoint *sync_ep)
796{
797 int err;
798
799 if (ep->use_count != 0) {
797 snd_printk(KERN_WARNING "Unable to change format on ep #%x: already in use\n",
798 ep->ep_num);
800 usb_audio_warn(ep->chip,
801 "Unable to change format on ep #%x: already in use\n",
802 ep->ep_num);
799 return -EBUSY;
800 }
801
802 /* release old buffers, if any */
803 release_urbs(ep, 0);
804
805 ep->datainterval = fmt->datainterval;
806 ep->maxpacksize = fmt->maxpacksize;

--- 18 unchanged lines hidden (view full) ---

825 break;
826 case SND_USB_ENDPOINT_TYPE_SYNC:
827 err = sync_ep_set_params(ep);
828 break;
829 default:
830 err = -EINVAL;
831 }
832
803 return -EBUSY;
804 }
805
806 /* release old buffers, if any */
807 release_urbs(ep, 0);
808
809 ep->datainterval = fmt->datainterval;
810 ep->maxpacksize = fmt->maxpacksize;

--- 18 unchanged lines hidden (view full) ---

829 break;
830 case SND_USB_ENDPOINT_TYPE_SYNC:
831 err = sync_ep_set_params(ep);
832 break;
833 default:
834 err = -EINVAL;
835 }
836
833 snd_printdd(KERN_DEBUG "Setting params for ep #%x (type %d, %d urbs), ret=%d\n",
834 ep->ep_num, ep->type, ep->nurbs, err);
837 usb_audio_dbg(ep->chip,
838 "Setting params for ep #%x (type %d, %d urbs), ret=%d\n",
839 ep->ep_num, ep->type, ep->nurbs, err);
835
836 return err;
837}
838
839/**
840 * snd_usb_endpoint_start: start an snd_usb_endpoint
841 *
842 * @ep: the endpoint to start

--- 58 unchanged lines hidden (view full) ---

901 if (usb_pipeout(ep->pipe)) {
902 prepare_outbound_urb(ep, urb->context);
903 } else {
904 prepare_inbound_urb(ep, urb->context);
905 }
906
907 err = usb_submit_urb(urb, GFP_ATOMIC);
908 if (err < 0) {
840
841 return err;
842}
843
844/**
845 * snd_usb_endpoint_start: start an snd_usb_endpoint
846 *
847 * @ep: the endpoint to start

--- 58 unchanged lines hidden (view full) ---

906 if (usb_pipeout(ep->pipe)) {
907 prepare_outbound_urb(ep, urb->context);
908 } else {
909 prepare_inbound_urb(ep, urb->context);
910 }
911
912 err = usb_submit_urb(urb, GFP_ATOMIC);
913 if (err < 0) {
909 snd_printk(KERN_ERR "cannot submit urb %d, error %d: %s\n",
910 i, err, usb_error_string(err));
914 usb_audio_err(ep->chip,
915 "cannot submit urb %d, error %d: %s\n",
916 i, err, usb_error_string(err));
911 goto __error;
912 }
913 set_bit(i, &ep->active_mask);
914 }
915
916 return 0;
917
918__error:

--- 222 unchanged lines hidden ---
917 goto __error;
918 }
919 set_bit(i, &ep->active_mask);
920 }
921
922 return 0;
923
924__error:

--- 222 unchanged lines hidden ---