From a0827526b7e1e4c88060812245a8cb9c381d5745 Mon Sep 17 00:00:00 2001 From: "Dobrowolski, PawelX" Date: Wed, 17 Jan 2024 11:47:29 +0100 Subject: [PATCH] loading module: fix native module interface register In SOF we have a two type loadable modules, IADK and native whose are sharing the same registering mechanism but for C++/C needs IADK is using adapter which translates methods for SOF needs. Native loadable module is not using any additional adapters and returns pointer for API used in built-in modules and loadable. Signed-off-by: Dobrowolski, PawelX --- src/audio/module_adapter/module/modules.c | 39 ++++++++--------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/src/audio/module_adapter/module/modules.c b/src/audio/module_adapter/module/modules.c index e9014a2d28e7..d41a33759690 100644 --- a/src/audio/module_adapter/module/modules.c +++ b/src/audio/module_adapter/module/modules.c @@ -99,27 +99,24 @@ static int modules_init(struct processing_module *mod) (struct sof_module_api_build_info *) (module_entry->segment[SOF_MAN_SEGMENT_TEXT].v_base_addr); - void *mod_adp; - /* Check if module is FDK */ if (mod_buildinfo->format == IADK_MODULE_API_BUILD_INFO_FORMAT && mod_buildinfo->api_version_number.full == IADK_MODULE_API_CURRENT_VERSION) { - mod_adp = system_agent_start(md->module_entry_point, module_id, - instance_id, 0, log_handle, &mod_cfg); + md->module_adapter = (void *)system_agent_start(md->module_entry_point, module_id, + instance_id, 0, log_handle, + &mod_cfg); } else /* Check if module is native */ if (mod_buildinfo->format == SOF_MODULE_API_BUILD_INFO_FORMAT && mod_buildinfo->api_version_number.full == SOF_MODULE_API_CURRENT_VERSION) { /* If start agent for sof loadable */ mod->is_native_sof = true; - mod_adp = native_system_agent_start(mod->sys_service, md->module_entry_point, + md->ops = native_system_agent_start(mod->sys_service, md->module_entry_point, module_id, instance_id, 0, log_handle, &mod_cfg); } else return -ENOEXEC; - md->module_adapter = mod_adp; - /* Allocate module buffers */ md->mpd.in_buff = rballoc(0, SOF_MEM_CAPS_RAM, src_cfg->ibs); if (!md->mpd.in_buff) { @@ -140,8 +137,7 @@ static int modules_init(struct processing_module *mod) /* Call module specific init function if exists. */ if (mod->is_native_sof) { - struct module_interface *mod_in = - (struct module_interface *)md->module_adapter; + const struct module_interface *mod_in = md->ops; /* The order of preference */ if (mod_in->process) @@ -184,8 +180,7 @@ static int modules_prepare(struct processing_module *mod, /* Call module specific prepare function if exists. */ if (mod->is_native_sof) { - struct module_interface *mod_in = - (struct module_interface *)mod->priv.module_adapter; + const struct module_interface *mod_in = mod->priv.ops; ret = mod_in->prepare(mod, sources, num_of_sources, sinks, num_of_sinks); } else { @@ -216,7 +211,7 @@ static int modules_process(struct processing_module *mod, return iadk_wrapper_process(mod->priv.module_adapter, sources, num_of_sources, sinks, num_of_sinks); - struct module_interface *mod_in = (struct module_interface *)mod->priv.module_adapter; + const struct module_interface *mod_in = mod->priv.ops; return mod_in->process(mod, sources, num_of_sources, sinks, num_of_sinks); } @@ -230,7 +225,7 @@ static int modules_process_audio_stream(struct processing_module *mod, if (!mod->is_native_sof) return -EOPNOTSUPP; - struct module_interface *mod_in = (struct module_interface *)mod->priv.module_adapter; + const struct module_interface *mod_in = mod->priv.ops; return mod_in->process_audio_stream(mod, input_buffers, num_input_buffers, output_buffers, num_output_buffers); @@ -258,8 +253,7 @@ static int modules_process_raw(struct processing_module *mod, modules_init_process(mod); /* Call module specific process function. */ - struct module_interface *mod_in = - (struct module_interface *)mod->priv.module_adapter; + const struct module_interface *mod_in = mod->priv.ops; return mod_in->process_raw_data(mod, input_buffers, num_input_buffers, output_buffers, num_output_buffers); @@ -281,8 +275,7 @@ static int modules_free(struct processing_module *mod) comp_info(dev, "modules_free()"); if (mod->is_native_sof) { - struct module_interface *mod_in = - (struct module_interface *)mod->priv.module_adapter; + const struct module_interface *mod_in = mod->priv.ops; ret = mod_in->free(mod); } else { @@ -321,8 +314,7 @@ static int modules_set_configuration(struct processing_module *mod, uint32_t con size_t response_size) { if (mod->is_native_sof) { - struct module_interface *mod_in = - (struct module_interface *)mod->priv.module_adapter; + const struct module_interface *mod_in = mod->priv.ops; return mod_in->set_configuration(mod, config_id, pos, data_offset_size, fragment, fragment_size, response, response_size); @@ -349,8 +341,7 @@ static int modules_get_configuration(struct processing_module *mod, uint32_t con size_t fragment_size) { if (mod->is_native_sof) { - struct module_interface *mod_in = - (struct module_interface *)mod->priv.module_adapter; + const struct module_interface *mod_in = mod->priv.ops; return mod_in->get_configuration(mod, config_id, data_offset_size, fragment, fragment_size); @@ -371,8 +362,7 @@ static int modules_set_processing_mode(struct processing_module *mod, enum module_processing_mode mode) { if (mod->is_native_sof) { - struct module_interface *mod_in = - (struct module_interface *)mod->priv.module_adapter; + const struct module_interface *mod_in = mod->priv.ops; return mod_in->set_processing_mode(mod, mode); } @@ -400,8 +390,7 @@ static enum module_processing_mode modules_get_processing_mode(struct processing static int modules_reset(struct processing_module *mod) { if (mod->is_native_sof) { - struct module_interface *mod_in = - (struct module_interface *)mod->priv.module_adapter; + const struct module_interface *mod_in = mod->priv.ops; return mod_in->reset(mod); }