Skip to content

Commit 347eddd

Browse files
DP: add get_deadline and get_LPT to module API
as described in zephyr_dp_scheduler.c TODO: get estimation of LPT from module manifest currently only a "worst case" is calculated Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent de82282 commit 347eddd

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

src/audio/module_adapter/module/generic.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,3 +611,27 @@ void module_update_buffer_position(struct input_stream_buffer *input_buffers,
611611
output_buffers->size += audio_stream_frame_bytes(sink) * frames;
612612
}
613613
EXPORT_SYMBOL(module_update_buffer_position);
614+
615+
uint32_t module_get_deadline(struct processing_module *mod)
616+
{
617+
uint32_t deadline;
618+
619+
/* LL modules have no deadline - it is always "now" */
620+
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_LL)
621+
return 0;
622+
623+
/* startup condition - set deadline to "unknown" */
624+
if (mod->dp_startup_delay)
625+
return UINT32_MAX / 2;
626+
627+
deadline = UINT32_MAX;
628+
/* calculate the shortest LFT for all sinks */
629+
for (size_t i = 0; i < mod->num_of_sinks; i++) {
630+
uint32_t sink_lft = sink_get_last_feeding_time(mod->sinks[i]);
631+
632+
deadline = MIN(deadline, sink_lft);
633+
}
634+
635+
return deadline;
636+
}
637+
EXPORT_SYMBOL(module_get_deadline);

src/include/sof/audio/module_adapter/module/generic.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,29 @@ void module_adapter_set_params(struct processing_module *mod, struct sof_ipc_str
334334
int module_adapter_set_state(struct processing_module *mod, struct comp_dev *dev,
335335
int cmd);
336336
int module_adapter_sink_src_prepare(struct comp_dev *dev);
337+
338+
/**
339+
* Get a deadline based on current LFT reported by all sinks
340+
* it returns a value >= UINT32_MAX / 2 in case the deadline cannot be calculated:
341+
* - if a module is in a dealayed start
342+
* - if there's no sink - i.e. DP module is a pure data consumer (like key phrare detector)
343+
*
344+
* @return a deadline the module must finish processing since NOW [in us]
345+
*/
346+
uint32_t module_get_deadline(struct processing_module *mod);
347+
348+
/**
349+
* Get a Longest Processing Time estimation for the module, in us
350+
* It is either
351+
* - a value taken from the manifest or estimated from module period (TODO)
352+
* - or a value taken from IPC call (TODO)
353+
* - a worst case - module period
354+
* note that module period may be calculated reasonably late, i.e. in prepare() method
355+
*/
356+
static inline uint32_t module_get_lpt(struct processing_module *mod)
357+
{
358+
/* return worst case of LPT - a module period. See zephyr_dp_schedule.c for description */
359+
return mod->dev->period;
360+
}
361+
337362
#endif /* __SOF_AUDIO_MODULE_GENERIC__ */

0 commit comments

Comments
 (0)