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