Skip to content

Commit b570b80

Browse files
jxstelterlgirdwood
authored andcommitted
module adapter: pass config size to module for ipc4
IPC4 SOF_IPC4_MOD_INIT_INSTANCE provides size of the configuration blob for the module. This size should be passed down to module adapter and forwarded to module. There are several reasons for using it: - consistency with IPC3 flow; - need for passing the size to IADK loadable modules; - possibility to graceful failure in case of configuration inconsistency. Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
1 parent 5135e7e commit b570b80

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/audio/module_adapter/module_adapter.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,15 @@ struct comp_dev *module_adapter_new(const struct comp_driver *drv,
102102
struct module_data *md = &mod->priv;
103103
struct module_config *dst = &md->cfg;
104104

105-
dst->data = spec;
105+
if (drv->type == SOF_COMP_MODULE_ADAPTER) {
106+
struct ipc_config_process *ipc_module_adapter = spec;
107+
108+
dst->data = ipc_module_adapter->data;
109+
dst->size = ipc_module_adapter->size;
110+
} else {
111+
dst->data = spec;
112+
}
113+
106114
#endif
107115

108116
/* Init processing module */

src/ipc/ipc4/handler.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ static int ipc4_init_module_instance(struct ipc4_message_request *ipc4)
608608
comp.id = IPC4_COMP_ID(module.primary.r.module_id, module.primary.r.instance_id);
609609
comp.pipeline_id = module.extension.r.ppl_instance_id;
610610
comp.core = module.extension.r.core_id;
611+
comp.ext_data_length = module.extension.r.param_block_size;
611612
dev = comp_new(&comp);
612613
if (!dev) {
613614
tr_err(&ipc_tr, "error: failed to init module %x : %x",

src/ipc/ipc4/helper.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct comp_dev *comp_new(struct sof_ipc_comp *comp)
6969
struct comp_ipc_config ipc_config;
7070
const struct comp_driver *drv;
7171
struct comp_dev *dev;
72+
struct ipc_config_process spec;
7273

7374
drv = ipc4_get_comp_drv(IPC4_MOD_ID(comp->id));
7475
if (!drv)
@@ -92,7 +93,14 @@ struct comp_dev *comp_new(struct sof_ipc_comp *comp)
9293
dcache_invalidate_region((__sparse_force void __sparse_cache *)(MAILBOX_HOSTBOX_BASE),
9394
MAILBOX_HOSTBOX_SIZE);
9495

95-
dev = drv->ops.create(drv, &ipc_config, (void *)MAILBOX_HOSTBOX_BASE);
96+
if (drv->type == SOF_COMP_MODULE_ADAPTER) {
97+
spec.data = (unsigned char *)MAILBOX_HOSTBOX_BASE;
98+
/* spec_size in IPC4 is in DW. Convert to bytes. */
99+
spec.size = comp->ext_data_length * 4;
100+
dev = drv->ops.create(drv, &ipc_config, (void *)&spec);
101+
} else {
102+
dev = drv->ops.create(drv, &ipc_config, (void *)MAILBOX_HOSTBOX_BASE);
103+
}
96104
if (!dev)
97105
return NULL;
98106

0 commit comments

Comments
 (0)