From 93198aa73515864f8821493eb9605f727b85f5c8 Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Wed, 21 Feb 2024 16:10:38 +0100 Subject: [PATCH] modules: Remove unnecessary functions from Processing Module Adapter To ensure proper operation of native loadable modules it is necessary to bypass Processing Module Adapter used by FDK modules. This is currently done by overriding the pointer to module_interface used by the Module Adapter. Thanks to this, the Module Adapter directly calls functions provided by native module. As in this case the Processing Module Adapter functions are omitted, support for native libraries are removed from it as it is no longer needed. This leads to remove is_native_sof variable and modules_process_raw, modules_process_audio_stream functions. Signed-off-by: Adrian Warecki --- src/audio/module_adapter/module/modules.c | 90 ++++++----------------- 1 file changed, 22 insertions(+), 68 deletions(-) diff --git a/src/audio/module_adapter/module/modules.c b/src/audio/module_adapter/module/modules.c index d83405888757..fbfb237ba79f 100644 --- a/src/audio/module_adapter/module/modules.c +++ b/src/audio/module_adapter/module/modules.c @@ -10,12 +10,8 @@ #include #include #include -#include -#include #include #include -#include -#include /* Intel module adapter is an extension to SOF module adapter component that allows to integrate * modules developed under IADK (Intel Audio Development Kit) Framework. IADK modules uses uniform @@ -51,32 +47,6 @@ DECLARE_SOF_RT_UUID("modules", intel_uuid, 0xee2585f2, 0xe7d8, 0x43dc, 0x90, 0xab, 0x42, 0x24, 0xe0, 0x0c, 0x3e, 0x84); DECLARE_TR_CTX(intel_codec_tr, SOF_UUID(intel_uuid), LOG_LEVEL_INFO); -static int modules_new(struct processing_module *mod, uintptr_t module_entry_point) -{ - struct module_data *md = &mod->priv; - struct comp_dev *dev = mod->dev; - struct comp_driver *drv = (struct comp_driver *)dev->drv; - uint32_t module_id = IPC4_MOD_ID(dev->ipc_config.id); - uint32_t instance_id = IPC4_INST_ID(dev->ipc_config.id); - uint32_t log_handle = (uint32_t) dev->drv->tctx; - /* Connect loadable module interfaces with module adapter entity. */ - /* Check if native Zephyr lib is loaded */ - void *system_agent; - - byte_array_t mod_cfg = { - .data = (uint8_t *)md->cfg.init_data, - /* Intel modules expects DW size here */ - .size = md->cfg.size >> 2, - }; - - system_agent = system_agent_start(module_entry_point, module_id, instance_id, 0, log_handle, - &mod_cfg); - - module_set_private_data(mod, system_agent); - - return 0; -} - /** * \brief modules_init. * \param[in] mod - processing module pointer. @@ -90,11 +60,11 @@ static int modules_init(struct processing_module *mod) struct comp_dev *dev = mod->dev; const struct comp_driver *const drv = dev->drv; const struct ipc4_base_module_cfg *src_cfg = &md->cfg.base_cfg; - struct comp_ipc_config *config = &(dev->ipc_config); - /* At this point module resources are allocated and it is moved to L2 memory. */ + const struct comp_ipc_config *config = &(dev->ipc_config); + void *system_agent; - int ret; uintptr_t module_entry_point = lib_manager_allocate_module(mod, config, src_cfg); + /* At this point module resources are allocated and it is moved to L2 memory. */ if (module_entry_point == 0) { comp_err(dev, "modules_init(), lib_manager_allocate_module() failed!"); @@ -102,38 +72,26 @@ static int modules_init(struct processing_module *mod) } comp_info(dev, "modules_init() start"); - if (!module_get_private_data(mod) && - drv->adapter_ops == &processing_module_adapter_interface) { - /* First load */ - ret = modules_new(mod, module_entry_point); - if (ret < 0) - return ret; - } + const uint32_t module_id = IPC4_MOD_ID(config->id); + const uint32_t instance_id = IPC4_INST_ID(config->id); + const uint32_t log_handle = (uint32_t)drv->tctx; - md->mpd.in_buff_size = src_cfg->ibs; - md->mpd.out_buff_size = src_cfg->obs; + byte_array_t mod_cfg = { + .data = (uint8_t *)md->cfg.init_data, + /* Intel modules expects DW size here */ + .size = md->cfg.size >> 2, + }; - /* Call module specific init function if exists. */ - if (mod->is_native_sof) { - const struct module_interface *mod_in = drv->adapter_ops; + system_agent = system_agent_start(module_entry_point, module_id, instance_id, 0, log_handle, + &mod_cfg); - /* The order of preference */ - if (mod_in->process) - mod->proc_type = MODULE_PROCESS_TYPE_SOURCE_SINK; - else if (mod_in->process_audio_stream) - mod->proc_type = MODULE_PROCESS_TYPE_STREAM; - else if (mod_in->process_raw_data) - mod->proc_type = MODULE_PROCESS_TYPE_RAW; - else - return -EINVAL; + module_set_private_data(mod, system_agent); - ret = mod_in->init(mod); - } else { - mod->proc_type = MODULE_PROCESS_TYPE_SOURCE_SINK; - ret = iadk_wrapper_init(module_get_private_data(mod)); - } + md->mpd.in_buff_size = src_cfg->ibs; + md->mpd.out_buff_size = src_cfg->obs; - return ret; + mod->proc_type = MODULE_PROCESS_TYPE_SOURCE_SINK; + return iadk_wrapper_init(system_agent); } /** @@ -176,7 +134,6 @@ static int modules_process(struct processing_module *mod, static int modules_free(struct processing_module *mod) { struct comp_dev *dev = mod->dev; - struct module_data *md = &mod->priv; int ret; comp_info(dev, "modules_free()"); @@ -184,13 +141,10 @@ static int modules_free(struct processing_module *mod) if (ret) comp_err(dev, "modules_free(): iadk_wrapper_free failed with error: %d", ret); - - if (!md->llext || !llext_unload(&md->llext)) { - /* Free module resources allocated in L2 memory. */ - ret = lib_manager_free_module(dev->ipc_config.id); - if (ret < 0) - comp_err(dev, "modules_free(), lib_manager_free_module() failed!"); - } + /* Free module resources allocated in L2 memory. */ + ret = lib_manager_free_module(dev->ipc_config.id); + if (ret < 0) + comp_err(dev, "modules_free(), lib_manager_free_module() failed!"); return ret; }