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