diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 9c56beddb319..1cc6cf83816c 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -1333,6 +1333,10 @@ int module_adapter_reset(struct comp_dev *dev) rfree(mod->stream_params); mod->stream_params = NULL; +#if CONFIG_IPC_MAJOR_4 + rfree(mod->priv.cfg.input_pins); +#endif + comp_dbg(dev, "module_adapter_reset(): done"); return comp_set_state(dev, COMP_TRIGGER_RESET); diff --git a/src/audio/module_adapter/module_adapter_ipc4.c b/src/audio/module_adapter/module_adapter_ipc4.c index 1e0257b0a1cb..81f7fca1d22d 100644 --- a/src/audio/module_adapter/module_adapter_ipc4.c +++ b/src/audio/module_adapter/module_adapter_ipc4.c @@ -38,19 +38,39 @@ int module_adapter_init_data(struct comp_dev *dev, const struct comp_ipc_config *config, const void *spec) { - if (dev->drv->type == SOF_COMP_MODULE_ADAPTER) { - const struct ipc_config_process *ipc_module_adapter = spec; + const struct ipc_config_process *cp = spec; + const struct ipc4_base_module_extended_cfg *cfg = (void *)cp->data; + size_t cfgsz = cp->size; - dst->init_data = ipc_module_adapter->data; - dst->size = ipc_module_adapter->size; - dst->avail = true; + assert(dev->drv->type == SOF_COMP_MODULE_ADAPTER); + if (cp->size < sizeof(cfg->base_cfg)) + return -EINVAL; - memcpy_s(&dst->base_cfg, sizeof(dst->base_cfg), ipc_module_adapter->data, - sizeof(dst->base_cfg)); - } else { - dst->init_data = spec; + dst->base_cfg = cfg->base_cfg; + dst->size = cp->size; + + if (cp->size >= sizeof(*cfg)) { + int ni = cfg->base_cfg_ext.nb_input_pins; + int no = cfg->base_cfg_ext.nb_output_pins; + size_t pinsz = (ni * sizeof(*dst->input_pins)) + + (no * sizeof(*dst->output_pins)); + + if (cp->size == (sizeof(*cfg) + pinsz)) { + dst->nb_input_pins = ni; + dst->nb_output_pins = no; + dst->input_pins = rmalloc(SOF_MEM_ZONE_RUNTIME_SHARED, + 0, SOF_MEM_CAPS_RAM, pinsz); + if (!dst->input_pins) + return -ENOMEM; + + dst->output_pins = (void *) &dst->input_pins[ni]; + memcpy_s(dst->input_pins, pinsz, + &cfg->base_cfg_ext.pin_formats[0], pinsz); + } } + dst->init_data = cp->data; /* legacy API */ + dst->avail = true; return 0; } diff --git a/src/include/module/module/base.h b/src/include/module/module/base.h index 904b83741961..323599b055f2 100644 --- a/src/include/module/module/base.h +++ b/src/include/module/module/base.h @@ -30,6 +30,10 @@ struct module_config { const void *init_data; /**< Initial IPC configuration. */ #if CONFIG_IPC_MAJOR_4 struct ipc4_base_module_cfg base_cfg; + uint8_t nb_input_pins; + uint8_t nb_output_pins; + struct ipc4_input_pin_format *input_pins; + struct ipc4_output_pin_format *output_pins; #endif };