Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modules: Remove unused code and variables #8897

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/audio/module_adapter/library/native_system_agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ typedef void* (*native_create_instance_f)(void *mod_cfg, void *parent_ppl,

struct native_system_agent native_sys_agent;

void *native_system_agent_start(uint32_t *sys_service,
uint32_t entry_point, uint32_t module_id,
uint32_t instance_id, uint32_t core_id, uint32_t log_handle,
void *mod_cfg)
void *native_system_agent_start(uint32_t entry_point, uint32_t module_id, uint32_t instance_id,
uint32_t core_id, uint32_t log_handle, void *mod_cfg)
{
native_sys_agent.module_id = module_id;
native_sys_agent.instance_id = instance_id;
Expand Down
162 changes: 21 additions & 141 deletions src/audio/module_adapter/module/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static int modules_new(struct processing_module *mod, const void *buildinfo,
/* Connect loadable module interfaces with module adapter entity. */
/* Check if native Zephyr lib is loaded */
struct sof_man_fw_desc *desc = lib_manager_get_library_module_desc(module_id);
void *system_agent;

if (!desc) {
comp_err(dev, "modules_init(): Failed to load manifest");
Expand Down Expand Up @@ -91,23 +92,20 @@ static int modules_new(struct processing_module *mod, const void *buildinfo,
/* 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) {
md->module_adapter = (void *)system_agent_start(module_entry_point,
module_id, instance_id,
0, log_handle, &mod_cfg);
system_agent = system_agent_start(module_entry_point, module_id, instance_id, 0,
log_handle, &mod_cfg);

module_set_private_data(mod, system_agent);
} else if (mod_buildinfo->format == SOF_MODULE_API_BUILD_INFO_FORMAT &&
mod_buildinfo->api_version_number.full == SOF_MODULE_API_CURRENT_VERSION) {
/* The module is native: start agent for sof loadable */
mod->is_native_sof = true;
drv->adapter_ops = native_system_agent_start(mod->sys_service, module_entry_point,
module_id, instance_id,
0, log_handle, &mod_cfg);
drv->adapter_ops = native_system_agent_start(module_entry_point, module_id,
instance_id, 0, log_handle, &mod_cfg);
} else {
return -ENOEXEC;
}

md->module_entry_point = module_entry_point;
md->private = mod;

return 0;
}

Expand Down Expand Up @@ -137,27 +135,15 @@ static int modules_init(struct processing_module *mod)
}
comp_info(dev, "modules_init() start");

if (!md->module_adapter && drv->adapter_ops == &processing_module_adapter_interface) {
if (!module_get_private_data(mod) &&
drv->adapter_ops == &processing_module_adapter_interface) {
/* First load */
ret = modules_new(mod, buildinfo, module_entry_point);
if (ret < 0)
return ret;
}

/* Allocate module buffers */
md->mpd.in_buff = rballoc(0, SOF_MEM_CAPS_RAM, src_cfg->ibs);
if (!md->mpd.in_buff) {
comp_err(dev, "modules_init(): Failed to alloc in_buff");
return -ENOMEM;
}
md->mpd.in_buff_size = src_cfg->ibs;

md->mpd.out_buff = rballoc(0, SOF_MEM_CAPS_RAM, src_cfg->obs);
if (!md->mpd.out_buff) {
comp_err(dev, "modules_init(): Failed to alloc out_buff");
rfree(md->mpd.in_buff);
return -ENOMEM;
}
md->mpd.out_buff_size = src_cfg->obs;

/* Call module specific init function if exists. */
Expand All @@ -177,7 +163,7 @@ static int modules_init(struct processing_module *mod)
ret = mod_in->init(mod);
} else {
mod->proc_type = MODULE_PROCESS_TYPE_SOURCE_SINK;
ret = iadk_wrapper_init(md->module_adapter);
ret = iadk_wrapper_init(module_get_private_data(mod));
}

return ret;
Expand All @@ -199,90 +185,18 @@ static int modules_prepare(struct processing_module *mod,
struct sof_sink **sinks, int num_of_sinks)
{
struct comp_dev *dev = mod->dev;
const struct comp_driver *const drv = dev->drv;
int ret = 0;

comp_info(dev, "modules_prepare()");

/* Call module specific prepare function if exists. */
if (mod->is_native_sof) {
const struct module_interface *mod_in = drv->adapter_ops;

ret = mod_in->prepare(mod, sources, num_of_sources, sinks, num_of_sinks);
} else {
ret = iadk_wrapper_prepare(mod->priv.module_adapter);
}
return ret;
}

static int modules_init_process(struct processing_module *mod)
{
struct module_data *codec = &mod->priv;
struct comp_dev *dev = mod->dev;

comp_dbg(dev, "modules_init_process()");

codec->mpd.produced = 0;
codec->mpd.consumed = 0;
codec->mpd.init_done = 1;

return 0;
return iadk_wrapper_prepare(module_get_private_data(mod));
}

static int modules_process(struct processing_module *mod,
struct sof_source **sources, int num_of_sources,
struct sof_sink **sinks, int num_of_sinks)
{
if (!mod->is_native_sof)
return iadk_wrapper_process(mod->priv.module_adapter, sources,
num_of_sources, sinks, num_of_sinks);

const struct module_interface *const mod_in = mod->dev->drv->adapter_ops;

return mod_in->process(mod, sources, num_of_sources, sinks, num_of_sinks);
}

static int modules_process_audio_stream(struct processing_module *mod,
struct input_stream_buffer *input_buffers,
int num_input_buffers,
struct output_stream_buffer *output_buffers,
int num_output_buffers)
{
if (!mod->is_native_sof)
return -EOPNOTSUPP;

const struct module_interface *const mod_in = mod->dev->drv->adapter_ops;

return mod_in->process_audio_stream(mod, input_buffers, num_input_buffers,
output_buffers, num_output_buffers);
}

/*
* \brief modules_process_raw.
* \param[in] mod - processing module pointer.
*
* \return: zero on success
* error code on failure
*/
static int modules_process_raw(struct processing_module *mod,
struct input_stream_buffer *input_buffers,
int num_input_buffers,
struct output_stream_buffer *output_buffers,
int num_output_buffers)
{
struct module_data *md = &mod->priv;

if (!mod->is_native_sof)
return -EOPNOTSUPP;

if (!md->mpd.init_done)
modules_init_process(mod);

/* Call module specific process function. */
const struct module_interface *const mod_in = mod->dev->drv->adapter_ops;

return mod_in->process_raw_data(mod, input_buffers, num_input_buffers,
output_buffers, num_output_buffers);
return iadk_wrapper_process(module_get_private_data(mod), sources,
num_of_sources, sinks, num_of_sinks);
}

/**
Expand All @@ -296,23 +210,13 @@ static int modules_free(struct processing_module *mod)
{
struct comp_dev *dev = mod->dev;
struct module_data *md = &mod->priv;
const struct comp_driver *const drv = dev->drv;
int ret;

comp_info(dev, "modules_free()");
if (mod->is_native_sof) {
const struct module_interface *mod_in = drv->adapter_ops;
ret = iadk_wrapper_free(module_get_private_data(mod));
if (ret)
comp_err(dev, "modules_free(): iadk_wrapper_free failed with error: %d", ret);

ret = mod_in->free(mod);
} else {
ret = iadk_wrapper_free(mod->priv.module_adapter);
}

if (ret < 0)
comp_err(dev, "Failed to free a module: %d", ret);

rfree(md->mpd.in_buff);
rfree(md->mpd.out_buff);

if (!md->llext || !llext_unload(&md->llext)) {
/* Free module resources allocated in L2 memory. */
Expand Down Expand Up @@ -345,13 +249,7 @@ static int modules_set_configuration(struct processing_module *mod, uint32_t con
size_t fragment_size, uint8_t *response,
size_t response_size)
{
if (mod->is_native_sof) {
const struct module_interface *const mod_in = mod->dev->drv->adapter_ops;

return mod_in->set_configuration(mod, config_id, pos, data_offset_size, fragment,
fragment_size, response, response_size);
}
return iadk_wrapper_set_configuration(mod->priv.module_adapter, config_id, pos,
return iadk_wrapper_set_configuration(module_get_private_data(mod), config_id, pos,
data_offset_size, fragment, fragment_size,
response, response_size);
}
Expand All @@ -372,13 +270,7 @@ static int modules_get_configuration(struct processing_module *mod, uint32_t con
uint32_t *data_offset_size, uint8_t *fragment,
size_t fragment_size)
{
if (mod->is_native_sof) {
const struct module_interface *const mod_in = mod->dev->drv->adapter_ops;

return mod_in->get_configuration(mod, config_id, data_offset_size,
fragment, fragment_size);
}
return iadk_wrapper_get_configuration(mod->priv.module_adapter, config_id,
return iadk_wrapper_get_configuration(module_get_private_data(mod), config_id,
MODULE_CFG_FRAGMENT_SINGLE, *data_offset_size,
fragment, fragment_size);
}
Expand All @@ -393,12 +285,7 @@ static int modules_get_configuration(struct processing_module *mod, uint32_t con
static int modules_set_processing_mode(struct processing_module *mod,
enum module_processing_mode mode)
{
if (mod->is_native_sof) {
const struct module_interface *const mod_in = mod->dev->drv->adapter_ops;

return mod_in->set_processing_mode(mod, mode);
}
return iadk_wrapper_set_processing_mode(mod->priv.module_adapter, mode);
return iadk_wrapper_set_processing_mode(module_get_private_data(mod), mode);
}

/**
Expand All @@ -409,7 +296,7 @@ static int modules_set_processing_mode(struct processing_module *mod,
*/
static enum module_processing_mode modules_get_processing_mode(struct processing_module *mod)
{
return iadk_wrapper_get_processing_mode(mod->priv.module_adapter);
return iadk_wrapper_get_processing_mode(module_get_private_data(mod));
}

/**
Expand All @@ -421,21 +308,14 @@ static enum module_processing_mode modules_get_processing_mode(struct processing
*/
static int modules_reset(struct processing_module *mod)
{
if (mod->is_native_sof) {
const struct module_interface *const mod_in = mod->dev->drv->adapter_ops;

return mod_in->reset(mod);
}
return iadk_wrapper_reset(mod->priv.module_adapter);
return iadk_wrapper_reset(module_get_private_data(mod));
}

/* Processing Module Adapter API*/
const struct module_interface processing_module_adapter_interface = {
.init = modules_init,
.prepare = modules_prepare,
.process_raw_data = modules_process_raw,
.process = modules_process,
.process_audio_stream = modules_process_audio_stream,
.set_processing_mode = modules_set_processing_mode,
.get_processing_mode = modules_get_processing_mode,
.set_configuration = modules_set_configuration,
Expand Down
5 changes: 0 additions & 5 deletions src/include/module/module/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ struct module_data {
void *runtime_params;
struct module_memory memory; /**< memory allocated by module */
struct module_processing_data mpd; /**< shared data comp <-> module */
void *module_adapter; /**<loadable module interface handle */
uintptr_t module_entry_point; /**<loadable module entry point address */
struct llext *llext; /**< Zephyr loadable extension context */
#endif /* SOF_MODULE_PRIVATE */
};
Expand Down Expand Up @@ -184,9 +182,6 @@ struct processing_module {
/* flag to insure that module is loadable */
bool is_native_sof;

/* pointer to system services for loadable modules */
uint32_t *sys_service;

/* total processed data after stream started */
uint64_t total_data_consumed;
uint64_t total_data_produced;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ struct native_system_agent {
uint32_t module_size;
};

void *native_system_agent_start(uint32_t *sys_service,
uint32_t entry_point, uint32_t module_id, uint32_t instance_id,
void *native_system_agent_start(uint32_t entry_point, uint32_t module_id, uint32_t instance_id,
uint32_t core_id, uint32_t log_handle, void *mod_cfg);

#endif /* __NATIVE_SYSTEM_AGENT_H__ */
Loading