summaryrefslogtreecommitdiff
path: root/sound/soc/intel/avs/topology.h
blob: 6a59dd766603f4ac974763fc3e759f841f4f94b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright(c) 2021 Intel Corporation. All rights reserved.
 *
 * Authors: Cezary Rojewski <cezary.rojewski@intel.com>
 *          Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
 */

#ifndef __SOUND_SOC_INTEL_AVS_TPLG_H
#define __SOUND_SOC_INTEL_AVS_TPLG_H

#include <linux/list.h>
#include "messages.h"

#define INVALID_OBJECT_ID	UINT_MAX

struct snd_soc_component;

struct avs_tplg {
	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
	u32 version;
	struct snd_soc_component *comp;

	struct avs_tplg_library *libs;
	u32 num_libs;
	struct avs_audio_format *fmts;
	u32 num_fmts;
	struct avs_tplg_modcfg_base *modcfgs_base;
	u32 num_modcfgs_base;
	struct avs_tplg_modcfg_ext *modcfgs_ext;
	u32 num_modcfgs_ext;
	struct avs_tplg_pplcfg *pplcfgs;
	u32 num_pplcfgs;
	struct avs_tplg_binding *bindings;
	u32 num_bindings;
	u32 num_condpath_tmpls;
	struct avs_tplg_init_config *init_configs;
	u32 num_init_configs;

	struct list_head path_tmpl_list;
};

struct avs_tplg_library {
	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
};

/* Matches header of struct avs_mod_cfg_base. */
struct avs_tplg_modcfg_base {
	u32 cpc;
	u32 ibs;
	u32 obs;
	u32 is_pages;
};

struct avs_tplg_pin_format {
	u32 pin_index;
	u32 iobs;
	struct avs_audio_format *fmt;
};

struct avs_tplg_modcfg_ext {
	guid_t type;

	union {
		struct {
			u16 num_input_pins;
			u16 num_output_pins;
			struct avs_tplg_pin_format *pin_fmts;
		} generic;
		struct {
			struct avs_audio_format *out_fmt;
			struct avs_audio_format *blob_fmt; /* optional override */
			u32 feature_mask;
			union avs_virtual_index vindex;
			u32 dma_type;
			u32 dma_buffer_size;
			u32 config_length;
			/* config_data part of priv data */
		} copier;
		struct {
			u32 out_channel_config;
			u32 coefficients_select;
			s32 coefficients[AVS_CHANNELS_MAX];
			u32 channel_map;
		} updown_mix;
		struct {
			u32 out_freq;
		} src;
		struct {
			u32 out_freq;
			u8 mode;
			u8 disable_jitter_buffer;
		} asrc;
		struct {
			u32 cpc_lp_mode;
		} wov;
		struct {
			struct avs_audio_format *ref_fmt;
			struct avs_audio_format *out_fmt;
			u32 cpc_lp_mode;
		} aec;
		struct {
			struct avs_audio_format *ref_fmt;
			struct avs_audio_format *out_fmt;
		} mux;
		struct {
			struct avs_audio_format *out_fmt;
		} micsel;
	};
};

/* Specifies path behaviour during PCM ->trigger(START) command. */
enum avs_tplg_trigger {
	AVS_TPLG_TRIGGER_AUTO = 0,
};

struct avs_tplg_pplcfg {
	u16 req_size;
	u8 priority;
	bool lp;
	u16 attributes;
	enum avs_tplg_trigger trigger;
};

struct avs_tplg_binding {
	char target_tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
	u32 target_path_tmpl_id;
	u32 target_ppl_id;
	u32 target_mod_id;
	u8 target_mod_pin;
	u32 mod_id;
	u8 mod_pin;
	u8 is_sink;
};

struct avs_tplg_path_template_id {
	u32 id;
	char tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
};

struct avs_tplg_path_template {
	u32 id;

	struct snd_soc_dapm_widget *w;

	struct list_head path_list;

	struct avs_tplg *owner;
	/* Driver path templates management. */
	struct list_head node;
};

struct avs_tplg_init_config {
	u32 id;

	u8 param;
	size_t length;
	void *data;
};

struct avs_tplg_path {
	u32 id;

	/* Path format requirements. */
	struct avs_audio_format *fe_fmt;
	struct avs_audio_format *be_fmt;

	struct list_head ppl_list;

	struct avs_tplg_path_template *owner;
	/* Path template path-variants management. */
	struct list_head node;
};

struct avs_tplg_pipeline {
	u32 id;

	struct avs_tplg_pplcfg *cfg;
	struct avs_tplg_binding **bindings;
	u32 num_bindings;
	struct list_head mod_list;

	struct avs_tplg_path *owner;
	/* Path pipelines management. */
	struct list_head node;
};

struct avs_tplg_module {
	u32 id;

	struct avs_tplg_modcfg_base *cfg_base;
	struct avs_audio_format *in_fmt;
	u8 core_id;
	u8 domain;
	struct avs_tplg_modcfg_ext *cfg_ext;
	u32 ctl_id;
	u32 num_config_ids;
	u32 *config_ids;

	struct avs_tplg_pipeline *owner;
	/* Pipeline modules management. */
	struct list_head node;
};

struct avs_tplg *avs_tplg_new(struct snd_soc_component *comp);

int avs_load_topology(struct snd_soc_component *comp, const char *filename);
int avs_remove_topology(struct snd_soc_component *comp);

#endif