]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - include/uapi/sound/asoc.h
ASoC: topology: Disable use from userspace
[karo-tx-linux.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 #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
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 */
86 #define SND_SOC_TPLG_ABI_VERSION        0x2
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
106 #define SND_SOC_TPLG_TYPE_MAX   SND_SOC_TPLG_TYPE_CODEC_LINK
107
108 /* vendor block IDs - please add new vendor types to end */
109 #define SND_SOC_TPLG_TYPE_VENDOR_FW     1000
110 #define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001
111 #define SND_SOC_TPLG_TYPE_VENDOR_COEFF  1002
112 #define SND_SOC_TPLG_TYPEVENDOR_CODEC   1003
113
114 #define SND_SOC_TPLG_STREAM_PLAYBACK    0
115 #define SND_SOC_TPLG_STREAM_CAPTURE     1
116
117 /*
118  * Block Header.
119  * This header preceeds all object and object arrays below.
120  */
121 struct snd_soc_tplg_hdr {
122         __le32 magic;           /* magic number */
123         __le32 abi;             /* ABI version */
124         __le32 version;         /* optional vendor specific version details */
125         __le32 type;            /* SND_SOC_TPLG_TYPE_ */
126         __le32 size;            /* size of this structure */
127         __le32 vendor_type;     /* optional vendor specific type info */
128         __le32 payload_size;    /* data bytes, excluding this header */
129         __le32 index;           /* identifier for block */
130         __le32 count;           /* number of elements in block */
131 } __attribute__((packed));
132
133 /*
134  * Private data.
135  * All topology objects may have private data that can be used by the driver or
136  * firmware. Core will ignore this data.
137  */
138 struct snd_soc_tplg_private {
139         __le32 size;    /* in bytes of private data */
140         char data[0];
141 } __attribute__((packed));
142
143 /*
144  * Kcontrol TLV data.
145  */
146 struct snd_soc_tplg_ctl_tlv {
147         __le32 size;    /* in bytes aligned to 4 */
148         __le32 numid;   /* control element numeric identification */
149         __le32 count;   /* number of elem in data array */
150         __le32 data[SND_SOC_TPLG_TLV_SIZE];
151 } __attribute__((packed));
152
153 /*
154  * Kcontrol channel data
155  */
156 struct snd_soc_tplg_channel {
157         __le32 size;    /* in bytes of this structure */
158         __le32 reg;
159         __le32 shift;
160         __le32 id;      /* ID maps to Left, Right, LFE etc */
161 } __attribute__((packed));
162
163 /*
164  * Kcontrol Operations IDs
165  */
166 struct snd_soc_tplg_kcontrol_ops_id {
167         __le32 get;
168         __le32 put;
169         __le32 info;
170 } __attribute__((packed));
171
172 /*
173  * kcontrol header
174  */
175 struct snd_soc_tplg_ctl_hdr {
176         __le32 size;    /* in bytes of this structure */
177         __le32 type;
178         char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
179         __le32 access;
180         struct snd_soc_tplg_kcontrol_ops_id ops;
181         __le32 tlv_size;        /* non zero means control has TLV data */
182 } __attribute__((packed));
183
184 /*
185  * Stream Capabilities
186  */
187 struct snd_soc_tplg_stream_caps {
188         __le32 size;            /* in bytes of this structure */
189         char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
190         __le64 formats[SND_SOC_TPLG_MAX_FORMATS];       /* supported formats SNDRV_PCM_FMTBIT_* */
191         __le32 rates;           /* supported rates SNDRV_PCM_RATE_* */
192         __le32 rate_min;        /* min rate */
193         __le32 rate_max;        /* max rate */
194         __le32 channels_min;    /* min channels */
195         __le32 channels_max;    /* max channels */
196         __le32 periods_min;     /* min number of periods */
197         __le32 periods_max;     /* max number of periods */
198         __le32 period_size_min; /* min period size bytes */
199         __le32 period_size_max; /* max period size bytes */
200         __le32 buffer_size_min; /* min buffer size bytes */
201         __le32 buffer_size_max; /* max buffer size bytes */
202 } __attribute__((packed));
203
204 /*
205  * FE or BE Stream configuration supported by SW/FW
206  */
207 struct snd_soc_tplg_stream {
208         __le32 size;            /* in bytes of this structure */
209         __le64 format;          /* SNDRV_PCM_FMTBIT_* */
210         __le32 rate;            /* SNDRV_PCM_RATE_* */
211         __le32 period_bytes;    /* size of period in bytes */
212         __le32 buffer_bytes;    /* size of buffer in bytes */
213         __le32 channels;        /* channels */
214         __le32 tdm_slot;        /* optional BE bitmask of supported TDM slots */
215         __le32 dai_fmt;         /* SND_SOC_DAIFMT_  */
216 } __attribute__((packed));
217
218 /*
219  * Duplex stream configuration supported by SW/FW.
220  */
221 struct snd_soc_tplg_stream_config {
222         __le32 size;            /* in bytes of this structure */
223         char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
224         struct snd_soc_tplg_stream playback;
225         struct snd_soc_tplg_stream capture;
226 } __attribute__((packed));
227
228 /*
229  * Manifest. List totals for each payload type. Not used in parsing, but will
230  * be passed to the component driver before any other objects in order for any
231  * global componnent resource allocations.
232  *
233  * File block representation for manifest :-
234  * +-----------------------------------+----+
235  * | struct snd_soc_tplg_hdr           |  1 |
236  * +-----------------------------------+----+
237  * | struct snd_soc_tplg_manifest      |  1 |
238  * +-----------------------------------+----+
239  */
240 struct snd_soc_tplg_manifest {
241         __le32 size;            /* in bytes of this structure */
242         __le32 control_elems;   /* number of control elements */
243         __le32 widget_elems;    /* number of widget elements */
244         __le32 graph_elems;     /* number of graph elements */
245         __le32 dai_elems;       /* number of DAI elements */
246         __le32 dai_link_elems;  /* number of DAI link elements */
247 } __attribute__((packed));
248
249 /*
250  * Mixer kcontrol.
251  *
252  * File block representation for mixer kcontrol :-
253  * +-----------------------------------+----+
254  * | struct snd_soc_tplg_hdr           |  1 |
255  * +-----------------------------------+----+
256  * | struct snd_soc_tplg_mixer_control |  N |
257  * +-----------------------------------+----+
258  */
259 struct snd_soc_tplg_mixer_control {
260         struct snd_soc_tplg_ctl_hdr hdr;
261         __le32 size;    /* in bytes of this structure */
262         __le32 min;
263         __le32 max;
264         __le32 platform_max;
265         __le32 invert;
266         __le32 num_channels;
267         struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
268         struct snd_soc_tplg_ctl_tlv tlv;
269         struct snd_soc_tplg_private priv;
270 } __attribute__((packed));
271
272 /*
273  * Enumerated kcontrol
274  *
275  * File block representation for enum kcontrol :-
276  * +-----------------------------------+----+
277  * | struct snd_soc_tplg_hdr           |  1 |
278  * +-----------------------------------+----+
279  * | struct snd_soc_tplg_enum_control  |  N |
280  * +-----------------------------------+----+
281  */
282 struct snd_soc_tplg_enum_control {
283         struct snd_soc_tplg_ctl_hdr hdr;
284         __le32 size;    /* in bytes of this structure */
285         __le32 num_channels;
286         struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
287         __le32 items;
288         __le32 mask;
289         __le32 count;
290         char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
291         __le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4];
292         struct snd_soc_tplg_private priv;
293 } __attribute__((packed));
294
295 /*
296  * Bytes kcontrol
297  *
298  * File block representation for bytes kcontrol :-
299  * +-----------------------------------+----+
300  * | struct snd_soc_tplg_hdr           |  1 |
301  * +-----------------------------------+----+
302  * | struct snd_soc_tplg_bytes_control |  N |
303  * +-----------------------------------+----+
304  */
305 struct snd_soc_tplg_bytes_control {
306         struct snd_soc_tplg_ctl_hdr hdr;
307         __le32 size;    /* in bytes of this structure */
308         __le32 max;
309         __le32 mask;
310         __le32 base;
311         __le32 num_regs;
312         struct snd_soc_tplg_private priv;
313 } __attribute__((packed));
314
315 /*
316  * DAPM Graph Element
317  *
318  * File block representation for DAPM graph elements :-
319  * +-------------------------------------+----+
320  * | struct snd_soc_tplg_hdr             |  1 |
321  * +-------------------------------------+----+
322  * | struct snd_soc_tplg_dapm_graph_elem |  N |
323  * +-------------------------------------+----+
324  */
325 struct snd_soc_tplg_dapm_graph_elem {
326         char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
327         char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
328         char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
329 } __attribute__((packed));
330
331 /*
332  * DAPM Widget.
333  *
334  * File block representation for DAPM widget :-
335  * +-------------------------------------+-----+
336  * | struct snd_soc_tplg_hdr             |  1  |
337  * +-------------------------------------+-----+
338  * | struct snd_soc_tplg_dapm_widget     |  N  |
339  * +-------------------------------------+-----+
340  * |   struct snd_soc_tplg_enum_control  | 0|1 |
341  * |   struct snd_soc_tplg_mixer_control | 0|N |
342  * +-------------------------------------+-----+
343  *
344  * Optional enum or mixer control can be appended to the end of each widget
345  * in the block.
346  */
347 struct snd_soc_tplg_dapm_widget {
348         __le32 size;            /* in bytes of this structure */
349         __le32 id;              /* SND_SOC_DAPM_CTL */
350         char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
351         char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
352
353         __le32 reg;             /* negative reg = no direct dapm */
354         __le32 shift;           /* bits to shift */
355         __le32 mask;            /* non-shifted mask */
356         __u32 invert;           /* invert the power bit */
357         __u32 ignore_suspend;   /* kept enabled over suspend */
358         __u16 event_flags;
359         __u16 event_type;
360         __u16 num_kcontrols;
361         struct snd_soc_tplg_private priv;
362         /*
363          * kcontrols that relate to this widget
364          * follow here after widget private data
365          */
366 } __attribute__((packed));
367
368 struct snd_soc_tplg_pcm_cfg_caps {
369         struct snd_soc_tplg_stream_caps caps;
370         struct snd_soc_tplg_stream_config configs[SND_SOC_TPLG_STREAM_CONFIG_MAX];
371         __le32 num_configs;     /* number of configs */
372 } __attribute__((packed));
373
374 /*
375  * Describes SW/FW specific features of PCM or DAI link.
376  *
377  * File block representation for PCM/DAI-Link :-
378  * +-----------------------------------+-----+
379  * | struct snd_soc_tplg_hdr           |  1  |
380  * +-----------------------------------+-----+
381  * | struct snd_soc_tplg_dapm_pcm_dai  |  N  |
382  * +-----------------------------------+-----+
383  */
384 struct snd_soc_tplg_pcm_dai {
385         __le32 size;            /* in bytes of this structure */
386         char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
387         __le32 id;                      /* unique ID - used to match */
388         __le32 playback;                /* supports playback mode */
389         __le32 capture;                 /* supports capture mode */
390         __le32 compress;                /* 1 = compressed; 0 = PCM */
391         struct snd_soc_tplg_pcm_cfg_caps capconf[2];    /* capabilities and configs */
392 } __attribute__((packed));
393
394 #endif