1 /* 2 * uapi/sound/asoc.h -- ALSA SoC Firmware Controls and DAPM 3 * 4 * Copyright (C) 2012 Texas Instruments Inc. 5 * Copyright (C) 2015 Intel Corporation. 6 * 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. 10 * 11 * Simple file API to load FW that includes mixers, coefficients, DAPM graphs, 12 * algorithms, equalisers, DAIs, widgets etc. 13 */ 14 15 #ifndef __LINUX_UAPI_SND_ASOC_H 16 #define __LINUX_UAPI_SND_ASOC_H 17 18 #include <linux/types.h> 19 #include <sound/asound.h> 20 21 /* 22 * Maximum number of channels topology kcontrol can represent. 23 */ 24 #define SND_SOC_TPLG_MAX_CHAN 8 25 26 /* 27 * Maximum number of PCM formats capability 28 */ 29 #define SND_SOC_TPLG_MAX_FORMATS 16 30 31 /* 32 * Maximum number of PCM stream configs 33 */ 34 #define SND_SOC_TPLG_STREAM_CONFIG_MAX 8 35 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 45 46 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 53 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 72 73 /* Header magic number and string sizes */ 74 #define SND_SOC_TPLG_MAGIC 0x41536F43 /* ASoC */ 75 76 /* string sizes */ 77 #define SND_SOC_TPLG_NUM_TEXTS 16 78 79 /* ABI version */ 80 #define SND_SOC_TPLG_ABI_VERSION 0x5 81 82 /* Max size of TLV data */ 83 #define SND_SOC_TPLG_TLV_SIZE 32 84 85 /* 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. 90 */ 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_BACKEND_LINK 10 101 #define SND_SOC_TPLG_TYPE_PDATA 11 102 #define SND_SOC_TPLG_TYPE_BE_DAI 12 103 #define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_BE_DAI 104 105 /* vendor block IDs - please add new vendor types to end */ 106 #define SND_SOC_TPLG_TYPE_VENDOR_FW 1000 107 #define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001 108 #define SND_SOC_TPLG_TYPE_VENDOR_COEFF 1002 109 #define SND_SOC_TPLG_TYPEVENDOR_CODEC 1003 110 111 #define SND_SOC_TPLG_STREAM_PLAYBACK 0 112 #define SND_SOC_TPLG_STREAM_CAPTURE 1 113 114 /* vendor tuple types */ 115 #define SND_SOC_TPLG_TUPLE_TYPE_UUID 0 116 #define SND_SOC_TPLG_TUPLE_TYPE_STRING 1 117 #define SND_SOC_TPLG_TUPLE_TYPE_BOOL 2 118 #define SND_SOC_TPLG_TUPLE_TYPE_BYTE 3 119 #define SND_SOC_TPLG_TUPLE_TYPE_WORD 4 120 #define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5 121 122 /* BE DAI flags */ 123 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_RATES (1 << 0) 124 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS (1 << 1) 125 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2) 126 127 /* 128 * Block Header. 129 * This header precedes all object and object arrays below. 130 */ 131 struct snd_soc_tplg_hdr { 132 __le32 magic; /* magic number */ 133 __le32 abi; /* ABI version */ 134 __le32 version; /* optional vendor specific version details */ 135 __le32 type; /* SND_SOC_TPLG_TYPE_ */ 136 __le32 size; /* size of this structure */ 137 __le32 vendor_type; /* optional vendor specific type info */ 138 __le32 payload_size; /* data bytes, excluding this header */ 139 __le32 index; /* identifier for block */ 140 __le32 count; /* number of elements in block */ 141 } __attribute__((packed)); 142 143 /* vendor tuple for uuid */ 144 struct snd_soc_tplg_vendor_uuid_elem { 145 __le32 token; 146 char uuid[16]; 147 } __attribute__((packed)); 148 149 /* vendor tuple for a bool/byte/short/word value */ 150 struct snd_soc_tplg_vendor_value_elem { 151 __le32 token; 152 __le32 value; 153 } __attribute__((packed)); 154 155 /* vendor tuple for string */ 156 struct snd_soc_tplg_vendor_string_elem { 157 __le32 token; 158 char string[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 159 } __attribute__((packed)); 160 161 struct snd_soc_tplg_vendor_array { 162 __le32 size; /* size in bytes of the array, including all elements */ 163 __le32 type; /* SND_SOC_TPLG_TUPLE_TYPE_ */ 164 __le32 num_elems; /* number of elements in array */ 165 union { 166 struct snd_soc_tplg_vendor_uuid_elem uuid[0]; 167 struct snd_soc_tplg_vendor_value_elem value[0]; 168 struct snd_soc_tplg_vendor_string_elem string[0]; 169 }; 170 } __attribute__((packed)); 171 172 /* 173 * Private data. 174 * All topology objects may have private data that can be used by the driver or 175 * firmware. Core will ignore this data. 176 */ 177 struct snd_soc_tplg_private { 178 __le32 size; /* in bytes of private data */ 179 union { 180 char data[0]; 181 struct snd_soc_tplg_vendor_array array[0]; 182 }; 183 } __attribute__((packed)); 184 185 /* 186 * Kcontrol TLV data. 187 */ 188 struct snd_soc_tplg_tlv_dbscale { 189 __le32 min; 190 __le32 step; 191 __le32 mute; 192 } __attribute__((packed)); 193 194 struct snd_soc_tplg_ctl_tlv { 195 __le32 size; /* in bytes of this structure */ 196 __le32 type; /* SNDRV_CTL_TLVT_*, type of TLV */ 197 union { 198 __le32 data[SND_SOC_TPLG_TLV_SIZE]; 199 struct snd_soc_tplg_tlv_dbscale scale; 200 }; 201 } __attribute__((packed)); 202 203 /* 204 * Kcontrol channel data 205 */ 206 struct snd_soc_tplg_channel { 207 __le32 size; /* in bytes of this structure */ 208 __le32 reg; 209 __le32 shift; 210 __le32 id; /* ID maps to Left, Right, LFE etc */ 211 } __attribute__((packed)); 212 213 /* 214 * Genericl Operations IDs, for binding Kcontrol or Bytes ext ops 215 * Kcontrol ops need get/put/info. 216 * Bytes ext ops need get/put. 217 */ 218 struct snd_soc_tplg_io_ops { 219 __le32 get; 220 __le32 put; 221 __le32 info; 222 } __attribute__((packed)); 223 224 /* 225 * kcontrol header 226 */ 227 struct snd_soc_tplg_ctl_hdr { 228 __le32 size; /* in bytes of this structure */ 229 __le32 type; 230 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 231 __le32 access; 232 struct snd_soc_tplg_io_ops ops; 233 struct snd_soc_tplg_ctl_tlv tlv; 234 } __attribute__((packed)); 235 236 /* 237 * Stream Capabilities 238 */ 239 struct snd_soc_tplg_stream_caps { 240 __le32 size; /* in bytes of this structure */ 241 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 242 __le64 formats; /* supported formats SNDRV_PCM_FMTBIT_* */ 243 __le32 rates; /* supported rates SNDRV_PCM_RATE_* */ 244 __le32 rate_min; /* min rate */ 245 __le32 rate_max; /* max rate */ 246 __le32 channels_min; /* min channels */ 247 __le32 channels_max; /* max channels */ 248 __le32 periods_min; /* min number of periods */ 249 __le32 periods_max; /* max number of periods */ 250 __le32 period_size_min; /* min period size bytes */ 251 __le32 period_size_max; /* max period size bytes */ 252 __le32 buffer_size_min; /* min buffer size bytes */ 253 __le32 buffer_size_max; /* max buffer size bytes */ 254 __le32 sig_bits; /* number of bits of content */ 255 } __attribute__((packed)); 256 257 /* 258 * FE or BE Stream configuration supported by SW/FW 259 */ 260 struct snd_soc_tplg_stream { 261 __le32 size; /* in bytes of this structure */ 262 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* Name of the stream */ 263 __le64 format; /* SNDRV_PCM_FMTBIT_* */ 264 __le32 rate; /* SNDRV_PCM_RATE_* */ 265 __le32 period_bytes; /* size of period in bytes */ 266 __le32 buffer_bytes; /* size of buffer in bytes */ 267 __le32 channels; /* channels */ 268 } __attribute__((packed)); 269 270 /* 271 * Manifest. List totals for each payload type. Not used in parsing, but will 272 * be passed to the component driver before any other objects in order for any 273 * global component resource allocations. 274 * 275 * File block representation for manifest :- 276 * +-----------------------------------+----+ 277 * | struct snd_soc_tplg_hdr | 1 | 278 * +-----------------------------------+----+ 279 * | struct snd_soc_tplg_manifest | 1 | 280 * +-----------------------------------+----+ 281 */ 282 struct snd_soc_tplg_manifest { 283 __le32 size; /* in bytes of this structure */ 284 __le32 control_elems; /* number of control elements */ 285 __le32 widget_elems; /* number of widget elements */ 286 __le32 graph_elems; /* number of graph elements */ 287 __le32 pcm_elems; /* number of PCM elements */ 288 __le32 dai_link_elems; /* number of DAI link elements */ 289 __le32 be_dai_elems; /* number of BE DAI elements */ 290 __le32 reserved[20]; /* reserved for new ABI element types */ 291 struct snd_soc_tplg_private priv; 292 } __attribute__((packed)); 293 294 /* 295 * Mixer kcontrol. 296 * 297 * File block representation for mixer kcontrol :- 298 * +-----------------------------------+----+ 299 * | struct snd_soc_tplg_hdr | 1 | 300 * +-----------------------------------+----+ 301 * | struct snd_soc_tplg_mixer_control | N | 302 * +-----------------------------------+----+ 303 */ 304 struct snd_soc_tplg_mixer_control { 305 struct snd_soc_tplg_ctl_hdr hdr; 306 __le32 size; /* in bytes of this structure */ 307 __le32 min; 308 __le32 max; 309 __le32 platform_max; 310 __le32 invert; 311 __le32 num_channels; 312 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN]; 313 struct snd_soc_tplg_private priv; 314 } __attribute__((packed)); 315 316 /* 317 * Enumerated kcontrol 318 * 319 * File block representation for enum kcontrol :- 320 * +-----------------------------------+----+ 321 * | struct snd_soc_tplg_hdr | 1 | 322 * +-----------------------------------+----+ 323 * | struct snd_soc_tplg_enum_control | N | 324 * +-----------------------------------+----+ 325 */ 326 struct snd_soc_tplg_enum_control { 327 struct snd_soc_tplg_ctl_hdr hdr; 328 __le32 size; /* in bytes of this structure */ 329 __le32 num_channels; 330 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN]; 331 __le32 items; 332 __le32 mask; 333 __le32 count; 334 char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 335 __le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4]; 336 struct snd_soc_tplg_private priv; 337 } __attribute__((packed)); 338 339 /* 340 * Bytes kcontrol 341 * 342 * File block representation for bytes kcontrol :- 343 * +-----------------------------------+----+ 344 * | struct snd_soc_tplg_hdr | 1 | 345 * +-----------------------------------+----+ 346 * | struct snd_soc_tplg_bytes_control | N | 347 * +-----------------------------------+----+ 348 */ 349 struct snd_soc_tplg_bytes_control { 350 struct snd_soc_tplg_ctl_hdr hdr; 351 __le32 size; /* in bytes of this structure */ 352 __le32 max; 353 __le32 mask; 354 __le32 base; 355 __le32 num_regs; 356 struct snd_soc_tplg_io_ops ext_ops; 357 struct snd_soc_tplg_private priv; 358 } __attribute__((packed)); 359 360 /* 361 * DAPM Graph Element 362 * 363 * File block representation for DAPM graph elements :- 364 * +-------------------------------------+----+ 365 * | struct snd_soc_tplg_hdr | 1 | 366 * +-------------------------------------+----+ 367 * | struct snd_soc_tplg_dapm_graph_elem | N | 368 * +-------------------------------------+----+ 369 */ 370 struct snd_soc_tplg_dapm_graph_elem { 371 char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 372 char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 373 char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 374 } __attribute__((packed)); 375 376 /* 377 * DAPM Widget. 378 * 379 * File block representation for DAPM widget :- 380 * +-------------------------------------+-----+ 381 * | struct snd_soc_tplg_hdr | 1 | 382 * +-------------------------------------+-----+ 383 * | struct snd_soc_tplg_dapm_widget | N | 384 * +-------------------------------------+-----+ 385 * | struct snd_soc_tplg_enum_control | 0|1 | 386 * | struct snd_soc_tplg_mixer_control | 0|N | 387 * +-------------------------------------+-----+ 388 * 389 * Optional enum or mixer control can be appended to the end of each widget 390 * in the block. 391 */ 392 struct snd_soc_tplg_dapm_widget { 393 __le32 size; /* in bytes of this structure */ 394 __le32 id; /* SND_SOC_DAPM_CTL */ 395 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 396 char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 397 398 __le32 reg; /* negative reg = no direct dapm */ 399 __le32 shift; /* bits to shift */ 400 __le32 mask; /* non-shifted mask */ 401 __le32 subseq; /* sort within widget type */ 402 __le32 invert; /* invert the power bit */ 403 __le32 ignore_suspend; /* kept enabled over suspend */ 404 __le16 event_flags; 405 __le16 event_type; 406 __le32 num_kcontrols; 407 struct snd_soc_tplg_private priv; 408 /* 409 * kcontrols that relate to this widget 410 * follow here after widget private data 411 */ 412 } __attribute__((packed)); 413 414 415 /* 416 * Describes SW/FW specific features of PCM (FE DAI & DAI link). 417 * 418 * File block representation for PCM :- 419 * +-----------------------------------+-----+ 420 * | struct snd_soc_tplg_hdr | 1 | 421 * +-----------------------------------+-----+ 422 * | struct snd_soc_tplg_pcm | N | 423 * +-----------------------------------+-----+ 424 */ 425 struct snd_soc_tplg_pcm { 426 __le32 size; /* in bytes of this structure */ 427 char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 428 char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 429 __le32 pcm_id; /* unique ID - used to match with DAI link */ 430 __le32 dai_id; /* unique ID - used to match */ 431 __le32 playback; /* supports playback mode */ 432 __le32 capture; /* supports capture mode */ 433 __le32 compress; /* 1 = compressed; 0 = PCM */ 434 struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */ 435 __le32 num_streams; /* number of streams */ 436 struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */ 437 } __attribute__((packed)); 438 439 440 /* 441 * Describes the BE or CC link runtime supported configs or params 442 * 443 * File block representation for BE/CC link config :- 444 * +-----------------------------------+-----+ 445 * | struct snd_soc_tplg_hdr | 1 | 446 * +-----------------------------------+-----+ 447 * | struct snd_soc_tplg_link_config | N | 448 * +-----------------------------------+-----+ 449 */ 450 struct snd_soc_tplg_link_config { 451 __le32 size; /* in bytes of this structure */ 452 __le32 id; /* unique ID - used to match */ 453 struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* supported configs playback and captrure */ 454 __le32 num_streams; /* number of streams */ 455 } __attribute__((packed)); 456 457 /* 458 * Describes SW/FW specific features of BE DAI. 459 * 460 * File block representation for BE DAI :- 461 * +-----------------------------------+-----+ 462 * | struct snd_soc_tplg_hdr | 1 | 463 * +-----------------------------------+-----+ 464 * | struct snd_soc_tplg_be_dai | N | 465 * +-----------------------------------+-----+ 466 */ 467 struct snd_soc_tplg_be_dai { 468 __le32 size; /* in bytes of this structure */ 469 char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* name - used to match */ 470 __le32 dai_id; /* unique ID - used to match */ 471 __le32 playback; /* supports playback mode */ 472 __le32 capture; /* supports capture mode */ 473 struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */ 474 __le32 flag_mask; /* bitmask of flags to configure */ 475 __le32 flags; /* SND_SOC_TPLG_DAI_FLGBIT_* */ 476 struct snd_soc_tplg_private priv; 477 } __attribute__((packed)); 478 #endif 479