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