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
11 changes: 2 additions & 9 deletions src/audio/mixin_mixout/mixin_mixout.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <rtos/panic.h>
#include <sof/ipc/msg.h>
#include <sof/ipc/notification_pool.h>
#include <rtos/alloc.h>
#include <rtos/init.h>
#include <sof/lib/uuid.h>
#include <sof/list.h>
Expand Down Expand Up @@ -139,7 +138,7 @@ static int mixin_init(struct processing_module *mod)

comp_dbg(dev, "mixin_init()");

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

Expand All @@ -166,7 +165,7 @@ static int mixout_init(struct processing_module *mod)

comp_dbg(dev, "mixout_new()");

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

Expand All @@ -180,17 +179,11 @@ static int mixout_init(struct processing_module *mod)

static int mixin_free(struct processing_module *mod)
{
struct mixin_data *md = module_get_private_data(mod);

rfree(md);

return 0;
}

static int mixout_free(struct processing_module *mod)
{
rfree(module_get_private_data(mod));

return 0;
}

Expand Down
22 changes: 4 additions & 18 deletions src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <sof/audio/ipc-config.h>
#include <sof/common.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 @@ -94,36 +93,27 @@ static int mux_demux_common_init(struct processing_module *mod, enum sof_comp_ty
return -EINVAL;
}

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

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;
return -ENOMEM;
}

module_data->private = cd;
ret = comp_init_data_blob(cd->model_handler, cfg->size, cfg->init_data);
if (ret < 0) {
comp_err(dev, "comp_init_data_blob() failed.");
goto err_init;
return ret;
}

mod->verify_params_flags = BUFF_PARAMS_CHANNELS;
mod->no_pause = true;
cd->comp_type = type;
return 0;

err_init:
comp_data_blob_handler_free(cd->model_handler);

err:
rfree(cd);
return ret;
}

static int mux_init(struct processing_module *mod)
Expand All @@ -135,12 +125,8 @@ static int mux_init(struct processing_module *mod)

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

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

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

Expand Down
45 changes: 9 additions & 36 deletions src/audio/nxp/eap.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Author: Daniel Baluta <daniel.baluta@nxp.com>

#include <rtos/panic.h>
#include <rtos/alloc.h>
#include <rtos/cache.h>
#include <rtos/init.h>
#include <rtos/string.h>
Expand Down Expand Up @@ -93,7 +92,7 @@ static int nxp_eap_init(struct processing_module *mod)
tr_info(mod->dev, "NXP EAP library, platform: %s version:%s",
info.pPlatform, info.pVersionNumber);

eap = rballoc(SOF_MEM_FLAG_USER, sizeof(*eap));
eap = mod_alloc(mod, sizeof(*eap));
if (!eap) {
comp_err(dev, "nxp_eap_init() failed to allocate module private data");
return -ENOMEM;
Expand All @@ -106,7 +105,6 @@ static int nxp_eap_init(struct processing_module *mod)
lvm_ret = LVM_GetMemoryTable(LVM_NULL, &eap->mem_tab, &eap->inst_params);
if (lvm_ret != LVM_SUCCESS) {
comp_err(dev, "nxp_eap_init() failed to get memory table %d", lvm_ret);
rfree(eap);
return -EINVAL;
}

Expand All @@ -115,54 +113,31 @@ static int nxp_eap_init(struct processing_module *mod)
eap->mem_tab.Region[i].pBaseAddress = NULL;

for (int i = 0; i < LVM_NR_MEMORY_REGIONS; i++) {
eap->mem_tab.Region[i].pBaseAddress = rballoc(SOF_MEM_FLAG_USER,
eap->mem_tab.Region[i].Size);
eap->mem_tab.Region[i].pBaseAddress = mod_alloc(mod, eap->mem_tab.Region[i].Size);
if (!eap->mem_tab.Region[i].pBaseAddress) {
comp_err(dev, "nxp_eap_init() failed to allocate memory for region %d", i);
ret = -ENOMEM;
goto free_mem;
return -ENOMEM;
}
}

lvm_ret = LVM_GetInstanceHandle(&eap->instance, &eap->mem_tab, &eap->inst_params);
if (lvm_ret != LVM_SUCCESS) {
comp_err(dev, "nxp_eap_init() failed to get instance handle err: %d", lvm_ret);
ret = -EINVAL;
goto free_mem;
return -EINVAL;
}

/* default parameters, no effects */
memcpy(&eap->ctrl_params, &ControlParamSet_allEffectOff, sizeof(eap->ctrl_params));

return 0;

free_mem:
for (int i = 0; i < LVM_NR_MEMORY_REGIONS; i++) {
if (eap->mem_tab.Region[i].pBaseAddress) {
rfree(eap->mem_tab.Region[i].pBaseAddress);
eap->mem_tab.Region[i].pBaseAddress = NULL;
}
}
rfree(eap);
return ret;
}

static int nxp_eap_free(struct processing_module *mod)
{
struct comp_dev *dev = mod->dev;
struct nxp_eap_data *eap = module_get_private_data(mod);

comp_dbg(dev, "nxp_eap_free()");

for (int i = 0; i < LVM_NR_MEMORY_REGIONS; i++) {
if (eap->mem_tab.Region[i].pBaseAddress) {
rfree(eap->mem_tab.Region[i].pBaseAddress);
eap->mem_tab.Region[i].pBaseAddress = NULL;
}
}

rfree(eap);

return 0;
}

Expand All @@ -189,15 +164,13 @@ static int nxp_eap_prepare(struct processing_module *mod,
*/
eap->buffer_bytes = NXP_EAP_DEFAULT_MAX_BLOCK_SIZE;

md->mpd.in_buff = rballoc_align(SOF_MEM_FLAG_USER, eap->buffer_bytes, 32);
md->mpd.in_buff = mod_alloc_align(mod, eap->buffer_bytes, 32);
if (!md->mpd.in_buff)
return -ENOMEM;

md->mpd.out_buff = rballoc_align(SOF_MEM_FLAG_USER, eap->buffer_bytes, 32);
if (!md->mpd.out_buff) {
rfree(md->mpd.in_buff);
md->mpd.out_buff = mod_alloc_align(mod, eap->buffer_bytes, 32);
if (!md->mpd.out_buff)
return -ENOMEM;
}

md->mpd.in_buff_size = eap->buffer_bytes;
md->mpd.out_buff_size = eap->buffer_bytes;
Expand All @@ -213,13 +186,13 @@ static int nxp_eap_reset(struct processing_module *mod)
comp_dbg(dev, "nxp_eap_reset");

if (md->mpd.in_buff) {
rfree(md->mpd.in_buff);
mod_free(mod, md->mpd.in_buff);
md->mpd.in_buff = NULL;
md->mpd.in_buff_size = 0;
}

if (md->mpd.out_buff) {
rfree(md->mpd.out_buff);
mod_free(mod, md->mpd.out_buff);
md->mpd.out_buff = NULL;
md->mpd.out_buff_size = 0;
}
Expand Down
20 changes: 5 additions & 15 deletions src/audio/rtnr/rtnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static int rtnr_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 @@ -250,17 +250,16 @@ static int rtnr_init(struct processing_module *mod)
cd->process_enable = true;

/* Handler for component 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;
}

ret = comp_init_data_blob(cd->model_handler, bs, ipc_rtnr->data);
if (ret < 0) {
comp_err(dev, "comp_init_data_blob() failed with error: %d", ret);
goto cd_fail;
return ret;
}

/* Component defaults */
Expand All @@ -269,8 +268,7 @@ static int rtnr_init(struct processing_module *mod)
cd->rtk_agl = RTKMA_API_Context_Create(cd->process_sample_rate);
if (cd->rtk_agl == 0) {
comp_err(dev, "RTKMA_API_Context_Create failed.");
ret = -EINVAL;
goto cd_fail;
return -EINVAL;
}
comp_info(dev, "RTKMA_API_Context_Create succeeded.");

Expand All @@ -283,11 +281,6 @@ static int rtnr_init(struct processing_module *mod)

/* Done. */
return 0;

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

static int rtnr_free(struct processing_module *mod)
Expand All @@ -296,11 +289,8 @@ static int rtnr_free(struct processing_module *mod)

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

comp_data_blob_handler_free(cd->model_handler);

RTKMA_API_Context_Free(cd->rtk_agl);

rfree(cd);
return 0;
}

Expand Down
6 changes: 1 addition & 5 deletions src/audio/selector/selector.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ static int selector_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 Down Expand Up @@ -729,12 +729,8 @@ static int selector_verify_params(struct processing_module *mod,
*/
static int selector_free(struct processing_module *mod)
{
struct comp_data *cd = module_get_private_data(mod);

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

rfree(cd);

return 0;
}

Expand Down
Loading