2 * uapi/sound/asoc.h -- ALSA SoC Firmware Controls and DAPM
4 * Copyright (C) 2012 Texas Instruments Inc.
5 * Copyright (C) 2015 Intel Corporation.
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.
11 * Simple file API to load FW that includes mixers, coefficients, DAPM graphs,
12 * algorithms, equalisers, DAIs, widgets etc.
15 #ifndef __LINUX_UAPI_SND_ASOC_H
16 #define __LINUX_UAPI_SND_ASOC_H
19 * Maximum number of channels topology kcontrol can represent.
21 #define SND_SOC_TPLG_MAX_CHAN 8
24 * Maximum number of PCM formats capability
26 #define SND_SOC_TPLG_MAX_FORMATS 16
29 * Maximum number of PCM stream configs
31 #define SND_SOC_TPLG_STREAM_CONFIG_MAX 8
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
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
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
70 /* Header magic number and string sizes */
71 #define SND_SOC_TPLG_MAGIC 0x41536F43 /* ASoC */
74 #define SND_SOC_TPLG_NUM_TEXTS 16
77 #define SND_SOC_TPLG_ABI_VERSION 0x4
79 /* Max size of TLV data */
80 #define SND_SOC_TPLG_TLV_SIZE 32
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.
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
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
107 #define SND_SOC_TPLG_STREAM_PLAYBACK 0
108 #define SND_SOC_TPLG_STREAM_CAPTURE 1
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
120 * This header precedes all object and object arrays below.
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));
134 /* vendor tuple for uuid */
135 struct snd_soc_tplg_vendor_uuid_elem {
138 } __attribute__((packed));
140 /* vendor tuple for a bool/byte/short/word value */
141 struct snd_soc_tplg_vendor_value_elem {
144 } __attribute__((packed));
146 /* vendor tuple for string */
147 struct snd_soc_tplg_vendor_string_elem {
149 char string[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
150 } __attribute__((packed));
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 */
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];
161 } __attribute__((packed));
165 * All topology objects may have private data that can be used by the driver or
166 * firmware. Core will ignore this data.
168 struct snd_soc_tplg_private {
169 __le32 size; /* in bytes of private data */
172 struct snd_soc_tplg_vendor_array array[0];
174 } __attribute__((packed));
179 struct snd_soc_tplg_tlv_dbscale {
183 } __attribute__((packed));
185 struct snd_soc_tplg_ctl_tlv {
186 __le32 size; /* in bytes of this structure */
187 __le32 type; /* SNDRV_CTL_TLVT_*, type of TLV */
189 __le32 data[SND_SOC_TPLG_TLV_SIZE];
190 struct snd_soc_tplg_tlv_dbscale scale;
192 } __attribute__((packed));
195 * Kcontrol channel data
197 struct snd_soc_tplg_channel {
198 __le32 size; /* in bytes of this structure */
201 __le32 id; /* ID maps to Left, Right, LFE etc */
202 } __attribute__((packed));
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.
209 struct snd_soc_tplg_io_ops {
213 } __attribute__((packed));
218 struct snd_soc_tplg_ctl_hdr {
219 __le32 size; /* in bytes of this structure */
221 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
223 struct snd_soc_tplg_io_ops ops;
224 struct snd_soc_tplg_ctl_tlv tlv;
225 } __attribute__((packed));
228 * Stream Capabilities
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));
248 * FE or BE Stream configuration supported by SW/FW
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));
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.
265 * File block representation for manifest :-
266 * +-----------------------------------+----+
267 * | struct snd_soc_tplg_hdr | 1 |
268 * +-----------------------------------+----+
269 * | struct snd_soc_tplg_manifest | 1 |
270 * +-----------------------------------+----+
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));
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 * +-----------------------------------+----+
292 struct snd_soc_tplg_mixer_control {
293 struct snd_soc_tplg_ctl_hdr hdr;
294 __le32 size; /* in bytes of this structure */
300 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
301 struct snd_soc_tplg_private priv;
302 } __attribute__((packed));
305 * Enumerated kcontrol
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 * +-----------------------------------+----+
314 struct snd_soc_tplg_enum_control {
315 struct snd_soc_tplg_ctl_hdr hdr;
316 __le32 size; /* in bytes of this structure */
318 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
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));
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 * +-----------------------------------+----+
337 struct snd_soc_tplg_bytes_control {
338 struct snd_soc_tplg_ctl_hdr hdr;
339 __le32 size; /* in bytes of this structure */
344 struct snd_soc_tplg_io_ops ext_ops;
345 struct snd_soc_tplg_private priv;
346 } __attribute__((packed));
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 * +-------------------------------------+----+
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));
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 * +-------------------------------------+-----+
377 * Optional enum or mixer control can be appended to the end of each widget
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];
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 */
394 __le32 num_kcontrols;
395 struct snd_soc_tplg_private priv;
397 * kcontrols that relate to this widget
398 * follow here after widget private data
400 } __attribute__((packed));
404 * Describes SW/FW specific features of PCM (FE DAI & DAI link).
406 * File block representation for PCM :-
407 * +-----------------------------------+-----+
408 * | struct snd_soc_tplg_hdr | 1 |
409 * +-----------------------------------+-----+
410 * | struct snd_soc_tplg_pcm | N |
411 * +-----------------------------------+-----+
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));
429 * Describes the BE or CC link runtime supported configs or params
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 * +-----------------------------------+-----+
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));