Lines Matching full:stream

78 struct stream {  struct
88 int (*stream_start)(struct stream *, Ssc *const, argument
90 void (*stream_disable)(struct stream *, Ssc *const, argument
92 void (*queue_drop)(struct stream *); argument
99 struct stream rx; argument
100 struct stream tx;
108 static void rx_stream_disable(struct stream *, Ssc *const,
110 static void tx_stream_disable(struct stream *, Ssc *const,
212 struct stream *stream = &dev_data->rx; in dma_rx_callback() local
216 __ASSERT_NO_MSG(stream->mem_block != NULL); in dma_rx_callback()
219 if (stream->state == I2S_STATE_ERROR) { in dma_rx_callback()
224 ret = queue_put(&stream->mem_block_queue, stream->mem_block, in dma_rx_callback()
225 stream->cfg.block_size); in dma_rx_callback()
227 stream->state = I2S_STATE_ERROR; in dma_rx_callback()
230 stream->mem_block = NULL; in dma_rx_callback()
231 k_sem_give(&stream->sem); in dma_rx_callback()
234 if (stream->state == I2S_STATE_STOPPING) { in dma_rx_callback()
235 stream->state = I2S_STATE_READY; in dma_rx_callback()
240 ret = k_mem_slab_alloc(stream->cfg.mem_slab, &stream->mem_block, in dma_rx_callback()
243 stream->state = I2S_STATE_ERROR; in dma_rx_callback()
248 DCACHE_INVALIDATE(stream->mem_block, stream->cfg.block_size); in dma_rx_callback()
250 ret = reload_dma(dev_cfg->dev_dma, stream->dma_channel, in dma_rx_callback()
251 (void *)&(ssc->SSC_RHR), stream->mem_block, in dma_rx_callback()
252 stream->cfg.block_size); in dma_rx_callback()
261 rx_stream_disable(stream, ssc, dev_cfg->dev_dma); in dma_rx_callback()
272 struct stream *stream = &dev_data->tx; in dma_tx_callback() local
277 __ASSERT_NO_MSG(stream->mem_block != NULL); in dma_tx_callback()
280 k_mem_slab_free(stream->cfg.mem_slab, stream->mem_block); in dma_tx_callback()
281 stream->mem_block = NULL; in dma_tx_callback()
284 if (stream->state == I2S_STATE_ERROR) { in dma_tx_callback()
290 if (stream->last_block) { in dma_tx_callback()
291 stream->state = I2S_STATE_READY; in dma_tx_callback()
296 ret = queue_get(&stream->mem_block_queue, &stream->mem_block, in dma_tx_callback()
299 if (stream->state == I2S_STATE_STOPPING) { in dma_tx_callback()
300 stream->state = I2S_STATE_READY; in dma_tx_callback()
302 stream->state = I2S_STATE_ERROR; in dma_tx_callback()
306 k_sem_give(&stream->sem); in dma_tx_callback()
309 DCACHE_CLEAN(stream->mem_block, mem_block_size); in dma_tx_callback()
311 ret = reload_dma(dev_cfg->dev_dma, stream->dma_channel, in dma_tx_callback()
312 stream->mem_block, (void *)&(ssc->SSC_THR), in dma_tx_callback()
322 tx_stream_disable(stream, ssc, dev_cfg->dev_dma); in dma_tx_callback()
534 struct stream *stream; in i2s_sam_config_get() local
537 stream = &dev_data->rx; in i2s_sam_config_get()
539 stream = &dev_data->tx; in i2s_sam_config_get()
542 if (stream->state == I2S_STATE_NOT_READY) { in i2s_sam_config_get()
546 return &stream->cfg; in i2s_sam_config_get()
558 struct stream *stream; in i2s_sam_configure() local
562 stream = &dev_data->rx; in i2s_sam_configure()
564 stream = &dev_data->tx; in i2s_sam_configure()
572 if (stream->state != I2S_STATE_NOT_READY && in i2s_sam_configure()
573 stream->state != I2S_STATE_READY) { in i2s_sam_configure()
579 stream->queue_drop(stream); in i2s_sam_configure()
580 (void)memset(&stream->cfg, 0, sizeof(struct i2s_config)); in i2s_sam_configure()
581 stream->state = I2S_STATE_NOT_READY; in i2s_sam_configure()
609 memcpy(&stream->cfg, i2s_cfg, sizeof(struct i2s_config)); in i2s_sam_configure()
617 ret = stream->set_data_format(dev_cfg, i2s_cfg); in i2s_sam_configure()
623 stream->word_size_bytes = get_word_size_bytes(word_size_bits); in i2s_sam_configure()
629 stream->state = I2S_STATE_READY; in i2s_sam_configure()
634 static int rx_stream_start(struct stream *stream, Ssc *const ssc, in rx_stream_start() argument
639 ret = k_mem_slab_alloc(stream->cfg.mem_slab, &stream->mem_block, in rx_stream_start()
652 .source_data_size = stream->word_size_bytes, in rx_stream_start()
653 .dest_data_size = stream->word_size_bytes, in rx_stream_start()
655 .dma_slot = stream->dma_perid, in rx_stream_start()
662 ret = start_dma(dev_dma, stream->dma_channel, &dma_cfg, in rx_stream_start()
663 (void *)&(ssc->SSC_RHR), stream->mem_block, in rx_stream_start()
664 stream->cfg.block_size); in rx_stream_start()
680 static int tx_stream_start(struct stream *stream, Ssc *const ssc, in tx_stream_start() argument
686 ret = queue_get(&stream->mem_block_queue, &stream->mem_block, in tx_stream_start()
691 k_sem_give(&stream->sem); in tx_stream_start()
701 .source_data_size = stream->word_size_bytes, in tx_stream_start()
702 .dest_data_size = stream->word_size_bytes, in tx_stream_start()
704 .dma_slot = stream->dma_perid, in tx_stream_start()
712 DCACHE_CLEAN(stream->mem_block, mem_block_size); in tx_stream_start()
714 ret = start_dma(dev_dma, stream->dma_channel, &dma_cfg, in tx_stream_start()
715 stream->mem_block, (void *)&(ssc->SSC_THR), in tx_stream_start()
732 static void rx_stream_disable(struct stream *stream, Ssc *const ssc, in rx_stream_disable() argument
737 dma_stop(dev_dma, stream->dma_channel); in rx_stream_disable()
738 if (stream->mem_block != NULL) { in rx_stream_disable()
739 k_mem_slab_free(stream->cfg.mem_slab, stream->mem_block); in rx_stream_disable()
740 stream->mem_block = NULL; in rx_stream_disable()
744 static void tx_stream_disable(struct stream *stream, Ssc *const ssc, in tx_stream_disable() argument
749 dma_stop(dev_dma, stream->dma_channel); in tx_stream_disable()
750 if (stream->mem_block != NULL) { in tx_stream_disable()
751 k_mem_slab_free(stream->cfg.mem_slab, stream->mem_block); in tx_stream_disable()
752 stream->mem_block = NULL; in tx_stream_disable()
756 static void rx_queue_drop(struct stream *stream) in rx_queue_drop() argument
761 while (queue_get(&stream->mem_block_queue, &mem_block, &size) == 0) { in rx_queue_drop()
762 k_mem_slab_free(stream->cfg.mem_slab, mem_block); in rx_queue_drop()
765 k_sem_reset(&stream->sem); in rx_queue_drop()
768 static void tx_queue_drop(struct stream *stream) in tx_queue_drop() argument
774 while (queue_get(&stream->mem_block_queue, &mem_block, &size) == 0) { in tx_queue_drop()
775 k_mem_slab_free(stream->cfg.mem_slab, mem_block); in tx_queue_drop()
780 k_sem_give(&stream->sem); in tx_queue_drop()
790 struct stream *stream; in i2s_sam_trigger() local
795 stream = &dev_data->rx; in i2s_sam_trigger()
797 stream = &dev_data->tx; in i2s_sam_trigger()
807 if (stream->state != I2S_STATE_READY) { in i2s_sam_trigger()
812 __ASSERT_NO_MSG(stream->mem_block == NULL); in i2s_sam_trigger()
814 ret = stream->stream_start(stream, ssc, dev_cfg->dev_dma); in i2s_sam_trigger()
820 stream->state = I2S_STATE_RUNNING; in i2s_sam_trigger()
821 stream->last_block = false; in i2s_sam_trigger()
826 if (stream->state != I2S_STATE_RUNNING) { in i2s_sam_trigger()
831 stream->state = I2S_STATE_STOPPING; in i2s_sam_trigger()
833 stream->last_block = true; in i2s_sam_trigger()
838 if (stream->state != I2S_STATE_RUNNING) { in i2s_sam_trigger()
843 stream->state = I2S_STATE_STOPPING; in i2s_sam_trigger()
848 if (stream->state == I2S_STATE_NOT_READY) { in i2s_sam_trigger()
852 stream->stream_disable(stream, ssc, dev_cfg->dev_dma); in i2s_sam_trigger()
853 stream->queue_drop(stream); in i2s_sam_trigger()
854 stream->state = I2S_STATE_READY; in i2s_sam_trigger()
858 if (stream->state != I2S_STATE_ERROR) { in i2s_sam_trigger()
862 stream->state = I2S_STATE_READY; in i2s_sam_trigger()
863 stream->queue_drop(stream); in i2s_sam_trigger()