Skip to content

Commit

Permalink
DP: src: Fix period calculation for SRC DP module
Browse files Browse the repository at this point in the history
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 <Jaroslaw.Stelter@intel.com>
  • Loading branch information
jxstelter committed Nov 20, 2023
1 parent 8fb9f76 commit 2fcfba5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/audio/src/src_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <sof/audio/sink_api.h>
#include <sof/audio/source_api.h>
#include <sof/audio/sink_source_utils.h>
#include <sof/schedule/ll_schedule_domain.h>
#include <rtos/panic.h>
#include <sof/ipc/msg.h>
#include <rtos/alloc.h>
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 2fcfba5

Please sign in to comment.