Merge remote-tracking branch 'vfio/next'
[deliverable/linux.git] / include / uapi / sound / asoc.h
CommitLineData
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 */
dc31e741 86#define SND_SOC_TPLG_ABI_VERSION 0x5
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
dc31e741
ML
108#define SND_SOC_TPLG_TYPE_BE_DAI 12
109#define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_BE_DAI
c147c0e1
LG
110
111/* vendor block IDs - please add new vendor types to end */
112#define SND_SOC_TPLG_TYPE_VENDOR_FW 1000
113#define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001
114#define SND_SOC_TPLG_TYPE_VENDOR_COEFF 1002
115#define SND_SOC_TPLG_TYPEVENDOR_CODEC 1003
116
117#define SND_SOC_TPLG_STREAM_PLAYBACK 0
118#define SND_SOC_TPLG_STREAM_CAPTURE 1
119
e42839b0
ML
120/* vendor tuple types */
121#define SND_SOC_TPLG_TUPLE_TYPE_UUID 0
122#define SND_SOC_TPLG_TUPLE_TYPE_STRING 1
123#define SND_SOC_TPLG_TUPLE_TYPE_BOOL 2
124#define SND_SOC_TPLG_TUPLE_TYPE_BYTE 3
125#define SND_SOC_TPLG_TUPLE_TYPE_WORD 4
126#define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5
127
dc31e741
ML
128/* BE DAI flags */
129#define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_RATES (1 << 0)
130#define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS (1 << 1)
131#define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2)
132
c147c0e1
LG
133/*
134 * Block Header.
9c3a4732 135 * This header precedes all object and object arrays below.
c147c0e1
LG
136 */
137struct snd_soc_tplg_hdr {
138 __le32 magic; /* magic number */
139 __le32 abi; /* ABI version */
140 __le32 version; /* optional vendor specific version details */
141 __le32 type; /* SND_SOC_TPLG_TYPE_ */
142 __le32 size; /* size of this structure */
143 __le32 vendor_type; /* optional vendor specific type info */
144 __le32 payload_size; /* data bytes, excluding this header */
145 __le32 index; /* identifier for block */
146 __le32 count; /* number of elements in block */
147} __attribute__((packed));
148
e42839b0
ML
149/* vendor tuple for uuid */
150struct snd_soc_tplg_vendor_uuid_elem {
151 __le32 token;
152 char uuid[16];
153} __attribute__((packed));
154
155/* vendor tuple for a bool/byte/short/word value */
156struct snd_soc_tplg_vendor_value_elem {
157 __le32 token;
158 __le32 value;
159} __attribute__((packed));
160
161/* vendor tuple for string */
162struct snd_soc_tplg_vendor_string_elem {
163 __le32 token;
164 char string[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
165} __attribute__((packed));
166
167struct snd_soc_tplg_vendor_array {
168 __le32 size; /* size in bytes of the array, including all elements */
169 __le32 type; /* SND_SOC_TPLG_TUPLE_TYPE_ */
170 __le32 num_elems; /* number of elements in array */
171 union {
172 struct snd_soc_tplg_vendor_uuid_elem uuid[0];
173 struct snd_soc_tplg_vendor_value_elem value[0];
174 struct snd_soc_tplg_vendor_string_elem string[0];
175 };
176} __attribute__((packed));
177
c147c0e1
LG
178/*
179 * Private data.
180 * All topology objects may have private data that can be used by the driver or
181 * firmware. Core will ignore this data.
182 */
183struct snd_soc_tplg_private {
184 __le32 size; /* in bytes of private data */
e42839b0
ML
185 union {
186 char data[0];
187 struct snd_soc_tplg_vendor_array array[0];
188 };
c147c0e1
LG
189} __attribute__((packed));
190
191/*
192 * Kcontrol TLV data.
193 */
28a87eeb
ML
194struct snd_soc_tplg_tlv_dbscale {
195 __le32 min;
196 __le32 step;
197 __le32 mute;
198} __attribute__((packed));
199
c147c0e1 200struct snd_soc_tplg_ctl_tlv {
28a87eeb
ML
201 __le32 size; /* in bytes of this structure */
202 __le32 type; /* SNDRV_CTL_TLVT_*, type of TLV */
203 union {
204 __le32 data[SND_SOC_TPLG_TLV_SIZE];
205 struct snd_soc_tplg_tlv_dbscale scale;
206 };
c147c0e1
LG
207} __attribute__((packed));
208
209/*
210 * Kcontrol channel data
211 */
212struct snd_soc_tplg_channel {
213 __le32 size; /* in bytes of this structure */
214 __le32 reg;
215 __le32 shift;
216 __le32 id; /* ID maps to Left, Right, LFE etc */
217} __attribute__((packed));
218
219/*
cb88498b
ML
220 * Genericl Operations IDs, for binding Kcontrol or Bytes ext ops
221 * Kcontrol ops need get/put/info.
222 * Bytes ext ops need get/put.
c147c0e1 223 */
cb88498b 224struct snd_soc_tplg_io_ops {
c147c0e1
LG
225 __le32 get;
226 __le32 put;
227 __le32 info;
228} __attribute__((packed));
229
230/*
231 * kcontrol header
232 */
233struct snd_soc_tplg_ctl_hdr {
234 __le32 size; /* in bytes of this structure */
235 __le32 type;
236 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
237 __le32 access;
cb88498b 238 struct snd_soc_tplg_io_ops ops;
28a87eeb 239 struct snd_soc_tplg_ctl_tlv tlv;
c147c0e1
LG
240} __attribute__((packed));
241
242/*
243 * Stream Capabilities
244 */
245struct snd_soc_tplg_stream_caps {
246 __le32 size; /* in bytes of this structure */
247 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
478d0d39 248 __le64 formats; /* supported formats SNDRV_PCM_FMTBIT_* */
c147c0e1
LG
249 __le32 rates; /* supported rates SNDRV_PCM_RATE_* */
250 __le32 rate_min; /* min rate */
251 __le32 rate_max; /* max rate */
252 __le32 channels_min; /* min channels */
253 __le32 channels_max; /* max channels */
254 __le32 periods_min; /* min number of periods */
255 __le32 periods_max; /* max number of periods */
256 __le32 period_size_min; /* min period size bytes */
257 __le32 period_size_max; /* max period size bytes */
258 __le32 buffer_size_min; /* min buffer size bytes */
259 __le32 buffer_size_max; /* max buffer size bytes */
f918e169 260 __le32 sig_bits; /* number of bits of content */
c147c0e1
LG
261} __attribute__((packed));
262
263/*
264 * FE or BE Stream configuration supported by SW/FW
265 */
266struct snd_soc_tplg_stream {
267 __le32 size; /* in bytes of this structure */
731324f5 268 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* Name of the stream */
c147c0e1
LG
269 __le64 format; /* SNDRV_PCM_FMTBIT_* */
270 __le32 rate; /* SNDRV_PCM_RATE_* */
271 __le32 period_bytes; /* size of period in bytes */
272 __le32 buffer_bytes; /* size of buffer in bytes */
273 __le32 channels; /* channels */
c147c0e1
LG
274} __attribute__((packed));
275
c147c0e1
LG
276/*
277 * Manifest. List totals for each payload type. Not used in parsing, but will
278 * be passed to the component driver before any other objects in order for any
9c3a4732 279 * global component resource allocations.
c147c0e1
LG
280 *
281 * File block representation for manifest :-
282 * +-----------------------------------+----+
283 * | struct snd_soc_tplg_hdr | 1 |
284 * +-----------------------------------+----+
285 * | struct snd_soc_tplg_manifest | 1 |
286 * +-----------------------------------+----+
287 */
288struct snd_soc_tplg_manifest {
289 __le32 size; /* in bytes of this structure */
290 __le32 control_elems; /* number of control elements */
291 __le32 widget_elems; /* number of widget elements */
292 __le32 graph_elems; /* number of graph elements */
4b6c56c2 293 __le32 pcm_elems; /* number of PCM elements */
c147c0e1 294 __le32 dai_link_elems; /* number of DAI link elements */
dc31e741
ML
295 __le32 be_dai_elems; /* number of BE DAI elements */
296 __le32 reserved[20]; /* reserved for new ABI element types */
c3879956 297 struct snd_soc_tplg_private priv;
c147c0e1
LG
298} __attribute__((packed));
299
300/*
301 * Mixer kcontrol.
302 *
303 * File block representation for mixer kcontrol :-
304 * +-----------------------------------+----+
305 * | struct snd_soc_tplg_hdr | 1 |
306 * +-----------------------------------+----+
307 * | struct snd_soc_tplg_mixer_control | N |
308 * +-----------------------------------+----+
309 */
310struct snd_soc_tplg_mixer_control {
311 struct snd_soc_tplg_ctl_hdr hdr;
312 __le32 size; /* in bytes of this structure */
313 __le32 min;
314 __le32 max;
315 __le32 platform_max;
316 __le32 invert;
317 __le32 num_channels;
318 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
c147c0e1
LG
319 struct snd_soc_tplg_private priv;
320} __attribute__((packed));
321
322/*
323 * Enumerated kcontrol
324 *
325 * File block representation for enum kcontrol :-
326 * +-----------------------------------+----+
327 * | struct snd_soc_tplg_hdr | 1 |
328 * +-----------------------------------+----+
329 * | struct snd_soc_tplg_enum_control | N |
330 * +-----------------------------------+----+
331 */
332struct snd_soc_tplg_enum_control {
333 struct snd_soc_tplg_ctl_hdr hdr;
334 __le32 size; /* in bytes of this structure */
335 __le32 num_channels;
336 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
337 __le32 items;
338 __le32 mask;
339 __le32 count;
340 char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
341 __le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4];
342 struct snd_soc_tplg_private priv;
343} __attribute__((packed));
344
345/*
346 * Bytes kcontrol
347 *
348 * File block representation for bytes kcontrol :-
349 * +-----------------------------------+----+
350 * | struct snd_soc_tplg_hdr | 1 |
351 * +-----------------------------------+----+
352 * | struct snd_soc_tplg_bytes_control | N |
353 * +-----------------------------------+----+
354 */
355struct snd_soc_tplg_bytes_control {
356 struct snd_soc_tplg_ctl_hdr hdr;
357 __le32 size; /* in bytes of this structure */
358 __le32 max;
359 __le32 mask;
360 __le32 base;
361 __le32 num_regs;
cb88498b 362 struct snd_soc_tplg_io_ops ext_ops;
c147c0e1
LG
363 struct snd_soc_tplg_private priv;
364} __attribute__((packed));
365
366/*
367 * DAPM Graph Element
368 *
369 * File block representation for DAPM graph elements :-
370 * +-------------------------------------+----+
371 * | struct snd_soc_tplg_hdr | 1 |
372 * +-------------------------------------+----+
373 * | struct snd_soc_tplg_dapm_graph_elem | N |
374 * +-------------------------------------+----+
375 */
376struct snd_soc_tplg_dapm_graph_elem {
377 char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
378 char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
379 char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
380} __attribute__((packed));
381
382/*
383 * DAPM Widget.
384 *
385 * File block representation for DAPM widget :-
386 * +-------------------------------------+-----+
387 * | struct snd_soc_tplg_hdr | 1 |
388 * +-------------------------------------+-----+
389 * | struct snd_soc_tplg_dapm_widget | N |
390 * +-------------------------------------+-----+
391 * | struct snd_soc_tplg_enum_control | 0|1 |
392 * | struct snd_soc_tplg_mixer_control | 0|N |
393 * +-------------------------------------+-----+
394 *
395 * Optional enum or mixer control can be appended to the end of each widget
396 * in the block.
397 */
398struct snd_soc_tplg_dapm_widget {
399 __le32 size; /* in bytes of this structure */
400 __le32 id; /* SND_SOC_DAPM_CTL */
401 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
402 char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
403
404 __le32 reg; /* negative reg = no direct dapm */
405 __le32 shift; /* bits to shift */
406 __le32 mask; /* non-shifted mask */
6dc6db79 407 __le32 subseq; /* sort within widget type */
e8b3fe8f
VP
408 __le32 invert; /* invert the power bit */
409 __le32 ignore_suspend; /* kept enabled over suspend */
410 __le16 event_flags;
411 __le16 event_type;
412 __le32 num_kcontrols;
c147c0e1
LG
413 struct snd_soc_tplg_private priv;
414 /*
415 * kcontrols that relate to this widget
416 * follow here after widget private data
417 */
418} __attribute__((packed));
419
c147c0e1
LG
420
421/*
5b2688a5 422 * Describes SW/FW specific features of PCM (FE DAI & DAI link).
c147c0e1 423 *
5b2688a5 424 * File block representation for PCM :-
c147c0e1
LG
425 * +-----------------------------------+-----+
426 * | struct snd_soc_tplg_hdr | 1 |
427 * +-----------------------------------+-----+
5b2688a5 428 * | struct snd_soc_tplg_pcm | N |
c147c0e1
LG
429 * +-----------------------------------+-----+
430 */
5b2688a5 431struct snd_soc_tplg_pcm {
c147c0e1 432 __le32 size; /* in bytes of this structure */
5b2688a5
VP
433 char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
434 char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
b84fff5a 435 __le32 pcm_id; /* unique ID - used to match with DAI link */
5b2688a5
VP
436 __le32 dai_id; /* unique ID - used to match */
437 __le32 playback; /* supports playback mode */
438 __le32 capture; /* supports capture mode */
439 __le32 compress; /* 1 = compressed; 0 = PCM */
440 struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */
441 __le32 num_streams; /* number of streams */
442 struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */
c147c0e1
LG
443} __attribute__((packed));
444
e2a9df65
VP
445
446/*
447 * Describes the BE or CC link runtime supported configs or params
448 *
449 * File block representation for BE/CC link config :-
450 * +-----------------------------------+-----+
451 * | struct snd_soc_tplg_hdr | 1 |
452 * +-----------------------------------+-----+
453 * | struct snd_soc_tplg_link_config | N |
454 * +-----------------------------------+-----+
455 */
456struct snd_soc_tplg_link_config {
457 __le32 size; /* in bytes of this structure */
458 __le32 id; /* unique ID - used to match */
459 struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* supported configs playback and captrure */
460 __le32 num_streams; /* number of streams */
461} __attribute__((packed));
dc31e741
ML
462
463/*
464 * Describes SW/FW specific features of BE DAI.
465 *
466 * File block representation for BE DAI :-
467 * +-----------------------------------+-----+
468 * | struct snd_soc_tplg_hdr | 1 |
469 * +-----------------------------------+-----+
470 * | struct snd_soc_tplg_be_dai | N |
471 * +-----------------------------------+-----+
472 */
473struct snd_soc_tplg_be_dai {
474 __le32 size; /* in bytes of this structure */
475 char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* name - used to match */
476 __le32 dai_id; /* unique ID - used to match */
477 __le32 playback; /* supports playback mode */
478 __le32 capture; /* supports capture mode */
479 struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */
480 __le32 flag_mask; /* bitmask of flags to configure */
481 __le32 flags; /* SND_SOC_TPLG_DAI_FLGBIT_* */
482 struct snd_soc_tplg_private priv;
483} __attribute__((packed));
c147c0e1 484#endif
This page took 0.077885 seconds and 5 git commands to generate.