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