blob: 0dd14e6abfa684f4716e4b8606d95252f6cb3f94 [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>
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070016#include <sound/apr_audio-v2.h>
17#include <linux/list.h>
Mitchel Humpherys71a6ac92012-09-06 10:22:31 -070018#include <linux/msm_ion.h>
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070019
20#define IN 0x000
21#define OUT 0x001
22#define CH_MODE_MONO 0x001
23#define CH_MODE_STEREO 0x002
24
25#define FORMAT_LINEAR_PCM 0x0000
26#define FORMAT_DTMF 0x0001
27#define FORMAT_ADPCM 0x0002
28#define FORMAT_YADPCM 0x0003
29#define FORMAT_MP3 0x0004
30#define FORMAT_MPEG4_AAC 0x0005
31#define FORMAT_AMRNB 0x0006
32#define FORMAT_AMRWB 0x0007
33#define FORMAT_V13K 0x0008
34#define FORMAT_EVRC 0x0009
35#define FORMAT_EVRCB 0x000a
36#define FORMAT_EVRCWB 0x000b
37#define FORMAT_MIDI 0x000c
38#define FORMAT_SBC 0x000d
39#define FORMAT_WMA_V10PRO 0x000e
40#define FORMAT_WMA_V9 0x000f
41#define FORMAT_AMR_WB_PLUS 0x0010
42#define FORMAT_MPEG4_MULTI_AAC 0x0011
43#define FORMAT_MULTI_CHANNEL_LINEAR_PCM 0x0012
Subhash Chandra Bose Naripeddyaf3e03d2013-02-08 11:35:55 -080044#define FORMAT_AC3 0x0013
45#define FORMAT_EAC3 0x0014
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070046
47#define ENCDEC_SBCBITRATE 0x0001
48#define ENCDEC_IMMEDIATE_DECODE 0x0002
49#define ENCDEC_CFG_BLK 0x0003
50
51#define CMD_PAUSE 0x0001
52#define CMD_FLUSH 0x0002
53#define CMD_EOS 0x0003
54#define CMD_CLOSE 0x0004
55#define CMD_OUT_FLUSH 0x0005
56
57/* bit 0:1 represents priority of stream */
58#define STREAM_PRIORITY_NORMAL 0x0000
59#define STREAM_PRIORITY_LOW 0x0001
60#define STREAM_PRIORITY_HIGH 0x0002
61
62/* bit 4 represents META enable of encoded data buffer */
63#define BUFFER_META_ENABLE 0x0010
64
65/* Enable Sample_Rate/Channel_Mode notification event from Decoder */
66#define SR_CM_NOTIFY_ENABLE 0x0004
67
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070068#define SYNC_IO_MODE 0x0001
Harmandeep Singheaf59b42012-06-05 21:46:02 -070069#define ASYNC_IO_MODE 0x0002
Phani Kumar Uppalapatif3c5fac2012-10-13 15:27:23 -070070#define COMPRESSED_IO 0x0040
Harmandeep Singheaf59b42012-06-05 21:46:02 -070071#define NT_MODE 0x0400
72
73
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070074#define NO_TIMESTAMP 0xFF00
75#define SET_TIMESTAMP 0x0000
76
77#define SOFT_PAUSE_ENABLE 1
78#define SOFT_PAUSE_DISABLE 0
79
80#define SESSION_MAX 0x08
81
82#define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */
83#define SOFT_PAUSE_STEP 2000 /* Step value 2ms or 2000us */
84enum {
85 SOFT_PAUSE_CURVE_LINEAR = 0,
86 SOFT_PAUSE_CURVE_EXP,
87 SOFT_PAUSE_CURVE_LOG,
88};
89
90#define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */
91#define SOFT_VOLUME_STEP 2000 /* Step value 2ms or 2000us */
92enum {
93 SOFT_VOLUME_CURVE_LINEAR = 0,
94 SOFT_VOLUME_CURVE_EXP,
95 SOFT_VOLUME_CURVE_LOG,
96};
97
98typedef void (*app_cb)(uint32_t opcode, uint32_t token,
99 uint32_t *payload, void *priv);
100
101struct audio_buffer {
102 dma_addr_t phys;
103 void *data;
104 uint32_t used;
105 uint32_t size;/* size of buffer */
106 uint32_t actual_size; /* actual number of bytes read by DSP */
107 struct ion_handle *handle;
108 struct ion_client *client;
109};
110
111struct audio_aio_write_param {
112 unsigned long paddr;
113 uint32_t len;
114 uint32_t uid;
115 uint32_t lsw_ts;
116 uint32_t msw_ts;
117 uint32_t flags;
118};
119
120struct audio_aio_read_param {
121 unsigned long paddr;
122 uint32_t len;
123 uint32_t uid;
124};
125
126struct audio_port_data {
127 struct audio_buffer *buf;
128 uint32_t max_buf_cnt;
129 uint32_t dsp_buf;
130 uint32_t cpu_buf;
131 struct list_head mem_map_handle;
132 uint32_t tmp_hdl;
133 /* read or write locks */
134 struct mutex lock;
135 spinlock_t dsp_lock;
136};
137
138struct audio_client {
139 int session;
140 app_cb cb;
141 atomic_t cmd_state;
142 /* Relative or absolute TS */
Phani Kumar Uppalapatic268df72013-02-19 19:06:41 -0800143 atomic_t time_flag;
Phani Kumar Uppalapati70a5d132012-12-05 11:35:13 -0800144 atomic_t nowait_cmd_cnt;
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700145 void *priv;
146 uint32_t io_mode;
147 uint64_t time_stamp;
148 struct apr_svc *apr;
149 struct apr_svc *mmap_apr;
150 struct mutex cmd_lock;
151 /* idx:1 out port, 0: in port*/
152 struct audio_port_data port[2];
153 wait_queue_head_t cmd_wait;
Phani Kumar Uppalapatic268df72013-02-19 19:06:41 -0800154 wait_queue_head_t time_wait;
Phani Kumar Uppalapati85b7c9b2013-02-19 09:59:47 -0800155 bool perf_mode;
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700156};
157
158void q6asm_audio_client_free(struct audio_client *ac);
159
160struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
161
162struct audio_client *q6asm_get_audio_client(int session_id);
163
164int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
165 struct audio_client *ac,
166 unsigned int bufsz,
167 unsigned int bufcnt);
168int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
169 /* 1:Out,0:In */,
170 struct audio_client *ac,
171 unsigned int bufsz,
172 unsigned int bufcnt);
173
174int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
175 struct audio_client *ac);
176
177int q6asm_open_read(struct audio_client *ac, uint32_t format
178 /*, uint16_t bits_per_sample*/);
179
180int q6asm_open_write(struct audio_client *ac, uint32_t format
181 /*, uint16_t bits_per_sample*/);
182
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800183int q6asm_open_write_v2(struct audio_client *ac, uint32_t format,
184 uint16_t bits_per_sample);
185
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -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
225void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
226 uint32_t *size, uint32_t *idx);
227
228int 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
241int q6asm_set_encdec_chan_map(struct audio_client *ac,
242 uint32_t num_channels);
243
Harmandeep Singheaf59b42012-06-05 21:46:02 -0700244int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
245 uint32_t rate, uint32_t channels);
246
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700247int q6asm_enable_sbrps(struct audio_client *ac,
248 uint32_t sbr_ps);
249
250int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
251 uint16_t sce_left, uint16_t sce_right);
252
Amal Paul2ca061b2013-02-25 14:57:33 -0800253int q6asm_cfg_aac_sel_mix_coef(struct audio_client *ac, uint32_t mix_coeff);
254
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700255int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
256 uint16_t min_rate, uint16_t max_rate,
257 uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
258
259int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
260 uint16_t min_rate, uint16_t max_rate,
261 uint16_t rate_modulation_cmd);
262
263int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
264 uint16_t band_mode, uint16_t dtx_enable);
265
266int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
267 uint16_t band_mode, uint16_t dtx_enable);
268
269int q6asm_media_format_block_pcm(struct audio_client *ac,
270 uint32_t rate, uint32_t channels);
271
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800272int q6asm_media_format_block_pcm_format_support(struct audio_client *ac,
273 uint32_t rate, uint32_t channels,
274 uint16_t bits_per_sample);
275
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700276int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
Subhash Chandra Bose Naripeddye6562162012-12-12 15:11:38 -0800277 uint32_t rate, uint32_t channels,
278 bool use_default_chmap, char *channel_map);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700279
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800280int q6asm_media_format_block_multi_ch_pcm_v2(
281 struct audio_client *ac,
282 uint32_t rate, uint32_t channels,
283 bool use_default_chmap, char *channel_map,
284 uint16_t bits_per_sample);
285
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700286int q6asm_media_format_block_aac(struct audio_client *ac,
287 struct asm_aac_cfg *cfg);
288
289int q6asm_media_format_block_multi_aac(struct audio_client *ac,
290 struct asm_aac_cfg *cfg);
291
292int q6asm_media_format_block_wma(struct audio_client *ac,
293 void *cfg);
294
295int q6asm_media_format_block_wmapro(struct audio_client *ac,
296 void *cfg);
297
Phani Kumar Uppalapati1e0324c2013-03-21 14:13:23 -0700298int q6asm_media_format_block_amrwbplus(struct audio_client *ac,
299 struct asm_amrwbplus_cfg *cfg);
Subhash Chandra Bose Naripeddyaf3e03d2013-02-08 11:35:55 -0800300
301int q6asm_ds1_set_endp_params(struct audio_client *ac,
302 int param_id, int param_value);
303
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700304/* PP specific */
305int q6asm_equalizer(struct audio_client *ac, void *eq);
306
307/* Send Volume Command */
308int q6asm_set_volume(struct audio_client *ac, int volume);
309
310/* Set SoftPause Params */
311int q6asm_set_softpause(struct audio_client *ac,
312 struct asm_softpause_params *param);
313
314/* Set Softvolume Params */
315int q6asm_set_softvolume(struct audio_client *ac,
316 struct asm_softvolume_params *param);
317
318/* Send left-right channel gain */
319int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
320
321/* Enable Mute/unmute flag */
322int q6asm_set_mute(struct audio_client *ac, int muteflag);
323
Patrick Laifc8f2242013-01-06 00:52:34 -0800324int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700325
326/* Client can set the IO mode to either AIO/SIO mode */
327int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
328
329/* Get Service ID for APR communication */
330int q6asm_get_apr_service_id(int session_id);
331
332/* Common format block without any payload
333*/
334int q6asm_media_format_block(struct audio_client *ac, uint32_t format);
335
336#endif /* __Q6_ASM_H__ */