blob: 968d46e668eb74835e497e152483263c10f67caf [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
Santosh Mardi23321202012-03-22 04:33:25 +053046#define FORMAT_AC3 0x0013
47#define FORMAT_DTS 0x0014
48#define FORMAT_EAC3 0x0015
49#define FORMAT_ATRAC 0x0016
50#define FORMAT_MAT 0x0017
51#define FORMAT_AAC 0x0018
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052
53#define ENCDEC_SBCBITRATE 0x0001
54#define ENCDEC_IMMEDIATE_DECODE 0x0002
55#define ENCDEC_CFG_BLK 0x0003
56
57#define CMD_PAUSE 0x0001
58#define CMD_FLUSH 0x0002
59#define CMD_EOS 0x0003
60#define CMD_CLOSE 0x0004
61#define CMD_OUT_FLUSH 0x0005
62
63/* bit 0:1 represents priority of stream */
64#define STREAM_PRIORITY_NORMAL 0x0000
65#define STREAM_PRIORITY_LOW 0x0001
66#define STREAM_PRIORITY_HIGH 0x0002
67
68/* bit 4 represents META enable of encoded data buffer */
69#define BUFFER_META_ENABLE 0x0010
70
71/* Enable Sample_Rate/Channel_Mode notification event from Decoder */
72#define SR_CM_NOTIFY_ENABLE 0x0004
73
74#define ASYNC_IO_MODE 0x0002
75#define SYNC_IO_MODE 0x0001
76#define NO_TIMESTAMP 0xFF00
77#define SET_TIMESTAMP 0x0000
78
79#define SOFT_PAUSE_ENABLE 1
80#define SOFT_PAUSE_DISABLE 0
81
82#define SESSION_MAX 0x08
83
Sriranjan Srikantam5285a212011-09-06 19:09:19 -070084#define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */
85#define SOFT_PAUSE_STEP 2000 /* Step value 2ms or 2000us */
86enum {
87 SOFT_PAUSE_CURVE_LINEAR = 0,
88 SOFT_PAUSE_CURVE_EXP,
89 SOFT_PAUSE_CURVE_LOG,
90};
91
92#define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */
93#define SOFT_VOLUME_STEP 2000 /* Step value 2ms or 2000us */
94enum {
95 SOFT_VOLUME_CURVE_LINEAR = 0,
96 SOFT_VOLUME_CURVE_EXP,
97 SOFT_VOLUME_CURVE_LOG,
98};
99
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100typedef void (*app_cb)(uint32_t opcode, uint32_t token,
101 uint32_t *payload, void *priv);
102
103struct audio_buffer {
104 dma_addr_t phys;
105 void *data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700106 uint32_t used;
107 uint32_t size;/* size of buffer */
108 uint32_t actual_size; /* actual number of bytes read by DSP */
Swaminathan Sathappanbdc55082012-02-16 22:47:40 -0800109#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
110 struct ion_handle *handle;
111 struct ion_client *client;
112#else
113 struct msm_mapped_buffer *mem_buffer;
114#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700115};
116
117struct audio_aio_write_param {
118 unsigned long paddr;
119 uint32_t uid;
120 uint32_t len;
121 uint32_t msw_ts;
122 uint32_t lsw_ts;
123 uint32_t flags;
124};
125
126struct audio_aio_read_param {
127 unsigned long paddr;
128 uint32_t len;
129 uint32_t uid;
130};
131
132struct audio_port_data {
133 struct audio_buffer *buf;
134 uint32_t max_buf_cnt;
135 uint32_t dsp_buf;
136 uint32_t cpu_buf;
137 /* read or write locks */
138 struct mutex lock;
139 spinlock_t dsp_lock;
140};
141
142struct audio_client {
143 int session;
144 /* idx:1 out port, 0: in port*/
145 struct audio_port_data port[2];
146
147 struct apr_svc *apr;
148 struct mutex cmd_lock;
149
150 atomic_t cmd_state;
151 atomic_t time_flag;
152 wait_queue_head_t cmd_wait;
153 wait_queue_head_t time_wait;
154
155 app_cb cb;
156 void *priv;
157 uint32_t io_mode;
158 uint64_t time_stamp;
159};
160
161void q6asm_audio_client_free(struct audio_client *ac);
162
163struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
164
Ben Romberger61754dc2011-10-31 18:25:41 -0700165struct audio_client *q6asm_get_audio_client(int session_id);
166
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700167int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
168 struct audio_client *ac,
169 unsigned int bufsz,
170 unsigned int bufcnt);
171int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
172 /* 1:Out,0:In */,
173 struct audio_client *ac,
174 unsigned int bufsz,
175 unsigned int bufcnt);
176
177int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
178 struct audio_client *ac);
179
180int q6asm_open_read(struct audio_client *ac, uint32_t format);
181
182int q6asm_open_write(struct audio_client *ac, uint32_t format);
183
Santosh Mardi23321202012-03-22 04:33:25 +0530184int q6asm_open_write_compressed(struct audio_client *ac, uint32_t format);
185
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700186int q6asm_open_read_write(struct audio_client *ac,
187 uint32_t rd_format,
188 uint32_t wr_format);
189
190int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
191 uint32_t lsw_ts, uint32_t flags);
192int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
193 uint32_t lsw_ts, uint32_t flags);
194
195int q6asm_async_write(struct audio_client *ac,
196 struct audio_aio_write_param *param);
197
198int q6asm_async_read(struct audio_client *ac,
199 struct audio_aio_read_param *param);
200
201int q6asm_read(struct audio_client *ac);
202int q6asm_read_nolock(struct audio_client *ac);
203
204int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add,
205 int dir, uint32_t bufsz, uint32_t bufcnt);
206
207int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add,
208 int dir);
209
210int q6asm_run(struct audio_client *ac, uint32_t flags,
211 uint32_t msw_ts, uint32_t lsw_ts);
212
213int q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
214 uint32_t msw_ts, uint32_t lsw_ts);
215
216int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable);
217
218int q6asm_cmd(struct audio_client *ac, int cmd);
219
220int q6asm_cmd_nowait(struct audio_client *ac, int cmd);
221
222void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac,
223 uint32_t *size, uint32_t *idx);
224
Jay Wang9cf59a02011-08-10 16:58:40 -0700225void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
226 uint32_t *size, uint32_t *idx);
227
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700228int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac);
229
230/* File format specific configurations to be added below */
231
232int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
233 uint32_t frames_per_buf,
234 uint32_t sample_rate, uint32_t channels,
235 uint32_t bit_rate,
236 uint32_t mode, uint32_t format);
237
238int q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
239 uint32_t rate, uint32_t channels);
240
Mingming Yin647e9ea2012-03-17 19:56:10 -0700241int q6asm_enc_cfg_blk_multi_ch_pcm(struct audio_client *ac,
242 uint32_t rate, uint32_t channels);
243
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700244int q6asm_enable_sbrps(struct audio_client *ac,
245 uint32_t sbr_ps);
246
Swaminathan Sathappan70765cd2011-07-19 18:42:47 -0700247int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
248 uint16_t sce_left, uint16_t sce_right);
249
Swaminathan Sathappan6f530882012-05-01 16:42:22 -0700250int q6asm_set_encdec_chan_map(struct audio_client *ac,
251 uint32_t num_channels);
252
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
254 uint16_t min_rate, uint16_t max_rate,
255 uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
256
257int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
258 uint16_t min_rate, uint16_t max_rate,
259 uint16_t rate_modulation_cmd);
260
261int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
262 uint16_t band_mode, uint16_t dtx_enable);
263
Alex Wong2caeecc2011-10-28 10:52:15 +0530264int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
265 uint16_t band_mode, uint16_t dtx_enable);
266
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700267int q6asm_media_format_block_pcm(struct audio_client *ac,
268 uint32_t rate, uint32_t channels);
269
Kiran Kandi5e809b02012-01-31 00:24:33 -0800270int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
271 uint32_t rate, uint32_t channels);
272
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700273int q6asm_media_format_block_aac(struct audio_client *ac,
274 struct asm_aac_cfg *cfg);
275
Bharath Ramachandramurthy4f71d502011-10-23 19:45:22 -0700276int q6asm_media_format_block_multi_aac(struct audio_client *ac,
277 struct asm_aac_cfg *cfg);
278
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700279int q6asm_media_format_block_wma(struct audio_client *ac,
280 void *cfg);
281
282int q6asm_media_format_block_wmapro(struct audio_client *ac,
283 void *cfg);
284
285/* PP specific */
286int q6asm_equalizer(struct audio_client *ac, void *eq);
287
288/* Send Volume Command */
289int q6asm_set_volume(struct audio_client *ac, int volume);
290
291/* Set SoftPause Params */
292int q6asm_set_softpause(struct audio_client *ac,
293 struct asm_softpause_params *param);
294
Swaminathan Sathappanb0021cd2011-08-31 15:20:12 -0700295/* Set Softvolume Params */
296int q6asm_set_softvolume(struct audio_client *ac,
297 struct asm_softvolume_params *param);
298
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700299/* Send left-right channel gain */
300int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
301
302/* Enable Mute/unmute flag */
303int q6asm_set_mute(struct audio_client *ac, int muteflag);
304
305uint64_t q6asm_get_session_time(struct audio_client *ac);
306
307/* Client can set the IO mode to either AIO/SIO mode */
308int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
309
Ben Romberger45b351c2011-07-20 22:37:27 -0700310#ifdef CONFIG_RTAC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700311/* Get Service ID for APR communication */
312int q6asm_get_apr_service_id(int session_id);
313#endif
314
Alex Wong2caeecc2011-10-28 10:52:15 +0530315/* Common format block without any payload
316*/
317int q6asm_media_format_block(struct audio_client *ac, uint32_t format);
318
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700319#endif /* __Q6_ASM_H__ */