OSDN Git Service

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