Skip to content

Commit f96de47

Browse files
author
Jyri Sarha
committed
Audio: Smart Amp: mod_alloc() and mod_free() for all memory operations
Replace all rbmalloc() and rfree() usage with mod_alloc() and mod_free(). Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 90584aa commit f96de47

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/audio/smart_amp/smart_amp.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ LOG_MODULE_REGISTER(smart_amp, CONFIG_SOF_LOG_LEVEL);
4242
#define SOF_SMART_AMP_MODEL 1
4343

4444
struct smart_amp_data {
45+
struct processing_module *mod;
4546
struct sof_smart_amp_config config;
4647
struct comp_buffer *source_buf; /**< stream source buffer */
4748
struct comp_buffer *feedback_buf; /**< feedback source buffer */
@@ -68,33 +69,34 @@ struct smart_amp_data {
6869
static inline void smart_amp_free_mod_memories(struct smart_amp_data *sad)
6970
{
7071
/* sof -> mod feed-forward data re-mapping and format conversion */
71-
rfree(sad->ff_mod.buf.data);
72+
mod_free(sad->mod, sad->ff_mod.buf.data);
7273
sad->ff_mod.buf.data = NULL;
7374
/* sof -> mod feedback data re-mapping and format conversion */
74-
rfree(sad->fb_mod.buf.data);
75+
mod_free(sad->mod, sad->fb_mod.buf.data);
7576
sad->fb_mod.buf.data = NULL;
7677
/* mod -> sof processed data format conversion */
77-
rfree(sad->out_mod.buf.data);
78+
mod_free(sad->mod, sad->out_mod.buf.data);
7879
sad->out_mod.buf.data = NULL;
7980

8081
/* mem block for mod private data usage */
81-
rfree(sad->mod_mems[MOD_MEMBLK_PRIVATE].data);
82+
mod_free(sad->mod, sad->mod_mems[MOD_MEMBLK_PRIVATE].data);
8283
sad->mod_mems[MOD_MEMBLK_PRIVATE].data = NULL;
8384
/* mem block for mod audio frame data usage */
84-
rfree(sad->mod_mems[MOD_MEMBLK_FRAME].data);
85+
mod_free(sad->mod, sad->mod_mems[MOD_MEMBLK_FRAME].data);
8586
sad->mod_mems[MOD_MEMBLK_FRAME].data = NULL;
8687
/* mem block for mod parameter blob usage */
87-
rfree(sad->mod_mems[MOD_MEMBLK_PARAM].data);
88+
mod_free(sad->mod, sad->mod_mems[MOD_MEMBLK_PARAM].data);
8889
sad->mod_mems[MOD_MEMBLK_PARAM].data = NULL;
8990

9091
/* inner model data struct */
91-
rfree(sad->mod_data);
92+
mod_free(sad->mod, sad->mod_data);
9293
sad->mod_data = NULL;
9394
}
9495

95-
static inline int smart_amp_buf_alloc(struct smart_amp_buf *buf, size_t size)
96+
static inline int smart_amp_buf_alloc(struct processing_module *mod,
97+
struct smart_amp_buf *buf, size_t size)
9698
{
97-
buf->data = rballoc(SOF_MEM_FLAG_USER, size);
99+
buf->data = mod_alloc(mod, size);
98100
if (!buf->data)
99101
return -ENOMEM;
100102
buf->size = size;
@@ -119,7 +121,7 @@ static ssize_t smart_amp_alloc_mod_memblk(struct smart_amp_data *sad,
119121

120122
/* allocate the memory block when returned size > 0. */
121123
size = ret;
122-
ret = smart_amp_buf_alloc(&sad->mod_mems[blk], size);
124+
ret = smart_amp_buf_alloc(sad->mod, &sad->mod_mems[blk], size);
123125
if (ret < 0)
124126
goto error;
125127

@@ -144,21 +146,21 @@ static int smart_amp_alloc_data_buffers(struct comp_dev *dev,
144146

145147
/* sof -> mod feed-forward data re-mapping and format conversion */
146148
size = SMART_AMP_FF_BUF_DB_SZ * sizeof(int32_t);
147-
ret = smart_amp_buf_alloc(&sad->ff_mod.buf, size);
149+
ret = smart_amp_buf_alloc(sad->mod, &sad->ff_mod.buf, size);
148150
if (ret < 0)
149151
goto error;
150152
total_size = size;
151153

152154
/* sof -> mod feedback data re-mapping and format conversion */
153155
size = SMART_AMP_FB_BUF_DB_SZ * sizeof(int32_t);
154-
ret = smart_amp_buf_alloc(&sad->fb_mod.buf, size);
156+
ret = smart_amp_buf_alloc(sad->mod, &sad->fb_mod.buf, size);
155157
if (ret < 0)
156158
goto error;
157159
total_size += size;
158160

159161
/* mod -> sof processed data format conversion */
160162
size = SMART_AMP_FF_BUF_DB_SZ * sizeof(int32_t);
161-
ret = smart_amp_buf_alloc(&sad->out_mod.buf, size);
163+
ret = smart_amp_buf_alloc(sad->mod, &sad->out_mod.buf, size);
162164
if (ret < 0)
163165
goto error;
164166
total_size += size;
@@ -186,6 +188,7 @@ static int smart_amp_init(struct processing_module *mod)
186188
return -ENOMEM;
187189

188190
mod->priv.private = sad;
191+
sad->mod = mod;
189192

190193
/* Copy config blob if present */
191194
if (mcfg->avail && mcfg->init_data && mcfg->size >= sizeof(struct sof_smart_amp_config)) {

0 commit comments

Comments
 (0)