diff --git a/src/audio/Kconfig b/src/audio/Kconfig index 46e44c3b5236..62dc9938b92b 100644 --- a/src/audio/Kconfig +++ b/src/audio/Kconfig @@ -72,6 +72,13 @@ config IPC4_GATEWAY host and DSP without using DMA: via memory window (audio payload) and IPC4 messages (set/get/flush commands). +config MODULE_MAX_CONNECTIONS + int "Module maximum number of connected sink/source modules" + default 8 + help + Specifies the maximum number of sink and source connections a module + may have to other modules. + rsource "up_down_mixer/Kconfig" config COMP_BLOB @@ -82,6 +89,13 @@ config COMP_BLOB multiple IPC messages. Not all components or modules need this. If unsure, say yes. +config MODULE_MAX_BLOB_SIZE + int "Maximum IPC blob size in bytes" + default 8192 + help + Specify the maximum size of IPC4 module blob data that can be + appended to each message. + rsource "src/Kconfig" config COMP_STUBS diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index 1e806a1d4915..9e2974acec39 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -437,9 +437,9 @@ int module_set_configuration(struct processing_module *mod, if (!md->new_cfg_size) return 0; - if (md->new_cfg_size > MAX_BLOB_SIZE) { + if (md->new_cfg_size > CONFIG_MODULE_MAX_BLOB_SIZE) { comp_err(dev, "module_set_configuration(): error: blob size is too big cfg size %zu, allowed %d", - md->new_cfg_size, MAX_BLOB_SIZE); + md->new_cfg_size, CONFIG_MODULE_MAX_BLOB_SIZE); return -EINVAL; } diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 7311bbcf87e9..30926bfe02cf 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -272,6 +272,12 @@ int module_adapter_prepare(struct comp_dev *dev) comp_err(dev, "module_adapter_prepare(): no source and sink buffers connected!"); return -EINVAL; } + if (mod->num_of_sources > CONFIG_MODULE_MAX_CONNECTIONS || + mod->num_of_sinks > CONFIG_MODULE_MAX_CONNECTIONS) { + comp_err(dev, "module_adapter_prepare(): too many connected sinks %d or sources %d!", + mod->num_of_sinks, mod->num_of_sources); + return -EINVAL; + } /* check processing mode */ if (IS_PROCESSING_MODE_AUDIO_STREAM(mod) && mod->max_sources > 1 && mod->max_sinks > 1) { diff --git a/src/include/module/module/base.h b/src/include/module/module/base.h index f4da3252f4e3..5be7a5e2ef91 100644 --- a/src/include/module/module/base.h +++ b/src/include/module/module/base.h @@ -101,8 +101,8 @@ struct processing_module { uint32_t num_of_sinks; /* sink and source handlers for the module */ - struct sof_sink *sinks[MODULE_MAX_SOURCES]; - struct sof_source *sources[MODULE_MAX_SOURCES]; + struct sof_sink *sinks[CONFIG_MODULE_MAX_CONNECTIONS]; + struct sof_source *sources[CONFIG_MODULE_MAX_CONNECTIONS]; /* this is used in case of raw data or audio_stream mode * number of buffers described by fields: diff --git a/src/include/sof/audio/module_adapter/module/cadence.h b/src/include/sof/audio/module_adapter/module/cadence.h index 954594f80aa3..a4ad3d9482f8 100644 --- a/src/include/sof/audio/module_adapter/module/cadence.h +++ b/src/include/sof/audio/module_adapter/module/cadence.h @@ -32,6 +32,14 @@ extern xa_codec_func_t xa_sbc_dec; extern xa_codec_func_t xa_vorbis_dec; extern xa_codec_func_t xa_src_pp; +#define API_CALL(cd, cmd, sub_cmd, value, ret) \ + do { \ + ret = (cd)->api((cd)->self, \ + (cmd), \ + (sub_cmd), \ + (value)); \ + } while (0) + /*****************************************************************************/ /* Cadence private data types */ /*****************************************************************************/ diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index fb7f4ca02202..bff6aa420629 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -27,23 +27,22 @@ #define IS_PROCESSING_MODE_RAW_DATA(mod) ((mod)->proc_type == MODULE_PROCESS_TYPE_RAW) #define IS_PROCESSING_MODE_SINK_SOURCE(mod) ((mod)->proc_type == MODULE_PROCESS_TYPE_SOURCE_SINK) -#define MAX_BLOB_SIZE 8192 -#define MODULE_MAX_SOURCES 8 - -#define API_CALL(cd, cmd, sub_cmd, value, ret) \ - do { \ - ret = (cd)->api((cd)->self, \ - (cmd), \ - (sub_cmd), \ - (value)); \ - } while (0) - #if CONFIG_IPC_MAJOR_4 #define IPC_MOD_CMD(v) #elif CONFIG_IPC_MAJOR_3 #define IPC_MOD_CMD(v) .cmd = v, #endif +/* + * \brief Macro to declare a module adapter component. + * \param adapter - name of the module. + * \param uuid - UUID of the module. + * \param tr - trace context for the module. + * + * This macro declares a module component with the specified name, UUID, and trace context. + * It initializes the component module structure with the appropriate type, UID, and + * struct module_interface operations. + */ #define DECLARE_MODULE_ADAPTER(adapter, uuid, tr) \ static const struct comp_driver comp_##adapter##_module = { \ .type = SOF_COMP_MODULE_ADAPTER, \ @@ -92,10 +91,10 @@ DECLARE_MODULE(sys_comp_module_##adapter##_init) * \brief Module-specific states */ enum module_state { - MODULE_DISABLED, /**< Module isn't initialized yet or has been freed.*/ - MODULE_INITIALIZED, /**< Module initialized or reset. */ - MODULE_IDLE, /**< Module is idle now. */ - MODULE_PROCESSING, /**< Module is processing samples now. */ + MODULE_DISABLED, /**< Module isn't initialized yet or has been freed.*/ + MODULE_INITIALIZED, /**< Module initialized or reset. */ + MODULE_IDLE, /**< Module is idle now. */ + MODULE_PROCESSING, /**< Module is processing samples now. */ }; /** @@ -112,8 +111,8 @@ struct module_param { * sample_rate may have an id of 0x01. */ uint32_t id; - uint32_t size; /**< The size of whole parameter - id + size + data */ - int32_t data[]; /**< A pointer to memory where config is stored.*/ + uint32_t size; /**< The size of whole parameter - id + size + data */ + int32_t data[]; /**< A pointer to memory where config is stored.*/ }; /**