Lines Matching full:stream

33 struct stream {  struct
50 struct stream rx; argument
55 struct stream tx;
173 struct stream *stream; in i2s_mcux_config_get() local
176 stream = &dev_data->rx; in i2s_mcux_config_get()
178 stream = &dev_data->tx; in i2s_mcux_config_get()
181 if (stream->state == I2S_STATE_NOT_READY) { in i2s_mcux_config_get()
185 return &stream->cfg; in i2s_mcux_config_get()
193 struct stream *stream; in i2s_mcux_configure() local
199 stream = &dev_data->rx; in i2s_mcux_configure()
201 stream = &dev_data->tx; in i2s_mcux_configure()
209 if (stream->state != I2S_STATE_NOT_READY && in i2s_mcux_configure()
210 stream->state != I2S_STATE_READY) { in i2s_mcux_configure()
216 stream->state = I2S_STATE_NOT_READY; in i2s_mcux_configure()
304 stream->dma_cfg.dest_data_size = 4U; in i2s_mcux_configure()
305 stream->dma_cfg.source_data_size = 4U; in i2s_mcux_configure()
308 memcpy(&stream->cfg, i2s_cfg, sizeof(struct i2s_config)); in i2s_mcux_configure()
310 stream->state = I2S_STATE_READY; in i2s_mcux_configure()
314 static inline void i2s_purge_stream_buffers(struct stream *stream, in i2s_purge_stream_buffers() argument
323 while (k_msgq_get(&stream->in_queue, &queue_entry, K_NO_WAIT) == 0) { in i2s_purge_stream_buffers()
327 while (k_msgq_get(&stream->in_queue, &buffer, K_NO_WAIT) == 0) { in i2s_purge_stream_buffers()
331 while (k_msgq_get(&stream->out_queue, &buffer, K_NO_WAIT) == 0) { in i2s_purge_stream_buffers()
340 struct stream *stream = &dev_data->tx; in i2s_mcux_tx_stream_disable() local
343 LOG_DBG("Stopping DMA channel %u for TX stream", stream->channel); in i2s_mcux_tx_stream_disable()
344 dma_stop(stream->dev_dma, stream->channel); in i2s_mcux_tx_stream_disable()
371 /* purge buffers queued in the stream */ in i2s_mcux_tx_stream_disable()
373 i2s_purge_stream_buffers(stream, stream->cfg.mem_slab, true); in i2s_mcux_tx_stream_disable()
381 struct stream *stream = &dev_data->rx; in i2s_mcux_rx_stream_disable() local
384 LOG_DBG("Stopping DMA channel %u for RX stream", stream->channel); in i2s_mcux_rx_stream_disable()
385 dma_stop(stream->dev_dma, stream->channel); in i2s_mcux_rx_stream_disable()
398 /* purge buffers queued in the stream */ in i2s_mcux_rx_stream_disable()
400 i2s_purge_stream_buffers(stream, stream->cfg.mem_slab, false); in i2s_mcux_rx_stream_disable()
412 struct stream *stream; in i2s_mcux_config_dma_blocks() local
415 stream = &dev_data->rx; in i2s_mcux_config_dma_blocks()
419 stream = &dev_data->tx; in i2s_mcux_config_dma_blocks()
424 stream->dma_cfg.head_block = blk_cfg; in i2s_mcux_config_dma_blocks()
444 stream->dma_cfg.user_data = (void *)dev; in i2s_mcux_config_dma_blocks()
446 dma_config(stream->dev_dma, stream->channel, &stream->dma_cfg); in i2s_mcux_config_dma_blocks()
448 LOG_DBG("dma_slot is %d", stream->dma_cfg.dma_slot); in i2s_mcux_config_dma_blocks()
449 LOG_DBG("channel_direction is %d", stream->dma_cfg.channel_direction); in i2s_mcux_config_dma_blocks()
451 stream->dma_cfg.complete_callback_en); in i2s_mcux_config_dma_blocks()
452 LOG_DBG("error_callback_dis is %d", stream->dma_cfg.error_callback_dis); in i2s_mcux_config_dma_blocks()
453 LOG_DBG("source_handshake is %d", stream->dma_cfg.source_handshake); in i2s_mcux_config_dma_blocks()
454 LOG_DBG("dest_handshake is %d", stream->dma_cfg.dest_handshake); in i2s_mcux_config_dma_blocks()
455 LOG_DBG("channel_priority is %d", stream->dma_cfg.channel_priority); in i2s_mcux_config_dma_blocks()
456 LOG_DBG("source_chaining_en is %d", stream->dma_cfg.source_chaining_en); in i2s_mcux_config_dma_blocks()
457 LOG_DBG("dest_chaining_en is %d", stream->dma_cfg.dest_chaining_en); in i2s_mcux_config_dma_blocks()
458 LOG_DBG("linked_channel is %d", stream->dma_cfg.linked_channel); in i2s_mcux_config_dma_blocks()
459 LOG_DBG("source_data_size is %d", stream->dma_cfg.source_data_size); in i2s_mcux_config_dma_blocks()
460 LOG_DBG("dest_data_size is %d", stream->dma_cfg.dest_data_size); in i2s_mcux_config_dma_blocks()
461 LOG_DBG("source_burst_length is %d", stream->dma_cfg.source_burst_length); in i2s_mcux_config_dma_blocks()
462 LOG_DBG("dest_burst_length is %d", stream->dma_cfg.dest_burst_length); in i2s_mcux_config_dma_blocks()
463 LOG_DBG("block_count is %d", stream->dma_cfg.block_count); in i2s_mcux_config_dma_blocks()
472 struct stream *stream = &dev_data->tx; in i2s_mcux_dma_tx_callback() local
476 LOG_DBG("tx cb: %d", stream->state); in i2s_mcux_dma_tx_callback()
478 ret = k_msgq_get(&stream->out_queue, &queue_entry.mem_block, K_NO_WAIT); in i2s_mcux_dma_tx_callback()
481 k_mem_slab_free(stream->cfg.mem_slab, queue_entry.mem_block); in i2s_mcux_dma_tx_callback()
487 if (stream->last_block) { in i2s_mcux_dma_tx_callback()
488 stream->state = I2S_STATE_READY; in i2s_mcux_dma_tx_callback()
494 switch (stream->state) { in i2s_mcux_dma_tx_callback()
498 ret = k_msgq_get(&stream->in_queue, &queue_entry, K_NO_WAIT); in i2s_mcux_dma_tx_callback()
504 k_msgq_put(&stream->out_queue, &queue_entry.mem_block, K_NO_WAIT); in i2s_mcux_dma_tx_callback()
505 dma_start(stream->dev_dma, stream->channel); in i2s_mcux_dma_tx_callback()
516 if (stream->state == I2S_STATE_STOPPING) { in i2s_mcux_dma_tx_callback()
517 stream->state = I2S_STATE_READY; in i2s_mcux_dma_tx_callback()
519 stream->state = I2S_STATE_ERROR; in i2s_mcux_dma_tx_callback()
535 struct stream *stream = &dev_data->rx; in i2s_mcux_dma_rx_callback() local
539 LOG_DBG("rx cb: %d", stream->state); in i2s_mcux_dma_rx_callback()
542 stream->state = I2S_STATE_ERROR; in i2s_mcux_dma_rx_callback()
547 switch (stream->state) { in i2s_mcux_dma_rx_callback()
551 ret = k_msgq_get(&stream->in_queue, &buffer, K_NO_WAIT); in i2s_mcux_dma_rx_callback()
555 ret = k_msgq_put(&stream->out_queue, &buffer, K_NO_WAIT); in i2s_mcux_dma_rx_callback()
558 &stream->out_queue, ret); in i2s_mcux_dma_rx_callback()
560 stream->state = I2S_STATE_ERROR; in i2s_mcux_dma_rx_callback()
562 if (stream->state == I2S_STATE_RUNNING) { in i2s_mcux_dma_rx_callback()
564 ret = k_mem_slab_alloc(stream->cfg.mem_slab, &buffer, K_NO_WAIT); in i2s_mcux_dma_rx_callback()
567 stream->cfg.mem_slab, ret); in i2s_mcux_dma_rx_callback()
569 stream->state = I2S_STATE_ERROR; in i2s_mcux_dma_rx_callback()
574 dma_reload(stream->dev_dma, stream->channel, in i2s_mcux_dma_rx_callback()
576 stream->cfg.block_size); in i2s_mcux_dma_rx_callback()
578 ret = k_msgq_put(&stream->in_queue, &buffer, K_NO_WAIT); in i2s_mcux_dma_rx_callback()
581 buffer, &stream->in_queue, ret); in i2s_mcux_dma_rx_callback()
583 dma_start(stream->dev_dma, stream->channel); in i2s_mcux_dma_rx_callback()
588 stream->state = I2S_STATE_READY; in i2s_mcux_dma_rx_callback()
602 struct stream *stream = &dev_data->tx; in i2s_mcux_tx_stream_start() local
607 ret = k_msgq_get(&stream->in_queue, &queue_entry, K_NO_WAIT); in i2s_mcux_tx_stream_start()
618 ret = k_msgq_put(&stream->out_queue, &queue_entry.mem_block, K_NO_WAIT); in i2s_mcux_tx_stream_start()
627 ret = dma_start(stream->dev_dma, stream->channel); in i2s_mcux_tx_stream_start()
645 struct stream *stream = &dev_data->rx; in i2s_mcux_rx_stream_start() local
649 num_of_bufs = k_mem_slab_num_free_get(stream->cfg.mem_slab); in i2s_mcux_rx_stream_start()
660 ret = k_mem_slab_alloc(stream->cfg.mem_slab, &buffer[i], in i2s_mcux_rx_stream_start()
669 stream->cfg.block_size); in i2s_mcux_rx_stream_start()
673 ret = k_msgq_put(&stream->in_queue, &buffer[i], K_NO_WAIT); in i2s_mcux_rx_stream_start()
683 ret = dma_start(stream->dev_dma, stream->channel); in i2s_mcux_rx_stream_start()
685 LOG_ERR("Failed to start DMA Ch%d (%d)", stream->channel, ret); in i2s_mcux_rx_stream_start()
699 struct stream *stream; in i2s_mcux_trigger() local
704 stream = &dev_data->rx; in i2s_mcux_trigger()
706 stream = &dev_data->tx; in i2s_mcux_trigger()
718 if (stream->state != I2S_STATE_READY) { in i2s_mcux_trigger()
720 stream->state); in i2s_mcux_trigger()
736 stream->state = I2S_STATE_RUNNING; in i2s_mcux_trigger()
737 stream->last_block = false; in i2s_mcux_trigger()
741 if (stream->state != I2S_STATE_RUNNING) { in i2s_mcux_trigger()
742 LOG_ERR("STOP trigger: invalid state %d", stream->state); in i2s_mcux_trigger()
746 stream->state = I2S_STATE_STOPPING; in i2s_mcux_trigger()
747 stream->last_block = true; in i2s_mcux_trigger()
751 if (stream->state != I2S_STATE_RUNNING) { in i2s_mcux_trigger()
752 LOG_ERR("DRAIN trigger: invalid state %d", stream->state); in i2s_mcux_trigger()
756 stream->state = I2S_STATE_STOPPING; in i2s_mcux_trigger()
760 if (stream->state == I2S_STATE_NOT_READY) { in i2s_mcux_trigger()
761 LOG_ERR("DROP trigger: invalid state %d", stream->state); in i2s_mcux_trigger()
765 stream->state = I2S_STATE_READY; in i2s_mcux_trigger()
774 if (stream->state != I2S_STATE_ERROR) { in i2s_mcux_trigger()
775 LOG_ERR("PREPARE trigger: invalid state %d", stream->state); in i2s_mcux_trigger()
779 stream->state = I2S_STATE_READY; in i2s_mcux_trigger()
801 struct stream *stream = &dev_data->rx; in i2s_mcux_read() local
805 if (stream->state == I2S_STATE_NOT_READY) { in i2s_mcux_read()
806 LOG_ERR("invalid state %d", stream->state); in i2s_mcux_read()
810 ret = k_msgq_get(&stream->out_queue, &buffer, in i2s_mcux_read()
811 SYS_TIMEOUT_MS(stream->cfg.timeout)); in i2s_mcux_read()
814 if (stream->state == I2S_STATE_ERROR) { in i2s_mcux_read()
822 *size = stream->cfg.block_size; in i2s_mcux_read()
830 struct stream *stream = &dev_data->tx; in i2s_mcux_write() local
837 if (stream->state != I2S_STATE_RUNNING && in i2s_mcux_write()
838 stream->state != I2S_STATE_READY) { in i2s_mcux_write()
839 LOG_ERR("invalid state (%d)", stream->state); in i2s_mcux_write()
843 ret = k_msgq_put(&stream->in_queue, &queue_entry, in i2s_mcux_write()
844 SYS_TIMEOUT_MS(stream->cfg.timeout)); in i2s_mcux_write()
866 struct stream *stream = &dev_data->tx; in i2s_mcux_isr() local
873 stream = &dev_data->tx; in i2s_mcux_isr()
874 stream->state = I2S_STATE_ERROR; in i2s_mcux_isr()
880 stream = &dev_data->rx; in i2s_mcux_isr()
881 stream->state = I2S_STATE_ERROR; in i2s_mcux_isr()