Skip to content

Commit 187b157

Browse files
committed
Test: cmocka: EQ FIR: Send config blob via set_config
Move the configuration blob out of the IPC init message in create_eq_fir_comp_ipc(). Add a new eq_fir_send_config() function that sends the blob via the module's set_configuration() callback, and call it from setup() after component creation. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent f29365d commit 187b157

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

test/cmocka/src/audio/eq_fir/eq_fir_process.c

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <sof/audio/component_ext.h>
1212
#include <eq_fir/eq_fir.h>
1313
#include <sof/audio/module_adapter/module/generic.h>
14+
#include <ipc/control.h>
1415

1516
#include "../../util.h"
1617
#include "../../../include/cmocka_chirp_2ch.h"
@@ -69,23 +70,48 @@ static int setup_group(void **state)
6970
static struct sof_ipc_comp_process *create_eq_fir_comp_ipc(struct test_data *td)
7071
{
7172
struct sof_ipc_comp_process *ipc;
72-
struct sof_eq_fir_config *eq;
7373
size_t ipc_size = sizeof(struct sof_ipc_comp_process);
74-
struct sof_abi_hdr *blob = (struct sof_abi_hdr *)fir_coef_2ch;
7574
const struct sof_uuid uuid = SOF_REG_UUID(eq_fir);
7675

77-
ipc = calloc(1, ipc_size + blob->size + SOF_UUID_SIZE);
76+
ipc = calloc(1, ipc_size + SOF_UUID_SIZE);
7877
memcpy_s(ipc + 1, SOF_UUID_SIZE, &uuid, SOF_UUID_SIZE);
79-
eq = (struct sof_eq_fir_config *)((char *)(ipc + 1) + SOF_UUID_SIZE);
8078
ipc->comp.hdr.size = ipc_size + SOF_UUID_SIZE;
8179
ipc->comp.type = SOF_COMP_MODULE_ADAPTER;
8280
ipc->config.hdr.size = sizeof(struct sof_ipc_comp_config);
83-
ipc->size = blob->size;
81+
ipc->size = 0;
8482
ipc->comp.ext_data_length = SOF_UUID_SIZE;
85-
memcpy_s(eq, blob->size, blob->data, blob->size);
8683
return ipc;
8784
}
8885

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+
89115
static void prepare_sink(struct test_data *td, struct processing_module *mod)
90116
{
91117
struct test_parameters *parameters = td->params;
@@ -156,6 +182,10 @@ static int setup(void **state)
156182
dev->frames = params->frames;
157183
mod = comp_mod(dev);
158184

185+
ret = eq_fir_send_config(mod);
186+
if (ret)
187+
return ret;
188+
159189
prepare_sink(td, mod);
160190
prepare_source(td, mod);
161191

0 commit comments

Comments
 (0)