diff options
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/endpoint.c | 11 | ||||
-rw-r--r-- | sound/usb/endpoint.h | 2 | ||||
-rw-r--r-- | sound/usb/pcm.c | 13 |
3 files changed, 15 insertions, 11 deletions
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index c41181202688..b896c5559524 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c | |||
@@ -799,7 +799,9 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
799 | /** | 799 | /** |
800 | * snd_usb_endpoint_start: start an snd_usb_endpoint | 800 | * snd_usb_endpoint_start: start an snd_usb_endpoint |
801 | * | 801 | * |
802 | * @ep: the endpoint to start | 802 | * @ep: the endpoint to start |
803 | * @can_sleep: flag indicating whether the operation is executed in | ||
804 | * non-atomic context | ||
803 | * | 805 | * |
804 | * A call to this function will increment the use count of the endpoint. | 806 | * A call to this function will increment the use count of the endpoint. |
805 | * In case it is not already running, the URBs for this endpoint will be | 807 | * In case it is not already running, the URBs for this endpoint will be |
@@ -809,7 +811,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
809 | * | 811 | * |
810 | * Returns an error if the URB submission failed, 0 in all other cases. | 812 | * Returns an error if the URB submission failed, 0 in all other cases. |
811 | */ | 813 | */ |
812 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep) | 814 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep) |
813 | { | 815 | { |
814 | int err; | 816 | int err; |
815 | unsigned int i; | 817 | unsigned int i; |
@@ -821,6 +823,11 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep) | |||
821 | if (++ep->use_count != 1) | 823 | if (++ep->use_count != 1) |
822 | return 0; | 824 | return 0; |
823 | 825 | ||
826 | /* just to be sure */ | ||
827 | deactivate_urbs(ep, 0, can_sleep); | ||
828 | if (can_sleep) | ||
829 | wait_clear_urbs(ep); | ||
830 | |||
824 | ep->active_mask = 0; | 831 | ep->active_mask = 0; |
825 | ep->unlink_mask = 0; | 832 | ep->unlink_mask = 0; |
826 | ep->phase = 0; | 833 | ep->phase = 0; |
diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h index ee2723fb174f..a8e60c1408e5 100644 --- a/sound/usb/endpoint.h +++ b/sound/usb/endpoint.h | |||
@@ -13,7 +13,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
13 | struct audioformat *fmt, | 13 | struct audioformat *fmt, |
14 | struct snd_usb_endpoint *sync_ep); | 14 | struct snd_usb_endpoint *sync_ep); |
15 | 15 | ||
16 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep); | 16 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep); |
17 | void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, | 17 | void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, |
18 | int force, int can_sleep, int wait); | 18 | int force, int can_sleep, int wait); |
19 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); | 19 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); |
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 62ec808ed792..1546577ae458 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
@@ -212,7 +212,7 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface, | |||
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | static int start_endpoints(struct snd_usb_substream *subs) | 215 | static int start_endpoints(struct snd_usb_substream *subs, int can_sleep) |
216 | { | 216 | { |
217 | int err; | 217 | int err; |
218 | 218 | ||
@@ -225,7 +225,7 @@ static int start_endpoints(struct snd_usb_substream *subs) | |||
225 | snd_printdd(KERN_DEBUG "Starting data EP @%p\n", ep); | 225 | snd_printdd(KERN_DEBUG "Starting data EP @%p\n", ep); |
226 | 226 | ||
227 | ep->data_subs = subs; | 227 | ep->data_subs = subs; |
228 | err = snd_usb_endpoint_start(ep); | 228 | err = snd_usb_endpoint_start(ep, can_sleep); |
229 | if (err < 0) { | 229 | if (err < 0) { |
230 | clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags); | 230 | clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags); |
231 | return err; | 231 | return err; |
@@ -239,7 +239,7 @@ static int start_endpoints(struct snd_usb_substream *subs) | |||
239 | snd_printdd(KERN_DEBUG "Starting sync EP @%p\n", ep); | 239 | snd_printdd(KERN_DEBUG "Starting sync EP @%p\n", ep); |
240 | 240 | ||
241 | ep->sync_slave = subs->data_endpoint; | 241 | ep->sync_slave = subs->data_endpoint; |
242 | err = snd_usb_endpoint_start(ep); | 242 | err = snd_usb_endpoint_start(ep, can_sleep); |
243 | if (err < 0) { | 243 | if (err < 0) { |
244 | clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); | 244 | clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); |
245 | return err; | 245 | return err; |
@@ -544,13 +544,10 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) | |||
544 | subs->last_frame_number = 0; | 544 | subs->last_frame_number = 0; |
545 | runtime->delay = 0; | 545 | runtime->delay = 0; |
546 | 546 | ||
547 | /* clear the pending deactivation on the target EPs */ | ||
548 | deactivate_endpoints(subs); | ||
549 | |||
550 | /* for playback, submit the URBs now; otherwise, the first hwptr_done | 547 | /* for playback, submit the URBs now; otherwise, the first hwptr_done |
551 | * updates for all URBs would happen at the same time when starting */ | 548 | * updates for all URBs would happen at the same time when starting */ |
552 | if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) | 549 | if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) |
553 | return start_endpoints(subs); | 550 | return start_endpoints(subs, 1); |
554 | 551 | ||
555 | return 0; | 552 | return 0; |
556 | } | 553 | } |
@@ -1175,7 +1172,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream | |||
1175 | 1172 | ||
1176 | switch (cmd) { | 1173 | switch (cmd) { |
1177 | case SNDRV_PCM_TRIGGER_START: | 1174 | case SNDRV_PCM_TRIGGER_START: |
1178 | err = start_endpoints(subs); | 1175 | err = start_endpoints(subs, 0); |
1179 | if (err < 0) | 1176 | if (err < 0) |
1180 | return err; | 1177 | return err; |
1181 | 1178 | ||