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