Skip to content

Commit dfc1660

Browse files
committed
audio: module-adapter: make generic.c user-space compatible
Replace direct rballoc() and rfree() calls with sof_heap_alloc() and sof_heap_free(), and use sof_sys_user_heap_get() as the heap. This makes the code ready to be used in user-space, including module prepare and free stages. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 5ead087 commit dfc1660

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/audio/module_adapter/module/generic.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ int module_load_config(struct comp_dev *dev, const void *cfg, size_t size)
5757

5858
if (!dst->data) {
5959
/* No space for config available yet, allocate now */
60-
dst->data = rballoc(SOF_MEM_FLAG_USER, size);
60+
dst->data = sof_heap_alloc(sof_sys_user_heap_get(),
61+
SOF_MEM_FLAG_USER, size, 0);
6162
} else if (dst->size != size) {
6263
/* The size allocated for previous config doesn't match the new one.
6364
* Free old container and allocate new one.
6465
*/
65-
rfree(dst->data);
66-
dst->data = rballoc(SOF_MEM_FLAG_USER, size);
66+
sof_heap_free(sof_sys_user_heap_get(), dst->data);
67+
dst->data = sof_heap_alloc(sof_sys_user_heap_get(),
68+
SOF_MEM_FLAG_USER, size, 0);
6769
}
6870
if (!dst->data) {
6971
comp_err(dev, "failed to allocate space for setup config.");
@@ -538,7 +540,7 @@ int module_prepare(struct processing_module *mod,
538540
* as it has been applied during the procedure - it is safe to
539541
* free it.
540542
*/
541-
rfree(md->cfg.data);
543+
sof_heap_free(sof_sys_user_heap_get(), md->cfg.data);
542544

543545
md->cfg.avail = false;
544546
md->cfg.data = NULL;
@@ -673,7 +675,7 @@ int module_reset(struct processing_module *mod)
673675

674676
md->cfg.avail = false;
675677
md->cfg.size = 0;
676-
rfree(md->cfg.data);
678+
sof_heap_free(sof_sys_user_heap_get(), md->cfg.data);
677679
md->cfg.data = NULL;
678680

679681
#if CONFIG_IPC_MAJOR_3
@@ -724,10 +726,10 @@ int module_free(struct processing_module *mod)
724726
/* Free all memory shared by module_adapter & module */
725727
md->cfg.avail = false;
726728
md->cfg.size = 0;
727-
rfree(md->cfg.data);
729+
sof_heap_free(sof_sys_user_heap_get(), md->cfg.data);
728730
md->cfg.data = NULL;
729731
if (md->runtime_params) {
730-
rfree(md->runtime_params);
732+
sof_heap_free(sof_sys_user_heap_get(), md->runtime_params);
731733
md->runtime_params = NULL;
732734
}
733735
#if CONFIG_IPC_MAJOR_3
@@ -794,7 +796,9 @@ int module_set_configuration(struct processing_module *mod,
794796
}
795797

796798
/* Allocate buffer for new params */
797-
md->runtime_params = rballoc(SOF_MEM_FLAG_USER, md->new_cfg_size);
799+
md->runtime_params = sof_heap_alloc(sof_sys_user_heap_get(),
800+
SOF_MEM_FLAG_USER,
801+
md->new_cfg_size, 0);
798802
if (!md->runtime_params) {
799803
comp_err(dev, "space allocation for new params failed");
800804
return -ENOMEM;
@@ -835,7 +839,7 @@ int module_set_configuration(struct processing_module *mod,
835839
md->new_cfg_size = 0;
836840

837841
if (md->runtime_params)
838-
rfree(md->runtime_params);
842+
sof_heap_free(sof_sys_user_heap_get(), md->runtime_params);
839843
md->runtime_params = NULL;
840844

841845
return ret;

0 commit comments

Comments
 (0)