blob: f547dcc68f23240c07eb9e499be9c7846815c14c [file] [log] [blame]
Amal Paul6e0f7982013-02-21 19:36:35 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -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_V2_H__
13#define __Q6_ASM_V2_H__
14
15#include <mach/qdsp6v2/apr.h>
16#include <mach/msm_subsystem_map.h>
17#include <sound/apr_audio-v2.h>
18#include <linux/list.h>
Mitchel Humpherys76a84982012-09-06 10:22:31 -070019#include <linux/msm_ion.h>
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070020
21#define IN 0x000
22#define OUT 0x001
23#define CH_MODE_MONO 0x001
24#define CH_MODE_STEREO 0x002
25
26#define FORMAT_LINEAR_PCM 0x0000
27#define FORMAT_DTMF 0x0001
28#define FORMAT_ADPCM 0x0002
29#define FORMAT_YADPCM 0x0003
30#define FORMAT_MP3 0x0004
31#define FORMAT_MPEG4_AAC 0x0005
32#define FORMAT_AMRNB 0x0006
33#define FORMAT_AMRWB 0x0007
34#define FORMAT_V13K 0x0008
35#define FORMAT_EVRC 0x0009
36#define FORMAT_EVRCB 0x000a
37#define FORMAT_EVRCWB 0x000b
38#define FORMAT_MIDI 0x000c
39#define FORMAT_SBC 0x000d
40#define FORMAT_WMA_V10PRO 0x000e
41#define FORMAT_WMA_V9 0x000f
42#define FORMAT_AMR_WB_PLUS 0x0010
43#define FORMAT_MPEG4_MULTI_AAC 0x0011
44#define FORMAT_MULTI_CHANNEL_LINEAR_PCM 0x0012
45
46#define ENCDEC_SBCBITRATE 0x0001
47#define ENCDEC_IMMEDIATE_DECODE 0x0002
48#define ENCDEC_CFG_BLK 0x0003
49
50#define CMD_PAUSE 0x0001
51#define CMD_FLUSH 0x0002
52#define CMD_EOS 0x0003
53#define CMD_CLOSE 0x0004
54#define CMD_OUT_FLUSH 0x0005
55
56/* bit 0:1 represents priority of stream */
57#define STREAM_PRIORITY_NORMAL 0x0000
58#define STREAM_PRIORITY_LOW 0x0001
59#define STREAM_PRIORITY_HIGH 0x0002
60
61/* bit 4 represents META enable of encoded data buffer */
62#define BUFFER_META_ENABLE 0x0010
63
64/* Enable Sample_Rate/Channel_Mode notification event from Decoder */
65#define SR_CM_NOTIFY_ENABLE 0x0004
66
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070067#define SYNC_IO_MODE 0x0001
Harmandeep Singheaf59b42012-06-05 21:46:02 -070068#define ASYNC_IO_MODE 0x0002
69#define NT_MODE 0x0400
70
71
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070072#define NO_TIMESTAMP 0xFF00
73#define SET_TIMESTAMP 0x0000
74
75#define SOFT_PAUSE_ENABLE 1
76#define SOFT_PAUSE_DISABLE 0
77
78#define SESSION_MAX 0x08
79
80#define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */
81#define SOFT_PAUSE_STEP 2000 /* Step value 2ms or 2000us */
82enum {
83 SOFT_PAUSE_CURVE_LINEAR = 0,
84 SOFT_PAUSE_CURVE_EXP,
85 SOFT_PAUSE_CURVE_LOG,
86};
87
88#define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */
89#define SOFT_VOLUME_STEP 2000 /* Step value 2ms or 2000us */
90enum {
91 SOFT_VOLUME_CURVE_LINEAR = 0,
92 SOFT_VOLUME_CURVE_EXP,
93 SOFT_VOLUME_CURVE_LOG,
94};
95
96typedef void (*app_cb)(uint32_t opcode, uint32_t token,
97 uint32_t *payload, void *priv);
98
99struct audio_buffer {
100 dma_addr_t phys;
101 void *data;
102 uint32_t used;
103 uint32_t size;/* size of buffer */
104 uint32_t actual_size; /* actual number of bytes read by DSP */
105 struct ion_handle *handle;
106 struct ion_client *client;
107};
108
109struct audio_aio_write_param {
110 unsigned long paddr;
111 uint32_t len;
112 uint32_t uid;
113 uint32_t lsw_ts;
114 uint32_t msw_ts;
115 uint32_t flags;
116};
117
118struct audio_aio_read_param {
119 unsigned long paddr;
120 uint32_t len;
121 uint32_t uid;
122};
123
124struct audio_port_data {
125 struct audio_buffer *buf;
126 uint32_t max_buf_cnt;
127 uint32_t dsp_buf;
128 uint32_t cpu_buf;
129 struct list_head mem_map_handle;
130 uint32_t tmp_hdl;
131 /* read or write locks */
132 struct mutex lock;
133 spinlock_t dsp_lock;
134};
135
136struct audio_client {
137 int session;
138 app_cb cb;
139 atomic_t cmd_state;
140 /* Relative or absolute TS */
141 uint32_t time_flag;
142 void *priv;
143 uint32_t io_mode;
144 uint64_t time_stamp;
145 struct apr_svc *apr;
146 struct apr_svc *mmap_apr;
147 struct mutex cmd_lock;
148 /* idx:1 out port, 0: in port*/
149 struct audio_port_data port[2];
150 wait_queue_head_t cmd_wait;
151};
152
153void q6asm_audio_client_free(struct audio_client *ac);
154
155struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
156
157struct audio_client *q6asm_get_audio_client(int session_id);
158
159int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
160 struct audio_client *ac,
161 unsigned int bufsz,
162 unsigned int bufcnt);
163int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
164 /* 1:Out,0:In */,
165 struct audio_client *ac,
166 unsigned int bufsz,
167 unsigned int bufcnt);
168
169int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
170 struct audio_client *ac);
171
172int q6asm_open_read(struct audio_client *ac, uint32_t format
173 /*, uint16_t bits_per_sample*/);
174
175int q6asm_open_write(struct audio_client *ac, uint32_t format
176 /*, uint16_t bits_per_sample*/);
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
217void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
218 uint32_t *size, uint32_t *idx);
219
220int 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_set_encdec_chan_map(struct audio_client *ac,
234 uint32_t num_channels);
235
Harmandeep Singheaf59b42012-06-05 21:46:02 -0700236int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
237 uint32_t rate, uint32_t channels);
238
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700239int q6asm_enable_sbrps(struct audio_client *ac,
240 uint32_t sbr_ps);
241
242int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
243 uint16_t sce_left, uint16_t sce_right);
244
Amal Paul6e0f7982013-02-21 19:36:35 -0800245int q6asm_cfg_aac_sel_mix_coef(struct audio_client *ac, uint32_t mix_coeff);
246
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700247int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
248 uint16_t min_rate, uint16_t max_rate,
249 uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
250
251int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
252 uint16_t min_rate, uint16_t max_rate,
253 uint16_t rate_modulation_cmd);
254
255int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
256 uint16_t band_mode, uint16_t dtx_enable);
257
258int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
259 uint16_t band_mode, uint16_t dtx_enable);
260
261int q6asm_media_format_block_pcm(struct audio_client *ac,
262 uint32_t rate, uint32_t channels);
263
264int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
265 uint32_t rate, uint32_t channels);
266
267int q6asm_media_format_block_aac(struct audio_client *ac,
268 struct asm_aac_cfg *cfg);
269
270int q6asm_media_format_block_multi_aac(struct audio_client *ac,
271 struct asm_aac_cfg *cfg);
272
273int q6asm_media_format_block_wma(struct audio_client *ac,
274 void *cfg);
275
276int q6asm_media_format_block_wmapro(struct audio_client *ac,
277 void *cfg);
278
279/* PP specific */
280int q6asm_equalizer(struct audio_client *ac, void *eq);
281
282/* Send Volume Command */
283int q6asm_set_volume(struct audio_client *ac, int volume);
284
285/* Set SoftPause Params */
286int q6asm_set_softpause(struct audio_client *ac,
287 struct asm_softpause_params *param);
288
289/* Set Softvolume Params */
290int q6asm_set_softvolume(struct audio_client *ac,
291 struct asm_softvolume_params *param);
292
293/* Send left-right channel gain */
294int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
295
296/* Enable Mute/unmute flag */
297int q6asm_set_mute(struct audio_client *ac, int muteflag);
298
299uint64_t q6asm_get_session_time(struct audio_client *ac);
300
301/* Client can set the IO mode to either AIO/SIO mode */
302int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
303
304/* Get Service ID for APR communication */
305int q6asm_get_apr_service_id(int session_id);
306
307/* Common format block without any payload
308*/
309int q6asm_media_format_block(struct audio_client *ac, uint32_t format);
310
311#endif /* __Q6_ASM_H__ */