Lines Matching full:stream
198 struct stream *stream; in i2s_stm32_configure() local
204 stream = &dev_data->rx; in i2s_stm32_configure()
206 stream = &dev_data->tx; in i2s_stm32_configure()
214 if (stream->state != I2S_STATE_NOT_READY && in i2s_stm32_configure()
215 stream->state != I2S_STATE_READY) { in i2s_stm32_configure()
220 stream->master = true; in i2s_stm32_configure()
223 stream->master = false; in i2s_stm32_configure()
227 stream->queue_drop(stream); in i2s_stm32_configure()
228 memset(&stream->cfg, 0, sizeof(struct i2s_config)); in i2s_stm32_configure()
229 stream->state = I2S_STATE_NOT_READY; in i2s_stm32_configure()
233 memcpy(&stream->cfg, i2s_cfg, sizeof(struct i2s_config)); in i2s_stm32_configure()
236 enable_mck = stream->master && cfg->master_clk_sel; in i2s_stm32_configure()
312 stream->state = I2S_STATE_READY; in i2s_stm32_configure()
321 struct stream *stream; in i2s_stm32_trigger() local
326 stream = &dev_data->rx; in i2s_stm32_trigger()
328 stream = &dev_data->tx; in i2s_stm32_trigger()
338 if (stream->state != I2S_STATE_READY) { in i2s_stm32_trigger()
340 stream->state); in i2s_stm32_trigger()
344 __ASSERT_NO_MSG(stream->mem_block == NULL); in i2s_stm32_trigger()
346 ret = stream->stream_start(stream, dev); in i2s_stm32_trigger()
352 stream->state = I2S_STATE_RUNNING; in i2s_stm32_trigger()
353 stream->last_block = false; in i2s_stm32_trigger()
358 if (stream->state != I2S_STATE_RUNNING) { in i2s_stm32_trigger()
365 stream->state = I2S_STATE_STOPPING; in i2s_stm32_trigger()
370 stream->tx_stop_for_drain = false; in i2s_stm32_trigger()
372 stream->stream_disable(stream, dev); in i2s_stm32_trigger()
373 stream->state = I2S_STATE_READY; in i2s_stm32_trigger()
374 stream->last_block = true; in i2s_stm32_trigger()
381 if (stream->state != I2S_STATE_RUNNING) { in i2s_stm32_trigger()
388 if ((queue_is_empty(&stream->mem_block_queue) == false) || in i2s_stm32_trigger()
390 stream->state = I2S_STATE_STOPPING; in i2s_stm32_trigger()
395 stream->tx_stop_for_drain = true; in i2s_stm32_trigger()
397 stream->stream_disable(stream, dev); in i2s_stm32_trigger()
398 stream->state = I2S_STATE_READY; in i2s_stm32_trigger()
410 if (stream->state == I2S_STATE_NOT_READY) { in i2s_stm32_trigger()
414 stream->stream_disable(stream, dev); in i2s_stm32_trigger()
415 stream->queue_drop(stream); in i2s_stm32_trigger()
416 stream->state = I2S_STATE_READY; in i2s_stm32_trigger()
420 if (stream->state != I2S_STATE_ERROR) { in i2s_stm32_trigger()
424 stream->state = I2S_STATE_READY; in i2s_stm32_trigger()
425 stream->queue_drop(stream); in i2s_stm32_trigger()
552 static void rx_stream_disable(struct stream *stream, const struct device *dev);
553 static void tx_stream_disable(struct stream *stream, const struct device *dev);
562 struct stream *stream = &dev_data->rx; in dma_rx_callback() local
568 stream->state = I2S_STATE_ERROR; in dma_rx_callback()
572 __ASSERT_NO_MSG(stream->mem_block != NULL); in dma_rx_callback()
575 if (stream->state == I2S_STATE_ERROR) { in dma_rx_callback()
579 mblk_tmp = stream->mem_block; in dma_rx_callback()
582 ret = k_mem_slab_alloc(stream->cfg.mem_slab, &stream->mem_block, in dma_rx_callback()
585 stream->state = I2S_STATE_ERROR; in dma_rx_callback()
589 ret = reload_dma(stream->dev_dma, stream->dma_channel, in dma_rx_callback()
590 &stream->dma_cfg, in dma_rx_callback()
596 stream->mem_block, in dma_rx_callback()
597 stream->cfg.block_size); in dma_rx_callback()
604 sys_cache_data_invd_range(mblk_tmp, stream->cfg.block_size); in dma_rx_callback()
607 ret = queue_put(&stream->mem_block_queue, mblk_tmp, in dma_rx_callback()
608 stream->cfg.block_size); in dma_rx_callback()
610 stream->state = I2S_STATE_ERROR; in dma_rx_callback()
613 k_sem_give(&stream->sem); in dma_rx_callback()
616 if (stream->state == I2S_STATE_STOPPING) { in dma_rx_callback()
617 stream->state = I2S_STATE_READY; in dma_rx_callback()
624 rx_stream_disable(stream, dev); in dma_rx_callback()
633 struct stream *stream = &dev_data->tx; in dma_tx_callback() local
639 stream->state = I2S_STATE_ERROR; in dma_tx_callback()
643 __ASSERT_NO_MSG(stream->mem_block != NULL); in dma_tx_callback()
646 k_mem_slab_free(stream->cfg.mem_slab, stream->mem_block); in dma_tx_callback()
647 stream->mem_block = NULL; in dma_tx_callback()
650 if (stream->state == I2S_STATE_ERROR) { in dma_tx_callback()
656 if ((stream->state == I2S_STATE_STOPPING) && (status == DMA_STATUS_COMPLETE)) { in dma_tx_callback()
662 if (queue_is_empty(&stream->mem_block_queue) == true) { in dma_tx_callback()
663 stream->queue_drop(stream); in dma_tx_callback()
664 stream->state = I2S_STATE_READY; in dma_tx_callback()
666 } else if (stream->tx_stop_for_drain == false) { in dma_tx_callback()
671 stream->state = I2S_STATE_READY; in dma_tx_callback()
678 if (stream->last_block) { in dma_tx_callback()
679 stream->state = I2S_STATE_READY; in dma_tx_callback()
684 ret = queue_get(&stream->mem_block_queue, &stream->mem_block, in dma_tx_callback()
687 if (stream->state == I2S_STATE_STOPPING) { in dma_tx_callback()
688 stream->state = I2S_STATE_READY; in dma_tx_callback()
690 stream->state = I2S_STATE_ERROR; in dma_tx_callback()
694 k_sem_give(&stream->sem); in dma_tx_callback()
697 sys_cache_data_flush_range(stream->mem_block, mem_block_size); in dma_tx_callback()
699 ret = reload_dma(stream->dev_dma, stream->dma_channel, in dma_tx_callback()
700 &stream->dma_cfg, in dma_tx_callback()
701 stream->mem_block, in dma_tx_callback()
716 tx_stream_disable(stream, dev); in dma_tx_callback()
746 struct stream *stream = &dev_data->tx; in i2s_stm32_initialize() local
750 stream->tx_stop_for_drain = false; in i2s_stm32_initialize()
792 static int rx_stream_start(struct stream *stream, const struct device *dev) in rx_stream_start() argument
797 ret = k_mem_slab_alloc(stream->cfg.mem_slab, &stream->mem_block, in rx_stream_start()
803 if (stream->master) { in rx_stream_start()
810 active_dma_rx_channel[stream->dma_channel] = dev; in rx_stream_start()
812 ret = start_dma(stream->dev_dma, stream->dma_channel, in rx_stream_start()
813 &stream->dma_cfg, in rx_stream_start()
819 stream->src_addr_increment, stream->mem_block, in rx_stream_start()
820 stream->dst_addr_increment, stream->fifo_threshold, in rx_stream_start()
821 stream->cfg.block_size); in rx_stream_start()
844 static int tx_stream_start(struct stream *stream, const struct device *dev) in tx_stream_start() argument
850 ret = queue_get(&stream->mem_block_queue, &stream->mem_block, in tx_stream_start()
855 k_sem_give(&stream->sem); in tx_stream_start()
858 sys_cache_data_flush_range(stream->mem_block, mem_block_size); in tx_stream_start()
860 if (stream->master) { in tx_stream_start()
867 active_dma_tx_channel[stream->dma_channel] = dev; in tx_stream_start()
869 ret = start_dma(stream->dev_dma, stream->dma_channel, in tx_stream_start()
870 &stream->dma_cfg, in tx_stream_start()
871 stream->mem_block, stream->src_addr_increment, in tx_stream_start()
877 stream->dst_addr_increment, stream->fifo_threshold, in tx_stream_start()
878 stream->cfg.block_size); in tx_stream_start()
901 static void rx_stream_disable(struct stream *stream, const struct device *dev) in rx_stream_disable() argument
914 dma_stop(stream->dev_dma, stream->dma_channel); in rx_stream_disable()
915 if (stream->mem_block != NULL) { in rx_stream_disable()
916 k_mem_slab_free(stream->cfg.mem_slab, stream->mem_block); in rx_stream_disable()
917 stream->mem_block = NULL; in rx_stream_disable()
922 active_dma_rx_channel[stream->dma_channel] = NULL; in rx_stream_disable()
925 static void tx_stream_disable(struct stream *stream, const struct device *dev) in tx_stream_disable() argument
938 dma_stop(stream->dev_dma, stream->dma_channel); in tx_stream_disable()
939 if (stream->mem_block != NULL) { in tx_stream_disable()
940 k_mem_slab_free(stream->cfg.mem_slab, stream->mem_block); in tx_stream_disable()
941 stream->mem_block = NULL; in tx_stream_disable()
948 active_dma_tx_channel[stream->dma_channel] = NULL; in tx_stream_disable()
951 static void rx_queue_drop(struct stream *stream) in rx_queue_drop() argument
956 while (queue_get(&stream->mem_block_queue, &mem_block, &size) == 0) { in rx_queue_drop()
957 k_mem_slab_free(stream->cfg.mem_slab, mem_block); in rx_queue_drop()
960 k_sem_reset(&stream->sem); in rx_queue_drop()
963 static void tx_queue_drop(struct stream *stream) in tx_queue_drop() argument
969 while (queue_get(&stream->mem_block_queue, &mem_block, &size) == 0) { in tx_queue_drop()
970 k_mem_slab_free(stream->cfg.mem_slab, mem_block); in tx_queue_drop()
975 k_sem_give(&stream->sem); in tx_queue_drop()