blob: bad9be73bfa01a64262e97b5f82504d03e4f9953 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
2 *
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
41
42#define ENCDEC_SBCBITRATE 0x0001
43#define ENCDEC_IMMEDIATE_DECODE 0x0002
44#define ENCDEC_CFG_BLK 0x0003
45
46#define CMD_PAUSE 0x0001
47#define CMD_FLUSH 0x0002
48#define CMD_EOS 0x0003
49#define CMD_CLOSE 0x0004
50#define CMD_OUT_FLUSH 0x0005
51
52/* bit 0:1 represents priority of stream */
53#define STREAM_PRIORITY_NORMAL 0x0000
54#define STREAM_PRIORITY_LOW 0x0001
55#define STREAM_PRIORITY_HIGH 0x0002
56
57/* bit 4 represents META enable of encoded data buffer */
58#define BUFFER_META_ENABLE 0x0010
59
60/* Enable Sample_Rate/Channel_Mode notification event from Decoder */
61#define SR_CM_NOTIFY_ENABLE 0x0004
62
63#define ASYNC_IO_MODE 0x0002
64#define SYNC_IO_MODE 0x0001
65#define NO_TIMESTAMP 0xFF00
66#define SET_TIMESTAMP 0x0000
67
68#define SOFT_PAUSE_ENABLE 1
69#define SOFT_PAUSE_DISABLE 0
70
71#define SESSION_MAX 0x08
72
Sriranjan Srikantam5285a212011-09-06 19:09:19 -070073#define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */
74#define SOFT_PAUSE_STEP 2000 /* Step value 2ms or 2000us */
75enum {
76 SOFT_PAUSE_CURVE_LINEAR = 0,
77 SOFT_PAUSE_CURVE_EXP,
78 SOFT_PAUSE_CURVE_LOG,
79};
80
81#define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */
82#define SOFT_VOLUME_STEP 2000 /* Step value 2ms or 2000us */
83enum {
84 SOFT_VOLUME_CURVE_LINEAR = 0,
85 SOFT_VOLUME_CURVE_EXP,
86 SOFT_VOLUME_CURVE_LOG,
87};
88
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089typedef void (*app_cb)(uint32_t opcode, uint32_t token,
90 uint32_t *payload, void *priv);
91
92struct audio_buffer {
93 dma_addr_t phys;
94 void *data;
95 struct msm_mapped_buffer *mem_buffer;
96 uint32_t used;
97 uint32_t size;/* size of buffer */
98 uint32_t actual_size; /* actual number of bytes read by DSP */
99};
100
101struct audio_aio_write_param {
102 unsigned long paddr;
103 uint32_t uid;
104 uint32_t len;
105 uint32_t msw_ts;
106 uint32_t lsw_ts;
107 uint32_t flags;
108};
109
110struct audio_aio_read_param {
111 unsigned long paddr;
112 uint32_t len;
113 uint32_t uid;
114};
115
116struct audio_port_data {
117 struct audio_buffer *buf;
118 uint32_t max_buf_cnt;
119 uint32_t dsp_buf;
120 uint32_t cpu_buf;
121 /* read or write locks */
122 struct mutex lock;
123 spinlock_t dsp_lock;
124};
125
126struct audio_client {
127 int session;
128 /* idx:1 out port, 0: in port*/
129 struct audio_port_data port[2];
130
131 struct apr_svc *apr;
132 struct mutex cmd_lock;
133
134 atomic_t cmd_state;
135 atomic_t time_flag;
136 wait_queue_head_t cmd_wait;
137 wait_queue_head_t time_wait;
138
139 app_cb cb;
140 void *priv;
141 uint32_t io_mode;
142 uint64_t time_stamp;
143};
144
145void q6asm_audio_client_free(struct audio_client *ac);
146
147struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
148
149int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
150 struct audio_client *ac,
151 unsigned int bufsz,
152 unsigned int bufcnt);
153int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
154 /* 1:Out,0:In */,
155 struct audio_client *ac,
156 unsigned int bufsz,
157 unsigned int bufcnt);
158
159int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
160 struct audio_client *ac);
161
162int q6asm_open_read(struct audio_client *ac, uint32_t format);
163
164int q6asm_open_write(struct audio_client *ac, uint32_t format);
165
166int q6asm_open_read_write(struct audio_client *ac,
167 uint32_t rd_format,
168 uint32_t wr_format);
169
170int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
171 uint32_t lsw_ts, uint32_t flags);
172int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
173 uint32_t lsw_ts, uint32_t flags);
174
175int q6asm_async_write(struct audio_client *ac,
176 struct audio_aio_write_param *param);
177
178int q6asm_async_read(struct audio_client *ac,
179 struct audio_aio_read_param *param);
180
181int q6asm_read(struct audio_client *ac);
182int q6asm_read_nolock(struct audio_client *ac);
183
184int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add,
185 int dir, uint32_t bufsz, uint32_t bufcnt);
186
187int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add,
188 int dir);
189
190int q6asm_run(struct audio_client *ac, uint32_t flags,
191 uint32_t msw_ts, uint32_t lsw_ts);
192
193int q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
194 uint32_t msw_ts, uint32_t lsw_ts);
195
196int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable);
197
198int q6asm_cmd(struct audio_client *ac, int cmd);
199
200int q6asm_cmd_nowait(struct audio_client *ac, int cmd);
201
202void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac,
203 uint32_t *size, uint32_t *idx);
204
Jay Wang9cf59a02011-08-10 16:58:40 -0700205void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
206 uint32_t *size, uint32_t *idx);
207
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700208int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac);
209
210/* File format specific configurations to be added below */
211
212int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
213 uint32_t frames_per_buf,
214 uint32_t sample_rate, uint32_t channels,
215 uint32_t bit_rate,
216 uint32_t mode, uint32_t format);
217
218int q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
219 uint32_t rate, uint32_t channels);
220
221int q6asm_enable_sbrps(struct audio_client *ac,
222 uint32_t sbr_ps);
223
Swaminathan Sathappan70765cd2011-07-19 18:42:47 -0700224int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
225 uint16_t sce_left, uint16_t sce_right);
226
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700227int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
228 uint16_t min_rate, uint16_t max_rate,
229 uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
230
231int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
232 uint16_t min_rate, uint16_t max_rate,
233 uint16_t rate_modulation_cmd);
234
235int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
236 uint16_t band_mode, uint16_t dtx_enable);
237
238int q6asm_media_format_block_pcm(struct audio_client *ac,
239 uint32_t rate, uint32_t channels);
240
241int q6asm_media_format_block_aac(struct audio_client *ac,
242 struct asm_aac_cfg *cfg);
243
244int q6asm_media_format_block_wma(struct audio_client *ac,
245 void *cfg);
246
247int q6asm_media_format_block_wmapro(struct audio_client *ac,
248 void *cfg);
249
250/* PP specific */
251int q6asm_equalizer(struct audio_client *ac, void *eq);
252
253/* Send Volume Command */
254int q6asm_set_volume(struct audio_client *ac, int volume);
255
256/* Set SoftPause Params */
257int q6asm_set_softpause(struct audio_client *ac,
258 struct asm_softpause_params *param);
259
Swaminathan Sathappanb0021cd2011-08-31 15:20:12 -0700260/* Set Softvolume Params */
261int q6asm_set_softvolume(struct audio_client *ac,
262 struct asm_softvolume_params *param);
263
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700264/* Send left-right channel gain */
265int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
266
267/* Enable Mute/unmute flag */
268int q6asm_set_mute(struct audio_client *ac, int muteflag);
269
270uint64_t q6asm_get_session_time(struct audio_client *ac);
271
272/* Client can set the IO mode to either AIO/SIO mode */
273int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
274
Ben Romberger45b351c2011-07-20 22:37:27 -0700275#ifdef CONFIG_RTAC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700276/* Get Service ID for APR communication */
277int q6asm_get_apr_service_id(int session_id);
278#endif
279
280#endif /* __Q6_ASM_H__ */