Lines Matching refs:rt
74 static int usb6fire_pcm_set_rate(struct pcm_runtime *rt) in usb6fire_pcm_set_rate() argument
77 struct control_runtime *ctrl_rt = rt->chip->control; in usb6fire_pcm_set_rate()
82 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_set_rate()
84 rates[rt->rate]); in usb6fire_pcm_set_rate()
88 ret = ctrl_rt->set_rate(ctrl_rt, rt->rate); in usb6fire_pcm_set_rate()
90 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_set_rate()
92 rates[rt->rate]); in usb6fire_pcm_set_rate()
99 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_set_rate()
101 rates[rt->rate]); in usb6fire_pcm_set_rate()
108 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_set_rate()
110 rates[rt->rate]); in usb6fire_pcm_set_rate()
114 rt->in_n_analog = IN_N_CHANNELS; in usb6fire_pcm_set_rate()
115 rt->out_n_analog = OUT_N_CHANNELS; in usb6fire_pcm_set_rate()
116 rt->in_packet_size = rates_in_packet_size[rt->rate]; in usb6fire_pcm_set_rate()
117 rt->out_packet_size = rates_out_packet_size[rt->rate]; in usb6fire_pcm_set_rate()
124 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_get_substream() local
127 return &rt->playback; in usb6fire_pcm_get_substream()
129 return &rt->capture; in usb6fire_pcm_get_substream()
130 dev_err(&rt->chip->dev->dev, "error getting pcm substream slot.\n"); in usb6fire_pcm_get_substream()
135 static void usb6fire_pcm_stream_stop(struct pcm_runtime *rt) in usb6fire_pcm_stream_stop() argument
138 struct control_runtime *ctrl_rt = rt->chip->control; in usb6fire_pcm_stream_stop()
140 if (rt->stream_state != STREAM_DISABLED) { in usb6fire_pcm_stream_stop()
142 rt->stream_state = STREAM_STOPPING; in usb6fire_pcm_stream_stop()
145 usb_kill_urb(&rt->in_urbs[i].instance); in usb6fire_pcm_stream_stop()
146 usb_kill_urb(&rt->out_urbs[i].instance); in usb6fire_pcm_stream_stop()
150 rt->stream_state = STREAM_DISABLED; in usb6fire_pcm_stream_stop()
155 static int usb6fire_pcm_stream_start(struct pcm_runtime *rt) in usb6fire_pcm_stream_start() argument
162 if (rt->stream_state == STREAM_DISABLED) { in usb6fire_pcm_stream_start()
164 rt->stream_wait_cond = false; in usb6fire_pcm_stream_start()
165 rt->stream_state = STREAM_STARTING; in usb6fire_pcm_stream_start()
168 packet = &rt->in_urbs[i].packets[k]; in usb6fire_pcm_stream_start()
169 packet->offset = k * rt->in_packet_size; in usb6fire_pcm_stream_start()
170 packet->length = rt->in_packet_size; in usb6fire_pcm_stream_start()
174 ret = usb_submit_urb(&rt->in_urbs[i].instance, in usb6fire_pcm_stream_start()
177 usb6fire_pcm_stream_stop(rt); in usb6fire_pcm_stream_start()
183 wait_event_timeout(rt->stream_wait_queue, rt->stream_wait_cond, in usb6fire_pcm_stream_start()
185 if (rt->stream_wait_cond) in usb6fire_pcm_stream_start()
186 rt->stream_state = STREAM_RUNNING; in usb6fire_pcm_stream_start()
188 usb6fire_pcm_stream_stop(rt); in usb6fire_pcm_stream_start()
202 struct pcm_runtime *rt = snd_pcm_substream_chip(sub->instance); in usb6fire_pcm_capture() local
216 / (rt->in_n_analog << 2); in usb6fire_pcm_capture()
231 src += rt->in_n_analog; in usb6fire_pcm_capture()
249 struct pcm_runtime *rt = snd_pcm_substream_chip(sub->instance); in usb6fire_pcm_playback() local
263 dev_err(&rt->chip->dev->dev, "Unknown sample format."); in usb6fire_pcm_playback()
272 / (rt->out_n_analog << 2); in usb6fire_pcm_playback()
279 dest += rt->out_n_analog; in usb6fire_pcm_playback()
294 struct pcm_runtime *rt = in_urb->chip->pcm; in usb6fire_pcm_in_urb_handler() local
304 if (usb_urb->status || rt->panic || rt->stream_state == STREAM_STOPPING) in usb6fire_pcm_in_urb_handler()
308 rt->panic = true; in usb6fire_pcm_in_urb_handler()
312 if (rt->stream_state == STREAM_DISABLED) { in usb6fire_pcm_in_urb_handler()
313 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_in_urb_handler()
319 sub = &rt->capture; in usb6fire_pcm_in_urb_handler()
336 - 4) / (rt->in_n_analog << 2) in usb6fire_pcm_in_urb_handler()
337 * (rt->out_n_analog << 2) + 4; in usb6fire_pcm_in_urb_handler()
344 sub = &rt->playback; in usb6fire_pcm_in_urb_handler()
362 / (rt->out_n_analog << 2); in usb6fire_pcm_in_urb_handler()
369 channel < rt->out_n_analog; in usb6fire_pcm_in_urb_handler()
382 struct pcm_runtime *rt = urb->chip->pcm; in usb6fire_pcm_out_urb_handler() local
384 if (rt->stream_state == STREAM_STARTING) { in usb6fire_pcm_out_urb_handler()
385 rt->stream_wait_cond = true; in usb6fire_pcm_out_urb_handler()
386 wake_up(&rt->stream_wait_queue); in usb6fire_pcm_out_urb_handler()
392 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_open() local
396 if (rt->panic) in usb6fire_pcm_open()
399 mutex_lock(&rt->stream_mutex); in usb6fire_pcm_open()
403 if (rt->rate < ARRAY_SIZE(rates)) in usb6fire_pcm_open()
404 alsa_rt->hw.rates = rates_alsaid[rt->rate]; in usb6fire_pcm_open()
406 sub = &rt->playback; in usb6fire_pcm_open()
408 if (rt->rate < ARRAY_SIZE(rates)) in usb6fire_pcm_open()
409 alsa_rt->hw.rates = rates_alsaid[rt->rate]; in usb6fire_pcm_open()
411 sub = &rt->capture; in usb6fire_pcm_open()
415 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_open()
416 dev_err(&rt->chip->dev->dev, "invalid stream type.\n"); in usb6fire_pcm_open()
422 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_open()
428 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_close() local
432 if (rt->panic) in usb6fire_pcm_close()
435 mutex_lock(&rt->stream_mutex); in usb6fire_pcm_close()
444 if (!rt->playback.instance && !rt->capture.instance) { in usb6fire_pcm_close()
445 usb6fire_pcm_stream_stop(rt); in usb6fire_pcm_close()
446 rt->rate = ARRAY_SIZE(rates); in usb6fire_pcm_close()
449 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_close()
467 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_prepare() local
472 if (rt->panic) in usb6fire_pcm_prepare()
477 mutex_lock(&rt->stream_mutex); in usb6fire_pcm_prepare()
481 if (rt->stream_state == STREAM_DISABLED) { in usb6fire_pcm_prepare()
482 for (rt->rate = 0; rt->rate < ARRAY_SIZE(rates); rt->rate++) in usb6fire_pcm_prepare()
483 if (alsa_rt->rate == rates[rt->rate]) in usb6fire_pcm_prepare()
485 if (rt->rate == ARRAY_SIZE(rates)) { in usb6fire_pcm_prepare()
486 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_prepare()
487 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_prepare()
493 ret = usb6fire_pcm_set_rate(rt); in usb6fire_pcm_prepare()
495 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_prepare()
498 ret = usb6fire_pcm_stream_start(rt); in usb6fire_pcm_prepare()
500 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_prepare()
501 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_prepare()
506 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_prepare()
513 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_trigger() local
516 if (rt->panic) in usb6fire_pcm_trigger()
545 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_pointer() local
549 if (rt->panic || !sub) in usb6fire_pcm_pointer()
588 static int usb6fire_pcm_buffers_init(struct pcm_runtime *rt) in usb6fire_pcm_buffers_init() argument
593 rt->out_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE, in usb6fire_pcm_buffers_init()
596 if (!rt->out_urbs[i].buffer) in usb6fire_pcm_buffers_init()
598 rt->in_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE, in usb6fire_pcm_buffers_init()
601 if (!rt->in_urbs[i].buffer) in usb6fire_pcm_buffers_init()
607 static void usb6fire_pcm_buffers_destroy(struct pcm_runtime *rt) in usb6fire_pcm_buffers_destroy() argument
612 kfree(rt->out_urbs[i].buffer); in usb6fire_pcm_buffers_destroy()
613 kfree(rt->in_urbs[i].buffer); in usb6fire_pcm_buffers_destroy()
622 struct pcm_runtime *rt = in usb6fire_pcm_init() local
625 if (!rt) in usb6fire_pcm_init()
628 ret = usb6fire_pcm_buffers_init(rt); in usb6fire_pcm_init()
630 usb6fire_pcm_buffers_destroy(rt); in usb6fire_pcm_init()
631 kfree(rt); in usb6fire_pcm_init()
635 rt->chip = chip; in usb6fire_pcm_init()
636 rt->stream_state = STREAM_DISABLED; in usb6fire_pcm_init()
637 rt->rate = ARRAY_SIZE(rates); in usb6fire_pcm_init()
638 init_waitqueue_head(&rt->stream_wait_queue); in usb6fire_pcm_init()
639 mutex_init(&rt->stream_mutex); in usb6fire_pcm_init()
641 spin_lock_init(&rt->playback.lock); in usb6fire_pcm_init()
642 spin_lock_init(&rt->capture.lock); in usb6fire_pcm_init()
645 usb6fire_pcm_init_urb(&rt->in_urbs[i], chip, true, IN_EP, in usb6fire_pcm_init()
647 usb6fire_pcm_init_urb(&rt->out_urbs[i], chip, false, OUT_EP, in usb6fire_pcm_init()
650 rt->in_urbs[i].peer = &rt->out_urbs[i]; in usb6fire_pcm_init()
651 rt->out_urbs[i].peer = &rt->in_urbs[i]; in usb6fire_pcm_init()
656 usb6fire_pcm_buffers_destroy(rt); in usb6fire_pcm_init()
657 kfree(rt); in usb6fire_pcm_init()
662 pcm->private_data = rt; in usb6fire_pcm_init()
668 usb6fire_pcm_buffers_destroy(rt); in usb6fire_pcm_init()
669 kfree(rt); in usb6fire_pcm_init()
674 rt->instance = pcm; in usb6fire_pcm_init()
676 chip->pcm = rt; in usb6fire_pcm_init()
682 struct pcm_runtime *rt = chip->pcm; in usb6fire_pcm_abort() local
685 if (rt) { in usb6fire_pcm_abort()
686 rt->panic = true; in usb6fire_pcm_abort()
688 if (rt->playback.instance) in usb6fire_pcm_abort()
689 snd_pcm_stop_xrun(rt->playback.instance); in usb6fire_pcm_abort()
691 if (rt->capture.instance) in usb6fire_pcm_abort()
692 snd_pcm_stop_xrun(rt->capture.instance); in usb6fire_pcm_abort()
695 usb_poison_urb(&rt->in_urbs[i].instance); in usb6fire_pcm_abort()
696 usb_poison_urb(&rt->out_urbs[i].instance); in usb6fire_pcm_abort()
704 struct pcm_runtime *rt = chip->pcm; in usb6fire_pcm_destroy() local
706 usb6fire_pcm_buffers_destroy(rt); in usb6fire_pcm_destroy()
707 kfree(rt); in usb6fire_pcm_destroy()