From 2fcfba55e88049a7b3e9d6b1d1b9952833a94a35 Mon Sep 17 00:00:00 2001 From: Jaroslaw Stelter Date: Wed, 8 Nov 2023 16:08:03 +0100 Subject: [PATCH] DP: src: Fix period calculation for SRC DP module The OBS parameter for SRC module could be set to higher value than the one defined by stream output format. This could result in wrong calculation of period parameter. Due to this issue we observe SRC tests regression on LNL platform. This patch adds output stream format to period calculation in addition to the one calculated from OBS. Lower value is selected. Also period is round down to represent integer multiple of LL ticks. Signed-off-by: Jaroslaw Stelter --- src/audio/src/src_ipc4.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/audio/src/src_ipc4.c b/src/audio/src/src_ipc4.c index cf87bde47554..e248fc4c19eb 100644 --- a/src/audio/src/src_ipc4.c +++ b/src/audio/src/src_ipc4.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -107,9 +108,17 @@ int src_set_params(struct processing_module *mod, struct sof_sink *sink) * as SRC uses period value to calculate its internal buffers, * it must be done here, right after setting sink parameters */ - if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) - dev->period = 1000000 * sink_get_min_free_space(sink) / + if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) { + uint32_t min_free_size = + sink_get_frame_bytes(sink) * (sink_get_rate(sink) / + (USEC_PER_SEC / LL_TIMER_PERIOD_US)); + min_free_size = MIN(min_free_size, sink_get_min_free_space(sink)); + + dev->period = 1000000 * min_free_size / (sink_get_frame_bytes(sink) * sink_get_rate(sink)); + /* Round down period to integer number of LL ticks */ + dev->period = ROUND_DOWN(dev->period, LL_TIMER_PERIOD_US); + } comp_info(dev, "SRC DP period calculated as: %u", dev->period);