asoc.h 14 KB

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