Skip to content

Commit 4f9b3ff

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. Also, modify the allocation of the stream_params for the module to include the SOF_MEM_FLAG_COHERENT flag to make sure that the memory is coherent across cores when the stream_params are accessed during the bind operation. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent a05cb2f commit 4f9b3ff

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

src/audio/module_adapter/module_adapter.c

Lines changed: 7 additions & 12 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,17 +517,19 @@ 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)
535530
rfree(mod->stream_params);
536531

537-
mod->stream_params = rzalloc(SOF_MEM_FLAG_USER,
532+
mod->stream_params = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
538533
sizeof(*mod->stream_params) + params->ext_data_length);
539534
if (!mod->stream_params)
540535
return -ENOMEM;

src/ipc/ipc4/helper.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,23 @@ __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+
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:
686703
ll_unblock(cross_core_bind, flags);
687704

688705
return IPC4_SUCCESS;

0 commit comments

Comments
 (0)