1515#include <sof/ipc/topology.h>
1616#include <rtos/interrupt.h>
1717#include <rtos/timer.h>
18- #include <rtos/alloc.h>
1918#include <rtos/cache.h>
2019#include <rtos/init.h>
2120#include <sof/lib/memory.h>
@@ -82,13 +81,12 @@ static void mic_privacy_event(void *arg, enum notify_id type, void *data)
8281 }
8382}
8483
85- static int mic_privacy_configure (struct comp_dev * dev , struct copier_data * cd )
84+ static int mic_privacy_configure (struct processing_module * mod , struct copier_data * cd )
8685{
8786 struct mic_privacy_data * mic_priv_data ;
8887 int ret ;
8988
90- mic_priv_data = rzalloc (SOF_MEM_FLAG_USER ,
91- sizeof (struct mic_privacy_data ));
89+ mic_priv_data = mod_zalloc (mod , sizeof (struct mic_privacy_data ));
9290 if (!mic_priv_data )
9391 return - ENOMEM ;
9492
@@ -100,31 +98,34 @@ static int mic_privacy_configure(struct comp_dev *dev, struct copier_data *cd)
10098 uint32_t zeroing_wait_time = (mic_privacy_get_dma_zeroing_wait_time () * 1000 ) /
10199 ADSP_RTC_FREQUENCY ;
102100
103- ret = copier_gain_set_params (dev , & mic_priv_data -> mic_priv_gain_params ,
101+ ret = copier_gain_set_params (mod -> dev , & mic_priv_data -> mic_priv_gain_params ,
104102 zeroing_wait_time , SOF_DAI_INTEL_NONE );
105103 if (ret != 0 ) {
106- rfree ( mic_priv_data );
104+ mod_free ( mod , mic_priv_data );
107105 return ret ;
108106 }
109107
110108 cd -> mic_priv = mic_priv_data ;
111109
112110 ret = notifier_register (cd -> mic_priv , NULL , NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE ,
113111 mic_privacy_event , 0 );
112+
114113 if (ret != 0 )
115- rfree ( mic_priv_data );
114+ mod_free ( mod , mic_priv_data );
116115
117116 return ret ;
118117}
119118
120- static void mic_privacy_free (struct copier_data * cd )
119+ static void mic_privacy_free (struct processing_module * mod )
121120{
121+ struct copier_data * cd = module_get_private_data (mod );
122+
122123 if (cd -> gtw_type == ipc4_gtw_dmic )
123124 mic_privacy_enable_dmic_irq (false);
124125
125126 notifier_unregister (cd -> mic_priv , NULL , NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE );
126127
127- rfree ( cd -> mic_priv );
128+ mod_free ( mod , cd -> mic_priv );
128129}
129130#endif
130131
@@ -141,7 +142,7 @@ __cold static int copier_init(struct processing_module *mod)
141142
142143 assert_can_be_cold ();
143144
144- cd = rzalloc ( SOF_MEM_FLAG_USER , sizeof (* cd ));
145+ cd = mod_zalloc ( mod , sizeof (* cd ));
145146 if (!cd )
146147 return - ENOMEM ;
147148
@@ -163,8 +164,7 @@ __cold static int copier_init(struct processing_module *mod)
163164 */
164165 if (copier -> gtw_cfg .config_length ) {
165166 gtw_cfg_size = copier -> gtw_cfg .config_length << 2 ;
166- gtw_cfg = rmalloc (SOF_MEM_FLAG_USER ,
167- gtw_cfg_size );
167+ gtw_cfg = mod_alloc (mod , gtw_cfg_size );
168168 if (!gtw_cfg ) {
169169 ret = - ENOMEM ;
170170 goto error_cd ;
@@ -191,15 +191,15 @@ __cold static int copier_init(struct processing_module *mod)
191191 switch (node_id .f .dma_type ) {
192192 case ipc4_hda_host_output_class :
193193 case ipc4_hda_host_input_class :
194- ret = copier_host_create (dev , cd , copier , dev -> pipeline );
194+ ret = copier_host_create (mod , copier , dev -> pipeline );
195195 if (ret < 0 ) {
196196 comp_err (dev , "unable to create host" );
197197 goto error ;
198198 }
199199#if CONFIG_INTEL_ADSP_MIC_PRIVACY
200200 if (cd -> direction == SOF_IPC_STREAM_CAPTURE &&
201201 node_id .f .dma_type == ipc4_hda_host_output_class ) {
202- ret = mic_privacy_configure (dev , cd );
202+ ret = mic_privacy_configure (mod , cd );
203203 if (ret < 0 ) {
204204 comp_err (dev , "unable to configure mic privacy" );
205205 goto error ;
@@ -221,7 +221,7 @@ __cold static int copier_init(struct processing_module *mod)
221221 }
222222#if CONFIG_INTEL_ADSP_MIC_PRIVACY
223223 if (cd -> direction == SOF_IPC_STREAM_CAPTURE ) {
224- ret = mic_privacy_configure (dev , cd );
224+ ret = mic_privacy_configure (mod , cd );
225225 if (ret < 0 ) {
226226 comp_err (dev , "unable to configure mic privacy" );
227227 goto error ;
@@ -232,7 +232,7 @@ __cold static int copier_init(struct processing_module *mod)
232232#if CONFIG_IPC4_GATEWAY
233233 case ipc4_ipc_output_class :
234234 case ipc4_ipc_input_class :
235- ret = copier_ipcgtw_create (dev , cd , copier , dev -> pipeline );
235+ ret = copier_ipcgtw_create (mod , copier , dev -> pipeline );
236236 if (ret < 0 ) {
237237 comp_err (dev , "unable to create IPC gateway" );
238238 goto error ;
@@ -257,9 +257,9 @@ __cold static int copier_init(struct processing_module *mod)
257257 dev -> state = COMP_STATE_READY ;
258258 return 0 ;
259259error :
260- rfree ( gtw_cfg );
260+ mod_free ( mod , gtw_cfg );
261261error_cd :
262- rfree ( cd );
262+ mod_free ( mod , cd );
263263 return ret ;
264264}
265265
@@ -271,16 +271,16 @@ __cold static int copier_free(struct processing_module *mod)
271271 assert_can_be_cold ();
272272
273273#if CONFIG_INTEL_ADSP_MIC_PRIVACY
274- mic_privacy_free (cd );
274+ mic_privacy_free (mod );
275275#endif
276276
277277 switch (dev -> ipc_config .type ) {
278278 case SOF_COMP_HOST :
279279 if (!cd -> ipc_gtw )
280- copier_host_free (cd );
280+ copier_host_free (mod );
281281 else
282282 /* handle gtw case */
283- copier_ipcgtw_free (cd );
283+ copier_ipcgtw_free (mod );
284284 break ;
285285 case SOF_COMP_DAI :
286286 copier_dai_free (cd );
@@ -290,8 +290,8 @@ __cold static int copier_free(struct processing_module *mod)
290290 }
291291
292292 if (cd )
293- rfree ( cd -> gtw_cfg );
294- rfree ( cd );
293+ mod_free ( mod , cd -> gtw_cfg );
294+ mod_free ( mod , cd );
295295
296296 return 0 ;
297297}
0 commit comments