Skip to content

Commit f29365d

Browse files
committed
Test: cmocka: EQ IIR: Send config blob via set_config
This patch moves the configuration blob out of the IPC init message in create_eq_iir_comp_ipc(). It adds a new eq_iir_send_config() function that sends the blob via the module's set_configuration() callback and calls it from setup() after component creation. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent da1eaa7 commit f29365d

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

test/cmocka/src/audio/eq_iir/eq_iir_process.c

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <sof/audio/component_ext.h>
1414
#include <eq_iir/eq_iir.h>
1515
#include <sof/audio/module_adapter/module/generic.h>
16+
#include <ipc/control.h>
1617

1718
#include "../../util.h"
1819
#include "../../../include/cmocka_chirp_2ch.h"
@@ -68,23 +69,48 @@ static int setup_group(void **state)
6869
static struct sof_ipc_comp_process *create_eq_iir_comp_ipc(struct test_data *td)
6970
{
7071
struct sof_ipc_comp_process *ipc;
71-
struct sof_eq_iir_config *eq;
7272
size_t ipc_size = sizeof(struct sof_ipc_comp_process);
73-
struct sof_abi_hdr *blob = (struct sof_abi_hdr *)iir_coef_2ch;
7473
const struct sof_uuid uuid = SOF_REG_UUID(eq_iir);
7574

76-
ipc = calloc(1, ipc_size + blob->size + SOF_UUID_SIZE);
75+
ipc = calloc(1, ipc_size + SOF_UUID_SIZE);
7776
memcpy_s(ipc + 1, SOF_UUID_SIZE, &uuid, SOF_UUID_SIZE);
78-
eq = (struct sof_eq_iir_config *)((char *)(ipc + 1) + SOF_UUID_SIZE);
7977
ipc->comp.hdr.size = ipc_size + SOF_UUID_SIZE;
8078
ipc->comp.type = SOF_COMP_MODULE_ADAPTER;
8179
ipc->config.hdr.size = sizeof(struct sof_ipc_comp_config);
82-
ipc->size = blob->size;
80+
ipc->size = 0;
8381
ipc->comp.ext_data_length = SOF_UUID_SIZE;
84-
memcpy_s(eq, blob->size, blob->data, blob->size);
8582
return ipc;
8683
}
8784

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

184+
ret = eq_iir_send_config(mod);
185+
if (ret)
186+
return ret;
187+
158188
prepare_sink(td, mod);
159189
prepare_source(td, mod);
160190

0 commit comments

Comments
 (0)