Skip to content

Commit e891b75

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 491bc1c commit e891b75

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
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 */
@@ -523,11 +516,13 @@ int module_adapter_params(struct comp_dev *dev, struct sof_ipc_stream_params *pa
523516

524517
module_adapter_set_params(mod, params);
525518

519+
#if CONFIG_IPC_MAJOR_3
526520
ret = comp_verify_params(dev, mod->verify_params_flags, params);
527521
if (ret < 0) {
528522
comp_err(dev, "comp_verify_params() failed.");
529523
return ret;
530524
}
525+
#endif
531526

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

src/ipc/ipc4/helper.c

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

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);
690+
691+
buffer_set_params(buffer, srcmod->stream_params, BUFFER_UPDATE_FORCE);
692+
}
693+
694+
if (sink->direction == SOF_IPC_STREAM_CAPTURE &&
695+
sink->drv->type == SOF_COMP_MODULE_ADAPTER) {
696+
struct processing_module *sinkmod = comp_mod(sink);
697+
698+
buffer_set_params(buffer, sinkmod->stream_params, BUFFER_UPDATE_FORCE);
699+
}
700+
686701
ll_unblock(cross_core_bind, flags);
687702

688703
return IPC4_SUCCESS;

0 commit comments

Comments
 (0)