Skip to content

Commit 0aba1c6

Browse files
author
Jyri Sarha
committed
audio: volume: 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 9a57d8c commit 0aba1c6

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

src/audio/volume/volume.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <sof/common.h>
2525
#include <rtos/panic.h>
2626
#include <sof/ipc/msg.h>
27-
#include <rtos/alloc.h>
2827
#include <rtos/init.h>
2928
#include <sof/lib/cpu.h>
3029
#include <sof/lib/uuid.h>
@@ -776,9 +775,9 @@ static int volume_free(struct processing_module *mod)
776775

777776
comp_dbg(mod->dev, "volume_free()");
778777

779-
volume_peak_free(cd);
780-
rfree(cd->vol);
781-
rfree(cd);
778+
volume_peak_free(mod);
779+
mod_free(mod, cd->vol);
780+
mod_free(mod, cd);
782781

783782
return 0;
784783
}

src/audio/volume/volume.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ void sys_comp_module_volume_interface_init(void);
300300
/* source_or_sink, true means source, false means sink */
301301
void set_volume_process(struct vol_data *cd, struct comp_dev *dev, bool source_or_sink);
302302

303-
void volume_peak_free(struct vol_data *cd);
303+
void volume_peak_free(struct processing_module *mod);
304304

305305
int volume_peak_prepare(struct vol_data *cd, struct processing_module *mod);
306306

src/audio/volume/volume_ipc3.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <sof/common.h>
1515
#include <rtos/panic.h>
1616
#include <sof/ipc/msg.h>
17-
#include <rtos/alloc.h>
1817
#include <rtos/init.h>
1918
#include <sof/lib/cpu.h>
2019
#include <sof/lib/uuid.h>
@@ -81,17 +80,17 @@ int volume_init(struct processing_module *mod)
8180
return -EINVAL;
8281
}
8382

84-
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(struct vol_data));
83+
cd = mod_zalloc(mod, sizeof(struct vol_data));
8584
if (!cd)
8685
return -ENOMEM;
8786

8887
/*
8988
* malloc memory to store current volume 4 times to ensure the address
9089
* is 8-byte aligned for multi-way xtensa intrinsic operations.
9190
*/
92-
cd->vol = rmalloc(SOF_MEM_FLAG_USER, vol_size);
91+
cd->vol = mod_alloc(mod, vol_size);
9392
if (!cd->vol) {
94-
rfree(cd);
93+
mod_free(mod, cd);
9594
comp_err(dev, "Failed to allocate %zu", vol_size);
9695
return -ENOMEM;
9796
}
@@ -158,8 +157,8 @@ int volume_init(struct processing_module *mod)
158157
break;
159158
default:
160159
comp_err(dev, "invalid ramp type %d", vol->ramp);
161-
rfree(cd);
162-
rfree(cd->vol);
160+
mod_free(mod, cd);
161+
mod_free(mod, cd->vol);
163162
return -EINVAL;
164163
}
165164

@@ -168,7 +167,7 @@ int volume_init(struct processing_module *mod)
168167
return 0;
169168
}
170169

171-
void volume_peak_free(struct vol_data *cd)
170+
void volume_peak_free(struct processing_module *mod)
172171
{
173172
}
174173

src/audio/volume/volume_ipc4.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <sof/common.h>
1515
#include <rtos/panic.h>
1616
#include <sof/ipc/msg.h>
17-
#include <rtos/alloc.h>
1817
#include <rtos/init.h>
1918
#include <sof/lib/cpu.h>
2019
#include <sof/lib/uuid.h>
@@ -128,28 +127,28 @@ int volume_init(struct processing_module *mod)
128127
return -EINVAL;
129128
}
130129

131-
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(struct vol_data));
130+
cd = mod_zalloc(mod, sizeof(struct vol_data));
132131
if (!cd)
133132
return -ENOMEM;
134133

135134
/*
136135
* malloc memory to store current volume 4 times to ensure the address
137136
* is 8-byte aligned for multi-way xtensa intrinsic operations.
138137
*/
139-
cd->vol = rmalloc(SOF_MEM_FLAG_USER, vol_size);
138+
cd->vol = mod_alloc(mod, vol_size);
140139
if (!cd->vol) {
141-
rfree(cd);
140+
mod_free(mod, cd);
142141
comp_err(dev, "Failed to allocate %d", vol_size);
143142
return -ENOMEM;
144143
}
145144

146145
/* malloc memory to store temp peak volume 4 times to ensure the address
147146
* is 8-byte aligned for multi-way xtensa intrinsic operations.
148147
*/
149-
cd->peak_vol = rzalloc(SOF_MEM_FLAG_USER, vol_size);
148+
cd->peak_vol = mod_zalloc(mod, vol_size);
150149
if (!cd->peak_vol) {
151-
rfree(cd->vol);
152-
rfree(cd);
150+
mod_free(mod, cd->vol);
151+
mod_free(mod, cd);
153152
comp_err(dev, "Failed to allocate %d for peak_vol", vol_size);
154153
return -ENOMEM;
155154
}
@@ -189,14 +188,15 @@ int volume_init(struct processing_module *mod)
189188
return 0;
190189
}
191190

192-
void volume_peak_free(struct vol_data *cd)
191+
void volume_peak_free(struct processing_module *mod)
193192
{
193+
struct vol_data *cd = module_get_private_data(mod);
194194
struct ipc4_peak_volume_regs regs;
195195

196196
/* clear mailbox */
197197
memset_s(&regs, sizeof(regs), 0, sizeof(regs));
198198
mailbox_sw_regs_write(cd->mailbox_offset, &regs, sizeof(regs));
199-
rfree(cd->peak_vol);
199+
mod_free(mod, cd->peak_vol);
200200
}
201201

202202
static int volume_set_volume(struct processing_module *mod, const uint8_t *data, int data_size)

0 commit comments

Comments
 (0)