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 #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.
28 * Maximum number of channels topology kcontrol can represent.
30 #define SND_SOC_TPLG_MAX_CHAN 8
33 * Maximum number of PCM formats capability
35 #define SND_SOC_TPLG_MAX_FORMATS 16
38 * Maximum number of PCM stream configs
40 #define SND_SOC_TPLG_STREAM_CONFIG_MAX 8
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
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
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
79 /* Header magic number and string sizes */
80 #define SND_SOC_TPLG_MAGIC 0x41536F43 /* ASoC */
83 #define SND_SOC_TPLG_NUM_TEXTS 16
86 #define SND_SOC_TPLG_ABI_VERSION 0x4
88 /* Max size of TLV data */
89 #define SND_SOC_TPLG_TLV_SIZE 32
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.
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_MAX SND_SOC_TPLG_TYPE_PDATA
110 /* vendor block IDs - please add new vendor types to end */
111 #define SND_SOC_TPLG_TYPE_VENDOR_FW 1000
112 #define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001
113 #define SND_SOC_TPLG_TYPE_VENDOR_COEFF 1002
114 #define SND_SOC_TPLG_TYPEVENDOR_CODEC 1003
116 #define SND_SOC_TPLG_STREAM_PLAYBACK 0
117 #define SND_SOC_TPLG_STREAM_CAPTURE 1
121 * This header precedes all object and object arrays below.
123 struct snd_soc_tplg_hdr
{
124 __le32 magic
; /* magic number */
125 __le32 abi
; /* ABI version */
126 __le32 version
; /* optional vendor specific version details */
127 __le32 type
; /* SND_SOC_TPLG_TYPE_ */
128 __le32 size
; /* size of this structure */
129 __le32 vendor_type
; /* optional vendor specific type info */
130 __le32 payload_size
; /* data bytes, excluding this header */
131 __le32 index
; /* identifier for block */
132 __le32 count
; /* number of elements in block */
133 } __attribute__((packed
));
137 * All topology objects may have private data that can be used by the driver or
138 * firmware. Core will ignore this data.
140 struct snd_soc_tplg_private
{
141 __le32 size
; /* in bytes of private data */
143 } __attribute__((packed
));
148 struct snd_soc_tplg_tlv_dbscale
{
152 } __attribute__((packed
));
154 struct snd_soc_tplg_ctl_tlv
{
155 __le32 size
; /* in bytes of this structure */
156 __le32 type
; /* SNDRV_CTL_TLVT_*, type of TLV */
158 __le32 data
[SND_SOC_TPLG_TLV_SIZE
];
159 struct snd_soc_tplg_tlv_dbscale scale
;
161 } __attribute__((packed
));
164 * Kcontrol channel data
166 struct snd_soc_tplg_channel
{
167 __le32 size
; /* in bytes of this structure */
170 __le32 id
; /* ID maps to Left, Right, LFE etc */
171 } __attribute__((packed
));
174 * Genericl Operations IDs, for binding Kcontrol or Bytes ext ops
175 * Kcontrol ops need get/put/info.
176 * Bytes ext ops need get/put.
178 struct snd_soc_tplg_io_ops
{
182 } __attribute__((packed
));
187 struct snd_soc_tplg_ctl_hdr
{
188 __le32 size
; /* in bytes of this structure */
190 char name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
192 struct snd_soc_tplg_io_ops ops
;
193 struct snd_soc_tplg_ctl_tlv tlv
;
194 } __attribute__((packed
));
197 * Stream Capabilities
199 struct snd_soc_tplg_stream_caps
{
200 __le32 size
; /* in bytes of this structure */
201 char name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
202 __le64 formats
; /* supported formats SNDRV_PCM_FMTBIT_* */
203 __le32 rates
; /* supported rates SNDRV_PCM_RATE_* */
204 __le32 rate_min
; /* min rate */
205 __le32 rate_max
; /* max rate */
206 __le32 channels_min
; /* min channels */
207 __le32 channels_max
; /* max channels */
208 __le32 periods_min
; /* min number of periods */
209 __le32 periods_max
; /* max number of periods */
210 __le32 period_size_min
; /* min period size bytes */
211 __le32 period_size_max
; /* max period size bytes */
212 __le32 buffer_size_min
; /* min buffer size bytes */
213 __le32 buffer_size_max
; /* max buffer size bytes */
214 } __attribute__((packed
));
217 * FE or BE Stream configuration supported by SW/FW
219 struct snd_soc_tplg_stream
{
220 __le32 size
; /* in bytes of this structure */
221 char name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
]; /* Name of the stream */
222 __le64 format
; /* SNDRV_PCM_FMTBIT_* */
223 __le32 rate
; /* SNDRV_PCM_RATE_* */
224 __le32 period_bytes
; /* size of period in bytes */
225 __le32 buffer_bytes
; /* size of buffer in bytes */
226 __le32 channels
; /* channels */
227 } __attribute__((packed
));
230 * Manifest. List totals for each payload type. Not used in parsing, but will
231 * be passed to the component driver before any other objects in order for any
232 * global component resource allocations.
234 * File block representation for manifest :-
235 * +-----------------------------------+----+
236 * | struct snd_soc_tplg_hdr | 1 |
237 * +-----------------------------------+----+
238 * | struct snd_soc_tplg_manifest | 1 |
239 * +-----------------------------------+----+
241 struct snd_soc_tplg_manifest
{
242 __le32 size
; /* in bytes of this structure */
243 __le32 control_elems
; /* number of control elements */
244 __le32 widget_elems
; /* number of widget elements */
245 __le32 graph_elems
; /* number of graph elements */
246 __le32 pcm_elems
; /* number of PCM elements */
247 __le32 dai_link_elems
; /* number of DAI link elements */
248 struct snd_soc_tplg_private priv
;
249 } __attribute__((packed
));
254 * File block representation for mixer kcontrol :-
255 * +-----------------------------------+----+
256 * | struct snd_soc_tplg_hdr | 1 |
257 * +-----------------------------------+----+
258 * | struct snd_soc_tplg_mixer_control | N |
259 * +-----------------------------------+----+
261 struct snd_soc_tplg_mixer_control
{
262 struct snd_soc_tplg_ctl_hdr hdr
;
263 __le32 size
; /* in bytes of this structure */
269 struct snd_soc_tplg_channel channel
[SND_SOC_TPLG_MAX_CHAN
];
270 struct snd_soc_tplg_private priv
;
271 } __attribute__((packed
));
274 * Enumerated kcontrol
276 * File block representation for enum kcontrol :-
277 * +-----------------------------------+----+
278 * | struct snd_soc_tplg_hdr | 1 |
279 * +-----------------------------------+----+
280 * | struct snd_soc_tplg_enum_control | N |
281 * +-----------------------------------+----+
283 struct snd_soc_tplg_enum_control
{
284 struct snd_soc_tplg_ctl_hdr hdr
;
285 __le32 size
; /* in bytes of this structure */
287 struct snd_soc_tplg_channel channel
[SND_SOC_TPLG_MAX_CHAN
];
291 char texts
[SND_SOC_TPLG_NUM_TEXTS
][SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
292 __le32 values
[SND_SOC_TPLG_NUM_TEXTS
* SNDRV_CTL_ELEM_ID_NAME_MAXLEN
/ 4];
293 struct snd_soc_tplg_private priv
;
294 } __attribute__((packed
));
299 * File block representation for bytes kcontrol :-
300 * +-----------------------------------+----+
301 * | struct snd_soc_tplg_hdr | 1 |
302 * +-----------------------------------+----+
303 * | struct snd_soc_tplg_bytes_control | N |
304 * +-----------------------------------+----+
306 struct snd_soc_tplg_bytes_control
{
307 struct snd_soc_tplg_ctl_hdr hdr
;
308 __le32 size
; /* in bytes of this structure */
313 struct snd_soc_tplg_io_ops ext_ops
;
314 struct snd_soc_tplg_private priv
;
315 } __attribute__((packed
));
320 * File block representation for DAPM graph elements :-
321 * +-------------------------------------+----+
322 * | struct snd_soc_tplg_hdr | 1 |
323 * +-------------------------------------+----+
324 * | struct snd_soc_tplg_dapm_graph_elem | N |
325 * +-------------------------------------+----+
327 struct snd_soc_tplg_dapm_graph_elem
{
328 char sink
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
329 char control
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
330 char source
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
331 } __attribute__((packed
));
336 * File block representation for DAPM widget :-
337 * +-------------------------------------+-----+
338 * | struct snd_soc_tplg_hdr | 1 |
339 * +-------------------------------------+-----+
340 * | struct snd_soc_tplg_dapm_widget | N |
341 * +-------------------------------------+-----+
342 * | struct snd_soc_tplg_enum_control | 0|1 |
343 * | struct snd_soc_tplg_mixer_control | 0|N |
344 * +-------------------------------------+-----+
346 * Optional enum or mixer control can be appended to the end of each widget
349 struct snd_soc_tplg_dapm_widget
{
350 __le32 size
; /* in bytes of this structure */
351 __le32 id
; /* SND_SOC_DAPM_CTL */
352 char name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
353 char sname
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
355 __le32 reg
; /* negative reg = no direct dapm */
356 __le32 shift
; /* bits to shift */
357 __le32 mask
; /* non-shifted mask */
358 __le32 subseq
; /* sort within widget type */
359 __le32 invert
; /* invert the power bit */
360 __le32 ignore_suspend
; /* kept enabled over suspend */
363 __le32 num_kcontrols
;
364 struct snd_soc_tplg_private priv
;
366 * kcontrols that relate to this widget
367 * follow here after widget private data
369 } __attribute__((packed
));
373 * Describes SW/FW specific features of PCM (FE DAI & DAI link).
375 * File block representation for PCM :-
376 * +-----------------------------------+-----+
377 * | struct snd_soc_tplg_hdr | 1 |
378 * +-----------------------------------+-----+
379 * | struct snd_soc_tplg_pcm | N |
380 * +-----------------------------------+-----+
382 struct snd_soc_tplg_pcm
{
383 __le32 size
; /* in bytes of this structure */
384 char pcm_name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
385 char dai_name
[SNDRV_CTL_ELEM_ID_NAME_MAXLEN
];
386 __le32 pcm_id
; /* unique ID - used to match */
387 __le32 dai_id
; /* unique ID - used to match */
388 __le32 playback
; /* supports playback mode */
389 __le32 capture
; /* supports capture mode */
390 __le32 compress
; /* 1 = compressed; 0 = PCM */
391 struct snd_soc_tplg_stream stream
[SND_SOC_TPLG_STREAM_CONFIG_MAX
]; /* for DAI link */
392 __le32 num_streams
; /* number of streams */
393 struct snd_soc_tplg_stream_caps caps
[2]; /* playback and capture for DAI */
394 } __attribute__((packed
));
398 * Describes the BE or CC link runtime supported configs or params
400 * File block representation for BE/CC link config :-
401 * +-----------------------------------+-----+
402 * | struct snd_soc_tplg_hdr | 1 |
403 * +-----------------------------------+-----+
404 * | struct snd_soc_tplg_link_config | N |
405 * +-----------------------------------+-----+
407 struct snd_soc_tplg_link_config
{
408 __le32 size
; /* in bytes of this structure */
409 __le32 id
; /* unique ID - used to match */
410 struct snd_soc_tplg_stream stream
[SND_SOC_TPLG_STREAM_CONFIG_MAX
]; /* supported configs playback and captrure */
411 __le32 num_streams
; /* number of streams */
412 } __attribute__((packed
));