OSDN Git Service

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