Skip to content

Commit 69f7374

Browse files
committed
src: audio: module_adapter: Do the params config right after init
The module_adapter_params() functions set the stream params based on the base config for each module which is available right after module init. So configure the params for IPC4 during module_new() and remove the call to ipc4_pipeline_params(). In order to update the buffer params, add a call to comp_verify_params() during module_bind when the intermediate buffers between modules are created. This should help with reducing the time to trigger pipelines during start. Add the params handling for the KPB module explicitly because it doesnt use the module adapter. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 60e7a0a commit 69f7374

File tree

5 files changed

+53
-51
lines changed

5 files changed

+53
-51
lines changed

src/audio/kpb.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ static int kpb_get_attribute(struct comp_dev *dev,
330330
return 0;
331331
}
332332

333+
static int kbp_verify_params(struct comp_dev *dev,
334+
struct sof_ipc_stream_params *params);
335+
333336
/**
334337
* \brief Initialize KPB sinks when binding.
335338
* \param[in] dev - component device pointer.
@@ -339,6 +342,7 @@ static int kpb_get_attribute(struct comp_dev *dev,
339342
static int kpb_bind(struct comp_dev *dev, struct bind_info *bind_data)
340343
{
341344
struct comp_data *kpb = comp_get_drvdata(dev);
345+
struct sof_ipc_stream_params params;
342346
struct ipc4_module_bind_unbind *bu;
343347
int buf_id;
344348
int ret = 0;
@@ -356,6 +360,7 @@ static int kpb_bind(struct comp_dev *dev, struct bind_info *bind_data)
356360
*/
357361
struct comp_buffer *sink;
358362

363+
kpb_set_params(dev, &params);
359364
comp_dev_for_each_consumer(dev, sink) {
360365
int sink_buf_id;
361366

@@ -372,6 +377,9 @@ static int kpb_bind(struct comp_dev *dev, struct bind_info *bind_data)
372377
else
373378
kpb->host_sink = sink;
374379
}
380+
381+
/* set buffer params based on the basecfg */
382+
buffer_set_params(sink, &params, BUFFER_UPDATE_FORCE);
375383
}
376384

377385
return ret;
@@ -453,6 +461,8 @@ static void kpb_set_params(struct comp_dev *dev,
453461
{}
454462
#endif /* CONFIG_IPC_MAJOR_4 */
455463

464+
static int kpb_params(struct comp_dev *dev, struct sof_ipc_stream_params *params);
465+
456466
/*
457467
* \brief Create a key phrase buffer component.
458468
* \param[in] config - generic ipc component pointer.
@@ -534,6 +544,17 @@ static struct comp_dev *kpb_new(const struct comp_driver *drv,
534544
dev->state = COMP_STATE_READY;
535545
kpb_change_state(kpb, KPB_STATE_CREATED);
536546

547+
#if CONFIG_IPC_MAJOR_4
548+
struct sof_ipc_stream_params params;
549+
550+
/* set params based on base config for IPC4 */
551+
ret = kpb_params(dev, &params);
552+
if (ret < 0) {
553+
rfree(dev);
554+
return NULL;
555+
}
556+
#endif
557+
537558
return dev;
538559
}
539560

src/audio/module_adapter/module_adapter.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ struct comp_dev *module_adapter_new(const struct comp_driver *drv,
123123

124124
dev->state = COMP_STATE_READY;
125125

126+
#if CONFIG_IPC_MAJOR_4
127+
struct sof_ipc_stream_params params = {{ 0 }};
128+
129+
/* set the stream params based on the module base cfg. It is OK to pass NULL params
130+
* here because it will be filled in based on the module base_cfg.
131+
*/
132+
ret = module_adapter_params(dev, &params);
133+
if (ret) {
134+
comp_err(dev, "module_adapter_new() %d: module params failed", ret);
135+
goto err;
136+
}
137+
#endif
138+
126139
comp_dbg(dev, "module_adapter_new() done");
127140
return dev;
128141
err:
@@ -1185,9 +1198,10 @@ int module_adapter_reset(struct comp_dev *dev)
11851198
buffer_zero(buffer);
11861199
}
11871200

1201+
#if CONFIG_IPC_MAJOR_3
11881202
rfree(mod->stream_params);
11891203
mod->stream_params = NULL;
1190-
1204+
#endif
11911205
comp_dbg(dev, "module_adapter_reset(): done");
11921206

11931207
return comp_set_state(dev, COMP_TRIGGER_RESET);
@@ -1219,6 +1233,7 @@ void module_adapter_free(struct comp_dev *dev)
12191233

12201234
#if CONFIG_IPC_MAJOR_4
12211235
rfree(mod->priv.cfg.input_pins);
1236+
rfree(mod->stream_params);
12221237
#endif
12231238

12241239
rfree(mod);

src/audio/module_adapter/module_adapter_ipc4.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,12 @@ int module_adapter_bind(struct comp_dev *dev, struct bind_info *bind_data)
253253

254254
mod->stream_copy_single_to_single = !module_adapter_multi_sink_source_prepare(dev);
255255

256-
return 0;
256+
/* call comp_verify_params() to update the buffer params */
257+
ret = comp_verify_params(dev, mod->verify_params_flags, mod->stream_params);
258+
if (ret < 0)
259+
comp_err(dev, "module_adapter_bind(): comp_verify_params() failed.");
260+
261+
return ret;
257262
}
258263
EXPORT_SYMBOL(module_adapter_bind);
259264

src/ipc/ipc4/handler.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -155,46 +155,6 @@ __cold static int ipc4_delete_pipeline(struct ipc4_message_request *ipc4)
155155
return ipc_pipeline_free(ipc, pipe->primary.r.instance_id);
156156
}
157157

158-
static int ipc4_comp_params(struct comp_dev *current,
159-
struct comp_buffer *calling_buf,
160-
struct pipeline_walk_context *ctx, int dir)
161-
{
162-
struct pipeline_data *ppl_data = ctx->comp_data;
163-
int err;
164-
165-
/* don't do any params if current is running */
166-
if (current->state == COMP_STATE_ACTIVE)
167-
return 0;
168-
169-
/* Stay on the current pipeline */
170-
if (current->pipeline != ((struct pipeline_data *)ctx->comp_data)->p)
171-
return 0;
172-
173-
err = comp_params(current, &ppl_data->params->params);
174-
if (err < 0 || err == PPL_STATUS_PATH_STOP)
175-
return err;
176-
177-
return pipeline_for_each_comp(current, ctx, dir);
178-
}
179-
180-
static int ipc4_pipeline_params(struct pipeline *p, struct comp_dev *host)
181-
{
182-
struct sof_ipc_pcm_params hw_params = {{ 0 }};
183-
struct pipeline_data data = {
184-
.start = host,
185-
.params = &hw_params,
186-
.p = p,
187-
};
188-
189-
struct pipeline_walk_context param_ctx = {
190-
.comp_func = ipc4_comp_params,
191-
.comp_data = &data,
192-
.skip_incomplete = true,
193-
};
194-
195-
return param_ctx.comp_func(host, NULL, &param_ctx, host->direction);
196-
}
197-
198158
static int ipc4_pcm_params(struct ipc_comp_dev *pcm_dev)
199159
{
200160
int err, reset_err;
@@ -205,15 +165,6 @@ static int ipc4_pcm_params(struct ipc_comp_dev *pcm_dev)
205165
return -EINVAL;
206166
}
207167

208-
/* configure pipeline audio params */
209-
err = ipc4_pipeline_params(pcm_dev->cd->pipeline, pcm_dev->cd);
210-
if (err < 0) {
211-
ipc_cmd_err(&ipc_tr, "ipc: pipe %d comp %d params failed %d",
212-
pcm_dev->cd->pipeline->pipeline_id,
213-
pcm_dev->cd->pipeline->comp_id, err);
214-
goto error;
215-
}
216-
217168
/* prepare pipeline audio params */
218169
err = pipeline_prepare(pcm_dev->cd->pipeline, pcm_dev->cd);
219170
if (err < 0) {

src/samples/audio/detect_test.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,16 @@ static struct comp_dev *test_keyword_new(const struct comp_driver *drv,
749749
dev->direction = SOF_IPC_STREAM_CAPTURE;
750750
dev->direction_set = true;
751751
dev->state = COMP_STATE_READY;
752+
753+
#if CONFIG_IPC_MAJOR_4
754+
struct sof_ipc_stream_params params;
755+
756+
/* set params based on base config for IPC4 */
757+
ret = test_keyword_params(dev, &params);
758+
if (ret < 0)
759+
goto cd_fail;
760+
#endif
761+
752762
return dev;
753763

754764
cd_fail:

0 commit comments

Comments
 (0)