Skip to content

Commit 1c722f2

Browse files
Jyri Sarhakv2019i
authored andcommitted
Audio: FIR: Memory, blob, and fast_get allocs to module API
Allocate all memory, blob handlers, and fast_get() buffers through module API mod_alloc() and friends. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent aa1d92d commit 1c722f2

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/audio/eq_fir/eq_fir.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <sof/common.h>
1616
#include <rtos/panic.h>
1717
#include <sof/ipc/msg.h>
18-
#include <rtos/alloc.h>
1918
#include <rtos/init.h>
2019
#include <sof/lib/uuid.h>
2120
#include <sof/list.h>
@@ -58,15 +57,16 @@ static void eq_fir_passthrough(struct fir_state_32x16 fir[],
5857
audio_stream_copy(source, 0, sink, 0, frames * audio_stream_get_channels(source));
5958
}
6059

61-
static void eq_fir_free_delaylines(struct comp_data *cd)
60+
static void eq_fir_free_delaylines(struct processing_module *mod)
6261
{
62+
struct comp_data *cd = module_get_private_data(mod);
6363
struct fir_state_32x16 *fir = cd->fir;
6464
int i = 0;
6565

6666
/* Free the common buffer for all EQs and point then
6767
* each FIR channel delay line to NULL.
6868
*/
69-
rfree(cd->fir_delay);
69+
mod_free(mod, cd->fir_delay);
7070
cd->fir_delay = NULL;
7171
cd->fir_delay_size = 0;
7272
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
@@ -198,12 +198,14 @@ static void eq_fir_init_delay(struct fir_state_32x16 *fir,
198198
}
199199
}
200200

201-
static int eq_fir_setup(struct comp_dev *dev, struct comp_data *cd, int nch)
201+
static int eq_fir_setup(struct processing_module *mod, int nch)
202202
{
203+
struct comp_data *cd = module_get_private_data(mod);
204+
struct comp_dev *dev = mod->dev;
203205
int delay_size;
204206

205207
/* Free existing FIR channels data if it was allocated */
206-
eq_fir_free_delaylines(cd);
208+
eq_fir_free_delaylines(mod);
207209

208210
/* Update number of channels */
209211
cd->nch = nch;
@@ -220,7 +222,7 @@ static int eq_fir_setup(struct comp_dev *dev, struct comp_data *cd, int nch)
220222
return 0;
221223

222224
/* Allocate all FIR channels data in a big chunk and clear it */
223-
cd->fir_delay = rballoc(SOF_MEM_FLAG_USER, delay_size);
225+
cd->fir_delay = mod_balloc(mod, delay_size);
224226
if (!cd->fir_delay) {
225227
comp_err(dev, "eq_fir_setup(), delay allocation failed for size %d", delay_size);
226228
return -ENOMEM;
@@ -264,7 +266,7 @@ static int eq_fir_init(struct processing_module *mod)
264266
return -EINVAL;
265267
}
266268

267-
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
269+
cd = mod_zalloc(mod, sizeof(*cd));
268270
if (!cd)
269271
return -ENOMEM;
270272

@@ -274,9 +276,9 @@ static int eq_fir_init(struct processing_module *mod)
274276
cd->nch = -1;
275277

276278
/* component model data handler */
277-
cd->model_handler = comp_data_blob_handler_new(dev);
279+
cd->model_handler = mod_data_blob_handler_new(mod);
278280
if (!cd->model_handler) {
279-
comp_err(dev, "comp_data_blob_handler_new() failed.");
281+
comp_err(dev, "mod_data_blob_handler_new() failed.");
280282
ret = -ENOMEM;
281283
goto err;
282284
}
@@ -298,9 +300,9 @@ static int eq_fir_init(struct processing_module *mod)
298300
return 0;
299301

300302
err_init:
301-
comp_data_blob_handler_free(cd->model_handler);
303+
mod_data_blob_handler_free(mod, cd->model_handler);
302304
err:
303-
rfree(cd);
305+
mod_free(mod, cd);
304306
return ret;
305307
}
306308

@@ -310,10 +312,10 @@ static int eq_fir_free(struct processing_module *mod)
310312

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

313-
eq_fir_free_delaylines(cd);
315+
eq_fir_free_delaylines(mod);
314316
comp_data_blob_handler_free(cd->model_handler);
315317

316-
rfree(cd);
318+
mod_free(mod, cd);
317319

318320
return 0;
319321
}
@@ -360,7 +362,7 @@ static int eq_fir_process(struct processing_module *mod,
360362
/* Check for changed configuration */
361363
if (comp_is_new_data_blob_available(cd->model_handler)) {
362364
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
363-
ret = eq_fir_setup(mod->dev, cd, audio_stream_get_channels(source));
365+
ret = eq_fir_setup(mod, audio_stream_get_channels(source));
364366
if (ret < 0) {
365367
comp_err(mod->dev, "eq_fir_process(), failed FIR setup");
366368
return ret;
@@ -437,7 +439,7 @@ static int eq_fir_prepare(struct processing_module *mod,
437439
cd->eq_fir_func = eq_fir_passthrough;
438440
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
439441
if (cd->config) {
440-
ret = eq_fir_setup(dev, cd, channels);
442+
ret = eq_fir_setup(mod, channels);
441443
if (ret < 0)
442444
comp_err(dev, "eq_fir_setup failed.");
443445
else if (cd->fir_delay_size)
@@ -464,7 +466,7 @@ static int eq_fir_reset(struct processing_module *mod)
464466

465467
comp_data_blob_set_validator(cd->model_handler, NULL);
466468

467-
eq_fir_free_delaylines(cd);
469+
eq_fir_free_delaylines(mod);
468470

469471
cd->eq_fir_func = NULL;
470472
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)

0 commit comments

Comments
 (0)