Skip to content

Commit

Permalink
loading module: fix native module interface register
Browse files Browse the repository at this point in the history
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 <pawelx.dobrowolski@intel.com>
  • Loading branch information
pjdobrowolski authored and mwasko committed Jan 24, 2024
1 parent 10f0e38 commit a082752
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions src/audio/module_adapter/module/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit a082752

Please sign in to comment.