Skip to content

Commit b90b7ae

Browse files
marcinszkudlinskilgirdwood
authored andcommitted
buf: extend module bind call API_CALL
Currently bind api call passes IPC4 header only. This commit extends API by adding pointers to sink/source of the entity that is being bound. Note that in pipeline 2.0 there's a possibility to bind a module to a module, therefore pointers to sink/src need to be provided instead of a pointer to a buffer Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent 92ae7d8 commit b90b7ae

13 files changed

Lines changed: 69 additions & 30 deletions

File tree

src/audio/copier/copier.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,9 +1173,9 @@ __cold static int copier_get_hw_params(struct comp_dev *dev, struct sof_ipc_stre
11731173
return dai_common_get_hw_params(dd, dev, params, dir);
11741174
}
11751175

1176-
__cold static int copier_bind(struct processing_module *mod, void *data)
1176+
__cold static int copier_bind(struct processing_module *mod, struct bind_info *bind_data)
11771177
{
1178-
const struct ipc4_module_bind_unbind *const bu = (struct ipc4_module_bind_unbind *)data;
1178+
const struct ipc4_module_bind_unbind *const bu = bind_data->ipc4_data;
11791179
const uint32_t src_id = IPC4_COMP_ID(bu->primary.r.module_id, bu->primary.r.instance_id);
11801180
const uint32_t src_queue_id = bu->extension.r.src_queue;
11811181
struct copier_data *cd = module_get_private_data(mod);

src/audio/kpb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ static int kpb_get_attribute(struct comp_dev *dev,
333333
/**
334334
* \brief Initialize KPB sinks when binding.
335335
* \param[in] dev - component device pointer.
336-
* \param[in] data - ipc4 bind/unbind data.
336+
* \param[in] bind_data - bind/unbind data.
337337
* \return: none.
338338
*/
339-
static int kpb_bind(struct comp_dev *dev, void *data)
339+
static int kpb_bind(struct comp_dev *dev, struct bind_info *bind_data)
340340
{
341341
struct comp_data *kpb = comp_get_drvdata(dev);
342342
struct ipc4_module_bind_unbind *bu;
@@ -345,7 +345,7 @@ static int kpb_bind(struct comp_dev *dev, void *data)
345345

346346
comp_dbg(dev, "kpb_bind()");
347347

348-
bu = (struct ipc4_module_bind_unbind *)data;
348+
bu = bind_data->ipc4_data;
349349
buf_id = IPC4_COMP_ID(bu->extension.r.src_queue, bu->extension.r.dst_queue);
350350

351351
/* We're assuming here that KPB Real Time sink (kpb->sel_sink) is

src/audio/mixin_mixout/mixin_mixout.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -784,17 +784,15 @@ static int mixout_prepare(struct processing_module *mod,
784784
return 0;
785785
}
786786

787-
static int mixout_bind(struct processing_module *mod, void *data)
787+
static int mixout_bind(struct processing_module *mod, struct bind_info *bind_data)
788788
{
789789
struct ipc4_module_bind_unbind *bu;
790790
struct comp_dev *mixin;
791791
struct pending_frames *pending_frames;
792792
int src_id;
793793
struct mixout_data *mixout_data;
794794

795-
comp_dbg(mod->dev, "mixout_bind() %p", data);
796-
797-
bu = (struct ipc4_module_bind_unbind *)data;
795+
bu = bind_data->ipc4_data;
798796
src_id = IPC4_COMP_ID(bu->primary.r.module_id, bu->primary.r.instance_id);
799797

800798
/* we are only interested in bind for mixin -> mixout pair */

src/audio/module_adapter/module/generic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,12 @@ int module_set_configuration(struct processing_module *mod,
493493
}
494494
EXPORT_SYMBOL(module_set_configuration);
495495

496-
int module_bind(struct processing_module *mod, void *data)
496+
int module_bind(struct processing_module *mod, struct bind_info *bind_data)
497497
{
498498
const struct module_interface *const ops = mod->dev->drv->adapter_ops;
499499

500500
if (ops->bind)
501-
return ops->bind(mod, data);
501+
return ops->bind(mod, bind_data);
502502
return 0;
503503
}
504504

src/audio/module_adapter/module_adapter_ipc4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ static bool module_adapter_multi_sink_source_prepare(struct comp_dev *dev)
242242
return false;
243243
}
244244

245-
int module_adapter_bind(struct comp_dev *dev, void *data)
245+
int module_adapter_bind(struct comp_dev *dev, struct bind_info *bind_data)
246246
{
247247
struct processing_module *mod = comp_mod(dev);
248248
int ret;
249249

250-
ret = module_bind(mod, data);
250+
ret = module_bind(mod, bind_data);
251251
if (ret < 0)
252252
return ret;
253253

src/debug/tester/tester.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ static int tester_free(struct processing_module *mod)
188188
return ret;
189189
}
190190

191-
static int tester_bind(struct processing_module *mod, void *data)
191+
static int tester_bind(struct processing_module *mod, struct bind_info *bind_data)
192192
{
193193
struct tester_module_data *cd = module_get_private_data(mod);
194194
int ret = 0;
195195

196196
if (cd->tester_case_interface->bind)
197-
ret = cd->tester_case_interface->bind(cd->test_case_ctx, mod, data);
197+
ret = cd->tester_case_interface->bind(cd->test_case_ctx, mod, bind_data);
198198

199199
return ret;
200200
}

src/debug/tester/tester.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct tester_test_case_interface {
7575
/**
7676
* copy of module bind method, with additional ctx param
7777
*/
78-
int (*bind)(void *ctx, struct processing_module *mod, void *data);
78+
int (*bind)(void *ctx, struct processing_module *mod, struct bind_info *bind_data);
7979

8080
/**
8181
* copy of module unbind method, with additional ctx param

src/idc/idc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ static int idc_ipc4_bind(uint32_t comp_id)
8686
{
8787
struct ipc_comp_dev *ipc_dev;
8888
struct idc_payload *payload;
89-
struct ipc4_module_bind_unbind *bu;
89+
struct bind_info *bu;
9090

9191
ipc_dev = ipc_get_comp_by_id(ipc_get(), comp_id);
9292
if (!ipc_dev)
9393
return -ENODEV;
9494

9595
payload = idc_payload_get(*idc_get(), cpu_get_id());
96-
bu = (struct ipc4_module_bind_unbind *)payload;
96+
bu = (struct bind_info *)payload;
9797

9898
return comp_bind(ipc_dev->cd, bu);
9999
}

src/include/module/module/interface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct output_stream_buffer {
6565
struct processing_module;
6666
struct sof_source;
6767
struct sof_sink;
68+
struct bind_info;
6869

6970
/*
7071
* This structure may be used by modules to carry short 16bit parameters.
@@ -266,7 +267,7 @@ struct module_interface {
266267
* (optional) Module specific bind procedure, called when modules are bound with each other.
267268
* Usually can be __cold
268269
*/
269-
int (*bind)(struct processing_module *mod, void *data);
270+
int (*bind)(struct processing_module *mod, struct bind_info *bind_data);
270271

271272
/**
272273
* (optional) Module specific unbind procedure, called when modules are disconnected from

src/include/sof/audio/component.h

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,40 @@ enum comp_copy_type {
271271
struct comp_driver;
272272
struct comp_ipc_config;
273273
union ipc_config_specific;
274+
struct ipc4_module_bind_unbind;
275+
276+
enum bind_type {
277+
COMP_BIND_TYPE_SOURCE,
278+
COMP_BIND_TYPE_SINK
279+
};
280+
281+
struct bind_info {
282+
/* pointer to IPC4 bind data */
283+
struct ipc4_module_bind_unbind *ipc4_data;
284+
285+
/* type of binding
286+
* bind call will be called twice for every component, first when binding a data source,
287+
* than when binding data sink.
288+
*
289+
* bind_type is indicating type of binding
290+
*/
291+
enum bind_type bind_type;
292+
293+
/* pointers to sink or source API of the data provider/consumer
294+
* that is being bound to the module
295+
*
296+
* if bind_type == COMP_BIND_TYPE_SOURCE, the pointer below points to source
297+
* if bind_type == COMP_BIND_TYPE_SINK, the pointer below points to sink
298+
*
299+
* NOTE! As in pipeline2.0 there may be a binding between modules,
300+
* without a buffer in between, it cannot be a pointer to any buffer type, module should
301+
* use sink/source API
302+
*/
303+
union {
304+
struct sof_source *source;
305+
struct sof_sink *sink;
306+
};
307+
};
274308

275309
/**
276310
* Audio component operations.
@@ -481,7 +515,7 @@ struct comp_ops {
481515
*
482516
* Usually can be __cold.
483517
*/
484-
int (*bind)(struct comp_dev *dev, void *data);
518+
int (*bind)(struct comp_dev *dev, struct bind_info *bind_data);
485519

486520
/**
487521
* Unbind, atomic - used to notify component of unbind event.

0 commit comments

Comments
 (0)