blob: af82b760dc3a0df6e27380c7091d7215ac3ecdaf [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
2 *
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_H__
13#define __Q6_ASM_H__
14
15#include <mach/qdsp6v2/apr.h>
16#include <mach/msm_subsystem_map.h>
17#include <sound/apr_audio.h>
18
19#define IN 0x000
20#define OUT 0x001
21#define CH_MODE_MONO 0x001
22#define CH_MODE_STEREO 0x002
23
24#define FORMAT_LINEAR_PCM 0x0000
25#define FORMAT_DTMF 0x0001
26#define FORMAT_ADPCM 0x0002
27#define FORMAT_YADPCM 0x0003
28#define FORMAT_MP3 0x0004
29#define FORMAT_MPEG4_AAC 0x0005
30#define FORMAT_AMRNB 0x0006
31#define FORMAT_AMRWB 0x0007
32#define FORMAT_V13K 0x0008
33#define FORMAT_EVRC 0x0009
34#define FORMAT_EVRCB 0x000a
35#define FORMAT_EVRCWB 0x000b
36#define FORMAT_MIDI 0x000c
37#define FORMAT_SBC 0x000d
38#define FORMAT_WMA_V10PRO 0x000e
39#define FORMAT_WMA_V9 0x000f
40#define FORMAT_AMR_WB_PLUS 0x0010
41
42#define ENCDEC_SBCBITRATE 0x0001
43#define ENCDEC_IMMEDIATE_DECODE 0x0002
44#define ENCDEC_CFG_BLK 0x0003
45
46#define CMD_PAUSE 0x0001
47#define CMD_FLUSH 0x0002
48#define CMD_EOS 0x0003
49#define CMD_CLOSE 0x0004
50#define CMD_OUT_FLUSH 0x0005
51
52/* bit 0:1 represents priority of stream */
53#define STREAM_PRIORITY_NORMAL 0x0000
54#define STREAM_PRIORITY_LOW 0x0001
55#define STREAM_PRIORITY_HIGH 0x0002
56
57/* bit 4 represents META enable of encoded data buffer */
58#define BUFFER_META_ENABLE 0x0010
59
60/* Enable Sample_Rate/Channel_Mode notification event from Decoder */
61#define SR_CM_NOTIFY_ENABLE 0x0004
62
63#define ASYNC_IO_MODE 0x0002
64#define SYNC_IO_MODE 0x0001
65#define NO_TIMESTAMP 0xFF00
66#define SET_TIMESTAMP 0x0000
67
68#define SOFT_PAUSE_ENABLE 1
69#define SOFT_PAUSE_DISABLE 0
70
71#define SESSION_MAX 0x08
72
73typedef void (*app_cb)(uint32_t opcode, uint32_t token,
74 uint32_t *payload, void *priv);
75
76struct audio_buffer {
77 dma_addr_t phys;
78 void *data;
79 struct msm_mapped_buffer *mem_buffer;
80 uint32_t used;
81 uint32_t size;/* size of buffer */
82 uint32_t actual_size; /* actual number of bytes read by DSP */
83};
84
85struct audio_aio_write_param {
86 unsigned long paddr;
87 uint32_t uid;
88 uint32_t len;
89 uint32_t msw_ts;
90 uint32_t lsw_ts;
91 uint32_t flags;
92};
93
94struct audio_aio_read_param {
95 unsigned long paddr;
96 uint32_t len;
97 uint32_t uid;
98};
99
100struct audio_port_data {
101 struct audio_buffer *buf;
102 uint32_t max_buf_cnt;
103 uint32_t dsp_buf;
104 uint32_t cpu_buf;
105 /* read or write locks */
106 struct mutex lock;
107 spinlock_t dsp_lock;
108};
109
110struct audio_client {
111 int session;
112 /* idx:1 out port, 0: in port*/
113 struct audio_port_data port[2];
114
115 struct apr_svc *apr;
116 struct mutex cmd_lock;
117
118 atomic_t cmd_state;
119 atomic_t time_flag;
120 wait_queue_head_t cmd_wait;
121 wait_queue_head_t time_wait;
122
123 app_cb cb;
124 void *priv;
125 uint32_t io_mode;
126 uint64_t time_stamp;
127};
128
129void q6asm_audio_client_free(struct audio_client *ac);
130
131struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv);
132
133int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */,
134 struct audio_client *ac,
135 unsigned int bufsz,
136 unsigned int bufcnt);
137int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir
138 /* 1:Out,0:In */,
139 struct audio_client *ac,
140 unsigned int bufsz,
141 unsigned int bufcnt);
142
143int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
144 struct audio_client *ac);
145
146int q6asm_open_read(struct audio_client *ac, uint32_t format);
147
148int q6asm_open_write(struct audio_client *ac, uint32_t format);
149
150int q6asm_open_read_write(struct audio_client *ac,
151 uint32_t rd_format,
152 uint32_t wr_format);
153
154int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
155 uint32_t lsw_ts, uint32_t flags);
156int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
157 uint32_t lsw_ts, uint32_t flags);
158
159int q6asm_async_write(struct audio_client *ac,
160 struct audio_aio_write_param *param);
161
162int q6asm_async_read(struct audio_client *ac,
163 struct audio_aio_read_param *param);
164
165int q6asm_read(struct audio_client *ac);
166int q6asm_read_nolock(struct audio_client *ac);
167
168int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add,
169 int dir, uint32_t bufsz, uint32_t bufcnt);
170
171int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add,
172 int dir);
173
174int q6asm_run(struct audio_client *ac, uint32_t flags,
175 uint32_t msw_ts, uint32_t lsw_ts);
176
177int q6asm_run_nowait(struct audio_client *ac, uint32_t flags,
178 uint32_t msw_ts, uint32_t lsw_ts);
179
180int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable);
181
182int q6asm_cmd(struct audio_client *ac, int cmd);
183
184int q6asm_cmd_nowait(struct audio_client *ac, int cmd);
185
186void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac,
187 uint32_t *size, uint32_t *idx);
188
189int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac);
190
191/* File format specific configurations to be added below */
192
193int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
194 uint32_t frames_per_buf,
195 uint32_t sample_rate, uint32_t channels,
196 uint32_t bit_rate,
197 uint32_t mode, uint32_t format);
198
199int q6asm_enc_cfg_blk_pcm(struct audio_client *ac,
200 uint32_t rate, uint32_t channels);
201
202int q6asm_enable_sbrps(struct audio_client *ac,
203 uint32_t sbr_ps);
204
205int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
206 uint16_t min_rate, uint16_t max_rate,
207 uint16_t reduced_rate_level, uint16_t rate_modulation_cmd);
208
209int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
210 uint16_t min_rate, uint16_t max_rate,
211 uint16_t rate_modulation_cmd);
212
213int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
214 uint16_t band_mode, uint16_t dtx_enable);
215
216int q6asm_media_format_block_pcm(struct audio_client *ac,
217 uint32_t rate, uint32_t channels);
218
219int q6asm_media_format_block_aac(struct audio_client *ac,
220 struct asm_aac_cfg *cfg);
221
222int q6asm_media_format_block_wma(struct audio_client *ac,
223 void *cfg);
224
225int q6asm_media_format_block_wmapro(struct audio_client *ac,
226 void *cfg);
227
228/* PP specific */
229int q6asm_equalizer(struct audio_client *ac, void *eq);
230
231/* Send Volume Command */
232int q6asm_set_volume(struct audio_client *ac, int volume);
233
234/* Set SoftPause Params */
235int q6asm_set_softpause(struct audio_client *ac,
236 struct asm_softpause_params *param);
237
238/* Send left-right channel gain */
239int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain);
240
241/* Enable Mute/unmute flag */
242int q6asm_set_mute(struct audio_client *ac, int muteflag);
243
244uint64_t q6asm_get_session_time(struct audio_client *ac);
245
246/* Client can set the IO mode to either AIO/SIO mode */
247int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
248
249#ifdef CONFIG_MSM8X60_RTAC
250/* Get Service ID for APR communication */
251int q6asm_get_apr_service_id(int session_id);
252#endif
253
254#endif /* __Q6_ASM_H__ */