msm_audio.h 14 KB

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