Lines Matching refs:rt
70 static int usb6fire_pcm_set_rate(struct pcm_runtime *rt) in usb6fire_pcm_set_rate() argument
73 struct control_runtime *ctrl_rt = rt->chip->control; in usb6fire_pcm_set_rate()
78 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_set_rate()
80 rates[rt->rate]); in usb6fire_pcm_set_rate()
84 ret = ctrl_rt->set_rate(ctrl_rt, rt->rate); in usb6fire_pcm_set_rate()
86 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_set_rate()
88 rates[rt->rate]); in usb6fire_pcm_set_rate()
95 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_set_rate()
97 rates[rt->rate]); in usb6fire_pcm_set_rate()
104 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_set_rate()
106 rates[rt->rate]); in usb6fire_pcm_set_rate()
110 rt->in_n_analog = IN_N_CHANNELS; in usb6fire_pcm_set_rate()
111 rt->out_n_analog = OUT_N_CHANNELS; in usb6fire_pcm_set_rate()
112 rt->in_packet_size = rates_in_packet_size[rt->rate]; in usb6fire_pcm_set_rate()
113 rt->out_packet_size = rates_out_packet_size[rt->rate]; in usb6fire_pcm_set_rate()
120 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_get_substream() local
123 return &rt->playback; in usb6fire_pcm_get_substream()
125 return &rt->capture; in usb6fire_pcm_get_substream()
126 dev_err(&rt->chip->dev->dev, "error getting pcm substream slot.\n"); in usb6fire_pcm_get_substream()
131 static void usb6fire_pcm_stream_stop(struct pcm_runtime *rt) in usb6fire_pcm_stream_stop() argument
134 struct control_runtime *ctrl_rt = rt->chip->control; in usb6fire_pcm_stream_stop()
136 if (rt->stream_state != STREAM_DISABLED) { in usb6fire_pcm_stream_stop()
138 rt->stream_state = STREAM_STOPPING; in usb6fire_pcm_stream_stop()
141 usb_kill_urb(&rt->in_urbs[i].instance); in usb6fire_pcm_stream_stop()
142 usb_kill_urb(&rt->out_urbs[i].instance); in usb6fire_pcm_stream_stop()
146 rt->stream_state = STREAM_DISABLED; in usb6fire_pcm_stream_stop()
151 static int usb6fire_pcm_stream_start(struct pcm_runtime *rt) in usb6fire_pcm_stream_start() argument
158 if (rt->stream_state == STREAM_DISABLED) { in usb6fire_pcm_stream_start()
160 rt->stream_wait_cond = false; in usb6fire_pcm_stream_start()
161 rt->stream_state = STREAM_STARTING; in usb6fire_pcm_stream_start()
164 packet = &rt->in_urbs[i].packets[k]; in usb6fire_pcm_stream_start()
165 packet->offset = k * rt->in_packet_size; in usb6fire_pcm_stream_start()
166 packet->length = rt->in_packet_size; in usb6fire_pcm_stream_start()
170 ret = usb_submit_urb(&rt->in_urbs[i].instance, in usb6fire_pcm_stream_start()
173 usb6fire_pcm_stream_stop(rt); in usb6fire_pcm_stream_start()
179 wait_event_timeout(rt->stream_wait_queue, rt->stream_wait_cond, in usb6fire_pcm_stream_start()
181 if (rt->stream_wait_cond) in usb6fire_pcm_stream_start()
182 rt->stream_state = STREAM_RUNNING; in usb6fire_pcm_stream_start()
184 usb6fire_pcm_stream_stop(rt); in usb6fire_pcm_stream_start()
198 struct pcm_runtime *rt = snd_pcm_substream_chip(sub->instance); in usb6fire_pcm_capture() local
212 / (rt->in_n_analog << 2); in usb6fire_pcm_capture()
227 src += rt->in_n_analog; in usb6fire_pcm_capture()
245 struct pcm_runtime *rt = snd_pcm_substream_chip(sub->instance); in usb6fire_pcm_playback() local
259 dev_err(&rt->chip->dev->dev, "Unknown sample format."); in usb6fire_pcm_playback()
268 / (rt->out_n_analog << 2); in usb6fire_pcm_playback()
275 dest += rt->out_n_analog; in usb6fire_pcm_playback()
290 struct pcm_runtime *rt = in_urb->chip->pcm; in usb6fire_pcm_in_urb_handler() local
300 if (usb_urb->status || rt->panic || rt->stream_state == STREAM_STOPPING) in usb6fire_pcm_in_urb_handler()
304 rt->panic = true; in usb6fire_pcm_in_urb_handler()
308 if (rt->stream_state == STREAM_DISABLED) { in usb6fire_pcm_in_urb_handler()
309 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_in_urb_handler()
315 sub = &rt->capture; in usb6fire_pcm_in_urb_handler()
332 - 4) / (rt->in_n_analog << 2) in usb6fire_pcm_in_urb_handler()
333 * (rt->out_n_analog << 2) + 4; in usb6fire_pcm_in_urb_handler()
340 sub = &rt->playback; in usb6fire_pcm_in_urb_handler()
358 / (rt->out_n_analog << 2); in usb6fire_pcm_in_urb_handler()
365 channel < rt->out_n_analog; in usb6fire_pcm_in_urb_handler()
378 struct pcm_runtime *rt = urb->chip->pcm; in usb6fire_pcm_out_urb_handler() local
380 if (rt->stream_state == STREAM_STARTING) { in usb6fire_pcm_out_urb_handler()
381 rt->stream_wait_cond = true; in usb6fire_pcm_out_urb_handler()
382 wake_up(&rt->stream_wait_queue); in usb6fire_pcm_out_urb_handler()
388 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_open() local
392 if (rt->panic) in usb6fire_pcm_open()
395 mutex_lock(&rt->stream_mutex); in usb6fire_pcm_open()
399 if (rt->rate < ARRAY_SIZE(rates)) in usb6fire_pcm_open()
400 alsa_rt->hw.rates = rates_alsaid[rt->rate]; in usb6fire_pcm_open()
402 sub = &rt->playback; in usb6fire_pcm_open()
404 if (rt->rate < ARRAY_SIZE(rates)) in usb6fire_pcm_open()
405 alsa_rt->hw.rates = rates_alsaid[rt->rate]; in usb6fire_pcm_open()
407 sub = &rt->capture; in usb6fire_pcm_open()
411 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_open()
412 dev_err(&rt->chip->dev->dev, "invalid stream type.\n"); in usb6fire_pcm_open()
418 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_open()
424 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_close() local
428 if (rt->panic) in usb6fire_pcm_close()
431 mutex_lock(&rt->stream_mutex); in usb6fire_pcm_close()
440 if (!rt->playback.instance && !rt->capture.instance) { in usb6fire_pcm_close()
441 usb6fire_pcm_stream_stop(rt); in usb6fire_pcm_close()
442 rt->rate = ARRAY_SIZE(rates); in usb6fire_pcm_close()
445 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_close()
451 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_prepare() local
456 if (rt->panic) in usb6fire_pcm_prepare()
461 mutex_lock(&rt->stream_mutex); in usb6fire_pcm_prepare()
465 if (rt->stream_state == STREAM_DISABLED) { in usb6fire_pcm_prepare()
466 for (rt->rate = 0; rt->rate < ARRAY_SIZE(rates); rt->rate++) in usb6fire_pcm_prepare()
467 if (alsa_rt->rate == rates[rt->rate]) in usb6fire_pcm_prepare()
469 if (rt->rate == ARRAY_SIZE(rates)) { in usb6fire_pcm_prepare()
470 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_prepare()
471 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_prepare()
477 ret = usb6fire_pcm_set_rate(rt); in usb6fire_pcm_prepare()
479 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_prepare()
482 ret = usb6fire_pcm_stream_start(rt); in usb6fire_pcm_prepare()
484 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_prepare()
485 dev_err(&rt->chip->dev->dev, in usb6fire_pcm_prepare()
490 mutex_unlock(&rt->stream_mutex); in usb6fire_pcm_prepare()
497 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_trigger() local
500 if (rt->panic) in usb6fire_pcm_trigger()
529 struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); in usb6fire_pcm_pointer() local
533 if (rt->panic || !sub) in usb6fire_pcm_pointer()
568 static int usb6fire_pcm_buffers_init(struct pcm_runtime *rt) in usb6fire_pcm_buffers_init() argument
573 rt->out_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE, in usb6fire_pcm_buffers_init()
576 if (!rt->out_urbs[i].buffer) in usb6fire_pcm_buffers_init()
578 rt->in_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE, in usb6fire_pcm_buffers_init()
581 if (!rt->in_urbs[i].buffer) in usb6fire_pcm_buffers_init()
587 static void usb6fire_pcm_buffers_destroy(struct pcm_runtime *rt) in usb6fire_pcm_buffers_destroy() argument
592 kfree(rt->out_urbs[i].buffer); in usb6fire_pcm_buffers_destroy()
593 kfree(rt->in_urbs[i].buffer); in usb6fire_pcm_buffers_destroy()
602 struct pcm_runtime *rt = in usb6fire_pcm_init() local
605 if (!rt) in usb6fire_pcm_init()
608 ret = usb6fire_pcm_buffers_init(rt); in usb6fire_pcm_init()
610 usb6fire_pcm_buffers_destroy(rt); in usb6fire_pcm_init()
611 kfree(rt); in usb6fire_pcm_init()
615 rt->chip = chip; in usb6fire_pcm_init()
616 rt->stream_state = STREAM_DISABLED; in usb6fire_pcm_init()
617 rt->rate = ARRAY_SIZE(rates); in usb6fire_pcm_init()
618 init_waitqueue_head(&rt->stream_wait_queue); in usb6fire_pcm_init()
619 mutex_init(&rt->stream_mutex); in usb6fire_pcm_init()
621 spin_lock_init(&rt->playback.lock); in usb6fire_pcm_init()
622 spin_lock_init(&rt->capture.lock); in usb6fire_pcm_init()
625 usb6fire_pcm_init_urb(&rt->in_urbs[i], chip, true, IN_EP, in usb6fire_pcm_init()
627 usb6fire_pcm_init_urb(&rt->out_urbs[i], chip, false, OUT_EP, in usb6fire_pcm_init()
630 rt->in_urbs[i].peer = &rt->out_urbs[i]; in usb6fire_pcm_init()
631 rt->out_urbs[i].peer = &rt->in_urbs[i]; in usb6fire_pcm_init()
636 usb6fire_pcm_buffers_destroy(rt); in usb6fire_pcm_init()
637 kfree(rt); in usb6fire_pcm_init()
642 pcm->private_data = rt; in usb6fire_pcm_init()
648 rt->instance = pcm; in usb6fire_pcm_init()
650 chip->pcm = rt; in usb6fire_pcm_init()
656 struct pcm_runtime *rt = chip->pcm; in usb6fire_pcm_abort() local
659 if (rt) { in usb6fire_pcm_abort()
660 rt->panic = true; in usb6fire_pcm_abort()
662 if (rt->playback.instance) in usb6fire_pcm_abort()
663 snd_pcm_stop_xrun(rt->playback.instance); in usb6fire_pcm_abort()
665 if (rt->capture.instance) in usb6fire_pcm_abort()
666 snd_pcm_stop_xrun(rt->capture.instance); in usb6fire_pcm_abort()
669 usb_poison_urb(&rt->in_urbs[i].instance); in usb6fire_pcm_abort()
670 usb_poison_urb(&rt->out_urbs[i].instance); in usb6fire_pcm_abort()
678 struct pcm_runtime *rt = chip->pcm; in usb6fire_pcm_destroy() local
680 usb6fire_pcm_buffers_destroy(rt); in usb6fire_pcm_destroy()
681 kfree(rt); in usb6fire_pcm_destroy()