Skip to content

Commit a29aff0

Browse files
committed
audio: module_adapter: Remove use of comp_verify_params for IPC4
comp_verify_params does 3 things, update comp params based on buffer flags, then set buffer params based on comp params and then finally set the component period frames based on buffer frames. In the case of IPC4, buffer flags are unused, so there's no need to update comp params based on these flags. So, move the setting of buffer params during the modules binding call where the buffers are allocated. Finally, set the component period frames based on the module's params during module init. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent aeda792 commit a29aff0

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

src/audio/module_adapter/module_adapter.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv,
171171
comp_err(dev, "%d: module params failed", ret);
172172
goto err;
173173
}
174+
175+
/* set component period frames */
176+
component_set_nearest_period_frames(dev, params.rate);
174177
#endif
175178

176179
comp_dbg(dev, "done");
@@ -231,11 +234,7 @@ int module_adapter_prepare(struct comp_dev *dev)
231234

232235
comp_dbg(dev, "start");
233236
#if CONFIG_IPC_MAJOR_4
234-
/*
235-
* if the stream_params are valid, just update the sink/source buffer params. If not,
236-
* retrieve the params from the basecfg, allocate stream_params and then update the
237-
* sink/source buffer params.
238-
*/
237+
/* allocate stream_params and retrieve the params from the basecfg if needed */
239238
if (!mod->stream_params) {
240239
struct sof_ipc_stream_params params;
241240

@@ -244,12 +243,6 @@ int module_adapter_prepare(struct comp_dev *dev)
244243
comp_err(dev, "module_adapter_new() %d: module params failed", ret);
245244
return ret;
246245
}
247-
} else {
248-
ret = comp_verify_params(dev, mod->verify_params_flags, mod->stream_params);
249-
if (ret < 0) {
250-
comp_err(dev, "comp_verify_params() failed.");
251-
return ret;
252-
}
253246
}
254247
#endif
255248
/* Prepare module */
@@ -540,11 +533,13 @@ int module_adapter_params(struct comp_dev *dev, struct sof_ipc_stream_params *pa
540533

541534
module_adapter_set_params(mod, params);
542535

536+
#if CONFIG_IPC_MAJOR_3
543537
ret = comp_verify_params(dev, mod->verify_params_flags, params);
544538
if (ret < 0) {
545539
comp_err(dev, "comp_verify_params() failed.");
546540
return ret;
547541
}
542+
#endif
548543

549544
/* allocate stream_params each time */
550545
if (mod->stream_params)

src/audio/module_adapter/module_adapter_ipc4.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,47 @@ static bool module_adapter_multi_sink_source_prepare(struct comp_dev *dev)
320320
return false;
321321
}
322322

323+
static int module_update_source_buffer_params(struct processing_module *mod,
324+
struct bind_info *bind_data)
325+
{
326+
struct module_config *dst = &mod->priv.cfg;
327+
struct sof_ipc_stream_params params;
328+
struct comp_buffer *buffer;
329+
int dst_queue_id = bind_data->ipc4_data->extension.r.dst_queue;
330+
331+
/* only update buffer params for sink components */
332+
if (bind_data->bind_type != COMP_BIND_TYPE_SOURCE)
333+
return 0;
334+
335+
comp_dev_for_each_producer(mod->dev, buffer) {
336+
if (IPC4_SINK_QUEUE_ID(buffer->stream.runtime_stream_params.id) != dst_queue_id)
337+
continue;
338+
339+
/* use base_cfg params for pin 0 or if base config extn is missing */
340+
if (!dst_queue_id || dst_queue_id >= dst->nb_input_pins) {
341+
buffer_set_params(buffer, mod->stream_params, BUFFER_UPDATE_FORCE);
342+
return 0;
343+
}
344+
345+
/* otherwise use the respective input pin audio format */
346+
ipc4_audio_format_to_stream_params(&dst->input_pins[dst_queue_id].audio_fmt,
347+
&params);
348+
buffer_set_params(buffer, &params, BUFFER_UPDATE_FORCE);
349+
return 0;
350+
}
351+
352+
return 0;
353+
}
354+
323355
int module_adapter_bind(struct comp_dev *dev, struct bind_info *bind_data)
324356
{
325357
struct processing_module *mod = comp_mod(dev);
326358
int ret;
327359

360+
ret = module_update_source_buffer_params(mod, bind_data);
361+
if (ret < 0)
362+
return ret;
363+
328364
ret = module_bind(mod, bind_data);
329365
if (ret < 0)
330366
return ret;

0 commit comments

Comments
 (0)