Skip to content

Commit b21fd99

Browse files
committed
ipc4: helper: Remove hardcoded UUID map for CONFIG_LIBRARY
Always append the UUID to the end of the module init IPC data and use that to look up the component driver instead of using the hardcoded UUID map. This will make it easier to support new processing elements with the plugin/testbench. Also, modify the get/set_large_config handlers to use the component driver set in the dev instead of looking it up again. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent f2efd4a commit b21fd99

File tree

3 files changed

+86
-80
lines changed

3 files changed

+86
-80
lines changed

src/ipc/ipc4/handler.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,13 +1052,6 @@ static int ipc4_get_large_config_module_instance(struct ipc4_message_request *ip
10521052
tr_dbg(&ipc_tr, "ipc4_get_large_config_module_instance %x : %x",
10531053
(uint32_t)config.primary.r.module_id, (uint32_t)config.primary.r.instance_id);
10541054

1055-
drv = ipc4_get_comp_drv(config.primary.r.module_id);
1056-
if (!drv)
1057-
return IPC4_MOD_INVALID_ID;
1058-
1059-
if (!drv->ops.get_large_config)
1060-
return IPC4_INVALID_REQUEST;
1061-
10621055
/* get component dev for non-basefw since there is no
10631056
* component dev for basefw
10641057
*/
@@ -1071,11 +1064,21 @@ static int ipc4_get_large_config_module_instance(struct ipc4_message_request *ip
10711064
if (!dev)
10721065
return IPC4_MOD_INVALID_ID;
10731066

1067+
drv = dev->drv;
1068+
10741069
/* Pass IPC to target core */
10751070
if (!cpu_is_me(dev->ipc_config.core))
10761071
return ipc4_process_on_core(dev->ipc_config.core, false);
1072+
} else {
1073+
drv = ipc4_get_comp_drv(config.primary.r.module_id);
10771074
}
10781075

1076+
if (!drv)
1077+
return IPC4_MOD_INVALID_ID;
1078+
1079+
if (!drv->ops.get_large_config)
1080+
return IPC4_INVALID_REQUEST;
1081+
10791082
data_offset = config.extension.r.data_off_size;
10801083

10811084
/* check for vendor param first */
@@ -1210,13 +1213,6 @@ static int ipc4_set_large_config_module_instance(struct ipc4_message_request *ip
12101213
tr_dbg(&ipc_tr, "ipc4_set_large_config_module_instance %x : %x",
12111214
(uint32_t)config.primary.r.module_id, (uint32_t)config.primary.r.instance_id);
12121215

1213-
drv = ipc4_get_comp_drv(config.primary.r.module_id);
1214-
if (!drv)
1215-
return IPC4_MOD_INVALID_ID;
1216-
1217-
if (!drv->ops.set_large_config)
1218-
return IPC4_INVALID_REQUEST;
1219-
12201216
if (config.primary.r.module_id) {
12211217
uint32_t comp_id;
12221218

@@ -1225,11 +1221,21 @@ static int ipc4_set_large_config_module_instance(struct ipc4_message_request *ip
12251221
if (!dev)
12261222
return IPC4_MOD_INVALID_ID;
12271223

1224+
drv = dev->drv;
1225+
12281226
/* Pass IPC to target core */
12291227
if (!cpu_is_me(dev->ipc_config.core))
12301228
return ipc4_process_on_core(dev->ipc_config.core, false);
1229+
} else {
1230+
drv = ipc4_get_comp_drv(config.primary.r.module_id);
12311231
}
12321232

1233+
if (!drv)
1234+
return IPC4_MOD_INVALID_ID;
1235+
1236+
if (!drv->ops.set_large_config)
1237+
return IPC4_INVALID_REQUEST;
1238+
12331239
/* check for vendor param first */
12341240
if (config.extension.r.large_param_id == VENDOR_CONFIG_PARAM) {
12351241
ret = ipc4_set_vendor_config_module_instance(dev, drv,

src/ipc/ipc4/helper.c

Lines changed: 20 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ static inline char *ipc4_get_comp_new_data(void)
9090

9191
return data;
9292
}
93+
94+
static const struct comp_driver *ipc4_library_get_comp_drv(char *data)
95+
{
96+
return ipc4_get_drv((const uint8_t *)data);
97+
}
9398
#else
9499
static inline char *ipc4_get_comp_new_data(void)
95100
{
@@ -107,9 +112,6 @@ struct comp_dev *comp_new_ipc4(struct ipc4_module_init_instance *module_init)
107112

108113
comp_id = IPC4_COMP_ID(module_init->primary.r.module_id,
109114
module_init->primary.r.instance_id);
110-
drv = ipc4_get_comp_drv(IPC4_MOD_ID(comp_id));
111-
if (!drv)
112-
return NULL;
113115

114116
if (ipc4_get_comp_dev(comp_id)) {
115117
tr_err(&ipc_tr, "comp 0x%x exists", comp_id);
@@ -127,6 +129,20 @@ struct comp_dev *comp_new_ipc4(struct ipc4_module_init_instance *module_init)
127129
ipc_config.core = module_init->extension.r.core_id;
128130
ipc_config.ipc_config_size = module_init->extension.r.param_block_size * sizeof(uint32_t);
129131

132+
dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE,
133+
MAILBOX_HOSTBOX_SIZE);
134+
135+
data = ipc4_get_comp_new_data();
136+
137+
#if CONFIG_LIBRARY
138+
ipc_config.ipc_config_size -= sizeof(struct sof_uuid);
139+
drv = ipc4_library_get_comp_drv(data + ipc_config.ipc_config_size);
140+
#else
141+
drv = ipc4_get_comp_drv(IPC4_MOD_ID(comp_id));
142+
#endif
143+
if (!drv)
144+
return NULL;
145+
130146
#if CONFIG_ZEPHYR_DP_SCHEDULER
131147
if (module_init->extension.r.proc_domain)
132148
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_DP;
@@ -140,15 +156,10 @@ struct comp_dev *comp_new_ipc4(struct ipc4_module_init_instance *module_init)
140156
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_LL;
141157
#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */
142158

143-
dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE,
144-
MAILBOX_HOSTBOX_SIZE);
145-
146-
data = ipc4_get_comp_new_data();
147159
if (drv->type == SOF_COMP_MODULE_ADAPTER) {
148160
const struct ipc_config_process spec = {
149161
.data = (const unsigned char *)data,
150-
/* spec_size in IPC4 is in DW. Convert to bytes. */
151-
.size = module_init->extension.r.param_block_size * sizeof(uint32_t),
162+
.size = ipc_config.ipc_config_size,
152163
};
153164

154165
dev = drv->ops.create(drv, &ipc_config, (const void *)&spec);
@@ -958,60 +969,13 @@ const struct comp_driver *ipc4_get_drv(const uint8_t *uuid)
958969
return drv;
959970
}
960971

961-
#if CONFIG_LIBRARY
962-
struct ipc4_module_uuid {
963-
int module_id;
964-
struct sof_uuid uuid;
965-
};
966-
967-
/* Hardcoded table mapping UUIDs with module ID's. TODO: replace this with a scalable solution */
968-
static const struct ipc4_module_uuid uuid_map[] = {
969-
{0x6, {.a = 0x61bca9a8, .b = 0x18d0, .c = 0x4a18,
970-
.d = { 0x8e, 0x7b, 0x26, 0x39, 0x21, 0x98, 0x04, 0xb7 }}}, /* gain */
971-
{0x2, {.a = 0x39656eb2, .b = 0x3b71, .c = 0x4049,
972-
.d = { 0x8d, 0x3f, 0xf9, 0x2c, 0xd5, 0xc4, 0x3c, 0x09 }}}, /* mixin */
973-
{0x3, {.a = 0x3c56505a, .b = 0x24d7, .c = 0x418f,
974-
.d = { 0xbd, 0xdc, 0xc1, 0xf5, 0xa3, 0xac, 0x2a, 0xe0 }}}, /* mixout */
975-
{0x95, {.a = 0x7ae671a7, .b = 0x4617, .c = 0x4a09,
976-
.d = { 0xbf, 0x6d, 0x9d, 0x29, 0xc9, 0x98, 0xdb, 0xc1 }}}, /* noise suppresion */
977-
{0x96, {.a = 0xe2b6031c, .b = 0x47e8, .c = 0x11ed,
978-
.d = { 0x07, 0xa9, 0x7f, 0x80, 0x1b, 0x6e, 0xfa, 0x6c }}}, /* host SHM write */
979-
{0x98, {.a = 0xdabe8814, .b = 0x47e8, .c = 0x11ed,
980-
.d = { 0xa5, 0x8b, 0xb3, 0x09, 0x97, 0x4f, 0xec, 0xce }}}, /* host SHM read */
981-
{0x97, {.a = 0x72cee996, .b = 0x39f2, .c = 0x11ed,
982-
.d = { 0xa0, 0x8f, 0x97, 0xfc, 0xc4, 0x2e, 0xaa, 0xeb }}}, /* ALSA aplay */
983-
{0x99, {.a = 0x66def9f0, .b = 0x39f2, .c = 0x11ed,
984-
.d = { 0xf7, 0x89, 0xaf, 0x98, 0xa6, 0x44, 0x0c, 0xc4 }}}, /* ALSA arecord */
985-
};
986-
987-
static const struct comp_driver *ipc4_library_get_drv(int module_id)
988-
{
989-
const struct ipc4_module_uuid *mod_uuid;
990-
int i;
991-
992-
for (i = 0; i < ARRAY_SIZE(uuid_map); i++) {
993-
mod_uuid = &uuid_map[i];
994-
995-
if (mod_uuid->module_id == module_id)
996-
return ipc4_get_drv((const uint8_t *)&mod_uuid->uuid);
997-
}
998-
999-
tr_err(&comp_tr, "ipc4_library_get_drv(): Unsupported module ID %#x\n", module_id);
1000-
return NULL;
1001-
}
1002-
#endif
1003-
1004972
const struct comp_driver *ipc4_get_comp_drv(uint32_t module_id)
1005973
{
1006974
const struct sof_man_fw_desc *desc = NULL;
1007975
const struct comp_driver *drv;
1008976
const struct sof_man_module *mod;
1009977
uint32_t entry_index;
1010978

1011-
#if CONFIG_LIBRARY
1012-
return ipc4_library_get_drv(module_id);
1013-
#endif
1014-
1015979
#ifdef RIMAGE_MANIFEST
1016980
desc = (const struct sof_man_fw_desc *)IMR_BOOT_LDR_MANIFEST_BASE;
1017981
#else

tools/plugin/alsaplug/tplg.c

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,30 @@ static int plug_aif_in_out(snd_sof_plug_t *plug, int dir)
101101
if (ret < 0)
102102
return ret;
103103

104-
comp_info->ipc_payload = calloc(sizeof(struct ipc4_base_module_cfg), 1);
104+
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg) + sizeof(struct sof_uuid);
105+
comp_info->ipc_payload = calloc(comp_info->ipc_size, 1);
105106
if (!comp_info->ipc_payload)
106107
return -ENOMEM;
107108

108-
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg);
109-
109+
/* overwrite the topology UUIDs with the SHM module UUID for the host components */
110110
if (dir == SOF_IPC_STREAM_PLAYBACK) {
111+
struct sof_uuid uuid = {.a = 0xe2b6031c, .b = 0x47e8, .c = 0x11ed,
112+
.d = { 0x07, 0xa9, 0x7f, 0x80, 0x1b, 0x6e, 0xfa, 0x6c }};
111113
comp_info->module_id = 0x96;
112114
plug_setup_widget_ipc_msg(comp_info);
115+
comp_info->uuid = uuid;
113116
} else {
117+
struct sof_uuid uuid = {.a = 0xdabe8814, .b = 0x47e8, .c = 0x11ed,
118+
.d = { 0xa5, 0x8b, 0xb3, 0x09, 0x97, 0x4f, 0xec, 0xce }};
114119
comp_info->module_id = 0x98;
115120
plug_setup_widget_ipc_msg(comp_info);
121+
comp_info->uuid = uuid;
116122
}
117123

124+
/* copy uuid to the end of the payload */
125+
memcpy(comp_info->ipc_payload + sizeof(struct ipc4_base_module_cfg), &comp_info->uuid,
126+
sizeof(struct sof_uuid));
127+
118128
return 0;
119129
}
120130

@@ -128,20 +138,32 @@ static int plug_dai_in_out(snd_sof_plug_t *plug, int dir)
128138
if (ret < 0)
129139
return ret;
130140

131-
comp_info->ipc_payload = calloc(sizeof(struct ipc4_base_module_cfg), 1);
141+
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg) + sizeof(struct sof_uuid);
142+
comp_info->ipc_payload = calloc(comp_info->ipc_size, 1);
132143
if (!comp_info->ipc_payload)
133144
return -ENOMEM;
134145

135-
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg);
136-
146+
/* overwrite the topology UUIDs with the ALSA module UUID for the DAI components */
137147
if (dir == SOF_IPC_STREAM_PLAYBACK) {
148+
struct sof_uuid uuid = {.a = 0x72cee996, .b = 0x39f2, .c = 0x11ed,
149+
.d = { 0xa0, 0x8f, 0x97, 0xfc, 0xc4, 0x2e, 0xaa, 0xeb }};
150+
138151
comp_info->module_id = 0x97;
139152
plug_setup_widget_ipc_msg(comp_info);
153+
comp_info->uuid = uuid;
140154
} else {
155+
struct sof_uuid uuid = {.a = 0x66def9f0, .b = 0x39f2, .c = 0x11ed,
156+
.d = { 0xf7, 0x89, 0xaf, 0x98, 0xa6, 0x44, 0x0c, 0xc4 }};
157+
141158
comp_info->module_id = 0x99;
142159
plug_setup_widget_ipc_msg(comp_info);
160+
comp_info->uuid = uuid;
143161
}
144162

163+
/* copy uuid to the end of the payload */
164+
memcpy(comp_info->ipc_payload + sizeof(struct ipc4_base_module_cfg), &comp_info->uuid,
165+
sizeof(struct sof_uuid));
166+
145167
return 0;
146168
}
147169

@@ -210,7 +232,7 @@ static int plug_new_mixer(snd_sof_plug_t *plug)
210232
return -ENOMEM;
211233

212234
comp_info->instance_id = plug->instance_ids[SND_SOC_TPLG_DAPM_MIXER]++;
213-
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg);
235+
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg) + sizeof(struct sof_uuid);
214236
comp_info->ipc_payload = calloc(comp_info->ipc_size, 1);
215237
if (!comp_info->ipc_payload)
216238
return -ENOMEM;
@@ -229,6 +251,10 @@ static int plug_new_mixer(snd_sof_plug_t *plug)
229251
comp_info->module_id = 0x3;
230252
plug_setup_widget_ipc_msg(comp_info);
231253
}
254+
255+
/* copy uuid to the end of the payload */
256+
memcpy(comp_info->ipc_payload + sizeof(struct ipc4_base_module_cfg), &comp_info->uuid,
257+
sizeof(struct sof_uuid));
232258
out:
233259
free(tplg_ctl);
234260
return ret;
@@ -240,10 +266,13 @@ static int plug_new_pga(snd_sof_plug_t *plug)
240266
struct tplg_comp_info *comp_info = ctx->current_comp_info;
241267
struct ipc4_peak_volume_config volume;
242268
struct snd_soc_tplg_ctl_hdr *tplg_ctl;
269+
uint32_t uuid_offset;
243270
int ret;
244271

245-
comp_info->ipc_size =
246-
sizeof(struct ipc4_peak_volume_config) + sizeof(struct ipc4_base_module_cfg);
272+
comp_info->ipc_size = sizeof(struct ipc4_peak_volume_config);
273+
comp_info->ipc_size += sizeof(struct ipc4_base_module_cfg);
274+
uuid_offset = comp_info->ipc_size;
275+
comp_info->ipc_size += sizeof(struct sof_uuid);
247276
comp_info->ipc_payload = calloc(comp_info->ipc_size, 1);
248277
if (!comp_info->ipc_payload)
249278
return -ENOMEM;
@@ -269,6 +298,9 @@ static int plug_new_pga(snd_sof_plug_t *plug)
269298
memcpy(comp_info->ipc_payload + sizeof(struct ipc4_base_module_cfg),
270299
&volume, sizeof(struct ipc4_peak_volume_config));
271300

301+
/* copy uuid to the end of the payload */
302+
memcpy(comp_info->ipc_payload + uuid_offset, &comp_info->uuid, sizeof(struct sof_uuid));
303+
272304
/* skip kcontrols for now */
273305
if (tplg_create_controls(ctx, ctx->widget->num_kcontrols,
274306
tplg_ctl, ctx->hdr->payload_size, comp_info) < 0) {
@@ -302,7 +334,7 @@ static int plug_new_process(snd_sof_plug_t *plug)
302334
return ret;
303335

304336
/* only base config supported for now. extn support will be added later */
305-
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg);
337+
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg) + sizeof(struct sof_uuid);
306338
comp_info->ipc_payload = calloc(comp_info->ipc_size, 1);
307339
if (!comp_info->ipc_payload)
308340
return -ENOMEM;
@@ -319,6 +351,10 @@ static int plug_new_process(snd_sof_plug_t *plug)
319351
return -ENOMEM;
320352
}
321353

354+
/* copy uuid to the end of the payload */
355+
memcpy(comp_info->ipc_payload + sizeof(struct ipc4_base_module_cfg), &comp_info->uuid,
356+
sizeof(struct sof_uuid));
357+
322358
/* set up kcontrols */
323359
ret = tplg_create_controls(ctx, ctx->widget->num_kcontrols,
324360
tplg_ctl, ctx->hdr->payload_size, comp_info);

0 commit comments

Comments
 (0)