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
18 #include <linux/types.h>
19 #include <sound/asound.h>
22 * Maximum number of channels topology kcontrol can represent.
24 #define SND_SOC_TPLG_MAX_CHAN 8
27 * Maximum number of PCM formats capability
29 #define SND_SOC_TPLG_MAX_FORMATS 16
32 * Maximum number of PCM stream configs
34 #define SND_SOC_TPLG_STREAM_CONFIG_MAX 8
37 * Maximum number of physical link's hardware configs
39 #define SND_SOC_TPLG_HW_CONFIG_MAX 8
41 /* individual kcontrol info types - can be mixed with other types */
42 #define SND_SOC_TPLG_CTL_VOLSW 1
43 #define SND_SOC_TPLG_CTL_VOLSW_SX 2
44 #define SND_SOC_TPLG_CTL_VOLSW_XR_SX 3
45 #define SND_SOC_TPLG_CTL_ENUM 4
46 #define SND_SOC_TPLG_CTL_BYTES 5
47 #define SND_SOC_TPLG_CTL_ENUM_VALUE 6
48 #define SND_SOC_TPLG_CTL_RANGE 7
49 #define SND_SOC_TPLG_CTL_STROBE 8
52 /* individual widget kcontrol info types - can be mixed with other types */
53 #define SND_SOC_TPLG_DAPM_CTL_VOLSW 64
54 #define SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE 65
55 #define SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT 66
56 #define SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE 67
57 #define SND_SOC_TPLG_DAPM_CTL_PIN 68
59 /* DAPM widget types - add new items to the end */
60 #define SND_SOC_TPLG_DAPM_INPUT 0
61 #define SND_SOC_TPLG_DAPM_OUTPUT 1
62 #define SND_SOC_TPLG_DAPM_MUX 2
63 #define SND_SOC_TPLG_DAPM_MIXER 3
64 #define SND_SOC_TPLG_DAPM_PGA 4
65 #define SND_SOC_TPLG_DAPM_OUT_DRV 5
66 #define SND_SOC_TPLG_DAPM_ADC 6
67 #define SND_SOC_TPLG_DAPM_DAC 7
68 #define SND_SOC_TPLG_DAPM_SWITCH 8
69 #define SND_SOC_TPLG_DAPM_PRE 9
70 #define SND_SOC_TPLG_DAPM_POST 10
71 #define SND_SOC_TPLG_DAPM_AIF_IN 11
72 #define SND_SOC_TPLG_DAPM_AIF_OUT 12
73 #define SND_SOC_TPLG_DAPM_DAI_IN 13
74 #define SND_SOC_TPLG_DAPM_DAI_OUT 14
75 #define SND_SOC_TPLG_DAPM_DAI_LINK 15
76 #define SND_SOC_TPLG_DAPM_BUFFER 16
77 #define SND_SOC_TPLG_DAPM_SCHEDULER 17
78 #define SND_SOC_TPLG_DAPM_EFFECT 18
79 #define SND_SOC_TPLG_DAPM_SIGGEN 19
80 #define SND_SOC_TPLG_DAPM_SRC 20
81 #define SND_SOC_TPLG_DAPM_ASRC 21
82 #define SND_SOC_TPLG_DAPM_ENCODER 22
83 #define SND_SOC_TPLG_DAPM_DECODER 23
84 #define SND_SOC_TPLG_DAPM_LAST SND_SOC_TPLG_DAPM_DECODER
86 /* Header magic number and string sizes */
87 #define SND_SOC_TPLG_MAGIC 0x41536F43 /* ASoC */
90 #define SND_SOC_TPLG_NUM_TEXTS 16
93 #define SND_SOC_TPLG_ABI_VERSION 0x5 /* current version */
94 #define SND_SOC_TPLG_ABI_VERSION_MIN 0x4 /* oldest version supported */
96 /* Max size of TLV data */
97 #define SND_SOC_TPLG_TLV_SIZE 32
100 * File and Block header data types.
101 * Add new generic and vendor types to end of list.
102 * Generic types are handled by the core whilst vendors types are passed
103 * to the component drivers for handling.
105 #define SND_SOC_TPLG_TYPE_MIXER 1
106 #define SND_SOC_TPLG_TYPE_BYTES 2
107 #define SND_SOC_TPLG_TYPE_ENUM 3
108 #define SND_SOC_TPLG_TYPE_DAPM_GRAPH 4
109 #define SND_SOC_TPLG_TYPE_DAPM_WIDGET 5
110 #define SND_SOC_TPLG_TYPE_DAI_LINK 6
111 #define SND_SOC_TPLG_TYPE_PCM 7
112 #define SND_SOC_TPLG_TYPE_MANIFEST 8
113 #define SND_SOC_TPLG_TYPE_CODEC_LINK 9
114 #define SND_SOC_TPLG_TYPE_BACKEND_LINK 10
115 #define SND_SOC_TPLG_TYPE_PDATA 11
116 #define SND_SOC_TPLG_TYPE_DAI 12
117 #define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_DAI
119 /* vendor block IDs - please add new vendor types to end */
120 #define SND_SOC_TPLG_TYPE_VENDOR_FW 1000
121 #define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001
122 #define SND_SOC_TPLG_TYPE_VENDOR_COEFF 1002
123 #define SND_SOC_TPLG_TYPEVENDOR_CODEC 1003
125 #define SND_SOC_TPLG_STREAM_PLAYBACK 0
126 #define SND_SOC_TPLG_STREAM_CAPTURE 1
128 /* vendor tuple types */
129 #define SND_SOC_TPLG_TUPLE_TYPE_UUID 0
130 #define SND_SOC_TPLG_TUPLE_TYPE_STRING 1
131 #define SND_SOC_TPLG_TUPLE_TYPE_BOOL 2
132 #define SND_SOC_TPLG_TUPLE_TYPE_BYTE 3
133 #define SND_SOC_TPLG_TUPLE_TYPE_WORD 4
134 #define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5
137 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_RATES (1 << 0)
138 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS (1 << 1)
139 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2)
141 /* DAI physical PCM data formats.
142 * Add new formats to the end of the list.
144 #define SND_SOC_DAI_FORMAT_I2S 1 /* I2S mode */
145 #define SND_SOC_DAI_FORMAT_RIGHT_J 2 /* Right Justified mode */
146 #define SND_SOC_DAI_FORMAT_LEFT_J 3 /* Left Justified mode */
147 #define SND_SOC_DAI_FORMAT_DSP_A 4 /* L data MSB after FRM LRC */
148 #define SND_SOC_DAI_FORMAT_DSP_B 5 /* L data MSB during FRM LRC */
149 #define SND_SOC_DAI_FORMAT_AC97 6 /* AC97 */
150 #define SND_SOC_DAI_FORMAT_PDM 7 /* Pulse density modulation */
152 /* left and right justified also known as MSB and LSB respectively */
153 #define SND_SOC_DAI_FORMAT_MSB SND_SOC_DAI_FORMAT_LEFT_J
154 #define SND_SOC_DAI_FORMAT_LSB SND_SOC_DAI_FORMAT_RIGHT_J
157 #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES (1 << 0)
158 #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS (1 << 1)
159 #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2)
160 #define SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP (1 << 3)
164 * This header precedes all object and object arrays below.
166 struct snd_soc_tplg_hdr
{
167 __le32 magic
; /* magic number */
168 __le32 abi
; /* ABI version */
169 __le32 version
; /* optional vendor specific version details */
170 __le32 type
; /* SND_SOC_TPLG_TYPE_ */
171 __le32 size
; /* size of this structure */
172 __le32 vendor_type
; /* optional vendor specific type info */
173 __le32 payload_size
; /* data bytes, excluding this header */
174 __le32 index
; /* identifier for block */
175 __le32 count
; /* number of elements in block */
176 } __attribute__((packed
));
178 /* vendor tuple for uuid */
179 struct snd_soc_tplg_vendor_uuid_elem
{
182 } __attribute__((packed
));
184 /* vendor tuple for a bool/byte/short/word value */
185 struct snd_soc_tplg_vendor_value_elem
{
188 } __attribute__((packed
));
190 /* vendor tuple for string */
191 struct snd_soc_tplg_vendor_string_elem
{
193 char string
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
194 } __attribute__((packed
));
196 struct snd_soc_tplg_vendor_array
{
197 __le32 size
; /* size in bytes of the array, including all elements */
198 __le32 type
; /* SND_SOC_TPLG_TUPLE_TYPE_ */
199 __le32 num_elems
; /* number of elements in array */
201 struct snd_soc_tplg_vendor_uuid_elem uuid
[0];
202 struct snd_soc_tplg_vendor_value_elem value
[0];
203 struct snd_soc_tplg_vendor_string_elem string
[0];
205 } __attribute__((packed
));
209 * All topology objects may have private data that can be used by the driver or
210 * firmware. Core will ignore this data.
212 struct snd_soc_tplg_private
{
213 __le32 size
; /* in bytes of private data */
216 struct snd_soc_tplg_vendor_array array
[0];
218 } __attribute__((packed
));
223 struct snd_soc_tplg_tlv_dbscale
{
227 } __attribute__((packed
));
229 struct snd_soc_tplg_ctl_tlv
{
230 __le32 size
; /* in bytes of this structure */
231 __le32 type
; /* SNDRV_CTL_TLVT_*, type of TLV */
233 __le32 data
[SND_SOC_TPLG_TLV_SIZE
];
234 struct snd_soc_tplg_tlv_dbscale scale
;
236 } __attribute__((packed
));
239 * Kcontrol channel data
241 struct snd_soc_tplg_channel
{
242 __le32 size
; /* in bytes of this structure */
245 __le32 id
; /* ID maps to Left, Right, LFE etc */
246 } __attribute__((packed
));
249 * Genericl Operations IDs, for binding Kcontrol or Bytes ext ops
250 * Kcontrol ops need get/put/info.
251 * Bytes ext ops need get/put.
253 struct snd_soc_tplg_io_ops
{
257 } __attribute__((packed
));
262 struct snd_soc_tplg_ctl_hdr
{
263 __le32 size
; /* in bytes of this structure */
265 char name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
267 struct snd_soc_tplg_io_ops ops
;
268 struct snd_soc_tplg_ctl_tlv tlv
;
269 } __attribute__((packed
));
272 * Stream Capabilities
274 struct snd_soc_tplg_stream_caps
{
275 __le32 size
; /* in bytes of this structure */
276 char name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
277 __le64 formats
; /* supported formats SNDRV_PCM_FMTBIT_* */
278 __le32 rates
; /* supported rates SNDRV_PCM_RATE_* */
279 __le32 rate_min
; /* min rate */
280 __le32 rate_max
; /* max rate */
281 __le32 channels_min
; /* min channels */
282 __le32 channels_max
; /* max channels */
283 __le32 periods_min
; /* min number of periods */
284 __le32 periods_max
; /* max number of periods */
285 __le32 period_size_min
; /* min period size bytes */
286 __le32 period_size_max
; /* max period size bytes */
287 __le32 buffer_size_min
; /* min buffer size bytes */
288 __le32 buffer_size_max
; /* max buffer size bytes */
289 __le32 sig_bits
; /* number of bits of content */
290 } __attribute__((packed
));
293 * FE or BE Stream configuration supported by SW/FW
295 struct snd_soc_tplg_stream
{
296 __le32 size
; /* in bytes of this structure */
297 char name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
]; /* Name of the stream */
298 __le64 format
; /* SNDRV_PCM_FMTBIT_* */
299 __le32 rate
; /* SNDRV_PCM_RATE_* */
300 __le32 period_bytes
; /* size of period in bytes */
301 __le32 buffer_bytes
; /* size of buffer in bytes */
302 __le32 channels
; /* channels */
303 } __attribute__((packed
));
307 * Describes a physical link's runtime supported hardware config,
308 * i.e. hardware audio formats.
310 struct snd_soc_tplg_hw_config
{
311 __le32 size
; /* in bytes of this structure */
312 __le32 id
; /* unique ID - - used to match */
313 __le32 fmt
; /* SND_SOC_DAI_FORMAT_ format value */
314 __u8 clock_gated
; /* 1 if clock can be gated to save power */
315 __u8 invert_bclk
; /* 1 for inverted BCLK, 0 for normal */
316 __u8 invert_fsync
; /* 1 for inverted frame clock, 0 for normal */
317 __u8 bclk_master
; /* 1 for master of BCLK, 0 for slave */
318 __u8 fsync_master
; /* 1 for master of FSYNC, 0 for slave */
319 __u8 mclk_direction
; /* 0 for input, 1 for output */
320 __le16 reserved
; /* for 32bit alignment */
321 __le32 mclk_rate
; /* MCLK or SYSCLK freqency in Hz */
322 __le32 bclk_rate
; /* BCLK freqency in Hz */
323 __le32 fsync_rate
; /* frame clock in Hz */
324 __le32 tdm_slots
; /* number of TDM slots in use */
325 __le32 tdm_slot_width
; /* width in bits for each slot */
326 __le32 tx_slots
; /* bit mask for active Tx slots */
327 __le32 rx_slots
; /* bit mask for active Rx slots */
328 __le32 tx_channels
; /* number of Tx channels */
329 __le32 tx_chanmap
[SND_SOC_TPLG_MAX_CHAN
]; /* array of slot number */
330 __le32 rx_channels
; /* number of Rx channels */
331 __le32 rx_chanmap
[SND_SOC_TPLG_MAX_CHAN
]; /* array of slot number */
332 } __attribute__((packed
));
335 * Manifest. List totals for each payload type. Not used in parsing, but will
336 * be passed to the component driver before any other objects in order for any
337 * global component resource allocations.
339 * File block representation for manifest :-
340 * +-----------------------------------+----+
341 * | struct snd_soc_tplg_hdr | 1 |
342 * +-----------------------------------+----+
343 * | struct snd_soc_tplg_manifest | 1 |
344 * +-----------------------------------+----+
346 struct snd_soc_tplg_manifest
{
347 __le32 size
; /* in bytes of this structure */
348 __le32 control_elems
; /* number of control elements */
349 __le32 widget_elems
; /* number of widget elements */
350 __le32 graph_elems
; /* number of graph elements */
351 __le32 pcm_elems
; /* number of PCM elements */
352 __le32 dai_link_elems
; /* number of DAI link elements */
353 __le32 dai_elems
; /* number of physical DAI elements */
354 __le32 reserved
[20]; /* reserved for new ABI element types */
355 struct snd_soc_tplg_private priv
;
356 } __attribute__((packed
));
361 * File block representation for mixer kcontrol :-
362 * +-----------------------------------+----+
363 * | struct snd_soc_tplg_hdr | 1 |
364 * +-----------------------------------+----+
365 * | struct snd_soc_tplg_mixer_control | N |
366 * +-----------------------------------+----+
368 struct snd_soc_tplg_mixer_control
{
369 struct snd_soc_tplg_ctl_hdr hdr
;
370 __le32 size
; /* in bytes of this structure */
376 struct snd_soc_tplg_channel channel
[SND_SOC_TPLG_MAX_CHAN
];
377 struct snd_soc_tplg_private priv
;
378 } __attribute__((packed
));
381 * Enumerated kcontrol
383 * File block representation for enum kcontrol :-
384 * +-----------------------------------+----+
385 * | struct snd_soc_tplg_hdr | 1 |
386 * +-----------------------------------+----+
387 * | struct snd_soc_tplg_enum_control | N |
388 * +-----------------------------------+----+
390 struct snd_soc_tplg_enum_control
{
391 struct snd_soc_tplg_ctl_hdr hdr
;
392 __le32 size
; /* in bytes of this structure */
394 struct snd_soc_tplg_channel channel
[SND_SOC_TPLG_MAX_CHAN
];
398 char texts
[SND_SOC_TPLG_NUM_TEXTS
][SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
399 __le32 values
[SND_SOC_TPLG_NUM_TEXTS
* SNDRV_CTL_ELEM_ID_NAME_MAXLEN
/ 4];
400 struct snd_soc_tplg_private priv
;
401 } __attribute__((packed
));
406 * File block representation for bytes kcontrol :-
407 * +-----------------------------------+----+
408 * | struct snd_soc_tplg_hdr | 1 |
409 * +-----------------------------------+----+
410 * | struct snd_soc_tplg_bytes_control | N |
411 * +-----------------------------------+----+
413 struct snd_soc_tplg_bytes_control
{
414 struct snd_soc_tplg_ctl_hdr hdr
;
415 __le32 size
; /* in bytes of this structure */
420 struct snd_soc_tplg_io_ops ext_ops
;
421 struct snd_soc_tplg_private priv
;
422 } __attribute__((packed
));
427 * File block representation for DAPM graph elements :-
428 * +-------------------------------------+----+
429 * | struct snd_soc_tplg_hdr | 1 |
430 * +-------------------------------------+----+
431 * | struct snd_soc_tplg_dapm_graph_elem | N |
432 * +-------------------------------------+----+
434 struct snd_soc_tplg_dapm_graph_elem
{
435 char sink
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
436 char control
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
437 char source
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
438 } __attribute__((packed
));
443 * File block representation for DAPM widget :-
444 * +-------------------------------------+-----+
445 * | struct snd_soc_tplg_hdr | 1 |
446 * +-------------------------------------+-----+
447 * | struct snd_soc_tplg_dapm_widget | N |
448 * +-------------------------------------+-----+
449 * | struct snd_soc_tplg_enum_control | 0|1 |
450 * | struct snd_soc_tplg_mixer_control | 0|N |
451 * +-------------------------------------+-----+
453 * Optional enum or mixer control can be appended to the end of each widget
456 struct snd_soc_tplg_dapm_widget
{
457 __le32 size
; /* in bytes of this structure */
458 __le32 id
; /* SND_SOC_DAPM_CTL */
459 char name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
460 char sname
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
462 __le32 reg
; /* negative reg = no direct dapm */
463 __le32 shift
; /* bits to shift */
464 __le32 mask
; /* non-shifted mask */
465 __le32 subseq
; /* sort within widget type */
466 __le32 invert
; /* invert the power bit */
467 __le32 ignore_suspend
; /* kept enabled over suspend */
470 __le32 num_kcontrols
;
471 struct snd_soc_tplg_private priv
;
473 * kcontrols that relate to this widget
474 * follow here after widget private data
476 } __attribute__((packed
));
480 * Describes SW/FW specific features of PCM (FE DAI & DAI link).
482 * File block representation for PCM :-
483 * +-----------------------------------+-----+
484 * | struct snd_soc_tplg_hdr | 1 |
485 * +-----------------------------------+-----+
486 * | struct snd_soc_tplg_pcm | N |
487 * +-----------------------------------+-----+
489 struct snd_soc_tplg_pcm
{
490 __le32 size
; /* in bytes of this structure */
491 char pcm_name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
492 char dai_name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
493 __le32 pcm_id
; /* unique ID - used to match with DAI link */
494 __le32 dai_id
; /* unique ID - used to match */
495 __le32 playback
; /* supports playback mode */
496 __le32 capture
; /* supports capture mode */
497 __le32 compress
; /* 1 = compressed; 0 = PCM */
498 struct snd_soc_tplg_stream stream
[SND_SOC_TPLG_STREAM_CONFIG_MAX
]; /* for DAI link */
499 __le32 num_streams
; /* number of streams */
500 struct snd_soc_tplg_stream_caps caps
[2]; /* playback and capture for DAI */
501 __le32 flag_mask
; /* bitmask of flags to configure */
502 __le32 flags
; /* SND_SOC_TPLG_LNK_FLGBIT_* flag value */
503 struct snd_soc_tplg_private priv
;
504 } __attribute__((packed
));
508 * Describes the physical link runtime supported configs or params
510 * File block representation for physical link config :-
511 * +-----------------------------------+-----+
512 * | struct snd_soc_tplg_hdr | 1 |
513 * +-----------------------------------+-----+
514 * | struct snd_soc_tplg_link_config | N |
515 * +-----------------------------------+-----+
517 struct snd_soc_tplg_link_config
{
518 __le32 size
; /* in bytes of this structure */
519 __le32 id
; /* unique ID - used to match */
520 char name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
]; /* name - used to match */
521 char stream_name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
]; /* stream name - used to match */
522 struct snd_soc_tplg_stream stream
[SND_SOC_TPLG_STREAM_CONFIG_MAX
]; /* supported configs playback and captrure */
523 __le32 num_streams
; /* number of streams */
524 struct snd_soc_tplg_hw_config hw_config
[SND_SOC_TPLG_HW_CONFIG_MAX
]; /* hw configs */
525 __le32 num_hw_configs
; /* number of hw configs */
526 __le32 default_hw_config_id
; /* default hw config ID for init */
527 __le32 flag_mask
; /* bitmask of flags to configure */
528 __le32 flags
; /* SND_SOC_TPLG_LNK_FLGBIT_* flag value */
529 struct snd_soc_tplg_private priv
;
530 } __attribute__((packed
));
533 * Describes SW/FW specific features of physical DAI.
534 * It can be used to configure backend DAIs for DPCM.
536 * File block representation for physical DAI :-
537 * +-----------------------------------+-----+
538 * | struct snd_soc_tplg_hdr | 1 |
539 * +-----------------------------------+-----+
540 * | struct snd_soc_tplg_dai | N |
541 * +-----------------------------------+-----+
543 struct snd_soc_tplg_dai
{
544 __le32 size
; /* in bytes of this structure */
545 char dai_name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
]; /* name - used to match */
546 __le32 dai_id
; /* unique ID - used to match */
547 __le32 playback
; /* supports playback mode */
548 __le32 capture
; /* supports capture mode */
549 struct snd_soc_tplg_stream_caps caps
[2]; /* playback and capture for DAI */
550 __le32 flag_mask
; /* bitmask of flags to configure */
551 __le32 flags
; /* SND_SOC_TPLG_DAI_FLGBIT_* */
552 struct snd_soc_tplg_private priv
;
553 } __attribute__((packed
));