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