HID: Add new force feedback driver for Mayflash game controller adapters
[sfrench/cifs-2.6.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        0x5
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_BACKEND_LINK  10
107 #define SND_SOC_TPLG_TYPE_PDATA         11
108 #define SND_SOC_TPLG_TYPE_BE_DAI        12
109 #define SND_SOC_TPLG_TYPE_MAX           SND_SOC_TPLG_TYPE_BE_DAI
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
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
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
133 /*
134  * Block Header.
135  * This header precedes all object and object arrays below.
136  */
137 struct 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
149 /* vendor tuple for uuid */
150 struct 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 */
156 struct snd_soc_tplg_vendor_value_elem {
157         __le32 token;
158         __le32 value;
159 } __attribute__((packed));
160
161 /* vendor tuple for string */
162 struct snd_soc_tplg_vendor_string_elem {
163         __le32 token;
164         char string[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
165 } __attribute__((packed));
166
167 struct 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
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  */
183 struct snd_soc_tplg_private {
184         __le32 size;    /* in bytes of private data */
185         union {
186                 char data[0];
187                 struct snd_soc_tplg_vendor_array array[0];
188         };
189 } __attribute__((packed));
190
191 /*
192  * Kcontrol TLV data.
193  */
194 struct snd_soc_tplg_tlv_dbscale {
195         __le32 min;
196         __le32 step;
197         __le32 mute;
198 } __attribute__((packed));
199
200 struct snd_soc_tplg_ctl_tlv {
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         };
207 } __attribute__((packed));
208
209 /*
210  * Kcontrol channel data
211  */
212 struct 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 /*
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.
223  */
224 struct snd_soc_tplg_io_ops {
225         __le32 get;
226         __le32 put;
227         __le32 info;
228 } __attribute__((packed));
229
230 /*
231  * kcontrol header
232  */
233 struct 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;
238         struct snd_soc_tplg_io_ops ops;
239         struct snd_soc_tplg_ctl_tlv tlv;
240 } __attribute__((packed));
241
242 /*
243  * Stream Capabilities
244  */
245 struct snd_soc_tplg_stream_caps {
246         __le32 size;            /* in bytes of this structure */
247         char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
248         __le64 formats; /* supported formats SNDRV_PCM_FMTBIT_* */
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 */
260         __le32 sig_bits;        /* number of bits of content */
261 } __attribute__((packed));
262
263 /*
264  * FE or BE Stream configuration supported by SW/FW
265  */
266 struct snd_soc_tplg_stream {
267         __le32 size;            /* in bytes of this structure */
268         char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* Name of the stream */
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 */
274 } __attribute__((packed));
275
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
279  * global component resource allocations.
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  */
288 struct 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 */
293         __le32 pcm_elems;       /* number of PCM elements */
294         __le32 dai_link_elems;  /* number of DAI link elements */
295         __le32 be_dai_elems;    /* number of BE DAI elements */
296         __le32 reserved[20];    /* reserved for new ABI element types */
297         struct snd_soc_tplg_private priv;
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  */
310 struct 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];
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  */
332 struct 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  */
355 struct 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;
362         struct snd_soc_tplg_io_ops ext_ops;
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  */
376 struct 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  */
398 struct 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 */
407         __le32 subseq;          /* sort within widget type */
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;
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
420
421 /*
422  * Describes SW/FW specific features of PCM (FE DAI & DAI link).
423  *
424  * File block representation for PCM :-
425  * +-----------------------------------+-----+
426  * | struct snd_soc_tplg_hdr           |  1  |
427  * +-----------------------------------+-----+
428  * | struct snd_soc_tplg_pcm           |  N  |
429  * +-----------------------------------+-----+
430  */
431 struct snd_soc_tplg_pcm {
432         __le32 size;            /* in bytes of this structure */
433         char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
434         char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
435         __le32 pcm_id;          /* unique ID - used to match with DAI link */
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 */
443 } __attribute__((packed));
444
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  */
456 struct 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));
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  */
473 struct 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));
484 #endif