Commit | Line | Data |
---|---|---|
c147c0e1 LG |
1 | /* |
2 | * uapi/sound/asoc.h -- ALSA SoC Firmware Controls and DAPM | |
3 | * | |
4 | * Copyright (C) 2012 Texas Instruments Inc. | |
5 | * Copyright (C) 2015 Intel Corporation. | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | * | |
11 | * Simple file API to load FW that includes mixers, coefficients, DAPM graphs, | |
12 | * algorithms, equalisers, DAIs, widgets etc. | |
13 | */ | |
14 | ||
15 | #ifndef __LINUX_UAPI_SND_ASOC_H | |
16 | #define __LINUX_UAPI_SND_ASOC_H | |
17 | ||
18 | #include <linux/types.h> | |
19 | #include <sound/asound.h> | |
20 | ||
8c90503b MB |
21 | #ifndef __KERNEL__ |
22 | #error This API is an early revision and not enabled in the current | |
23 | #error kernel release, it will be enabled in a future kernel version | |
24 | #error with incompatible changes to what is here. | |
25 | #endif | |
26 | ||
c147c0e1 LG |
27 | /* |
28 | * Maximum number of channels topology kcontrol can represent. | |
29 | */ | |
30 | #define SND_SOC_TPLG_MAX_CHAN 8 | |
31 | ||
32 | /* | |
33 | * Maximum number of PCM formats capability | |
34 | */ | |
35 | #define SND_SOC_TPLG_MAX_FORMATS 16 | |
36 | ||
37 | /* | |
38 | * Maximum number of PCM stream configs | |
39 | */ | |
40 | #define SND_SOC_TPLG_STREAM_CONFIG_MAX 8 | |
41 | ||
42 | /* individual kcontrol info types - can be mixed with other types */ | |
43 | #define SND_SOC_TPLG_CTL_VOLSW 1 | |
44 | #define SND_SOC_TPLG_CTL_VOLSW_SX 2 | |
45 | #define SND_SOC_TPLG_CTL_VOLSW_XR_SX 3 | |
46 | #define SND_SOC_TPLG_CTL_ENUM 4 | |
47 | #define SND_SOC_TPLG_CTL_BYTES 5 | |
48 | #define SND_SOC_TPLG_CTL_ENUM_VALUE 6 | |
49 | #define SND_SOC_TPLG_CTL_RANGE 7 | |
50 | #define SND_SOC_TPLG_CTL_STROBE 8 | |
51 | ||
52 | ||
53 | /* individual widget kcontrol info types - can be mixed with other types */ | |
54 | #define SND_SOC_TPLG_DAPM_CTL_VOLSW 64 | |
55 | #define SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE 65 | |
56 | #define SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT 66 | |
57 | #define SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE 67 | |
58 | #define SND_SOC_TPLG_DAPM_CTL_PIN 68 | |
59 | ||
60 | /* DAPM widget types - add new items to the end */ | |
61 | #define SND_SOC_TPLG_DAPM_INPUT 0 | |
62 | #define SND_SOC_TPLG_DAPM_OUTPUT 1 | |
63 | #define SND_SOC_TPLG_DAPM_MUX 2 | |
64 | #define SND_SOC_TPLG_DAPM_MIXER 3 | |
65 | #define SND_SOC_TPLG_DAPM_PGA 4 | |
66 | #define SND_SOC_TPLG_DAPM_OUT_DRV 5 | |
67 | #define SND_SOC_TPLG_DAPM_ADC 6 | |
68 | #define SND_SOC_TPLG_DAPM_DAC 7 | |
69 | #define SND_SOC_TPLG_DAPM_SWITCH 8 | |
70 | #define SND_SOC_TPLG_DAPM_PRE 9 | |
71 | #define SND_SOC_TPLG_DAPM_POST 10 | |
72 | #define SND_SOC_TPLG_DAPM_AIF_IN 11 | |
73 | #define SND_SOC_TPLG_DAPM_AIF_OUT 12 | |
74 | #define SND_SOC_TPLG_DAPM_DAI_IN 13 | |
75 | #define SND_SOC_TPLG_DAPM_DAI_OUT 14 | |
76 | #define SND_SOC_TPLG_DAPM_DAI_LINK 15 | |
77 | #define SND_SOC_TPLG_DAPM_LAST SND_SOC_TPLG_DAPM_DAI_LINK | |
78 | ||
79 | /* Header magic number and string sizes */ | |
80 | #define SND_SOC_TPLG_MAGIC 0x41536F43 /* ASoC */ | |
81 | ||
82 | /* string sizes */ | |
83 | #define SND_SOC_TPLG_NUM_TEXTS 16 | |
84 | ||
85 | /* ABI version */ | |
5b2688a5 | 86 | #define SND_SOC_TPLG_ABI_VERSION 0x4 |
c147c0e1 LG |
87 | |
88 | /* Max size of TLV data */ | |
89 | #define SND_SOC_TPLG_TLV_SIZE 32 | |
90 | ||
91 | /* | |
92 | * File and Block header data types. | |
93 | * Add new generic and vendor types to end of list. | |
94 | * Generic types are handled by the core whilst vendors types are passed | |
95 | * to the component drivers for handling. | |
96 | */ | |
97 | #define SND_SOC_TPLG_TYPE_MIXER 1 | |
98 | #define SND_SOC_TPLG_TYPE_BYTES 2 | |
99 | #define SND_SOC_TPLG_TYPE_ENUM 3 | |
100 | #define SND_SOC_TPLG_TYPE_DAPM_GRAPH 4 | |
101 | #define SND_SOC_TPLG_TYPE_DAPM_WIDGET 5 | |
102 | #define SND_SOC_TPLG_TYPE_DAI_LINK 6 | |
103 | #define SND_SOC_TPLG_TYPE_PCM 7 | |
104 | #define SND_SOC_TPLG_TYPE_MANIFEST 8 | |
105 | #define SND_SOC_TPLG_TYPE_CODEC_LINK 9 | |
7c545b32 VP |
106 | #define SND_SOC_TPLG_TYPE_BACKEND_LINK 10 |
107 | #define SND_SOC_TPLG_TYPE_PDATA 11 | |
c7bcf877 | 108 | #define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_PDATA |
c147c0e1 LG |
109 | |
110 | /* vendor block IDs - please add new vendor types to end */ | |
111 | #define SND_SOC_TPLG_TYPE_VENDOR_FW 1000 | |
112 | #define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001 | |
113 | #define SND_SOC_TPLG_TYPE_VENDOR_COEFF 1002 | |
114 | #define SND_SOC_TPLG_TYPEVENDOR_CODEC 1003 | |
115 | ||
116 | #define SND_SOC_TPLG_STREAM_PLAYBACK 0 | |
117 | #define SND_SOC_TPLG_STREAM_CAPTURE 1 | |
118 | ||
119 | /* | |
120 | * Block Header. | |
9c3a4732 | 121 | * This header precedes all object and object arrays below. |
c147c0e1 LG |
122 | */ |
123 | struct snd_soc_tplg_hdr { | |
124 | __le32 magic; /* magic number */ | |
125 | __le32 abi; /* ABI version */ | |
126 | __le32 version; /* optional vendor specific version details */ | |
127 | __le32 type; /* SND_SOC_TPLG_TYPE_ */ | |
128 | __le32 size; /* size of this structure */ | |
129 | __le32 vendor_type; /* optional vendor specific type info */ | |
130 | __le32 payload_size; /* data bytes, excluding this header */ | |
131 | __le32 index; /* identifier for block */ | |
132 | __le32 count; /* number of elements in block */ | |
133 | } __attribute__((packed)); | |
134 | ||
135 | /* | |
136 | * Private data. | |
137 | * All topology objects may have private data that can be used by the driver or | |
138 | * firmware. Core will ignore this data. | |
139 | */ | |
140 | struct snd_soc_tplg_private { | |
141 | __le32 size; /* in bytes of private data */ | |
142 | char data[0]; | |
143 | } __attribute__((packed)); | |
144 | ||
145 | /* | |
146 | * Kcontrol TLV data. | |
147 | */ | |
28a87eeb ML |
148 | struct snd_soc_tplg_tlv_dbscale { |
149 | __le32 min; | |
150 | __le32 step; | |
151 | __le32 mute; | |
152 | } __attribute__((packed)); | |
153 | ||
c147c0e1 | 154 | struct snd_soc_tplg_ctl_tlv { |
28a87eeb ML |
155 | __le32 size; /* in bytes of this structure */ |
156 | __le32 type; /* SNDRV_CTL_TLVT_*, type of TLV */ | |
157 | union { | |
158 | __le32 data[SND_SOC_TPLG_TLV_SIZE]; | |
159 | struct snd_soc_tplg_tlv_dbscale scale; | |
160 | }; | |
c147c0e1 LG |
161 | } __attribute__((packed)); |
162 | ||
163 | /* | |
164 | * Kcontrol channel data | |
165 | */ | |
166 | struct snd_soc_tplg_channel { | |
167 | __le32 size; /* in bytes of this structure */ | |
168 | __le32 reg; | |
169 | __le32 shift; | |
170 | __le32 id; /* ID maps to Left, Right, LFE etc */ | |
171 | } __attribute__((packed)); | |
172 | ||
173 | /* | |
cb88498b ML |
174 | * Genericl Operations IDs, for binding Kcontrol or Bytes ext ops |
175 | * Kcontrol ops need get/put/info. | |
176 | * Bytes ext ops need get/put. | |
c147c0e1 | 177 | */ |
cb88498b | 178 | struct snd_soc_tplg_io_ops { |
c147c0e1 LG |
179 | __le32 get; |
180 | __le32 put; | |
181 | __le32 info; | |
182 | } __attribute__((packed)); | |
183 | ||
184 | /* | |
185 | * kcontrol header | |
186 | */ | |
187 | struct snd_soc_tplg_ctl_hdr { | |
188 | __le32 size; /* in bytes of this structure */ | |
189 | __le32 type; | |
190 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | |
191 | __le32 access; | |
cb88498b | 192 | struct snd_soc_tplg_io_ops ops; |
28a87eeb | 193 | struct snd_soc_tplg_ctl_tlv tlv; |
c147c0e1 LG |
194 | } __attribute__((packed)); |
195 | ||
196 | /* | |
197 | * Stream Capabilities | |
198 | */ | |
199 | struct snd_soc_tplg_stream_caps { | |
200 | __le32 size; /* in bytes of this structure */ | |
201 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | |
478d0d39 | 202 | __le64 formats; /* supported formats SNDRV_PCM_FMTBIT_* */ |
c147c0e1 LG |
203 | __le32 rates; /* supported rates SNDRV_PCM_RATE_* */ |
204 | __le32 rate_min; /* min rate */ | |
205 | __le32 rate_max; /* max rate */ | |
206 | __le32 channels_min; /* min channels */ | |
207 | __le32 channels_max; /* max channels */ | |
208 | __le32 periods_min; /* min number of periods */ | |
209 | __le32 periods_max; /* max number of periods */ | |
210 | __le32 period_size_min; /* min period size bytes */ | |
211 | __le32 period_size_max; /* max period size bytes */ | |
212 | __le32 buffer_size_min; /* min buffer size bytes */ | |
213 | __le32 buffer_size_max; /* max buffer size bytes */ | |
214 | } __attribute__((packed)); | |
215 | ||
216 | /* | |
217 | * FE or BE Stream configuration supported by SW/FW | |
218 | */ | |
219 | struct snd_soc_tplg_stream { | |
220 | __le32 size; /* in bytes of this structure */ | |
731324f5 | 221 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* Name of the stream */ |
c147c0e1 LG |
222 | __le64 format; /* SNDRV_PCM_FMTBIT_* */ |
223 | __le32 rate; /* SNDRV_PCM_RATE_* */ | |
224 | __le32 period_bytes; /* size of period in bytes */ | |
225 | __le32 buffer_bytes; /* size of buffer in bytes */ | |
226 | __le32 channels; /* channels */ | |
227 | __le32 tdm_slot; /* optional BE bitmask of supported TDM slots */ | |
228 | __le32 dai_fmt; /* SND_SOC_DAIFMT_ */ | |
229 | } __attribute__((packed)); | |
230 | ||
c147c0e1 LG |
231 | /* |
232 | * Manifest. List totals for each payload type. Not used in parsing, but will | |
233 | * be passed to the component driver before any other objects in order for any | |
9c3a4732 | 234 | * global component resource allocations. |
c147c0e1 LG |
235 | * |
236 | * File block representation for manifest :- | |
237 | * +-----------------------------------+----+ | |
238 | * | struct snd_soc_tplg_hdr | 1 | | |
239 | * +-----------------------------------+----+ | |
240 | * | struct snd_soc_tplg_manifest | 1 | | |
241 | * +-----------------------------------+----+ | |
242 | */ | |
243 | struct snd_soc_tplg_manifest { | |
244 | __le32 size; /* in bytes of this structure */ | |
245 | __le32 control_elems; /* number of control elements */ | |
246 | __le32 widget_elems; /* number of widget elements */ | |
247 | __le32 graph_elems; /* number of graph elements */ | |
248 | __le32 dai_elems; /* number of DAI elements */ | |
249 | __le32 dai_link_elems; /* number of DAI link elements */ | |
c3879956 | 250 | struct snd_soc_tplg_private priv; |
c147c0e1 LG |
251 | } __attribute__((packed)); |
252 | ||
253 | /* | |
254 | * Mixer kcontrol. | |
255 | * | |
256 | * File block representation for mixer kcontrol :- | |
257 | * +-----------------------------------+----+ | |
258 | * | struct snd_soc_tplg_hdr | 1 | | |
259 | * +-----------------------------------+----+ | |
260 | * | struct snd_soc_tplg_mixer_control | N | | |
261 | * +-----------------------------------+----+ | |
262 | */ | |
263 | struct snd_soc_tplg_mixer_control { | |
264 | struct snd_soc_tplg_ctl_hdr hdr; | |
265 | __le32 size; /* in bytes of this structure */ | |
266 | __le32 min; | |
267 | __le32 max; | |
268 | __le32 platform_max; | |
269 | __le32 invert; | |
270 | __le32 num_channels; | |
271 | struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN]; | |
c147c0e1 LG |
272 | struct snd_soc_tplg_private priv; |
273 | } __attribute__((packed)); | |
274 | ||
275 | /* | |
276 | * Enumerated kcontrol | |
277 | * | |
278 | * File block representation for enum kcontrol :- | |
279 | * +-----------------------------------+----+ | |
280 | * | struct snd_soc_tplg_hdr | 1 | | |
281 | * +-----------------------------------+----+ | |
282 | * | struct snd_soc_tplg_enum_control | N | | |
283 | * +-----------------------------------+----+ | |
284 | */ | |
285 | struct snd_soc_tplg_enum_control { | |
286 | struct snd_soc_tplg_ctl_hdr hdr; | |
287 | __le32 size; /* in bytes of this structure */ | |
288 | __le32 num_channels; | |
289 | struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN]; | |
290 | __le32 items; | |
291 | __le32 mask; | |
292 | __le32 count; | |
293 | char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | |
294 | __le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4]; | |
295 | struct snd_soc_tplg_private priv; | |
296 | } __attribute__((packed)); | |
297 | ||
298 | /* | |
299 | * Bytes kcontrol | |
300 | * | |
301 | * File block representation for bytes kcontrol :- | |
302 | * +-----------------------------------+----+ | |
303 | * | struct snd_soc_tplg_hdr | 1 | | |
304 | * +-----------------------------------+----+ | |
305 | * | struct snd_soc_tplg_bytes_control | N | | |
306 | * +-----------------------------------+----+ | |
307 | */ | |
308 | struct snd_soc_tplg_bytes_control { | |
309 | struct snd_soc_tplg_ctl_hdr hdr; | |
310 | __le32 size; /* in bytes of this structure */ | |
311 | __le32 max; | |
312 | __le32 mask; | |
313 | __le32 base; | |
314 | __le32 num_regs; | |
cb88498b | 315 | struct snd_soc_tplg_io_ops ext_ops; |
c147c0e1 LG |
316 | struct snd_soc_tplg_private priv; |
317 | } __attribute__((packed)); | |
318 | ||
319 | /* | |
320 | * DAPM Graph Element | |
321 | * | |
322 | * File block representation for DAPM graph elements :- | |
323 | * +-------------------------------------+----+ | |
324 | * | struct snd_soc_tplg_hdr | 1 | | |
325 | * +-------------------------------------+----+ | |
326 | * | struct snd_soc_tplg_dapm_graph_elem | N | | |
327 | * +-------------------------------------+----+ | |
328 | */ | |
329 | struct snd_soc_tplg_dapm_graph_elem { | |
330 | char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | |
331 | char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | |
332 | char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | |
333 | } __attribute__((packed)); | |
334 | ||
335 | /* | |
336 | * DAPM Widget. | |
337 | * | |
338 | * File block representation for DAPM widget :- | |
339 | * +-------------------------------------+-----+ | |
340 | * | struct snd_soc_tplg_hdr | 1 | | |
341 | * +-------------------------------------+-----+ | |
342 | * | struct snd_soc_tplg_dapm_widget | N | | |
343 | * +-------------------------------------+-----+ | |
344 | * | struct snd_soc_tplg_enum_control | 0|1 | | |
345 | * | struct snd_soc_tplg_mixer_control | 0|N | | |
346 | * +-------------------------------------+-----+ | |
347 | * | |
348 | * Optional enum or mixer control can be appended to the end of each widget | |
349 | * in the block. | |
350 | */ | |
351 | struct snd_soc_tplg_dapm_widget { | |
352 | __le32 size; /* in bytes of this structure */ | |
353 | __le32 id; /* SND_SOC_DAPM_CTL */ | |
354 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | |
355 | char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | |
356 | ||
357 | __le32 reg; /* negative reg = no direct dapm */ | |
358 | __le32 shift; /* bits to shift */ | |
359 | __le32 mask; /* non-shifted mask */ | |
6dc6db79 | 360 | __le32 subseq; /* sort within widget type */ |
e8b3fe8f VP |
361 | __le32 invert; /* invert the power bit */ |
362 | __le32 ignore_suspend; /* kept enabled over suspend */ | |
363 | __le16 event_flags; | |
364 | __le16 event_type; | |
365 | __le32 num_kcontrols; | |
c147c0e1 LG |
366 | struct snd_soc_tplg_private priv; |
367 | /* | |
368 | * kcontrols that relate to this widget | |
369 | * follow here after widget private data | |
370 | */ | |
371 | } __attribute__((packed)); | |
372 | ||
c147c0e1 LG |
373 | |
374 | /* | |
5b2688a5 | 375 | * Describes SW/FW specific features of PCM (FE DAI & DAI link). |
c147c0e1 | 376 | * |
5b2688a5 | 377 | * File block representation for PCM :- |
c147c0e1 LG |
378 | * +-----------------------------------+-----+ |
379 | * | struct snd_soc_tplg_hdr | 1 | | |
380 | * +-----------------------------------+-----+ | |
5b2688a5 | 381 | * | struct snd_soc_tplg_pcm | N | |
c147c0e1 LG |
382 | * +-----------------------------------+-----+ |
383 | */ | |
5b2688a5 | 384 | struct snd_soc_tplg_pcm { |
c147c0e1 | 385 | __le32 size; /* in bytes of this structure */ |
5b2688a5 VP |
386 | char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; |
387 | char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | |
388 | __le32 pcm_id; /* unique ID - used to match */ | |
389 | __le32 dai_id; /* unique ID - used to match */ | |
390 | __le32 playback; /* supports playback mode */ | |
391 | __le32 capture; /* supports capture mode */ | |
392 | __le32 compress; /* 1 = compressed; 0 = PCM */ | |
393 | struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */ | |
394 | __le32 num_streams; /* number of streams */ | |
395 | struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */ | |
c147c0e1 LG |
396 | } __attribute__((packed)); |
397 | ||
398 | #endif |