Skip to content

Commit 00b3887

Browse files
marcinszkudlinskitmleman
authored andcommitted
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 58f48e4 commit 00b3887

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
@@ -796,3 +796,27 @@ void module_update_buffer_position(struct input_stream_buffer *input_buffers,
796796
output_buffers->size += audio_stream_frame_bytes(sink) * frames;
797797
}
798798
EXPORT_SYMBOL(module_update_buffer_position);
799+
800+
uint32_t module_get_deadline(struct processing_module *mod)
801+
{
802+
uint32_t deadline;
803+
804+
/* LL modules have no deadline - it is always "now" */
805+
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_LL)
806+
return 0;
807+
808+
/* startup condition - set deadline to "unknown" */
809+
if (mod->dp_startup_delay)
810+
return UINT32_MAX / 2;
811+
812+
deadline = UINT32_MAX;
813+
/* calculate the shortest LFT for all sinks */
814+
for (size_t i = 0; i < mod->num_of_sinks; i++) {
815+
uint32_t sink_lft = sink_get_last_feeding_time(mod->sinks[i]);
816+
817+
deadline = MIN(deadline, sink_lft);
818+
}
819+
820+
return deadline;
821+
}
822+
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
@@ -407,4 +407,29 @@ void module_adapter_set_params(struct processing_module *mod, struct sof_ipc_str
407407
int module_adapter_set_state(struct processing_module *mod, struct comp_dev *dev,
408408
int cmd);
409409
int module_adapter_sink_src_prepare(struct comp_dev *dev);
410+
411+
/**
412+
* Get a deadline based on current LFT reported by all sinks
413+
* it returns a value >= UINT32_MAX / 2 in case the deadline cannot be calculated:
414+
* - if a module is in a dealayed start
415+
* - if there's no sink - i.e. DP module is a pure data consumer (like key phrare detector)
416+
*
417+
* @return a deadline the module must finish processing since NOW [in us]
418+
*/
419+
uint32_t module_get_deadline(struct processing_module *mod);
420+
421+
/**
422+
* Get a Longest Processing Time estimation for the module, in us
423+
* It is either
424+
* - a value taken from the manifest or estimated from module period (TODO)
425+
* - or a value taken from IPC call (TODO)
426+
* - a worst case - module period
427+
* note that module period may be calculated reasonably late, i.e. in prepare() method
428+
*/
429+
static inline uint32_t module_get_lpt(struct processing_module *mod)
430+
{
431+
/* return worst case of LPT - a module period. See zephyr_dp_schedule.c for description */
432+
return mod->dev->period;
433+
}
434+
410435
#endif /* __SOF_AUDIO_MODULE_GENERIC__ */

0 commit comments

Comments
 (0)