blob: f9d2a404f9df644547625dc7b26fdab517714530 [file] [log] [blame]
Subhash Chandra Bose Naripeddye6562162012-12-12 15:11:38 -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 Humpherys71a6ac92012-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
Phani Kumar Uppalapatif3c5fac2012-10-13 15:27:23 -070069#define COMPRESSED_IO 0x0040
Harmandeep Singheaf59b42012-06-05 21:46:02 -070070#define NT_MODE 0x0400
71
72
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070073#define NO_TIMESTAMP 0xFF00
74#define SET_TIMESTAMP 0x0000
75
76#define SOFT_PAUSE_ENABLE 1
77#define SOFT_PAUSE_DISABLE 0
78
79#define SESSION_MAX 0x08
80
81#define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */
82#define SOFT_PAUSE_STEP 2000 /* Step value 2ms or 2000us */
83enum {
84 SOFT_PAUSE_CURVE_LINEAR = 0,
85 SOFT_PAUSE_CURVE_EXP,
86 SOFT_PAUSE_CURVE_LOG,
87};
88
89#define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */
90#define SOFT_VOLUME_STEP 2000 /* Step value 2ms or 2000us */
91enum {
92 SOFT_VOLUME_CURVE_LINEAR = 0,
93 SOFT_VOLUME_CURVE_EXP,
94 SOFT_VOLUME_CURVE_LOG,
95};
96
97typedef void (*app_cb)(uint32_t opcode, uint32_t token,
98 uint32_t *payload, void *priv);
99
100struct audio_buffer {
101 dma_addr_t phys;
102 void *data;
103 uint32_t used;
104 uint32_t size;/* size of buffer */
105 uint32_t actual_size; /* actual number of bytes read by DSP */
106 struct ion_handle *handle;
107 struct ion_client *client;
108};
109
110struct audio_aio_write_param {
111 unsigned long paddr;
112 uint32_t len;
113 uint32_t uid;
114 uint32_t lsw_ts;
115 uint32_t msw_ts;
116 uint32_t flags;
117};
118
119struct audio_aio_read_param {
120 unsigned long paddr;
121 uint32_t len;
122 uint32_t uid;
123};
124
125struct audio_port_data {
126 struct audio_buffer *buf;
127 uint32_t max_buf_cnt;
128 uint32_t dsp_buf;
129 uint32_t cpu_buf;
130 struct list_head mem_map_handle;
131 uint32_t tmp_hdl;
132 /* read or write locks */
133 struct mutex lock;
134 spinlock_t dsp_lock;
135};
136
137struct audio_client {
138 int session;
139 app_cb cb;
140 atomic_t cmd_state;
141 /* Relative or absolute TS */
Phani Kumar Uppalapatic268df72013-02-19 19:06:41 -0800142 atomic_t time_flag;
Phani Kumar Uppalapati70a5d132012-12-05 11:35:13 -0800143 atomic_t nowait_cmd_cnt;
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700144 void *priv;
145 uint32_t io_mode;
146 uint64_t time_stamp;
147 struct apr_svc *apr;
148 struct apr_svc *mmap_apr;
149 struct mutex cmd_lock;
150 /* idx:1 out port, 0: in port*/
151 struct audio_port_data port[2];
152 wait_queue_head_t cmd_wait;
Phani Kumar Uppalapatic268df72013-02-19 19:06:41 -0800153 wait_queue_head_t time_wait;
Phani Kumar Uppalapati85b7c9b2013-02-19 09:59:47 -0800154 bool perf_mode;
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700155};
156
157void q6asm_audio_client_free(struct audio_client *ac);
158
159struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
160
161struct audio_client *q6asm_get_audio_client(int session_id);
162
163int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
164 struct audio_client *ac,
165 unsigned int bufsz,
166 unsigned int bufcnt);
167int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
168 /* 1:Out,0:In */,
169 struct audio_client *ac,
170 unsigned int bufsz,
171 unsigned int bufcnt);
172
173int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
174 struct audio_client *ac);
175
176int q6asm_open_read(struct audio_client *ac, uint32_t format
177 /*, uint16_t bits_per_sample*/);
178
179int q6asm_open_write(struct audio_client *ac, uint32_t format
180 /*, uint16_t bits_per_sample*/);
181
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800182int q6asm_open_write_v2(struct audio_client *ac, uint32_t format,
183 uint16_t bits_per_sample);
184
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700185int q6asm_open_read_write(struct audio_client *ac,
186 uint32_t rd_format,
187 uint32_t wr_format);
188
189int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
190 uint32_t lsw_ts, uint32_t flags);
191int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
192 uint32_t lsw_ts, uint32_t flags);
193
194int q6asm_async_write(struct audio_client *ac,
195 struct audio_aio_write_param *param);
196
197int q6asm_async_read(struct audio_client *ac,
198 struct audio_aio_read_param *param);
199
200int q6asm_read(struct audio_client *ac);
201int q6asm_read_nolock(struct audio_client *ac);
202
203int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add,
204 int dir, uint32_t bufsz, uint32_t bufcnt);
205
206int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add,
207 int dir);
208
209int q6asm_run(struct audio_client *ac, uint32_t flags,
210 uint32_t msw_ts, uint32_t lsw_ts);
211
212int q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
213 uint32_t msw_ts, uint32_t lsw_ts);
214
215int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable);
216
217int q6asm_cmd(struct audio_client *ac, int cmd);
218
219int q6asm_cmd_nowait(struct audio_client *ac, int cmd);
220
221void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac,
222 uint32_t *size, uint32_t *idx);
223
224void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
225 uint32_t *size, uint32_t *idx);
226
227int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac);
228
229/* File format specific configurations to be added below */
230
231int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
232 uint32_t frames_per_buf,
233 uint32_t sample_rate, uint32_t channels,
234 uint32_t bit_rate,
235 uint32_t mode, uint32_t format);
236
237int q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
238 uint32_t rate, uint32_t channels);
239
240int q6asm_set_encdec_chan_map(struct audio_client *ac,
241 uint32_t num_channels);
242
Harmandeep Singheaf59b42012-06-05 21:46:02 -0700243int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
244 uint32_t rate, uint32_t channels);
245
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700246int q6asm_enable_sbrps(struct audio_client *ac,
247 uint32_t sbr_ps);
248
249int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
250 uint16_t sce_left, uint16_t sce_right);
251
Amal Paul2ca061b2013-02-25 14:57:33 -0800252int q6asm_cfg_aac_sel_mix_coef(struct audio_client *ac, uint32_t mix_coeff);
253
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700254int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
255 uint16_t min_rate, uint16_t max_rate,
256 uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
257
258int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
259 uint16_t min_rate, uint16_t max_rate,
260 uint16_t rate_modulation_cmd);
261
262int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
263 uint16_t band_mode, uint16_t dtx_enable);
264
265int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
266 uint16_t band_mode, uint16_t dtx_enable);
267
268int q6asm_media_format_block_pcm(struct audio_client *ac,
269 uint32_t rate, uint32_t channels);
270
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800271int q6asm_media_format_block_pcm_format_support(struct audio_client *ac,
272 uint32_t rate, uint32_t channels,
273 uint16_t bits_per_sample);
274
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700275int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
Subhash Chandra Bose Naripeddye6562162012-12-12 15:11:38 -0800276 uint32_t rate, uint32_t channels,
277 bool use_default_chmap, char *channel_map);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700278
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800279int q6asm_media_format_block_multi_ch_pcm_v2(
280 struct audio_client *ac,
281 uint32_t rate, uint32_t channels,
282 bool use_default_chmap, char *channel_map,
283 uint16_t bits_per_sample);
284
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700285int q6asm_media_format_block_aac(struct audio_client *ac,
286 struct asm_aac_cfg *cfg);
287
288int q6asm_media_format_block_multi_aac(struct audio_client *ac,
289 struct asm_aac_cfg *cfg);
290
291int q6asm_media_format_block_wma(struct audio_client *ac,
292 void *cfg);
293
294int q6asm_media_format_block_wmapro(struct audio_client *ac,
295 void *cfg);
296
Phani Kumar Uppalapati1e0324c2013-03-21 14:13:23 -0700297int q6asm_media_format_block_amrwbplus(struct audio_client *ac,
298 struct asm_amrwbplus_cfg *cfg);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700299/* PP specific */
300int q6asm_equalizer(struct audio_client *ac, void *eq);
301
302/* Send Volume Command */
303int q6asm_set_volume(struct audio_client *ac, int volume);
304
305/* Set SoftPause Params */
306int q6asm_set_softpause(struct audio_client *ac,
307 struct asm_softpause_params *param);
308
309/* Set Softvolume Params */
310int q6asm_set_softvolume(struct audio_client *ac,
311 struct asm_softvolume_params *param);
312
313/* Send left-right channel gain */
314int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
315
316/* Enable Mute/unmute flag */
317int q6asm_set_mute(struct audio_client *ac, int muteflag);
318
Patrick Laifc8f2242013-01-06 00:52:34 -0800319int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700320
321/* Client can set the IO mode to either AIO/SIO mode */
322int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
323
324/* Get Service ID for APR communication */
325int q6asm_get_apr_service_id(int session_id);
326
327/* Common format block without any payload
328*/
329int q6asm_media_format_block(struct audio_client *ac, uint32_t format);
330
331#endif /* __Q6_ASM_H__ */