Skip to content

Commit 32fc81f

Browse files
committed
Tools: Testbench: Convert file component to module adapter
This is done as preparation for testbench IPC4 support. The update to IPC4 is simpler for a module adapter component. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 0ab4441 commit 32fc81f

10 files changed

Lines changed: 298 additions & 384 deletions

File tree

src/audio/module_adapter/module_adapter_ipc3.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ int module_adapter_init_data(struct comp_dev *dev,
8080
case SOF_COMP_DCBLOCK:
8181
case SOF_COMP_SMART_AMP:
8282
case SOF_COMP_MODULE_ADAPTER:
83+
case SOF_COMP_FILEREAD:
84+
case SOF_COMP_FILEWRITE:
8385
case SOF_COMP_NONE:
8486
{
8587
const struct ipc_config_process *ipc_module_adapter = spec;

src/include/ipc/topology.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,16 @@ struct sof_ipc_comp_process {
243243

244244
/* IPC file component used by testbench only */
245245
struct sof_ipc_comp_file {
246+
/* These need to be the same as in above sof_ipc_comp_process */
246247
struct sof_ipc_comp comp;
247248
struct sof_ipc_comp_config config;
249+
uint32_t size; /**< size of bespoke data section in bytes */
250+
uint32_t type; /**< sof_ipc_process_type */
251+
252+
/* reserved for future use */
253+
uint32_t reserved[7];
254+
255+
/* These are additional parameters for file */
248256
uint32_t rate;
249257
uint32_t channels;
250258
char *fn;

src/include/sof/audio/ipc-config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ struct ipc_config_process {
143143

144144
/* file IO ipc comp */
145145
struct ipc_comp_file {
146+
struct ipc_config_process module_header; /* Needed for module_adapter_init_data() */
146147
uint32_t rate;
147148
uint32_t channels;
148149
char *fn;

src/ipc/ipc3/helper.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,9 @@ static int comp_specific_builder(struct sof_ipc_comp *comp,
202202
{
203203
#if CONFIG_LIBRARY
204204
struct sof_ipc_comp_file *file = (struct sof_ipc_comp_file *)comp;
205-
#else
205+
#endif
206206
struct sof_ipc_comp_host *host = (struct sof_ipc_comp_host *)comp;
207207
struct sof_ipc_comp_dai *dai = (struct sof_ipc_comp_dai *)comp;
208-
#endif
209208
struct sof_ipc_comp_volume *vol = (struct sof_ipc_comp_volume *)comp;
210209
struct sof_ipc_comp_process *proc = (struct sof_ipc_comp_process *)comp;
211210
struct sof_ipc_comp_src *src = (struct sof_ipc_comp_src *)comp;
@@ -217,20 +216,25 @@ static int comp_specific_builder(struct sof_ipc_comp *comp,
217216
switch (comp->type) {
218217
#if CONFIG_LIBRARY
219218
/* test bench maps host and DAIs to a file */
220-
case SOF_COMP_HOST:
221-
case SOF_COMP_SG_HOST:
222-
case SOF_COMP_DAI:
223-
case SOF_COMP_SG_DAI:
219+
case SOF_COMP_FILEREAD:
220+
case SOF_COMP_FILEWRITE:
224221
if (IPC_TAIL_IS_SIZE_INVALID(*file))
225222
return -EBADMSG;
223+
226224
config->file.channels = file->channels;
227225
config->file.fn = file->fn;
228226
config->file.frame_fmt = file->frame_fmt;
229227
config->file.mode = file->mode;
230228
config->file.rate = file->rate;
231229
config->file.direction = file->direction;
230+
231+
/* For module_adapter_init_data() ipc_module_adapter compatibility */
232+
config->file.module_header.type = proc->type;
233+
config->file.module_header.size = proc->size;
234+
config->file.module_header.data = (uint8_t *)proc->data -
235+
sizeof(struct ipc_config_process);
232236
break;
233-
#else
237+
#endif
234238
case SOF_COMP_HOST:
235239
case SOF_COMP_SG_HOST:
236240
if (IPC_TAIL_IS_SIZE_INVALID(*host))
@@ -247,7 +251,6 @@ static int comp_specific_builder(struct sof_ipc_comp *comp,
247251
config->dai.direction = dai->direction;
248252
config->dai.type = dai->type;
249253
break;
250-
#endif
251254
case SOF_COMP_VOLUME:
252255
if (IPC_TAIL_IS_SIZE_INVALID(*vol))
253256
return -EBADMSG;

tools/testbench/common_test.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
// SPDX-License-Identifier: BSD-3-Clause
22
//
3-
// Copyright(c) 2018 Intel Corporation. All rights reserved.
3+
// Copyright(c) 2018-2024 Intel Corporation. All rights reserved.
44

5-
#include <stdint.h>
6-
#include <stddef.h>
7-
#include <time.h>
8-
#include <stdio.h>
9-
#include <stdlib.h>
10-
#include <rtos/string.h>
11-
#include <math.h>
12-
#include <rtos/sof.h>
13-
#include <rtos/task.h>
14-
#include <rtos/alloc.h>
15-
#include <sof/lib/notifier.h>
5+
#include <sof/audio/component_ext.h>
6+
#include <sof/audio/pipeline.h>
167
#include <sof/ipc/driver.h>
178
#include <sof/ipc/topology.h>
189
#include <sof/lib/agent.h>
1910
#include <sof/lib/dai.h>
2011
#include <sof/lib/dma.h>
12+
#include <sof/lib/notifier.h>
2113
#include <sof/schedule/edf_schedule.h>
2214
#include <sof/schedule/ll_schedule.h>
2315
#include <sof/schedule/ll_schedule_domain.h>
2416
#include <sof/schedule/schedule.h>
17+
#include <rtos/alloc.h>
18+
#include <rtos/sof.h>
19+
#include <rtos/string.h>
20+
#include <rtos/task.h>
2521
#include <rtos/wait.h>
26-
#include <sof/audio/pipeline.h>
27-
#include <sof/audio/component_ext.h>
22+
#include <tplg_parser/topology.h>
23+
#include <math.h>
24+
#include <stddef.h>
25+
#include <stdint.h>
26+
#include <stdio.h>
27+
#include <stdlib.h>
28+
#include <time.h>
29+
2830
#include "testbench/common_test.h"
2931
#include "testbench/trace.h"
30-
#include <tplg_parser/topology.h>
32+
#include "testbench/file.h"
3133

3234
#if defined __XCC__
3335
#include <xtensa/tie/xt_timer.h>
@@ -43,7 +45,6 @@ int tb_setup(struct sof *sof, struct testbench_prm *tp)
4345

4446
/* init components */
4547
sys_comp_init(sof);
46-
sys_comp_file_init();
4748
sys_comp_selector_init();
4849

4950
/* Module adapter components */
@@ -53,6 +54,7 @@ int tb_setup(struct sof *sof, struct testbench_prm *tp)
5354
sys_comp_module_drc_interface_init();
5455
sys_comp_module_eq_fir_interface_init();
5556
sys_comp_module_eq_iir_interface_init();
57+
sys_comp_module_file_interface_init();
5658
sys_comp_module_google_rtc_audio_processing_interface_init();
5759
sys_comp_module_igo_nr_interface_init();
5860
sys_comp_module_mfcc_interface_init();

0 commit comments

Comments
 (0)