Skip to content

Commit

Permalink
fix: some code does not care for non-module adapter components
Browse files Browse the repository at this point in the history
Legacy API that is not using module_adapter is now depreciated,
but there are still some modules that use it. So all common code
must work properly with both types of modules.
This commit is fixing crash in bind operation when binding
a legacy module. There also some comments added in potentially
similar places, but where legacy modules cannot be used.

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
  • Loading branch information
marcinszkudlinski authored and kv2019i committed Jun 18, 2024
1 parent 79c7db1 commit 5f5fdb6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/audio/module_adapter/module/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ int module_load_config(struct comp_dev *dev, const void *cfg, size_t size)
{
int ret;
struct module_config *dst;
/* loadable module must use module adapter */
struct processing_module *mod = comp_mod(dev);
struct module_data *md = &mod->priv;

Expand Down
1 change: 1 addition & 0 deletions src/audio/pipeline/pipeline-schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ static enum task_state dp_task_run(void *data)
int pipeline_comp_dp_task_init(struct comp_dev *comp)
{
int ret;
/* DP tasks are guaranteed to have a module_adapter */
struct processing_module *mod = comp_mod(comp);
struct task_ops ops = {
.run = dp_task_run,
Expand Down
4 changes: 3 additions & 1 deletion src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,9 @@ struct comp_dev {

const struct comp_driver *drv; /**< driver */

struct processing_module *mod; /**< self->mod->dev == self, always */
struct processing_module *mod; /**< self->mod->dev == self, NULL if component is not using
* module adapter
*/

/* lists */
struct list_item bsource_list; /**< list of source buffers */
Expand Down
31 changes: 16 additions & 15 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect)
if (!cpu_is_me(source->ipc_config.core) && !cross_core_bind)
return ipc4_process_on_core(source->ipc_config.core, false);

struct processing_module *srcmod = comp_mod(source);
struct processing_module *dstmod = comp_mod(sink);
struct module_config *dstcfg = &dstmod->priv.cfg;
struct module_config *srccfg = &srcmod->priv.cfg;
if (source->drv->type == SOF_COMP_MODULE_ADAPTER) {
struct processing_module *srcmod = comp_mod(source);
struct module_config *srccfg = &srcmod->priv.cfg;

/* get obs from the base config extension if the src queue ID is non-zero */
if (bu->extension.r.src_queue && bu->extension.r.src_queue < srccfg->nb_output_pins)
obs = srccfg->output_pins[bu->extension.r.src_queue].obs;
/* get obs from the base config extension if the src queue ID is non-zero */
if (bu->extension.r.src_queue && bu->extension.r.src_queue < srccfg->nb_output_pins)
obs = srccfg->output_pins[bu->extension.r.src_queue].obs;
}

/* get obs from base config if src queue ID is 0 or if base config extn is missing */
if (!obs) {
Expand All @@ -490,10 +490,14 @@ int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect)
obs = source_src_cfg.obs;
}

/* get ibs from the base config extension if the sink queue ID is non-zero */
if (bu->extension.r.dst_queue && bu->extension.r.dst_queue < dstcfg->nb_input_pins)
ibs = dstcfg->input_pins[bu->extension.r.dst_queue].ibs;
if (sink->drv->type == SOF_COMP_MODULE_ADAPTER) {
struct processing_module *dstmod = comp_mod(sink);
struct module_config *dstcfg = &dstmod->priv.cfg;

/* get ibs from the base config extension if the sink queue ID is non-zero */
if (bu->extension.r.dst_queue && bu->extension.r.dst_queue < dstcfg->nb_input_pins)
ibs = dstcfg->input_pins[bu->extension.r.dst_queue].ibs;
}
/* get ibs from base config if sink queue ID is 0 or if base config extn is missing */
if (!ibs) {
ret = comp_get_attribute(sink, COMP_ATTR_BASE_CONFIG, &sink_src_cfg);
Expand Down Expand Up @@ -538,13 +542,10 @@ int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect)
source_set_min_available(audio_stream_get_source(&buffer->stream), ibs);

#if CONFIG_ZEPHYR_DP_SCHEDULER
/* mod->dev may be null in case of a module not using module adapter */
if (dstmod->dev &&
dstmod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP)
if (sink->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP)
/* data destination module needs to use dp_queue */
buffer_create_shadow_dp_queue(buffer, false /* at_input = false */);
else if (srcmod->dev &&
srcmod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP)
else if (source->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP)
/* data source module needs to use dp_queue */
buffer_create_shadow_dp_queue(buffer, true /* at_input = true */);
#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */
Expand Down

0 comments on commit 5f5fdb6

Please sign in to comment.