Skip to content

Commit 7dd90d9

Browse files
Jyri Sarhalgirdwood
authored andcommitted
audio: codec_adapter: Convert DAX module to use new module API
Convert all comp_data_blob_handler_new/free(), rmalloc(), bmalloc(), and rfree() calls to their module associated counterparts. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 4c4ca6a commit 7dd90d9

1 file changed

Lines changed: 23 additions & 22 deletions

File tree

  • src/audio/module_adapter/module/dolby

src/audio/module_adapter/module/dolby/dax.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,24 @@ static int sof_to_dax_buffer_layout(enum sof_ipc_buffer_format sof_buf_fmt)
9494
}
9595
}
9696

97-
static void dax_buffer_release(struct dax_buffer *dax_buff)
97+
static void dax_buffer_release(struct processing_module *mod, struct dax_buffer *dax_buff)
9898
{
9999
if (dax_buff->addr) {
100-
rfree(dax_buff->addr);
100+
mod_free(mod, dax_buff->addr);
101101
dax_buff->addr = NULL;
102102
}
103103
dax_buff->size = 0;
104104
dax_buff->avail = 0;
105105
dax_buff->free = 0;
106106
}
107107

108-
static int dax_buffer_alloc(struct dax_buffer *dax_buff, uint32_t bytes)
108+
static int dax_buffer_alloc(struct processing_module *mod,
109+
struct dax_buffer *dax_buff, uint32_t bytes)
109110
{
110-
dax_buffer_release(dax_buff);
111-
dax_buff->addr = rballoc(SOF_MEM_CAPS_RAM, bytes);
111+
dax_buffer_release(mod, dax_buff);
112+
dax_buff->addr = mod_balloc(mod, bytes);
112113
if (!dax_buff->addr)
113-
dax_buff->addr = rzalloc(SOF_MEM_CAPS_RAM, bytes);
114+
dax_buff->addr = mod_zalloc(mod, bytes);
114115
if (!dax_buff->addr)
115116
return -ENOMEM;
116117

@@ -143,7 +144,7 @@ static int set_tuning_file(struct processing_module *mod, void *value, uint32_t
143144
struct comp_dev *dev = mod->dev;
144145
struct sof_dax *dax_ctx = module_get_private_data(mod);
145146

146-
if (dax_buffer_alloc(&dax_ctx->tuning_file_buffer, size) != 0) {
147+
if (dax_buffer_alloc(mod, &dax_ctx->tuning_file_buffer, size) != 0) {
147148
comp_err(dev, "allocate %u bytes failed for tuning file", size);
148149
ret = -ENOMEM;
149150
} else {
@@ -425,14 +426,14 @@ static int sof_dax_free(struct processing_module *mod)
425426

426427
if (dax_ctx) {
427428
dax_free(dax_ctx);
428-
dax_buffer_release(&dax_ctx->persist_buffer);
429-
dax_buffer_release(&dax_ctx->scratch_buffer);
430-
dax_buffer_release(&dax_ctx->tuning_file_buffer);
431-
dax_buffer_release(&dax_ctx->input_buffer);
432-
dax_buffer_release(&dax_ctx->output_buffer);
433-
comp_data_blob_handler_free(dax_ctx->blob_handler);
429+
dax_buffer_release(mod, &dax_ctx->persist_buffer);
430+
dax_buffer_release(mod, &dax_ctx->scratch_buffer);
431+
dax_buffer_release(mod, &dax_ctx->tuning_file_buffer);
432+
dax_buffer_release(mod, &dax_ctx->input_buffer);
433+
dax_buffer_release(mod, &dax_ctx->output_buffer);
434+
mod_data_blob_handler_free(mod, dax_ctx->blob_handler);
434435
dax_ctx->blob_handler = NULL;
435-
rfree(dax_ctx);
436+
mod_free(mod, dax_ctx);
436437
module_set_private_data(mod, NULL);
437438
}
438439
return 0;
@@ -447,7 +448,7 @@ static int sof_dax_init(struct processing_module *mod)
447448
uint32_t persist_sz;
448449
uint32_t scratch_sz;
449450

450-
md->private = rzalloc(SOF_MEM_CAPS_RAM, sizeof(struct sof_dax));
451+
md->private = mod_zalloc(mod, sizeof(struct sof_dax));
451452
if (!md->private) {
452453
comp_err(dev, "failed to allocate %u bytes for initialization",
453454
sizeof(struct sof_dax));
@@ -462,21 +463,21 @@ static int sof_dax_init(struct processing_module *mod)
462463
dax_ctx->volume = 1 << 23;
463464
dax_ctx->update_flags = 0;
464465

465-
dax_ctx->blob_handler = comp_data_blob_handler_new(dev);
466+
dax_ctx->blob_handler = mod_data_blob_handler_new(mod);
466467
if (!dax_ctx->blob_handler) {
467468
comp_err(dev, "create blob handler failed");
468469
ret = -ENOMEM;
469470
goto err;
470471
}
471472

472473
persist_sz = dax_query_persist_memory(dax_ctx);
473-
if (dax_buffer_alloc(&dax_ctx->persist_buffer, persist_sz) != 0) {
474+
if (dax_buffer_alloc(mod, &dax_ctx->persist_buffer, persist_sz) != 0) {
474475
comp_err(dev, "allocate %u bytes failed for persist", persist_sz);
475476
ret = -ENOMEM;
476477
goto err;
477478
}
478479
scratch_sz = dax_query_scratch_memory(dax_ctx);
479-
if (dax_buffer_alloc(&dax_ctx->scratch_buffer, scratch_sz) != 0) {
480+
if (dax_buffer_alloc(mod, &dax_ctx->scratch_buffer, scratch_sz) != 0) {
480481
comp_err(dev, "allocate %u bytes failed for scratch", scratch_sz);
481482
ret = -ENOMEM;
482483
goto err;
@@ -602,12 +603,12 @@ static int sof_dax_prepare(struct processing_module *mod, struct sof_source **so
602603
dax_ctx->input_media_format.num_channels *
603604
dax_ctx->input_media_format.bytes_per_sample;
604605
obs = dax_ctx->period_bytes + dax_ctx->sof_period_bytes;
605-
if (dax_buffer_alloc(&dax_ctx->input_buffer, ibs) != 0) {
606+
if (dax_buffer_alloc(mod, &dax_ctx->input_buffer, ibs) != 0) {
606607
comp_err(dev, "allocate %u bytes failed for input", ibs);
607608
ret = -ENOMEM;
608609
goto err;
609610
}
610-
if (dax_buffer_alloc(&dax_ctx->output_buffer, obs) != 0) {
611+
if (dax_buffer_alloc(mod, &dax_ctx->output_buffer, obs) != 0) {
611612
comp_err(dev, "allocate %u bytes failed for output", obs);
612613
ret = -ENOMEM;
613614
goto err;
@@ -619,8 +620,8 @@ static int sof_dax_prepare(struct processing_module *mod, struct sof_source **so
619620
return 0;
620621

621622
err:
622-
dax_buffer_release(&dax_ctx->input_buffer);
623-
dax_buffer_release(&dax_ctx->output_buffer);
623+
dax_buffer_release(mod, &dax_ctx->input_buffer);
624+
dax_buffer_release(mod, &dax_ctx->output_buffer);
624625
return ret;
625626
}
626627

0 commit comments

Comments
 (0)