blob: 213868948a9eea9f1669737176c807353be0ee3d [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
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
Krishnankutty Kolathappilly05c7bd92013-04-27 23:34:53 -070081/* payload structure bytes */
82#define READDONE_IDX_STATUS 0
83#define READDONE_IDX_BUFADD_LSW 1
84#define READDONE_IDX_BUFADD_MSW 2
85#define READDONE_IDX_MEMMAP_HDL 3
86#define READDONE_IDX_SIZE 4
87#define READDONE_IDX_OFFSET 5
88#define READDONE_IDX_LSW_TS 6
89#define READDONE_IDX_MSW_TS 7
90#define READDONE_IDX_FLAGS 8
91#define READDONE_IDX_NUMFRAMES 9
92#define READDONE_IDX_SEQ_ID 10
93
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070094#define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */
95#define SOFT_PAUSE_STEP 2000 /* Step value 2ms or 2000us */
96enum {
97 SOFT_PAUSE_CURVE_LINEAR = 0,
98 SOFT_PAUSE_CURVE_EXP,
99 SOFT_PAUSE_CURVE_LOG,
100};
101
102#define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */
103#define SOFT_VOLUME_STEP 2000 /* Step value 2ms or 2000us */
104enum {
105 SOFT_VOLUME_CURVE_LINEAR = 0,
106 SOFT_VOLUME_CURVE_EXP,
107 SOFT_VOLUME_CURVE_LOG,
108};
109
110typedef void (*app_cb)(uint32_t opcode, uint32_t token,
111 uint32_t *payload, void *priv);
112
113struct audio_buffer {
114 dma_addr_t phys;
115 void *data;
116 uint32_t used;
117 uint32_t size;/* size of buffer */
118 uint32_t actual_size; /* actual number of bytes read by DSP */
119 struct ion_handle *handle;
120 struct ion_client *client;
121};
122
123struct audio_aio_write_param {
124 unsigned long paddr;
125 uint32_t len;
126 uint32_t uid;
127 uint32_t lsw_ts;
128 uint32_t msw_ts;
129 uint32_t flags;
130};
131
132struct audio_aio_read_param {
133 unsigned long paddr;
134 uint32_t len;
135 uint32_t uid;
136};
137
138struct audio_port_data {
139 struct audio_buffer *buf;
140 uint32_t max_buf_cnt;
141 uint32_t dsp_buf;
142 uint32_t cpu_buf;
143 struct list_head mem_map_handle;
144 uint32_t tmp_hdl;
145 /* read or write locks */
146 struct mutex lock;
147 spinlock_t dsp_lock;
148};
149
150struct audio_client {
151 int session;
152 app_cb cb;
153 atomic_t cmd_state;
154 /* Relative or absolute TS */
Phani Kumar Uppalapatic268df72013-02-19 19:06:41 -0800155 atomic_t time_flag;
Phani Kumar Uppalapati70a5d132012-12-05 11:35:13 -0800156 atomic_t nowait_cmd_cnt;
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700157 void *priv;
158 uint32_t io_mode;
159 uint64_t time_stamp;
160 struct apr_svc *apr;
161 struct apr_svc *mmap_apr;
162 struct mutex cmd_lock;
163 /* idx:1 out port, 0: in port*/
164 struct audio_port_data port[2];
165 wait_queue_head_t cmd_wait;
Phani Kumar Uppalapatic268df72013-02-19 19:06:41 -0800166 wait_queue_head_t time_wait;
Phani Kumar Uppalapati85b7c9b2013-02-19 09:59:47 -0800167 bool perf_mode;
Fred Ohc274a7a2013-03-25 13:59:17 -0700168 /* audio cache operations fptr*/
169 int (*fptr_cache_ops)(struct audio_buffer *abuff, int cache_op);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700170};
171
172void q6asm_audio_client_free(struct audio_client *ac);
173
174struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
175
176struct audio_client *q6asm_get_audio_client(int session_id);
177
178int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
179 struct audio_client *ac,
180 unsigned int bufsz,
181 unsigned int bufcnt);
182int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
183 /* 1:Out,0:In */,
184 struct audio_client *ac,
185 unsigned int bufsz,
186 unsigned int bufcnt);
187
188int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
189 struct audio_client *ac);
190
191int q6asm_open_read(struct audio_client *ac, uint32_t format
192 /*, uint16_t bits_per_sample*/);
193
194int q6asm_open_write(struct audio_client *ac, uint32_t format
195 /*, uint16_t bits_per_sample*/);
196
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800197int q6asm_open_write_v2(struct audio_client *ac, uint32_t format,
198 uint16_t bits_per_sample);
199
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700200int q6asm_open_read_write(struct audio_client *ac,
201 uint32_t rd_format,
202 uint32_t wr_format);
203
204int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
205 uint32_t lsw_ts, uint32_t flags);
206int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
207 uint32_t lsw_ts, uint32_t flags);
208
209int q6asm_async_write(struct audio_client *ac,
210 struct audio_aio_write_param *param);
211
212int q6asm_async_read(struct audio_client *ac,
213 struct audio_aio_read_param *param);
214
215int q6asm_read(struct audio_client *ac);
216int q6asm_read_nolock(struct audio_client *ac);
217
218int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add,
219 int dir, uint32_t bufsz, uint32_t bufcnt);
220
221int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add,
222 int dir);
223
224int q6asm_run(struct audio_client *ac, uint32_t flags,
225 uint32_t msw_ts, uint32_t lsw_ts);
226
227int q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
228 uint32_t msw_ts, uint32_t lsw_ts);
229
230int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable);
231
232int q6asm_cmd(struct audio_client *ac, int cmd);
233
234int q6asm_cmd_nowait(struct audio_client *ac, int cmd);
235
236void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac,
237 uint32_t *size, uint32_t *idx);
238
239void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
240 uint32_t *size, uint32_t *idx);
241
242int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac);
243
244/* File format specific configurations to be added below */
245
246int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
247 uint32_t frames_per_buf,
248 uint32_t sample_rate, uint32_t channels,
249 uint32_t bit_rate,
250 uint32_t mode, uint32_t format);
251
252int q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
253 uint32_t rate, uint32_t channels);
254
255int q6asm_set_encdec_chan_map(struct audio_client *ac,
256 uint32_t num_channels);
257
Harmandeep Singheaf59b42012-06-05 21:46:02 -0700258int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
259 uint32_t rate, uint32_t channels);
260
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700261int q6asm_enable_sbrps(struct audio_client *ac,
262 uint32_t sbr_ps);
263
264int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
265 uint16_t sce_left, uint16_t sce_right);
266
Amal Paul2ca061b2013-02-25 14:57:33 -0800267int q6asm_cfg_aac_sel_mix_coef(struct audio_client *ac, uint32_t mix_coeff);
268
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700269int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
270 uint16_t min_rate, uint16_t max_rate,
271 uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
272
273int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
274 uint16_t min_rate, uint16_t max_rate,
275 uint16_t rate_modulation_cmd);
276
277int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
278 uint16_t band_mode, uint16_t dtx_enable);
279
280int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
281 uint16_t band_mode, uint16_t dtx_enable);
282
283int q6asm_media_format_block_pcm(struct audio_client *ac,
284 uint32_t rate, uint32_t channels);
285
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800286int q6asm_media_format_block_pcm_format_support(struct audio_client *ac,
287 uint32_t rate, uint32_t channels,
288 uint16_t bits_per_sample);
289
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700290int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
Subhash Chandra Bose Naripeddye6562162012-12-12 15:11:38 -0800291 uint32_t rate, uint32_t channels,
292 bool use_default_chmap, char *channel_map);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700293
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800294int q6asm_media_format_block_multi_ch_pcm_v2(
295 struct audio_client *ac,
296 uint32_t rate, uint32_t channels,
297 bool use_default_chmap, char *channel_map,
298 uint16_t bits_per_sample);
299
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700300int q6asm_media_format_block_aac(struct audio_client *ac,
301 struct asm_aac_cfg *cfg);
302
303int q6asm_media_format_block_multi_aac(struct audio_client *ac,
304 struct asm_aac_cfg *cfg);
305
306int q6asm_media_format_block_wma(struct audio_client *ac,
307 void *cfg);
308
309int q6asm_media_format_block_wmapro(struct audio_client *ac,
310 void *cfg);
311
Phani Kumar Uppalapati1e0324c2013-03-21 14:13:23 -0700312int q6asm_media_format_block_amrwbplus(struct audio_client *ac,
313 struct asm_amrwbplus_cfg *cfg);
Subhash Chandra Bose Naripeddyaf3e03d2013-02-08 11:35:55 -0800314
315int q6asm_ds1_set_endp_params(struct audio_client *ac,
316 int param_id, int param_value);
317
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700318/* PP specific */
319int q6asm_equalizer(struct audio_client *ac, void *eq);
320
321/* Send Volume Command */
322int q6asm_set_volume(struct audio_client *ac, int volume);
323
324/* Set SoftPause Params */
325int q6asm_set_softpause(struct audio_client *ac,
326 struct asm_softpause_params *param);
327
328/* Set Softvolume Params */
329int q6asm_set_softvolume(struct audio_client *ac,
330 struct asm_softvolume_params *param);
331
332/* Send left-right channel gain */
333int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
334
335/* Enable Mute/unmute flag */
336int q6asm_set_mute(struct audio_client *ac, int muteflag);
337
Patrick Laifc8f2242013-01-06 00:52:34 -0800338int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700339
340/* Client can set the IO mode to either AIO/SIO mode */
341int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
342
343/* Get Service ID for APR communication */
344int q6asm_get_apr_service_id(int session_id);
345
346/* Common format block without any payload
347*/
348int q6asm_media_format_block(struct audio_client *ac, uint32_t format);
349
350#endif /* __Q6_ASM_H__ */