Skip to content

Commit bd043d5

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 768b3de commit bd043d5

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
@@ -44,6 +44,7 @@ LOG_MODULE_REGISTER(smart_amp, CONFIG_SOF_LOG_LEVEL);
4444
#define SOF_SMART_AMP_MODEL 1
4545

4646
struct smart_amp_data {
47+
struct processing_module *mod;
4748
struct sof_smart_amp_config config;
4849
struct comp_buffer *source_buf; /**< stream source buffer */
4950
struct comp_buffer *feedback_buf; /**< feedback source buffer */
@@ -72,33 +73,34 @@ struct smart_amp_data {
7273
static inline void smart_amp_free_mod_memories(struct smart_amp_data *sad)
7374
{
7475
/* sof -> mod feed-forward data re-mapping and format conversion */
75-
rfree(sad->ff_mod.buf.data);
76+
mod_free(sad->mod, sad->ff_mod.buf.data);
7677
sad->ff_mod.buf.data = NULL;
7778
/* sof -> mod feedback data re-mapping and format conversion */
78-
rfree(sad->fb_mod.buf.data);
79+
mod_free(sad->mod, sad->fb_mod.buf.data);
7980
sad->fb_mod.buf.data = NULL;
8081
/* mod -> sof processed data format conversion */
81-
rfree(sad->out_mod.buf.data);
82+
mod_free(sad->mod, sad->out_mod.buf.data);
8283
sad->out_mod.buf.data = NULL;
8384

8485
/* mem block for mod private data usage */
85-
rfree(sad->mod_mems[MOD_MEMBLK_PRIVATE].data);
86+
mod_free(sad->mod, sad->mod_mems[MOD_MEMBLK_PRIVATE].data);
8687
sad->mod_mems[MOD_MEMBLK_PRIVATE].data = NULL;
8788
/* mem block for mod audio frame data usage */
88-
rfree(sad->mod_mems[MOD_MEMBLK_FRAME].data);
89+
mod_free(sad->mod, sad->mod_mems[MOD_MEMBLK_FRAME].data);
8990
sad->mod_mems[MOD_MEMBLK_FRAME].data = NULL;
9091
/* mem block for mod parameter blob usage */
91-
rfree(sad->mod_mems[MOD_MEMBLK_PARAM].data);
92+
mod_free(sad->mod, sad->mod_mems[MOD_MEMBLK_PARAM].data);
9293
sad->mod_mems[MOD_MEMBLK_PARAM].data = NULL;
9394

9495
/* inner model data struct */
95-
rfree(sad->mod_data);
96+
mod_free(sad->mod, sad->mod_data);
9697
sad->mod_data = NULL;
9798
}
9899

99-
static inline int smart_amp_buf_alloc(struct smart_amp_buf *buf, size_t size)
100+
static inline int smart_amp_buf_alloc(struct processing_module *mod,
101+
struct smart_amp_buf *buf, size_t size)
100102
{
101-
buf->data = rballoc(SOF_MEM_FLAG_USER, size);
103+
buf->data = mod_alloc(mod, size);
102104
if (!buf->data)
103105
return -ENOMEM;
104106
buf->size = size;
@@ -123,7 +125,7 @@ static ssize_t smart_amp_alloc_mod_memblk(struct smart_amp_data *sad,
123125

124126
/* allocate the memory block when returned size > 0. */
125127
size = ret;
126-
ret = smart_amp_buf_alloc(&sad->mod_mems[blk], size);
128+
ret = smart_amp_buf_alloc(sad->mod, &sad->mod_mems[blk], size);
127129
if (ret < 0)
128130
goto error;
129131

@@ -148,21 +150,21 @@ static int smart_amp_alloc_data_buffers(struct comp_dev *dev,
148150

149151
/* sof -> mod feed-forward data re-mapping and format conversion */
150152
size = SMART_AMP_FF_BUF_DB_SZ * sizeof(int32_t);
151-
ret = smart_amp_buf_alloc(&sad->ff_mod.buf, size);
153+
ret = smart_amp_buf_alloc(sad->mod, &sad->ff_mod.buf, size);
152154
if (ret < 0)
153155
goto error;
154156
total_size = size;
155157

156158
/* sof -> mod feedback data re-mapping and format conversion */
157159
size = SMART_AMP_FB_BUF_DB_SZ * sizeof(int32_t);
158-
ret = smart_amp_buf_alloc(&sad->fb_mod.buf, size);
160+
ret = smart_amp_buf_alloc(sad->mod, &sad->fb_mod.buf, size);
159161
if (ret < 0)
160162
goto error;
161163
total_size += size;
162164

163165
/* mod -> sof processed data format conversion */
164166
size = SMART_AMP_FF_BUF_DB_SZ * sizeof(int32_t);
165-
ret = smart_amp_buf_alloc(&sad->out_mod.buf, size);
167+
ret = smart_amp_buf_alloc(sad->mod, &sad->out_mod.buf, size);
166168
if (ret < 0)
167169
goto error;
168170
total_size += size;
@@ -190,6 +192,7 @@ static int smart_amp_init(struct processing_module *mod)
190192
return -ENOMEM;
191193

192194
mod->priv.private = sad;
195+
sad->mod = mod;
193196

194197
/* Copy IPC config */
195198
if (mcfg->avail) {

0 commit comments

Comments
 (0)