From 38c831de8baff1562f81242a48115e913e41fe04 Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Fri, 16 Oct 2026 17:31:28 +0200 Subject: [PATCH 1/4] audio: crossover: drop comp_buffer from prepare and params Convert prepare, the sink assignment and the IPC4 params helper to the sink/source API and drop their struct comp_buffer uses. Signed-off-by: Adrian Warecki --- src/audio/crossover/crossover.c | 28 +++++++++++++--------------- src/audio/crossover/crossover.h | 3 ++- src/audio/crossover/crossover_ipc3.c | 3 ++- src/audio/crossover/crossover_ipc4.c | 14 ++++++-------- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/audio/crossover/crossover.c b/src/audio/crossover/crossover.c index 2f696800db66..e0d101cd7470 100644 --- a/src/audio/crossover/crossover.c +++ b/src/audio/crossover/crossover.c @@ -109,7 +109,7 @@ static unsigned int crossover_assign_sinks(struct processing_module *mod, unsigned int sink_id, state; sink_id = crossover_get_sink_id(cd, sink_get_pipeline_id(snk), j); - state = comp_buffer_get_sink_state(comp_buffer_get_from_sink(snk)); + state = sink_get_state(snk); if (state != dev->state) continue; @@ -558,38 +558,36 @@ static int crossover_prepare(struct processing_module *mod, { struct comp_data *cd = module_get_private_data(mod); struct comp_dev *dev = mod->dev; - struct comp_buffer *source, *sink; size_t data_size; - int channels; - int ret; + unsigned int channels; + int i, ret; comp_info(dev, "entry"); - source = comp_dev_get_first_data_producer(dev); - if (!source) { - comp_err(dev, "no source buffer"); + if (num_of_sources != 1) { + comp_err(dev, "expected 1 source, got %d", num_of_sources); return -ENOTCONN; } - crossover_params(mod); + crossover_params(mod, sources[0], sinks, num_of_sinks); /* Crossover has a variable number of sinks */ mod->max_sinks = SOF_CROSSOVER_MAX_STREAMS; /* Get source data format */ - cd->source_format = audio_stream_get_frm_fmt(&source->stream); - channels = audio_stream_get_channels(&source->stream); + cd->source_format = source_get_frm_fmt(sources[0]); + channels = source_get_channels(sources[0]); - /* Validate frame format and buffer size of sinks */ - comp_dev_for_each_consumer(dev, sink) { - if (cd->source_format != audio_stream_get_frm_fmt(&sink->stream)) { + /* Validate frame format of sinks */ + for (i = 0; i < num_of_sinks; i++) { + if (cd->source_format != sink_get_frm_fmt(sinks[i])) { comp_err(dev, "Source fmt %d and sink fmt %d are different.", - cd->source_format, audio_stream_get_frm_fmt(&sink->stream)); + cd->source_format, sink_get_frm_fmt(sinks[i])); return -EINVAL; } } - comp_info(dev, "source_format=%d, sink_formats=%d, nch=%d", + comp_info(dev, "source_format=%d, sink_formats=%d, nch=%u", cd->source_format, cd->source_format, channels); cd->config = comp_get_data_blob(cd->model_handler, &data_size, NULL); diff --git a/src/audio/crossover/crossover.h b/src/audio/crossover/crossover.h index 068364b2b037..fbd3e5fce33b 100644 --- a/src/audio/crossover/crossover.h +++ b/src/audio/crossover/crossover.h @@ -140,7 +140,8 @@ int crossover_output_pin_init(struct processing_module *mod); int crossover_check_sink_assign(struct processing_module *mod, struct sof_crossover_config *config); int crossover_check_config(struct processing_module *mod, const uint8_t *fragment); -void crossover_params(struct processing_module *mod); +void crossover_params(struct processing_module *mod, struct sof_source *source, + struct sof_sink **sinks, int num_of_sinks); int crossover_get_stream_index(struct processing_module *mod, struct sof_crossover_config *config, uint32_t pipe_id); diff --git a/src/audio/crossover/crossover_ipc3.c b/src/audio/crossover/crossover_ipc3.c index 48f56ac3cced..8886608b7499 100644 --- a/src/audio/crossover/crossover_ipc3.c +++ b/src/audio/crossover/crossover_ipc3.c @@ -84,6 +84,7 @@ int crossover_check_config(struct processing_module *mod, const uint8_t *fragmen /** * \brief IPC4 specific component prepare, updates source and sink buffers formats from base_cfg */ -void crossover_params(struct processing_module *mod) +void crossover_params(struct processing_module *mod, struct sof_source *source, + struct sof_sink **sinks, int num_of_sinks) { } diff --git a/src/audio/crossover/crossover_ipc4.c b/src/audio/crossover/crossover_ipc4.c index 3e0beffeeeb1..3f78efae4c01 100644 --- a/src/audio/crossover/crossover_ipc4.c +++ b/src/audio/crossover/crossover_ipc4.c @@ -107,22 +107,20 @@ int crossover_check_config(struct processing_module *mod, const uint8_t *fragmen /** * \brief IPC4 specific component prepare, updates source and sink buffers formats from base_cfg */ -void crossover_params(struct processing_module *mod) +void crossover_params(struct processing_module *mod, struct sof_source *source, + struct sof_sink **sinks, int num_of_sinks) { struct sof_ipc_stream_params *params = mod->stream_params; - struct comp_buffer *sinkb, *sourceb; struct comp_dev *dev = mod->dev; + int i; comp_dbg(dev, "entry"); ipc4_base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params); component_set_nearest_period_frames(dev, params->rate); - /* First producer verified by the caller */ - sourceb = comp_dev_get_first_data_producer(dev); - ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt); + ipc4_update_source_format(source, &mod->priv.cfg.base_cfg.audio_fmt); - comp_dev_for_each_consumer(dev, sinkb) { - ipc4_update_buffer_format(sinkb, &mod->priv.cfg.base_cfg.audio_fmt); - } + for (i = 0; i < num_of_sinks; i++) + ipc4_update_sink_format(sinks[i], &mod->priv.cfg.base_cfg.audio_fmt); } From a42166e3266d6ba088cf982d7c429282390e41eb Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Fri, 16 Oct 2026 17:36:23 +0200 Subject: [PATCH 2/4] audio: crossover: use unsigned int for channel counts Change the channel-count parameters of the setup and coefficient init helpers and the channel count read in prepare from int to unsigned int. Signed-off-by: Adrian Warecki --- src/audio/crossover/crossover.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/audio/crossover/crossover.c b/src/audio/crossover/crossover.c index e0d101cd7470..f897c823c1ba 100644 --- a/src/audio/crossover/crossover.c +++ b/src/audio/crossover/crossover.c @@ -233,12 +233,13 @@ int crossover_init_coef_ch(struct processing_module *mod, * * \param nch number of channels in the audio stream. */ -static int crossover_init_coef(struct processing_module *mod, int nch) +static int crossover_init_coef(struct processing_module *mod, unsigned int nch) { struct comp_data *cd = module_get_private_data(mod); struct sof_eq_iir_biquad *crossover; struct sof_crossover_config *config = cd->config; - int ch, err; + unsigned int ch; + int err; if (!config) { comp_err(mod->dev, "no config is set"); @@ -247,7 +248,7 @@ static int crossover_init_coef(struct processing_module *mod, int nch) /* Sanity checks */ if (nch > PLATFORM_MAX_CHANNELS) { - comp_err(mod->dev, "invalid channels count (%i)", nch); + comp_err(mod->dev, "invalid channels count (%u)", nch); return -EINVAL; } @@ -274,7 +275,7 @@ static int crossover_init_coef(struct processing_module *mod, int nch) /** * \brief Setup the state, coefficients and processing functions for crossover. */ -static int crossover_setup(struct processing_module *mod, int nch) +static int crossover_setup(struct processing_module *mod, unsigned int nch) { int ret = 0; From ca16edfe0592991b433add143f9d877a91ea7ba5 Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Fri, 16 Oct 2026 17:45:44 +0200 Subject: [PATCH 3/4] audio: crossover: wrap the source pointer with source_cir_buf_wrap Use source_cir_buf_wrap instead of cir_buf_wrap to advance the read-only source pointer in the processing functions. Signed-off-by: Adrian Warecki --- src/audio/crossover/crossover_generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio/crossover/crossover_generic.c b/src/audio/crossover/crossover_generic.c index 41a55d9ec0d6..261ca1c85284 100644 --- a/src/audio/crossover/crossover_generic.c +++ b/src/audio/crossover/crossover_generic.c @@ -184,7 +184,7 @@ static int crossover_s16_default(struct comp_data *cd, } remaining_samples -= n; - x = cir_buf_wrap(x + n, x_start, x_end); + x = source_cir_buf_wrap(x + n, x_start, x_end); for (j = 0; j < active_sinks; j++) y[j] = cir_buf_wrap(y[j] + n, y_start[j], y_end[j]); } @@ -263,7 +263,7 @@ static int crossover_s24_default(struct comp_data *cd, } remaining_samples -= n; - x = cir_buf_wrap(x + n, x_start, x_end); + x = source_cir_buf_wrap(x + n, x_start, x_end); for (j = 0; j < active_sinks; j++) y[j] = cir_buf_wrap(y[j] + n, y_start[j], y_end[j]); } @@ -360,7 +360,7 @@ static int crossover_s32_default(struct comp_data *cd, } remaining_samples -= n; - x = cir_buf_wrap(x + n, x_start, x_end); + x = source_cir_buf_wrap(x + n, x_start, x_end); for (j = 0; j < active_sinks; j++) y[j] = cir_buf_wrap(y[j] + n, y_start[j], y_end[j]); } From bf9869ebc5b7320d2f2a407e3ee71830c6b4f647 Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Fri, 16 Oct 2026 17:56:32 +0200 Subject: [PATCH 4/4] audio: crossover: use size_t for the proc-func lookup counter Change the loop counter in the processing-function lookup helpers from int to size_t so it matches crossover_proc_fncount and avoids a signed/unsigned comparison. Signed-off-by: Adrian Warecki --- src/audio/crossover/crossover.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/audio/crossover/crossover.h b/src/audio/crossover/crossover.h index fbd3e5fce33b..22c30618619d 100644 --- a/src/audio/crossover/crossover.h +++ b/src/audio/crossover/crossover.h @@ -87,10 +87,9 @@ extern const size_t crossover_proc_fncount; /** * \brief Returns Crossover processing function. */ -static inline crossover_process_func - crossover_find_proc_func(enum sof_ipc_frame src_fmt) +static inline crossover_process_func crossover_find_proc_func(enum sof_ipc_frame src_fmt) { - int i; + size_t i; /* Find suitable processing function from map */ for (i = 0; i < crossover_proc_fncount; i++) @@ -103,10 +102,9 @@ static inline crossover_process_func /** * \brief Returns Crossover passthrough functions. */ -static inline crossover_process_func - crossover_find_proc_func_pass(enum sof_ipc_frame src_fmt) +static inline crossover_process_func crossover_find_proc_func_pass(enum sof_ipc_frame src_fmt) { - int i; + size_t i; /* Find suitable processing function from map */ for (i = 0; i < crossover_proc_fncount; i++)