Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][Do no review] Tools: Testbech: Add IPC4 support #9025

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/arch/host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (supports_implicit_fallthrough)
endif()

# C & ASM flags
target_compile_options(sof_options INTERFACE -g -O3 -fPIC -DPIC -std=c99 -std=gnu99 -fgnu89-inline
target_compile_options(sof_options INTERFACE -g -fPIC -DPIC -std=c99 -std=gnu99 -fgnu89-inline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long term we can inherit the optimization level from Kconfig

-Wall -Werror -Wmissing-prototypes ${implicit_fallthrough} -Wno-pointer-to-int-cast
-Wno-int-to-pointer-cast -Wpointer-arith
-DCONFIG_LIBRARY "-imacros${CONFIG_H_PATH}")
Expand Down
3 changes: 2 additions & 1 deletion src/arch/host/configs/library_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ CONFIG_COMP_VOLUME=y
CONFIG_COMP_VOLUME_LINEAR_RAMP=y
CONFIG_COMP_VOLUME_WINDOWS_FADE=y
CONFIG_DEBUG_MEMORY_USAGE_SCAN=n
CONFIG_IPC_MAJOR_3=y
#CONFIG_IPC_MAJOR_3=y
CONFIG_IPC_MAJOR_4=y
CONFIG_LIBRARY=y
CONFIG_LIBRARY_STATIC=y
CONFIG_MATH_IIR_DF2T=y
Expand Down
2 changes: 1 addition & 1 deletion src/audio/crossover/crossover_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int crossover_get_sink_id(struct comp_data *cd, uint32_t pipeline_id, uint32_t i
* kernel know that the base_cfg_ext needs to be appended to the IPC payload. The
* Extension is needed to know the output pin indices.
*/
int crossover_init_output_pins(struct processing_module *mod)
static int crossover_init_output_pins(struct processing_module *mod)
{
struct comp_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;
Expand Down
2 changes: 2 additions & 0 deletions src/audio/pipeline/pipeline-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ static int pipeline_comp_trigger(struct comp_dev *current,
* Initialization delay is only used with SSP, where we
* don't use more than one DAI per copier
*/
#if !CONFIG_LIBRARY
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we provide this API in the file module instead, even if it returns 0 today.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I started to separate file component module adapter changes into a separate PR. It was quite simple to get dai_get_init_delay_ms() to pass without duplicating much of DAI data structures.

struct dai_data *dd;
#if CONFIG_IPC_MAJOR_3
dd = comp_get_drvdata(current);
Expand All @@ -498,6 +499,7 @@ static int pipeline_comp_trigger(struct comp_dev *current,
#error Unknown IPC major version
#endif
ppl_data->delay_ms = dai_get_init_delay_ms(dd->dai);
#endif
}
break;
default:
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/ipc4/alh.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#ifndef __SOF_IPC4_ALH_H__
#define __SOF_IPC4_ALH_H__

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <ipc4/gateway.h>
Expand Down
5 changes: 5 additions & 0 deletions src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -744,22 +744,27 @@ void sys_comp_host_init(void);
void sys_comp_kpb_init(void);
void sys_comp_selector_init(void);

void sys_comp_module_copier_interface_init(void);
void sys_comp_module_crossover_interface_init(void);
void sys_comp_module_dcblock_interface_init(void);
void sys_comp_module_demux_interface_init(void);
void sys_comp_module_drc_interface_init(void);
void sys_comp_module_dts_interface_init(void);
void sys_comp_module_eq_fir_interface_init(void);
void sys_comp_module_eq_iir_interface_init(void);
void sys_comp_module_gain_interface_init(void);
void sys_comp_module_google_rtc_audio_processing_interface_init(void);
void sys_comp_module_google_ctc_audio_processing_interface_init(void);
void sys_comp_module_igo_nr_interface_init(void);
void sys_comp_module_mfcc_interface_init(void);
void sys_comp_module_mixer_interface_init(void);
void sys_comp_module_mixin_interface_init(void);
void sys_comp_module_mixout_interface_init(void);
void sys_comp_module_multiband_drc_interface_init(void);
void sys_comp_module_mux_interface_init(void);
void sys_comp_module_asrc_interface_init(void);
void sys_comp_module_rtnr_interface_init(void);
void sys_comp_module_selector_interface_init(void);
void sys_comp_module_src_interface_init(void);
void sys_comp_module_tdfb_interface_init(void);
void sys_comp_module_volume_interface_init(void);
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
10 changes: 10 additions & 0 deletions src/include/sof/lib/dai-legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ struct llp_slot_info {
uint32_t reg_offset;
};

typedef int (*channel_copy_func)(const struct audio_stream *src, unsigned int src_channel,
struct audio_stream *dst, unsigned int dst_channel,
unsigned int frames);

/**
* \brief DAI runtime data
*/
Expand All @@ -181,6 +185,12 @@ struct dai_data {
int xrun; /* true if we are doing xrun recovery */

pcm_converter_func process; /* processing function */
uint32_t chmap;
channel_copy_func channel_copy; /* channel copy func used by multi-endpoint
* gateway to mux/demux stream from/to multiple
* DMA buffers
*/


uint32_t period_bytes; /* number of bytes per one period */
uint64_t total_data_processed;
Expand Down
20 changes: 10 additions & 10 deletions src/ipc/ipc3/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,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 @@ -211,20 +210,22 @@ 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:
if (IPC_TAIL_IS_SIZE_INVALID(*file))
return -EBADMSG;
case SOF_COMP_FILEREAD:
case SOF_COMP_FILEWRITE:
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 @@ -241,7 +242,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
4 changes: 4 additions & 0 deletions src/ipc/ipc4/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ static void ipc_compound_msg_done(uint32_t msg_id, int error)

static int ipc_wait_for_compound_msg(void)
{
#if CONFIG_LIBRARY
atomic_set(&msg_data.delayed_reply, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, where do we clear this in DSP mode ? i.e. does this need to be executed on all targets ?

#else
int try_count = 30;

while (atomic_read(&msg_data.delayed_reply)) {
Expand All @@ -545,6 +548,7 @@ static int ipc_wait_for_compound_msg(void)
return IPC4_FAILURE;
}
}
#endif

return IPC4_SUCCESS;
}
Expand Down
10 changes: 10 additions & 0 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,16 @@ static const struct ipc4_module_uuid uuid_map[] = {
.d = { 0xa0, 0x8f, 0x97, 0xfc, 0xc4, 0x2e, 0xaa, 0xeb }}}, /* ALSA aplay */
{0x99, {.a = 0x66def9f0, .b = 0x39f2, .c = 0x11ed,
.d = { 0xf7, 0x89, 0xaf, 0x98, 0xa6, 0x44, 0x0c, 0xc4 }}}, /* ALSA arecord */
{0x9a, {.a = 0xbfc7488c, .b = 0x75aa, .c = 0x4ce8,
.d = { 0x9d, 0xbe, 0xd8, 0xda, 0x08, 0xa6, 0x98, 0xc2 }}}, /* FILE component */
{0x9b, {.a = 0xbfc7488c, .b = 0x75aa, .c = 0x4ce8,
.d = { 0x9d, 0xbe, 0xd8, 0xda, 0x08, 0xa6, 0x98, 0xc2 }}}, /* FILE component */
{0x9c, {.a = 0xbfc7488c, .b = 0x75aa, .c = 0x4ce8,
.d = { 0x9d, 0xbe, 0xd8, 0xda, 0x08, 0xa6, 0x98, 0xc2 }}}, /* FILE component */
{0x9d, {.a = 0xbfc7488c, .b = 0x75aa, .c = 0x4ce8,
.d = { 0x9d, 0xbe, 0xd8, 0xda, 0x08, 0xa6, 0x98, 0xc2 }}}, /* FILE component */
{0x9e, {.a = 0xb809efaf, .b = 0x5681, .c = 0x42b1,
.d = { 0x9e, 0xd6, 0x04, 0xbb, 0x01, 0x2d, 0xd3, 0x84 }}}, /* dcblock */
};

static const struct comp_driver *ipc4_library_get_drv(int module_id)
Expand Down
1 change: 1 addition & 0 deletions src/platform/library/include/platform/lib/ll_schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef __LIBRARY_INCLUDE_LIB_SCHEDULE_H__
#define __LIBRARY_INCLUDE_LIB_SCHEDULE_H__

#include <rtos/task.h>
#include <stdint.h>

struct task;
Expand Down
3 changes: 2 additions & 1 deletion tools/test/audio/comp_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ run_testbench ()
delete_file_check "$FN_TRACE"
if [ -z "$FN_TRACE" ]; then
# shellcheck disable=SC2086
$VALGRIND_CMD $CMD
#$VALGRIND_CMD $CMD
$CMD 2> /dev/null
else
$VALGRIND_CMD $CMD 2> "$FN_TRACE" || {
local ret=$?
Expand Down
11 changes: 10 additions & 1 deletion tools/testbench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ add_executable(testbench
common_test.c
file.c
topology.c
topology_ipc4.c
)

# TODO
#if(CONFIG_IPC_MAJOR_3)
# add_local_sources(testbench topology_ipc3.c)
#elseif(CONFIG_IPC_MAJOR_4)
# add_local_sources(testbench topology_ipc4.c)
#endif()


sof_append_relative_path_definitions(testbench)

target_include_directories(testbench PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
Expand All @@ -41,7 +50,7 @@ if (supports_implicit_fallthrough)
set(implicit_fallthrough -Wimplicit-fallthrough)
endif()

target_compile_options(testbench PRIVATE -g -O3 -Wall -Werror -Wmissing-prototypes
target_compile_options(testbench PRIVATE -g -Wall -Werror -Wmissing-prototypes
${implicit_fallthrough} -DCONFIG_LIBRARY -DCONFIG_LIBRARY_STATIC -imacros${config_h})

target_link_libraries(testbench PRIVATE -lm)
Expand Down
Loading
Loading