Skip to content

Commit 8ef19c8

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. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent f2efd4a commit 8ef19c8

File tree

2 files changed

+64
-66
lines changed

2 files changed

+64
-66
lines changed

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: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,29 @@ 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-
110109
if (dir == SOF_IPC_STREAM_PLAYBACK) {
110+
struct sof_uuid uuid = {.a = 0xe2b6031c, .b = 0x47e8, .c = 0x11ed,
111+
.d = { 0x07, 0xa9, 0x7f, 0x80, 0x1b, 0x6e, 0xfa, 0x6c }};
111112
comp_info->module_id = 0x96;
112113
plug_setup_widget_ipc_msg(comp_info);
114+
comp_info->uuid = uuid;
113115
} else {
116+
struct sof_uuid uuid = {.a = 0xdabe8814, .b = 0x47e8, .c = 0x11ed,
117+
.d = { 0xa5, 0x8b, 0xb3, 0x09, 0x97, 0x4f, 0xec, 0xce }};
114118
comp_info->module_id = 0x98;
115119
plug_setup_widget_ipc_msg(comp_info);
120+
comp_info->uuid = uuid;
116121
}
117122

123+
/* copy uuid to the end of the payload */
124+
memcpy(comp_info->ipc_payload + sizeof(struct ipc4_base_module_cfg), &comp_info->uuid,
125+
sizeof(struct sof_uuid));
126+
118127
return 0;
119128
}
120129

@@ -128,20 +137,31 @@ static int plug_dai_in_out(snd_sof_plug_t *plug, int dir)
128137
if (ret < 0)
129138
return ret;
130139

131-
comp_info->ipc_payload = calloc(sizeof(struct ipc4_base_module_cfg), 1);
140+
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg) + sizeof(struct sof_uuid);
141+
comp_info->ipc_payload = calloc(comp_info->ipc_size, 1);
132142
if (!comp_info->ipc_payload)
133143
return -ENOMEM;
134144

135-
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg);
136-
137145
if (dir == SOF_IPC_STREAM_PLAYBACK) {
146+
struct sof_uuid uuid = {.a = 0x72cee996, .b = 0x39f2, .c = 0x11ed,
147+
.d = { 0xa0, 0x8f, 0x97, 0xfc, 0xc4, 0x2e, 0xaa, 0xeb }};
148+
138149
comp_info->module_id = 0x97;
139150
plug_setup_widget_ipc_msg(comp_info);
151+
comp_info->uuid = uuid;
140152
} else {
153+
struct sof_uuid uuid = {.a = 0x66def9f0, .b = 0x39f2, .c = 0x11ed,
154+
.d = { 0xf7, 0x89, 0xaf, 0x98, 0xa6, 0x44, 0x0c, 0xc4 }};
155+
141156
comp_info->module_id = 0x99;
142157
plug_setup_widget_ipc_msg(comp_info);
158+
comp_info->uuid = uuid;
143159
}
144160

161+
/* copy uuid to the end of the payload */
162+
memcpy(comp_info->ipc_payload + sizeof(struct ipc4_base_module_cfg), &comp_info->uuid,
163+
sizeof(struct sof_uuid));
164+
145165
return 0;
146166
}
147167

@@ -210,7 +230,7 @@ static int plug_new_mixer(snd_sof_plug_t *plug)
210230
return -ENOMEM;
211231

212232
comp_info->instance_id = plug->instance_ids[SND_SOC_TPLG_DAPM_MIXER]++;
213-
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg);
233+
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg) + sizeof(struct sof_uuid);
214234
comp_info->ipc_payload = calloc(comp_info->ipc_size, 1);
215235
if (!comp_info->ipc_payload)
216236
return -ENOMEM;
@@ -229,6 +249,10 @@ static int plug_new_mixer(snd_sof_plug_t *plug)
229249
comp_info->module_id = 0x3;
230250
plug_setup_widget_ipc_msg(comp_info);
231251
}
252+
253+
/* copy uuid to the end of the payload */
254+
memcpy(comp_info->ipc_payload + sizeof(struct ipc4_base_module_cfg), &comp_info->uuid,
255+
sizeof(struct sof_uuid));
232256
out:
233257
free(tplg_ctl);
234258
return ret;
@@ -240,10 +264,13 @@ static int plug_new_pga(snd_sof_plug_t *plug)
240264
struct tplg_comp_info *comp_info = ctx->current_comp_info;
241265
struct ipc4_peak_volume_config volume;
242266
struct snd_soc_tplg_ctl_hdr *tplg_ctl;
267+
uint32_t uuid_offset;
243268
int ret;
244269

245-
comp_info->ipc_size =
246-
sizeof(struct ipc4_peak_volume_config) + sizeof(struct ipc4_base_module_cfg);
270+
comp_info->ipc_size = sizeof(struct ipc4_peak_volume_config);
271+
comp_info->ipc_size += sizeof(struct ipc4_base_module_cfg);
272+
uuid_offset = comp_info->ipc_size;
273+
comp_info->ipc_size += sizeof(struct sof_uuid);
247274
comp_info->ipc_payload = calloc(comp_info->ipc_size, 1);
248275
if (!comp_info->ipc_payload)
249276
return -ENOMEM;
@@ -269,6 +296,9 @@ static int plug_new_pga(snd_sof_plug_t *plug)
269296
memcpy(comp_info->ipc_payload + sizeof(struct ipc4_base_module_cfg),
270297
&volume, sizeof(struct ipc4_peak_volume_config));
271298

299+
/* copy uuid to the end of the payload */
300+
memcpy(comp_info->ipc_payload + uuid_offset, &comp_info->uuid, sizeof(struct sof_uuid));
301+
272302
/* skip kcontrols for now */
273303
if (tplg_create_controls(ctx, ctx->widget->num_kcontrols,
274304
tplg_ctl, ctx->hdr->payload_size, comp_info) < 0) {
@@ -302,7 +332,7 @@ static int plug_new_process(snd_sof_plug_t *plug)
302332
return ret;
303333

304334
/* only base config supported for now. extn support will be added later */
305-
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg);
335+
comp_info->ipc_size = sizeof(struct ipc4_base_module_cfg) + sizeof(struct sof_uuid);
306336
comp_info->ipc_payload = calloc(comp_info->ipc_size, 1);
307337
if (!comp_info->ipc_payload)
308338
return -ENOMEM;
@@ -319,6 +349,10 @@ static int plug_new_process(snd_sof_plug_t *plug)
319349
return -ENOMEM;
320350
}
321351

352+
/* copy uuid to the end of the payload */
353+
memcpy(comp_info->ipc_payload + sizeof(struct ipc4_base_module_cfg), &comp_info->uuid,
354+
sizeof(struct sof_uuid));
355+
322356
/* set up kcontrols */
323357
ret = tplg_create_controls(ctx, ctx->widget->num_kcontrols,
324358
tplg_ctl, ctx->hdr->payload_size, comp_info);

0 commit comments

Comments
 (0)