Skip to content

Commit

Permalink
Tools: Testbench: Fix ASRC 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 6647ada commit 81beaa2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
3 changes: 2 additions & 1 deletion tools/testbench/include/testbench/topology_ipc4.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#define TB_IPC4_MAX_TPLG_OBJECT_SIZE 4096
#define TB_IPC4_MAX_MSG_SIZE 384

#define TB_PROCESS_MODULE_ID 0x95
#define TB_PGA_MODULE_ID 0x6
#define TB_SRC_MODULE_ID 0x7
#define TB_ASRC_MODULE_ID 0x8
#define TB_PROCESS_MODULE_ID 0x95
#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
36 changes: 31 additions & 5 deletions tools/testbench/topology_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,21 +478,47 @@ static int tb_new_src(struct testbench_prm *tp)

static int tb_new_asrc(struct testbench_prm *tp)
{
struct ipc4_asrc_module_cfg asrc;
struct tplg_context *ctx = &tp->tplg;
char tplg_object[TB_IPC4_MAX_TPLG_OBJECT_SIZE] = {0};
struct sof_ipc_comp_asrc *asrc = (struct sof_ipc_comp_asrc *)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_asrc(ctx, &asrc->comp, TB_IPC4_MAX_TPLG_OBJECT_SIZE,
comp_info->ipc_size = sizeof(struct ipc4_asrc_module_cfg);
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_ASRC_MODULE_ID;

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

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

/* 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
5 changes: 4 additions & 1 deletion tools/tplg_parser/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ static int asrc_ipc3_build(struct tplg_context *ctx, void *_asrc)

/* ASRC - IPC4 */
static const struct sof_topology_token asrc4_tokens[] = {
/* TODO */
{SOF_TKN_ASRC_RATE_OUT, SND_SOC_TPLG_TUPLE_TYPE_WORD,
tplg_token_get_uint32_t, offsetof(struct ipc4_asrc_module_cfg, out_freq), 0},
{SOF_TKN_ASRC_OPERATION_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD,
tplg_token_get_uint32_t, offsetof(struct ipc4_asrc_module_cfg, asrc_mode), 0},
};

static const struct sof_topology_token_group asrc_ipc4_tokens[] = {
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 @@ -21,6 +21,7 @@
#include <sof/list.h>
#include <volume/peak_volume.h>
#include <src/src_ipc.h>
#include <asrc/asrc_ipc4.h>

#include "copier/copier.h"

Expand Down

0 comments on commit 81beaa2

Please sign in to comment.