Skip to content

Commit c681756

Browse files
marcinszkudlinskikv2019i
authored andcommitted
mod: align DP period down to LL cycle
As DP EDF scheduler runs in LL cycles, DP period should be always calculated at granularity of LL cycle Fail preparation if a module calculated period shorter than 1LL cycle Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent fc9edf7 commit c681756

2 files changed

Lines changed: 29 additions & 12 deletions

File tree

src/audio/module_adapter/module_adapter.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <sof/audio/source_api.h>
1919
#include <sof/audio/audio_buffer.h>
2020
#include <sof/audio/pipeline.h>
21+
#include <sof/schedule/ll_schedule_domain.h>
2122
#include <sof/common.h>
2223
#include <sof/platform.h>
2324
#include <sof/ut.h>
@@ -198,9 +199,21 @@ int module_adapter_prepare(struct comp_dev *dev)
198199
* but events and therefore don't have any deadline for processing
199200
* Second example is a module with variable data rate on output (like MPEG encoder)
200201
*/
201-
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP && !dev->period) {
202-
module_adapter_calculate_dp_period(dev);
203-
comp_info(dev, "DP Module period set to %u", dev->period);
202+
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
203+
/* calculate DP period if a module didn't */
204+
if (!dev->period)
205+
module_adapter_calculate_dp_period(dev);
206+
207+
if (dev->period < LL_TIMER_PERIOD_US) {
208+
comp_err(dev, "DP Module period too short (%u us), must be at least 1LL cycle (%llu us)",
209+
dev->period, LL_TIMER_PERIOD_US);
210+
return -EINVAL;
211+
}
212+
213+
/* align down period to LL cycle time */
214+
dev->period /= LL_TIMER_PERIOD_US;
215+
dev->period *= LL_TIMER_PERIOD_US;
216+
comp_info(dev, "DP Module period set to %u us", dev->period);
204217
}
205218
#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */
206219

src/audio/src/src_ipc4.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <sof/audio/sink_api.h>
1717
#include <sof/audio/source_api.h>
1818
#include <sof/audio/sink_source_utils.h>
19+
#include <sof/schedule/ll_schedule_domain.h>
1920
#include <rtos/panic.h>
2021
#include <sof/ipc/msg.h>
2122
#include <rtos/alloc.h>
@@ -99,17 +100,20 @@ int src_set_params(struct processing_module *mod, struct sof_sink *sink)
99100

100101
src_params.frame_fmt = valid_fmt;
101102
ret = sink_set_params(sink, &src_params, true);
102-
103-
/* if module is to be run as DP, calculate module period
104-
* according to OBS size and data rate
105-
* as SRC uses period value to calculate its internal buffers,
106-
* it must be done here, right after setting sink parameters
107-
*/
108-
if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP)
103+
if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
104+
/* if module is to be run as DP, calculate module period
105+
* according to OBS size and data rate
106+
* as SRC uses period value to calculate its internal buffers,
107+
* it must be done here, right after setting sink parameters
108+
*/
109109
dev->period = 1000000 * sink_get_min_free_space(sink) /
110-
(sink_get_frame_bytes(sink) * sink_get_rate(sink));
110+
(sink_get_frame_bytes(sink) * sink_get_rate(sink));
111+
/* align down period to LL cycle time */
112+
dev->period /= LL_TIMER_PERIOD_US;
113+
dev->period *= LL_TIMER_PERIOD_US;
111114

112-
comp_info(dev, "SRC DP period calculated as: %u", dev->period);
115+
comp_info(dev, "SRC DP period calculated as: %u us", dev->period);
116+
}
113117

114118
component_set_nearest_period_frames(dev, src_params.rate);
115119
/* Update module stream_params */

0 commit comments

Comments
 (0)