asoc.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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 0x4
  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_MAX SND_SOC_TPLG_TYPE_PDATA
  94. /* vendor block IDs - please add new vendor types to end */
  95. #define SND_SOC_TPLG_TYPE_VENDOR_FW 1000
  96. #define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001
  97. #define SND_SOC_TPLG_TYPE_VENDOR_COEFF 1002
  98. #define SND_SOC_TPLG_TYPEVENDOR_CODEC 1003
  99. #define SND_SOC_TPLG_STREAM_PLAYBACK 0
  100. #define SND_SOC_TPLG_STREAM_CAPTURE 1
  101. /* vendor tuple types */
  102. #define SND_SOC_TPLG_TUPLE_TYPE_UUID 0
  103. #define SND_SOC_TPLG_TUPLE_TYPE_STRING 1
  104. #define SND_SOC_TPLG_TUPLE_TYPE_BOOL 2
  105. #define SND_SOC_TPLG_TUPLE_TYPE_BYTE 3
  106. #define SND_SOC_TPLG_TUPLE_TYPE_WORD 4
  107. #define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5
  108. /*
  109. * Block Header.
  110. * This header precedes all object and object arrays below.
  111. */
  112. struct snd_soc_tplg_hdr {
  113. __le32 magic; /* magic number */
  114. __le32 abi; /* ABI version */
  115. __le32 version; /* optional vendor specific version details */
  116. __le32 type; /* SND_SOC_TPLG_TYPE_ */
  117. __le32 size; /* size of this structure */
  118. __le32 vendor_type; /* optional vendor specific type info */
  119. __le32 payload_size; /* data bytes, excluding this header */
  120. __le32 index; /* identifier for block */
  121. __le32 count; /* number of elements in block */
  122. } __attribute__((packed));
  123. /* vendor tuple for uuid */
  124. struct snd_soc_tplg_vendor_uuid_elem {
  125. __le32 token;
  126. char uuid[16];
  127. } __attribute__((packed));
  128. /* vendor tuple for a bool/byte/short/word value */
  129. struct snd_soc_tplg_vendor_value_elem {
  130. __le32 token;
  131. __le32 value;
  132. } __attribute__((packed));
  133. /* vendor tuple for string */
  134. struct snd_soc_tplg_vendor_string_elem {
  135. __le32 token;
  136. char string[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  137. } __attribute__((packed));
  138. struct snd_soc_tplg_vendor_array {
  139. __le32 size; /* size in bytes of the array, including all elements */
  140. __le32 type; /* SND_SOC_TPLG_TUPLE_TYPE_ */
  141. __le32 num_elems; /* number of elements in array */
  142. union {
  143. struct snd_soc_tplg_vendor_uuid_elem uuid[0];
  144. struct snd_soc_tplg_vendor_value_elem value[0];
  145. struct snd_soc_tplg_vendor_string_elem string[0];
  146. };
  147. } __attribute__((packed));
  148. /*
  149. * Private data.
  150. * All topology objects may have private data that can be used by the driver or
  151. * firmware. Core will ignore this data.
  152. */
  153. struct snd_soc_tplg_private {
  154. __le32 size; /* in bytes of private data */
  155. union {
  156. char data[0];
  157. struct snd_soc_tplg_vendor_array array[0];
  158. };
  159. } __attribute__((packed));
  160. /*
  161. * Kcontrol TLV data.
  162. */
  163. struct snd_soc_tplg_tlv_dbscale {
  164. __le32 min;
  165. __le32 step;
  166. __le32 mute;
  167. } __attribute__((packed));
  168. struct snd_soc_tplg_ctl_tlv {
  169. __le32 size; /* in bytes of this structure */
  170. __le32 type; /* SNDRV_CTL_TLVT_*, type of TLV */
  171. union {
  172. __le32 data[SND_SOC_TPLG_TLV_SIZE];
  173. struct snd_soc_tplg_tlv_dbscale scale;
  174. };
  175. } __attribute__((packed));
  176. /*
  177. * Kcontrol channel data
  178. */
  179. struct snd_soc_tplg_channel {
  180. __le32 size; /* in bytes of this structure */
  181. __le32 reg;
  182. __le32 shift;
  183. __le32 id; /* ID maps to Left, Right, LFE etc */
  184. } __attribute__((packed));
  185. /*
  186. * Genericl Operations IDs, for binding Kcontrol or Bytes ext ops
  187. * Kcontrol ops need get/put/info.
  188. * Bytes ext ops need get/put.
  189. */
  190. struct snd_soc_tplg_io_ops {
  191. __le32 get;
  192. __le32 put;
  193. __le32 info;
  194. } __attribute__((packed));
  195. /*
  196. * kcontrol header
  197. */
  198. struct snd_soc_tplg_ctl_hdr {
  199. __le32 size; /* in bytes of this structure */
  200. __le32 type;
  201. char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  202. __le32 access;
  203. struct snd_soc_tplg_io_ops ops;
  204. struct snd_soc_tplg_ctl_tlv tlv;
  205. } __attribute__((packed));
  206. /*
  207. * Stream Capabilities
  208. */
  209. struct snd_soc_tplg_stream_caps {
  210. __le32 size; /* in bytes of this structure */
  211. char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  212. __le64 formats; /* supported formats SNDRV_PCM_FMTBIT_* */
  213. __le32 rates; /* supported rates SNDRV_PCM_RATE_* */
  214. __le32 rate_min; /* min rate */
  215. __le32 rate_max; /* max rate */
  216. __le32 channels_min; /* min channels */
  217. __le32 channels_max; /* max channels */
  218. __le32 periods_min; /* min number of periods */
  219. __le32 periods_max; /* max number of periods */
  220. __le32 period_size_min; /* min period size bytes */
  221. __le32 period_size_max; /* max period size bytes */
  222. __le32 buffer_size_min; /* min buffer size bytes */
  223. __le32 buffer_size_max; /* max buffer size bytes */
  224. } __attribute__((packed));
  225. /*
  226. * FE or BE Stream configuration supported by SW/FW
  227. */
  228. struct snd_soc_tplg_stream {
  229. __le32 size; /* in bytes of this structure */
  230. char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* Name of the stream */
  231. __le64 format; /* SNDRV_PCM_FMTBIT_* */
  232. __le32 rate; /* SNDRV_PCM_RATE_* */
  233. __le32 period_bytes; /* size of period in bytes */
  234. __le32 buffer_bytes; /* size of buffer in bytes */
  235. __le32 channels; /* channels */
  236. } __attribute__((packed));
  237. /*
  238. * Manifest. List totals for each payload type. Not used in parsing, but will
  239. * be passed to the component driver before any other objects in order for any
  240. * global component resource allocations.
  241. *
  242. * File block representation for manifest :-
  243. * +-----------------------------------+----+
  244. * | struct snd_soc_tplg_hdr | 1 |
  245. * +-----------------------------------+----+
  246. * | struct snd_soc_tplg_manifest | 1 |
  247. * +-----------------------------------+----+
  248. */
  249. struct snd_soc_tplg_manifest {
  250. __le32 size; /* in bytes of this structure */
  251. __le32 control_elems; /* number of control elements */
  252. __le32 widget_elems; /* number of widget elements */
  253. __le32 graph_elems; /* number of graph elements */
  254. __le32 pcm_elems; /* number of PCM elements */
  255. __le32 dai_link_elems; /* number of DAI link elements */
  256. struct snd_soc_tplg_private priv;
  257. } __attribute__((packed));
  258. /*
  259. * Mixer kcontrol.
  260. *
  261. * File block representation for mixer kcontrol :-
  262. * +-----------------------------------+----+
  263. * | struct snd_soc_tplg_hdr | 1 |
  264. * +-----------------------------------+----+
  265. * | struct snd_soc_tplg_mixer_control | N |
  266. * +-----------------------------------+----+
  267. */
  268. struct snd_soc_tplg_mixer_control {
  269. struct snd_soc_tplg_ctl_hdr hdr;
  270. __le32 size; /* in bytes of this structure */
  271. __le32 min;
  272. __le32 max;
  273. __le32 platform_max;
  274. __le32 invert;
  275. __le32 num_channels;
  276. struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
  277. struct snd_soc_tplg_private priv;
  278. } __attribute__((packed));
  279. /*
  280. * Enumerated kcontrol
  281. *
  282. * File block representation for enum kcontrol :-
  283. * +-----------------------------------+----+
  284. * | struct snd_soc_tplg_hdr | 1 |
  285. * +-----------------------------------+----+
  286. * | struct snd_soc_tplg_enum_control | N |
  287. * +-----------------------------------+----+
  288. */
  289. struct snd_soc_tplg_enum_control {
  290. struct snd_soc_tplg_ctl_hdr hdr;
  291. __le32 size; /* in bytes of this structure */
  292. __le32 num_channels;
  293. struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
  294. __le32 items;
  295. __le32 mask;
  296. __le32 count;
  297. char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  298. __le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4];
  299. struct snd_soc_tplg_private priv;
  300. } __attribute__((packed));
  301. /*
  302. * Bytes kcontrol
  303. *
  304. * File block representation for bytes kcontrol :-
  305. * +-----------------------------------+----+
  306. * | struct snd_soc_tplg_hdr | 1 |
  307. * +-----------------------------------+----+
  308. * | struct snd_soc_tplg_bytes_control | N |
  309. * +-----------------------------------+----+
  310. */
  311. struct snd_soc_tplg_bytes_control {
  312. struct snd_soc_tplg_ctl_hdr hdr;
  313. __le32 size; /* in bytes of this structure */
  314. __le32 max;
  315. __le32 mask;
  316. __le32 base;
  317. __le32 num_regs;
  318. struct snd_soc_tplg_io_ops ext_ops;
  319. struct snd_soc_tplg_private priv;
  320. } __attribute__((packed));
  321. /*
  322. * DAPM Graph Element
  323. *
  324. * File block representation for DAPM graph elements :-
  325. * +-------------------------------------+----+
  326. * | struct snd_soc_tplg_hdr | 1 |
  327. * +-------------------------------------+----+
  328. * | struct snd_soc_tplg_dapm_graph_elem | N |
  329. * +-------------------------------------+----+
  330. */
  331. struct snd_soc_tplg_dapm_graph_elem {
  332. char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  333. char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  334. char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  335. } __attribute__((packed));
  336. /*
  337. * DAPM Widget.
  338. *
  339. * File block representation for DAPM widget :-
  340. * +-------------------------------------+-----+
  341. * | struct snd_soc_tplg_hdr | 1 |
  342. * +-------------------------------------+-----+
  343. * | struct snd_soc_tplg_dapm_widget | N |
  344. * +-------------------------------------+-----+
  345. * | struct snd_soc_tplg_enum_control | 0|1 |
  346. * | struct snd_soc_tplg_mixer_control | 0|N |
  347. * +-------------------------------------+-----+
  348. *
  349. * Optional enum or mixer control can be appended to the end of each widget
  350. * in the block.
  351. */
  352. struct snd_soc_tplg_dapm_widget {
  353. __le32 size; /* in bytes of this structure */
  354. __le32 id; /* SND_SOC_DAPM_CTL */
  355. char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  356. char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  357. __le32 reg; /* negative reg = no direct dapm */
  358. __le32 shift; /* bits to shift */
  359. __le32 mask; /* non-shifted mask */
  360. __le32 subseq; /* sort within widget type */
  361. __le32 invert; /* invert the power bit */
  362. __le32 ignore_suspend; /* kept enabled over suspend */
  363. __le16 event_flags;
  364. __le16 event_type;
  365. __le32 num_kcontrols;
  366. struct snd_soc_tplg_private priv;
  367. /*
  368. * kcontrols that relate to this widget
  369. * follow here after widget private data
  370. */
  371. } __attribute__((packed));
  372. /*
  373. * Describes SW/FW specific features of PCM (FE DAI & DAI link).
  374. *
  375. * File block representation for PCM :-
  376. * +-----------------------------------+-----+
  377. * | struct snd_soc_tplg_hdr | 1 |
  378. * +-----------------------------------+-----+
  379. * | struct snd_soc_tplg_pcm | N |
  380. * +-----------------------------------+-----+
  381. */
  382. struct snd_soc_tplg_pcm {
  383. __le32 size; /* in bytes of this structure */
  384. char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  385. char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  386. __le32 pcm_id; /* unique ID - used to match with DAI link */
  387. __le32 dai_id; /* unique ID - used to match */
  388. __le32 playback; /* supports playback mode */
  389. __le32 capture; /* supports capture mode */
  390. __le32 compress; /* 1 = compressed; 0 = PCM */
  391. struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */
  392. __le32 num_streams; /* number of streams */
  393. struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */
  394. } __attribute__((packed));
  395. /*
  396. * Describes the BE or CC link runtime supported configs or params
  397. *
  398. * File block representation for BE/CC link config :-
  399. * +-----------------------------------+-----+
  400. * | struct snd_soc_tplg_hdr | 1 |
  401. * +-----------------------------------+-----+
  402. * | struct snd_soc_tplg_link_config | N |
  403. * +-----------------------------------+-----+
  404. */
  405. struct snd_soc_tplg_link_config {
  406. __le32 size; /* in bytes of this structure */
  407. __le32 id; /* unique ID - used to match */
  408. struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* supported configs playback and captrure */
  409. __le32 num_streams; /* number of streams */
  410. } __attribute__((packed));
  411. #endif