Skip to content

Commit bb400ed

Browse files
Jyri Sarhalgirdwood
authored andcommitted
Audio: ASRC: 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 986f03f commit bb400ed

5 files changed

Lines changed: 62 additions & 61 deletions

File tree

src/audio/asrc/asrc.c

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <sof/audio/ipc-config.h>
1212
#include <rtos/panic.h>
1313
#include <sof/ipc/msg.h>
14-
#include <rtos/alloc.h>
1514
#include <rtos/init.h>
1615
#include <sof/lib/uuid.h>
1716
#include <sof/math/numbers.h>
@@ -217,7 +216,7 @@ static int asrc_init(struct processing_module *mod)
217216
return -EINVAL;
218217
}
219218

220-
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
219+
cd = mod_zalloc(mod, sizeof(*cd));
221220
if (!cd)
222221
return -ENOMEM;
223222

@@ -242,7 +241,7 @@ static int asrc_init(struct processing_module *mod)
242241
return 0;
243242
}
244243

245-
static int asrc_initialize_buffers(struct asrc_farrow *src_obj)
244+
static int asrc_initialize_buffers(struct processing_module *mod, struct asrc_farrow *src_obj)
246245
{
247246
int32_t *buf_32;
248247
int16_t *buf_16;
@@ -261,7 +260,7 @@ static int asrc_initialize_buffers(struct asrc_farrow *src_obj)
261260
buffer_size = src_obj->buffer_length * sizeof(int32_t);
262261

263262
for (ch = 0; ch < src_obj->num_channels; ch++) {
264-
buf_32 = rzalloc(SOF_MEM_FLAG_USER, buffer_size);
263+
buf_32 = mod_zalloc(mod, buffer_size);
265264

266265
if (!buf_32)
267266
return -ENOMEM;
@@ -272,7 +271,7 @@ static int asrc_initialize_buffers(struct asrc_farrow *src_obj)
272271
buffer_size = src_obj->buffer_length * sizeof(int16_t);
273272

274273
for (ch = 0; ch < src_obj->num_channels; ch++) {
275-
buf_16 = rzalloc(SOF_MEM_FLAG_USER, buffer_size);
274+
buf_16 = mod_zalloc(mod, buffer_size);
276275

277276
if (!buf_16)
278277
return -ENOMEM;
@@ -284,7 +283,7 @@ static int asrc_initialize_buffers(struct asrc_farrow *src_obj)
284283
return 0;
285284
}
286285

287-
static void asrc_release_buffers(struct asrc_farrow *src_obj)
286+
static void asrc_release_buffers(struct processing_module *mod, struct asrc_farrow *src_obj)
288287
{
289288
int32_t *buf_32;
290289
int16_t *buf_16;
@@ -299,7 +298,7 @@ static void asrc_release_buffers(struct asrc_farrow *src_obj)
299298

300299
if (buf_32) {
301300
src_obj->ring_buffers32[ch] = NULL;
302-
rfree(buf_32);
301+
mod_free(mod, buf_32);
303302
}
304303
}
305304
else
@@ -308,7 +307,7 @@ static void asrc_release_buffers(struct asrc_farrow *src_obj)
308307

309308
if (buf_16) {
310309
src_obj->ring_buffers16[ch] = NULL;
311-
rfree(buf_16);
310+
mod_free(mod, buf_16);
312311
}
313312
}
314313
}
@@ -320,11 +319,11 @@ static int asrc_free(struct processing_module *mod)
320319

321320
comp_dbg(dev, "asrc_free()");
322321

323-
rfree(cd->buf);
324-
asrc_release_buffers(cd->asrc_obj);
325-
asrc_free_polyphase_filter(cd->asrc_obj);
326-
rfree(cd->asrc_obj);
327-
rfree(cd);
322+
mod_free(mod, cd->buf);
323+
asrc_release_buffers(mod, cd->asrc_obj);
324+
asrc_free_polyphase_filter(mod, cd->asrc_obj);
325+
mod_free(mod, cd->asrc_obj);
326+
mod_free(mod, cd);
328327
return 0;
329328
}
330329

@@ -614,8 +613,7 @@ static int asrc_prepare(struct processing_module *mod,
614613
cd->buf_size = (cd->source_frames_max + cd->sink_frames_max) *
615614
frame_bytes;
616615

617-
cd->buf = rzalloc(SOF_MEM_FLAG_USER,
618-
cd->buf_size);
616+
cd->buf = mod_zalloc(mod, cd->buf_size);
619617
if (!cd->buf) {
620618
cd->buf_size = 0;
621619
comp_err(dev, "asrc_prepare(), allocation fail for size %d",
@@ -632,16 +630,15 @@ static int asrc_prepare(struct processing_module *mod,
632630

633631
/* Get required size and allocate memory for ASRC */
634632
sample_bits = sample_bytes * 8;
635-
ret = asrc_get_required_size(dev, &cd->asrc_size,
633+
ret = asrc_get_required_size(mod, &cd->asrc_size,
636634
audio_stream_get_channels(&sourceb->stream),
637635
sample_bits);
638636
if (ret) {
639637
comp_err(dev, "asrc_prepare(), get_required_size_bytes failed");
640638
goto err_free_buf;
641639
}
642640

643-
cd->asrc_obj = rzalloc(SOF_MEM_FLAG_USER,
644-
cd->asrc_size);
641+
cd->asrc_obj = mod_zalloc(mod, cd->asrc_size);
645642
if (!cd->asrc_obj) {
646643
comp_err(dev, "asrc_prepare(), allocation fail for size %d",
647644
cd->asrc_size);
@@ -659,7 +656,7 @@ static int asrc_prepare(struct processing_module *mod,
659656
fs_sec = cd->source_rate;
660657
}
661658

662-
ret = asrc_initialise(dev, cd->asrc_obj, audio_stream_get_channels(&sourceb->stream),
659+
ret = asrc_initialise(mod, cd->asrc_obj, audio_stream_get_channels(&sourceb->stream),
663660
fs_prim, fs_sec,
664661
ASRC_IOF_INTERLEAVED, ASRC_IOF_INTERLEAVED,
665662
ASRC_BM_LINEAR, cd->frames, sample_bits,
@@ -670,7 +667,7 @@ static int asrc_prepare(struct processing_module *mod,
670667
}
671668

672669
/* Allocate ring buffers */
673-
ret = asrc_initialize_buffers(cd->asrc_obj);
670+
ret = asrc_initialize_buffers(mod, cd->asrc_obj);
674671

675672
/* check for errors */
676673
if (ret) {
@@ -698,12 +695,12 @@ static int asrc_prepare(struct processing_module *mod,
698695
return 0;
699696

700697
err_free_asrc:
701-
asrc_release_buffers(cd->asrc_obj);
702-
rfree(cd->asrc_obj);
698+
asrc_release_buffers(mod, cd->asrc_obj);
699+
mod_free(mod, cd->asrc_obj);
703700
cd->asrc_obj = NULL;
704701

705702
err_free_buf:
706-
rfree(cd->buf);
703+
mod_free(mod, cd->buf);
707704
cd->buf = NULL;
708705

709706
err:
@@ -865,10 +862,10 @@ static int asrc_reset(struct processing_module *mod)
865862
asrc_dai_stop_timestamp(cd);
866863

867864
/* Free the allocations those were done in prepare() */
868-
asrc_release_buffers(cd->asrc_obj);
869-
asrc_free_polyphase_filter(cd->asrc_obj);
870-
rfree(cd->asrc_obj);
871-
rfree(cd->buf);
865+
asrc_release_buffers(mod, cd->asrc_obj);
866+
asrc_free_polyphase_filter(mod, cd->asrc_obj);
867+
mod_free(mod, cd->asrc_obj);
868+
mod_free(mod, cd->buf);
872869
cd->asrc_obj = NULL;
873870
cd->buf = NULL;
874871

0 commit comments

Comments
 (0)