jpayne@69
|
1 /*
|
jpayne@69
|
2 *
|
jpayne@69
|
3 * This library is free software; you can redistribute it and/or modify
|
jpayne@69
|
4 * it under the terms of the GNU Lesser General Public License as
|
jpayne@69
|
5 * published by the Free Software Foundation; either version 2.1 of
|
jpayne@69
|
6 * the License, or (at your option) any later version.
|
jpayne@69
|
7 *
|
jpayne@69
|
8 * This program is distributed in the hope that it will be useful,
|
jpayne@69
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jpayne@69
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jpayne@69
|
11 * GNU Lesser General Public License for more details.
|
jpayne@69
|
12 *
|
jpayne@69
|
13 * You should have received a copy of the GNU Lesser General Public
|
jpayne@69
|
14 * License along with this library; if not, write to the Free Software
|
jpayne@69
|
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
jpayne@69
|
16 *
|
jpayne@69
|
17 * Copyright (C) 2015 Intel Corporation
|
jpayne@69
|
18 *
|
jpayne@69
|
19 */
|
jpayne@69
|
20
|
jpayne@69
|
21 #ifndef __ALSA_TOPOLOGY_H
|
jpayne@69
|
22 #define __ALSA_TOPOLOGY_H
|
jpayne@69
|
23
|
jpayne@69
|
24 #include <stdint.h>
|
jpayne@69
|
25
|
jpayne@69
|
26 #ifdef __cplusplus
|
jpayne@69
|
27 extern "C" {
|
jpayne@69
|
28 #endif
|
jpayne@69
|
29
|
jpayne@69
|
30 /**
|
jpayne@69
|
31 * \defgroup topology Topology Interface
|
jpayne@69
|
32 * \{
|
jpayne@69
|
33 */
|
jpayne@69
|
34
|
jpayne@69
|
35 /*! \page topology ALSA Topology Interface
|
jpayne@69
|
36 *
|
jpayne@69
|
37 * The topology interface allows developers to define DSP topologies in a text
|
jpayne@69
|
38 * file format and to convert the text topology to a binary topology
|
jpayne@69
|
39 * representation that can be understood by the kernel. The topology core
|
jpayne@69
|
40 * currently recognises the following object types :-
|
jpayne@69
|
41 *
|
jpayne@69
|
42 * * Controls (mixer, enumerated and byte) including TLV data.
|
jpayne@69
|
43 * * PCMs (Front End DAI & DAI link)
|
jpayne@69
|
44 * * DAPM widgets
|
jpayne@69
|
45 * * DAPM graph elements.
|
jpayne@69
|
46 * * Physical DAI & DAI links
|
jpayne@69
|
47 * * Private data for each object type.
|
jpayne@69
|
48 * * Manifest (containing count of each object type)
|
jpayne@69
|
49 *
|
jpayne@69
|
50 * <h3>Topology File Format</h3>
|
jpayne@69
|
51 *
|
jpayne@69
|
52 * The topology text format uses the standard ALSA configuration file format to
|
jpayne@69
|
53 * describe each topology object type. This allows topology objects to include
|
jpayne@69
|
54 * other topology objects as part of their definition. i.e. a TLV data object
|
jpayne@69
|
55 * can be shared amongst many control objects that use the same TLV data.
|
jpayne@69
|
56 *
|
jpayne@69
|
57 *
|
jpayne@69
|
58 * <h4>Controls</h4>
|
jpayne@69
|
59 * Topology audio controls can belong to three different types :-
|
jpayne@69
|
60 * * Mixer control
|
jpayne@69
|
61 * * Enumerated control
|
jpayne@69
|
62 * * Byte control
|
jpayne@69
|
63 *
|
jpayne@69
|
64 * Each control type can contain TLV data, private data, operations and also
|
jpayne@69
|
65 * belong to widget objects.<br>
|
jpayne@69
|
66 *
|
jpayne@69
|
67 * <h5>Control Operations</h5>
|
jpayne@69
|
68 * Driver Kcontrol callback info(), get() and put() operations are mapped with
|
jpayne@69
|
69 * the CTL ops section in topology configuration files. The ctl ops section can
|
jpayne@69
|
70 * assign operations using the standard names (listed below) for the standard
|
jpayne@69
|
71 * kcontrol types or use ID numbers (>256) to map to bespoke driver controls.<br>
|
jpayne@69
|
72 *
|
jpayne@69
|
73 * <pre>
|
jpayne@69
|
74 *
|
jpayne@69
|
75 * ops."ctl" {
|
jpayne@69
|
76 * info "volsw"
|
jpayne@69
|
77 * get "257"
|
jpayne@69
|
78 * put "257"
|
jpayne@69
|
79 * }
|
jpayne@69
|
80 *
|
jpayne@69
|
81 * </pre>
|
jpayne@69
|
82 *
|
jpayne@69
|
83 * This mapping shows info() using the standard "volsw" info callback whilst
|
jpayne@69
|
84 * the get() and put() are mapped to bespoke driver callbacks. <br>
|
jpayne@69
|
85 *
|
jpayne@69
|
86 * The Standard operations names for control get(), put() and info calls
|
jpayne@69
|
87 * are :-
|
jpayne@69
|
88 * * volsw
|
jpayne@69
|
89 * * volsw_sx
|
jpayne@69
|
90 * * volsw_xr_sx
|
jpayne@69
|
91 * * enum
|
jpayne@69
|
92 * * bytes
|
jpayne@69
|
93 * * enum_value
|
jpayne@69
|
94 * * range
|
jpayne@69
|
95 * * strobe
|
jpayne@69
|
96 *
|
jpayne@69
|
97 * <h5>Control Access</h5>
|
jpayne@69
|
98 * Controls access can be specified using the "access" section. If no "access"
|
jpayne@69
|
99 * section is defined then default RW access flags are set for normal and TLV
|
jpayne@69
|
100 * controls.
|
jpayne@69
|
101 *
|
jpayne@69
|
102 * <pre>
|
jpayne@69
|
103 * access [
|
jpayne@69
|
104 * read
|
jpayne@69
|
105 * write
|
jpayne@69
|
106 * tlv_command
|
jpayne@69
|
107 * ]
|
jpayne@69
|
108 * </pre>
|
jpayne@69
|
109 *
|
jpayne@69
|
110 * The standard access flags are as follows :-
|
jpayne@69
|
111 * * read
|
jpayne@69
|
112 * * write
|
jpayne@69
|
113 * * read_write
|
jpayne@69
|
114 * * volatile
|
jpayne@69
|
115 * * timestamp
|
jpayne@69
|
116 * * tlv_read
|
jpayne@69
|
117 * * tlv_write
|
jpayne@69
|
118 * * tlv_read_write
|
jpayne@69
|
119 * * tlv_command
|
jpayne@69
|
120 * * inactive
|
jpayne@69
|
121 * * lock
|
jpayne@69
|
122 * * owner
|
jpayne@69
|
123 * * tlv_callback
|
jpayne@69
|
124 * * user
|
jpayne@69
|
125 *
|
jpayne@69
|
126 * <h5>Control TLV Data</h5>
|
jpayne@69
|
127 * Controls can also use TLV data to represent dB information. This can be done
|
jpayne@69
|
128 * by defining a TLV section and using the TLV section within the control.
|
jpayne@69
|
129 * The TLV data for DBScale types are defined as follows :-
|
jpayne@69
|
130 *
|
jpayne@69
|
131 * <pre>
|
jpayne@69
|
132 * scale {
|
jpayne@69
|
133 * min "-9000"
|
jpayne@69
|
134 * step "300"
|
jpayne@69
|
135 * mute "1"
|
jpayne@69
|
136 * }
|
jpayne@69
|
137 * </pre>
|
jpayne@69
|
138 *
|
jpayne@69
|
139 * Where the meanings and values for min, step and mute are exactly the same
|
jpayne@69
|
140 * as defined in driver code.
|
jpayne@69
|
141 *
|
jpayne@69
|
142 * <h5>Control Channel Mapping</h5>
|
jpayne@69
|
143 * Controls can also specify which channels they are mapped with. This is useful
|
jpayne@69
|
144 * for userspace as it allows applications to determine the correct control
|
jpayne@69
|
145 * channel for Left and Right etc. Channel maps are defined as follows :-
|
jpayne@69
|
146 *
|
jpayne@69
|
147 * <pre>
|
jpayne@69
|
148 * channel."name" {
|
jpayne@69
|
149 * reg "0"
|
jpayne@69
|
150 * shift "0"
|
jpayne@69
|
151 * }
|
jpayne@69
|
152 * </pre>
|
jpayne@69
|
153 *
|
jpayne@69
|
154 * The channel map reg is the register offset for the control, shift is the
|
jpayne@69
|
155 * bit shift within the register for the channel and the section name is the
|
jpayne@69
|
156 * channel name and can be one of the following :-
|
jpayne@69
|
157 *
|
jpayne@69
|
158 * <pre>
|
jpayne@69
|
159 * * mono # mono stream
|
jpayne@69
|
160 * * fl # front left
|
jpayne@69
|
161 * * fr # front right
|
jpayne@69
|
162 * * rl # rear left
|
jpayne@69
|
163 * * rr # rear right
|
jpayne@69
|
164 * * fc # front center
|
jpayne@69
|
165 * * lfe # LFE
|
jpayne@69
|
166 * * sl # side left
|
jpayne@69
|
167 * * sr # side right
|
jpayne@69
|
168 * * rc # rear center
|
jpayne@69
|
169 * * flc # front left center
|
jpayne@69
|
170 * * frc # front right center
|
jpayne@69
|
171 * * rlc # rear left center
|
jpayne@69
|
172 * * rrc # rear right center
|
jpayne@69
|
173 * * flw # front left wide
|
jpayne@69
|
174 * * frw # front right wide
|
jpayne@69
|
175 * * flh # front left high
|
jpayne@69
|
176 * * fch # front center high
|
jpayne@69
|
177 * * frh # front right high
|
jpayne@69
|
178 * * tc # top center
|
jpayne@69
|
179 * * tfl # top front left
|
jpayne@69
|
180 * * tfr # top front right
|
jpayne@69
|
181 * * tfc # top front center
|
jpayne@69
|
182 * * trl # top rear left
|
jpayne@69
|
183 * * trr # top rear right
|
jpayne@69
|
184 * * trc # top rear center
|
jpayne@69
|
185 * * tflc # top front left center
|
jpayne@69
|
186 * * tfrc # top front right center
|
jpayne@69
|
187 * * tsl # top side left
|
jpayne@69
|
188 * * tsr # top side right
|
jpayne@69
|
189 * * llfe # left LFE
|
jpayne@69
|
190 * * rlfe # right LFE
|
jpayne@69
|
191 * * bc # bottom center
|
jpayne@69
|
192 * * blc # bottom left center
|
jpayne@69
|
193 * * brc # bottom right center
|
jpayne@69
|
194 * </pre>
|
jpayne@69
|
195 *
|
jpayne@69
|
196 * <h5>Control Private Data</h5>
|
jpayne@69
|
197 * Controls can also have private data. This can be done by defining a private
|
jpayne@69
|
198 * data section and including the section within the control. The private data
|
jpayne@69
|
199 * section is defined as follows :-
|
jpayne@69
|
200 *
|
jpayne@69
|
201 * <pre>
|
jpayne@69
|
202 * SectionData."pdata for EQU1" {
|
jpayne@69
|
203 * file "/path/to/file"
|
jpayne@69
|
204 * bytes "0x12,0x34,0x56,0x78"
|
jpayne@69
|
205 * shorts "0x1122,0x3344,0x5566,0x7788"
|
jpayne@69
|
206 * words "0xaabbccdd,0x11223344,0x66aa77bb,0xefef1234"
|
jpayne@69
|
207 * tuples "section id of the vendor tuples"
|
jpayne@69
|
208 * };
|
jpayne@69
|
209 * </pre>
|
jpayne@69
|
210 * The file, bytes, shorts, words and tuples keywords are all mutually
|
jpayne@69
|
211 * exclusive as the private data should only be taken from one source.
|
jpayne@69
|
212 * The private data can either be read from a separate file or defined in
|
jpayne@69
|
213 * the topology file using the bytes, shorts, words or tuples keywords.
|
jpayne@69
|
214 * The keyword tuples is to define vendor specific tuples. Please refer to
|
jpayne@69
|
215 * section Vendor Tokens and Vendor tuples.
|
jpayne@69
|
216 *
|
jpayne@69
|
217 * It's easy to use a vendor tuples object to define a C structure instance.
|
jpayne@69
|
218 * And a data section can include multiple vendor tuples objects:
|
jpayne@69
|
219 *
|
jpayne@69
|
220 * <pre>
|
jpayne@69
|
221 * SectionData."data element name" {
|
jpayne@69
|
222 * index "1" #Index number
|
jpayne@69
|
223 * tuples [
|
jpayne@69
|
224 * "id of the 1st vendor tuples section"
|
jpayne@69
|
225 * "id of the 2nd vendor tuples section"
|
jpayne@69
|
226 * ...
|
jpayne@69
|
227 * ]
|
jpayne@69
|
228 * };
|
jpayne@69
|
229 * </pre>
|
jpayne@69
|
230 *
|
jpayne@69
|
231 * <h5>How to define an element with private data</h5>
|
jpayne@69
|
232 * An element can refer to a single data section or multiple data
|
jpayne@69
|
233 * sections.
|
jpayne@69
|
234 *
|
jpayne@69
|
235 * <h6>To refer to a single data section:</h6>
|
jpayne@69
|
236 * <pre>
|
jpayne@69
|
237 * Sectionxxx."element name" {
|
jpayne@69
|
238 * ...
|
jpayne@69
|
239 * data "name of data section" # optional private data
|
jpayne@69
|
240 * }
|
jpayne@69
|
241 * </pre>
|
jpayne@69
|
242 *
|
jpayne@69
|
243 * <h6>To refer to multiple data sections:</h6>
|
jpayne@69
|
244 * <pre>
|
jpayne@69
|
245 * Sectionxxx."element name" {
|
jpayne@69
|
246 * ...
|
jpayne@69
|
247 * data [ # optional private data
|
jpayne@69
|
248 * "name of 1st data section"
|
jpayne@69
|
249 * "name of 2nd data section"
|
jpayne@69
|
250 * ...
|
jpayne@69
|
251 * ]
|
jpayne@69
|
252 * }
|
jpayne@69
|
253 * </pre>
|
jpayne@69
|
254 * And data of these sections will be merged in the same order as they are
|
jpayne@69
|
255 * in the list, as the element's private data for kernel.
|
jpayne@69
|
256 *
|
jpayne@69
|
257 * </pre>
|
jpayne@69
|
258 *
|
jpayne@69
|
259 * <h6>Vendor Tokens</h6>
|
jpayne@69
|
260 * A vendor token list is defined as a new section. Each token element is
|
jpayne@69
|
261 * a pair of string ID and integer value. And both the ID and value are
|
jpayne@69
|
262 * vendor-specific.
|
jpayne@69
|
263 *
|
jpayne@69
|
264 * <pre>
|
jpayne@69
|
265 * SectionVendorTokens."id of the vendor tokens" {
|
jpayne@69
|
266 * comment "optional comments"
|
jpayne@69
|
267 * VENDOR_TOKEN_ID1 "1"
|
jpayne@69
|
268 * VENDOR_TOKEN_ID2 "2"
|
jpayne@69
|
269 * VENDOR_TOKEN_ID3 "3"
|
jpayne@69
|
270 * ...
|
jpayne@69
|
271 * }
|
jpayne@69
|
272 * </pre>
|
jpayne@69
|
273 *
|
jpayne@69
|
274 * <h6>Vendor Tuples</h6>
|
jpayne@69
|
275 * Vendor tuples are defined as a new section. It contains a reference to
|
jpayne@69
|
276 * a vendor token list and several tuple arrays.
|
jpayne@69
|
277 * All arrays share a vendor token list, defined by the tokens keyword.
|
jpayne@69
|
278 * Each tuple array is for a specific type, defined by the string following
|
jpayne@69
|
279 * the tuples keyword. Supported types are: string, uuid, bool, byte,
|
jpayne@69
|
280 * short and word.
|
jpayne@69
|
281 *
|
jpayne@69
|
282 * <pre>
|
jpayne@69
|
283 * SectionVendorTuples."id of the vendor tuples" {
|
jpayne@69
|
284 * tokens "id of the vendor tokens"
|
jpayne@69
|
285 *
|
jpayne@69
|
286 * tuples."string" {
|
jpayne@69
|
287 * VENDOR_TOKEN_ID1 "character string"
|
jpayne@69
|
288 * ...
|
jpayne@69
|
289 * }
|
jpayne@69
|
290 *
|
jpayne@69
|
291 * tuples."uuid" { # 16 characters separated by commas
|
jpayne@69
|
292 * VENDOR_TOKEN_ID2 "0x01,0x02,...,0x0f"
|
jpayne@69
|
293 * ...
|
jpayne@69
|
294 * }
|
jpayne@69
|
295 *
|
jpayne@69
|
296 * tuples."bool" {
|
jpayne@69
|
297 * VENDOR_TOKEN_ID3 "true/false"
|
jpayne@69
|
298 * ...
|
jpayne@69
|
299 * }
|
jpayne@69
|
300 *
|
jpayne@69
|
301 * tuples."byte" {
|
jpayne@69
|
302 * VENDOR_TOKEN_ID4 "0x11"
|
jpayne@69
|
303 * VENDOR_TOKEN_ID5 "0x22"
|
jpayne@69
|
304 * ...
|
jpayne@69
|
305 * }
|
jpayne@69
|
306 *
|
jpayne@69
|
307 * tuples."short" {
|
jpayne@69
|
308 * VENDOR_TOKEN_ID6 "0x1122"
|
jpayne@69
|
309 * VENDOR_TOKEN_ID7 "0x3344"
|
jpayne@69
|
310 * ...
|
jpayne@69
|
311 * }
|
jpayne@69
|
312 *
|
jpayne@69
|
313 * tuples."word" {
|
jpayne@69
|
314 * VENDOR_TOKEN_ID8 "0x11223344"
|
jpayne@69
|
315 * VENDOR_TOKEN_ID9 "0x55667788"
|
jpayne@69
|
316 * ...
|
jpayne@69
|
317 * }
|
jpayne@69
|
318 * }
|
jpayne@69
|
319 * </pre>
|
jpayne@69
|
320 * To define multiple vendor tuples of same type, please append some
|
jpayne@69
|
321 * characters after the type string ("string", "uuid", "bool", "byte", "short"
|
jpayne@69
|
322 * or "word"), to avoid ID duplication in the SectionVendorTuples.<br>
|
jpayne@69
|
323 * The parser will check the first few characters in ID to get the tuple type.
|
jpayne@69
|
324 * Here is an example:
|
jpayne@69
|
325 * <pre>
|
jpayne@69
|
326 * SectionVendorTuples."id of the vendor tuples" {
|
jpayne@69
|
327 * ...
|
jpayne@69
|
328 * tuples."word.module0" {
|
jpayne@69
|
329 * VENDOR_TOKEN_PARAM_ID1 "0x00112233"
|
jpayne@69
|
330 * VENDOR_TOKEN_PARAM_ID2 "0x44556677"
|
jpayne@69
|
331 * ...
|
jpayne@69
|
332 * }
|
jpayne@69
|
333 *
|
jpayne@69
|
334 * tuples."word.module2" {
|
jpayne@69
|
335 * VENDOR_TOKEN_PARAM_ID1 "0x11223344"
|
jpayne@69
|
336 * VENDOR_TOKEN_PARAM_ID2 "0x55667788"
|
jpayne@69
|
337 * ...
|
jpayne@69
|
338 * }
|
jpayne@69
|
339 * ...
|
jpayne@69
|
340 * }
|
jpayne@69
|
341 *
|
jpayne@69
|
342 * </pre>
|
jpayne@69
|
343 *
|
jpayne@69
|
344 * <h5>Mixer Controls</h5>
|
jpayne@69
|
345 * A mixer control is defined as a new section that can include channel mapping,
|
jpayne@69
|
346 * TLV data, callback operations and private data. The mixer section also
|
jpayne@69
|
347 * includes a few other config options that are shown here :-
|
jpayne@69
|
348 *
|
jpayne@69
|
349 * <pre>
|
jpayne@69
|
350 * SectionControlMixer."mixer name" {
|
jpayne@69
|
351 * comment "optional comments"
|
jpayne@69
|
352 *
|
jpayne@69
|
353 * index "1" # Index number
|
jpayne@69
|
354 *
|
jpayne@69
|
355 * channel."name" { # Channel maps
|
jpayne@69
|
356 * ....
|
jpayne@69
|
357 * }
|
jpayne@69
|
358 *
|
jpayne@69
|
359 * ops."ctl" { # Ops callback functions
|
jpayne@69
|
360 * ....
|
jpayne@69
|
361 * }
|
jpayne@69
|
362 *
|
jpayne@69
|
363 * max "32" # Max control value
|
jpayne@69
|
364 * invert "0" # Whether control values are inverted
|
jpayne@69
|
365 *
|
jpayne@69
|
366 * tlv "tld_data" # optional TLV data
|
jpayne@69
|
367 *
|
jpayne@69
|
368 * data "pdata for mixer1" # optional private data
|
jpayne@69
|
369 * }
|
jpayne@69
|
370 * </pre>
|
jpayne@69
|
371 *
|
jpayne@69
|
372 * The section name is used to define the mixer name. The index number can be
|
jpayne@69
|
373 * used to identify topology objects groups(index "0" is common, fit for all
|
jpayne@69
|
374 * user cases).This allows driver operations on objects with index number N and
|
jpayne@69
|
375 * can be used to add/remove pipelines of objects whilst other objects are
|
jpayne@69
|
376 * unaffected.
|
jpayne@69
|
377 *
|
jpayne@69
|
378 * <h5>Byte Controls</h5>
|
jpayne@69
|
379 * A byte control is defined as a new section that can include channel mapping,
|
jpayne@69
|
380 * TLV data, callback operations and private data. The bytes section also
|
jpayne@69
|
381 * includes a few other config options that are shown here :-
|
jpayne@69
|
382 *
|
jpayne@69
|
383 * <pre>
|
jpayne@69
|
384 * SectionControlBytes."name" {
|
jpayne@69
|
385 * comment "optional comments"
|
jpayne@69
|
386 *
|
jpayne@69
|
387 * index "1" # Index number
|
jpayne@69
|
388 *
|
jpayne@69
|
389 * channel."name" { # Channel maps
|
jpayne@69
|
390 * ....
|
jpayne@69
|
391 * }
|
jpayne@69
|
392 *
|
jpayne@69
|
393 * ops."ctl" { # Ops callback functions
|
jpayne@69
|
394 * ....
|
jpayne@69
|
395 * }
|
jpayne@69
|
396 *
|
jpayne@69
|
397 * base "0" # Register base
|
jpayne@69
|
398 * num_regs "16" # Number of registers
|
jpayne@69
|
399 * mask "0xff" # Mask
|
jpayne@69
|
400 * max "255" # Maximum value
|
jpayne@69
|
401 *
|
jpayne@69
|
402 * tlv "tld_data" # optional TLV data
|
jpayne@69
|
403 *
|
jpayne@69
|
404 * data "pdata for mixer1" # optional private data
|
jpayne@69
|
405 * }
|
jpayne@69
|
406 * </pre>
|
jpayne@69
|
407 *
|
jpayne@69
|
408 * <h5>Enumerated Controls</h5>
|
jpayne@69
|
409 * A enumerated control is defined as a new section (like mixer and byte) that
|
jpayne@69
|
410 * can include channel mapping, callback operations, private data and
|
jpayne@69
|
411 * text strings to represent the enumerated control options.<br>
|
jpayne@69
|
412 *
|
jpayne@69
|
413 * The text strings for the enumerated controls are defined in a separate
|
jpayne@69
|
414 * section as follows :-
|
jpayne@69
|
415 *
|
jpayne@69
|
416 * <pre>
|
jpayne@69
|
417 * SectionText."name" {
|
jpayne@69
|
418 *
|
jpayne@69
|
419 * Values [
|
jpayne@69
|
420 * "value1"
|
jpayne@69
|
421 * "value2"
|
jpayne@69
|
422 "value3"
|
jpayne@69
|
423 * ]
|
jpayne@69
|
424 * }
|
jpayne@69
|
425 * </pre>
|
jpayne@69
|
426 *
|
jpayne@69
|
427 * All the enumerated text values are listed in the values list.<br>
|
jpayne@69
|
428 * The enumerated control is similar to the other controls and defined as
|
jpayne@69
|
429 * follows :-
|
jpayne@69
|
430 *
|
jpayne@69
|
431 * <pre>
|
jpayne@69
|
432 * SectionControlMixer."name" {
|
jpayne@69
|
433 * comment "optional comments"
|
jpayne@69
|
434 *
|
jpayne@69
|
435 * index "1" # Index number
|
jpayne@69
|
436 *
|
jpayne@69
|
437 * texts "EQU1" # Enumerated text items
|
jpayne@69
|
438 *
|
jpayne@69
|
439 * channel."name" { # Channel maps
|
jpayne@69
|
440 * ....
|
jpayne@69
|
441 * }
|
jpayne@69
|
442 *
|
jpayne@69
|
443 * ops."ctl" { # Ops callback functions
|
jpayne@69
|
444 * ....
|
jpayne@69
|
445 * }
|
jpayne@69
|
446 *
|
jpayne@69
|
447 * data "pdata for mixer1" # optional private data
|
jpayne@69
|
448 * }
|
jpayne@69
|
449 * </pre>
|
jpayne@69
|
450 *
|
jpayne@69
|
451 * <h4>DAPM Graph</h4>
|
jpayne@69
|
452 * DAPM graphs can easily be defined using the topology file. The format is
|
jpayne@69
|
453 * very similar to the DAPM graph kernel format. :-
|
jpayne@69
|
454 *
|
jpayne@69
|
455 * <pre>
|
jpayne@69
|
456 * SectionGraph."dsp" {
|
jpayne@69
|
457 * index "1" # Index number
|
jpayne@69
|
458 *
|
jpayne@69
|
459 * lines [
|
jpayne@69
|
460 * "sink1, control, source1"
|
jpayne@69
|
461 * "sink2, , source2"
|
jpayne@69
|
462 * ]
|
jpayne@69
|
463 * }
|
jpayne@69
|
464 * </pre>
|
jpayne@69
|
465 *
|
jpayne@69
|
466 * The lines in the graph are defined as a variable size list of sinks,
|
jpayne@69
|
467 * controls and sources. The control name is optional as some graph lines have
|
jpayne@69
|
468 * no associated controls. The section name can be used to differentiate the
|
jpayne@69
|
469 * graph with other graphs, it's not used by the kernel atm.
|
jpayne@69
|
470 *
|
jpayne@69
|
471 * <h4>DAPM Widgets</h4>
|
jpayne@69
|
472 * DAPM widgets are similar to controls in that they can include many other
|
jpayne@69
|
473 * objects. Widgets can contain private data, mixer controls and enum controls.
|
jpayne@69
|
474 *
|
jpayne@69
|
475 * The following widget types are supported and match the driver types :-
|
jpayne@69
|
476 *
|
jpayne@69
|
477 * * input
|
jpayne@69
|
478 * * output
|
jpayne@69
|
479 * * mux
|
jpayne@69
|
480 * * mixer
|
jpayne@69
|
481 * * pga
|
jpayne@69
|
482 * * out_drv
|
jpayne@69
|
483 * * adc
|
jpayne@69
|
484 * * dac
|
jpayne@69
|
485 * * switch
|
jpayne@69
|
486 * * pre
|
jpayne@69
|
487 * * post
|
jpayne@69
|
488 * * aif_in
|
jpayne@69
|
489 * * aif_out
|
jpayne@69
|
490 * * dai_in
|
jpayne@69
|
491 * * dai_out
|
jpayne@69
|
492 * * dai_link
|
jpayne@69
|
493 *
|
jpayne@69
|
494 * Widgets are defined as follows :-
|
jpayne@69
|
495 *
|
jpayne@69
|
496 * <pre>
|
jpayne@69
|
497 * SectionWidget."name" {
|
jpayne@69
|
498 *
|
jpayne@69
|
499 * index "1" # Index number
|
jpayne@69
|
500 *
|
jpayne@69
|
501 * type "aif_in" # Widget type - detailed above
|
jpayne@69
|
502 * stream_name "name" # Stream name
|
jpayne@69
|
503 *
|
jpayne@69
|
504 * no_pm "true" # No PM control bit.
|
jpayne@69
|
505 * reg "20" # PM bit register offset
|
jpayne@69
|
506 * shift "0" # PM bit register shift
|
jpayne@69
|
507 * invert "1 # PM bit is inverted
|
jpayne@69
|
508 * subseq "8" # subsequence number
|
jpayne@69
|
509 *
|
jpayne@69
|
510 * event_type "1" # DAPM widget event type
|
jpayne@69
|
511 * event_flags "1" # DAPM widget event flags
|
jpayne@69
|
512 *
|
jpayne@69
|
513 * mixer "name" # Optional Mixer Control
|
jpayne@69
|
514 * enum "name" # Optional Enum Control
|
jpayne@69
|
515 *
|
jpayne@69
|
516 * data "name" # optional private data
|
jpayne@69
|
517 * }
|
jpayne@69
|
518 * </pre>
|
jpayne@69
|
519 *
|
jpayne@69
|
520 * The section name is the widget name. The mixer and enum fields are mutually
|
jpayne@69
|
521 * exclusive and used to include controls into the widget. The index and data
|
jpayne@69
|
522 * fields are the same for widgets as they are for controls whilst the other
|
jpayne@69
|
523 * fields map on very closely to the driver widget fields.
|
jpayne@69
|
524 *
|
jpayne@69
|
525 * <h5>Widget Private Data</h5>
|
jpayne@69
|
526 * Widget can have private data. For the format of the private data, please
|
jpayne@69
|
527 * refer to section Control Private Data.
|
jpayne@69
|
528 *
|
jpayne@69
|
529 * <h4>PCM Capabilities</h4>
|
jpayne@69
|
530 * Topology can also define the PCM capabilities of front end or physical DAIs.
|
jpayne@69
|
531 * Capabilities can be defined with the following section :-
|
jpayne@69
|
532 *
|
jpayne@69
|
533 * <pre>
|
jpayne@69
|
534 * SectionPCMCapabilities."name" {
|
jpayne@69
|
535 *
|
jpayne@69
|
536 * formats "S24_LE,S16_LE" # Supported formats
|
jpayne@69
|
537 * rates "48000" # Supported rates
|
jpayne@69
|
538 * rate_min "48000" # Max supported sample rate
|
jpayne@69
|
539 * rate_max "48000" # Min supported sample rate
|
jpayne@69
|
540 * channels_min "2" # Min number of channels
|
jpayne@69
|
541 * channels_max "2" # max number of channels
|
jpayne@69
|
542 * }
|
jpayne@69
|
543 * </pre>
|
jpayne@69
|
544 * The supported formats use the same naming convention as the driver macros.
|
jpayne@69
|
545 * The PCM capabilities name can be referred to and included by PCM and
|
jpayne@69
|
546 * physical DAI sections.
|
jpayne@69
|
547 *
|
jpayne@69
|
548 * <h4>PCM Configurations</h4>
|
jpayne@69
|
549 * PCM runtime configurations can be defined for playback and capture stream
|
jpayne@69
|
550 * directions with the following section :-
|
jpayne@69
|
551 *
|
jpayne@69
|
552 * <pre>
|
jpayne@69
|
553 * SectionPCMConfig."name" {
|
jpayne@69
|
554 *
|
jpayne@69
|
555 * config."playback" { # playback config
|
jpayne@69
|
556 * format "S16_LE" # playback format
|
jpayne@69
|
557 * rate "48000" # playback sample rate
|
jpayne@69
|
558 * channels "2" # playback channels
|
jpayne@69
|
559 * tdm_slot "0xf" # playback TDM slot
|
jpayne@69
|
560 * }
|
jpayne@69
|
561 *
|
jpayne@69
|
562 * config."capture" { # capture config
|
jpayne@69
|
563 * format "S16_LE" # capture format
|
jpayne@69
|
564 * rate "48000" # capture sample rate
|
jpayne@69
|
565 * channels "2" # capture channels
|
jpayne@69
|
566 * tdm_slot "0xf" # capture TDM slot
|
jpayne@69
|
567 * }
|
jpayne@69
|
568 * }
|
jpayne@69
|
569 * </pre>
|
jpayne@69
|
570 *
|
jpayne@69
|
571 * The supported formats use the same naming convention as the driver macros.
|
jpayne@69
|
572 * The PCM configuration name can be referred to and included by PCM and
|
jpayne@69
|
573 * physical link sections.
|
jpayne@69
|
574 *
|
jpayne@69
|
575 * <h4>PCM (Front-end DAI & DAI link) </h4>
|
jpayne@69
|
576 * PCM sections define the supported capabilities and configurations for
|
jpayne@69
|
577 * supported playback and capture streams, names and flags for front end
|
jpayne@69
|
578 * DAI & DAI links. Topology kernel driver will use a PCM object to create
|
jpayne@69
|
579 * a pair of FE DAI & DAI links.
|
jpayne@69
|
580 *
|
jpayne@69
|
581 * <pre>
|
jpayne@69
|
582 * SectionPCM."name" {
|
jpayne@69
|
583 *
|
jpayne@69
|
584 * index "1" # Index number
|
jpayne@69
|
585 *
|
jpayne@69
|
586 * id "0" # used for binding to the PCM
|
jpayne@69
|
587 *
|
jpayne@69
|
588 * dai."name of front-end DAI" {
|
jpayne@69
|
589 * id "0" # used for binding to the front-end DAI
|
jpayne@69
|
590 * }
|
jpayne@69
|
591 *
|
jpayne@69
|
592 * pcm."playback" {
|
jpayne@69
|
593 * capabilities "capabilities1" # capabilities for playback
|
jpayne@69
|
594 *
|
jpayne@69
|
595 * configs [ # supported configs for playback
|
jpayne@69
|
596 * "config1"
|
jpayne@69
|
597 * "config2"
|
jpayne@69
|
598 * ]
|
jpayne@69
|
599 * }
|
jpayne@69
|
600 *
|
jpayne@69
|
601 * pcm."capture" {
|
jpayne@69
|
602 * capabilities "capabilities2" # capabilities for capture
|
jpayne@69
|
603 *
|
jpayne@69
|
604 * configs [ # supported configs for capture
|
jpayne@69
|
605 * "config1"
|
jpayne@69
|
606 * "config2"
|
jpayne@69
|
607 * "config3"
|
jpayne@69
|
608 * ]
|
jpayne@69
|
609 * }
|
jpayne@69
|
610 *
|
jpayne@69
|
611 * # Optional boolean flags
|
jpayne@69
|
612 * symmetric_rates "true"
|
jpayne@69
|
613 * symmetric_channels "true"
|
jpayne@69
|
614 * symmetric_sample_bits "false"
|
jpayne@69
|
615 *
|
jpayne@69
|
616 * data "name" # optional private data
|
jpayne@69
|
617 * }
|
jpayne@69
|
618 * </pre>
|
jpayne@69
|
619 *
|
jpayne@69
|
620 * <h4>Physical DAI Link Configurations</h4>
|
jpayne@69
|
621 * The runtime configurations of a physical DAI link can be defined by
|
jpayne@69
|
622 * SectionLink. <br> Backend DAI links belong to physical links, and can
|
jpayne@69
|
623 * be configured by either SectionLink or SectionBE, with same syntax.
|
jpayne@69
|
624 * But SectionBE is deprecated atm since the internal processing is
|
jpayne@69
|
625 * actually same.
|
jpayne@69
|
626 *
|
jpayne@69
|
627 * <pre>
|
jpayne@69
|
628 * SectionLink."name" {
|
jpayne@69
|
629 *
|
jpayne@69
|
630 * index "1" # Index number
|
jpayne@69
|
631 *
|
jpayne@69
|
632 * id "0" # used for binding to the link
|
jpayne@69
|
633 *
|
jpayne@69
|
634 * stream_name "name" # used for binding to the link
|
jpayne@69
|
635 *
|
jpayne@69
|
636 * hw_configs [ # runtime supported HW configurations, optional
|
jpayne@69
|
637 * "config1"
|
jpayne@69
|
638 * "config2"
|
jpayne@69
|
639 * ...
|
jpayne@69
|
640 * ]
|
jpayne@69
|
641 *
|
jpayne@69
|
642 * default_hw_conf_id "1" #default HW config ID for init
|
jpayne@69
|
643 *
|
jpayne@69
|
644 * # Optional boolean flags
|
jpayne@69
|
645 * symmetric_rates "true"
|
jpayne@69
|
646 * symmetric_channels "false"
|
jpayne@69
|
647 * symmetric_sample_bits "true"
|
jpayne@69
|
648 *
|
jpayne@69
|
649 * data "name" # optional private data
|
jpayne@69
|
650 * }
|
jpayne@69
|
651 * </pre>
|
jpayne@69
|
652 *
|
jpayne@69
|
653 * A physical link can refer to multiple runtime supported hardware
|
jpayne@69
|
654 * configurations, which is defined by SectionHWConfig.
|
jpayne@69
|
655 *
|
jpayne@69
|
656 * <pre>
|
jpayne@69
|
657 * SectionHWConfig."name" {
|
jpayne@69
|
658 *
|
jpayne@69
|
659 * id "1" # used for binding to the config
|
jpayne@69
|
660 * format "I2S" # physical audio format.
|
jpayne@69
|
661 * bclk "master" # Platform is master of bit clock
|
jpayne@69
|
662 * fsync "slave" # Platform is slave of fsync
|
jpayne@69
|
663 * }
|
jpayne@69
|
664 * </pre>
|
jpayne@69
|
665 *
|
jpayne@69
|
666 * <h4>Physical DAI</h4>
|
jpayne@69
|
667 * A physical DAI (e.g. backend DAI for DPCM) is defined as a new section
|
jpayne@69
|
668 * that can include a unique ID, playback and capture stream capabilities,
|
jpayne@69
|
669 * optional flags, and private data. <br>
|
jpayne@69
|
670 * Its PCM stream capablities are same as those for PCM objects,
|
jpayne@69
|
671 * please refer to section 'PCM Capabilities'.
|
jpayne@69
|
672 *
|
jpayne@69
|
673 * <pre>
|
jpayne@69
|
674 * SectionDAI."name" {
|
jpayne@69
|
675 *
|
jpayne@69
|
676 * index "1" # Index number
|
jpayne@69
|
677 *
|
jpayne@69
|
678 * id "0" # used for binding to the Backend DAI
|
jpayne@69
|
679 *
|
jpayne@69
|
680 * pcm."playback" {
|
jpayne@69
|
681 * capabilities "capabilities1" # capabilities for playback
|
jpayne@69
|
682 * }
|
jpayne@69
|
683 *
|
jpayne@69
|
684 * pcm."capture" {
|
jpayne@69
|
685 * capabilities "capabilities2" # capabilities for capture
|
jpayne@69
|
686 * }
|
jpayne@69
|
687 *
|
jpayne@69
|
688 * symmetric_rates "true" # optional flags
|
jpayne@69
|
689 * symmetric_channels "true"
|
jpayne@69
|
690 * symmetric_sample_bits "false"
|
jpayne@69
|
691 *
|
jpayne@69
|
692 * data "name" # optional private data
|
jpayne@69
|
693 * }
|
jpayne@69
|
694 * </pre>
|
jpayne@69
|
695 *
|
jpayne@69
|
696 * <h4>Manifest Private Data</h4>
|
jpayne@69
|
697 * Manfiest may have private data. Users need to define a manifest section
|
jpayne@69
|
698 * and add the references to 1 or multiple data sections. Please refer to
|
jpayne@69
|
699 * section 'How to define an element with private data'. <br>
|
jpayne@69
|
700 * And the text conf file can have at most 1 manifest section. <br><br>
|
jpayne@69
|
701 *
|
jpayne@69
|
702 * Manifest section is defined as follows :-
|
jpayne@69
|
703 *
|
jpayne@69
|
704 * <pre>
|
jpayne@69
|
705 * SectionManifest"name" {
|
jpayne@69
|
706 *
|
jpayne@69
|
707 * data "name" # optional private data
|
jpayne@69
|
708 * }
|
jpayne@69
|
709 * </pre>
|
jpayne@69
|
710 *
|
jpayne@69
|
711 * <h4>Include other files</h4>
|
jpayne@69
|
712 * Users may include other files in a text conf file via alsaconf syntax
|
jpayne@69
|
713 * <path/to/configuration-file>. This allows users to define common info
|
jpayne@69
|
714 * in separate files (e.g. vendor tokens, tuples) and share them for
|
jpayne@69
|
715 * different platforms, thus save the total size of config files. <br>
|
jpayne@69
|
716 * Users can also specifiy additional configuraiton directories relative
|
jpayne@69
|
717 * to "/usr/share/alsa/" to search the included files, via alsaconf syntax
|
jpayne@69
|
718 * <searchfdir:/relative-path/to/usr/share/alsa>. <br><br>
|
jpayne@69
|
719 *
|
jpayne@69
|
720 * For example, file A and file B are two text conf files for platform X,
|
jpayne@69
|
721 * they will be installed to /usr/share/alsa/topology/platformx. If we
|
jpayne@69
|
722 * need file A to include file B, in file A we can add: <br>
|
jpayne@69
|
723 *
|
jpayne@69
|
724 * <searchdir:topology/platformx> <br>
|
jpayne@69
|
725 * <name-of-file-B> <br><br>
|
jpayne@69
|
726 *
|
jpayne@69
|
727 * ALSA conf will search and open an included file in the following order
|
jpayne@69
|
728 * of priority:
|
jpayne@69
|
729 * 1. directly open the file by its name;
|
jpayne@69
|
730 * 2. search for the file name in "/usr/share/alsa";
|
jpayne@69
|
731 * 3. search for the file name in user specified subdirectories under
|
jpayne@69
|
732 * "/usr/share/alsa".
|
jpayne@69
|
733 *
|
jpayne@69
|
734 * The order of the included files need not to be same as their
|
jpayne@69
|
735 * dependencies, since the topology library will load them all before
|
jpayne@69
|
736 * parsing their dependencies. <br>
|
jpayne@69
|
737 *
|
jpayne@69
|
738 * The configuration directories defined by a file will only be used to search
|
jpayne@69
|
739 * the files included by this file.
|
jpayne@69
|
740 */
|
jpayne@69
|
741
|
jpayne@69
|
742 /** Maximum number of channels supported in one control */
|
jpayne@69
|
743 #define SND_TPLG_MAX_CHAN 8
|
jpayne@69
|
744
|
jpayne@69
|
745 /** Topology context */
|
jpayne@69
|
746 typedef struct snd_tplg snd_tplg_t;
|
jpayne@69
|
747
|
jpayne@69
|
748 /** Topology object types */
|
jpayne@69
|
749 enum snd_tplg_type {
|
jpayne@69
|
750 SND_TPLG_TYPE_TLV = 0, /*!< TLV Data */
|
jpayne@69
|
751 SND_TPLG_TYPE_MIXER, /*!< Mixer control*/
|
jpayne@69
|
752 SND_TPLG_TYPE_ENUM, /*!< Enumerated control */
|
jpayne@69
|
753 SND_TPLG_TYPE_TEXT, /*!< Text data */
|
jpayne@69
|
754 SND_TPLG_TYPE_DATA, /*!< Private data */
|
jpayne@69
|
755 SND_TPLG_TYPE_BYTES, /*!< Byte control */
|
jpayne@69
|
756 SND_TPLG_TYPE_STREAM_CONFIG, /*!< PCM Stream configuration */
|
jpayne@69
|
757 SND_TPLG_TYPE_STREAM_CAPS, /*!< PCM Stream capabilities */
|
jpayne@69
|
758 SND_TPLG_TYPE_PCM, /*!< PCM stream device */
|
jpayne@69
|
759 SND_TPLG_TYPE_DAPM_WIDGET, /*!< DAPM widget */
|
jpayne@69
|
760 SND_TPLG_TYPE_DAPM_GRAPH, /*!< DAPM graph elements */
|
jpayne@69
|
761 SND_TPLG_TYPE_BE, /*!< BE DAI link */
|
jpayne@69
|
762 SND_TPLG_TYPE_CC, /*!< Hostless codec <-> codec link */
|
jpayne@69
|
763 SND_TPLG_TYPE_MANIFEST, /*!< Topology manifest */
|
jpayne@69
|
764 SND_TPLG_TYPE_TOKEN, /*!< Vendor tokens */
|
jpayne@69
|
765 SND_TPLG_TYPE_TUPLE, /*!< Vendor tuples */
|
jpayne@69
|
766 SND_TPLG_TYPE_LINK, /*!< Physical DAI link */
|
jpayne@69
|
767 SND_TPLG_TYPE_HW_CONFIG, /*!< Link HW config */
|
jpayne@69
|
768 SND_TPLG_TYPE_DAI, /*!< Physical DAI */
|
jpayne@69
|
769 };
|
jpayne@69
|
770
|
jpayne@69
|
771 /** Fit for all user cases */
|
jpayne@69
|
772 #define SND_TPLG_INDEX_ALL 0
|
jpayne@69
|
773
|
jpayne@69
|
774 /** Flags for the snd_tplg_create */
|
jpayne@69
|
775 #define SND_TPLG_CREATE_VERBOSE (1<<0) /*!< Verbose output */
|
jpayne@69
|
776 #define SND_TPLG_CREATE_DAPM_NOSORT (1<<1) /*!< Do not sort DAPM objects by index */
|
jpayne@69
|
777
|
jpayne@69
|
778 /**
|
jpayne@69
|
779 * \brief Return the version of the topology library.
|
jpayne@69
|
780 * \return A static string with the version number.
|
jpayne@69
|
781 */
|
jpayne@69
|
782 const char *snd_tplg_version(void);
|
jpayne@69
|
783
|
jpayne@69
|
784 /**
|
jpayne@69
|
785 * \brief Create a new topology parser instance.
|
jpayne@69
|
786 * \return New topology parser instance
|
jpayne@69
|
787 */
|
jpayne@69
|
788 snd_tplg_t *snd_tplg_new(void);
|
jpayne@69
|
789
|
jpayne@69
|
790 /**
|
jpayne@69
|
791 * \brief Create a new topology parser instance.
|
jpayne@69
|
792 * \return New topology parser instance
|
jpayne@69
|
793 */
|
jpayne@69
|
794 snd_tplg_t *snd_tplg_create(int flags);
|
jpayne@69
|
795
|
jpayne@69
|
796 /**
|
jpayne@69
|
797 * \brief Free a topology parser instance.
|
jpayne@69
|
798 * \param tplg Topology parser instance
|
jpayne@69
|
799 */
|
jpayne@69
|
800 void snd_tplg_free(snd_tplg_t *tplg);
|
jpayne@69
|
801
|
jpayne@69
|
802 /**
|
jpayne@69
|
803 * \brief Load topology from the text buffer.
|
jpayne@69
|
804 * \param tplg Topology instance.
|
jpayne@69
|
805 * \param buf Text buffer.
|
jpayne@69
|
806 * \param size Text buffer size in bytes.
|
jpayne@69
|
807 * \return Zero on success, otherwise a negative error code
|
jpayne@69
|
808 */
|
jpayne@69
|
809 int snd_tplg_load(snd_tplg_t *tplg, const char *buf, size_t size);
|
jpayne@69
|
810
|
jpayne@69
|
811 /**
|
jpayne@69
|
812 * \brief Parse and build topology text file into binary file.
|
jpayne@69
|
813 * \param tplg Topology instance.
|
jpayne@69
|
814 * \param infile Topology text input file to be parsed
|
jpayne@69
|
815 * \param outfile Binary topology output file.
|
jpayne@69
|
816 * \return Zero on success, otherwise a negative error code
|
jpayne@69
|
817 */
|
jpayne@69
|
818 int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,
|
jpayne@69
|
819 const char *outfile);
|
jpayne@69
|
820
|
jpayne@69
|
821 /**
|
jpayne@69
|
822 * \brief Enable verbose reporting of binary file output
|
jpayne@69
|
823 * \param tplg Topology Instance
|
jpayne@69
|
824 * \param verbose Enable verbose output level if non zero
|
jpayne@69
|
825 */
|
jpayne@69
|
826 void snd_tplg_verbose(snd_tplg_t *tplg, int verbose);
|
jpayne@69
|
827
|
jpayne@69
|
828 /** \struct snd_tplg_tlv_template
|
jpayne@69
|
829 * \brief Template type for all TLV objects.
|
jpayne@69
|
830 */
|
jpayne@69
|
831 struct snd_tplg_tlv_template {
|
jpayne@69
|
832 int type; /*!< TLV type SNDRV_CTL_TLVT_ */
|
jpayne@69
|
833 };
|
jpayne@69
|
834
|
jpayne@69
|
835 /** \struct snd_tplg_tlv_dbscale_template
|
jpayne@69
|
836 * \brief Template type for TLV Scale objects.
|
jpayne@69
|
837 */
|
jpayne@69
|
838 struct snd_tplg_tlv_dbscale_template {
|
jpayne@69
|
839 struct snd_tplg_tlv_template hdr; /*!< TLV type header */
|
jpayne@69
|
840 int min; /*!< dB minimum value in 0.1dB */
|
jpayne@69
|
841 int step; /*!< dB step size in 0.1dB */
|
jpayne@69
|
842 int mute; /*!< is min dB value mute ? */
|
jpayne@69
|
843 };
|
jpayne@69
|
844
|
jpayne@69
|
845 /** \struct snd_tplg_channel_template
|
jpayne@69
|
846 * \brief Template type for single channel mapping.
|
jpayne@69
|
847 */
|
jpayne@69
|
848 struct snd_tplg_channel_elem {
|
jpayne@69
|
849 int size; /*!< size in bytes of this structure */
|
jpayne@69
|
850 int reg; /*!< channel control register */
|
jpayne@69
|
851 int shift; /*!< channel shift for control bits */
|
jpayne@69
|
852 int id; /*!< ID maps to Left, Right, LFE etc */
|
jpayne@69
|
853 };
|
jpayne@69
|
854
|
jpayne@69
|
855 /** \struct snd_tplg_channel_map_template
|
jpayne@69
|
856 * \brief Template type for channel mapping.
|
jpayne@69
|
857 */
|
jpayne@69
|
858 struct snd_tplg_channel_map_template {
|
jpayne@69
|
859 int num_channels; /*!< number of channel mappings */
|
jpayne@69
|
860 struct snd_tplg_channel_elem channel[SND_TPLG_MAX_CHAN]; /*!< mapping */
|
jpayne@69
|
861 };
|
jpayne@69
|
862
|
jpayne@69
|
863 /** \struct snd_tplg_pdata_template
|
jpayne@69
|
864 * \brief Template type for private data objects.
|
jpayne@69
|
865 */
|
jpayne@69
|
866 struct snd_tplg_pdata_template {
|
jpayne@69
|
867 unsigned int length; /*!< data length */
|
jpayne@69
|
868 const void *data; /*!< data */
|
jpayne@69
|
869 };
|
jpayne@69
|
870
|
jpayne@69
|
871 /** \struct snd_tplg_io_ops_template
|
jpayne@69
|
872 * \brief Template type for object operations mapping.
|
jpayne@69
|
873 */
|
jpayne@69
|
874 struct snd_tplg_io_ops_template {
|
jpayne@69
|
875 int get; /*!< get callback ID */
|
jpayne@69
|
876 int put; /*!< put callback ID */
|
jpayne@69
|
877 int info; /*!< info callback ID */
|
jpayne@69
|
878 };
|
jpayne@69
|
879
|
jpayne@69
|
880 /** \struct snd_tplg_ctl_template
|
jpayne@69
|
881 * \brief Template type for control objects.
|
jpayne@69
|
882 */
|
jpayne@69
|
883 struct snd_tplg_ctl_template {
|
jpayne@69
|
884 int type; /*!< Control type */
|
jpayne@69
|
885 const char *name; /*!< Control name */
|
jpayne@69
|
886 int access; /*!< Control access */
|
jpayne@69
|
887 struct snd_tplg_io_ops_template ops; /*!< operations */
|
jpayne@69
|
888 union {
|
jpayne@69
|
889 struct snd_tplg_tlv_template *tlv; /*!< non NULL means we have TLV data */
|
jpayne@69
|
890 struct snd_tplg_tlv_dbscale_template *tlv_scale; /*!< scale TLV data */
|
jpayne@69
|
891 };
|
jpayne@69
|
892 };
|
jpayne@69
|
893
|
jpayne@69
|
894 /** \struct snd_tplg_mixer_template
|
jpayne@69
|
895 * \brief Template type for mixer control objects.
|
jpayne@69
|
896 */
|
jpayne@69
|
897 struct snd_tplg_mixer_template {
|
jpayne@69
|
898 struct snd_tplg_ctl_template hdr; /*!< control type header */
|
jpayne@69
|
899 struct snd_tplg_channel_map_template *map; /*!< channel map */
|
jpayne@69
|
900 int min; /*!< min value for mixer */
|
jpayne@69
|
901 int max; /*!< max value for mixer */
|
jpayne@69
|
902 int platform_max; /*!< max value for platform control */
|
jpayne@69
|
903 int invert; /*!< whether controls bits are inverted */
|
jpayne@69
|
904 struct snd_soc_tplg_private *priv; /*!< control private data */
|
jpayne@69
|
905 };
|
jpayne@69
|
906
|
jpayne@69
|
907 /** \struct snd_tplg_enum_template
|
jpayne@69
|
908 * \brief Template type for enumerated control objects.
|
jpayne@69
|
909 */
|
jpayne@69
|
910 struct snd_tplg_enum_template {
|
jpayne@69
|
911 struct snd_tplg_ctl_template hdr; /*!< control type header */
|
jpayne@69
|
912 struct snd_tplg_channel_map_template *map; /*!< channel map */
|
jpayne@69
|
913 int items; /*!< number of enumerated items in control */
|
jpayne@69
|
914 int mask; /*!< register mask size */
|
jpayne@69
|
915 const char **texts; /*!< control text items */
|
jpayne@69
|
916 const int **values; /*!< control value items */
|
jpayne@69
|
917 struct snd_soc_tplg_private *priv; /*!< control private data */
|
jpayne@69
|
918 };
|
jpayne@69
|
919
|
jpayne@69
|
920 /** \struct snd_tplg_bytes_template
|
jpayne@69
|
921 * \brief Template type for TLV Scale objects.
|
jpayne@69
|
922 */
|
jpayne@69
|
923 struct snd_tplg_bytes_template {
|
jpayne@69
|
924 struct snd_tplg_ctl_template hdr; /*!< control type header */
|
jpayne@69
|
925 int max; /*!< max byte control value */
|
jpayne@69
|
926 int mask; /*!< byte control mask */
|
jpayne@69
|
927 int base; /*!< base register */
|
jpayne@69
|
928 int num_regs; /*!< number of registers */
|
jpayne@69
|
929 struct snd_tplg_io_ops_template ext_ops; /*!< ops mapping */
|
jpayne@69
|
930 struct snd_soc_tplg_private *priv; /*!< control private data */
|
jpayne@69
|
931 };
|
jpayne@69
|
932
|
jpayne@69
|
933 /** \struct snd_tplg_graph_elem
|
jpayne@69
|
934 * \brief Template type for single DAPM graph element.
|
jpayne@69
|
935 */
|
jpayne@69
|
936 struct snd_tplg_graph_elem {
|
jpayne@69
|
937 const char *src; /*!< source widget name */
|
jpayne@69
|
938 const char *ctl; /*!< control name or NULL if no control */
|
jpayne@69
|
939 const char *sink; /*!< sink widget name */
|
jpayne@69
|
940 };
|
jpayne@69
|
941
|
jpayne@69
|
942 /** \struct snd_tplg_graph_template
|
jpayne@69
|
943 * \brief Template type for array of DAPM graph elements.
|
jpayne@69
|
944 */
|
jpayne@69
|
945 struct snd_tplg_graph_template {
|
jpayne@69
|
946 int count; /*!< Number of graph elements */
|
jpayne@69
|
947 struct snd_tplg_graph_elem elem[0]; /*!< graph elements */
|
jpayne@69
|
948 };
|
jpayne@69
|
949
|
jpayne@69
|
950 /** \struct snd_tplg_widget_template
|
jpayne@69
|
951 * \brief Template type for DAPM widget objects.
|
jpayne@69
|
952 */
|
jpayne@69
|
953 struct snd_tplg_widget_template {
|
jpayne@69
|
954 int id; /*!< SND_SOC_DAPM_CTL */
|
jpayne@69
|
955 const char *name; /*!< widget name */
|
jpayne@69
|
956 const char *sname; /*!< stream name (certain widgets only) */
|
jpayne@69
|
957 int reg; /*!< negative reg = no direct dapm */
|
jpayne@69
|
958 int shift; /*!< bits to shift */
|
jpayne@69
|
959 int mask; /*!< non-shifted mask */
|
jpayne@69
|
960 int subseq; /*!< sort within widget type */
|
jpayne@69
|
961 unsigned int invert; /*!< invert the power bit */
|
jpayne@69
|
962 unsigned int ignore_suspend; /*!< kept enabled over suspend */
|
jpayne@69
|
963 unsigned short event_flags; /*!< PM event sequence flags */
|
jpayne@69
|
964 unsigned short event_type; /*!< PM event sequence type */
|
jpayne@69
|
965 struct snd_soc_tplg_private *priv; /*!< widget private data */
|
jpayne@69
|
966 int num_ctls; /*!< Number of controls used by widget */
|
jpayne@69
|
967 struct snd_tplg_ctl_template *ctl[0]; /*!< array of widget controls */
|
jpayne@69
|
968 };
|
jpayne@69
|
969
|
jpayne@69
|
970 /** \struct snd_tplg_stream_template
|
jpayne@69
|
971 * \brief Stream configurations.
|
jpayne@69
|
972 */
|
jpayne@69
|
973 struct snd_tplg_stream_template {
|
jpayne@69
|
974 const char *name; /*!< name of the stream config */
|
jpayne@69
|
975 int format; /*!< SNDRV_PCM_FMTBIT_* */
|
jpayne@69
|
976 int rate; /*!< SNDRV_PCM_RATE_* */
|
jpayne@69
|
977 int period_bytes; /*!< size of period in bytes */
|
jpayne@69
|
978 int buffer_bytes; /*!< size of buffer in bytes. */
|
jpayne@69
|
979 int channels; /*!< number of channels */
|
jpayne@69
|
980 };
|
jpayne@69
|
981
|
jpayne@69
|
982 /** \struct snd_tplg_stream_caps_template
|
jpayne@69
|
983 * \brief Stream Capabilities.
|
jpayne@69
|
984 */
|
jpayne@69
|
985 struct snd_tplg_stream_caps_template {
|
jpayne@69
|
986 const char *name; /*!< name of the stream caps */
|
jpayne@69
|
987 uint64_t formats; /*!< supported formats SNDRV_PCM_FMTBIT_* */
|
jpayne@69
|
988 unsigned int rates; /*!< supported rates SNDRV_PCM_RATE_* */
|
jpayne@69
|
989 unsigned int rate_min; /*!< min rate */
|
jpayne@69
|
990 unsigned int rate_max; /*!< max rate */
|
jpayne@69
|
991 unsigned int channels_min; /*!< min channels */
|
jpayne@69
|
992 unsigned int channels_max; /*!< max channels */
|
jpayne@69
|
993 unsigned int periods_min; /*!< min number of periods */
|
jpayne@69
|
994 unsigned int periods_max; /*!< max number of periods */
|
jpayne@69
|
995 unsigned int period_size_min; /*!< min period size bytes */
|
jpayne@69
|
996 unsigned int period_size_max; /*!< max period size bytes */
|
jpayne@69
|
997 unsigned int buffer_size_min; /*!< min buffer size bytes */
|
jpayne@69
|
998 unsigned int buffer_size_max; /*!< max buffer size bytes */
|
jpayne@69
|
999 unsigned int sig_bits; /*!< number of bits of content */
|
jpayne@69
|
1000 };
|
jpayne@69
|
1001
|
jpayne@69
|
1002 /** \struct snd_tplg_pcm_template
|
jpayne@69
|
1003 * \brief Template type for PCM (FE DAI & DAI links).
|
jpayne@69
|
1004 */
|
jpayne@69
|
1005 struct snd_tplg_pcm_template {
|
jpayne@69
|
1006 const char *pcm_name; /*!< PCM stream name */
|
jpayne@69
|
1007 const char *dai_name; /*!< DAI name */
|
jpayne@69
|
1008 unsigned int pcm_id; /*!< unique ID - used to match */
|
jpayne@69
|
1009 unsigned int dai_id; /*!< unique ID - used to match */
|
jpayne@69
|
1010 unsigned int playback; /*!< supports playback mode */
|
jpayne@69
|
1011 unsigned int capture; /*!< supports capture mode */
|
jpayne@69
|
1012 unsigned int compress; /*!< 1 = compressed; 0 = PCM */
|
jpayne@69
|
1013 struct snd_tplg_stream_caps_template *caps[2]; /*!< playback & capture for DAI */
|
jpayne@69
|
1014 unsigned int flag_mask; /*!< bitmask of flags to configure */
|
jpayne@69
|
1015 unsigned int flags; /*!< flag value SND_SOC_TPLG_LNK_FLGBIT_* */
|
jpayne@69
|
1016 struct snd_soc_tplg_private *priv; /*!< private data */
|
jpayne@69
|
1017 int num_streams; /*!< number of supported configs */
|
jpayne@69
|
1018 struct snd_tplg_stream_template stream[0]; /*!< supported configs */
|
jpayne@69
|
1019 };
|
jpayne@69
|
1020
|
jpayne@69
|
1021 /** \struct snd_tplg_hw_config_template
|
jpayne@69
|
1022 * \brief Template type to describe a physical link runtime supported
|
jpayne@69
|
1023 * hardware config, i.e. hardware audio formats.
|
jpayne@69
|
1024 */
|
jpayne@69
|
1025 struct snd_tplg_hw_config_template {
|
jpayne@69
|
1026 int id; /* unique ID - - used to match */
|
jpayne@69
|
1027 unsigned int fmt; /* SND_SOC_DAI_FORMAT_ format value */
|
jpayne@69
|
1028 unsigned char clock_gated; /* SND_SOC_TPLG_DAI_CLK_GATE_ value */
|
jpayne@69
|
1029 unsigned char invert_bclk; /* 1 for inverted BCLK, 0 for normal */
|
jpayne@69
|
1030 unsigned char invert_fsync; /* 1 for inverted frame clock, 0 for normal */
|
jpayne@69
|
1031 unsigned char bclk_master; /* SND_SOC_TPLG_BCLK_ value */
|
jpayne@69
|
1032 unsigned char fsync_master; /* SND_SOC_TPLG_FSYNC_ value */
|
jpayne@69
|
1033 unsigned char mclk_direction; /* SND_SOC_TPLG_MCLK_ value */
|
jpayne@69
|
1034 unsigned short reserved; /* for 32bit alignment */
|
jpayne@69
|
1035 unsigned int mclk_rate; /* MCLK or SYSCLK freqency in Hz */
|
jpayne@69
|
1036 unsigned int bclk_rate; /* BCLK freqency in Hz */
|
jpayne@69
|
1037 unsigned int fsync_rate; /* frame clock in Hz */
|
jpayne@69
|
1038 unsigned int tdm_slots; /* number of TDM slots in use */
|
jpayne@69
|
1039 unsigned int tdm_slot_width; /* width in bits for each slot */
|
jpayne@69
|
1040 unsigned int tx_slots; /* bit mask for active Tx slots */
|
jpayne@69
|
1041 unsigned int rx_slots; /* bit mask for active Rx slots */
|
jpayne@69
|
1042 unsigned int tx_channels; /* number of Tx channels */
|
jpayne@69
|
1043 unsigned int *tx_chanmap; /* array of slot number */
|
jpayne@69
|
1044 unsigned int rx_channels; /* number of Rx channels */
|
jpayne@69
|
1045 unsigned int *rx_chanmap; /* array of slot number */
|
jpayne@69
|
1046 };
|
jpayne@69
|
1047
|
jpayne@69
|
1048 /** \struct snd_tplg_dai_template
|
jpayne@69
|
1049 * \brief Template type for physical DAI.
|
jpayne@69
|
1050 * It can be used to configure backend DAIs for DPCM.
|
jpayne@69
|
1051 */
|
jpayne@69
|
1052 struct snd_tplg_dai_template {
|
jpayne@69
|
1053 const char *dai_name; /*!< DAI name */
|
jpayne@69
|
1054 unsigned int dai_id; /*!< unique ID - used to match */
|
jpayne@69
|
1055 unsigned int playback; /*!< supports playback mode */
|
jpayne@69
|
1056 unsigned int capture; /*!< supports capture mode */
|
jpayne@69
|
1057 struct snd_tplg_stream_caps_template *caps[2]; /*!< playback & capture for DAI */
|
jpayne@69
|
1058 unsigned int flag_mask; /*!< bitmask of flags to configure */
|
jpayne@69
|
1059 unsigned int flags; /*!< SND_SOC_TPLG_DAI_FLGBIT_* */
|
jpayne@69
|
1060 struct snd_soc_tplg_private *priv; /*!< private data */
|
jpayne@69
|
1061
|
jpayne@69
|
1062 };
|
jpayne@69
|
1063
|
jpayne@69
|
1064 /** \struct snd_tplg_link_template
|
jpayne@69
|
1065 * \brief Template type for physical DAI Links.
|
jpayne@69
|
1066 */
|
jpayne@69
|
1067 struct snd_tplg_link_template {
|
jpayne@69
|
1068 const char *name; /*!< link name, used to match */
|
jpayne@69
|
1069 int id; /*!< unique ID - used to match with existing physical links */
|
jpayne@69
|
1070 const char *stream_name; /*!< link stream name, used to match */
|
jpayne@69
|
1071
|
jpayne@69
|
1072 int num_streams; /*!< number of configs */
|
jpayne@69
|
1073 struct snd_tplg_stream_template *stream; /*!< supported configs */
|
jpayne@69
|
1074
|
jpayne@69
|
1075 struct snd_tplg_hw_config_template *hw_config; /*!< supported HW configs */
|
jpayne@69
|
1076 int num_hw_configs; /* number of hw configs */
|
jpayne@69
|
1077 int default_hw_config_id; /* default hw config ID for init */
|
jpayne@69
|
1078
|
jpayne@69
|
1079 unsigned int flag_mask; /* bitmask of flags to configure */
|
jpayne@69
|
1080 unsigned int flags; /* SND_SOC_TPLG_LNK_FLGBIT_* flag value */
|
jpayne@69
|
1081 struct snd_soc_tplg_private *priv; /*!< private data */
|
jpayne@69
|
1082 };
|
jpayne@69
|
1083
|
jpayne@69
|
1084 /** \struct snd_tplg_obj_template
|
jpayne@69
|
1085 * \brief Generic Template Object
|
jpayne@69
|
1086 */
|
jpayne@69
|
1087 typedef struct snd_tplg_obj_template {
|
jpayne@69
|
1088 enum snd_tplg_type type; /*!< template object type */
|
jpayne@69
|
1089 int index; /*!< group index for object */
|
jpayne@69
|
1090 int version; /*!< optional vendor specific version details */
|
jpayne@69
|
1091 int vendor_type; /*!< optional vendor specific type info */
|
jpayne@69
|
1092 union {
|
jpayne@69
|
1093 struct snd_tplg_widget_template *widget; /*!< DAPM widget */
|
jpayne@69
|
1094 struct snd_tplg_mixer_template *mixer; /*!< Mixer control */
|
jpayne@69
|
1095 struct snd_tplg_bytes_template *bytes_ctl; /*!< Bytes control */
|
jpayne@69
|
1096 struct snd_tplg_enum_template *enum_ctl; /*!< Enum control */
|
jpayne@69
|
1097 struct snd_tplg_graph_template *graph; /*!< Graph elements */
|
jpayne@69
|
1098 struct snd_tplg_pcm_template *pcm; /*!< PCM elements */
|
jpayne@69
|
1099 struct snd_tplg_link_template *link; /*!< physical DAI Links */
|
jpayne@69
|
1100 struct snd_tplg_dai_template *dai; /*!< Physical DAI */
|
jpayne@69
|
1101 };
|
jpayne@69
|
1102 } snd_tplg_obj_template_t;
|
jpayne@69
|
1103
|
jpayne@69
|
1104 /**
|
jpayne@69
|
1105 * \brief Register topology template object.
|
jpayne@69
|
1106 * \param tplg Topology instance.
|
jpayne@69
|
1107 * \param t Template object.
|
jpayne@69
|
1108 * \return Zero on success, otherwise a negative error code
|
jpayne@69
|
1109 */
|
jpayne@69
|
1110 int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t);
|
jpayne@69
|
1111
|
jpayne@69
|
1112 /**
|
jpayne@69
|
1113 * \brief Build all registered topology data into binary file.
|
jpayne@69
|
1114 * \param tplg Topology instance.
|
jpayne@69
|
1115 * \param outfile Binary topology output file.
|
jpayne@69
|
1116 * \return Zero on success, otherwise a negative error code
|
jpayne@69
|
1117 */
|
jpayne@69
|
1118 int snd_tplg_build(snd_tplg_t *tplg, const char *outfile);
|
jpayne@69
|
1119
|
jpayne@69
|
1120 /**
|
jpayne@69
|
1121 * \brief Build all registered topology data into memory.
|
jpayne@69
|
1122 * \param tplg Topology instance.
|
jpayne@69
|
1123 * \param bin Binary topology output buffer (malloc).
|
jpayne@69
|
1124 * \param size Binary topology output buffer size in bytes.
|
jpayne@69
|
1125 * \return Zero on success, otherwise a negative error code
|
jpayne@69
|
1126 */
|
jpayne@69
|
1127 int snd_tplg_build_bin(snd_tplg_t *tplg, void **bin, size_t *size);
|
jpayne@69
|
1128
|
jpayne@69
|
1129 /**
|
jpayne@69
|
1130 * \brief Attach private data to topology manifest.
|
jpayne@69
|
1131 * \param tplg Topology instance.
|
jpayne@69
|
1132 * \param data Private data.
|
jpayne@69
|
1133 * \param len Length of data in bytes.
|
jpayne@69
|
1134 * \return Zero on success, otherwise a negative error code
|
jpayne@69
|
1135 */
|
jpayne@69
|
1136 int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len);
|
jpayne@69
|
1137
|
jpayne@69
|
1138 /**
|
jpayne@69
|
1139 * \brief Set an optional vendor specific version number.
|
jpayne@69
|
1140 * \param tplg Topology instance.
|
jpayne@69
|
1141 * \param version Vendor specific version number.
|
jpayne@69
|
1142 * \return Zero on success, otherwise a negative error code
|
jpayne@69
|
1143 */
|
jpayne@69
|
1144 int snd_tplg_set_version(snd_tplg_t *tplg, unsigned int version);
|
jpayne@69
|
1145
|
jpayne@69
|
1146 /*
|
jpayne@69
|
1147 * Flags for the snd_tplg_save()
|
jpayne@69
|
1148 */
|
jpayne@69
|
1149 #define SND_TPLG_SAVE_SORT (1<<0) /*!< sort identifiers */
|
jpayne@69
|
1150 #define SND_TPLG_SAVE_GROUPS (1<<1) /*!< create the structure by group index */
|
jpayne@69
|
1151 #define SND_TPLG_SAVE_NOCHECK (1<<16) /*!< unchecked output for debugging */
|
jpayne@69
|
1152
|
jpayne@69
|
1153 /**
|
jpayne@69
|
1154 * \brief Save the topology to the text configuration string.
|
jpayne@69
|
1155 * \param tplg Topology instance.
|
jpayne@69
|
1156 * \param dst A pointer to string with result (malloc).
|
jpayne@69
|
1157 * \return Zero on success, otherwise a negative error code
|
jpayne@69
|
1158 */
|
jpayne@69
|
1159 int snd_tplg_save(snd_tplg_t *tplg, char **dst, int flags);
|
jpayne@69
|
1160
|
jpayne@69
|
1161 /**
|
jpayne@69
|
1162 * \brief Decode the binary topology contents.
|
jpayne@69
|
1163 * \param tplg Topology instance.
|
jpayne@69
|
1164 * \param bin Binary topology input buffer.
|
jpayne@69
|
1165 * \param size Binary topology input buffer size.
|
jpayne@69
|
1166 * \return Zero on success, otherwise a negative error code
|
jpayne@69
|
1167 */
|
jpayne@69
|
1168 int snd_tplg_decode(snd_tplg_t *tplg, void *bin, size_t size, int dflags);
|
jpayne@69
|
1169
|
jpayne@69
|
1170 /* \} */
|
jpayne@69
|
1171
|
jpayne@69
|
1172 #ifdef __cplusplus
|
jpayne@69
|
1173 }
|
jpayne@69
|
1174 #endif
|
jpayne@69
|
1175
|
jpayne@69
|
1176 #endif /* __ALSA_TOPOLOGY_H */
|