asoc.h 12 KB

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