|
13 | 13 | #include <sof/audio/component_ext.h> |
14 | 14 | #include <eq_iir/eq_iir.h> |
15 | 15 | #include <sof/audio/module_adapter/module/generic.h> |
| 16 | +#include <ipc/control.h> |
16 | 17 |
|
17 | 18 | #include "../../util.h" |
18 | 19 | #include "../../../include/cmocka_chirp_2ch.h" |
@@ -68,23 +69,48 @@ static int setup_group(void **state) |
68 | 69 | static struct sof_ipc_comp_process *create_eq_iir_comp_ipc(struct test_data *td) |
69 | 70 | { |
70 | 71 | struct sof_ipc_comp_process *ipc; |
71 | | - struct sof_eq_iir_config *eq; |
72 | 72 | size_t ipc_size = sizeof(struct sof_ipc_comp_process); |
73 | | - struct sof_abi_hdr *blob = (struct sof_abi_hdr *)iir_coef_2ch; |
74 | 73 | const struct sof_uuid uuid = SOF_REG_UUID(eq_iir); |
75 | 74 |
|
76 | | - ipc = calloc(1, ipc_size + blob->size + SOF_UUID_SIZE); |
| 75 | + ipc = calloc(1, ipc_size + SOF_UUID_SIZE); |
77 | 76 | memcpy_s(ipc + 1, SOF_UUID_SIZE, &uuid, SOF_UUID_SIZE); |
78 | | - eq = (struct sof_eq_iir_config *)((char *)(ipc + 1) + SOF_UUID_SIZE); |
79 | 77 | ipc->comp.hdr.size = ipc_size + SOF_UUID_SIZE; |
80 | 78 | ipc->comp.type = SOF_COMP_MODULE_ADAPTER; |
81 | 79 | ipc->config.hdr.size = sizeof(struct sof_ipc_comp_config); |
82 | | - ipc->size = blob->size; |
| 80 | + ipc->size = 0; |
83 | 81 | ipc->comp.ext_data_length = SOF_UUID_SIZE; |
84 | | - memcpy_s(eq, blob->size, blob->data, blob->size); |
85 | 82 | return ipc; |
86 | 83 | } |
87 | 84 |
|
| 85 | +static int eq_iir_send_config(struct processing_module *mod) |
| 86 | +{ |
| 87 | + const struct module_interface *const ops = mod->dev->drv->adapter_ops; |
| 88 | + struct sof_abi_hdr *blob = (struct sof_abi_hdr *)iir_coef_2ch; |
| 89 | + size_t cdata_size = sizeof(struct sof_ipc_ctrl_data) + sizeof(struct sof_abi_hdr) + |
| 90 | + blob->size; |
| 91 | + struct sof_ipc_ctrl_data *cdata; |
| 92 | + int ret; |
| 93 | + |
| 94 | + cdata = calloc(1, cdata_size); |
| 95 | + if (!cdata) |
| 96 | + return -ENOMEM; |
| 97 | + |
| 98 | + cdata->cmd = SOF_CTRL_CMD_BINARY; |
| 99 | + cdata->num_elems = blob->size; |
| 100 | + cdata->data[0].magic = blob->magic; |
| 101 | + cdata->data[0].type = blob->type; |
| 102 | + cdata->data[0].size = blob->size; |
| 103 | + cdata->data[0].abi = blob->abi; |
| 104 | + memcpy_s(cdata->data[0].data, blob->size, blob->data, blob->size); |
| 105 | + |
| 106 | + ret = ops->set_configuration(mod, 0, MODULE_CFG_FRAGMENT_SINGLE, |
| 107 | + blob->size, (const uint8_t *)cdata, |
| 108 | + blob->size, NULL, 0); |
| 109 | + |
| 110 | + free(cdata); |
| 111 | + return ret; |
| 112 | +} |
| 113 | + |
88 | 114 | static void prepare_sink(struct test_data *td, struct processing_module *mod) |
89 | 115 | { |
90 | 116 | struct test_parameters *parameters = td->params; |
@@ -155,6 +181,10 @@ static int setup(void **state) |
155 | 181 | dev->frames = params->frames; |
156 | 182 | mod = comp_mod(dev); |
157 | 183 |
|
| 184 | + ret = eq_iir_send_config(mod); |
| 185 | + if (ret) |
| 186 | + return ret; |
| 187 | + |
158 | 188 | prepare_sink(td, mod); |
159 | 189 | prepare_source(td, mod); |
160 | 190 |
|
|
0 commit comments