Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* 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 |
Bharath Ramachandramurthy | 4f71d50 | 2011-10-23 19:45:22 -0700 | [diff] [blame^] | 41 | #define FORMAT_MPEG4_MULTI_AAC 0x0011 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 42 | |
| 43 | #define ENCDEC_SBCBITRATE 0x0001 |
| 44 | #define ENCDEC_IMMEDIATE_DECODE 0x0002 |
| 45 | #define ENCDEC_CFG_BLK 0x0003 |
| 46 | |
| 47 | #define CMD_PAUSE 0x0001 |
| 48 | #define CMD_FLUSH 0x0002 |
| 49 | #define CMD_EOS 0x0003 |
| 50 | #define CMD_CLOSE 0x0004 |
| 51 | #define CMD_OUT_FLUSH 0x0005 |
| 52 | |
| 53 | /* bit 0:1 represents priority of stream */ |
| 54 | #define STREAM_PRIORITY_NORMAL 0x0000 |
| 55 | #define STREAM_PRIORITY_LOW 0x0001 |
| 56 | #define STREAM_PRIORITY_HIGH 0x0002 |
| 57 | |
| 58 | /* bit 4 represents META enable of encoded data buffer */ |
| 59 | #define BUFFER_META_ENABLE 0x0010 |
| 60 | |
| 61 | /* Enable Sample_Rate/Channel_Mode notification event from Decoder */ |
| 62 | #define SR_CM_NOTIFY_ENABLE 0x0004 |
| 63 | |
| 64 | #define ASYNC_IO_MODE 0x0002 |
| 65 | #define SYNC_IO_MODE 0x0001 |
| 66 | #define NO_TIMESTAMP 0xFF00 |
| 67 | #define SET_TIMESTAMP 0x0000 |
| 68 | |
| 69 | #define SOFT_PAUSE_ENABLE 1 |
| 70 | #define SOFT_PAUSE_DISABLE 0 |
| 71 | |
| 72 | #define SESSION_MAX 0x08 |
| 73 | |
Sriranjan Srikantam | 5285a21 | 2011-09-06 19:09:19 -0700 | [diff] [blame] | 74 | #define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */ |
| 75 | #define SOFT_PAUSE_STEP 2000 /* Step value 2ms or 2000us */ |
| 76 | enum { |
| 77 | SOFT_PAUSE_CURVE_LINEAR = 0, |
| 78 | SOFT_PAUSE_CURVE_EXP, |
| 79 | SOFT_PAUSE_CURVE_LOG, |
| 80 | }; |
| 81 | |
| 82 | #define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */ |
| 83 | #define SOFT_VOLUME_STEP 2000 /* Step value 2ms or 2000us */ |
| 84 | enum { |
| 85 | SOFT_VOLUME_CURVE_LINEAR = 0, |
| 86 | SOFT_VOLUME_CURVE_EXP, |
| 87 | SOFT_VOLUME_CURVE_LOG, |
| 88 | }; |
| 89 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 90 | typedef void (*app_cb)(uint32_t opcode, uint32_t token, |
| 91 | uint32_t *payload, void *priv); |
| 92 | |
| 93 | struct audio_buffer { |
| 94 | dma_addr_t phys; |
| 95 | void *data; |
| 96 | struct msm_mapped_buffer *mem_buffer; |
| 97 | uint32_t used; |
| 98 | uint32_t size;/* size of buffer */ |
| 99 | uint32_t actual_size; /* actual number of bytes read by DSP */ |
| 100 | }; |
| 101 | |
| 102 | struct audio_aio_write_param { |
| 103 | unsigned long paddr; |
| 104 | uint32_t uid; |
| 105 | uint32_t len; |
| 106 | uint32_t msw_ts; |
| 107 | uint32_t lsw_ts; |
| 108 | uint32_t flags; |
| 109 | }; |
| 110 | |
| 111 | struct audio_aio_read_param { |
| 112 | unsigned long paddr; |
| 113 | uint32_t len; |
| 114 | uint32_t uid; |
| 115 | }; |
| 116 | |
| 117 | struct audio_port_data { |
| 118 | struct audio_buffer *buf; |
| 119 | uint32_t max_buf_cnt; |
| 120 | uint32_t dsp_buf; |
| 121 | uint32_t cpu_buf; |
| 122 | /* read or write locks */ |
| 123 | struct mutex lock; |
| 124 | spinlock_t dsp_lock; |
| 125 | }; |
| 126 | |
| 127 | struct audio_client { |
| 128 | int session; |
| 129 | /* idx:1 out port, 0: in port*/ |
| 130 | struct audio_port_data port[2]; |
| 131 | |
| 132 | struct apr_svc *apr; |
| 133 | struct mutex cmd_lock; |
| 134 | |
| 135 | atomic_t cmd_state; |
| 136 | atomic_t time_flag; |
| 137 | wait_queue_head_t cmd_wait; |
| 138 | wait_queue_head_t time_wait; |
| 139 | |
| 140 | app_cb cb; |
| 141 | void *priv; |
| 142 | uint32_t io_mode; |
| 143 | uint64_t time_stamp; |
| 144 | }; |
| 145 | |
| 146 | void q6asm_audio_client_free(struct audio_client *ac); |
| 147 | |
| 148 | struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv); |
| 149 | |
| 150 | int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */, |
| 151 | struct audio_client *ac, |
| 152 | unsigned int bufsz, |
| 153 | unsigned int bufcnt); |
| 154 | int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir |
| 155 | /* 1:Out,0:In */, |
| 156 | struct audio_client *ac, |
| 157 | unsigned int bufsz, |
| 158 | unsigned int bufcnt); |
| 159 | |
| 160 | int q6asm_audio_client_buf_free_contiguous(unsigned int dir, |
| 161 | struct audio_client *ac); |
| 162 | |
| 163 | int q6asm_open_read(struct audio_client *ac, uint32_t format); |
| 164 | |
| 165 | int q6asm_open_write(struct audio_client *ac, uint32_t format); |
| 166 | |
| 167 | int q6asm_open_read_write(struct audio_client *ac, |
| 168 | uint32_t rd_format, |
| 169 | uint32_t wr_format); |
| 170 | |
| 171 | int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts, |
| 172 | uint32_t lsw_ts, uint32_t flags); |
| 173 | int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts, |
| 174 | uint32_t lsw_ts, uint32_t flags); |
| 175 | |
| 176 | int q6asm_async_write(struct audio_client *ac, |
| 177 | struct audio_aio_write_param *param); |
| 178 | |
| 179 | int q6asm_async_read(struct audio_client *ac, |
| 180 | struct audio_aio_read_param *param); |
| 181 | |
| 182 | int q6asm_read(struct audio_client *ac); |
| 183 | int q6asm_read_nolock(struct audio_client *ac); |
| 184 | |
| 185 | int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add, |
| 186 | int dir, uint32_t bufsz, uint32_t bufcnt); |
| 187 | |
| 188 | int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add, |
| 189 | int dir); |
| 190 | |
| 191 | int q6asm_run(struct audio_client *ac, uint32_t flags, |
| 192 | uint32_t msw_ts, uint32_t lsw_ts); |
| 193 | |
| 194 | int q6asm_run_nowait(struct audio_client *ac, uint32_t flags, |
| 195 | uint32_t msw_ts, uint32_t lsw_ts); |
| 196 | |
| 197 | int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable); |
| 198 | |
| 199 | int q6asm_cmd(struct audio_client *ac, int cmd); |
| 200 | |
| 201 | int q6asm_cmd_nowait(struct audio_client *ac, int cmd); |
| 202 | |
| 203 | void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac, |
| 204 | uint32_t *size, uint32_t *idx); |
| 205 | |
Jay Wang | 9cf59a0 | 2011-08-10 16:58:40 -0700 | [diff] [blame] | 206 | void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac, |
| 207 | uint32_t *size, uint32_t *idx); |
| 208 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 209 | int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac); |
| 210 | |
| 211 | /* File format specific configurations to be added below */ |
| 212 | |
| 213 | int q6asm_enc_cfg_blk_aac(struct audio_client *ac, |
| 214 | uint32_t frames_per_buf, |
| 215 | uint32_t sample_rate, uint32_t channels, |
| 216 | uint32_t bit_rate, |
| 217 | uint32_t mode, uint32_t format); |
| 218 | |
| 219 | int q6asm_enc_cfg_blk_pcm(struct audio_client *ac, |
| 220 | uint32_t rate, uint32_t channels); |
| 221 | |
| 222 | int q6asm_enable_sbrps(struct audio_client *ac, |
| 223 | uint32_t sbr_ps); |
| 224 | |
Swaminathan Sathappan | 70765cd | 2011-07-19 18:42:47 -0700 | [diff] [blame] | 225 | int q6asm_cfg_dual_mono_aac(struct audio_client *ac, |
| 226 | uint16_t sce_left, uint16_t sce_right); |
| 227 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 228 | int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf, |
| 229 | uint16_t min_rate, uint16_t max_rate, |
| 230 | uint16_t reduced_rate_level, uint16_t rate_modulation_cmd); |
| 231 | |
| 232 | int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf, |
| 233 | uint16_t min_rate, uint16_t max_rate, |
| 234 | uint16_t rate_modulation_cmd); |
| 235 | |
| 236 | int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf, |
| 237 | uint16_t band_mode, uint16_t dtx_enable); |
| 238 | |
| 239 | int q6asm_media_format_block_pcm(struct audio_client *ac, |
| 240 | uint32_t rate, uint32_t channels); |
| 241 | |
| 242 | int q6asm_media_format_block_aac(struct audio_client *ac, |
| 243 | struct asm_aac_cfg *cfg); |
| 244 | |
Bharath Ramachandramurthy | 4f71d50 | 2011-10-23 19:45:22 -0700 | [diff] [blame^] | 245 | int q6asm_media_format_block_multi_aac(struct audio_client *ac, |
| 246 | struct asm_aac_cfg *cfg); |
| 247 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 248 | int q6asm_media_format_block_wma(struct audio_client *ac, |
| 249 | void *cfg); |
| 250 | |
| 251 | int q6asm_media_format_block_wmapro(struct audio_client *ac, |
| 252 | void *cfg); |
| 253 | |
| 254 | /* PP specific */ |
| 255 | int q6asm_equalizer(struct audio_client *ac, void *eq); |
| 256 | |
| 257 | /* Send Volume Command */ |
| 258 | int q6asm_set_volume(struct audio_client *ac, int volume); |
| 259 | |
| 260 | /* Set SoftPause Params */ |
| 261 | int q6asm_set_softpause(struct audio_client *ac, |
| 262 | struct asm_softpause_params *param); |
| 263 | |
Swaminathan Sathappan | b0021cd | 2011-08-31 15:20:12 -0700 | [diff] [blame] | 264 | /* Set Softvolume Params */ |
| 265 | int q6asm_set_softvolume(struct audio_client *ac, |
| 266 | struct asm_softvolume_params *param); |
| 267 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 268 | /* Send left-right channel gain */ |
| 269 | int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain); |
| 270 | |
| 271 | /* Enable Mute/unmute flag */ |
| 272 | int q6asm_set_mute(struct audio_client *ac, int muteflag); |
| 273 | |
| 274 | uint64_t q6asm_get_session_time(struct audio_client *ac); |
| 275 | |
| 276 | /* Client can set the IO mode to either AIO/SIO mode */ |
| 277 | int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode); |
| 278 | |
Ben Romberger | 45b351c | 2011-07-20 22:37:27 -0700 | [diff] [blame] | 279 | #ifdef CONFIG_RTAC |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 280 | /* Get Service ID for APR communication */ |
| 281 | int q6asm_get_apr_service_id(int session_id); |
| 282 | #endif |
| 283 | |
| 284 | #endif /* __Q6_ASM_H__ */ |