asoc.h 12 KB

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