Skip to content

Commit 8c40f41

Browse files
committed
dai: use ibs/obs for dma buffer size calculation
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>
1 parent 6980cdd commit 8c40f41

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/audio/dai-zephyr.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,12 +848,28 @@ static int dai_set_dma_buffer(struct dai_data *dd, struct comp_dev *dev,
848848

849849
/* calculate DMA buffer size */
850850
period_count = dd->dma->plat_data.period_count;
851+
852+
#if CONFIG_IPC_MAJOR_4
853+
struct ipc4_copier_module_cfg *copier_cfg = dd->dai_spec_config;
854+
uint32_t dma_buff_length_periods;
855+
856+
/* copier ibs/obs is set to size of one period */
857+
if (dev->direction == SOF_IPC_STREAM_CAPTURE)
858+
dma_buff_length_periods = dd->ipc_config.dma_buffer_size / copier_cfg->base.ibs;
859+
else
860+
dma_buff_length_periods = dd->ipc_config.dma_buffer_size / copier_cfg->base.obs;
861+
862+
period_count = MAX(period_count, dma_buff_length_periods);
863+
#else
864+
period_count = MAX(period_count,
865+
SOF_DIV_ROUND_UP(dd->ipc_config.dma_buffer_size, period_bytes));
866+
#endif /* CONFIG_IPC_MAJOR_4 */
867+
851868
if (!period_count) {
852869
comp_err(dev, "dai_set_dma_buffer(): no valid dma buffer period count");
853870
return -EINVAL;
854871
}
855-
period_count = MAX(period_count,
856-
SOF_DIV_ROUND_UP(dd->ipc_config.dma_buffer_size, period_bytes));
872+
857873
buffer_size = ALIGN_UP(period_count * period_bytes, align);
858874
*pc = period_count;
859875

0 commit comments

Comments
 (0)