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