Skip to content

Commit

Permalink
DP: module: Fix period calculation for DP modules
Browse files Browse the repository at this point in the history
The OBS parameter for 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 9, 2023
1 parent b9bd230 commit 279ba92
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/audio/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <sof/audio/sink_source_utils.h>
#include <sof/audio/dp_queue.h>
#include <sof/audio/pipeline.h>
#include <sof/schedule/ll_schedule_domain.h>
#include <sof/common.h>
#include <sof/platform.h>
#include <sof/ut.h>
Expand Down Expand Up @@ -240,9 +241,17 @@ static int module_adapter_dp_queue_prepare(struct comp_dev *dev)
&sink_buffer->stream.runtime_stream_params,
sizeof(sink_buffer->stream.runtime_stream_params));
/* calculate time required the module to provide OBS data portion - a period */
unsigned int sink_period = 1000000 * sink_get_min_free_space(mod->sinks[i]) /
uint32_t min_free_size =
sink_get_frame_bytes(mod->sinks[i]) *
(sink_get_rate(mod->sinks[i]) / (USEC_PER_SEC / LL_TIMER_PERIOD_US));
min_free_size = MIN(min_free_size, sink_get_min_free_space(mod->sinks[i]));

unsigned int sink_period = 1000000 * min_free_size /
(sink_get_frame_bytes(mod->sinks[i]) *
sink_get_rate(mod->sinks[i]));
/* Round down period to integer number of LL ticks */
sink_period = (sink_period / LL_TIMER_PERIOD_US) * LL_TIMER_PERIOD_US;

/* note the minimal period for the module */
if (period > sink_period)
period = sink_period;
Expand Down

0 comments on commit 279ba92

Please sign in to comment.