Skip to content
Open
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
37 changes: 18 additions & 19 deletions src/audio/crossover/crossover.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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");
Expand All @@ -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;
}

Expand All @@ -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;

Expand Down Expand Up @@ -558,38 +559,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);
Expand Down
13 changes: 6 additions & 7 deletions src/audio/crossover/crossover.h
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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++)
Expand Down Expand Up @@ -140,7 +138,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);

Expand Down
6 changes: 3 additions & 3 deletions src/audio/crossover/crossover_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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]);
}
Expand Down
3 changes: 2 additions & 1 deletion src/audio/crossover/crossover_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
14 changes: 6 additions & 8 deletions src/audio/crossover/crossover_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Loading