Skip to content

Commit

Permalink
dai: use ibs/obs for dma buffer size calculation
Browse files Browse the repository at this point in the history
Use ibs/obs size from ipc4_base_module_cfg to properly calculate
period_count. It is especially important when FW aggregation mode
is enabled and there are multiple DMAs allocated under one copier
instance. That way period count for every DMA will be correctly
evaluated and used for DMA buffer size calculation.

Signed-off-by: Ievgen Ganakov <ievgen.ganakov@intel.com>
  • Loading branch information
iganakov authored and kv2019i committed Apr 5, 2024
1 parent 1e9a497 commit 2126e28
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,12 +848,28 @@ static int dai_set_dma_buffer(struct dai_data *dd, struct comp_dev *dev,

/* calculate DMA buffer size */
period_count = dd->dma->plat_data.period_count;

#if CONFIG_IPC_MAJOR_4
struct ipc4_copier_module_cfg *copier_cfg = dd->dai_spec_config;
uint32_t dma_buff_length_periods;

/* copier ibs/obs is set to size of one period */
if (dev->direction == SOF_IPC_STREAM_CAPTURE)
dma_buff_length_periods = dd->ipc_config.dma_buffer_size / copier_cfg->base.ibs;
else
dma_buff_length_periods = dd->ipc_config.dma_buffer_size / copier_cfg->base.obs;

period_count = MAX(period_count, dma_buff_length_periods);
#else
period_count = MAX(period_count,
SOF_DIV_ROUND_UP(dd->ipc_config.dma_buffer_size, period_bytes));
#endif /* CONFIG_IPC_MAJOR_4 */

if (!period_count) {
comp_err(dev, "dai_set_dma_buffer(): no valid dma buffer period count");
return -EINVAL;
}
period_count = MAX(period_count,
SOF_DIV_ROUND_UP(dd->ipc_config.dma_buffer_size, period_bytes));

buffer_size = ALIGN_UP(period_count * period_bytes, align);
*pc = period_count;

Expand Down

0 comments on commit 2126e28

Please sign in to comment.