2022-02-22 21:54:13 +08:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//
|
|
|
|
// Copyright(c) 2019 Intel Corporation. All rights reserved.
|
|
|
|
//
|
|
|
|
// Author: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
|
|
|
|
|
|
|
|
/* Topology parser */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ipc/topology.h>
|
|
|
|
#include <sof/lib/uuid.h>
|
|
|
|
#include <sof/ipc/topology.h>
|
2022-08-20 20:54:45 +08:00
|
|
|
#include <tplg_parser/topology.h>
|
|
|
|
#include <tplg_parser/tokens.h>
|
2022-02-22 21:54:13 +08:00
|
|
|
|
|
|
|
/* PCM */
|
|
|
|
static const struct sof_topology_token pcm_tokens[] = {
|
|
|
|
{SOF_TKN_PCM_DMAC_CONFIG, SND_SOC_TPLG_TUPLE_TYPE_WORD,
|
2023-01-03 05:00:25 +08:00
|
|
|
tplg_token_get_uint32_t,
|
2022-02-22 21:54:13 +08:00
|
|
|
offsetof(struct sof_ipc_comp_host, dmac_config), 0},
|
|
|
|
};
|
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
/* PCM - IPC3 */
|
|
|
|
static const struct sof_topology_token_group pcm_ipc3_tokens[] = {
|
|
|
|
{pcm_tokens, ARRAY_SIZE(pcm_tokens),
|
|
|
|
offsetof(struct sof_ipc_comp_host, comp)},
|
|
|
|
{comp_tokens, ARRAY_SIZE(comp_tokens),
|
|
|
|
offsetof(struct sof_ipc_comp_host, config)},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int pcm_ipc3_build(struct tplg_context *ctx, void *_pcm)
|
2022-02-22 21:54:13 +08:00
|
|
|
{
|
2023-01-03 05:00:25 +08:00
|
|
|
struct sof_ipc_comp_host *host = _pcm;
|
2022-02-22 21:54:13 +08:00
|
|
|
int comp_id = ctx->comp_id;
|
|
|
|
|
|
|
|
/* configure host comp IPC message */
|
|
|
|
host->comp.hdr.size = sizeof(*host);
|
|
|
|
host->comp.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_NEW;
|
|
|
|
host->comp.id = comp_id;
|
|
|
|
host->comp.type = SOF_COMP_HOST;
|
|
|
|
host->comp.pipeline_id = ctx->pipeline_id;
|
2023-01-03 05:00:25 +08:00
|
|
|
host->direction = ctx->dir;
|
2022-02-22 21:54:13 +08:00
|
|
|
host->config.hdr.size = sizeof(host->config);
|
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-02-22 21:54:13 +08:00
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
/* PCM - IPC4 */
|
|
|
|
static const struct sof_topology_token pcm4_tokens[] = {
|
|
|
|
/* TODO */
|
|
|
|
};
|
2022-02-22 21:54:13 +08:00
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
static const struct sof_topology_token_group pcm_ipc4_tokens[] = {
|
|
|
|
{pcm4_tokens, ARRAY_SIZE(pcm4_tokens)},
|
|
|
|
};
|
2022-02-22 21:54:13 +08:00
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
static int pcm_ipc4_build(struct tplg_context *ctx, void *pcm)
|
|
|
|
{
|
|
|
|
/* TODO */
|
|
|
|
return 0;
|
|
|
|
}
|
2022-02-22 21:54:13 +08:00
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
static const struct sof_topology_module_desc pcm_ipc[] = {
|
|
|
|
{3, pcm_ipc3_tokens, ARRAY_SIZE(pcm_ipc3_tokens),
|
|
|
|
pcm_ipc3_build, sizeof(struct sof_ipc_comp_host)},
|
|
|
|
{4, pcm_ipc4_tokens, ARRAY_SIZE(pcm_ipc4_tokens), pcm_ipc4_build},
|
|
|
|
};
|
2022-02-22 21:54:13 +08:00
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
int tplg_new_pcm(struct tplg_context *ctx, void *host, size_t host_size)
|
|
|
|
{
|
|
|
|
return tplg_create_object(ctx, pcm_ipc, ARRAY_SIZE(pcm_ipc),
|
|
|
|
"pcm", host, host_size);
|
2022-02-22 21:54:13 +08:00
|
|
|
}
|
|
|
|
|