dma: Remove redundant sink/source bytes parameter from dma_buffer_copy*

This value is strictly correlated with given samples number,
passing sink/source bytes number as separate parameter may
lead to data desynchronization.
Temporary number of samples and sink_bytes is calculated in
dma_buffer_copy_*() function, but it should be removed in
future. 'process' should be modified to take only number of
bytes to process from source stream and return number of
output bytes in sink stream, to allow easily handling of
compressed audio streams.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This commit is contained in:
Karol Trzcinski 2020-07-09 19:02:46 +02:00 committed by Marcin Maka
parent 6ac8e1f2f8
commit 87574da19e
4 changed files with 24 additions and 32 deletions

View File

@ -73,9 +73,6 @@ static void dai_dma_cb(void *arg, enum notify_id type, void *data)
struct comp_dev *dev = arg;
struct dai_data *dd = comp_get_drvdata(dev);
uint32_t bytes = next->elem.size;
uint32_t sink_bytes;
uint32_t samples = bytes /
audio_stream_sample_bytes(&dd->dma_buffer->stream);
void *buffer_ptr;
comp_dbg(dev, "dai_dma_cb()");
@ -101,18 +98,14 @@ static void dai_dma_cb(void *arg, enum notify_id type, void *data)
return;
}
sink_bytes = samples *
audio_stream_sample_bytes(&dd->local_buffer->stream);
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
dma_buffer_copy_to(dd->local_buffer, sink_bytes,
dd->dma_buffer, bytes,
dd->process, samples);
dma_buffer_copy_to(dd->local_buffer, dd->dma_buffer,
dd->process, bytes);
buffer_ptr = dd->local_buffer->stream.r_ptr;
} else {
dma_buffer_copy_from(dd->dma_buffer, bytes, dd->local_buffer,
sink_bytes, dd->process, samples);
dma_buffer_copy_from(dd->dma_buffer, dd->local_buffer,
dd->process, bytes);
buffer_ptr = dd->local_buffer->stream.w_ptr;
}

View File

@ -130,18 +130,13 @@ static uint32_t host_dma_get_split(struct host_data *hd, uint32_t bytes)
static void host_update_position(struct comp_dev *dev, uint32_t bytes)
{
struct host_data *hd = comp_get_drvdata(dev);
uint32_t samples;
samples = bytes / audio_stream_sample_bytes(&hd->local_buffer->stream);
if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
dma_buffer_copy_from(hd->dma_buffer, bytes,
hd->local_buffer, bytes,
hd->process, samples);
dma_buffer_copy_from(hd->dma_buffer, hd->local_buffer,
hd->process, bytes);
else
dma_buffer_copy_to(hd->local_buffer, bytes,
hd->dma_buffer, bytes,
hd->process, samples);
dma_buffer_copy_to(hd->local_buffer, hd->dma_buffer,
hd->process, bytes);
dev->position += bytes;

View File

@ -607,14 +607,12 @@ typedef void (*dma_process)(const struct audio_stream *,
struct audio_stream *, uint32_t);
/* copies data from DMA buffer using provided processing function */
void dma_buffer_copy_from(struct comp_buffer *source, uint32_t source_bytes,
struct comp_buffer *sink, uint32_t sink_bytes,
dma_process_func process, uint32_t samples);
void dma_buffer_copy_from(struct comp_buffer *source, struct comp_buffer *sink,
dma_process_func process, uint32_t source_bytes);
/* copies data to DMA buffer using provided processing function */
void dma_buffer_copy_to(struct comp_buffer *source, uint32_t source_bytes,
struct comp_buffer *sink, uint32_t sink_bytes,
dma_process_func process, uint32_t samples);
void dma_buffer_copy_to(struct comp_buffer *source, struct comp_buffer *sink,
dma_process_func process, uint32_t sink_bytes);
/* generic DMA DSP <-> Host copier */

View File

@ -189,11 +189,14 @@ void dma_sg_free(struct dma_sg_elem_array *elem_array)
dma_sg_init(elem_array);
}
void dma_buffer_copy_from(struct comp_buffer *source, uint32_t source_bytes,
struct comp_buffer *sink, uint32_t sink_bytes,
dma_process_func process, uint32_t samples)
void dma_buffer_copy_from(struct comp_buffer *source, struct comp_buffer *sink,
dma_process_func process, uint32_t source_bytes)
{
struct audio_stream *istream = &source->stream;
uint32_t samples = source_bytes /
audio_stream_sample_bytes(istream);
uint32_t sink_bytes = audio_stream_sample_bytes(&sink->stream) *
samples;
/* source buffer contains data copied by DMA */
audio_stream_invalidate(istream, source_bytes);
@ -209,11 +212,14 @@ void dma_buffer_copy_from(struct comp_buffer *source, uint32_t source_bytes,
comp_update_buffer_produce(sink, sink_bytes);
}
void dma_buffer_copy_to(struct comp_buffer *source, uint32_t source_bytes,
struct comp_buffer *sink, uint32_t sink_bytes,
dma_process_func process, uint32_t samples)
void dma_buffer_copy_to(struct comp_buffer *source, struct comp_buffer *sink,
dma_process_func process, uint32_t sink_bytes)
{
struct audio_stream *ostream = &sink->stream;
uint32_t samples = sink_bytes /
audio_stream_sample_bytes(ostream);
uint32_t source_bytes = audio_stream_sample_bytes(&source->stream) *
samples;
buffer_invalidate(source, source_bytes);