Skip to content
Draft
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
32 changes: 11 additions & 21 deletions src/audio/tdfb/tdfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <ipc/control.h>
#include <ipc/stream.h>
#include <ipc/topology.h>
#include <rtos/alloc.h>
#include <rtos/init.h>
#include <rtos/panic.h>
#include <rtos/string.h>
Expand Down Expand Up @@ -261,15 +260,16 @@ static inline int set_pass_func(struct processing_module *mod, enum sof_ipc_fram
* Control code functions next. The processing is in fir_ C modules.
*/

static void tdfb_free_delaylines(struct tdfb_comp_data *cd)
static void tdfb_free_delaylines(struct processing_module *mod)
{
struct tdfb_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 @@ -511,10 +511,10 @@ static int tdfb_setup(struct processing_module *mod, int source_nch, int sink_nc

if (delay_size > cd->fir_delay_size) {
/* Free existing FIR channels data if it was allocated */
tdfb_free_delaylines(cd);
tdfb_free_delaylines(mod);

/* 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(mod->dev, "tdfb_setup(), delay allocation failed for size %d",
delay_size);
Expand Down Expand Up @@ -554,7 +554,7 @@ static int tdfb_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 @@ -571,10 +571,10 @@ static int tdfb_init(struct processing_module *mod)
/* Initialize IPC for direction of arrival estimate update */
ret = tdfb_ipc_notification_init(mod);
if (ret)
goto err_free_cd;
return ret;

/* Handler for configuration data */
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;
Expand All @@ -598,14 +598,8 @@ static int tdfb_init(struct processing_module *mod)
return 0;

err:
/* These are null if not used for IPC version */
rfree(cd->ctrl_data);
ipc_msg_free(cd->msg);

err_free_cd:
rfree(cd);
return ret;

}

static int tdfb_free(struct processing_module *mod)
Expand All @@ -615,11 +609,7 @@ static int tdfb_free(struct processing_module *mod)
comp_dbg(mod->dev, "tdfb_free()");

ipc_msg_free(cd->msg);
tdfb_free_delaylines(cd);
comp_data_blob_handler_free(cd->model_handler);
tdfb_direction_free(cd);
rfree(cd->ctrl_data);
rfree(cd);

return 0;
}

Expand Down Expand Up @@ -780,7 +770,7 @@ static int tdfb_prepare(struct processing_module *mod,
comp_dbg(dev, "dev_frames = %d, max_frames = %d", dev->frames, cd->max_frames);

/* Initialize tracking */
ret = tdfb_direction_init(cd, rate, source_channels);
ret = tdfb_direction_init(mod, rate, source_channels);
if (!ret) {
comp_info(dev, "max_lag = %d, xcorr_size = %zu",
cd->direction.max_lag, cd->direction.d_size);
Expand All @@ -803,7 +793,7 @@ static int tdfb_reset(struct processing_module *mod)

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

tdfb_free_delaylines(cd);
tdfb_free_delaylines(mod);

cd->tdfb_func = NULL;
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
Expand Down
3 changes: 1 addition & 2 deletions src/audio/tdfb/tdfb_comp.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ void tdfb_fir_s32(struct tdfb_comp_data *cd,
struct output_stream_buffer *bsink, int frames);
#endif

int tdfb_direction_init(struct tdfb_comp_data *cd, int32_t fs, int channels);
int tdfb_direction_init(struct processing_module *mod, int32_t fs, int channels);
void tdfb_direction_copy_emphasis(struct tdfb_comp_data *cd, int channels, int *channel, int32_t x);
void tdfb_direction_estimate(struct tdfb_comp_data *cd, int frames, int channels);
void tdfb_direction_free(struct tdfb_comp_data *cd);

static inline void tdfb_cinc_s16(int16_t **ptr, int16_t *end, size_t size)
{
Expand Down
30 changes: 7 additions & 23 deletions src/audio/tdfb/tdfb_direction.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "tdfb_comp.h"

#include <ipc/topology.h>
#include <rtos/alloc.h>
#include <sof/math/iir_df1.h>
#include <sof/math/trig.h>
#include <sof/math/sqrt.h>
Expand Down Expand Up @@ -176,8 +175,9 @@ static bool line_array_mode_check(struct tdfb_comp_data *cd)
return true;
}

int tdfb_direction_init(struct tdfb_comp_data *cd, int32_t fs, int ch_count)
int tdfb_direction_init(struct processing_module *mod, int32_t fs, int ch_count)
{
struct tdfb_comp_data *cd = module_get_private_data(mod);
struct sof_eq_iir_header *filt;
int32_t *delay;
int32_t d_max;
Expand All @@ -200,7 +200,7 @@ int tdfb_direction_init(struct tdfb_comp_data *cd, int32_t fs, int ch_count)

/* Allocate delay lines for IIR filters and initialize them */
size = ch_count * iir_delay_size_df1(filt);
delay = rzalloc(SOF_MEM_FLAG_USER, size);
delay = mod_zalloc(mod, size);
if (!delay)
return -ENOMEM;

Expand All @@ -225,9 +225,9 @@ int tdfb_direction_init(struct tdfb_comp_data *cd, int32_t fs, int ch_count)
cd->direction.max_lag = Q_MULTSR_32X32((int64_t)fs, t_max, 0, 15, 0) + 1;
n = (cd->max_frames + (2 * cd->direction.max_lag + 1)) * ch_count;
cd->direction.d_size = n * sizeof(int16_t);
cd->direction.d = rzalloc(SOF_MEM_FLAG_USER, cd->direction.d_size);
cd->direction.d = mod_zalloc(mod, cd->direction.d_size);
if (!cd->direction.d)
goto err_free_iir;
return -ENOMEM;

/* Set needed pointers to xcorr delay line, advance write pointer by max_lag to keep read
* always behind write
Expand All @@ -238,9 +238,9 @@ int tdfb_direction_init(struct tdfb_comp_data *cd, int32_t fs, int ch_count)

/* xcorr result is temporary but too large for stack so it is allocated here */
cd->direction.r_size = (2 * cd->direction.max_lag + 1) * sizeof(int32_t);
cd->direction.r = rzalloc(SOF_MEM_FLAG_USER, cd->direction.r_size);
cd->direction.r = mod_zalloc(mod, cd->direction.r_size);
if (!cd->direction.r)
goto err_free_all;
return -ENOMEM;

/* Check for line array mode */
cd->direction.line_array = line_array_mode_check(cd);
Expand All @@ -249,22 +249,6 @@ int tdfb_direction_init(struct tdfb_comp_data *cd, int32_t fs, int ch_count)
cd->direction.az = 0;
cd->direction.step_sign = 1;
return 0;

err_free_all:
rfree(cd->direction.d);
cd->direction.d = NULL;

err_free_iir:
rfree(cd->direction.df1_delay);
cd->direction.df1_delay = NULL;
return -ENOMEM;
}

void tdfb_direction_free(struct tdfb_comp_data *cd)
{
rfree(cd->direction.df1_delay);
rfree(cd->direction.d);
rfree(cd->direction.r);
}

/* Measure level of one channel */
Expand Down
2 changes: 1 addition & 1 deletion src/audio/tdfb/tdfb_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static int init_get_ctl_ipc(struct processing_module *mod)
struct tdfb_comp_data *cd = module_get_private_data(mod);
int comp_id = dev_comp_id(mod->dev);

cd->ctrl_data = rzalloc(SOF_MEM_FLAG_USER, TDFB_GET_CTRL_DATA_SIZE);
cd->ctrl_data = mod_zalloc(mod, TDFB_GET_CTRL_DATA_SIZE);
if (!cd->ctrl_data)
return -ENOMEM;

Expand Down
5 changes: 1 addition & 4 deletions src/audio/template_comp/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ __cold static int template_comp_init(struct processing_module *mod)

comp_info(dev, "template_comp_init()");

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

Expand Down Expand Up @@ -168,12 +168,9 @@ static int template_comp_reset(struct processing_module *mod)
*/
__cold static int template_comp_free(struct processing_module *mod)
{
struct template_comp_comp_data *cd = module_get_private_data(mod);

assert_can_be_cold();

comp_dbg(mod->dev, "template_comp_free()");
rfree(cd);
return 0;
}

Expand Down
18 changes: 4 additions & 14 deletions src/audio/tensorflow/tflm-classify.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <ipc/stream.h>
#include <ipc/topology.h>
#include <module/module/llext.h>
#include <rtos/alloc.h>
#include <rtos/init.h>
#include <rtos/panic.h>
#include <rtos/string.h>
Expand Down Expand Up @@ -61,25 +60,24 @@ __cold static int tflm_init(struct processing_module *mod)

comp_info(dev, "tflm_init()");

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

md->private = cd;

/* Handler for configuration data */
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 cd_fail;
return -ENOMEM;
}

/* Get configuration data and reset DRC state */
ret = comp_init_data_blob(cd->model_handler, bs, cfg->data);
if (ret < 0) {
comp_err(dev, "comp_init_data_blob() failed.");
goto cd_fail;
return ret;
}

/* hard coded atm */
Expand All @@ -100,20 +98,12 @@ __cold static int tflm_init(struct processing_module *mod)
}

return ret;

cd_fail:
rfree(cd);
return ret;
}

__cold static int tflm_free(struct processing_module *mod)
{
struct tflm_comp_data *cd = module_get_private_data(mod);

assert_can_be_cold();

comp_data_blob_handler_free(cd->model_handler);
rfree(cd);
return 0;
}

Expand Down
28 changes: 7 additions & 21 deletions src/audio/up_down_mixer/up_down_mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <sof/audio/pipeline.h>
#include <rtos/panic.h>
#include <sof/ipc/msg.h>
#include <rtos/alloc.h>
#include <rtos/cache.h>
#include <rtos/init.h>
#include <sof/lib/notifier.h>
Expand Down Expand Up @@ -324,12 +323,6 @@ static int init_mix(struct processing_module *mod,

static int up_down_mixer_free(struct processing_module *mod)
{
struct up_down_mixer_data *cd = module_get_private_data(mod);

rfree(cd->buf_in);
rfree(cd->buf_out);
rfree(cd);

return 0;
}

Expand All @@ -342,20 +335,18 @@ static int up_down_mixer_init(struct processing_module *mod)
struct up_down_mixer_data *cd;
int ret;

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

mod_data->private = cd;

cd->buf_in = rballoc(SOF_MEM_FLAG_USER, mod->priv.cfg.base_cfg.ibs);
cd->buf_out = rballoc(SOF_MEM_FLAG_USER, mod->priv.cfg.base_cfg.obs);
if (!cd->buf_in || !cd->buf_out) {
ret = -ENOMEM;
goto err;
}
cd->buf_in = mod_alloc(mod, mod->priv.cfg.base_cfg.ibs);
cd->buf_out = mod_alloc(mod, mod->priv.cfg.base_cfg.obs);
if (!cd->buf_in || !cd->buf_out)
return -ENOMEM;

switch (up_down_mixer->coefficients_select) {
case DEFAULT_COEFFICIENTS:
Expand All @@ -380,20 +371,15 @@ static int up_down_mixer_init(struct processing_module *mod)
break;
default:
comp_err(dev, "unsupported coefficient type");
ret = -EINVAL;
break;
return -EINVAL;
}

if (ret < 0) {
comp_err(dev, "failed to initialize up_down_mix");
goto err;
return ret;
}

return 0;

err:
up_down_mixer_free(mod);
return ret;
}

static int
Expand Down
5 changes: 0 additions & 5 deletions src/audio/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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/cpu.h>
#include <sof/lib/uuid.h>
Expand Down Expand Up @@ -775,11 +774,7 @@ static int volume_free(struct processing_module *mod)
struct vol_data *cd = module_get_private_data(mod);

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

volume_peak_free(cd);
rfree(cd->vol);
rfree(cd);

return 0;
}

Expand Down
Loading
Loading