Skip to content

Commit

Permalink
Tools: Testbench: Fix SRC component load
Browse files Browse the repository at this point in the history
This replaces for IPC4 testbench the previous non-working version
that was a copy of IPC3 version.

Signed-off-by: Seppo Ingalsuo <[email protected]>
  • Loading branch information
singalsu committed Oct 3, 2024
1 parent 2942192 commit 6647ada
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions tools/testbench/include/testbench/topology_ipc4.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#define TB_PROCESS_MODULE_ID 0x95
#define TB_PGA_MODULE_ID 0x6
#define TB_SRC_MODULE_ID 0x7
#define TB_FILE_OUT_AIF_MODULE_ID 0x9a
#define TB_FILE_IN_AIF_MODULE_ID 0x9b
#define TB_FILE_OUT_DAI_MODULE_ID 0x9c
Expand Down
34 changes: 30 additions & 4 deletions tools/testbench/topology_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,21 +431,47 @@ int tb_pipelines_set_state(struct testbench_prm *tp, int state, int dir)

static int tb_new_src(struct testbench_prm *tp)
{
struct ipc4_config_src src;
struct tplg_context *ctx = &tp->tplg;
char tplg_object[TB_IPC4_MAX_TPLG_OBJECT_SIZE] = {0};
struct sof_ipc_comp_src *src = (struct sof_ipc_comp_src *)tplg_object;
struct tplg_comp_info *comp_info = ctx->current_comp_info;
struct snd_soc_tplg_ctl_hdr *tplg_ctl;
size_t uuid_offset;
int ret;

ret = tplg_parse_widget_audio_formats(ctx);
if (ret < 0)
return ret;

tplg_ctl = calloc(ctx->hdr->payload_size, 1);
if (!tplg_ctl)
return -ENOMEM;

ret = tplg_new_src(ctx, &src->comp, TB_IPC4_MAX_TPLG_OBJECT_SIZE,
comp_info->ipc_size = sizeof(struct ipc4_config_src);
uuid_offset = comp_info->ipc_size;
comp_info->ipc_size += sizeof(struct sof_uuid);
comp_info->ipc_payload = calloc(comp_info->ipc_size, 1);
if (!comp_info->ipc_payload)
return -ENOMEM;

comp_info->instance_id = tp->instance_ids[SND_SOC_TPLG_DAPM_EFFECT]++;
comp_info->module_id = TB_SRC_MODULE_ID;

ret = tplg_new_src(ctx, &src, sizeof(struct ipc4_config_src),
tplg_ctl, ctx->hdr->payload_size);
if (ret < 0)
if (ret < 0) {
fprintf(stderr, "error: failed to create SRC\n");
goto out;
}

/* copy volume data to ipc_payload */
memcpy(comp_info->ipc_payload, &src, sizeof(struct ipc4_config_src));

/* copy uuid to the end of the payload */
memcpy(comp_info->ipc_payload + uuid_offset, &comp_info->uuid, sizeof(struct sof_uuid));

tb_setup_widget_ipc_msg(comp_info);

out:
free(tplg_ctl);
return ret;
}
Expand Down
1 change: 1 addition & 0 deletions tools/tplg_parser/include/tplg_parser/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <kernel/tokens.h>
#include <sof/list.h>
#include <volume/peak_volume.h>
#include <src/src_ipc.h>

#include "copier/copier.h"

Expand Down
5 changes: 4 additions & 1 deletion tools/tplg_parser/src.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <sof/ipc/topology.h>
#include <tplg_parser/topology.h>
#include <tplg_parser/tokens.h>
#include <src/src_ipc.h>

/* SRC - IPC3 */
static const struct sof_topology_token src3_tokens[] = {
Expand Down Expand Up @@ -55,7 +56,9 @@ static int src_ipc3_build(struct tplg_context *ctx, void *_src)

/* ASRC - IPC4 */
static const struct sof_topology_token src4_tokens[] = {
/* TODO */
{SOF_TKN_SRC_RATE_OUT, SND_SOC_TPLG_TUPLE_TYPE_WORD,
tplg_token_get_uint32_t,
offsetof(struct ipc4_config_src, sink_rate), 0},
};

static const struct sof_topology_token_group src_ipc4_tokens[] = {
Expand Down

0 comments on commit 6647ada

Please sign in to comment.