Skip to content
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
14 changes: 14 additions & 0 deletions src/audio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/audio/module_adapter/module/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions src/audio/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/include/module/module/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions src/include/sof/audio/module_adapter/module/cadence.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Copy link

Copilot AI Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API_CALL macro is now defined here and was removed from generic.h, but duplicating it in multiple module headers can lead to drift. Consider moving this macro to a common header (e.g., module_api.h) to keep definitions centralized.

Copilot uses AI. Check for mistakes.
do { \
ret = (cd)->api((cd)->self, \
(cmd), \
(sub_cmd), \
(value)); \
} while (0)

/*****************************************************************************/
/* Cadence private data types */
/*****************************************************************************/
Expand Down
33 changes: 16 additions & 17 deletions src/include/sof/audio/module_adapter/module/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down Expand Up @@ -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. */
};

/**
Expand All @@ -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.*/
};

/**
Expand Down
Loading