blob: 0fabc5b027c602f2c30e8cefb7fbb4745b17bd85 [file] [log] [blame]
Kiran Kandi5e809b02012-01-31 00:24:33 -08001/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12#ifndef __Q6_ASM_H__
13#define __Q6_ASM_H__
14
15#include <mach/qdsp6v2/apr.h>
16#include <mach/msm_subsystem_map.h>
17#include <sound/apr_audio.h>
Swaminathan Sathappanbdc55082012-02-16 22:47:40 -080018#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
19#include <linux/ion.h>
20#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070021
22#define IN 0x000
23#define OUT 0x001
24#define CH_MODE_MONO 0x001
25#define CH_MODE_STEREO 0x002
26
27#define FORMAT_LINEAR_PCM 0x0000
28#define FORMAT_DTMF 0x0001
29#define FORMAT_ADPCM 0x0002
30#define FORMAT_YADPCM 0x0003
31#define FORMAT_MP3 0x0004
32#define FORMAT_MPEG4_AAC 0x0005
33#define FORMAT_AMRNB 0x0006
34#define FORMAT_AMRWB 0x0007
35#define FORMAT_V13K 0x0008
36#define FORMAT_EVRC 0x0009
37#define FORMAT_EVRCB 0x000a
38#define FORMAT_EVRCWB 0x000b
39#define FORMAT_MIDI 0x000c
40#define FORMAT_SBC 0x000d
41#define FORMAT_WMA_V10PRO 0x000e
42#define FORMAT_WMA_V9 0x000f
43#define FORMAT_AMR_WB_PLUS 0x0010
Bharath Ramachandramurthy4f71d502011-10-23 19:45:22 -070044#define FORMAT_MPEG4_MULTI_AAC 0x0011
Kiran Kandi5e809b02012-01-31 00:24:33 -080045#define FORMAT_MULTI_CHANNEL_LINEAR_PCM 0x0012
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046
47#define ENCDEC_SBCBITRATE 0x0001
48#define ENCDEC_IMMEDIATE_DECODE 0x0002
49#define ENCDEC_CFG_BLK 0x0003
50
51#define CMD_PAUSE 0x0001
52#define CMD_FLUSH 0x0002
53#define CMD_EOS 0x0003
54#define CMD_CLOSE 0x0004
55#define CMD_OUT_FLUSH 0x0005
56
57/* bit 0:1 represents priority of stream */
58#define STREAM_PRIORITY_NORMAL 0x0000
59#define STREAM_PRIORITY_LOW 0x0001
60#define STREAM_PRIORITY_HIGH 0x0002
61
62/* bit 4 represents META enable of encoded data buffer */
63#define BUFFER_META_ENABLE 0x0010
64
65/* Enable Sample_Rate/Channel_Mode notification event from Decoder */
66#define SR_CM_NOTIFY_ENABLE 0x0004
67
68#define ASYNC_IO_MODE 0x0002
69#define SYNC_IO_MODE 0x0001
70#define NO_TIMESTAMP 0xFF00
71#define SET_TIMESTAMP 0x0000
72
73#define SOFT_PAUSE_ENABLE 1
74#define SOFT_PAUSE_DISABLE 0
75
76#define SESSION_MAX 0x08
77
Sriranjan Srikantam5285a212011-09-06 19:09:19 -070078#define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */
79#define SOFT_PAUSE_STEP 2000 /* Step value 2ms or 2000us */
80enum {
81 SOFT_PAUSE_CURVE_LINEAR = 0,
82 SOFT_PAUSE_CURVE_EXP,
83 SOFT_PAUSE_CURVE_LOG,
84};
85
86#define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */
87#define SOFT_VOLUME_STEP 2000 /* Step value 2ms or 2000us */
88enum {
89 SOFT_VOLUME_CURVE_LINEAR = 0,
90 SOFT_VOLUME_CURVE_EXP,
91 SOFT_VOLUME_CURVE_LOG,
92};
93
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094typedef void (*app_cb)(uint32_t opcode, uint32_t token,
95 uint32_t *payload, void *priv);
96
97struct audio_buffer {
98 dma_addr_t phys;
99 void *data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100 uint32_t used;
101 uint32_t size;/* size of buffer */
102 uint32_t actual_size; /* actual number of bytes read by DSP */
Swaminathan Sathappanbdc55082012-02-16 22:47:40 -0800103#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
104 struct ion_handle *handle;
105 struct ion_client *client;
106#else
107 struct msm_mapped_buffer *mem_buffer;
108#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700109};
110
111struct audio_aio_write_param {
112 unsigned long paddr;
113 uint32_t uid;
114 uint32_t len;
115 uint32_t msw_ts;
116 uint32_t lsw_ts;
117 uint32_t flags;
118};
119
120struct audio_aio_read_param {
121 unsigned long paddr;
122 uint32_t len;
123 uint32_t uid;
124};
125
126struct audio_port_data {
127 struct audio_buffer *buf;
128 uint32_t max_buf_cnt;
129 uint32_t dsp_buf;
130 uint32_t cpu_buf;
131 /* read or write locks */
132 struct mutex lock;
133 spinlock_t dsp_lock;
134};
135
136struct audio_client {
137 int session;
138 /* idx:1 out port, 0: in port*/
139 struct audio_port_data port[2];
140
141 struct apr_svc *apr;
142 struct mutex cmd_lock;
143
144 atomic_t cmd_state;
145 atomic_t time_flag;
146 wait_queue_head_t cmd_wait;
147 wait_queue_head_t time_wait;
148
149 app_cb cb;
150 void *priv;
151 uint32_t io_mode;
152 uint64_t time_stamp;
153};
154
155void q6asm_audio_client_free(struct audio_client *ac);
156
157struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
158
Ben Romberger61754dc2011-10-31 18:25:41 -0700159struct audio_client *q6asm_get_audio_client(int session_id);
160
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700161int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
162 struct audio_client *ac,
163 unsigned int bufsz,
164 unsigned int bufcnt);
165int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
166 /* 1:Out,0:In */,
167 struct audio_client *ac,
168 unsigned int bufsz,
169 unsigned int bufcnt);
170
171int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
172 struct audio_client *ac);
173
174int q6asm_open_read(struct audio_client *ac, uint32_t format);
175
176int q6asm_open_write(struct audio_client *ac, uint32_t format);
177
178int q6asm_open_read_write(struct audio_client *ac,
179 uint32_t rd_format,
180 uint32_t wr_format);
181
182int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
183 uint32_t lsw_ts, uint32_t flags);
184int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
185 uint32_t lsw_ts, uint32_t flags);
186
187int q6asm_async_write(struct audio_client *ac,
188 struct audio_aio_write_param *param);
189
190int q6asm_async_read(struct audio_client *ac,
191 struct audio_aio_read_param *param);
192
193int q6asm_read(struct audio_client *ac);
194int q6asm_read_nolock(struct audio_client *ac);
195
196int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add,
197 int dir, uint32_t bufsz, uint32_t bufcnt);
198
199int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add,
200 int dir);
201
202int q6asm_run(struct audio_client *ac, uint32_t flags,
203 uint32_t msw_ts, uint32_t lsw_ts);
204
205int q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
206 uint32_t msw_ts, uint32_t lsw_ts);
207
208int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable);
209
210int q6asm_cmd(struct audio_client *ac, int cmd);
211
212int q6asm_cmd_nowait(struct audio_client *ac, int cmd);
213
214void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac,
215 uint32_t *size, uint32_t *idx);
216
Jay Wang9cf59a02011-08-10 16:58:40 -0700217void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
218 uint32_t *size, uint32_t *idx);
219
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700220int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac);
221
222/* File format specific configurations to be added below */
223
224int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
225 uint32_t frames_per_buf,
226 uint32_t sample_rate, uint32_t channels,
227 uint32_t bit_rate,
228 uint32_t mode, uint32_t format);
229
230int q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
231 uint32_t rate, uint32_t channels);
232
233int q6asm_enable_sbrps(struct audio_client *ac,
234 uint32_t sbr_ps);
235
Swaminathan Sathappan70765cd2011-07-19 18:42:47 -0700236int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
237 uint16_t sce_left, uint16_t sce_right);
238
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700239int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
240 uint16_t min_rate, uint16_t max_rate,
241 uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
242
243int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
244 uint16_t min_rate, uint16_t max_rate,
245 uint16_t rate_modulation_cmd);
246
247int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
248 uint16_t band_mode, uint16_t dtx_enable);
249
Alex Wong2caeecc2011-10-28 10:52:15 +0530250int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
251 uint16_t band_mode, uint16_t dtx_enable);
252
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253int q6asm_media_format_block_pcm(struct audio_client *ac,
254 uint32_t rate, uint32_t channels);
255
Kiran Kandi5e809b02012-01-31 00:24:33 -0800256int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
257 uint32_t rate, uint32_t channels);
258
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700259int q6asm_media_format_block_aac(struct audio_client *ac,
260 struct asm_aac_cfg *cfg);
261
Bharath Ramachandramurthy4f71d502011-10-23 19:45:22 -0700262int q6asm_media_format_block_multi_aac(struct audio_client *ac,
263 struct asm_aac_cfg *cfg);
264
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700265int q6asm_media_format_block_wma(struct audio_client *ac,
266 void *cfg);
267
268int q6asm_media_format_block_wmapro(struct audio_client *ac,
269 void *cfg);
270
271/* PP specific */
272int q6asm_equalizer(struct audio_client *ac, void *eq);
273
274/* Send Volume Command */
275int q6asm_set_volume(struct audio_client *ac, int volume);
276
277/* Set SoftPause Params */
278int q6asm_set_softpause(struct audio_client *ac,
279 struct asm_softpause_params *param);
280
Swaminathan Sathappanb0021cd2011-08-31 15:20:12 -0700281/* Set Softvolume Params */
282int q6asm_set_softvolume(struct audio_client *ac,
283 struct asm_softvolume_params *param);
284
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700285/* Send left-right channel gain */
286int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
287
288/* Enable Mute/unmute flag */
289int q6asm_set_mute(struct audio_client *ac, int muteflag);
290
291uint64_t q6asm_get_session_time(struct audio_client *ac);
292
293/* Client can set the IO mode to either AIO/SIO mode */
294int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
295
Ben Romberger45b351c2011-07-20 22:37:27 -0700296#ifdef CONFIG_RTAC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700297/* Get Service ID for APR communication */
298int q6asm_get_apr_service_id(int session_id);
299#endif
300
Alex Wong2caeecc2011-10-28 10:52:15 +0530301/* Common format block without any payload
302*/
303int q6asm_media_format_block(struct audio_client *ac, uint32_t format);
304
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700305#endif /* __Q6_ASM_H__ */