Skip to content

Commit

Permalink
Audio: EQIIR: Fix in IPC4 invalid coefficients blob set at init()
Browse files Browse the repository at this point in the history
The cfg->size is the size of ipc4_base_module_cfg. The
cfg->data is NULL but when such is encountered the
comp_init_data_blob() allocates a zero bytes of size.

Such blob is illegal and e.g. IIR will fail if not another
blob is received by prepare(). DC block operates,
but applies a rather high cut-off frequency that results
to silent audio for e.g. lower voice frequencies. What
happens with such illegal blob is component specific.

The expected operation for most components is pass-through
when a configuration blob is not set. This change should
ensure that the component is not initialized with incorrect
bytes control data if such is not passed with topology.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
  • Loading branch information
singalsu committed Sep 20, 2024
1 parent 88cde10 commit f8bff98
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/audio/crossover/crossover.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ static int crossover_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct comp_data *cd;
const struct module_config *ipc_crossover = &md->cfg;
size_t bs = ipc_crossover->size;
size_t bs = module_adapter_init_bytes_blob_size(ipc_crossover);
int ret;

comp_info(dev, "crossover_init()");
Expand Down
2 changes: 1 addition & 1 deletion src/audio/dcblock/dcblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static int dcblock_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct module_config *ipc_dcblock = &md->cfg;
struct comp_data *cd;
size_t bs = ipc_dcblock->size;
size_t bs = module_adapter_init_bytes_blob_size(ipc_dcblock);
int ret;

comp_info(dev, "dcblock_init()");
Expand Down
2 changes: 1 addition & 1 deletion src/audio/drc/drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static int drc_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct module_config *cfg = &md->cfg;
struct drc_comp_data *cd;
size_t bs = cfg->size;
size_t bs = module_adapter_init_bytes_blob_size(cfg);
int ret;

comp_info(dev, "drc_init()");
Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_fir/eq_fir.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static int eq_fir_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct module_config *cfg = &md->cfg;
struct comp_data *cd = NULL;
size_t bs = cfg->size;
size_t bs = module_adapter_init_bytes_blob_size(cfg);
int i;
int ret;

Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_iir/eq_iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static int eq_iir_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct module_config *cfg = &md->cfg;
struct comp_data *cd;
size_t bs = cfg->size;
size_t bs = module_adapter_init_bytes_blob_size(cfg);
int i, ret;

comp_info(dev, "eq_iir_init()");
Expand Down
2 changes: 1 addition & 1 deletion src/audio/igo_nr/igo_nr.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ static int igo_nr_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct module_config *cfg = &md->cfg;
struct comp_data *cd;
size_t bs = cfg->size;
size_t bs = module_adapter_init_bytes_blob_size(cfg);
int32_t ret;

comp_info(dev, "igo_nr_init()");
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mfcc/mfcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static int mfcc_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct module_config *cfg = &md->cfg;
struct mfcc_comp_data *cd = NULL;
size_t bs = cfg->size;
size_t bs = module_adapter_init_bytes_blob_size(cfg);
int ret;

comp_info(dev, "mfcc_init()");
Expand Down
5 changes: 5 additions & 0 deletions src/audio/module_adapter/module_adapter_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,8 @@ int module_adapter_sink_src_prepare(struct comp_dev *dev)

return ret;
}

size_t module_adapter_init_bytes_blob_size(const struct module_config *config)
{
return config->size;
}
5 changes: 5 additions & 0 deletions src/audio/module_adapter/module_adapter_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,8 @@ int module_adapter_sink_src_prepare(struct comp_dev *dev)
return module_prepare(mod, mod->sources, mod->num_of_sources,
mod->sinks, mod->num_of_sinks);
}

size_t module_adapter_init_bytes_blob_size(const struct module_config *config)
{
return 0;
}
2 changes: 1 addition & 1 deletion src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static int multiband_drc_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct module_config *cfg = &md->cfg;
struct multiband_drc_comp_data *cd;
size_t bs = cfg->size;
size_t bs = module_adapter_init_bytes_blob_size(cfg);
int ret;

comp_info(dev, "multiband_drc_init()");
Expand Down
2 changes: 1 addition & 1 deletion src/audio/rtnr/rtnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static int rtnr_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct module_config *ipc_rtnr = &mod_data->cfg;
struct comp_data *cd;
size_t bs = ipc_rtnr->size;
size_t bs = module_adapter_init_bytes_blob_size(ipc_rtnr);
int ret;

comp_info(dev, "rtnr_new()");
Expand Down
2 changes: 1 addition & 1 deletion src/audio/tdfb/tdfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ static int tdfb_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct module_config *cfg = &md->cfg;
struct tdfb_comp_data *cd;
size_t bs = cfg->size;
size_t bs = module_adapter_init_bytes_blob_size(cfg);
int ret;
int i;

Expand Down
2 changes: 2 additions & 0 deletions src/include/sof/audio/module_adapter/module/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,6 @@ void module_adapter_set_params(struct processing_module *mod, struct sof_ipc_str
int module_adapter_set_state(struct processing_module *mod, struct comp_dev *dev,
int cmd);
int module_adapter_sink_src_prepare(struct comp_dev *dev);
size_t module_adapter_init_bytes_blob_size(const struct module_config *config);

#endif /* __SOF_AUDIO_MODULE_GENERIC__ */

0 comments on commit f8bff98

Please sign in to comment.