Skip to content

Commit

Permalink
1. fixed bug that copy order incorrect at host component.
Browse files Browse the repository at this point in the history
2. a lot of log just print wPtr and rPtr of local-buffer and dma-buffer, it can confirm copy order correctness. It should disable logs manually.
  • Loading branch information
chihualee committed Sep 3, 2024
1 parent ff57b79 commit bce1363
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/audio/host-legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ static uint32_t host_get_copy_bytes_one_shot(struct host_data *hd, struct comp_d
*/
static int host_copy_one_shot(struct host_data *hd, struct comp_dev *dev, copy_callback_t cb)
{
struct comp_buffer *source;
struct comp_buffer *sink;
uint32_t copy_bytes = 0;
int ret = 0;

Expand All @@ -212,6 +214,17 @@ static int host_copy_one_shot(struct host_data *hd, struct comp_dev *dev, copy_c
return ret;
}

if (dev->direction == SOF_IPC_STREAM_CAPTURE)
{
source = hd->local_buffer;
sink = hd->dma_buffer;
comp_info(dev, "bf cp local buf addr %p end %p w %p r %p", source->stream.addr, source->stream.end_addr, source->stream.w_ptr, source->stream.r_ptr);
comp_info(dev, "bf cp dma addr %p end %p w %p r %p", sink->stream.addr, sink->stream.end_addr, sink->stream.w_ptr, sink->stream.r_ptr);
ret = dma_buffer_copy_to(source, sink, hd->process, copy_bytes);
comp_info(dev, "af cp local buf addr %p end %p w %p r %p", source->stream.addr, source->stream.end_addr, source->stream.w_ptr, source->stream.r_ptr);
comp_info(dev, "af cp dma addr %p end %p w %p r %p", sink->stream.addr, sink->stream.end_addr, sink->stream.w_ptr, sink->stream.r_ptr);
}

ret = dma_copy_legacy(hd->chan, copy_bytes, DMA_COPY_ONE_SHOT);
if (ret < 0) {
comp_err(dev, "host_copy_one_shot(): dma_copy() failed, ret = %u", ret);
Expand All @@ -226,18 +239,14 @@ void host_common_update(struct host_data *hd, struct comp_dev *dev, uint32_t byt
{
struct comp_buffer *source;
struct comp_buffer *sink;
int ret;
int ret = 0;
bool update_mailbox = false;
bool send_ipc = false;

if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
source = hd->dma_buffer;
sink = hd->local_buffer;
ret = dma_buffer_copy_from(source, sink, hd->process, bytes, DUMMY_CHMAP);
} else {
source = hd->local_buffer;
sink = hd->dma_buffer;
ret = dma_buffer_copy_to(source, sink, hd->process, bytes, DUMMY_CHMAP);
}

/* assert dma_buffer_copy succeed */
Expand Down
1 change: 1 addition & 0 deletions src/drivers/generic/dummy-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static ssize_t dummy_dma_copy_crt_elem(struct dma_chan_pdata *pdata,
*/
dcache_invalidate_region((void *)rptr, copy_size);

tr_info(&ddma_tr, "dummy dma wptr %x rptr %x size 0x%x", wptr, rptr, copy_size);
/* Perform the copy, being careful if we overflow the elem */
ret = memcpy_s((void *)wptr, remaining_size, (void *)rptr, copy_size);
assert(!ret);
Expand Down

0 comments on commit bce1363

Please sign in to comment.