Skip to content
Closed
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
44 changes: 15 additions & 29 deletions src/audio/eq_fir/eq_fir.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <sof/common.h>
#include <rtos/panic.h>
#include <sof/ipc/msg.h>
#include <rtos/alloc.h>
#include <rtos/init.h>
#include <sof/lib/uuid.h>
#include <sof/list.h>
Expand Down Expand Up @@ -58,15 +57,16 @@ static void eq_fir_passthrough(struct fir_state_32x16 fir[],
audio_stream_copy(source, 0, sink, 0, frames * audio_stream_get_channels(source));
}

static void eq_fir_free_delaylines(struct comp_data *cd)
static void eq_fir_free_delaylines(struct processing_module *mod)
{
struct comp_data *cd = module_get_private_data(mod);
struct fir_state_32x16 *fir = cd->fir;
int i = 0;

/* Free the common buffer for all EQs and point then
* each FIR channel delay line to NULL.
*/
rfree(cd->fir_delay);
mod_free(mod, cd->fir_delay);
cd->fir_delay = NULL;
cd->fir_delay_size = 0;
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
Expand Down Expand Up @@ -198,12 +198,13 @@ static void eq_fir_init_delay(struct fir_state_32x16 *fir,
}
}

static int eq_fir_setup(struct comp_dev *dev, struct comp_data *cd, int nch)
static int eq_fir_setup(struct processing_module *mod, struct comp_data *cd, int nch)
{
struct comp_dev *dev = mod->dev;
int delay_size;

/* Free existing FIR channels data if it was allocated */
eq_fir_free_delaylines(cd);
eq_fir_free_delaylines(mod);

/* Update number of channels */
cd->nch = nch;
Expand All @@ -220,7 +221,7 @@ static int eq_fir_setup(struct comp_dev *dev, struct comp_data *cd, int nch)
return 0;

/* Allocate all FIR channels data in a big chunk and clear it */
cd->fir_delay = rballoc(SOF_MEM_FLAG_USER, delay_size);
cd->fir_delay = mod_alloc(mod, delay_size);
if (!cd->fir_delay) {
comp_err(dev, "eq_fir_setup(), delay allocation failed for size %d", delay_size);
return -ENOMEM;
Expand Down Expand Up @@ -264,7 +265,7 @@ static int eq_fir_init(struct processing_module *mod)
return -EINVAL;
}

cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
cd = mod_zalloc(mod, sizeof(*cd));
if (!cd)
return -ENOMEM;

Expand All @@ -274,11 +275,10 @@ static int eq_fir_init(struct processing_module *mod)
cd->nch = -1;

/* component model data handler */
cd->model_handler = comp_data_blob_handler_new(dev);
cd->model_handler = mod_data_blob_handler_new(mod);
if (!cd->model_handler) {
comp_err(dev, "comp_data_blob_handler_new() failed.");
ret = -ENOMEM;
goto err;
comp_err(dev, "mod_data_blob_handler_new() failed.");
return -ENOMEM;
}

md->private = cd;
Expand All @@ -289,32 +289,18 @@ static int eq_fir_init(struct processing_module *mod)
ret = comp_init_data_blob(cd->model_handler, bs, cfg->init_data);
if (ret < 0) {
comp_err(dev, "comp_init_data_blob() failed.");
goto err_init;
return ret;
}

for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
fir_reset(&cd->fir[i]);

return 0;

err_init:
comp_data_blob_handler_free(cd->model_handler);
err:
rfree(cd);
return ret;
}

static int eq_fir_free(struct processing_module *mod)
{
struct comp_data *cd = module_get_private_data(mod);

comp_dbg(mod->dev, "eq_fir_free()");

eq_fir_free_delaylines(cd);
comp_data_blob_handler_free(cd->model_handler);

rfree(cd);

return 0;
}

Expand Down Expand Up @@ -360,7 +346,7 @@ static int eq_fir_process(struct processing_module *mod,
/* Check for changed configuration */
if (comp_is_new_data_blob_available(cd->model_handler)) {
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
ret = eq_fir_setup(mod->dev, cd, audio_stream_get_channels(source));
ret = eq_fir_setup(mod, cd, audio_stream_get_channels(source));
if (ret < 0) {
comp_err(mod->dev, "eq_fir_process(), failed FIR setup");
return ret;
Expand Down Expand Up @@ -437,7 +423,7 @@ static int eq_fir_prepare(struct processing_module *mod,
cd->eq_fir_func = eq_fir_passthrough;
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
if (cd->config) {
ret = eq_fir_setup(dev, cd, channels);
ret = eq_fir_setup(mod, cd, channels);
if (ret < 0)
comp_err(dev, "eq_fir_setup failed.");
else if (cd->fir_delay_size)
Expand All @@ -464,7 +450,7 @@ static int eq_fir_reset(struct processing_module *mod)

comp_data_blob_set_validator(cd->model_handler, NULL);

eq_fir_free_delaylines(cd);
eq_fir_free_delaylines(mod);

cd->eq_fir_func = NULL;
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
Expand Down
25 changes: 7 additions & 18 deletions src/audio/eq_iir/eq_iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <sof/common.h>
#include <rtos/panic.h>
#include <sof/ipc/msg.h>
#include <rtos/alloc.h>
#include <rtos/init.h>
#include <sof/lib/uuid.h>
#include <sof/list.h>
Expand Down Expand Up @@ -60,18 +59,17 @@ static int eq_iir_init(struct processing_module *mod)
return -EINVAL;
}

cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
cd = mod_zalloc(mod, sizeof(*cd));
if (!cd)
return -ENOMEM;

md->private = cd;

/* component model data handler */
cd->model_handler = comp_data_blob_handler_new(dev);
cd->model_handler = mod_data_blob_handler_new(mod);
if (!cd->model_handler) {
comp_err(dev, "comp_data_blob_handler_new() failed.");
ret = -ENOMEM;
goto err;
comp_err(dev, "mod_data_blob_handler_new() failed.");
return -ENOMEM;
}

/* Allocate and make a copy of the coefficients blob and reset IIR. If
Expand All @@ -80,27 +78,18 @@ static int eq_iir_init(struct processing_module *mod)
ret = comp_init_data_blob(cd->model_handler, bs, cfg->data);
if (ret < 0) {
comp_err(dev, "comp_init_data_blob() failed with error: %d", ret);
comp_data_blob_handler_free(cd->model_handler);
goto err;
return ret;
}

for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
iir_reset_df1(&cd->iir[i]);

return 0;
err:
rfree(cd);
return ret;
}

static int eq_iir_free(struct processing_module *mod)
{
struct comp_data *cd = module_get_private_data(mod);

eq_iir_free_delaylines(cd);
comp_data_blob_handler_free(cd->model_handler);

rfree(cd);
eq_iir_free_delaylines(mod);
return 0;
}

Expand Down Expand Up @@ -234,7 +223,7 @@ static int eq_iir_reset(struct processing_module *mod)
struct comp_data *cd = module_get_private_data(mod);
int i;

eq_iir_free_delaylines(cd);
eq_iir_free_delaylines(mod);

cd->eq_iir_func = NULL;
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_iir/eq_iir.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ void eq_iir_pass(struct processing_module *mod, struct input_stream_buffer *bsou

int eq_iir_setup(struct processing_module *mod, int nch);

void eq_iir_free_delaylines(struct comp_data *cd);
void eq_iir_free_delaylines(struct processing_module *mod);
#endif /* __SOF_AUDIO_EQ_IIR_EQ_IIR_H__ */
10 changes: 5 additions & 5 deletions src/audio/eq_iir/eq_iir_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,16 @@ static void eq_iir_init_delay(struct iir_state_df1 *iir,
}
}

void eq_iir_free_delaylines(struct comp_data *cd)
void eq_iir_free_delaylines(struct processing_module *mod)
{
struct comp_data *cd = module_get_private_data(mod);
struct iir_state_df1 *iir = cd->iir;
int i = 0;

/* Free the common buffer for all EQs and point then
* each IIR channel delay line to NULL.
*/
rfree(cd->iir_delay);
mod_free(mod, cd->iir_delay);
cd->iir_delay = NULL;
cd->iir_delay_size = 0;
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
Expand All @@ -315,7 +316,7 @@ int eq_iir_setup(struct processing_module *mod, int nch)
int delay_size;

/* Free existing IIR channels data if it was allocated */
eq_iir_free_delaylines(cd);
eq_iir_free_delaylines(mod);

/* Set coefficients for each channel EQ from coefficient blob */
delay_size = eq_iir_init_coef(mod, nch);
Expand All @@ -329,8 +330,7 @@ int eq_iir_setup(struct processing_module *mod, int nch)
return 0;

/* Allocate all IIR channels data in a big chunk and clear it */
cd->iir_delay = rzalloc(SOF_MEM_FLAG_USER,
delay_size);
cd->iir_delay = mod_zalloc(mod, delay_size);
if (!cd->iir_delay) {
comp_err(mod->dev, "eq_iir_setup(), delay allocation fail");
return -ENOMEM;
Expand Down
1 change: 0 additions & 1 deletion src/audio/eq_iir/eq_iir_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <sof/common.h>
#include <rtos/panic.h>
#include <sof/ipc/msg.h>
#include <rtos/alloc.h>
#include <rtos/init.h>
#include <sof/lib/uuid.h>
#include <sof/list.h>
Expand Down
1 change: 0 additions & 1 deletion src/audio/eq_iir/eq_iir_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <sof/common.h>
#include <rtos/panic.h>
#include <sof/ipc/msg.h>
#include <rtos/alloc.h>
#include <rtos/init.h>
#include <sof/lib/uuid.h>
#include <sof/list.h>
Expand Down
20 changes: 5 additions & 15 deletions src/audio/google/google_ctc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,7 @@ static int ctc_free(struct processing_module *mod)

comp_info(mod->dev, "ctc_free()");

if (cd) {
rfree(cd->input);
rfree(cd->output);
GoogleCtcAudioProcessingFree(cd->state);
rfree(cd);
module_set_private_data(mod, NULL);
}
GoogleCtcAudioProcessingFree(cd->state);

return 0;
}
Expand All @@ -265,10 +259,9 @@ static int ctc_init(struct processing_module *mod)
comp_info(dev, "ctc_init()");

/* Create private component data */
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
cd = mod_zalloc(mod, sizeof(*cd));
if (!cd) {
comp_err(dev, "Failed to create component data");
ctc_free(mod);
return -ENOMEM;
}

Expand All @@ -277,23 +270,20 @@ static int ctc_init(struct processing_module *mod)
cd->chunk_frames = kChunkFrames;
buf_size = cd->chunk_frames * sizeof(cd->input[0]) * kMaxChannels;

cd->input = rballoc(SOF_MEM_FLAG_USER, buf_size);
cd->input = mod_alloc(mod, buf_size);
if (!cd->input) {
comp_err(dev, "Failed to allocate input buffer");
ctc_free(mod);
return -ENOMEM;
}
cd->output = rballoc(SOF_MEM_FLAG_USER, buf_size);
cd->output = mod_alloc(mod, buf_size);
if (!cd->output) {
comp_err(dev, "Failed to allocate output buffer");
ctc_free(mod);
return -ENOMEM;
}

cd->tuning_handler = comp_data_blob_handler_new(dev);
cd->tuning_handler = mod_data_blob_handler_new(mod);
if (!cd->tuning_handler) {
comp_err(dev, "Failed to create tuning handler");
ctc_free(mod);
return -ENOMEM;
}

Expand Down
8 changes: 2 additions & 6 deletions src/audio/google/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,15 @@ static int google_rtc_audio_processing_init(struct processing_module *mod)
comp_info(dev, "google_rtc_audio_processing_init()");

/* Create private component data */
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
cd = mod_zalloc(mod, sizeof(*cd));
if (!cd) {
ret = -ENOMEM;
goto fail;
}

md->private = cd;

cd->tuning_handler = comp_data_blob_handler_new(dev);
cd->tuning_handler = mod_data_blob_handler_new(mod);
if (!cd->tuning_handler) {
ret = -ENOMEM;
goto fail;
Expand Down Expand Up @@ -585,8 +585,6 @@ static int google_rtc_audio_processing_init(struct processing_module *mod)
GoogleRtcAudioProcessingFree(cd->state);
}
GoogleRtcAudioProcessingDetachMemoryBuffer();
comp_data_blob_handler_free(cd->tuning_handler);
rfree(cd);
}

return ret;
Expand All @@ -601,8 +599,6 @@ static int google_rtc_audio_processing_free(struct processing_module *mod)
GoogleRtcAudioProcessingFree(cd->state);
cd->state = NULL;
GoogleRtcAudioProcessingDetachMemoryBuffer();
comp_data_blob_handler_free(cd->tuning_handler);
rfree(cd);
return 0;
}

Expand Down
Loading
Loading