asoc.h 13 KB

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