A free of null pointer is fixed with this change. Also the possibility of nondefined number of channels in EQ config or switch command is eliminated by by initializing the FIR for max channels.
Some trace output is added for FIR setup.
Signed-off-by: Seppo Ingalsuo seppo.ingalsuo@linux.intel.com --- src/audio/eq_fir.c | 28 ++++++++++++++++++++-------- src/audio/eq_fir.h | 2 +- src/include/uapi/ipc.h | 6 ++++++ 3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/src/audio/eq_fir.c b/src/audio/eq_fir.c index 5617313..d5f9738 100644 --- a/src/audio/eq_fir.c +++ b/src/audio/eq_fir.c @@ -175,6 +175,9 @@ static int eq_fir_setup(struct fir_state_32x16 fir[], } }
+ /* Free existing FIR channels data if it was allocated */ + eq_fir_free_delaylines(fir); + /* Initialize 1st phase */ for (i = 0; i < nch; i++) { resp = config->assign_response[i]; @@ -191,8 +194,6 @@ static int eq_fir_setup(struct fir_state_32x16 fir[], }
} - /* Free existing FIR channels data if it was allocated */ - eq_fir_free_delaylines(fir);
/* Allocate all FIR channels data in a big chunk and clear it */ fir_data = rballoc(RZONE_SYS, RFLAGS_NONE, @@ -306,11 +307,9 @@ static int eq_fir_cmd(struct comp_dev *dev, int cmd, void *data) { trace_src("ECm"); struct comp_data *cd = comp_get_drvdata(dev); - struct comp_buffer *source = list_first_item(&dev->bsource_list, - struct comp_buffer, sink_list); struct sof_ipc_eq_fir_blob *blob; struct sof_ipc_eq_fir_switch *assign; - + struct eq_fir_update *fir_update; int i; size_t bs;
@@ -318,9 +317,15 @@ static int eq_fir_cmd(struct comp_dev *dev, int cmd, void *data) case COMP_CMD_EQ_FIR_SWITCH: trace_src("EFx"); assign = (struct sof_ipc_eq_fir_switch *) data; + fir_update = (struct eq_fir_update *) assign->data; eq_fir_switch_response(cd->fir, cd->config, - (struct eq_fir_update *) assign->data, - source->params.pcm->channels); + fir_update, PLATFORM_MAX_CHANNELS); + + /* Print trace information */ + tracev_value(iir_update->stream_max_channels); + for (i = 0; i < fir_update->stream_max_channels; i++) + tracev_value(iir_update->assign_response[i]); + break; case COMP_CMD_EQ_FIR_CONFIG: trace_src("EFc"); @@ -338,7 +343,14 @@ static int eq_fir_cmd(struct comp_dev *dev, int cmd, void *data) return -EINVAL;
memcpy(cd->config, blob->data, bs); - eq_fir_setup(cd->fir, cd->config, source->params.pcm->channels); + eq_fir_setup(cd->fir, cd->config, PLATFORM_MAX_CHANNELS); + + /* Print trace information */ + tracev_value(cd->config->stream_max_channels); + tracev_value(cd->config->number_of_responses_defined); + for (i = 0; i < cd->config->stream_max_channels; i++) + tracev_value(cd->config->assign_response[i]); + break; case COMP_CMD_MUTE: trace_src("EFm"); diff --git a/src/audio/eq_fir.h b/src/audio/eq_fir.h index 0b5dbb1..7579ba4 100644 --- a/src/audio/eq_fir.h +++ b/src/audio/eq_fir.h @@ -52,7 +52,7 @@
#define NHEADER_EQ_FIR_BLOB 2 /* Header is two words plus assigns plus coef */
-#define EQ_FIR_MAX_BLOB_SIZE 4096 /* Max size allowed for blob */ +#define EQ_FIR_MAX_BLOB_SIZE 4096 /* Max size allowed for blob in bytes */
struct eq_fir_configuration { uint16_t stream_max_channels; diff --git a/src/include/uapi/ipc.h b/src/include/uapi/ipc.h index d89039e..db7a8bb 100644 --- a/src/include/uapi/ipc.h +++ b/src/include/uapi/ipc.h @@ -511,6 +511,12 @@ struct sof_ipc_comp_tone { int32_t ramp_step; } __attribute__((packed));
+/* FIR equalizer component */ +struct sof_ipc_comp_eq_fir { + struct sof_ipc_comp comp; + struct sof_ipc_pcm_comp pcm; +} __attribute__((packed)); + /* IPC to pass configuration blobs to equalizers and re-assign responses */ struct sof_ipc_eq_fir_blob { struct sof_ipc_comp comp;