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
36 /* individual kcontrol info types - can be mixed with other types */
37 #define SND_SOC_TPLG_CTL_VOLSW 1
38 #define SND_SOC_TPLG_CTL_VOLSW_SX 2
39 #define SND_SOC_TPLG_CTL_VOLSW_XR_SX 3
40 #define SND_SOC_TPLG_CTL_ENUM 4
41 #define SND_SOC_TPLG_CTL_BYTES 5
42 #define SND_SOC_TPLG_CTL_ENUM_VALUE 6
43 #define SND_SOC_TPLG_CTL_RANGE 7
44 #define SND_SOC_TPLG_CTL_STROBE 8
47 /* individual widget kcontrol info types - can be mixed with other types */
48 #define SND_SOC_TPLG_DAPM_CTL_VOLSW 64
49 #define SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE 65
50 #define SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT 66
51 #define SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE 67
52 #define SND_SOC_TPLG_DAPM_CTL_PIN 68
54 /* DAPM widget types - add new items to the end */
55 #define SND_SOC_TPLG_DAPM_INPUT 0
56 #define SND_SOC_TPLG_DAPM_OUTPUT 1
57 #define SND_SOC_TPLG_DAPM_MUX 2
58 #define SND_SOC_TPLG_DAPM_MIXER 3
59 #define SND_SOC_TPLG_DAPM_PGA 4
60 #define SND_SOC_TPLG_DAPM_OUT_DRV 5
61 #define SND_SOC_TPLG_DAPM_ADC 6
62 #define SND_SOC_TPLG_DAPM_DAC 7
63 #define SND_SOC_TPLG_DAPM_SWITCH 8
64 #define SND_SOC_TPLG_DAPM_PRE 9
65 #define SND_SOC_TPLG_DAPM_POST 10
66 #define SND_SOC_TPLG_DAPM_AIF_IN 11
67 #define SND_SOC_TPLG_DAPM_AIF_OUT 12
68 #define SND_SOC_TPLG_DAPM_DAI_IN 13
69 #define SND_SOC_TPLG_DAPM_DAI_OUT 14
70 #define SND_SOC_TPLG_DAPM_DAI_LINK 15
71 #define SND_SOC_TPLG_DAPM_LAST SND_SOC_TPLG_DAPM_DAI_LINK
73 /* Header magic number and string sizes */
74 #define SND_SOC_TPLG_MAGIC 0x41536F43 /* ASoC */
77 #define SND_SOC_TPLG_NUM_TEXTS 16
80 #define SND_SOC_TPLG_ABI_VERSION 0x3
82 /* Max size of TLV data */
83 #define SND_SOC_TPLG_TLV_SIZE 32
86 * File and Block header data types.
87 * Add new generic and vendor types to end of list.
88 * Generic types are handled by the core whilst vendors types are passed
89 * to the component drivers for handling.
91 #define SND_SOC_TPLG_TYPE_MIXER 1
92 #define SND_SOC_TPLG_TYPE_BYTES 2
93 #define SND_SOC_TPLG_TYPE_ENUM 3
94 #define SND_SOC_TPLG_TYPE_DAPM_GRAPH 4
95 #define SND_SOC_TPLG_TYPE_DAPM_WIDGET 5
96 #define SND_SOC_TPLG_TYPE_DAI_LINK 6
97 #define SND_SOC_TPLG_TYPE_PCM 7
98 #define SND_SOC_TPLG_TYPE_MANIFEST 8
99 #define SND_SOC_TPLG_TYPE_CODEC_LINK 9
100 #define SND_SOC_TPLG_TYPE_PDATA 10
101 #define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_PDATA
103 /* vendor block IDs - please add new vendor types to end */
104 #define SND_SOC_TPLG_TYPE_VENDOR_FW 1000
105 #define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001
106 #define SND_SOC_TPLG_TYPE_VENDOR_COEFF 1002
107 #define SND_SOC_TPLG_TYPEVENDOR_CODEC 1003
109 #define SND_SOC_TPLG_STREAM_PLAYBACK 0
110 #define SND_SOC_TPLG_STREAM_CAPTURE 1
114 * This header precedes all object and object arrays below.
116 struct snd_soc_tplg_hdr {
117 __le32 magic; /* magic number */
118 __le32 abi; /* ABI version */
119 __le32 version; /* optional vendor specific version details */
120 __le32 type; /* SND_SOC_TPLG_TYPE_ */
121 __le32 size; /* size of this structure */
122 __le32 vendor_type; /* optional vendor specific type info */
123 __le32 payload_size; /* data bytes, excluding this header */
124 __le32 index; /* identifier for block */
125 __le32 count; /* number of elements in block */
126 } __attribute__((packed));
130 * All topology objects may have private data that can be used by the driver or
131 * firmware. Core will ignore this data.
133 struct snd_soc_tplg_private {
134 __le32 size; /* in bytes of private data */
136 } __attribute__((packed));
141 struct snd_soc_tplg_tlv_dbscale {
145 } __attribute__((packed));
147 struct snd_soc_tplg_ctl_tlv {
148 __le32 size; /* in bytes of this structure */
149 __le32 type; /* SNDRV_CTL_TLVT_*, type of TLV */
151 __le32 data[SND_SOC_TPLG_TLV_SIZE];
152 struct snd_soc_tplg_tlv_dbscale scale;
154 } __attribute__((packed));
157 * Kcontrol channel data
159 struct snd_soc_tplg_channel {
160 __le32 size; /* in bytes of this structure */
163 __le32 id; /* ID maps to Left, Right, LFE etc */
164 } __attribute__((packed));
167 * Genericl Operations IDs, for binding Kcontrol or Bytes ext ops
168 * Kcontrol ops need get/put/info.
169 * Bytes ext ops need get/put.
171 struct snd_soc_tplg_io_ops {
175 } __attribute__((packed));
180 struct snd_soc_tplg_ctl_hdr {
181 __le32 size; /* in bytes of this structure */
183 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
185 struct snd_soc_tplg_io_ops ops;
186 struct snd_soc_tplg_ctl_tlv tlv;
187 } __attribute__((packed));
190 * Stream Capabilities
192 struct snd_soc_tplg_stream_caps {
193 __le32 size; /* in bytes of this structure */
194 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
195 __le64 formats[SND_SOC_TPLG_MAX_FORMATS]; /* supported formats SNDRV_PCM_FMTBIT_* */
196 __le32 rates; /* supported rates SNDRV_PCM_RATE_* */
197 __le32 rate_min; /* min rate */
198 __le32 rate_max; /* max rate */
199 __le32 channels_min; /* min channels */
200 __le32 channels_max; /* max channels */
201 __le32 periods_min; /* min number of periods */
202 __le32 periods_max; /* max number of periods */
203 __le32 period_size_min; /* min period size bytes */
204 __le32 period_size_max; /* max period size bytes */
205 __le32 buffer_size_min; /* min buffer size bytes */
206 __le32 buffer_size_max; /* max buffer size bytes */
207 } __attribute__((packed));
210 * FE or BE Stream configuration supported by SW/FW
212 struct snd_soc_tplg_stream {
213 __le32 size; /* in bytes of this structure */
214 __le64 format; /* SNDRV_PCM_FMTBIT_* */
215 __le32 rate; /* SNDRV_PCM_RATE_* */
216 __le32 period_bytes; /* size of period in bytes */
217 __le32 buffer_bytes; /* size of buffer in bytes */
218 __le32 channels; /* channels */
219 __le32 tdm_slot; /* optional BE bitmask of supported TDM slots */
220 __le32 dai_fmt; /* SND_SOC_DAIFMT_ */
221 } __attribute__((packed));
224 * Duplex stream configuration supported by SW/FW.
226 struct snd_soc_tplg_stream_config {
227 __le32 size; /* in bytes of this structure */
228 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
229 struct snd_soc_tplg_stream playback;
230 struct snd_soc_tplg_stream capture;
231 } __attribute__((packed));
234 * Manifest. List totals for each payload type. Not used in parsing, but will
235 * be passed to the component driver before any other objects in order for any
236 * global component resource allocations.
238 * File block representation for manifest :-
239 * +-----------------------------------+----+
240 * | struct snd_soc_tplg_hdr | 1 |
241 * +-----------------------------------+----+
242 * | struct snd_soc_tplg_manifest | 1 |
243 * +-----------------------------------+----+
245 struct snd_soc_tplg_manifest {
246 __le32 size; /* in bytes of this structure */
247 __le32 control_elems; /* number of control elements */
248 __le32 widget_elems; /* number of widget elements */
249 __le32 graph_elems; /* number of graph elements */
250 __le32 dai_elems; /* number of DAI elements */
251 __le32 dai_link_elems; /* number of DAI link elements */
252 struct snd_soc_tplg_private priv;
253 } __attribute__((packed));
258 * File block representation for mixer kcontrol :-
259 * +-----------------------------------+----+
260 * | struct snd_soc_tplg_hdr | 1 |
261 * +-----------------------------------+----+
262 * | struct snd_soc_tplg_mixer_control | N |
263 * +-----------------------------------+----+
265 struct snd_soc_tplg_mixer_control {
266 struct snd_soc_tplg_ctl_hdr hdr;
267 __le32 size; /* in bytes of this structure */
273 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
274 struct snd_soc_tplg_private priv;
275 } __attribute__((packed));
278 * Enumerated kcontrol
280 * File block representation for enum kcontrol :-
281 * +-----------------------------------+----+
282 * | struct snd_soc_tplg_hdr | 1 |
283 * +-----------------------------------+----+
284 * | struct snd_soc_tplg_enum_control | N |
285 * +-----------------------------------+----+
287 struct snd_soc_tplg_enum_control {
288 struct snd_soc_tplg_ctl_hdr hdr;
289 __le32 size; /* in bytes of this structure */
291 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
295 char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
296 __le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4];
297 struct snd_soc_tplg_private priv;
298 } __attribute__((packed));
303 * File block representation for bytes kcontrol :-
304 * +-----------------------------------+----+
305 * | struct snd_soc_tplg_hdr | 1 |
306 * +-----------------------------------+----+
307 * | struct snd_soc_tplg_bytes_control | N |
308 * +-----------------------------------+----+
310 struct snd_soc_tplg_bytes_control {
311 struct snd_soc_tplg_ctl_hdr hdr;
312 __le32 size; /* in bytes of this structure */
317 struct snd_soc_tplg_io_ops ext_ops;
318 struct snd_soc_tplg_private priv;
319 } __attribute__((packed));
324 * File block representation for DAPM graph elements :-
325 * +-------------------------------------+----+
326 * | struct snd_soc_tplg_hdr | 1 |
327 * +-------------------------------------+----+
328 * | struct snd_soc_tplg_dapm_graph_elem | N |
329 * +-------------------------------------+----+
331 struct snd_soc_tplg_dapm_graph_elem {
332 char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
333 char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
334 char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
335 } __attribute__((packed));
340 * File block representation for DAPM widget :-
341 * +-------------------------------------+-----+
342 * | struct snd_soc_tplg_hdr | 1 |
343 * +-------------------------------------+-----+
344 * | struct snd_soc_tplg_dapm_widget | N |
345 * +-------------------------------------+-----+
346 * | struct snd_soc_tplg_enum_control | 0|1 |
347 * | struct snd_soc_tplg_mixer_control | 0|N |
348 * +-------------------------------------+-----+
350 * Optional enum or mixer control can be appended to the end of each widget
353 struct snd_soc_tplg_dapm_widget {
354 __le32 size; /* in bytes of this structure */
355 __le32 id; /* SND_SOC_DAPM_CTL */
356 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
357 char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
359 __le32 reg; /* negative reg = no direct dapm */
360 __le32 shift; /* bits to shift */
361 __le32 mask; /* non-shifted mask */
362 __le32 subseq; /* sort within widget type */
363 __u32 invert; /* invert the power bit */
364 __u32 ignore_suspend; /* kept enabled over suspend */
368 struct snd_soc_tplg_private priv;
370 * kcontrols that relate to this widget
371 * follow here after widget private data
373 } __attribute__((packed));
375 struct snd_soc_tplg_pcm_cfg_caps {
376 struct snd_soc_tplg_stream_caps caps;
377 struct snd_soc_tplg_stream_config configs[SND_SOC_TPLG_STREAM_CONFIG_MAX];
378 __le32 num_configs; /* number of configs */
379 } __attribute__((packed));
382 * Describes SW/FW specific features of PCM or DAI link.
384 * File block representation for PCM/DAI-Link :-
385 * +-----------------------------------+-----+
386 * | struct snd_soc_tplg_hdr | 1 |
387 * +-----------------------------------+-----+
388 * | struct snd_soc_tplg_dapm_pcm_dai | N |
389 * +-----------------------------------+-----+
391 struct snd_soc_tplg_pcm_dai {
392 __le32 size; /* in bytes of this structure */
393 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
394 __le32 id; /* unique ID - used to match */
395 __le32 playback; /* supports playback mode */
396 __le32 capture; /* supports capture mode */
397 __le32 compress; /* 1 = compressed; 0 = PCM */
398 struct snd_soc_tplg_pcm_cfg_caps capconf[2]; /* capabilities and configs */
399 } __attribute__((packed));