asoc.h 15 KB

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