xref: /linux/sound/soc/intel/avs/topology.h (revision 2aa680df68062e4e0c356ec2aa7100c13654907b)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright(c) 2021 Intel Corporation
4  *
5  * Authors: Cezary Rojewski <cezary.rojewski@intel.com>
6  *          Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
7  */
8 
9 #ifndef __SOUND_SOC_INTEL_AVS_TPLG_H
10 #define __SOUND_SOC_INTEL_AVS_TPLG_H
11 
12 #include <linux/list.h>
13 #include "messages.h"
14 
15 #define INVALID_OBJECT_ID	UINT_MAX
16 
17 struct snd_soc_component;
18 
19 struct avs_tplg {
20 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
21 	u32 version;
22 	struct snd_soc_component *comp;
23 
24 	struct avs_tplg_library *libs;
25 	u32 num_libs;
26 	struct avs_audio_format *fmts;
27 	u32 num_fmts;
28 	struct avs_tplg_modcfg_base *modcfgs_base;
29 	u32 num_modcfgs_base;
30 	struct avs_tplg_modcfg_ext *modcfgs_ext;
31 	u32 num_modcfgs_ext;
32 	struct avs_tplg_pplcfg *pplcfgs;
33 	u32 num_pplcfgs;
34 	struct avs_tplg_binding *bindings;
35 	u32 num_bindings;
36 	struct avs_tplg_path_template *condpath_tmpls;
37 	u32 num_condpath_tmpls;
38 	struct avs_tplg_init_config *init_configs;
39 	u32 num_init_configs;
40 	struct avs_tplg_nhlt_config *nhlt_configs;
41 	u32 num_nhlt_configs;
42 
43 	struct list_head path_tmpl_list;
44 };
45 
46 struct avs_tplg_library {
47 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
48 };
49 
50 /* Matches header of struct avs_mod_cfg_base. */
51 struct avs_tplg_modcfg_base {
52 	u32 cpc;
53 	u32 ibs;
54 	u32 obs;
55 	u32 is_pages;
56 };
57 
58 struct avs_tplg_pin_format {
59 	u32 pin_index;
60 	u32 iobs;
61 	struct avs_audio_format *fmt;
62 };
63 
64 struct avs_tplg_modcfg_ext {
65 	guid_t type;
66 
67 	union {
68 		struct {
69 			u16 num_input_pins;
70 			u16 num_output_pins;
71 			struct avs_tplg_pin_format *pin_fmts;
72 		} generic;
73 		struct {
74 			struct avs_audio_format *out_fmt;
75 			struct avs_audio_format *blob_fmt; /* optional override */
76 			u32 feature_mask;
77 			union avs_virtual_index vindex;
78 			u32 dma_type;
79 			u32 dma_buffer_size;
80 		} copier;
81 		struct {
82 			struct avs_audio_format *ref_fmt;
83 			struct avs_audio_format *out_fmt;
84 			u32 wake_tick_period;
85 			union avs_virtual_index vindex;
86 			u32 dma_type;
87 			u32 dma_buffer_size;
88 			struct avs_audio_format *blob_fmt; /* optional override */
89 		} whm;
90 		struct {
91 			u32 out_channel_config;
92 			u32 coefficients_select;
93 			s32 coefficients[AVS_COEFF_CHANNELS_MAX];
94 			u32 channel_map;
95 		} updown_mix;
96 		struct {
97 			u32 out_freq;
98 		} src;
99 		struct {
100 			u32 out_freq;
101 			u8 mode;
102 			u8 disable_jitter_buffer;
103 		} asrc;
104 		struct {
105 			u32 cpc_lp_mode;
106 		} wov;
107 		struct {
108 			struct avs_audio_format *ref_fmt;
109 			struct avs_audio_format *out_fmt;
110 			u32 cpc_lp_mode;
111 		} aec;
112 		struct {
113 			struct avs_audio_format *ref_fmt;
114 			struct avs_audio_format *out_fmt;
115 		} mux;
116 		struct {
117 			struct avs_audio_format *out_fmt;
118 		} micsel;
119 		struct {
120 			u32 target_volume;
121 			u32 curve_type;
122 			u32 curve_duration;
123 		} peakvol;
124 	};
125 };
126 
127 /* Specifies path behaviour during PCM ->trigger(START) command. */
128 enum avs_tplg_trigger {
129 	AVS_TPLG_TRIGGER_AUTO = 0,
130 };
131 
132 struct avs_tplg_pplcfg {
133 	u16 req_size;
134 	u8 priority;
135 	bool lp;
136 	u16 attributes;
137 	enum avs_tplg_trigger trigger;
138 };
139 
140 struct avs_tplg_binding {
141 	char target_tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
142 	u32 target_path_tmpl_id;
143 	u32 target_ppl_id;
144 	u32 target_mod_id;
145 	u8 target_mod_pin;
146 	u32 mod_id;
147 	u8 mod_pin;
148 	u8 is_sink;
149 };
150 
151 struct avs_tplg_path_template_id {
152 	u32 id;
153 	char tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
154 };
155 
156 struct avs_tplg_path_template {
157 	u32 id;
158 
159 	struct snd_soc_dapm_widget *w;
160 
161 	/* Conditional path. */
162 	struct avs_tplg_path_template_id source;
163 	struct avs_tplg_path_template_id sink;
164 
165 	struct list_head path_list;
166 
167 	struct avs_tplg *owner;
168 	/* Driver path templates management. */
169 	struct list_head node;
170 };
171 
172 struct avs_tplg_init_config {
173 	u32 id;
174 
175 	u8 param;
176 	size_t length;
177 	void *data;
178 };
179 
180 struct avs_tplg_nhlt_config {
181 	u32 id;
182 	struct acpi_nhlt_config *blob;
183 };
184 
185 struct avs_tplg_path {
186 	u32 id;
187 
188 	/* Path format requirements. */
189 	struct avs_audio_format *fe_fmt;
190 	struct avs_audio_format *be_fmt;
191 	/* Condpath path-variant requirements. */
192 	u32 source_path_id;
193 	u32 sink_path_id;
194 
195 	struct list_head ppl_list;
196 
197 	struct avs_tplg_path_template *owner;
198 	/* Path template path-variants management. */
199 	struct list_head node;
200 };
201 
202 struct avs_tplg_pipeline {
203 	u32 id;
204 
205 	struct avs_tplg_pplcfg *cfg;
206 	struct avs_tplg_binding **bindings;
207 	u32 num_bindings;
208 	struct list_head mod_list;
209 
210 	struct avs_tplg_path *owner;
211 	/* Path pipelines management. */
212 	struct list_head node;
213 };
214 
215 struct avs_tplg_module {
216 	u32 id;
217 
218 	struct avs_tplg_modcfg_base *cfg_base;
219 	struct avs_audio_format *in_fmt;
220 	u8 core_id;
221 	u8 domain;
222 	struct avs_tplg_modcfg_ext *cfg_ext;
223 	u32 ctl_id;
224 	u32 num_config_ids;
225 	u32 *config_ids;
226 	struct avs_tplg_nhlt_config *nhlt_config;
227 
228 	struct avs_tplg_pipeline *owner;
229 	/* Pipeline modules management. */
230 	struct list_head node;
231 };
232 
233 struct avs_tplg *avs_tplg_new(struct snd_soc_component *comp);
234 
235 int avs_load_topology(struct snd_soc_component *comp, const char *filename);
236 int avs_remove_topology(struct snd_soc_component *comp);
237 
238 #endif
239