Skip to content

Commit

Permalink
Tools: Testbench: Convert file component to module adapter
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
singalsu authored and lgirdwood committed Sep 17, 2024
1 parent c6d336a commit 9d1177a
Show file tree
Hide file tree
Showing 10 changed files with 281 additions and 382 deletions.
2 changes: 2 additions & 0 deletions src/audio/module_adapter/module_adapter_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ int module_adapter_init_data(struct comp_dev *dev,
case SOF_COMP_DCBLOCK:
case SOF_COMP_SMART_AMP:
case SOF_COMP_MODULE_ADAPTER:
case SOF_COMP_FILEREAD:
case SOF_COMP_FILEWRITE:
case SOF_COMP_NONE:
{
const struct ipc_config_process *ipc_module_adapter = spec;
Expand Down
8 changes: 8 additions & 0 deletions src/include/ipc/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,16 @@ struct sof_ipc_comp_process {

/* IPC file component used by testbench only */
struct sof_ipc_comp_file {
/* These need to be the same as in above sof_ipc_comp_process */
struct sof_ipc_comp comp;
struct sof_ipc_comp_config config;
uint32_t size; /**< size of bespoke data section in bytes */
uint32_t type; /**< sof_ipc_process_type */

/* reserved for future use */
uint32_t reserved[7];

/* These are additional parameters for file */
uint32_t rate;
uint32_t channels;
char *fn;
Expand Down
1 change: 1 addition & 0 deletions src/include/sof/audio/ipc-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ struct ipc_config_process {

/* file IO ipc comp */
struct ipc_comp_file {
struct ipc_config_process module_header; /* Needed for module_adapter_init_data() */
uint32_t rate;
uint32_t channels;
char *fn;
Expand Down
19 changes: 11 additions & 8 deletions src/ipc/ipc3/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,9 @@ static int comp_specific_builder(struct sof_ipc_comp *comp,
{
#if CONFIG_LIBRARY
struct sof_ipc_comp_file *file = (struct sof_ipc_comp_file *)comp;
#else
#endif
struct sof_ipc_comp_host *host = (struct sof_ipc_comp_host *)comp;
struct sof_ipc_comp_dai *dai = (struct sof_ipc_comp_dai *)comp;
#endif
struct sof_ipc_comp_volume *vol = (struct sof_ipc_comp_volume *)comp;
struct sof_ipc_comp_process *proc = (struct sof_ipc_comp_process *)comp;
struct sof_ipc_comp_src *src = (struct sof_ipc_comp_src *)comp;
Expand All @@ -217,20 +216,25 @@ static int comp_specific_builder(struct sof_ipc_comp *comp,
switch (comp->type) {
#if CONFIG_LIBRARY
/* test bench maps host and DAIs to a file */
case SOF_COMP_HOST:
case SOF_COMP_SG_HOST:
case SOF_COMP_DAI:
case SOF_COMP_SG_DAI:
case SOF_COMP_FILEREAD:
case SOF_COMP_FILEWRITE:
if (IPC_TAIL_IS_SIZE_INVALID(*file))
return -EBADMSG;

config->file.channels = file->channels;
config->file.fn = file->fn;
config->file.frame_fmt = file->frame_fmt;
config->file.mode = file->mode;
config->file.rate = file->rate;
config->file.direction = file->direction;

/* For module_adapter_init_data() ipc_module_adapter compatibility */
config->file.module_header.type = proc->type;
config->file.module_header.size = proc->size;
config->file.module_header.data = (uint8_t *)proc->data -
sizeof(struct ipc_config_process);
break;
#else
#endif
case SOF_COMP_HOST:
case SOF_COMP_SG_HOST:
if (IPC_TAIL_IS_SIZE_INVALID(*host))
Expand All @@ -247,7 +251,6 @@ static int comp_specific_builder(struct sof_ipc_comp *comp,
config->dai.direction = dai->direction;
config->dai.type = dai->type;
break;
#endif
case SOF_COMP_VOLUME:
if (IPC_TAIL_IS_SIZE_INVALID(*vol))
return -EBADMSG;
Expand Down
34 changes: 18 additions & 16 deletions tools/testbench/common_test.c
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2018 Intel Corporation. All rights reserved.
// Copyright(c) 2018-2024 Intel Corporation. All rights reserved.

#include <stdint.h>
#include <stddef.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <rtos/string.h>
#include <math.h>
#include <rtos/sof.h>
#include <rtos/task.h>
#include <rtos/alloc.h>
#include <sof/lib/notifier.h>
#include <sof/audio/component_ext.h>
#include <sof/audio/pipeline.h>
#include <sof/ipc/driver.h>
#include <sof/ipc/topology.h>
#include <sof/lib/agent.h>
#include <sof/lib/dai.h>
#include <sof/lib/dma.h>
#include <sof/lib/notifier.h>
#include <sof/schedule/edf_schedule.h>
#include <sof/schedule/ll_schedule.h>
#include <sof/schedule/ll_schedule_domain.h>
#include <sof/schedule/schedule.h>
#include <rtos/alloc.h>
#include <rtos/sof.h>
#include <rtos/string.h>
#include <rtos/task.h>
#include <rtos/wait.h>
#include <sof/audio/pipeline.h>
#include <sof/audio/component_ext.h>
#include <tplg_parser/topology.h>
#include <math.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "testbench/common_test.h"
#include "testbench/trace.h"
#include <tplg_parser/topology.h>
#include "testbench/file.h"

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

/* init components */
sys_comp_init(sof);
sys_comp_file_init();
sys_comp_selector_init();

/* Module adapter components */
Expand All @@ -53,6 +54,7 @@ int tb_setup(struct sof *sof, struct testbench_prm *tp)
sys_comp_module_drc_interface_init();
sys_comp_module_eq_fir_interface_init();
sys_comp_module_eq_iir_interface_init();
sys_comp_module_file_interface_init();
sys_comp_module_google_rtc_audio_processing_interface_init();
sys_comp_module_igo_nr_interface_init();
sys_comp_module_mfcc_interface_init();
Expand Down
Loading

0 comments on commit 9d1177a

Please sign in to comment.