Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/arch/host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/arch/host/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
2 changes: 0 additions & 2 deletions src/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/host/schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
50 changes: 6 additions & 44 deletions src/host/testbench.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
30 changes: 20 additions & 10 deletions src/host/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@jajanusz sorry for the delayed response. although harmless, this step is unnecessary because there will only ever be one DAPM_WIDGET header in topology containing all the widgets, if I am not mistaken. So the num_comps should just be equal to the 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++,
Expand Down
1 change: 0 additions & 1 deletion src/include/host/common_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 4 additions & 0 deletions src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tools/test/audio/src_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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

# Use topology from component test topologies
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}

Expand Down