asoc.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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 0x5
  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_BACKEND_LINK 10
  87. #define SND_SOC_TPLG_TYPE_PDATA 11
  88. #define SND_SOC_TPLG_TYPE_BE_DAI 12
  89. #define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_BE_DAI
  90. /* vendor block IDs - please add new vendor types to end */
  91. #define SND_SOC_TPLG_TYPE_VENDOR_FW 1000
  92. #define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001
  93. #define SND_SOC_TPLG_TYPE_VENDOR_COEFF 1002
  94. #define SND_SOC_TPLG_TYPEVENDOR_CODEC 1003
  95. #define SND_SOC_TPLG_STREAM_PLAYBACK 0
  96. #define SND_SOC_TPLG_STREAM_CAPTURE 1
  97. /* vendor tuple types */
  98. #define SND_SOC_TPLG_TUPLE_TYPE_UUID 0
  99. #define SND_SOC_TPLG_TUPLE_TYPE_STRING 1
  100. #define SND_SOC_TPLG_TUPLE_TYPE_BOOL 2
  101. #define SND_SOC_TPLG_TUPLE_TYPE_BYTE 3
  102. #define SND_SOC_TPLG_TUPLE_TYPE_WORD 4
  103. #define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5
  104. /* BE DAI flags */
  105. #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_RATES (1 << 0)
  106. #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS (1 << 1)
  107. #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2)
  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. __le32 sig_bits; /* number of bits of content */
  225. } __attribute__((packed));
  226. /*
  227. * FE or BE Stream configuration supported by SW/FW
  228. */
  229. struct snd_soc_tplg_stream {
  230. __le32 size; /* in bytes of this structure */
  231. char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* Name of the stream */
  232. __le64 format; /* SNDRV_PCM_FMTBIT_* */
  233. __le32 rate; /* SNDRV_PCM_RATE_* */
  234. __le32 period_bytes; /* size of period in bytes */
  235. __le32 buffer_bytes; /* size of buffer in bytes */
  236. __le32 channels; /* channels */
  237. } __attribute__((packed));
  238. /*
  239. * Manifest. List totals for each payload type. Not used in parsing, but will
  240. * be passed to the component driver before any other objects in order for any
  241. * global component resource allocations.
  242. *
  243. * File block representation for manifest :-
  244. * +-----------------------------------+----+
  245. * | struct snd_soc_tplg_hdr | 1 |
  246. * +-----------------------------------+----+
  247. * | struct snd_soc_tplg_manifest | 1 |
  248. * +-----------------------------------+----+
  249. */
  250. struct snd_soc_tplg_manifest {
  251. __le32 size; /* in bytes of this structure */
  252. __le32 control_elems; /* number of control elements */
  253. __le32 widget_elems; /* number of widget elements */
  254. __le32 graph_elems; /* number of graph elements */
  255. __le32 pcm_elems; /* number of PCM elements */
  256. __le32 dai_link_elems; /* number of DAI link elements */
  257. __le32 be_dai_elems; /* number of BE DAI elements */
  258. __le32 reserved[20]; /* reserved for new ABI element types */
  259. struct snd_soc_tplg_private priv;
  260. } __attribute__((packed));
  261. /*
  262. * Mixer kcontrol.
  263. *
  264. * File block representation for mixer kcontrol :-
  265. * +-----------------------------------+----+
  266. * | struct snd_soc_tplg_hdr | 1 |
  267. * +-----------------------------------+----+
  268. * | struct snd_soc_tplg_mixer_control | N |
  269. * +-----------------------------------+----+
  270. */
  271. struct snd_soc_tplg_mixer_control {
  272. struct snd_soc_tplg_ctl_hdr hdr;
  273. __le32 size; /* in bytes of this structure */
  274. __le32 min;
  275. __le32 max;
  276. __le32 platform_max;
  277. __le32 invert;
  278. __le32 num_channels;
  279. struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
  280. struct snd_soc_tplg_private priv;
  281. } __attribute__((packed));
  282. /*
  283. * Enumerated kcontrol
  284. *
  285. * File block representation for enum kcontrol :-
  286. * +-----------------------------------+----+
  287. * | struct snd_soc_tplg_hdr | 1 |
  288. * +-----------------------------------+----+
  289. * | struct snd_soc_tplg_enum_control | N |
  290. * +-----------------------------------+----+
  291. */
  292. struct snd_soc_tplg_enum_control {
  293. struct snd_soc_tplg_ctl_hdr hdr;
  294. __le32 size; /* in bytes of this structure */
  295. __le32 num_channels;
  296. struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
  297. __le32 items;
  298. __le32 mask;
  299. __le32 count;
  300. char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  301. __le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4];
  302. struct snd_soc_tplg_private priv;
  303. } __attribute__((packed));
  304. /*
  305. * Bytes kcontrol
  306. *
  307. * File block representation for bytes kcontrol :-
  308. * +-----------------------------------+----+
  309. * | struct snd_soc_tplg_hdr | 1 |
  310. * +-----------------------------------+----+
  311. * | struct snd_soc_tplg_bytes_control | N |
  312. * +-----------------------------------+----+
  313. */
  314. struct snd_soc_tplg_bytes_control {
  315. struct snd_soc_tplg_ctl_hdr hdr;
  316. __le32 size; /* in bytes of this structure */
  317. __le32 max;
  318. __le32 mask;
  319. __le32 base;
  320. __le32 num_regs;
  321. struct snd_soc_tplg_io_ops ext_ops;
  322. struct snd_soc_tplg_private priv;
  323. } __attribute__((packed));
  324. /*
  325. * DAPM Graph Element
  326. *
  327. * File block representation for DAPM graph elements :-
  328. * +-------------------------------------+----+
  329. * | struct snd_soc_tplg_hdr | 1 |
  330. * +-------------------------------------+----+
  331. * | struct snd_soc_tplg_dapm_graph_elem | N |
  332. * +-------------------------------------+----+
  333. */
  334. struct snd_soc_tplg_dapm_graph_elem {
  335. char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  336. char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  337. char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  338. } __attribute__((packed));
  339. /*
  340. * DAPM Widget.
  341. *
  342. * File block representation for DAPM widget :-
  343. * +-------------------------------------+-----+
  344. * | struct snd_soc_tplg_hdr | 1 |
  345. * +-------------------------------------+-----+
  346. * | struct snd_soc_tplg_dapm_widget | N |
  347. * +-------------------------------------+-----+
  348. * | struct snd_soc_tplg_enum_control | 0|1 |
  349. * | struct snd_soc_tplg_mixer_control | 0|N |
  350. * +-------------------------------------+-----+
  351. *
  352. * Optional enum or mixer control can be appended to the end of each widget
  353. * in the block.
  354. */
  355. struct snd_soc_tplg_dapm_widget {
  356. __le32 size; /* in bytes of this structure */
  357. __le32 id; /* SND_SOC_DAPM_CTL */
  358. char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  359. char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  360. __le32 reg; /* negative reg = no direct dapm */
  361. __le32 shift; /* bits to shift */
  362. __le32 mask; /* non-shifted mask */
  363. __le32 subseq; /* sort within widget type */
  364. __le32 invert; /* invert the power bit */
  365. __le32 ignore_suspend; /* kept enabled over suspend */
  366. __le16 event_flags;
  367. __le16 event_type;
  368. __le32 num_kcontrols;
  369. struct snd_soc_tplg_private priv;
  370. /*
  371. * kcontrols that relate to this widget
  372. * follow here after widget private data
  373. */
  374. } __attribute__((packed));
  375. /*
  376. * Describes SW/FW specific features of PCM (FE DAI & DAI link).
  377. *
  378. * File block representation for PCM :-
  379. * +-----------------------------------+-----+
  380. * | struct snd_soc_tplg_hdr | 1 |
  381. * +-----------------------------------+-----+
  382. * | struct snd_soc_tplg_pcm | N |
  383. * +-----------------------------------+-----+
  384. */
  385. struct snd_soc_tplg_pcm {
  386. __le32 size; /* in bytes of this structure */
  387. char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  388. char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  389. __le32 pcm_id; /* unique ID - used to match with DAI link */
  390. __le32 dai_id; /* unique ID - used to match */
  391. __le32 playback; /* supports playback mode */
  392. __le32 capture; /* supports capture mode */
  393. __le32 compress; /* 1 = compressed; 0 = PCM */
  394. struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */
  395. __le32 num_streams; /* number of streams */
  396. struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */
  397. } __attribute__((packed));
  398. /*
  399. * Describes the BE or CC link runtime supported configs or params
  400. *
  401. * File block representation for BE/CC link config :-
  402. * +-----------------------------------+-----+
  403. * | struct snd_soc_tplg_hdr | 1 |
  404. * +-----------------------------------+-----+
  405. * | struct snd_soc_tplg_link_config | N |
  406. * +-----------------------------------+-----+
  407. */
  408. struct snd_soc_tplg_link_config {
  409. __le32 size; /* in bytes of this structure */
  410. __le32 id; /* unique ID - used to match */
  411. struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* supported configs playback and captrure */
  412. __le32 num_streams; /* number of streams */
  413. } __attribute__((packed));
  414. /*
  415. * Describes SW/FW specific features of BE DAI.
  416. *
  417. * File block representation for BE DAI :-
  418. * +-----------------------------------+-----+
  419. * | struct snd_soc_tplg_hdr | 1 |
  420. * +-----------------------------------+-----+
  421. * | struct snd_soc_tplg_be_dai | N |
  422. * +-----------------------------------+-----+
  423. */
  424. struct snd_soc_tplg_be_dai {
  425. __le32 size; /* in bytes of this structure */
  426. char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* name - used to match */
  427. __le32 dai_id; /* unique ID - used to match */
  428. __le32 playback; /* supports playback mode */
  429. __le32 capture; /* supports capture mode */
  430. struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */
  431. __le32 flag_mask; /* bitmask of flags to configure */
  432. __le32 flags; /* SND_SOC_TPLG_DAI_FLGBIT_* */
  433. struct snd_soc_tplg_private priv;
  434. } __attribute__((packed));
  435. #endif