blob: 8a35ca00785a39f3828c3c21de7e22226605201f [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* include/linux/msm_audio.h
2 *
3 * Copyright (C) 2008 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __LINUX_MSM_AUDIO_H
17#define __LINUX_MSM_AUDIO_H
18
19#include <linux/types.h>
20#include <linux/ioctl.h>
21
22/* PCM Audio */
23
24#define AUDIO_IOCTL_MAGIC 'a'
25
26#define AUDIO_START _IOW(AUDIO_IOCTL_MAGIC, 0, unsigned)
27#define AUDIO_STOP _IOW(AUDIO_IOCTL_MAGIC, 1, unsigned)
28#define AUDIO_FLUSH _IOW(AUDIO_IOCTL_MAGIC, 2, unsigned)
29#define AUDIO_GET_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 3, unsigned)
30#define AUDIO_SET_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 4, unsigned)
31#define AUDIO_GET_STATS _IOR(AUDIO_IOCTL_MAGIC, 5, unsigned)
32#define AUDIO_ENABLE_AUDPP _IOW(AUDIO_IOCTL_MAGIC, 6, unsigned)
33#define AUDIO_SET_ADRC _IOW(AUDIO_IOCTL_MAGIC, 7, unsigned)
34#define AUDIO_SET_EQ _IOW(AUDIO_IOCTL_MAGIC, 8, unsigned)
35#define AUDIO_SET_RX_IIR _IOW(AUDIO_IOCTL_MAGIC, 9, unsigned)
36#define AUDIO_SET_VOLUME _IOW(AUDIO_IOCTL_MAGIC, 10, unsigned)
37#define AUDIO_PAUSE _IOW(AUDIO_IOCTL_MAGIC, 11, unsigned)
38#define AUDIO_PLAY_DTMF _IOW(AUDIO_IOCTL_MAGIC, 12, unsigned)
39#define AUDIO_GET_EVENT _IOR(AUDIO_IOCTL_MAGIC, 13, unsigned)
40#define AUDIO_ABORT_GET_EVENT _IOW(AUDIO_IOCTL_MAGIC, 14, unsigned)
41#define AUDIO_REGISTER_PMEM _IOW(AUDIO_IOCTL_MAGIC, 15, unsigned)
42#define AUDIO_DEREGISTER_PMEM _IOW(AUDIO_IOCTL_MAGIC, 16, unsigned)
43#define AUDIO_ASYNC_WRITE _IOW(AUDIO_IOCTL_MAGIC, 17, unsigned)
44#define AUDIO_ASYNC_READ _IOW(AUDIO_IOCTL_MAGIC, 18, unsigned)
45#define AUDIO_SET_INCALL _IOW(AUDIO_IOCTL_MAGIC, 19, struct msm_voicerec_mode)
46#define AUDIO_GET_NUM_SND_DEVICE _IOR(AUDIO_IOCTL_MAGIC, 20, unsigned)
47#define AUDIO_GET_SND_DEVICES _IOWR(AUDIO_IOCTL_MAGIC, 21, \
48 struct msm_snd_device_list)
49#define AUDIO_ENABLE_SND_DEVICE _IOW(AUDIO_IOCTL_MAGIC, 22, unsigned)
50#define AUDIO_DISABLE_SND_DEVICE _IOW(AUDIO_IOCTL_MAGIC, 23, unsigned)
51#define AUDIO_ROUTE_STREAM _IOW(AUDIO_IOCTL_MAGIC, 24, \
52 struct msm_audio_route_config)
53#define AUDIO_GET_PCM_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 30, unsigned)
54#define AUDIO_SET_PCM_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 31, unsigned)
55#define AUDIO_SWITCH_DEVICE _IOW(AUDIO_IOCTL_MAGIC, 32, unsigned)
56#define AUDIO_SET_MUTE _IOW(AUDIO_IOCTL_MAGIC, 33, unsigned)
57#define AUDIO_UPDATE_ACDB _IOW(AUDIO_IOCTL_MAGIC, 34, unsigned)
58#define AUDIO_START_VOICE _IOW(AUDIO_IOCTL_MAGIC, 35, unsigned)
59#define AUDIO_STOP_VOICE _IOW(AUDIO_IOCTL_MAGIC, 36, unsigned)
60#define AUDIO_REINIT_ACDB _IOW(AUDIO_IOCTL_MAGIC, 39, unsigned)
61#define AUDIO_OUTPORT_FLUSH _IOW(AUDIO_IOCTL_MAGIC, 40, unsigned short)
62#define AUDIO_SET_ERR_THRESHOLD_VALUE _IOW(AUDIO_IOCTL_MAGIC, 41, \
63 unsigned short)
64#define AUDIO_GET_BITSTREAM_ERROR_INFO _IOR(AUDIO_IOCTL_MAGIC, 42, \
65 struct msm_audio_bitstream_error_info)
66/* Qualcomm extensions */
67#define AUDIO_SET_STREAM_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 80, \
68 struct msm_audio_stream_config)
69#define AUDIO_GET_STREAM_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 81, \
70 struct msm_audio_stream_config)
71#define AUDIO_GET_SESSION_ID _IOR(AUDIO_IOCTL_MAGIC, 82, unsigned short)
72#define AUDIO_GET_STREAM_INFO _IOR(AUDIO_IOCTL_MAGIC, 83, \
73 struct msm_audio_bitstream_info)
74#define AUDIO_SET_PAN _IOW(AUDIO_IOCTL_MAGIC, 84, unsigned)
75#define AUDIO_SET_QCONCERT_PLUS _IOW(AUDIO_IOCTL_MAGIC, 85, unsigned)
76#define AUDIO_SET_MBADRC _IOW(AUDIO_IOCTL_MAGIC, 86, unsigned)
77#define AUDIO_SET_VOLUME_PATH _IOW(AUDIO_IOCTL_MAGIC, 87, \
78 struct msm_vol_info)
79#define AUDIO_SET_MAX_VOL_ALL _IOW(AUDIO_IOCTL_MAGIC, 88, unsigned)
80#define AUDIO_ENABLE_AUDPRE _IOW(AUDIO_IOCTL_MAGIC, 89, unsigned)
81#define AUDIO_SET_AGC _IOW(AUDIO_IOCTL_MAGIC, 90, unsigned)
82#define AUDIO_SET_NS _IOW(AUDIO_IOCTL_MAGIC, 91, unsigned)
83#define AUDIO_SET_TX_IIR _IOW(AUDIO_IOCTL_MAGIC, 92, unsigned)
84#define AUDIO_GET_BUF_CFG _IOW(AUDIO_IOCTL_MAGIC, 93, \
85 struct msm_audio_buf_cfg)
86#define AUDIO_SET_BUF_CFG _IOW(AUDIO_IOCTL_MAGIC, 94, \
87 struct msm_audio_buf_cfg)
88#define AUDIO_SET_ACDB_BLK _IOW(AUDIO_IOCTL_MAGIC, 95, \
89 struct msm_acdb_cmd_device)
90#define AUDIO_GET_ACDB_BLK _IOW(AUDIO_IOCTL_MAGIC, 96, \
91 struct msm_acdb_cmd_device)
92
Chaithanya Krishna Bacharajubbc2e702012-02-16 14:46:55 +053093#define AUDIO_REGISTER_ION _IOW(AUDIO_IOCTL_MAGIC, 97, unsigned)
94#define AUDIO_DEREGISTER_ION _IOW(AUDIO_IOCTL_MAGIC, 98, unsigned)
95
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096#define AUDIO_MAX_COMMON_IOCTL_NUM 100
97
98
99#define HANDSET_MIC 0x01
100#define HANDSET_SPKR 0x02
101#define HEADSET_MIC 0x03
102#define HEADSET_SPKR_MONO 0x04
103#define HEADSET_SPKR_STEREO 0x05
104#define SPKR_PHONE_MIC 0x06
105#define SPKR_PHONE_MONO 0x07
106#define SPKR_PHONE_STEREO 0x08
107#define BT_SCO_MIC 0x09
108#define BT_SCO_SPKR 0x0A
109#define BT_A2DP_SPKR 0x0B
110#define TTY_HEADSET_MIC 0x0C
111#define TTY_HEADSET_SPKR 0x0D
112
113/* Default devices are not supported in a */
114/* device switching context. Only supported */
115/* for stream devices. */
116/* DO NOT USE */
117#define DEFAULT_TX 0x0E
118#define DEFAULT_RX 0x0F
119
120#define BT_A2DP_TX 0x10
121
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
127#define I2S_RX 0x20
128#define I2S_TX 0x21
129
130#define ADRC_ENABLE 0x0001
131#define EQ_ENABLE 0x0002
132#define IIR_ENABLE 0x0004
133#define QCONCERT_PLUS_ENABLE 0x0008
134#define MBADRC_ENABLE 0x0010
135
136#define AGC_ENABLE 0x0001
137#define NS_ENABLE 0x0002
138#define TX_IIR_ENABLE 0x0004
139#define FLUENCE_ENABLE 0x0008
140
141#define VOC_REC_UPLINK 0x00
142#define VOC_REC_DOWNLINK 0x01
143#define VOC_REC_BOTH 0x02
144
145struct msm_audio_config {
146 uint32_t buffer_size;
147 uint32_t buffer_count;
148 uint32_t channel_count;
149 uint32_t sample_rate;
150 uint32_t type;
151 uint32_t meta_field;
152 uint32_t bits;
153 uint32_t unused[3];
154};
155
156struct msm_audio_stream_config {
157 uint32_t buffer_size;
158 uint32_t buffer_count;
159};
160
161struct msm_audio_buf_cfg{
162 uint32_t meta_info_enable;
163 uint32_t frames_per_buf;
164};
165
166struct msm_audio_stats {
167 uint32_t byte_count;
168 uint32_t sample_count;
169 uint32_t unused[2];
170};
171
Chaithanya Krishna Bacharajubbc2e702012-02-16 14:46:55 +0530172struct msm_audio_ion_info {
173 int fd;
174 void *vaddr;
175};
176
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700177struct msm_audio_pmem_info {
178 int fd;
179 void *vaddr;
180};
181
182struct msm_audio_aio_buf {
183 void *buf_addr;
184 uint32_t buf_len;
185 uint32_t data_len;
186 void *private_data;
187 unsigned short mfield_sz; /*only useful for data has meta field */
188};
189
190/* Audio routing */
191
192#define SND_IOCTL_MAGIC 's'
193
194#define SND_MUTE_UNMUTED 0
195#define SND_MUTE_MUTED 1
196
197struct msm_mute_info {
198 uint32_t mute;
199 uint32_t path;
200};
201
202struct msm_vol_info {
203 uint32_t vol;
204 uint32_t path;
205};
206
207struct msm_voicerec_mode {
208 uint32_t rec_mode;
209};
210
211struct msm_snd_device_config {
212 uint32_t device;
213 uint32_t ear_mute;
214 uint32_t mic_mute;
215};
216
217#define SND_SET_DEVICE _IOW(SND_IOCTL_MAGIC, 2, struct msm_device_config *)
218
219#define SND_METHOD_VOICE 0
220
221struct msm_snd_volume_config {
222 uint32_t device;
223 uint32_t method;
224 uint32_t volume;
225};
226
227#define SND_SET_VOLUME _IOW(SND_IOCTL_MAGIC, 3, struct msm_snd_volume_config *)
228
229/* Returns the number of SND endpoints supported. */
230
231#define SND_GET_NUM_ENDPOINTS _IOR(SND_IOCTL_MAGIC, 4, unsigned *)
232
233struct msm_snd_endpoint {
234 int id; /* input and output */
235 char name[64]; /* output only */
236};
237
238/* Takes an index between 0 and one less than the number returned by
239 * SND_GET_NUM_ENDPOINTS, and returns the SND index and name of a
240 * SND endpoint. On input, the .id field contains the number of the
241 * endpoint, and on exit it contains the SND index, while .name contains
242 * the description of the endpoint.
243 */
244
245#define SND_GET_ENDPOINT _IOWR(SND_IOCTL_MAGIC, 5, struct msm_snd_endpoint *)
246
247
248#define SND_AVC_CTL _IOW(SND_IOCTL_MAGIC, 6, unsigned *)
249#define SND_AGC_CTL _IOW(SND_IOCTL_MAGIC, 7, unsigned *)
250
251struct msm_audio_pcm_config {
252 uint32_t pcm_feedback; /* 0 - disable > 0 - enable */
253 uint32_t buffer_count; /* Number of buffers to allocate */
254 uint32_t buffer_size; /* Size of buffer for capturing of
255 PCM samples */
256};
257
258#define AUDIO_EVENT_SUSPEND 0
259#define AUDIO_EVENT_RESUME 1
260#define AUDIO_EVENT_WRITE_DONE 2
261#define AUDIO_EVENT_READ_DONE 3
262#define AUDIO_EVENT_STREAM_INFO 4
263#define AUDIO_EVENT_BITSTREAM_ERROR_INFO 5
264
265#define AUDIO_CODEC_TYPE_MP3 0
266#define AUDIO_CODEC_TYPE_AAC 1
267
268struct msm_audio_bitstream_info {
269 uint32_t codec_type;
270 uint32_t chan_info;
271 uint32_t sample_rate;
272 uint32_t bit_stream_info;
273 uint32_t bit_rate;
274 uint32_t unused[3];
275};
276
277struct msm_audio_bitstream_error_info {
278 uint32_t dec_id;
279 uint32_t err_msg_indicator;
280 uint32_t err_type;
281};
282
283union msm_audio_event_payload {
284 struct msm_audio_aio_buf aio_buf;
285 struct msm_audio_bitstream_info stream_info;
286 struct msm_audio_bitstream_error_info error_info;
287 int reserved;
288};
289
290struct msm_audio_event {
291 int event_type;
292 int timeout_ms;
293 union msm_audio_event_payload event_payload;
294};
295
296#define MSM_SNDDEV_CAP_RX 0x1
297#define MSM_SNDDEV_CAP_TX 0x2
298#define MSM_SNDDEV_CAP_VOICE 0x4
299
300struct msm_snd_device_info {
301 uint32_t dev_id;
302 uint32_t dev_cap; /* bitmask describe capability of device */
303 char dev_name[64];
304};
305
306struct msm_snd_device_list {
307 uint32_t num_dev; /* Indicate number of device info to be retrieved */
308 struct msm_snd_device_info *list;
309};
310
311struct msm_dtmf_config {
312 uint16_t path;
313 uint16_t dtmf_hi;
314 uint16_t dtmf_low;
315 uint16_t duration;
316 uint16_t tx_gain;
317 uint16_t rx_gain;
318 uint16_t mixing;
319};
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
326struct msm_audio_route_config {
327 uint32_t stream_type;
328 uint32_t stream_id;
329 uint32_t dev_id;
330};
331
332#define AUDIO_MAX_EQ_BANDS 12
333
334struct msm_audio_eq_band {
335 uint16_t band_idx; /* The band index, 0 .. 11 */
336 uint32_t filter_type; /* Filter band type */
337 uint32_t center_freq_hz; /* Filter band center frequency */
338 uint32_t filter_gain; /* Filter band initial gain (dB) */
339 /* Range is +12 dB to -12 dB with 1dB increments. */
340 uint32_t q_factor;
341} __attribute__ ((packed));
342
343struct msm_audio_eq_stream_config {
344 uint32_t enable; /* Number of consequtive bands specified */
345 uint32_t num_bands;
346 struct msm_audio_eq_band eq_bands[AUDIO_MAX_EQ_BANDS];
347} __attribute__ ((packed));
348
349struct msm_acdb_cmd_device {
350 uint32_t command_id;
351 uint32_t device_id;
352 uint32_t network_id;
353 uint32_t sample_rate_id; /* Actual sample rate value */
354 uint32_t interface_id; /* See interface id's above */
355 uint32_t algorithm_block_id; /* See enumerations above */
356 uint32_t total_bytes; /* Length in bytes used by buffer */
357 uint32_t *phys_buf; /* Physical Address of data */
358};
359
360
361#endif