Skip to content

Commit

Permalink
module: (cosmetic) regroup some declarations and assignments
Browse files Browse the repository at this point in the history
Regroup code in modules_init() to move declarations and assignments
closer to where they're needed.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
  • Loading branch information
lyakh committed Nov 2, 2023
1 parent bfe7b76 commit 8b8f7bd
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/audio/module_adapter/module/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,19 @@ static int modules_init(struct processing_module *mod)
int ret;

if (!md->module_adapter) {
byte_array_t mod_cfg;

mod_cfg.data = (uint8_t *)md->cfg.init_data;
/* Intel modules expects DW size here */
mod_cfg.size = md->cfg.size >> 2;
md->private = mod;

struct comp_ipc_config *config = &(mod->dev->ipc_config);

/* At this point module resources are allocated and it is moved to L2 memory. */
const void *buildinfo = NULL;
uint32_t module_entry_point = lib_manager_allocate_module(mod, config,
src_cfg, &buildinfo);

if (module_entry_point == 0) {
comp_err(dev, "modules_init(), lib_manager_allocate_module() failed!");
return -EINVAL;
}
md->module_entry_point = module_entry_point;

uint32_t module_id = IPC4_MOD_ID(config->id);
uint32_t instance_id = IPC4_INST_ID(config->id);
uint32_t log_handle = (uint32_t) mod->dev->drv->tctx;
/* Connect loadable module interfaces with module adapter entity. */
/* Check if native Zephyr lib is loaded */
struct sof_man_fw_desc *desc;
Expand All @@ -107,21 +98,29 @@ static int modules_init(struct processing_module *mod)
(module_entry->segment[SOF_MAN_SEGMENT_TEXT].v_base_addr);
}

uint32_t log_handle = (uint32_t)mod->dev->drv->tctx;
byte_array_t mod_cfg = {
.data = (uint8_t *)md->cfg.init_data,
/* Intel modules expects DW size here */
.size = md->cfg.size >> 2,
};
void *mod_adp;

/* Check if module is FDK */
if (mod_buildinfo->api_version_number.fields.major < SOF_MODULE_API_MAJOR_VERSION) {
mod_adp = system_agent_start(md->module_entry_point, module_id,
mod_adp = system_agent_start(module_entry_point, module_id,
instance_id, 0, log_handle, &mod_cfg);
} else {
/* If not start agent for sof loadable */
mod->is_native_sof = true;
mod_adp = native_system_agent_start(mod->sys_service, md->module_entry_point,
mod_adp = native_system_agent_start(mod->sys_service, module_entry_point,
module_id, instance_id, 0, log_handle,
&mod_cfg);
}

md->module_entry_point = module_entry_point;
md->module_adapter = mod_adp;
md->private = mod;
}

/* Allocate module buffers */
Expand Down

0 comments on commit 8b8f7bd

Please sign in to comment.