Skip to content

Commit 2845fc8

Browse files
ranj063lgirdwood
authored andcommitted
ipc4: helper: Use get_attribute instead of ipc4_comp_get_base_module_cfg
Add a new component attribute COMP_ATTR_BASE_CONFIG to retrieve the base config from the modules instead of using ipc4_comp_get_base_module_cfg(). Also, implement the get_attribute API for all the components that support IPC4. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent def800e commit 2845fc8

14 files changed

Lines changed: 152 additions & 34 deletions

File tree

‎src/audio/aria/aria.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,21 @@ static int aria_copy(struct comp_dev *dev)
335335
return 0;
336336
}
337337

338+
static int aria_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
339+
{
340+
struct aria_data *cd = comp_get_drvdata(dev);
341+
342+
switch (type) {
343+
case COMP_ATTR_BASE_CONFIG:
344+
*(struct ipc4_base_module_cfg *)value = cd->base;
345+
break;
346+
default:
347+
return -EINVAL;
348+
}
349+
350+
return 0;
351+
}
352+
338353
static const struct comp_driver comp_aria = {
339354
.uid = SOF_RT_UUID(aria_comp_uuid),
340355
.tctx = &aria_comp_tr,
@@ -345,6 +360,7 @@ static const struct comp_driver comp_aria = {
345360
.copy = aria_copy,
346361
.prepare = aria_prepare,
347362
.reset = aria_reset,
363+
.get_attribute = aria_get_attribute,
348364
},
349365
};
350366

‎src/audio/asrc/asrc.c‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ DECLARE_TR_CTX(asrc_tr, SOF_UUID(asrc_uuid), LOG_LEVEL_INFO);
7171
/* asrc component private data */
7272
struct comp_data {
7373
#if CONFIG_IPC_MAJOR_4
74-
/* Must be the 1st field, function ipc4_comp_get_base_module_cfg casts components
75-
* private data as ipc4_base_module_cfg!
76-
*/
7774
struct ipc4_asrc_module_cfg ipc_config;
7875
#else
7976
struct ipc_config_asrc ipc_config;
@@ -309,6 +306,21 @@ static inline bool asrc_get_asynchronous_mode(const struct ipc4_asrc_module_cfg
309306
{
310307
return false;
311308
}
309+
310+
static int asrc_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
311+
{
312+
struct comp_data *cd = comp_get_drvdata(dev);
313+
314+
switch (type) {
315+
case COMP_ATTR_BASE_CONFIG:
316+
*(struct ipc4_base_module_cfg *)value = cd->ipc_config.base;
317+
break;
318+
default:
319+
return -EINVAL;
320+
}
321+
322+
return 0;
323+
}
312324
#endif
313325

314326
static struct comp_dev *asrc_new(const struct comp_driver *drv,
@@ -1077,6 +1089,9 @@ static const struct comp_driver comp_asrc = {
10771089
.copy = asrc_copy,
10781090
.prepare = asrc_prepare,
10791091
.reset = asrc_reset,
1092+
#if CONFIG_IPC_MAJOR_4
1093+
.get_attribute = asrc_get_attribute,
1094+
#endif
10801095
},
10811096
};
10821097

‎src/audio/copier/copier.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,9 @@ static int copier_get_attribute(struct comp_dev *dev, uint32_t type, void *value
11951195
case COMP_ATTR_VDMA_INDEX:
11961196
*(uint32_t *)value = cd->config.gtw_cfg.node_id.f.v_index;
11971197
break;
1198+
case COMP_ATTR_BASE_CONFIG:
1199+
*(struct ipc4_base_module_cfg *)value = cd->config.base;
1200+
break;
11981201
default:
11991202
return -EINVAL;
12001203
}

‎src/audio/mixin_mixout.c‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,36 @@ static int mixout_unbind(struct comp_dev *dev, void *data)
990990
return 0;
991991
}
992992

993+
static int mixin_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
994+
{
995+
struct mixin_data *md = comp_get_drvdata(dev);
996+
997+
switch (type) {
998+
case COMP_ATTR_BASE_CONFIG:
999+
*(struct ipc4_base_module_cfg *)value = md->base_cfg;
1000+
break;
1001+
default:
1002+
return -EINVAL;
1003+
}
1004+
1005+
return 0;
1006+
}
1007+
1008+
static int mixout_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
1009+
{
1010+
struct mixout_data *md = comp_get_drvdata(dev);
1011+
1012+
switch (type) {
1013+
case COMP_ATTR_BASE_CONFIG:
1014+
*(struct ipc4_base_module_cfg *)value = md->base_cfg;
1015+
break;
1016+
default:
1017+
return -EINVAL;
1018+
}
1019+
1020+
return 0;
1021+
}
1022+
9931023
static const struct comp_driver comp_mixin = {
9941024
.uid = SOF_RT_UUID(mixin_uuid),
9951025
.tctx = &mixin_tr,
@@ -1001,6 +1031,7 @@ static const struct comp_driver comp_mixin = {
10011031
.trigger = mixinout_trigger,
10021032
.copy = mixin_copy,
10031033
.reset = mixin_reset,
1034+
.get_attribute = mixin_get_attribute,
10041035
},
10051036
};
10061037

@@ -1030,6 +1061,7 @@ static const struct comp_driver comp_mixout = {
10301061
.bind = mixout_bind,
10311062
.unbind = mixout_unbind,
10321063
.reset = mixout_reset,
1064+
.get_attribute = mixout_get_attribute,
10331065
},
10341066
};
10351067

‎src/audio/module_adapter/module_adapter.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,27 @@ int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_
963963
(uint8_t *)data, fragment_size);
964964
return 0;
965965
}
966+
967+
int module_adapter_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
968+
{
969+
struct processing_module *mod = comp_get_drvdata(dev);
970+
971+
switch (type) {
972+
case COMP_ATTR_BASE_CONFIG:
973+
memcpy_s(value, sizeof(struct ipc4_base_module_cfg), mod->priv.private,
974+
sizeof(struct ipc4_base_module_cfg));
975+
break;
976+
default:
977+
return -EINVAL;
978+
}
979+
980+
return 0;
981+
}
966982
#else
983+
int module_adapter_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
984+
{
985+
return -EINVAL;
986+
}
967987
int module_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block,
968988
bool last_block, uint32_t data_offset, char *data)
969989
{

‎src/audio/pipeline/pipeline-graph.c‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,18 +480,28 @@ struct comp_dev *pipeline_get_dai_comp_latency(uint32_t pipeline_id, uint32_t *l
480480
while (ipc_sink) {
481481
struct comp_buffer *buffer;
482482
uint64_t input_data, output_data;
483-
struct ipc4_base_module_cfg *input_base_cfg;
484-
struct ipc4_base_module_cfg *output_base_cfg;
483+
struct ipc4_base_module_cfg input_base_cfg;
484+
struct ipc4_base_module_cfg output_base_cfg;
485+
const struct comp_driver *drv;
486+
int ret;
485487

486488
/* Calculate pipeline latency */
487489
input_data = comp_get_total_data_processed(source, 0, true);
488490
output_data = comp_get_total_data_processed(ipc_sink->cd, 0, false);
489491
if (!input_data || !output_data)
490492
return NULL;
491493

492-
input_base_cfg = ipc4_comp_get_base_module_cfg(source);
493-
output_base_cfg = ipc4_comp_get_base_module_cfg(ipc_sink->cd);
494-
*latency += input_data / input_base_cfg->ibs - output_data / output_base_cfg->obs;
494+
drv = source->drv;
495+
ret = drv->ops.get_attribute(source, COMP_ATTR_BASE_CONFIG, &input_base_cfg);
496+
if (ret < 0)
497+
return NULL;
498+
499+
drv = ipc_sink->cd->drv;
500+
ret = drv->ops.get_attribute(ipc_sink->cd, COMP_ATTR_BASE_CONFIG, &output_base_cfg);
501+
if (ret < 0)
502+
return NULL;
503+
504+
*latency += input_data / input_base_cfg.ibs - output_data / output_base_cfg.obs;
495505

496506
/* If the component doesn't have a sink buffer, this is a dai. */
497507
if (list_is_empty(&ipc_sink->cd->bsink_list))

‎src/audio/src/src.c‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ struct ipc4_config_src {
8686

8787
struct comp_data {
8888
#if CONFIG_IPC_MAJOR_4
89-
/* Must be the 1st field, function ipc4_comp_get_base_module_cfg casts components
90-
* private data as ipc4_base_module_cfg!
91-
*/
9289
struct ipc4_config_src ipc_config;
9390
#else
9491
struct ipc_config_src ipc_config;
@@ -484,6 +481,21 @@ static void src_copy_sxx(struct comp_dev *dev,
484481
}
485482

486483
#if CONFIG_IPC_MAJOR_4
484+
static int src_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
485+
{
486+
struct comp_data *cd = comp_get_drvdata(dev);
487+
488+
switch (type) {
489+
case COMP_ATTR_BASE_CONFIG:
490+
*(struct ipc4_base_module_cfg *)value = cd->ipc_config.base;
491+
break;
492+
default:
493+
return -EINVAL;
494+
}
495+
496+
return 0;
497+
}
498+
487499
static int src_rate_check(void *spec)
488500
{
489501
struct ipc4_config_src *ipc_src = spec;
@@ -1071,6 +1083,9 @@ static const struct comp_driver comp_src = {
10711083
.copy = src_copy,
10721084
.prepare = src_prepare,
10731085
.reset = src_reset,
1086+
#if CONFIG_IPC_MAJOR_4
1087+
.get_attribute = src_get_attribute,
1088+
#endif
10741089
},
10751090
};
10761091

‎src/audio/up_down_mixer/up_down_mixer.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,21 @@ static int up_down_mixer_trigger(struct comp_dev *dev, int cmd)
505505
return comp_set_state(dev, cmd);
506506
}
507507

508+
static int up_down_mixer_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
509+
{
510+
struct up_down_mixer_data *cd = comp_get_drvdata(dev);
511+
512+
switch (type) {
513+
case COMP_ATTR_BASE_CONFIG:
514+
*(struct ipc4_base_module_cfg *)value = cd->base;
515+
break;
516+
default:
517+
return -EINVAL;
518+
}
519+
520+
return 0;
521+
}
522+
508523
static const struct comp_driver comp_up_down_mixer = {
509524
.uid = SOF_RT_UUID(up_down_mixer_comp_uuid),
510525
.tctx = &up_down_mixer_comp_tr,
@@ -515,6 +530,7 @@ static const struct comp_driver comp_up_down_mixer = {
515530
.copy = up_down_mixer_copy,
516531
.prepare = up_down_mixer_prepare,
517532
.reset = up_down_mixer_reset,
533+
.get_attribute = up_down_mixer_get_attribute,
518534
},
519535
};
520536

‎src/include/ipc4/copier.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,6 @@ struct ipc4_data_segment_enabled {
321321
} __attribute__((packed, aligned(4)));
322322

323323
struct copier_data {
324-
/* Must be the 1st field, function ipc4_comp_get_base_module_cfg casts components
325-
* private data as ipc4_base_module_cfg!
326-
*/
327324
struct ipc4_copier_module_cfg config;
328325
struct comp_dev *endpoint[IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT];
329326
struct comp_buffer *endpoint_buffer[IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT];

‎src/include/sof/audio/aria/aria.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ int aria_process_data(struct comp_dev *dev, int32_t *__restrict dst,
5353
* \brief Aria component private data.
5454
*/
5555
struct aria_data {
56-
/* Must be the 1st field, function ipc4_comp_get_base_module_cfg casts components
57-
* private data as ipc4_base_module_cfg!
58-
*/
5956
struct ipc4_base_module_cfg base;
6057

6158
/* channels count */

0 commit comments

Comments
 (0)