Skip to content

Commit 6a50158

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 and the device period for LL modules for valid period frames calculation. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent ec32333 commit 6a50158

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

src/audio/module_adapter/module_adapter.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,13 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv,
132132
/* set the pipeline pointer if ipc_pipe is valid */
133133
ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, config->pipeline_id,
134134
IPC_COMP_IGNORE_REMOTE);
135-
if (ipc_pipe)
135+
if (ipc_pipe) {
136136
dev->pipeline = ipc_pipe->pipeline;
137+
138+
/* LL modules have the same period as the pipeline */
139+
if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_LL)
140+
dev->period = ipc_pipe->pipeline->period;
141+
}
137142
#endif
138143

139144
/* Init processing module */
@@ -166,6 +171,9 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv,
166171
comp_err(dev, "%d: module params failed", ret);
167172
goto err;
168173
}
174+
175+
/* set component period frames */
176+
component_set_nearest_period_frames(dev, params.rate);
169177
#endif
170178

171179
comp_dbg(dev, "done");
@@ -226,11 +234,7 @@ int module_adapter_prepare(struct comp_dev *dev)
226234

227235
comp_dbg(dev, "start");
228236
#if CONFIG_IPC_MAJOR_4
229-
/*
230-
* if the stream_params are valid, just update the sink/source buffer params. If not,
231-
* retrieve the params from the basecfg, allocate stream_params and then update the
232-
* sink/source buffer params.
233-
*/
237+
/* allocate stream_params and retrieve the params from the basecfg if needed */
234238
if (!mod->stream_params) {
235239
struct sof_ipc_stream_params params;
236240

@@ -239,12 +243,6 @@ int module_adapter_prepare(struct comp_dev *dev)
239243
comp_err(dev, "module_adapter_new() %d: module params failed", ret);
240244
return ret;
241245
}
242-
} else {
243-
ret = comp_verify_params(dev, mod->verify_params_flags, mod->stream_params);
244-
if (ret < 0) {
245-
comp_err(dev, "comp_verify_params() failed.");
246-
return ret;
247-
}
248246
}
249247
#endif
250248
/* Prepare module */
@@ -535,11 +533,13 @@ int module_adapter_params(struct comp_dev *dev, struct sof_ipc_stream_params *pa
535533

536534
module_adapter_set_params(mod, params);
537535

536+
#if CONFIG_IPC_MAJOR_3
538537
ret = comp_verify_params(dev, mod->verify_params_flags, params);
539538
if (ret < 0) {
540539
comp_err(dev, "comp_verify_params() failed.");
541540
return ret;
542541
}
542+
#endif
543543

544544
/* allocate stream_params each time */
545545
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)