Lines Matching refs:subs

58 static int usx2y_urb_capt_retire(struct snd_usx2y_substream *subs)  in usx2y_urb_capt_retire()  argument
60 struct urb *urb = subs->completed_urb; in usx2y_urb_capt_retire()
61 struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; in usx2y_urb_capt_retire()
63 int i, len, lens = 0, hwptr_done = subs->hwptr_done; in usx2y_urb_capt_retire()
65 struct usx2ydev *usx2y = subs->usx2y; in usx2y_urb_capt_retire()
97 subs->hwptr_done = hwptr_done; in usx2y_urb_capt_retire()
98 subs->transfer_done += lens; in usx2y_urb_capt_retire()
100 if (subs->transfer_done >= runtime->period_size) { in usx2y_urb_capt_retire()
101 subs->transfer_done -= runtime->period_size; in usx2y_urb_capt_retire()
102 snd_pcm_period_elapsed(subs->pcm_substream); in usx2y_urb_capt_retire()
117 static int usx2y_urb_play_prepare(struct snd_usx2y_substream *subs, in usx2y_urb_play_prepare() argument
121 struct usx2ydev *usx2y = subs->usx2y; in usx2y_urb_play_prepare()
122 struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; in usx2y_urb_play_prepare()
141 if (atomic_read(&subs->state) >= STATE_PRERUNNING) { in usx2y_urb_play_prepare()
142 if (subs->hwptr + count > runtime->buffer_size) { in usx2y_urb_play_prepare()
146 len = runtime->buffer_size - subs->hwptr; in usx2y_urb_play_prepare()
147 urb->transfer_buffer = subs->tmpbuf; in usx2y_urb_play_prepare()
148 memcpy(subs->tmpbuf, runtime->dma_area + in usx2y_urb_play_prepare()
149 subs->hwptr * usx2y->stride, len * usx2y->stride); in usx2y_urb_play_prepare()
150 memcpy(subs->tmpbuf + len * usx2y->stride, in usx2y_urb_play_prepare()
152 subs->hwptr += count; in usx2y_urb_play_prepare()
153 subs->hwptr -= runtime->buffer_size; in usx2y_urb_play_prepare()
156 urb->transfer_buffer = runtime->dma_area + subs->hwptr * usx2y->stride; in usx2y_urb_play_prepare()
157 subs->hwptr += count; in usx2y_urb_play_prepare()
158 if (subs->hwptr >= runtime->buffer_size) in usx2y_urb_play_prepare()
159 subs->hwptr -= runtime->buffer_size; in usx2y_urb_play_prepare()
162 urb->transfer_buffer = subs->tmpbuf; in usx2y_urb_play_prepare()
173 static void usx2y_urb_play_retire(struct snd_usx2y_substream *subs, struct urb *urb) in usx2y_urb_play_retire() argument
175 struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; in usx2y_urb_play_retire()
176 int len = urb->actual_length / subs->usx2y->stride; in usx2y_urb_play_retire()
178 subs->transfer_done += len; in usx2y_urb_play_retire()
179 subs->hwptr_done += len; in usx2y_urb_play_retire()
180 if (subs->hwptr_done >= runtime->buffer_size) in usx2y_urb_play_retire()
181 subs->hwptr_done -= runtime->buffer_size; in usx2y_urb_play_retire()
182 if (subs->transfer_done >= runtime->period_size) { in usx2y_urb_play_retire()
183 subs->transfer_done -= runtime->period_size; in usx2y_urb_play_retire()
184 snd_pcm_period_elapsed(subs->pcm_substream); in usx2y_urb_play_retire()
188 static int usx2y_urb_submit(struct snd_usx2y_substream *subs, struct urb *urb, int frame) in usx2y_urb_submit() argument
196 urb->dev = subs->usx2y->dev; /* we need to set this at each time */ in usx2y_urb_submit()
260 struct snd_usx2y_substream *subs; in usx2y_clients_stop() local
265 subs = usx2y->subs[s]; in usx2y_clients_stop()
266 if (subs) { in usx2y_clients_stop()
267 snd_printdd("%i %p state=%i\n", s, subs, atomic_read(&subs->state)); in usx2y_clients_stop()
268 atomic_set(&subs->state, STATE_STOPPED); in usx2y_clients_stop()
272 subs = usx2y->subs[s]; in usx2y_clients_stop()
273 if (subs) { in usx2y_clients_stop()
274 if (atomic_read(&subs->state) >= STATE_PRERUNNING) in usx2y_clients_stop()
275 snd_pcm_stop_xrun(subs->pcm_substream); in usx2y_clients_stop()
277 urb = subs->urb[u]; in usx2y_clients_stop()
289 struct snd_usx2y_substream *subs, struct urb *urb) in usx2y_error_urb_status() argument
291 snd_printk(KERN_ERR "ep=%i stalled with status=%i\n", subs->endpoint, urb->status); in usx2y_error_urb_status()
298 struct snd_usx2y_substream *subs = urb->context; in i_usx2y_urb_complete() local
299 struct usx2ydev *usx2y = subs->usx2y; in i_usx2y_urb_complete()
302 if (unlikely(atomic_read(&subs->state) < STATE_PREPARED)) { in i_usx2y_urb_complete()
305 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", in i_usx2y_urb_complete()
310 usx2y_error_urb_status(usx2y, subs, urb); in i_usx2y_urb_complete()
314 subs->completed_urb = urb; in i_usx2y_urb_complete()
316 capsubs = usx2y->subs[SNDRV_PCM_STREAM_CAPTURE]; in i_usx2y_urb_complete()
317 playbacksubs = usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK]; in i_usx2y_urb_complete()
335 struct snd_usx2y_substream *subs; in usx2y_urbs_set_complete() local
340 subs = usx2y->subs[s]; in usx2y_urbs_set_complete()
341 if (subs) { in usx2y_urbs_set_complete()
343 urb = subs->urb[u]; in usx2y_urbs_set_complete()
359 struct snd_usx2y_substream *subs = urb->context; in i_usx2y_subs_startup() local
360 struct usx2ydev *usx2y = subs->usx2y; in i_usx2y_subs_startup()
374 static void usx2y_subs_prepare(struct snd_usx2y_substream *subs) in usx2y_subs_prepare() argument
377 subs, subs->endpoint, subs->urb[0], subs->urb[1]); in usx2y_subs_prepare()
379 subs->hwptr = 0; in usx2y_subs_prepare()
380 subs->hwptr_done = 0; in usx2y_subs_prepare()
381 subs->transfer_done = 0; in usx2y_subs_prepare()
398 static void usx2y_urbs_release(struct snd_usx2y_substream *subs) in usx2y_urbs_release() argument
402 snd_printdd("%s %i\n", __func__, subs->endpoint); in usx2y_urbs_release()
404 usx2y_urb_release(subs->urb + i, in usx2y_urbs_release()
405 subs != subs->usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK]); in usx2y_urbs_release()
407 kfree(subs->tmpbuf); in usx2y_urbs_release()
408 subs->tmpbuf = NULL; in usx2y_urbs_release()
414 static int usx2y_urbs_allocate(struct snd_usx2y_substream *subs) in usx2y_urbs_allocate() argument
418 int is_playback = subs == subs->usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK]; in usx2y_urbs_allocate()
419 struct usb_device *dev = subs->usx2y->dev; in usx2y_urbs_allocate()
422 pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) : in usx2y_urbs_allocate()
423 usb_rcvisocpipe(dev, subs->endpoint); in usx2y_urbs_allocate()
424 subs->maxpacksize = usb_maxpacket(dev, pipe, is_playback); in usx2y_urbs_allocate()
425 if (!subs->maxpacksize) in usx2y_urbs_allocate()
428 if (is_playback && !subs->tmpbuf) { /* allocate a temporary buffer for playback */ in usx2y_urbs_allocate()
429 subs->tmpbuf = kcalloc(nr_of_packs(), subs->maxpacksize, GFP_KERNEL); in usx2y_urbs_allocate()
430 if (!subs->tmpbuf) in usx2y_urbs_allocate()
435 purb = subs->urb + i; in usx2y_urbs_allocate()
442 usx2y_urbs_release(subs); in usx2y_urbs_allocate()
448 kmalloc_array(subs->maxpacksize, in usx2y_urbs_allocate()
451 usx2y_urbs_release(subs); in usx2y_urbs_allocate()
458 (*purb)->context = subs; in usx2y_urbs_allocate()
465 static void usx2y_subs_startup(struct snd_usx2y_substream *subs) in usx2y_subs_startup() argument
467 struct usx2ydev *usx2y = subs->usx2y; in usx2y_subs_startup()
469 usx2y->prepare_subs = subs; in usx2y_subs_startup()
470 subs->urb[0]->start_frame = -1; in usx2y_subs_startup()
475 static int usx2y_urbs_start(struct snd_usx2y_substream *subs) in usx2y_urbs_start() argument
478 struct usx2ydev *usx2y = subs->usx2y; in usx2y_urbs_start()
482 err = usx2y_urbs_allocate(subs); in usx2y_urbs_start()
485 subs->completed_urb = NULL; in usx2y_urbs_start()
487 struct snd_usx2y_substream *subs = usx2y->subs[i]; in usx2y_urbs_start() local
489 if (subs && atomic_read(&subs->state) >= STATE_PREPARED) in usx2y_urbs_start()
494 usx2y_subs_startup(subs); in usx2y_urbs_start()
496 urb = subs->urb[i]; in usx2y_urbs_start()
499 atomic_set(&subs->state, STATE_STARTING3); in usx2y_urbs_start()
502 urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack; in usx2y_urbs_start()
503 urb->iso_frame_desc[pack].length = subs->maxpacksize; in usx2y_urbs_start()
505 urb->transfer_buffer_length = subs->maxpacksize * nr_of_packs(); in usx2y_urbs_start()
517 atomic_set(&subs->state, STATE_STARTING1); in usx2y_urbs_start()
523 if (atomic_read(&subs->state) != STATE_PREPARED) in usx2y_urbs_start()
539 struct snd_usx2y_substream *subs = substream->runtime->private_data; in snd_usx2y_pcm_pointer() local
541 return subs->hwptr_done; in snd_usx2y_pcm_pointer()
549 struct snd_usx2y_substream *subs = substream->runtime->private_data; in snd_usx2y_pcm_trigger() local
554 if (atomic_read(&subs->state) == STATE_PREPARED && in snd_usx2y_pcm_trigger()
555 atomic_read(&subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE]->state) >= STATE_PREPARED) { in snd_usx2y_pcm_trigger()
556 atomic_set(&subs->state, STATE_PRERUNNING); in snd_usx2y_pcm_trigger()
564 if (atomic_read(&subs->state) >= STATE_PRERUNNING) in snd_usx2y_pcm_trigger()
565 atomic_set(&subs->state, STATE_PREPARED); in snd_usx2y_pcm_trigger()
776 struct snd_usx2y_substream *subs; in snd_usx2y_pcm_hw_params() local
786 subs = dev->subs[i]; in snd_usx2y_pcm_hw_params()
787 if (!subs) in snd_usx2y_pcm_hw_params()
789 test_substream = subs->pcm_substream; in snd_usx2y_pcm_hw_params()
813 struct snd_usx2y_substream *subs = runtime->private_data; in snd_usx2y_pcm_hw_free() local
816 mutex_lock(&subs->usx2y->pcm_mutex); in snd_usx2y_pcm_hw_free()
820 cap_subs = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE]; in snd_usx2y_pcm_hw_free()
821 atomic_set(&subs->state, STATE_STOPPED); in snd_usx2y_pcm_hw_free()
822 usx2y_urbs_release(subs); in snd_usx2y_pcm_hw_free()
831 playback_subs = subs->usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK]; in snd_usx2y_pcm_hw_free()
833 atomic_set(&subs->state, STATE_STOPPED); in snd_usx2y_pcm_hw_free()
834 usx2y_urbs_release(subs); in snd_usx2y_pcm_hw_free()
837 mutex_unlock(&subs->usx2y->pcm_mutex); in snd_usx2y_pcm_hw_free()
849 struct snd_usx2y_substream *subs = runtime->private_data; in snd_usx2y_pcm_prepare() local
850 struct usx2ydev *usx2y = subs->usx2y; in snd_usx2y_pcm_prepare()
851 struct snd_usx2y_substream *capsubs = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE]; in snd_usx2y_pcm_prepare()
857 usx2y_subs_prepare(subs); in snd_usx2y_pcm_prepare()
871 snd_printdd("starting capture pipe for %s\n", subs == capsubs ? "self" : "playpipe"); in snd_usx2y_pcm_prepare()
877 if (subs != capsubs && atomic_read(&subs->state) < STATE_PREPARED) in snd_usx2y_pcm_prepare()
878 err = usx2y_urbs_start(subs); in snd_usx2y_pcm_prepare()
906 struct snd_usx2y_substream *subs = in snd_usx2y_pcm_open() local
911 if (subs->usx2y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS) in snd_usx2y_pcm_open()
915 runtime->private_data = subs; in snd_usx2y_pcm_open()
916 subs->pcm_substream = substream; in snd_usx2y_pcm_open()
924 struct snd_usx2y_substream *subs = runtime->private_data; in snd_usx2y_pcm_close() local
926 subs->pcm_substream = NULL; in snd_usx2y_pcm_close()
967 usx2y(card)->subs + 2 * usx2y(card)->pcm_devs; in usx2y_audio_stream_new()