blob: d08f528ce940f40b456c4aa623c5f3a2177900e3 [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>
18
19#define IN 0x000
20#define OUT 0x001
21#define CH_MODE_MONO 0x001
22#define CH_MODE_STEREO 0x002
23
24#define FORMAT_LINEAR_PCM 0x0000
25#define FORMAT_DTMF 0x0001
26#define FORMAT_ADPCM 0x0002
27#define FORMAT_YADPCM 0x0003
28#define FORMAT_MP3 0x0004
29#define FORMAT_MPEG4_AAC 0x0005
30#define FORMAT_AMRNB 0x0006
31#define FORMAT_AMRWB 0x0007
32#define FORMAT_V13K 0x0008
33#define FORMAT_EVRC 0x0009
34#define FORMAT_EVRCB 0x000a
35#define FORMAT_EVRCWB 0x000b
36#define FORMAT_MIDI 0x000c
37#define FORMAT_SBC 0x000d
38#define FORMAT_WMA_V10PRO 0x000e
39#define FORMAT_WMA_V9 0x000f
40#define FORMAT_AMR_WB_PLUS 0x0010
Bharath Ramachandramurthy4f71d502011-10-23 19:45:22 -070041#define FORMAT_MPEG4_MULTI_AAC 0x0011
Kiran Kandi5e809b02012-01-31 00:24:33 -080042#define FORMAT_MULTI_CHANNEL_LINEAR_PCM 0x0012
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070043
44#define ENCDEC_SBCBITRATE 0x0001
45#define ENCDEC_IMMEDIATE_DECODE 0x0002
46#define ENCDEC_CFG_BLK 0x0003
47
48#define CMD_PAUSE 0x0001
49#define CMD_FLUSH 0x0002
50#define CMD_EOS 0x0003
51#define CMD_CLOSE 0x0004
52#define CMD_OUT_FLUSH 0x0005
53
54/* bit 0:1 represents priority of stream */
55#define STREAM_PRIORITY_NORMAL 0x0000
56#define STREAM_PRIORITY_LOW 0x0001
57#define STREAM_PRIORITY_HIGH 0x0002
58
59/* bit 4 represents META enable of encoded data buffer */
60#define BUFFER_META_ENABLE 0x0010
61
62/* Enable Sample_Rate/Channel_Mode notification event from Decoder */
63#define SR_CM_NOTIFY_ENABLE 0x0004
64
65#define ASYNC_IO_MODE 0x0002
66#define SYNC_IO_MODE 0x0001
67#define NO_TIMESTAMP 0xFF00
68#define SET_TIMESTAMP 0x0000
69
70#define SOFT_PAUSE_ENABLE 1
71#define SOFT_PAUSE_DISABLE 0
72
73#define SESSION_MAX 0x08
74
Sriranjan Srikantam5285a212011-09-06 19:09:19 -070075#define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */
76#define SOFT_PAUSE_STEP 2000 /* Step value 2ms or 2000us */
77enum {
78 SOFT_PAUSE_CURVE_LINEAR = 0,
79 SOFT_PAUSE_CURVE_EXP,
80 SOFT_PAUSE_CURVE_LOG,
81};
82
83#define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */
84#define SOFT_VOLUME_STEP 2000 /* Step value 2ms or 2000us */
85enum {
86 SOFT_VOLUME_CURVE_LINEAR = 0,
87 SOFT_VOLUME_CURVE_EXP,
88 SOFT_VOLUME_CURVE_LOG,
89};
90
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091typedef void (*app_cb)(uint32_t opcode, uint32_t token,
92 uint32_t *payload, void *priv);
93
94struct audio_buffer {
95 dma_addr_t phys;
96 void *data;
97 struct msm_mapped_buffer *mem_buffer;
98 uint32_t used;
99 uint32_t size;/* size of buffer */
100 uint32_t actual_size; /* actual number of bytes read by DSP */
101};
102
103struct audio_aio_write_param {
104 unsigned long paddr;
105 uint32_t uid;
106 uint32_t len;
107 uint32_t msw_ts;
108 uint32_t lsw_ts;
109 uint32_t flags;
110};
111
112struct audio_aio_read_param {
113 unsigned long paddr;
114 uint32_t len;
115 uint32_t uid;
116};
117
118struct audio_port_data {
119 struct audio_buffer *buf;
120 uint32_t max_buf_cnt;
121 uint32_t dsp_buf;
122 uint32_t cpu_buf;
123 /* read or write locks */
124 struct mutex lock;
125 spinlock_t dsp_lock;
126};
127
128struct audio_client {
129 int session;
130 /* idx:1 out port, 0: in port*/
131 struct audio_port_data port[2];
132
133 struct apr_svc *apr;
134 struct mutex cmd_lock;
135
136 atomic_t cmd_state;
137 atomic_t time_flag;
138 wait_queue_head_t cmd_wait;
139 wait_queue_head_t time_wait;
140
141 app_cb cb;
142 void *priv;
143 uint32_t io_mode;
144 uint64_t time_stamp;
145};
146
147void q6asm_audio_client_free(struct audio_client *ac);
148
149struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
150
Ben Romberger61754dc2011-10-31 18:25:41 -0700151struct audio_client *q6asm_get_audio_client(int session_id);
152
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
154 struct audio_client *ac,
155 unsigned int bufsz,
156 unsigned int bufcnt);
157int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
158 /* 1:Out,0:In */,
159 struct audio_client *ac,
160 unsigned int bufsz,
161 unsigned int bufcnt);
162
163int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
164 struct audio_client *ac);
165
166int q6asm_open_read(struct audio_client *ac, uint32_t format);
167
168int q6asm_open_write(struct audio_client *ac, uint32_t format);
169
170int q6asm_open_read_write(struct audio_client *ac,
171 uint32_t rd_format,
172 uint32_t wr_format);
173
174int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
175 uint32_t lsw_ts, uint32_t flags);
176int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
177 uint32_t lsw_ts, uint32_t flags);
178
179int q6asm_async_write(struct audio_client *ac,
180 struct audio_aio_write_param *param);
181
182int q6asm_async_read(struct audio_client *ac,
183 struct audio_aio_read_param *param);
184
185int q6asm_read(struct audio_client *ac);
186int q6asm_read_nolock(struct audio_client *ac);
187
188int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add,
189 int dir, uint32_t bufsz, uint32_t bufcnt);
190
191int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add,
192 int dir);
193
194int q6asm_run(struct audio_client *ac, uint32_t flags,
195 uint32_t msw_ts, uint32_t lsw_ts);
196
197int q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
198 uint32_t msw_ts, uint32_t lsw_ts);
199
200int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable);
201
202int q6asm_cmd(struct audio_client *ac, int cmd);
203
204int q6asm_cmd_nowait(struct audio_client *ac, int cmd);
205
206void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac,
207 uint32_t *size, uint32_t *idx);
208
Jay Wang9cf59a02011-08-10 16:58:40 -0700209void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
210 uint32_t *size, uint32_t *idx);
211
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700212int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac);
213
214/* File format specific configurations to be added below */
215
216int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
217 uint32_t frames_per_buf,
218 uint32_t sample_rate, uint32_t channels,
219 uint32_t bit_rate,
220 uint32_t mode, uint32_t format);
221
222int q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
223 uint32_t rate, uint32_t channels);
224
225int q6asm_enable_sbrps(struct audio_client *ac,
226 uint32_t sbr_ps);
227
Swaminathan Sathappan70765cd2011-07-19 18:42:47 -0700228int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
229 uint16_t sce_left, uint16_t sce_right);
230
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700231int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
232 uint16_t min_rate, uint16_t max_rate,
233 uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
234
235int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
236 uint16_t min_rate, uint16_t max_rate,
237 uint16_t rate_modulation_cmd);
238
239int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
240 uint16_t band_mode, uint16_t dtx_enable);
241
Alex Wong2caeecc2011-10-28 10:52:15 +0530242int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
243 uint16_t band_mode, uint16_t dtx_enable);
244
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700245int q6asm_media_format_block_pcm(struct audio_client *ac,
246 uint32_t rate, uint32_t channels);
247
Kiran Kandi5e809b02012-01-31 00:24:33 -0800248int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
249 uint32_t rate, uint32_t channels);
250
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700251int q6asm_media_format_block_aac(struct audio_client *ac,
252 struct asm_aac_cfg *cfg);
253
Bharath Ramachandramurthy4f71d502011-10-23 19:45:22 -0700254int q6asm_media_format_block_multi_aac(struct audio_client *ac,
255 struct asm_aac_cfg *cfg);
256
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700257int q6asm_media_format_block_wma(struct audio_client *ac,
258 void *cfg);
259
260int q6asm_media_format_block_wmapro(struct audio_client *ac,
261 void *cfg);
262
263/* PP specific */
264int q6asm_equalizer(struct audio_client *ac, void *eq);
265
266/* Send Volume Command */
267int q6asm_set_volume(struct audio_client *ac, int volume);
268
269/* Set SoftPause Params */
270int q6asm_set_softpause(struct audio_client *ac,
271 struct asm_softpause_params *param);
272
Swaminathan Sathappanb0021cd2011-08-31 15:20:12 -0700273/* Set Softvolume Params */
274int q6asm_set_softvolume(struct audio_client *ac,
275 struct asm_softvolume_params *param);
276
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700277/* Send left-right channel gain */
278int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
279
280/* Enable Mute/unmute flag */
281int q6asm_set_mute(struct audio_client *ac, int muteflag);
282
283uint64_t q6asm_get_session_time(struct audio_client *ac);
284
285/* Client can set the IO mode to either AIO/SIO mode */
286int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
287
Ben Romberger45b351c2011-07-20 22:37:27 -0700288#ifdef CONFIG_RTAC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700289/* Get Service ID for APR communication */
290int q6asm_get_apr_service_id(int session_id);
291#endif
292
Alex Wong2caeecc2011-10-28 10:52:15 +0530293/* Common format block without any payload
294*/
295int q6asm_media_format_block(struct audio_client *ac, uint32_t format);
296
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700297#endif /* __Q6_ASM_H__ */