mirror of https://github.com/thesofproject/sof.git
lib: dma: Add a new DMA buffer copy function
Add a new DMA copy function, dma_buffer_copy_from_no_consume(), that can be used to copy from the DMA buffer to the sink without modifying the read pointer in the DMA buffer. This will be used when the DMA data needs to be copied to multiple sink buffers. The DMA buffer pointer should be updated at the end of all copies in this case. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This commit is contained in:
parent
4a4d8d2619
commit
a09982e093
|
@ -378,3 +378,24 @@ int dma_buffer_copy_to(struct comp_buffer __sparse_cache *source,
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int dma_buffer_copy_from_no_consume(struct comp_buffer __sparse_cache *source,
|
||||
struct comp_buffer __sparse_cache *sink,
|
||||
dma_process_func process, uint32_t source_bytes)
|
||||
{
|
||||
struct audio_stream __sparse_cache *istream = &source->stream;
|
||||
uint32_t samples = source_bytes /
|
||||
audio_stream_sample_bytes(istream);
|
||||
uint32_t sink_bytes = audio_stream_sample_bytes(&sink->stream) *
|
||||
samples;
|
||||
int ret;
|
||||
|
||||
/* process data */
|
||||
ret = process(istream, 0, &sink->stream, 0, samples);
|
||||
|
||||
buffer_stream_writeback(sink, sink_bytes);
|
||||
|
||||
comp_update_buffer_produce(sink, sink_bytes);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -532,6 +532,15 @@ int dma_buffer_copy_from(struct comp_buffer __sparse_cache *source,
|
|||
struct comp_buffer __sparse_cache *sink,
|
||||
dma_process_func process, uint32_t source_bytes);
|
||||
|
||||
/*
|
||||
* Used when copying DMA buffer bytes into multiple sink buffers, one at a time using the provided
|
||||
* conversion function. DMA buffer consume should be performed after the data has been copied
|
||||
* to all sinks.
|
||||
*/
|
||||
int dma_buffer_copy_from_no_consume(struct comp_buffer __sparse_cache *source,
|
||||
struct comp_buffer __sparse_cache *sink,
|
||||
dma_process_func process, uint32_t source_bytes);
|
||||
|
||||
/* copies data to DMA buffer using provided processing function */
|
||||
int dma_buffer_copy_to(struct comp_buffer __sparse_cache *source,
|
||||
struct comp_buffer __sparse_cache *sink,
|
||||
|
|
Loading…
Reference in New Issue