Skip to content

Commit c41a88d

Browse files
author
Jyri Sarha
committed
component: module_adapter: Add module_ext_init_decode() and call it
Add module_ext_init_decode() for struct ipc4_module_init_ext_init payload decoding. The function goes decodes ext_init and following object array payload. The only recognized object so far is struct sof_ipc4_mod_init_ext_dp_memory_data. The possibly found stack and heap size requirements are copied to struct module_config, but no other functionality is added. This first version ignores rtos_domain and gna_used flags, and fails if their associated data is found in the message payload. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 5759b54 commit c41a88d

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

src/audio/module_adapter/module_adapter_ipc4.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,48 @@
2525

2626
LOG_MODULE_DECLARE(module_adapter, CONFIG_SOF_LOG_LEVEL);
2727

28+
static const struct ipc4_base_module_extended_cfg *
29+
module_ext_init_decode(struct comp_dev *dev, struct module_config *dst,
30+
const unsigned char *data, uint32_t *size)
31+
{
32+
const struct ipc4_module_init_ext_init *ext_init =
33+
(const struct ipc4_module_init_ext_init *)data;
34+
bool last_object = !ext_init->data_obj_array;
35+
const struct ipc4_module_init_ext_object *obj;
36+
37+
/* TODO: Handle ext_init->gna_used and ext_init->rtos_domain here */
38+
obj = (const struct ipc4_module_init_ext_object *)(ext_init + 1);
39+
while (!last_object) {
40+
switch (obj->object_id) {
41+
case IPC4_MOD_INIT_DATA_GLB_ID_DP_DATA:
42+
struct ipc4_module_init_ext_obj_dp_data *dp_data =
43+
(struct ipc4_module_init_ext_obj_dp_data *)(obj + 1);
44+
dst->stack_size = dp_data->stack_size;
45+
dst->heap_size = dp_data->heap_size;
46+
comp_info(dev, "init_ext_obj_dp_data stack %u heap %u",
47+
dp_data->stack_size, dp_data->heap_size);
48+
break;
49+
default:
50+
comp_info(dev, "Unknown ext init object id %u of %u words",
51+
obj->object_id, obj->object_words);
52+
}
53+
last_object = obj->last_object;
54+
obj = (struct ipc4_module_init_ext_object *)
55+
(((uint32_t *) (obj + 1)) + obj->object_words);
56+
if ((unsigned char *)obj - data > *size) {
57+
comp_err(dev, "ext init object array overflow, %u > %u",
58+
(unsigned char *)obj - data, *size);
59+
return NULL;
60+
}
61+
}
62+
63+
/* Remove decoded ext_init payload from the size */
64+
*size -= (unsigned char *) obj - data;
65+
66+
/* return remaining payload */
67+
return (const struct ipc4_base_module_extended_cfg *)obj;
68+
}
69+
2870
/*
2971
* \module adapter data initialize.
3072
* \param[in] dev - device.
@@ -39,11 +81,18 @@ int module_adapter_init_data(struct comp_dev *dev,
3981
const struct comp_ipc_config *config,
4082
const void *spec)
4183
{
84+
const struct ipc4_base_module_extended_cfg *cfg;
4285
const struct ipc_config_process *args = spec;
43-
const struct ipc4_base_module_extended_cfg *cfg = (void *)args->data;
4486
size_t cfgsz = args->size;
4587

4688
assert(dev->drv->type == SOF_COMP_MODULE_ADAPTER);
89+
if (config->ipc_extended_init)
90+
cfg = module_ext_init_decode(dev, dst, args->data, &cfgsz);
91+
else
92+
cfg = (const struct ipc4_base_module_extended_cfg *)args->data;
93+
94+
if (cfg == NULL)
95+
return -EINVAL;
4796
if (cfgsz < sizeof(cfg->base_cfg))
4897
return -EINVAL;
4998

0 commit comments

Comments
 (0)