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
112 * This header precedes all object and object arrays below.
114 struct snd_soc_tplg_hdr {
115 __le32 magic; /* magic number */
116 __le32 abi; /* ABI version */
117 __le32 version; /* optional vendor specific version details */
118 __le32 type; /* SND_SOC_TPLG_TYPE_ */
119 __le32 size; /* size of this structure */
120 __le32 vendor_type; /* optional vendor specific type info */
121 __le32 payload_size; /* data bytes, excluding this header */
122 __le32 index; /* identifier for block */
123 __le32 count; /* number of elements in block */
124 } __attribute__((packed));
128 * All topology objects may have private data that can be used by the driver or
129 * firmware. Core will ignore this data.
131 struct snd_soc_tplg_private {
132 __le32 size; /* in bytes of private data */
134 } __attribute__((packed));
139 struct snd_soc_tplg_tlv_dbscale {
143 } __attribute__((packed));
145 struct snd_soc_tplg_ctl_tlv {
146 __le32 size; /* in bytes of this structure */
147 __le32 type; /* SNDRV_CTL_TLVT_*, type of TLV */
149 __le32 data[SND_SOC_TPLG_TLV_SIZE];
150 struct snd_soc_tplg_tlv_dbscale scale;
152 } __attribute__((packed));
155 * Kcontrol channel data
157 struct snd_soc_tplg_channel {
158 __le32 size; /* in bytes of this structure */
161 __le32 id; /* ID maps to Left, Right, LFE etc */
162 } __attribute__((packed));
165 * Genericl Operations IDs, for binding Kcontrol or Bytes ext ops
166 * Kcontrol ops need get/put/info.
167 * Bytes ext ops need get/put.
169 struct snd_soc_tplg_io_ops {
173 } __attribute__((packed));
178 struct snd_soc_tplg_ctl_hdr {
179 __le32 size; /* in bytes of this structure */
181 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
183 struct snd_soc_tplg_io_ops ops;
184 struct snd_soc_tplg_ctl_tlv tlv;
185 } __attribute__((packed));
188 * Stream Capabilities
190 struct snd_soc_tplg_stream_caps {
191 __le32 size; /* in bytes of this structure */
192 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
193 __le64 formats; /* supported formats SNDRV_PCM_FMTBIT_* */
194 __le32 rates; /* supported rates SNDRV_PCM_RATE_* */
195 __le32 rate_min; /* min rate */
196 __le32 rate_max; /* max rate */
197 __le32 channels_min; /* min channels */
198 __le32 channels_max; /* max channels */
199 __le32 periods_min; /* min number of periods */
200 __le32 periods_max; /* max number of periods */
201 __le32 period_size_min; /* min period size bytes */
202 __le32 period_size_max; /* max period size bytes */
203 __le32 buffer_size_min; /* min buffer size bytes */
204 __le32 buffer_size_max; /* max buffer size bytes */
205 } __attribute__((packed));
208 * FE or BE Stream configuration supported by SW/FW
210 struct snd_soc_tplg_stream {
211 __le32 size; /* in bytes of this structure */
212 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* Name of the stream */
213 __le64 format; /* SNDRV_PCM_FMTBIT_* */
214 __le32 rate; /* SNDRV_PCM_RATE_* */
215 __le32 period_bytes; /* size of period in bytes */
216 __le32 buffer_bytes; /* size of buffer in bytes */
217 __le32 channels; /* channels */
218 } __attribute__((packed));
221 * Manifest. List totals for each payload type. Not used in parsing, but will
222 * be passed to the component driver before any other objects in order for any
223 * global component resource allocations.
225 * File block representation for manifest :-
226 * +-----------------------------------+----+
227 * | struct snd_soc_tplg_hdr | 1 |
228 * +-----------------------------------+----+
229 * | struct snd_soc_tplg_manifest | 1 |
230 * +-----------------------------------+----+
232 struct snd_soc_tplg_manifest {
233 __le32 size; /* in bytes of this structure */
234 __le32 control_elems; /* number of control elements */
235 __le32 widget_elems; /* number of widget elements */
236 __le32 graph_elems; /* number of graph elements */
237 __le32 pcm_elems; /* number of PCM elements */
238 __le32 dai_link_elems; /* number of DAI link elements */
239 struct snd_soc_tplg_private priv;
240 } __attribute__((packed));
245 * File block representation for mixer kcontrol :-
246 * +-----------------------------------+----+
247 * | struct snd_soc_tplg_hdr | 1 |
248 * +-----------------------------------+----+
249 * | struct snd_soc_tplg_mixer_control | N |
250 * +-----------------------------------+----+
252 struct snd_soc_tplg_mixer_control {
253 struct snd_soc_tplg_ctl_hdr hdr;
254 __le32 size; /* in bytes of this structure */
260 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
261 struct snd_soc_tplg_private priv;
262 } __attribute__((packed));
265 * Enumerated kcontrol
267 * File block representation for enum kcontrol :-
268 * +-----------------------------------+----+
269 * | struct snd_soc_tplg_hdr | 1 |
270 * +-----------------------------------+----+
271 * | struct snd_soc_tplg_enum_control | N |
272 * +-----------------------------------+----+
274 struct snd_soc_tplg_enum_control {
275 struct snd_soc_tplg_ctl_hdr hdr;
276 __le32 size; /* in bytes of this structure */
278 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
282 char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
283 __le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4];
284 struct snd_soc_tplg_private priv;
285 } __attribute__((packed));
290 * File block representation for bytes kcontrol :-
291 * +-----------------------------------+----+
292 * | struct snd_soc_tplg_hdr | 1 |
293 * +-----------------------------------+----+
294 * | struct snd_soc_tplg_bytes_control | N |
295 * +-----------------------------------+----+
297 struct snd_soc_tplg_bytes_control {
298 struct snd_soc_tplg_ctl_hdr hdr;
299 __le32 size; /* in bytes of this structure */
304 struct snd_soc_tplg_io_ops ext_ops;
305 struct snd_soc_tplg_private priv;
306 } __attribute__((packed));
311 * File block representation for DAPM graph elements :-
312 * +-------------------------------------+----+
313 * | struct snd_soc_tplg_hdr | 1 |
314 * +-------------------------------------+----+
315 * | struct snd_soc_tplg_dapm_graph_elem | N |
316 * +-------------------------------------+----+
318 struct snd_soc_tplg_dapm_graph_elem {
319 char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
320 char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
321 char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
322 } __attribute__((packed));
327 * File block representation for DAPM widget :-
328 * +-------------------------------------+-----+
329 * | struct snd_soc_tplg_hdr | 1 |
330 * +-------------------------------------+-----+
331 * | struct snd_soc_tplg_dapm_widget | N |
332 * +-------------------------------------+-----+
333 * | struct snd_soc_tplg_enum_control | 0|1 |
334 * | struct snd_soc_tplg_mixer_control | 0|N |
335 * +-------------------------------------+-----+
337 * Optional enum or mixer control can be appended to the end of each widget
340 struct snd_soc_tplg_dapm_widget {
341 __le32 size; /* in bytes of this structure */
342 __le32 id; /* SND_SOC_DAPM_CTL */
343 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
344 char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
346 __le32 reg; /* negative reg = no direct dapm */
347 __le32 shift; /* bits to shift */
348 __le32 mask; /* non-shifted mask */
349 __le32 subseq; /* sort within widget type */
350 __le32 invert; /* invert the power bit */
351 __le32 ignore_suspend; /* kept enabled over suspend */
354 __le32 num_kcontrols;
355 struct snd_soc_tplg_private priv;
357 * kcontrols that relate to this widget
358 * follow here after widget private data
360 } __attribute__((packed));
364 * Describes SW/FW specific features of PCM (FE DAI & DAI link).
366 * File block representation for PCM :-
367 * +-----------------------------------+-----+
368 * | struct snd_soc_tplg_hdr | 1 |
369 * +-----------------------------------+-----+
370 * | struct snd_soc_tplg_pcm | N |
371 * +-----------------------------------+-----+
373 struct snd_soc_tplg_pcm {
374 __le32 size; /* in bytes of this structure */
375 char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
376 char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
377 __le32 pcm_id; /* unique ID - used to match */
378 __le32 dai_id; /* unique ID - used to match */
379 __le32 playback; /* supports playback mode */
380 __le32 capture; /* supports capture mode */
381 __le32 compress; /* 1 = compressed; 0 = PCM */
382 struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */
383 __le32 num_streams; /* number of streams */
384 struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */
385 } __attribute__((packed));
389 * Describes the BE or CC link runtime supported configs or params
391 * File block representation for BE/CC link config :-
392 * +-----------------------------------+-----+
393 * | struct snd_soc_tplg_hdr | 1 |
394 * +-----------------------------------+-----+
395 * | struct snd_soc_tplg_link_config | N |
396 * +-----------------------------------+-----+
398 struct snd_soc_tplg_link_config {
399 __le32 size; /* in bytes of this structure */
400 __le32 id; /* unique ID - used to match */
401 struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* supported configs playback and captrure */
402 __le32 num_streams; /* number of streams */
403 } __attribute__((packed));