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 0x4 87 88/* Max size of TLV data */ 89#define SND_SOC_TPLG_TLV_SIZE 32 90 91/* 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. 96 */ 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 109 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 115 116#define SND_SOC_TPLG_STREAM_PLAYBACK 0 117#define SND_SOC_TPLG_STREAM_CAPTURE 1 118 119/* vendor tuple types */ 120#define SND_SOC_TPLG_TUPLE_TYPE_UUID 0 121#define SND_SOC_TPLG_TUPLE_TYPE_STRING 1 122#define SND_SOC_TPLG_TUPLE_TYPE_BOOL 2 123#define SND_SOC_TPLG_TUPLE_TYPE_BYTE 3 124#define SND_SOC_TPLG_TUPLE_TYPE_WORD 4 125#define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5 126 127/* 128 * Block Header. 129 * This header precedes all object and object arrays below. 130 */ 131struct 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 */ 144struct 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 */ 150struct snd_soc_tplg_vendor_value_elem { 151 __le32 token; 152 __le32 value; 153} __attribute__((packed)); 154 155/* vendor tuple for string */ 156struct snd_soc_tplg_vendor_string_elem { 157 __le32 token; 158 char string[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 159} __attribute__((packed)); 160 161struct 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 */ 177struct 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 */ 188struct snd_soc_tplg_tlv_dbscale { 189 __le32 min; 190 __le32 step; 191 __le32 mute; 192} __attribute__((packed)); 193 194struct 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 */ 206struct 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 */ 218struct snd_soc_tplg_io_ops { 219 __le32 get; 220 __le32 put; 221 __le32 info; 222} __attribute__((packed)); 223 224/* 225 * kcontrol header 226 */ 227struct 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 */ 239struct 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} __attribute__((packed)); 255 256/* 257 * FE or BE Stream configuration supported by SW/FW 258 */ 259struct snd_soc_tplg_stream { 260 __le32 size; /* in bytes of this structure */ 261 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* Name of the stream */ 262 __le64 format; /* SNDRV_PCM_FMTBIT_* */ 263 __le32 rate; /* SNDRV_PCM_RATE_* */ 264 __le32 period_bytes; /* size of period in bytes */ 265 __le32 buffer_bytes; /* size of buffer in bytes */ 266 __le32 channels; /* channels */ 267} __attribute__((packed)); 268 269/* 270 * Manifest. List totals for each payload type. Not used in parsing, but will 271 * be passed to the component driver before any other objects in order for any 272 * global component resource allocations. 273 * 274 * File block representation for manifest :- 275 * +-----------------------------------+----+ 276 * | struct snd_soc_tplg_hdr | 1 | 277 * +-----------------------------------+----+ 278 * | struct snd_soc_tplg_manifest | 1 | 279 * +-----------------------------------+----+ 280 */ 281struct snd_soc_tplg_manifest { 282 __le32 size; /* in bytes of this structure */ 283 __le32 control_elems; /* number of control elements */ 284 __le32 widget_elems; /* number of widget elements */ 285 __le32 graph_elems; /* number of graph elements */ 286 __le32 pcm_elems; /* number of PCM elements */ 287 __le32 dai_link_elems; /* number of DAI link elements */ 288 struct snd_soc_tplg_private priv; 289} __attribute__((packed)); 290 291/* 292 * Mixer kcontrol. 293 * 294 * File block representation for mixer kcontrol :- 295 * +-----------------------------------+----+ 296 * | struct snd_soc_tplg_hdr | 1 | 297 * +-----------------------------------+----+ 298 * | struct snd_soc_tplg_mixer_control | N | 299 * +-----------------------------------+----+ 300 */ 301struct snd_soc_tplg_mixer_control { 302 struct snd_soc_tplg_ctl_hdr hdr; 303 __le32 size; /* in bytes of this structure */ 304 __le32 min; 305 __le32 max; 306 __le32 platform_max; 307 __le32 invert; 308 __le32 num_channels; 309 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN]; 310 struct snd_soc_tplg_private priv; 311} __attribute__((packed)); 312 313/* 314 * Enumerated kcontrol 315 * 316 * File block representation for enum kcontrol :- 317 * +-----------------------------------+----+ 318 * | struct snd_soc_tplg_hdr | 1 | 319 * +-----------------------------------+----+ 320 * | struct snd_soc_tplg_enum_control | N | 321 * +-----------------------------------+----+ 322 */ 323struct snd_soc_tplg_enum_control { 324 struct snd_soc_tplg_ctl_hdr hdr; 325 __le32 size; /* in bytes of this structure */ 326 __le32 num_channels; 327 struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN]; 328 __le32 items; 329 __le32 mask; 330 __le32 count; 331 char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 332 __le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4]; 333 struct snd_soc_tplg_private priv; 334} __attribute__((packed)); 335 336/* 337 * Bytes kcontrol 338 * 339 * File block representation for bytes kcontrol :- 340 * +-----------------------------------+----+ 341 * | struct snd_soc_tplg_hdr | 1 | 342 * +-----------------------------------+----+ 343 * | struct snd_soc_tplg_bytes_control | N | 344 * +-----------------------------------+----+ 345 */ 346struct snd_soc_tplg_bytes_control { 347 struct snd_soc_tplg_ctl_hdr hdr; 348 __le32 size; /* in bytes of this structure */ 349 __le32 max; 350 __le32 mask; 351 __le32 base; 352 __le32 num_regs; 353 struct snd_soc_tplg_io_ops ext_ops; 354 struct snd_soc_tplg_private priv; 355} __attribute__((packed)); 356 357/* 358 * DAPM Graph Element 359 * 360 * File block representation for DAPM graph elements :- 361 * +-------------------------------------+----+ 362 * | struct snd_soc_tplg_hdr | 1 | 363 * +-------------------------------------+----+ 364 * | struct snd_soc_tplg_dapm_graph_elem | N | 365 * +-------------------------------------+----+ 366 */ 367struct snd_soc_tplg_dapm_graph_elem { 368 char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 369 char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 370 char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 371} __attribute__((packed)); 372 373/* 374 * DAPM Widget. 375 * 376 * File block representation for DAPM widget :- 377 * +-------------------------------------+-----+ 378 * | struct snd_soc_tplg_hdr | 1 | 379 * +-------------------------------------+-----+ 380 * | struct snd_soc_tplg_dapm_widget | N | 381 * +-------------------------------------+-----+ 382 * | struct snd_soc_tplg_enum_control | 0|1 | 383 * | struct snd_soc_tplg_mixer_control | 0|N | 384 * +-------------------------------------+-----+ 385 * 386 * Optional enum or mixer control can be appended to the end of each widget 387 * in the block. 388 */ 389struct snd_soc_tplg_dapm_widget { 390 __le32 size; /* in bytes of this structure */ 391 __le32 id; /* SND_SOC_DAPM_CTL */ 392 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 393 char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 394 395 __le32 reg; /* negative reg = no direct dapm */ 396 __le32 shift; /* bits to shift */ 397 __le32 mask; /* non-shifted mask */ 398 __le32 subseq; /* sort within widget type */ 399 __le32 invert; /* invert the power bit */ 400 __le32 ignore_suspend; /* kept enabled over suspend */ 401 __le16 event_flags; 402 __le16 event_type; 403 __le32 num_kcontrols; 404 struct snd_soc_tplg_private priv; 405 /* 406 * kcontrols that relate to this widget 407 * follow here after widget private data 408 */ 409} __attribute__((packed)); 410 411 412/* 413 * Describes SW/FW specific features of PCM (FE DAI & DAI link). 414 * 415 * File block representation for PCM :- 416 * +-----------------------------------+-----+ 417 * | struct snd_soc_tplg_hdr | 1 | 418 * +-----------------------------------+-----+ 419 * | struct snd_soc_tplg_pcm | N | 420 * +-----------------------------------+-----+ 421 */ 422struct snd_soc_tplg_pcm { 423 __le32 size; /* in bytes of this structure */ 424 char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 425 char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 426 __le32 pcm_id; /* unique ID - used to match with DAI link */ 427 __le32 dai_id; /* unique ID - used to match */ 428 __le32 playback; /* supports playback mode */ 429 __le32 capture; /* supports capture mode */ 430 __le32 compress; /* 1 = compressed; 0 = PCM */ 431 struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */ 432 __le32 num_streams; /* number of streams */ 433 struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */ 434} __attribute__((packed)); 435 436 437/* 438 * Describes the BE or CC link runtime supported configs or params 439 * 440 * File block representation for BE/CC link config :- 441 * +-----------------------------------+-----+ 442 * | struct snd_soc_tplg_hdr | 1 | 443 * +-----------------------------------+-----+ 444 * | struct snd_soc_tplg_link_config | N | 445 * +-----------------------------------+-----+ 446 */ 447struct snd_soc_tplg_link_config { 448 __le32 size; /* in bytes of this structure */ 449 __le32 id; /* unique ID - used to match */ 450 struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* supported configs playback and captrure */ 451 __le32 num_streams; /* number of streams */ 452} __attribute__((packed)); 453#endif 454