asoc.h 12 KB

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