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/math/iir_df1.h>
@@ -47,12 +46,13 @@ DECLARE_TR_CTX(crossover_tr, SOF_UUID(crossover_uuid), LOG_LEVEL_INFO);
4746 * \brief Reset the state (coefficients and delay) of the crossover filter
4847 * across all channels
4948 */
50- static void crossover_reset_state (struct comp_data * cd )
49+ static void crossover_reset_state (struct processing_module * mod ,
50+ struct comp_data * cd )
5151{
5252 int i ;
5353
5454 for (i = 0 ; i < PLATFORM_MAX_CHANNELS ; i ++ )
55- crossover_reset_state_ch (& cd -> state [i ]);
55+ crossover_reset_state_ch (mod , & cd -> state [i ]);
5656}
5757
5858/**
@@ -156,7 +156,8 @@ static int crossover_assign_sinks(struct processing_module *mod,
156156 * high/low pass filter.
157157 * \param[out] lr4 initialized struct
158158 */
159- static int crossover_init_coef_lr4 (struct sof_eq_iir_biquad * coef ,
159+ static int crossover_init_coef_lr4 (struct processing_module * mod ,
160+ struct sof_eq_iir_biquad * coef ,
160161 struct iir_state_df1 * lr4 )
161162{
162163 int ret ;
@@ -169,8 +170,7 @@ static int crossover_init_coef_lr4(struct sof_eq_iir_biquad *coef,
169170 * in series due to identity. To maintain the structure of
170171 * iir_state_df1, it requires two copies of coefficients in a row.
171172 */
172- lr4 -> coef = rzalloc (SOF_MEM_FLAG_USER ,
173- sizeof (struct sof_eq_iir_biquad ) * 2 );
173+ lr4 -> coef = mod_zalloc (mod , sizeof (struct sof_eq_iir_biquad ) * 2 );
174174 if (!lr4 -> coef )
175175 return - ENOMEM ;
176176
@@ -189,8 +189,7 @@ static int crossover_init_coef_lr4(struct sof_eq_iir_biquad *coef,
189189 * delay[0..1] -> state for first biquad
190190 * delay[2..3] -> state for second biquad
191191 */
192- lr4 -> delay = rzalloc (SOF_MEM_FLAG_USER ,
193- sizeof (uint64_t ) * CROSSOVER_NUM_DELAYS_LR4 );
192+ lr4 -> delay = mod_zalloc (mod , sizeof (uint64_t ) * CROSSOVER_NUM_DELAYS_LR4 );
194193 if (!lr4 -> delay )
195194 return - ENOMEM ;
196195
@@ -203,7 +202,8 @@ static int crossover_init_coef_lr4(struct sof_eq_iir_biquad *coef,
203202/**
204203 * \brief Initializes the crossover coefficients for one channel
205204 */
206- int crossover_init_coef_ch (struct sof_eq_iir_biquad * coef ,
205+ int crossover_init_coef_ch (struct processing_module * mod ,
206+ struct sof_eq_iir_biquad * coef ,
207207 struct crossover_state * ch_state ,
208208 int32_t num_sinks )
209209{
@@ -214,12 +214,12 @@ int crossover_init_coef_ch(struct sof_eq_iir_biquad *coef,
214214
215215 for (i = 0 ; i < num_lr4s ; i ++ ) {
216216 /* Get the low pass coefficients */
217- err = crossover_init_coef_lr4 (& coef [j ],
217+ err = crossover_init_coef_lr4 (mod , & coef [j ],
218218 & ch_state -> lowpass [i ]);
219219 if (err < 0 )
220220 return - EINVAL ;
221221 /* Get the high pass coefficients */
222- err = crossover_init_coef_lr4 (& coef [j + 1 ],
222+ err = crossover_init_coef_lr4 (mod , & coef [j + 1 ],
223223 & ch_state -> highpass [i ]);
224224 if (err < 0 )
225225 return - EINVAL ;
@@ -259,13 +259,13 @@ static int crossover_init_coef(struct processing_module *mod, int nch)
259259 /* Collect the coef array and assign it to every channel */
260260 crossover = config -> coef ;
261261 for (ch = 0 ; ch < nch ; ch ++ ) {
262- err = crossover_init_coef_ch (crossover , & cd -> state [ch ],
262+ err = crossover_init_coef_ch (mod , crossover , & cd -> state [ch ],
263263 config -> num_sinks );
264264 /* Free all previously allocated blocks in case of an error */
265265 if (err < 0 ) {
266266 comp_err (mod -> dev , "crossover_init_coef(), could not assign coefficients to ch %d" ,
267267 ch );
268- crossover_reset_state (cd );
268+ crossover_reset_state (mod , cd );
269269 return err ;
270270 }
271271 }
@@ -282,7 +282,7 @@ static int crossover_setup(struct processing_module *mod, int nch)
282282 int ret = 0 ;
283283
284284 /* Reset any previous state */
285- crossover_reset_state (cd );
285+ crossover_reset_state (mod , cd );
286286
287287 /* Assign LR4 coefficients from config */
288288 ret = crossover_init_coef (mod , nch );
@@ -312,40 +312,34 @@ static int crossover_init(struct processing_module *mod)
312312 return - ENOMEM ;
313313 }
314314
315- cd = rzalloc ( SOF_MEM_FLAG_USER , sizeof (* cd ));
315+ cd = mod_zalloc ( mod , sizeof (* cd ));
316316 if (!cd )
317317 return - ENOMEM ;
318318
319319 md -> private = cd ;
320320
321321 /* Handler for configuration data */
322- cd -> model_handler = comp_data_blob_handler_new ( dev );
322+ cd -> model_handler = mod_data_blob_handler_new ( mod );
323323 if (!cd -> model_handler ) {
324324 comp_err (dev , "comp_data_blob_handler_new() failed." );
325- ret = - ENOMEM ;
326- goto cd_fail ;
325+ return - ENOMEM ;
327326 }
328327
329328 /* Get configuration data and reset Crossover state */
330329 ret = comp_init_data_blob (cd -> model_handler , bs , ipc_crossover -> data );
331330 if (ret < 0 ) {
332331 comp_err (dev , "comp_init_data_blob() failed." );
333- goto cd_fail ;
332+ return ret ;
334333 }
335334
336335 ret = crossover_output_pin_init (mod );
337336 if (ret < 0 ) {
338337 comp_err (dev , "crossover_init_output_pins() failed." );
339- goto cd_fail ;
338+ return ret ;
340339 }
341340
342- crossover_reset_state (cd );
341+ crossover_reset_state (mod , cd );
343342 return 0 ;
344-
345- cd_fail :
346- comp_data_blob_handler_free (cd -> model_handler );
347- rfree (cd );
348- return ret ;
349343}
350344
351345/**
@@ -357,11 +351,8 @@ static int crossover_free(struct processing_module *mod)
357351
358352 comp_info (mod -> dev , "crossover_free()" );
359353
360- comp_data_blob_handler_free (cd -> model_handler );
361-
362- crossover_reset_state (cd );
354+ crossover_reset_state (mod , cd );
363355
364- rfree (cd );
365356 return 0 ;
366357}
367358
@@ -616,7 +607,7 @@ static int crossover_reset(struct processing_module *mod)
616607
617608 comp_info (mod -> dev , "crossover_reset()" );
618609
619- crossover_reset_state (cd );
610+ crossover_reset_state (mod , cd );
620611
621612 cd -> crossover_process = NULL ;
622613 cd -> crossover_split = NULL ;
0 commit comments