blob: 65ca46fe6163b2bdb3a0b9ce9417b366c2bb68e0 [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>
Ben Romberger092d70c2013-08-07 15:33:47 -070016#include <mach/qdsp6v2/rtac.h>
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070017#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
Subhash Chandra Bose Naripeddyaf3e03d2013-02-08 11:35:55 -080045#define FORMAT_AC3 0x0013
46#define FORMAT_EAC3 0x0014
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070047
48#define ENCDEC_SBCBITRATE 0x0001
49#define ENCDEC_IMMEDIATE_DECODE 0x0002
50#define ENCDEC_CFG_BLK 0x0003
51
52#define CMD_PAUSE 0x0001
53#define CMD_FLUSH 0x0002
54#define CMD_EOS 0x0003
55#define CMD_CLOSE 0x0004
56#define CMD_OUT_FLUSH 0x0005
Alexy Josepha02bd1c2013-10-31 17:11:31 -070057#define CMD_SUSPEND 0x0006
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070058
59/* bit 0:1 represents priority of stream */
60#define STREAM_PRIORITY_NORMAL 0x0000
61#define STREAM_PRIORITY_LOW 0x0001
62#define STREAM_PRIORITY_HIGH 0x0002
63
64/* bit 4 represents META enable of encoded data buffer */
65#define BUFFER_META_ENABLE 0x0010
66
67/* Enable Sample_Rate/Channel_Mode notification event from Decoder */
68#define SR_CM_NOTIFY_ENABLE 0x0004
69
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070070#define SYNC_IO_MODE 0x0001
Harmandeep Singheaf59b42012-06-05 21:46:02 -070071#define ASYNC_IO_MODE 0x0002
Phani Kumar Uppalapatif3c5fac2012-10-13 15:27:23 -070072#define COMPRESSED_IO 0x0040
Harmandeep Singheaf59b42012-06-05 21:46:02 -070073#define NT_MODE 0x0400
74
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070075#define NO_TIMESTAMP 0xFF00
76#define SET_TIMESTAMP 0x0000
77
78#define SOFT_PAUSE_ENABLE 1
79#define SOFT_PAUSE_DISABLE 0
80
Ben Romberger971765c2013-07-23 17:27:18 -070081#define SESSION_MAX 0x08
82#define ASM_CONTROL_SESSION 0x0F
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070083
Krishnankutty Kolathappilly05c7bd92013-04-27 23:34:53 -070084/* payload structure bytes */
85#define READDONE_IDX_STATUS 0
86#define READDONE_IDX_BUFADD_LSW 1
87#define READDONE_IDX_BUFADD_MSW 2
88#define READDONE_IDX_MEMMAP_HDL 3
89#define READDONE_IDX_SIZE 4
90#define READDONE_IDX_OFFSET 5
91#define READDONE_IDX_LSW_TS 6
92#define READDONE_IDX_MSW_TS 7
93#define READDONE_IDX_FLAGS 8
94#define READDONE_IDX_NUMFRAMES 9
95#define READDONE_IDX_SEQ_ID 10
96
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070097#define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */
Santosh Mardib8d48f52013-07-19 05:33:28 +053098#define SOFT_PAUSE_STEP 0 /* Step value 0ms or 0us */
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -070099enum {
100 SOFT_PAUSE_CURVE_LINEAR = 0,
101 SOFT_PAUSE_CURVE_EXP,
102 SOFT_PAUSE_CURVE_LOG,
103};
104
105#define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */
Santosh Mardib8d48f52013-07-19 05:33:28 +0530106#define SOFT_VOLUME_STEP 0 /* Step value 0ms or 0us */
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700107enum {
108 SOFT_VOLUME_CURVE_LINEAR = 0,
109 SOFT_VOLUME_CURVE_EXP,
110 SOFT_VOLUME_CURVE_LOG,
111};
112
113typedef void (*app_cb)(uint32_t opcode, uint32_t token,
114 uint32_t *payload, void *priv);
115
116struct audio_buffer {
117 dma_addr_t phys;
118 void *data;
119 uint32_t used;
120 uint32_t size;/* size of buffer */
121 uint32_t actual_size; /* actual number of bytes read by DSP */
122 struct ion_handle *handle;
123 struct ion_client *client;
124};
125
126struct audio_aio_write_param {
127 unsigned long paddr;
128 uint32_t len;
129 uint32_t uid;
130 uint32_t lsw_ts;
131 uint32_t msw_ts;
132 uint32_t flags;
133};
134
135struct audio_aio_read_param {
136 unsigned long paddr;
137 uint32_t len;
138 uint32_t uid;
139};
140
141struct audio_port_data {
142 struct audio_buffer *buf;
143 uint32_t max_buf_cnt;
144 uint32_t dsp_buf;
145 uint32_t cpu_buf;
146 struct list_head mem_map_handle;
147 uint32_t tmp_hdl;
148 /* read or write locks */
149 struct mutex lock;
150 spinlock_t dsp_lock;
151};
152
153struct audio_client {
154 int session;
155 app_cb cb;
156 atomic_t cmd_state;
157 /* Relative or absolute TS */
Phani Kumar Uppalapatic268df72013-02-19 19:06:41 -0800158 atomic_t time_flag;
Phani Kumar Uppalapati70a5d132012-12-05 11:35:13 -0800159 atomic_t nowait_cmd_cnt;
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700160 void *priv;
161 uint32_t io_mode;
162 uint64_t time_stamp;
163 struct apr_svc *apr;
164 struct apr_svc *mmap_apr;
165 struct mutex cmd_lock;
166 /* idx:1 out port, 0: in port*/
167 struct audio_port_data port[2];
168 wait_queue_head_t cmd_wait;
Phani Kumar Uppalapatic268df72013-02-19 19:06:41 -0800169 wait_queue_head_t time_wait;
Phani Kumar Uppalapati85b7c9b2013-02-19 09:59:47 -0800170 bool perf_mode;
Fred Ohc274a7a2013-03-25 13:59:17 -0700171 /* audio cache operations fptr*/
172 int (*fptr_cache_ops)(struct audio_buffer *abuff, int cache_op);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700173};
174
175void q6asm_audio_client_free(struct audio_client *ac);
176
177struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
178
179struct audio_client *q6asm_get_audio_client(int session_id);
180
181int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
182 struct audio_client *ac,
183 unsigned int bufsz,
184 unsigned int bufcnt);
185int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
186 /* 1:Out,0:In */,
187 struct audio_client *ac,
188 unsigned int bufsz,
189 unsigned int bufcnt);
190
191int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
192 struct audio_client *ac);
193
194int q6asm_open_read(struct audio_client *ac, uint32_t format
195 /*, uint16_t bits_per_sample*/);
196
Damir Didjusto1c69f1b2013-06-17 20:55:53 -0700197int q6asm_open_read_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_write(struct audio_client *ac, uint32_t format
201 /*, uint16_t bits_per_sample*/);
202
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800203int q6asm_open_write_v2(struct audio_client *ac, uint32_t format,
204 uint16_t bits_per_sample);
205
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700206int q6asm_open_read_write(struct audio_client *ac,
207 uint32_t rd_format,
208 uint32_t wr_format);
209
210int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
211 uint32_t lsw_ts, uint32_t flags);
212int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
213 uint32_t lsw_ts, uint32_t flags);
214
215int q6asm_async_write(struct audio_client *ac,
216 struct audio_aio_write_param *param);
217
218int q6asm_async_read(struct audio_client *ac,
219 struct audio_aio_read_param *param);
220
221int q6asm_read(struct audio_client *ac);
222int q6asm_read_nolock(struct audio_client *ac);
223
224int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add,
225 int dir, uint32_t bufsz, uint32_t bufcnt);
226
227int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add,
228 int dir);
229
Ben Romberger971765c2013-07-23 17:27:18 -0700230int q6asm_unmap_cal_blocks(void);
231
Ben Romberger092d70c2013-08-07 15:33:47 -0700232int q6asm_map_rtac_block(struct rtac_cal_block_data *cal_block);
233
234int q6asm_unmap_rtac_block(uint32_t *mem_map_handle);
235
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700236int q6asm_run(struct audio_client *ac, uint32_t flags,
237 uint32_t msw_ts, uint32_t lsw_ts);
238
239int q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
240 uint32_t msw_ts, uint32_t lsw_ts);
241
242int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable);
243
244int q6asm_cmd(struct audio_client *ac, int cmd);
245
246int q6asm_cmd_nowait(struct audio_client *ac, int cmd);
247
248void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac,
249 uint32_t *size, uint32_t *idx);
250
251void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac,
252 uint32_t *size, uint32_t *idx);
253
254int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac);
255
256/* File format specific configurations to be added below */
257
258int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
259 uint32_t frames_per_buf,
260 uint32_t sample_rate, uint32_t channels,
261 uint32_t bit_rate,
262 uint32_t mode, uint32_t format);
263
264int q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
265 uint32_t rate, uint32_t channels);
266
Damir Didjusto1c69f1b2013-06-17 20:55:53 -0700267int q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac,
268 uint32_t rate, uint32_t channels,
269 uint16_t bits_per_sample);
270
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700271int q6asm_set_encdec_chan_map(struct audio_client *ac,
272 uint32_t num_channels);
273
Harmandeep Singheaf59b42012-06-05 21:46:02 -0700274int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
275 uint32_t rate, uint32_t channels);
276
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700277int q6asm_enable_sbrps(struct audio_client *ac,
278 uint32_t sbr_ps);
279
280int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
281 uint16_t sce_left, uint16_t sce_right);
282
Amal Paul2ca061b2013-02-25 14:57:33 -0800283int q6asm_cfg_aac_sel_mix_coef(struct audio_client *ac, uint32_t mix_coeff);
284
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700285int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
286 uint16_t min_rate, uint16_t max_rate,
287 uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
288
289int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
290 uint16_t min_rate, uint16_t max_rate,
291 uint16_t rate_modulation_cmd);
292
293int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
294 uint16_t band_mode, uint16_t dtx_enable);
295
296int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
297 uint16_t band_mode, uint16_t dtx_enable);
298
299int q6asm_media_format_block_pcm(struct audio_client *ac,
300 uint32_t rate, uint32_t channels);
301
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800302int q6asm_media_format_block_pcm_format_support(struct audio_client *ac,
303 uint32_t rate, uint32_t channels,
304 uint16_t bits_per_sample);
305
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700306int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
Subhash Chandra Bose Naripeddye6562162012-12-12 15:11:38 -0800307 uint32_t rate, uint32_t channels,
308 bool use_default_chmap, char *channel_map);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700309
Bhalchandra Gajare5b40c532013-02-19 13:36:47 -0800310int q6asm_media_format_block_multi_ch_pcm_v2(
311 struct audio_client *ac,
312 uint32_t rate, uint32_t channels,
313 bool use_default_chmap, char *channel_map,
314 uint16_t bits_per_sample);
315
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700316int q6asm_media_format_block_aac(struct audio_client *ac,
317 struct asm_aac_cfg *cfg);
318
319int q6asm_media_format_block_multi_aac(struct audio_client *ac,
320 struct asm_aac_cfg *cfg);
321
322int q6asm_media_format_block_wma(struct audio_client *ac,
323 void *cfg);
324
325int q6asm_media_format_block_wmapro(struct audio_client *ac,
326 void *cfg);
327
Phani Kumar Uppalapati1e0324c2013-03-21 14:13:23 -0700328int q6asm_media_format_block_amrwbplus(struct audio_client *ac,
329 struct asm_amrwbplus_cfg *cfg);
Subhash Chandra Bose Naripeddyaf3e03d2013-02-08 11:35:55 -0800330
331int q6asm_ds1_set_endp_params(struct audio_client *ac,
332 int param_id, int param_value);
333
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700334/* PP specific */
335int q6asm_equalizer(struct audio_client *ac, void *eq);
336
337/* Send Volume Command */
338int q6asm_set_volume(struct audio_client *ac, int volume);
339
340/* Set SoftPause Params */
341int q6asm_set_softpause(struct audio_client *ac,
342 struct asm_softpause_params *param);
343
344/* Set Softvolume Params */
345int q6asm_set_softvolume(struct audio_client *ac,
346 struct asm_softvolume_params *param);
347
348/* Send left-right channel gain */
349int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
350
351/* Enable Mute/unmute flag */
352int q6asm_set_mute(struct audio_client *ac, int muteflag);
353
Patrick Laifc8f2242013-01-06 00:52:34 -0800354int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp);
Bharath Ramachandramurthy2e3168f2012-05-03 16:29:09 -0700355
356/* Client can set the IO mode to either AIO/SIO mode */
357int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
358
359/* Get Service ID for APR communication */
360int q6asm_get_apr_service_id(int session_id);
361
362/* Common format block without any payload
363*/
364int q6asm_media_format_block(struct audio_client *ac, uint32_t format);
365
366#endif /* __Q6_ASM_H__ */