mirror of https://github.com/thesofproject/sof.git
dma: dma_buffer_copy_*() functions should use cached buffer objects
dma_buffer_copy_to() and dma_buffer_copy_from() should be called on properly acquired buffer objects. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
parent
e3e4ced1f7
commit
084f8ccc42
|
@ -240,8 +240,8 @@ struct dma_info {
|
|||
};
|
||||
|
||||
struct audio_stream;
|
||||
typedef int (*dma_process_func)(const struct audio_stream *source,
|
||||
uint32_t ioffset, struct audio_stream *sink,
|
||||
typedef int (*dma_process_func)(const struct audio_stream __sparse_cache *source,
|
||||
uint32_t ioffset, struct audio_stream __sparse_cache *sink,
|
||||
uint32_t ooffset, uint32_t frames);
|
||||
|
||||
/**
|
||||
|
@ -517,11 +517,13 @@ typedef void (*dma_process)(const struct audio_stream *,
|
|||
struct audio_stream *, uint32_t);
|
||||
|
||||
/* copies data from DMA buffer using provided processing function */
|
||||
int dma_buffer_copy_from(struct comp_buffer *source, struct comp_buffer *sink,
|
||||
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);
|
||||
|
||||
/* copies data to DMA buffer using provided processing function */
|
||||
int dma_buffer_copy_to(struct comp_buffer *source, struct comp_buffer *sink,
|
||||
int dma_buffer_copy_to(struct comp_buffer __sparse_cache *source,
|
||||
struct comp_buffer __sparse_cache *sink,
|
||||
dma_process_func process, uint32_t sink_bytes);
|
||||
|
||||
/* generic DMA DSP <-> Host copier */
|
||||
|
|
|
@ -317,10 +317,11 @@ void dma_sg_free(struct dma_sg_elem_array *elem_array)
|
|||
dma_sg_init(elem_array);
|
||||
}
|
||||
|
||||
int dma_buffer_copy_from(struct comp_buffer *source, struct comp_buffer *sink,
|
||||
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)
|
||||
{
|
||||
struct audio_stream *istream = &source->stream;
|
||||
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) *
|
||||
|
@ -340,15 +341,16 @@ int dma_buffer_copy_from(struct comp_buffer *source, struct comp_buffer *sink,
|
|||
* appear in topology so notifier event is not needed
|
||||
*/
|
||||
audio_stream_consume(istream, source_bytes);
|
||||
comp_update_buffer_produce(sink, sink_bytes);
|
||||
comp_update_buffer_cached_produce(sink, sink_bytes);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int dma_buffer_copy_to(struct comp_buffer *source, struct comp_buffer *sink,
|
||||
int dma_buffer_copy_to(struct comp_buffer __sparse_cache *source,
|
||||
struct comp_buffer __sparse_cache *sink,
|
||||
dma_process_func process, uint32_t sink_bytes)
|
||||
{
|
||||
struct audio_stream *ostream = &sink->stream;
|
||||
struct audio_stream __sparse_cache *ostream = &sink->stream;
|
||||
uint32_t samples = sink_bytes /
|
||||
audio_stream_sample_bytes(ostream);
|
||||
uint32_t source_bytes = audio_stream_sample_bytes(&source->stream) *
|
||||
|
@ -368,7 +370,7 @@ int dma_buffer_copy_to(struct comp_buffer *source, struct comp_buffer *sink,
|
|||
* appear in topology so notifier event is not needed
|
||||
*/
|
||||
audio_stream_produce(ostream, sink_bytes);
|
||||
comp_update_buffer_consume(source, source_bytes);
|
||||
comp_update_buffer_cached_consume(source, source_bytes);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue