@@ -78,10 +78,6 @@ static __aligned(PLATFORM_DCACHE_ALIGN)
7878float micbuf [CHAN_MAX ][NUM_FRAMES ];
7979
8080struct google_rtc_audio_processing_comp_data {
81- #ifdef CONFIG_IPC_MAJOR_4
82- struct ipc4_audio_format in_fmts [2 ];
83- struct ipc4_audio_format out_fmt ;
84- #endif
8581 uint32_t num_frames ;
8682 int num_aec_reference_channels ;
8783 int num_capture_channels ;
@@ -112,110 +108,6 @@ void GoogleRtcFree(void *ptr)
112108 return rfree (ptr );
113109}
114110
115- #ifdef CONFIG_IPC_MAJOR_4
116- /* Workaround: IPC4 fails to set up stream metadata on the buffer
117- * objects at pipeline creation time, and traditionally components
118- * have been responsible for doing this. The way this works is that
119- * during the init() call, we cache the relevant ipc4_audio_format
120- * records from the module "extended config" (which is untyped
121- * byte-packed data, I think it's raw bytes from the host?) that
122- * correspond to our connected streams. This config struct gets freed
123- * after initialization, so it has to be done then.
124- *
125- * Then at prepare time, we must use ipc4_update_source/sink_format()
126- * to set values on the (incompletely initialized) streams.
127- * Similarly, we have to call audio_stream_init_alignment_constants(),
128- * otherwise needed values on the audio stream remain uninitialized.
129- *
130- * It's not really documented what happens if our settings disagree
131- * with the component on the other side of the buffer! Presumably
132- * that would be a fatal topology bug, but nothing is set up to detect
133- * it. In fact in practice most other components DON'T do this, so
134- * our settings win (and thus we must do this, or else the rest of the
135- * stream sees garbage and misbehaves, generally with buffer overruns
136- * or short reads).
137- *
138- * Finally, there is somewhat... unique handling needed to get correct
139- * IBS/OBS buffer sizing. We have two inputs with different stream
140- * formats, and thus different minimum block sizes. The "base" module
141- * config only has space for one IBS value. So the pipeline code has
142- * an "extended" config with separate IBS per pin, but it will only
143- * use it if it knows about it, which it doesn't by default because
144- * module initialization throws away the data! So it falls to us to
145- * duplicate a copy and store it ourselves, in a separate field from
146- * where we found it.
147- */
148- static int init_ipc4_fmts (struct processing_module * mod )
149- {
150- int i ;
151- struct google_rtc_audio_processing_comp_data * cd = module_get_private_data (mod );
152- const struct ipc4_base_module_extended_cfg * bmec = mod -> priv .cfg .init_data ;
153- const struct ipc4_input_pin_format * ipf ;
154- const struct ipc4_output_pin_format * opf ;
155- const struct ipc4_base_module_cfg_ext * bce ;
156-
157- if (!bmec )
158- return - EINVAL ;
159-
160- bce = & bmec -> base_cfg_ext ;
161- if (bce -> nb_input_pins != 2 && bce -> nb_output_pins != 1 ) {
162- comp_err (mod -> dev , "Must have 2 input, 1 output pins" );
163- return - EINVAL ;
164- }
165-
166- ipf = (void * )& bce -> pin_formats [0 ];
167- for (i = 0 ; i < bce -> nb_input_pins ; i ++ , ipf ++ ) {
168- if (ipf -> pin_index < 0 || ipf -> pin_index >= 2 ) {
169- comp_err (mod -> dev , "Incorrect input pin index %d" , ipf -> pin_index );
170- return - EINVAL ;
171- }
172- cd -> in_fmts [ipf -> pin_index ] = ipf -> audio_fmt ;
173- }
174-
175- opf = (void * )ipf ;
176- if (opf -> pin_index != 0 ) {
177- comp_err (mod -> dev , "Incorrect output pin index %d\n" , opf -> pin_index );
178- return - EINVAL ;
179- }
180- cd -> out_fmt = opf -> audio_fmt ;
181-
182- size_t bcesz = sizeof (* bce ) + (bce -> nb_input_pins * sizeof (* ipf )
183- + bce -> nb_output_pins * sizeof (* opf ));
184- void * bcedup = rzalloc (SOF_MEM_ZONE_RUNTIME , 0 , SOF_MEM_CAPS_RAM , bcesz );
185-
186- if (!bcedup )
187- return - ENOMEM ;
188- memcpy (bcedup , bce , bcesz );
189- mod -> priv .cfg .basecfg_ext = bcedup ;
190-
191- return 0 ;
192- }
193-
194- static void prepare_ipc4_fmts (struct processing_module * mod ,
195- struct sof_source * * sources ,
196- struct sof_sink * * sinks )
197- {
198- struct google_rtc_audio_processing_comp_data * cd = module_get_private_data (mod );
199-
200- /* FIXME: The "pin" index (the value of the pin_index field of
201- * the ipc4_in/output_pin_format structs seen in module config
202- * at init() time) and the "source" index (the ordering of the
203- * sources[] argument to prepare()/process()) ARE PRESENTED
204- * BACKWARDS! And I don't see any API to tell me which is
205- * which (note that the ordering of the connected buffers in
206- * the comp_dev sink/source lists is a THIRD convention, and
207- * matches sources[]/sinks[]).
208- */
209- ipc4_update_source_format (sources [0 ], & cd -> in_fmts [1 ]);
210- ipc4_update_source_format (sources [1 ], & cd -> in_fmts [0 ]);
211- ipc4_update_sink_format (sinks [0 ], & cd -> out_fmt );
212-
213- source_set_alignment_constants (sources [0 ], 1 , 1 );
214- source_set_alignment_constants (sources [1 ], 1 , 1 );
215- sink_set_alignment_constants (sinks [0 ], 1 , 1 );
216- }
217- #endif
218-
219111static ALWAYS_INLINE float s16_to_float (const char * ptr )
220112{
221113 float scale = - (float )SHRT_MIN ;
@@ -623,12 +515,6 @@ static int google_rtc_audio_processing_init(struct processing_module *mod)
623515
624516 md -> private = cd ;
625517
626- #ifdef CONFIG_IPC_MAJOR_4
627- ret = init_ipc4_fmts (mod ); /* workaround, see above */
628- if (ret < 0 )
629- goto fail ;
630- #endif
631-
632518 cd -> tuning_handler = comp_data_blob_handler_new (dev );
633519 if (!cd -> tuning_handler ) {
634520 ret = - ENOMEM ;
@@ -743,7 +629,7 @@ static int google_rtc_audio_processing_prepare(struct processing_module *mod,
743629 }
744630
745631#ifdef CONFIG_IPC_MAJOR_4
746- prepare_ipc4_fmts ( mod , sources , sinks ); /* Workaround, see above */
632+ ipc4_update_source_format ( sources [ 0 ], & mod -> priv . cfg . input_pins [ 1 ]. audio_fmt );
747633#endif
748634
749635 /* searching for stream and feedback source buffers */
0 commit comments