msm_audio.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. /* include/linux/msm_audio.h
  2. *
  3. * Copyright (C) 2008 Google, Inc.
  4. * Copyright (c) 2012, 2014, 2017 The Linux Foundation. All rights reserved.
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef _UAPI_LINUX_MSM_AUDIO_H
  17. #define _UAPI_LINUX_MSM_AUDIO_H
  18. #include <linux/types.h>
  19. #include <linux/ioctl.h>
  20. /* PCM Audio */
  21. #define AUDIO_IOCTL_MAGIC 'a'
  22. #define AUDIO_START _IOW(AUDIO_IOCTL_MAGIC, 0, unsigned int)
  23. #define AUDIO_STOP _IOW(AUDIO_IOCTL_MAGIC, 1, unsigned int)
  24. #define AUDIO_FLUSH _IOW(AUDIO_IOCTL_MAGIC, 2, unsigned int)
  25. #define AUDIO_GET_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 3, \
  26. struct msm_audio_config)
  27. #define AUDIO_SET_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 4, \
  28. struct msm_audio_config)
  29. #define AUDIO_GET_STATS _IOR(AUDIO_IOCTL_MAGIC, 5, \
  30. struct msm_audio_stats)
  31. #define AUDIO_ENABLE_AUDPP _IOW(AUDIO_IOCTL_MAGIC, 6, unsigned int)
  32. #define AUDIO_SET_ADRC _IOW(AUDIO_IOCTL_MAGIC, 7, unsigned int)
  33. #define AUDIO_SET_EQ _IOW(AUDIO_IOCTL_MAGIC, 8, unsigned int)
  34. #define AUDIO_SET_RX_IIR _IOW(AUDIO_IOCTL_MAGIC, 9, unsigned int)
  35. #define AUDIO_SET_VOLUME _IOW(AUDIO_IOCTL_MAGIC, 10, unsigned int)
  36. #define AUDIO_PAUSE _IOW(AUDIO_IOCTL_MAGIC, 11, unsigned int)
  37. #define AUDIO_PLAY_DTMF _IOW(AUDIO_IOCTL_MAGIC, 12, unsigned int)
  38. #define AUDIO_GET_EVENT _IOR(AUDIO_IOCTL_MAGIC, 13, \
  39. struct msm_audio_event)
  40. #define AUDIO_ABORT_GET_EVENT _IOW(AUDIO_IOCTL_MAGIC, 14, unsigned int)
  41. #define AUDIO_REGISTER_PMEM _IOW(AUDIO_IOCTL_MAGIC, 15, unsigned int)
  42. #define AUDIO_DEREGISTER_PMEM _IOW(AUDIO_IOCTL_MAGIC, 16, unsigned int)
  43. #define AUDIO_ASYNC_WRITE _IOW(AUDIO_IOCTL_MAGIC, 17, \
  44. struct msm_audio_aio_buf)
  45. #define AUDIO_ASYNC_READ _IOW(AUDIO_IOCTL_MAGIC, 18, \
  46. struct msm_audio_aio_buf)
  47. #define AUDIO_SET_INCALL _IOW(AUDIO_IOCTL_MAGIC, 19, struct msm_voicerec_mode)
  48. #define AUDIO_GET_NUM_SND_DEVICE _IOR(AUDIO_IOCTL_MAGIC, 20, unsigned int)
  49. #define AUDIO_GET_SND_DEVICES _IOWR(AUDIO_IOCTL_MAGIC, 21, \
  50. struct msm_snd_device_list)
  51. #define AUDIO_ENABLE_SND_DEVICE _IOW(AUDIO_IOCTL_MAGIC, 22, unsigned int)
  52. #define AUDIO_DISABLE_SND_DEVICE _IOW(AUDIO_IOCTL_MAGIC, 23, unsigned int)
  53. #define AUDIO_ROUTE_STREAM _IOW(AUDIO_IOCTL_MAGIC, 24, \
  54. struct msm_audio_route_config)
  55. #define AUDIO_GET_PCM_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 30, unsigned int)
  56. #define AUDIO_SET_PCM_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 31, unsigned int)
  57. #define AUDIO_SWITCH_DEVICE _IOW(AUDIO_IOCTL_MAGIC, 32, unsigned int)
  58. #define AUDIO_SET_MUTE _IOW(AUDIO_IOCTL_MAGIC, 33, unsigned int)
  59. #define AUDIO_UPDATE_ACDB _IOW(AUDIO_IOCTL_MAGIC, 34, unsigned int)
  60. #define AUDIO_START_VOICE _IOW(AUDIO_IOCTL_MAGIC, 35, unsigned int)
  61. #define AUDIO_STOP_VOICE _IOW(AUDIO_IOCTL_MAGIC, 36, unsigned int)
  62. #define AUDIO_REINIT_ACDB _IOW(AUDIO_IOCTL_MAGIC, 39, unsigned int)
  63. #define AUDIO_OUTPORT_FLUSH _IOW(AUDIO_IOCTL_MAGIC, 40, unsigned short)
  64. #define AUDIO_SET_ERR_THRESHOLD_VALUE _IOW(AUDIO_IOCTL_MAGIC, 41, \
  65. unsigned short)
  66. #define AUDIO_GET_BITSTREAM_ERROR_INFO _IOR(AUDIO_IOCTL_MAGIC, 42, \
  67. struct msm_audio_bitstream_error_info)
  68. #define AUDIO_SET_SRS_TRUMEDIA_PARAM _IOW(AUDIO_IOCTL_MAGIC, 43, unsigned int)
  69. /* Qualcomm technologies inc extensions */
  70. #define AUDIO_SET_STREAM_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 80, \
  71. struct msm_audio_stream_config)
  72. #define AUDIO_GET_STREAM_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 81, \
  73. struct msm_audio_stream_config)
  74. #define AUDIO_GET_SESSION_ID _IOR(AUDIO_IOCTL_MAGIC, 82, unsigned short)
  75. #define AUDIO_GET_STREAM_INFO _IOR(AUDIO_IOCTL_MAGIC, 83, \
  76. struct msm_audio_bitstream_info)
  77. #define AUDIO_SET_PAN _IOW(AUDIO_IOCTL_MAGIC, 84, unsigned int)
  78. #define AUDIO_SET_QCONCERT_PLUS _IOW(AUDIO_IOCTL_MAGIC, 85, unsigned int)
  79. #define AUDIO_SET_MBADRC _IOW(AUDIO_IOCTL_MAGIC, 86, unsigned int)
  80. #define AUDIO_SET_VOLUME_PATH _IOW(AUDIO_IOCTL_MAGIC, 87, \
  81. struct msm_vol_info)
  82. #define AUDIO_SET_MAX_VOL_ALL _IOW(AUDIO_IOCTL_MAGIC, 88, unsigned int)
  83. #define AUDIO_ENABLE_AUDPRE _IOW(AUDIO_IOCTL_MAGIC, 89, unsigned int)
  84. #define AUDIO_SET_AGC _IOW(AUDIO_IOCTL_MAGIC, 90, unsigned int)
  85. #define AUDIO_SET_NS _IOW(AUDIO_IOCTL_MAGIC, 91, unsigned int)
  86. #define AUDIO_SET_TX_IIR _IOW(AUDIO_IOCTL_MAGIC, 92, unsigned int)
  87. #define AUDIO_GET_BUF_CFG _IOW(AUDIO_IOCTL_MAGIC, 93, \
  88. struct msm_audio_buf_cfg)
  89. #define AUDIO_SET_BUF_CFG _IOW(AUDIO_IOCTL_MAGIC, 94, \
  90. struct msm_audio_buf_cfg)
  91. #define AUDIO_SET_ACDB_BLK _IOW(AUDIO_IOCTL_MAGIC, 95, \
  92. struct msm_acdb_cmd_device)
  93. #define AUDIO_GET_ACDB_BLK _IOW(AUDIO_IOCTL_MAGIC, 96, \
  94. struct msm_acdb_cmd_device)
  95. #define AUDIO_REGISTER_ION _IOW(AUDIO_IOCTL_MAGIC, 97, \
  96. struct msm_audio_ion_info)
  97. #define AUDIO_DEREGISTER_ION _IOW(AUDIO_IOCTL_MAGIC, 98, \
  98. struct msm_audio_ion_info)
  99. #define AUDIO_SET_EFFECTS_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 99, \
  100. struct msm_hwacc_effects_config)
  101. #define AUDIO_EFFECTS_SET_BUF_LEN _IOW(AUDIO_IOCTL_MAGIC, 100, \
  102. struct msm_hwacc_buf_cfg)
  103. #define AUDIO_EFFECTS_GET_BUF_AVAIL _IOW(AUDIO_IOCTL_MAGIC, 101, \
  104. struct msm_hwacc_buf_avail)
  105. #define AUDIO_EFFECTS_WRITE _IOW(AUDIO_IOCTL_MAGIC, 102, void *)
  106. #define AUDIO_EFFECTS_READ _IOWR(AUDIO_IOCTL_MAGIC, 103, void *)
  107. #define AUDIO_EFFECTS_SET_PP_PARAMS _IOW(AUDIO_IOCTL_MAGIC, 104, void *)
  108. #define AUDIO_PM_AWAKE _IOW(AUDIO_IOCTL_MAGIC, 105, unsigned int)
  109. #define AUDIO_PM_RELAX _IOW(AUDIO_IOCTL_MAGIC, 106, unsigned int)
  110. #define AUDIO_MAX_COMMON_IOCTL_NUM 107
  111. #define HANDSET_MIC 0x01
  112. #define HANDSET_SPKR 0x02
  113. #define HEADSET_MIC 0x03
  114. #define HEADSET_SPKR_MONO 0x04
  115. #define HEADSET_SPKR_STEREO 0x05
  116. #define SPKR_PHONE_MIC 0x06
  117. #define SPKR_PHONE_MONO 0x07
  118. #define SPKR_PHONE_STEREO 0x08
  119. #define BT_SCO_MIC 0x09
  120. #define BT_SCO_SPKR 0x0A
  121. #define BT_A2DP_SPKR 0x0B
  122. #define TTY_HEADSET_MIC 0x0C
  123. #define TTY_HEADSET_SPKR 0x0D
  124. /* Default devices are not supported in a */
  125. /* device switching context. Only supported */
  126. /* for stream devices. */
  127. /* DO NOT USE */
  128. #define DEFAULT_TX 0x0E
  129. #define DEFAULT_RX 0x0F
  130. #define BT_A2DP_TX 0x10
  131. #define HEADSET_MONO_PLUS_SPKR_MONO_RX 0x11
  132. #define HEADSET_MONO_PLUS_SPKR_STEREO_RX 0x12
  133. #define HEADSET_STEREO_PLUS_SPKR_MONO_RX 0x13
  134. #define HEADSET_STEREO_PLUS_SPKR_STEREO_RX 0x14
  135. #define I2S_RX 0x20
  136. #define I2S_TX 0x21
  137. #define ADRC_ENABLE 0x0001
  138. #define EQUALIZER_ENABLE 0x0002
  139. #define IIR_ENABLE 0x0004
  140. #define QCONCERT_PLUS_ENABLE 0x0008
  141. #define MBADRC_ENABLE 0x0010
  142. #define SRS_ENABLE 0x0020
  143. #define SRS_DISABLE 0x0040
  144. #define AGC_ENABLE 0x0001
  145. #define NS_ENABLE 0x0002
  146. #define TX_IIR_ENABLE 0x0004
  147. #define FLUENCE_ENABLE 0x0008
  148. #define VOC_REC_UPLINK 0x00
  149. #define VOC_REC_DOWNLINK 0x01
  150. #define VOC_REC_BOTH 0x02
  151. struct msm_audio_config {
  152. uint32_t buffer_size;
  153. uint32_t buffer_count;
  154. uint32_t channel_count;
  155. uint32_t sample_rate;
  156. uint32_t type;
  157. uint32_t meta_field;
  158. uint32_t bits;
  159. uint32_t unused[3];
  160. };
  161. struct msm_audio_stream_config {
  162. uint32_t buffer_size;
  163. uint32_t buffer_count;
  164. };
  165. struct msm_audio_buf_cfg {
  166. uint32_t meta_info_enable;
  167. uint32_t frames_per_buf;
  168. };
  169. struct msm_audio_stats {
  170. uint32_t byte_count;
  171. uint32_t sample_count;
  172. uint32_t unused[2];
  173. };
  174. struct msm_audio_ion_info {
  175. int fd;
  176. void *vaddr;
  177. };
  178. struct msm_audio_pmem_info {
  179. int fd;
  180. void *vaddr;
  181. };
  182. struct msm_audio_aio_buf {
  183. void *buf_addr;
  184. uint32_t buf_len;
  185. uint32_t data_len;
  186. void *private_data;
  187. unsigned short mfield_sz; /*only useful for data has meta field */
  188. };
  189. /* Audio routing */
  190. #define SND_IOCTL_MAGIC 's'
  191. #define SND_MUTE_UNMUTED 0
  192. #define SND_MUTE_MUTED 1
  193. struct msm_mute_info {
  194. uint32_t mute;
  195. uint32_t path;
  196. };
  197. struct msm_vol_info {
  198. uint32_t vol;
  199. uint32_t path;
  200. };
  201. struct msm_voicerec_mode {
  202. uint32_t rec_mode;
  203. };
  204. struct msm_snd_device_config {
  205. uint32_t device;
  206. uint32_t ear_mute;
  207. uint32_t mic_mute;
  208. };
  209. #define SND_SET_DEVICE _IOW(SND_IOCTL_MAGIC, 2, struct msm_device_config *)
  210. enum cad_device_path_type {
  211. CAD_DEVICE_PATH_RX, /*For Decoding session*/
  212. CAD_DEVICE_PATH_TX, /* For Encoding session*/
  213. CAD_DEVICE_PATH_RX_TX, /* For Voice call */
  214. CAD_DEVICE_PATH_LB, /* For loopback (FM Analog)*/
  215. CAD_DEVICE_PATH_MAX
  216. };
  217. struct cad_devices_type {
  218. uint32_t rx_device;
  219. uint32_t tx_device;
  220. enum cad_device_path_type pathtype;
  221. };
  222. struct msm_cad_device_config {
  223. struct cad_devices_type device;
  224. uint32_t ear_mute;
  225. uint32_t mic_mute;
  226. };
  227. #define CAD_SET_DEVICE _IOW(SND_IOCTL_MAGIC, 2, struct msm_cad_device_config *)
  228. #define SND_METHOD_VOICE 0
  229. #define SND_METHOD_MIDI 4
  230. struct msm_snd_volume_config {
  231. uint32_t device;
  232. uint32_t method;
  233. uint32_t volume;
  234. };
  235. #define SND_SET_VOLUME _IOW(SND_IOCTL_MAGIC, 3, struct msm_snd_volume_config *)
  236. struct msm_cad_volume_config {
  237. struct cad_devices_type device;
  238. uint32_t method;
  239. uint32_t volume;
  240. };
  241. #define CAD_SET_VOLUME _IOW(SND_IOCTL_MAGIC, 3, struct msm_cad_volume_config *)
  242. /* Returns the number of SND endpoints supported. */
  243. #define SND_GET_NUM_ENDPOINTS _IOR(SND_IOCTL_MAGIC, 4, unsigned int *)
  244. struct msm_snd_endpoint {
  245. int id; /* input and output */
  246. char name[64]; /* output only */
  247. };
  248. /* Takes an index between 0 and one less than the number returned by
  249. * SND_GET_NUM_ENDPOINTS, and returns the SND index and name of a
  250. * SND endpoint. On input, the .id field contains the number of the
  251. * endpoint, and on exit it contains the SND index, while .name contains
  252. * the description of the endpoint.
  253. */
  254. #define SND_GET_ENDPOINT _IOWR(SND_IOCTL_MAGIC, 5, struct msm_snd_endpoint *)
  255. #define SND_AVC_CTL _IOW(SND_IOCTL_MAGIC, 6, unsigned int *)
  256. #define SND_AGC_CTL _IOW(SND_IOCTL_MAGIC, 7, unsigned int *)
  257. /*return the number of CAD endpoints supported. */
  258. #define CAD_GET_NUM_ENDPOINTS _IOR(SND_IOCTL_MAGIC, 4, unsigned int *)
  259. struct msm_cad_endpoint {
  260. int id; /* input and output */
  261. char name[64]; /* output only */
  262. };
  263. /* Takes an index between 0 and one less than the number returned by
  264. * SND_GET_NUM_ENDPOINTS, and returns the CAD index and name of a
  265. * CAD endpoint. On input, the .id field contains the number of the
  266. * endpoint, and on exit it contains the SND index, while .name contains
  267. * the description of the endpoint.
  268. */
  269. #define CAD_GET_ENDPOINT _IOWR(SND_IOCTL_MAGIC, 5, struct msm_cad_endpoint *)
  270. struct msm_audio_pcm_config {
  271. uint32_t pcm_feedback; /* 0 - disable > 0 - enable */
  272. uint32_t buffer_count; /* Number of buffers to allocate */
  273. uint32_t buffer_size; /* Size of buffer for capturing of
  274. * PCM samples
  275. */
  276. };
  277. #define AUDIO_EVENT_SUSPEND 0
  278. #define AUDIO_EVENT_RESUME 1
  279. #define AUDIO_EVENT_WRITE_DONE 2
  280. #define AUDIO_EVENT_READ_DONE 3
  281. #define AUDIO_EVENT_STREAM_INFO 4
  282. #define AUDIO_EVENT_BITSTREAM_ERROR_INFO 5
  283. #define AUDIO_CODEC_TYPE_MP3 0
  284. #define AUDIO_CODEC_TYPE_AAC 1
  285. struct msm_audio_bitstream_info {
  286. uint32_t codec_type;
  287. uint32_t chan_info;
  288. uint32_t sample_rate;
  289. uint32_t bit_stream_info;
  290. uint32_t bit_rate;
  291. uint32_t unused[3];
  292. };
  293. struct msm_audio_bitstream_error_info {
  294. uint32_t dec_id;
  295. uint32_t err_msg_indicator;
  296. uint32_t err_type;
  297. };
  298. union msm_audio_event_payload {
  299. struct msm_audio_aio_buf aio_buf;
  300. struct msm_audio_bitstream_info stream_info;
  301. struct msm_audio_bitstream_error_info error_info;
  302. int reserved;
  303. };
  304. struct msm_audio_event {
  305. int event_type;
  306. int timeout_ms;
  307. union msm_audio_event_payload event_payload;
  308. };
  309. #define MSM_SNDDEV_CAP_RX 0x1
  310. #define MSM_SNDDEV_CAP_TX 0x2
  311. #define MSM_SNDDEV_CAP_VOICE 0x4
  312. struct msm_snd_device_info {
  313. uint32_t dev_id;
  314. uint32_t dev_cap; /* bitmask describe capability of device */
  315. char dev_name[64];
  316. };
  317. struct msm_snd_device_list {
  318. uint32_t num_dev; /* Indicate number of device info to be retrieved */
  319. struct msm_snd_device_info *list;
  320. };
  321. struct msm_dtmf_config {
  322. uint16_t path;
  323. uint16_t dtmf_hi;
  324. uint16_t dtmf_low;
  325. uint16_t duration;
  326. uint16_t tx_gain;
  327. uint16_t rx_gain;
  328. uint16_t mixing;
  329. };
  330. #define AUDIO_ROUTE_STREAM_VOICE_RX 0
  331. #define AUDIO_ROUTE_STREAM_VOICE_TX 1
  332. #define AUDIO_ROUTE_STREAM_PLAYBACK 2
  333. #define AUDIO_ROUTE_STREAM_REC 3
  334. struct msm_audio_route_config {
  335. uint32_t stream_type;
  336. uint32_t stream_id;
  337. uint32_t dev_id;
  338. };
  339. #define AUDIO_MAX_EQ_BANDS 12
  340. struct msm_audio_eq_band {
  341. uint16_t band_idx; /* The band index, 0 .. 11 */
  342. uint32_t filter_type; /* Filter band type */
  343. uint32_t center_freq_hz; /* Filter band center frequency */
  344. uint32_t filter_gain; /* Filter band initial gain (dB) */
  345. /* Range is +12 dB to -12 dB with 1dB increments. */
  346. uint32_t q_factor;
  347. } __attribute__ ((packed));
  348. struct msm_audio_eq_stream_config {
  349. uint32_t enable; /* Number of consequtive bands specified */
  350. uint32_t num_bands;
  351. struct msm_audio_eq_band eq_bands[AUDIO_MAX_EQ_BANDS];
  352. } __attribute__ ((packed));
  353. struct msm_acdb_cmd_device {
  354. uint32_t command_id;
  355. uint32_t device_id;
  356. uint32_t network_id;
  357. uint32_t sample_rate_id; /* Actual sample rate value */
  358. uint32_t interface_id; /* See interface id's above */
  359. uint32_t algorithm_block_id; /* See enumerations above */
  360. uint32_t total_bytes; /* Length in bytes used by buffer */
  361. uint32_t *phys_buf; /* Physical Address of data */
  362. };
  363. struct msm_hwacc_data_config {
  364. __u32 buf_size;
  365. __u32 num_buf;
  366. __u32 num_channels;
  367. __u8 channel_map[8];
  368. __u32 sample_rate;
  369. __u32 bits_per_sample;
  370. };
  371. struct msm_hwacc_buf_cfg {
  372. __u32 input_len;
  373. __u32 output_len;
  374. };
  375. struct msm_hwacc_buf_avail {
  376. __u32 input_num_avail;
  377. __u32 output_num_avail;
  378. };
  379. struct msm_hwacc_effects_config {
  380. struct msm_hwacc_data_config input;
  381. struct msm_hwacc_data_config output;
  382. struct msm_hwacc_buf_cfg buf_cfg;
  383. __u32 meta_mode_enabled;
  384. __u32 overwrite_topology;
  385. __s32 topology;
  386. };
  387. #define ADSP_STREAM_PP_EVENT 0
  388. #define ADSP_STREAM_ENCDEC_EVENT 1
  389. #define ADSP_STREAM_IEC_61937_FMT_UPDATE_EVENT 2
  390. #define ADSP_STREAM_EVENT_MAX 3
  391. struct msm_adsp_event_data {
  392. __u32 event_type;
  393. __u32 payload_len;
  394. __u8 payload[0];
  395. };
  396. #endif