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
|
|
|
|
|
|
|
/* scheduling */
|
|
|
|
static const struct sof_topology_token sched_tokens[] = {
|
|
|
|
{SOF_TKN_SCHED_PERIOD, 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_pipe_new, period), 0},
|
|
|
|
{SOF_TKN_SCHED_PRIORITY, 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_pipe_new, priority), 0},
|
|
|
|
{SOF_TKN_SCHED_MIPS, 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_pipe_new, period_mips), 0},
|
|
|
|
{SOF_TKN_SCHED_CORE, 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_pipe_new, core), 0},
|
|
|
|
{SOF_TKN_SCHED_FRAMES, 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_pipe_new, frames_per_sched), 0},
|
|
|
|
{SOF_TKN_SCHED_TIME_DOMAIN, 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_pipe_new, time_domain), 0},
|
|
|
|
};
|
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
/* Pipeline - IPC3 */
|
|
|
|
static const struct sof_topology_token_group pipeline_ipc3_tokens[] = {
|
|
|
|
{sched_tokens, ARRAY_SIZE(sched_tokens),
|
|
|
|
0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int pipeline_ipc3_build(struct tplg_context *ctx, void *_pipeline)
|
2022-02-22 21:54:13 +08:00
|
|
|
{
|
2023-01-03 05:00:25 +08:00
|
|
|
struct sof_ipc_pipe_new *pipeline = _pipeline;
|
2022-02-22 21:54:13 +08:00
|
|
|
int comp_id = ctx->comp_id;
|
|
|
|
|
|
|
|
/* configure pipeline */
|
|
|
|
pipeline->comp_id = comp_id;
|
|
|
|
pipeline->pipeline_id = ctx->pipeline_id;
|
|
|
|
pipeline->hdr.size = sizeof(*pipeline);
|
|
|
|
pipeline->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_PIPE_NEW;
|
|
|
|
|
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
|
|
|
/* Pipeline - IPC4 */
|
|
|
|
static const struct sof_topology_token pipeline4_tokens[] = {
|
2023-08-05 07:23:16 +08:00
|
|
|
{SOF_TKN_SCHED_CORE, SND_SOC_TPLG_TUPLE_TYPE_WORD, tplg_token_get_uint32_t,
|
|
|
|
offsetof(struct sof_ipc_pipe_new, core)},
|
2023-01-03 05:00:25 +08:00
|
|
|
};
|
2022-02-22 21:54:13 +08:00
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
static const struct sof_topology_token_group pipeline_ipc4_tokens[] = {
|
|
|
|
{pipeline4_tokens, ARRAY_SIZE(pipeline4_tokens)},
|
|
|
|
};
|
2022-02-22 21:54:13 +08:00
|
|
|
|
2023-08-05 07:23:16 +08:00
|
|
|
static int pipeline_ipc4_build(struct tplg_context *ctx, void *_pipeline)
|
2023-01-03 05:00:25 +08:00
|
|
|
{
|
2023-08-05 07:23:16 +08:00
|
|
|
struct sof_ipc_pipe_new *pipeline = _pipeline;
|
|
|
|
|
|
|
|
pipeline->pipeline_id = ctx->pipeline_id;
|
2023-08-17 09:40:17 +08:00
|
|
|
tplg_debug("pipeline: %d core: %d\n", pipeline->pipeline_id, pipeline->core);
|
2023-08-05 07:23:16 +08:00
|
|
|
|
2022-02-22 21:54:13 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
static const struct sof_topology_module_desc pipeline_ipc[] = {
|
|
|
|
{3, pipeline_ipc3_tokens, ARRAY_SIZE(pipeline_ipc3_tokens),
|
|
|
|
pipeline_ipc3_build, sizeof(struct sof_ipc_pipe_new)},
|
|
|
|
{4, pipeline_ipc4_tokens, ARRAY_SIZE(pipeline_ipc4_tokens), pipeline_ipc4_build},
|
|
|
|
};
|
2022-08-20 20:54:45 +08:00
|
|
|
|
|
|
|
/* load pipeline dapm widget */
|
2023-01-03 05:00:25 +08:00
|
|
|
int tplg_new_pipeline(struct tplg_context *ctx, void *pipeline,
|
|
|
|
size_t pipeline_size, struct snd_soc_tplg_ctl_hdr *rctl)
|
2022-02-22 21:54:13 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2023-01-03 05:00:25 +08:00
|
|
|
ret = tplg_create_object(ctx, pipeline_ipc, ARRAY_SIZE(pipeline_ipc),
|
|
|
|
"pipeline", pipeline, pipeline_size);
|
2022-08-20 20:54:45 +08:00
|
|
|
return ret;
|
2022-02-22 21:54:13 +08:00
|
|
|
}
|