Skip to content

Commit 7ab8fd7

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 4d898ff commit 7ab8fd7

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

src/audio/module_adapter/module_adapter.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv,
155155
comp_err(dev, "%d: module params failed", ret);
156156
goto err;
157157
}
158+
159+
/* set component period frames */
160+
component_set_nearest_period_frames(dev, params.rate);
158161
#endif
159162

160163
comp_dbg(dev, "done");
@@ -215,11 +218,7 @@ int module_adapter_prepare(struct comp_dev *dev)
215218

216219
comp_dbg(dev, "start");
217220
#if CONFIG_IPC_MAJOR_4
218-
/*
219-
* if the stream_params are valid, just update the sink/source buffer params. If not,
220-
* retrieve the params from the basecfg, allocate stream_params and then update the
221-
* sink/source buffer params.
222-
*/
221+
/* allocate stream_params and retrieve the params from the basecfg if needed */
223222
if (!mod->stream_params) {
224223
struct sof_ipc_stream_params params;
225224

@@ -228,12 +227,6 @@ int module_adapter_prepare(struct comp_dev *dev)
228227
comp_err(dev, "module_adapter_new() %d: module params failed", ret);
229228
return ret;
230229
}
231-
} else {
232-
ret = comp_verify_params(dev, mod->verify_params_flags, mod->stream_params);
233-
if (ret < 0) {
234-
comp_err(dev, "comp_verify_params() failed.");
235-
return ret;
236-
}
237230
}
238231
#endif
239232
/* Prepare module */
@@ -524,11 +517,13 @@ int module_adapter_params(struct comp_dev *dev, struct sof_ipc_stream_params *pa
524517

525518
module_adapter_set_params(mod, params);
526519

520+
#if CONFIG_IPC_MAJOR_3
527521
ret = comp_verify_params(dev, mod->verify_params_flags, params);
528522
if (ret < 0) {
529523
comp_err(dev, "comp_verify_params() failed.");
530524
return ret;
531525
}
526+
#endif
532527

533528
/* allocate stream_params each time */
534529
if (mod->stream_params)

src/ipc/ipc4/helper.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,31 @@ __cold int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect)
683683
source->direction_set = true;
684684
}
685685

686-
ll_unblock(cross_core_bind, flags);
686+
/* set sink buffer params for playback and source buffer params for capture */
687+
if (source->direction == SOF_IPC_STREAM_PLAYBACK &&
688+
source->drv->type == SOF_COMP_MODULE_ADAPTER) {
689+
struct processing_module *srcmod = comp_mod(source);
687690

688-
return IPC4_SUCCESS;
691+
buffer_set_params(buffer, srcmod->stream_params, BUFFER_UPDATE_FORCE);
692+
goto out;
693+
}
694+
695+
if (sink->direction == SOF_IPC_STREAM_CAPTURE &&
696+
sink->drv->type == SOF_COMP_MODULE_ADAPTER) {
697+
struct processing_module *sinkmod = comp_mod(sink);
698+
699+
buffer_set_params(buffer, sinkmod->stream_params, BUFFER_UPDATE_FORCE);
700+
}
701+
702+
out:
703+
if (audio_buffer_hw_params_configured(&buffer->audio_buffer)) {
704+
ll_unblock(cross_core_bind, flags);
705+
706+
return IPC4_SUCCESS;
707+
}
708+
709+
tr_err(&ipc_tr, "failed to set buffer params while binding source: %d and sink: %d",
710+
src_id, sink_id);
689711

690712
e_sink_bind:
691713
/* sink bind was already called */

0 commit comments

Comments
 (0)