diff --git a/src/arch/host/CMakeLists.txt b/src/arch/host/CMakeLists.txt index 839f995917f4..2452486c4e21 100644 --- a/src/arch/host/CMakeLists.txt +++ b/src/arch/host/CMakeLists.txt @@ -19,6 +19,8 @@ set(CONFIG_COMP_MUX 1) set(CONFIG_COMP_SWITCH 1) set(CONFIG_COMP_DAI 1) set(CONFIG_COMP_SEL 1) +set(CONFIG_TRACE 1) +set(CONFIG_TRACEE 1) configure_file ( "${PROJECT_SOURCE_DIR}/src/arch/host/config.h.in" diff --git a/src/arch/host/config.h.in b/src/arch/host/config.h.in index f4dca43951ee..3bcd143a5e1e 100644 --- a/src/arch/host/config.h.in +++ b/src/arch/host/config.h.in @@ -9,3 +9,5 @@ #define CONFIG_COMP_MUX @CONFIG_COMP_MUX@ #define CONFIG_COMP_SWITCH @CONFIG_COMP_SWITCH@ #define CONFIG_COMP_DAI @CONFIG_COMP_DAI@ +#define CONFIG_TRACE @CONFIG_TRACE@ +#define CONFIG_TRACEE @CONFIG_TRACEE@ diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 9dca5e9bb6e4..f022d13cc614 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -74,8 +74,6 @@ add_library(sof_audio_core SHARED "") target_link_libraries(sof_audio_core PRIVATE sof_options) target_link_libraries(sof_audio_core PRIVATE -Wl,--export-dynamic) add_local_sources(sof_audio_core - dai.c - host.c pipeline.c component.c buffer.c diff --git a/src/host/schedule.c b/src/host/schedule.c index 920938204290..b92a73e5f514 100644 --- a/src/host/schedule.c +++ b/src/host/schedule.c @@ -55,7 +55,10 @@ int schedule_task_init(struct task *task, uint16_t type, uint16_t priority, task->func = func; task->data = data; - return schedulers[task->type]->schedule_task_init(task, xflags); + if (schedulers[task->type]->schedule_task_init) + return schedulers[task->type]->schedule_task_init(task, xflags); + else + return -ENOENT; } void schedule_task(struct task *task, uint64_t start, uint64_t deadline, diff --git a/src/host/testbench.c b/src/host/testbench.c index e212a0aa8b48..36283f0f8570 100644 --- a/src/host/testbench.c +++ b/src/host/testbench.c @@ -42,10 +42,9 @@ /* shared library look up table */ struct shared_lib_table lib_table[NUM_WIDGETS_SUPPORTED] = { -{"file", "", SND_SOC_TPLG_DAPM_AIF_IN, "", 0, NULL}, -{"vol", "libsof_volume.so", SND_SOC_TPLG_DAPM_PGA, "sys_comp_volume_init", 0, - NULL}, -{"src", "libsof_src.so", SND_SOC_TPLG_DAPM_SRC, "sys_comp_src_init", 0, NULL}, + {"file", "", SND_SOC_TPLG_DAPM_AIF_IN, 0, NULL}, + {"vol", "libsof_volume.so", SND_SOC_TPLG_DAPM_PGA, 0, NULL}, + {"src", "libsof_src.so", SND_SOC_TPLG_DAPM_SRC, 0, NULL}, }; /* main firmware context */ @@ -71,7 +70,6 @@ static void parse_libraries(char *libs) char *lib_token = NULL; char *comp_token = NULL; char *token = strtok_r(libs, ",", &lib_token); - char message[DEBUG_MSG_LEN]; int index; while (token) { @@ -92,19 +90,9 @@ static void parse_libraries(char *libs) if (!token1) break; - /* close default shared library object */ - if (lib_table[index].handle) - dlclose(lib_table[index].handle); - - /* open volume shared library object */ - lib_table[index].handle = dlopen(token1, RTLD_LAZY); - if (!lib_table[index].handle) { - fprintf(stderr, "error: %s\n", dlerror()); - exit(EXIT_FAILURE); - } - - sprintf(message, "opening shared lib %s\n", token1); - debug_print(message); + /* set to new name that may be used while loading */ + strncpy(lib_table[index].library_name, token1, + MAX_LIB_NAME_LEN - 1); /* next library */ token = strtok_r(NULL, ",", &lib_token); @@ -154,25 +142,6 @@ static void free_comps(void) } } -static int set_up_library_table(void) -{ - int i; - - /* set up default shared libraries */ - for (i = 1; i < NUM_WIDGETS_SUPPORTED; i++) { - - /* open default shared library */ - lib_table[i].handle = - dlopen(lib_table[i].library_name, RTLD_LAZY); - if (!lib_table[i].handle) { - fprintf(stderr, "error: %s\n", dlerror()); - return -EINVAL; - } - } - - return 0; -} - static void parse_input_args(int argc, char **argv, struct testbench_prm *tp) { int option = 0; @@ -246,13 +215,6 @@ int main(int argc, char **argv) tp.fs_in = 0; tp.fs_out = 0; - /* set up shared library look up table */ - ret = set_up_library_table(); - if (ret < 0) { - fprintf(stderr, "error: setting up shared libraried\n"); - exit(EXIT_FAILURE); - } - /* command line arguments*/ parse_input_args(argc, argv, &tp); diff --git a/src/host/topology.c b/src/host/topology.c index 08bc296fdfe4..10ee56744380 100644 --- a/src/host/topology.c +++ b/src/host/topology.c @@ -53,7 +53,7 @@ struct shared_lib_table *lib_table; static void register_comp(int comp_type) { int index; - char message[DEBUG_MSG_LEN]; + char message[DEBUG_MSG_LEN + MAX_LIB_NAME_LEN]; /* register file comp driver (no shared library needed) */ if (comp_type == SND_SOC_TPLG_DAPM_DAI_IN || @@ -77,11 +77,19 @@ static void register_comp(int comp_type) lib_table[index].comp_name); debug_print(message); - /* register comp driver */ - void (*comp_init)() = - (void (*)(void))dlsym(lib_table[index].handle, - lib_table[index].comp_init); - comp_init(); + /* open shared library object */ + sprintf(message, "opening shared lib %s\n", + lib_table[index].library_name); + debug_print(message); + + lib_table[index].handle = dlopen(lib_table[index].library_name, + RTLD_LAZY); + if (!lib_table[index].handle) { + fprintf(stderr, "error: %s\n", dlerror()); + exit(EXIT_FAILURE); + } + + /* comp init is executed on lib load */ lib_table[index].register_drv = 1; } @@ -828,11 +836,13 @@ int parse_topology(struct sof *sof, struct shared_lib_table *library_table, sprintf(message, "number of DAPM widgets %d\n", hdr->count); debug_print(message); - size = sizeof(struct comp_info) * hdr->count; - temp_comp_list = (struct comp_info *)malloc(size); - num_comps = hdr->count; - for (i = 0; i < hdr->count; i++) + num_comps += hdr->count; + size = sizeof(struct comp_info) * num_comps; + temp_comp_list = (struct comp_info *) + realloc(temp_comp_list, size); + + for (i = (num_comps - hdr->count); i < num_comps; i++) load_widget(sof, fr_id, fw_id, sched_id, temp_comp_list, &pipeline, next_comp_id++, diff --git a/src/include/host/common_test.h b/src/include/host/common_test.h index d8f9fe7697a2..e4b09f45cf0d 100644 --- a/src/include/host/common_test.h +++ b/src/include/host/common_test.h @@ -66,7 +66,6 @@ struct shared_lib_table { char *comp_name; char library_name[MAX_LIB_NAME_LEN]; uint32_t widget_type; - const char *comp_init; int register_drv; void *handle; }; diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index 85a3f0a390ab..71fdb390ab6f 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -152,6 +152,10 @@ */ #ifdef UNIT_TEST #define DECLARE_COMPONENT(init) +#elif CONFIG_HOST +/* In case of shared libs components are initialised in dlopen */ +#define DECLARE_COMPONENT(init) __attribute__((constructor)) \ + static void _comp_init(void) { init(); } #else #define DECLARE_COMPONENT(init) __attribute__((__used__)) \ __attribute__((section(".comp_init"))) static void(*f)(void) = init diff --git a/tools/test/audio/src_run.sh b/tools/test/audio/src_run.sh index 9c88b17f1320..3c41a4f7a32e 100755 --- a/tools/test/audio/src_run.sh +++ b/tools/test/audio/src_run.sh @@ -10,7 +10,7 @@ FN_IN=$5 FN_OUT=$6 # The HOST_ROOT path need to be retrived from SOFT .configure command -HOST_ROOT=../../../../host-root +HOST_ROOT=../../../build_host/install/ HOST_EXE=$HOST_ROOT/bin/testbench HOST_LIB=$HOST_ROOT/lib @@ -18,7 +18,7 @@ HOST_LIB=$HOST_ROOT/lib INFMT=s${BITS_IN}le OUTFMT=s${BITS_IN}le MCLK=24576k -tplg1=../../test/topology/test-playback-ssp2-mclk-0-I2S- +tplg1=../../build_tools/test/topology/test-playback-ssp2-mclk-0-I2S- tplg2=${COMP}-${INFMT}-${OUTFMT}-48k-${MCLK}-nocodec.tplg TPLG=${tplg1}${tplg2}