Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* arch/arm/mach-msm/qdsp5/audmgr.h |
| 2 | * |
| 3 | * Copyright (C) 2008 Google, Inc. |
Sidipotu Ashok | 3144aa2 | 2012-03-16 10:55:24 +0530 | [diff] [blame] | 4 | * Copyright (c) 2008-2009, 2012 Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5 | * |
| 6 | * This software is licensed under the terms of the GNU General Public |
| 7 | * License version 2, as published by the Free Software Foundation, and |
| 8 | * may be copied, distributed, and modified under those terms. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #ifndef _AUDIO_RPC_H_ |
| 18 | #define _AUDIO_RPC_H_ |
| 19 | |
| 20 | #include <mach/qdsp5/qdsp5audppcmdi.h> |
| 21 | |
| 22 | enum rpc_aud_def_sample_rate_type { |
| 23 | RPC_AUD_DEF_SAMPLE_RATE_NONE, |
| 24 | RPC_AUD_DEF_SAMPLE_RATE_8000, |
| 25 | RPC_AUD_DEF_SAMPLE_RATE_11025, |
| 26 | RPC_AUD_DEF_SAMPLE_RATE_12000, |
| 27 | RPC_AUD_DEF_SAMPLE_RATE_16000, |
| 28 | RPC_AUD_DEF_SAMPLE_RATE_22050, |
| 29 | RPC_AUD_DEF_SAMPLE_RATE_24000, |
| 30 | RPC_AUD_DEF_SAMPLE_RATE_32000, |
| 31 | RPC_AUD_DEF_SAMPLE_RATE_44100, |
| 32 | RPC_AUD_DEF_SAMPLE_RATE_48000, |
| 33 | RPC_AUD_DEF_SAMPLE_RATE_MAX, |
| 34 | }; |
| 35 | |
| 36 | enum rpc_aud_def_method_type { |
| 37 | RPC_AUD_DEF_METHOD_NONE, |
| 38 | RPC_AUD_DEF_METHOD_KEY_BEEP, |
| 39 | RPC_AUD_DEF_METHOD_PLAYBACK, |
| 40 | RPC_AUD_DEF_METHOD_VOICE, |
| 41 | RPC_AUD_DEF_METHOD_RECORD, |
| 42 | RPC_AUD_DEF_METHOD_HOST_PCM, |
| 43 | RPC_AUD_DEF_METHOD_MIDI_OUT, |
| 44 | RPC_AUD_DEF_METHOD_RECORD_SBC, |
| 45 | RPC_AUD_DEF_METHOD_DTMF_RINGER, |
| 46 | RPC_AUD_DEF_METHOD_MAX, |
| 47 | }; |
| 48 | |
| 49 | enum rpc_aud_def_codec_type { |
| 50 | RPC_AUD_DEF_CODEC_NONE, |
| 51 | RPC_AUD_DEF_CODEC_DTMF, |
| 52 | RPC_AUD_DEF_CODEC_MIDI, |
| 53 | RPC_AUD_DEF_CODEC_MP3, |
| 54 | RPC_AUD_DEF_CODEC_PCM, |
| 55 | RPC_AUD_DEF_CODEC_AAC, |
| 56 | RPC_AUD_DEF_CODEC_WMA, |
| 57 | RPC_AUD_DEF_CODEC_RA, |
| 58 | RPC_AUD_DEF_CODEC_ADPCM, |
| 59 | RPC_AUD_DEF_CODEC_GAUDIO, |
| 60 | RPC_AUD_DEF_CODEC_VOC_EVRC, |
| 61 | RPC_AUD_DEF_CODEC_VOC_13K, |
| 62 | RPC_AUD_DEF_CODEC_VOC_4GV_NB, |
| 63 | RPC_AUD_DEF_CODEC_VOC_AMR, |
| 64 | RPC_AUD_DEF_CODEC_VOC_EFR, |
| 65 | RPC_AUD_DEF_CODEC_VOC_FR, |
| 66 | RPC_AUD_DEF_CODEC_VOC_HR, |
| 67 | RPC_AUD_DEF_CODEC_VOC_CDMA, |
| 68 | RPC_AUD_DEF_CODEC_VOC_CDMA_WB, |
| 69 | RPC_AUD_DEF_CODEC_VOC_UMTS, |
| 70 | RPC_AUD_DEF_CODEC_VOC_UMTS_WB, |
| 71 | RPC_AUD_DEF_CODEC_SBC, |
| 72 | RPC_AUD_DEF_CODEC_VOC_PCM, |
| 73 | RPC_AUD_DEF_CODEC_AMR_WB, |
| 74 | RPC_AUD_DEF_CODEC_AMR_WB_PLUS, |
| 75 | RPC_AUD_DEF_CODEC_AAC_BSAC, |
| 76 | RPC_AUD_DEF_CODEC_MAX, |
| 77 | RPC_AUD_DEF_CODEC_AMR_NB, |
| 78 | RPC_AUD_DEF_CODEC_13K, |
| 79 | RPC_AUD_DEF_CODEC_EVRC, |
| 80 | RPC_AUD_DEF_CODEC_MAX_002, |
| 81 | }; |
| 82 | |
| 83 | enum rpc_snd_method_type { |
| 84 | RPC_SND_METHOD_VOICE = 0, |
| 85 | RPC_SND_METHOD_KEY_BEEP, |
| 86 | RPC_SND_METHOD_MESSAGE, |
| 87 | RPC_SND_METHOD_RING, |
| 88 | RPC_SND_METHOD_MIDI, |
| 89 | RPC_SND_METHOD_AUX, |
| 90 | RPC_SND_METHOD_MAX, |
| 91 | }; |
| 92 | |
| 93 | enum rpc_voc_codec_type { |
| 94 | RPC_VOC_CODEC_DEFAULT, |
| 95 | RPC_VOC_CODEC_ON_CHIP_0 = RPC_VOC_CODEC_DEFAULT, |
| 96 | RPC_VOC_CODEC_ON_CHIP_1, |
| 97 | RPC_VOC_CODEC_STEREO_HEADSET, |
| 98 | RPC_VOC_CODEC_ON_CHIP_AUX, |
| 99 | RPC_VOC_CODEC_BT_OFF_BOARD, |
| 100 | RPC_VOC_CODEC_BT_A2DP, |
| 101 | RPC_VOC_CODEC_OFF_BOARD, |
| 102 | RPC_VOC_CODEC_SDAC, |
| 103 | RPC_VOC_CODEC_RX_EXT_SDAC_TX_INTERNAL, |
| 104 | RPC_VOC_CODEC_IN_STEREO_SADC_OUT_MONO_HANDSET, |
| 105 | RPC_VOC_CODEC_IN_STEREO_SADC_OUT_STEREO_HEADSET, |
| 106 | RPC_VOC_CODEC_TX_INT_SADC_RX_EXT_AUXPCM, |
| 107 | RPC_VOC_CODEC_EXT_STEREO_SADC_OUT_MONO_HANDSET, |
| 108 | RPC_VOC_CODEC_EXT_STEREO_SADC_OUT_STEREO_HEADSET, |
| 109 | RPC_VOC_CODEC_TTY_ON_CHIP_1, |
| 110 | RPC_VOC_CODEC_TTY_OFF_BOARD, |
| 111 | RPC_VOC_CODEC_TTY_VCO, |
| 112 | RPC_VOC_CODEC_TTY_HCO, |
| 113 | RPC_VOC_CODEC_ON_CHIP_0_DUAL_MIC, |
| 114 | RPC_VOC_CODEC_MAX, |
| 115 | RPC_VOC_CODEC_NONE, |
| 116 | }; |
| 117 | |
| 118 | enum rpc_audmgr_status_type { |
| 119 | RPC_AUDMGR_STATUS_READY, |
| 120 | RPC_AUDMGR_STATUS_CODEC_CONFIG, |
| 121 | RPC_AUDMGR_STATUS_PENDING, |
| 122 | RPC_AUDMGR_STATUS_SUSPEND, |
| 123 | RPC_AUDMGR_STATUS_FAILURE, |
| 124 | RPC_AUDMGR_STATUS_VOLUME_CHANGE, |
| 125 | RPC_AUDMGR_STATUS_DISABLED, |
| 126 | RPC_AUDMGR_STATUS_ERROR, |
| 127 | }; |
| 128 | |
| 129 | struct rpc_audmgr_enable_client_args { |
| 130 | uint32_t set_to_one; |
| 131 | uint32_t tx_sample_rate; |
| 132 | uint32_t rx_sample_rate; |
| 133 | uint32_t def_method; |
| 134 | uint32_t codec_type; |
| 135 | uint32_t snd_method; |
| 136 | |
| 137 | uint32_t cb_func; |
| 138 | uint32_t client_data; |
| 139 | }; |
| 140 | |
| 141 | #define AUDMGR_ENABLE_CLIENT 2 |
| 142 | #define AUDMGR_DISABLE_CLIENT 3 |
| 143 | #define AUDMGR_SUSPEND_EVENT_RSP 4 |
| 144 | #define AUDMGR_REGISTER_OPERATION_LISTENER 5 |
| 145 | #define AUDMGR_UNREGISTER_OPERATION_LISTENER 6 |
| 146 | #define AUDMGR_REGISTER_CODEC_LISTENER 7 |
| 147 | #define AUDMGR_GET_RX_SAMPLE_RATE 8 |
| 148 | #define AUDMGR_GET_TX_SAMPLE_RATE 9 |
| 149 | #define AUDMGR_SET_DEVICE_MODE 10 |
| 150 | |
| 151 | #define AUDMGR_PROG_VERS "rs30000013:0x7feccbff" |
| 152 | #define AUDMGR_PROG 0x30000013 |
| 153 | #define AUDMGR_VERS 0x7feccbff |
| 154 | #define AUDMGR_VERS_COMP 0x00010001 |
| 155 | #define AUDMGR_VERS_COMP_VER2 0x00020001 |
| 156 | #define AUDMGR_VERS_COMP_VER3 0x00030001 |
| 157 | |
| 158 | struct rpc_audmgr_cb_func_ptr { |
| 159 | uint32_t cb_id; /* cb_func */ |
| 160 | uint32_t status; /* Audmgr status */ |
| 161 | uint32_t set_to_one; /* Pointer status (1 = valid, 0 = invalid) */ |
| 162 | uint32_t disc; |
| 163 | /* disc = AUDMGR_STATUS_READY => data=handle |
| 164 | disc = AUDMGR_STATUS_CODEC_CONFIG => data = volume |
| 165 | disc = AUDMGR_STATUS_DISABLED => data =status_disabled |
| 166 | disc = AUDMGR_STATUS_VOLUME_CHANGE => data = volume_change */ |
| 167 | union { |
| 168 | uint32_t handle; |
| 169 | uint32_t volume; |
| 170 | uint32_t status_disabled; |
| 171 | uint32_t volume_change; |
| 172 | } u; |
| 173 | uint32_t client_data; |
| 174 | }; |
| 175 | |
| 176 | #define AUDMGR_CB_FUNC_PTR 1 |
| 177 | #define AUDMGR_OPR_LSTNR_CB_FUNC_PTR 2 |
| 178 | #define AUDMGR_CODEC_LSTR_FUNC_PTR 3 |
| 179 | |
| 180 | #define AUDMGR_CB_PROG_VERS "rs31000013:0xf8e3e2d9" |
| 181 | #define AUDMGR_CB_PROG 0x31000013 |
| 182 | #define AUDMGR_CB_VERS 0xf8e3e2d9 |
| 183 | |
| 184 | struct audmgr { |
| 185 | wait_queue_head_t wait; |
| 186 | uint32_t handle; |
| 187 | int state; |
| 188 | }; |
| 189 | |
| 190 | struct audmgr_config { |
| 191 | uint32_t tx_rate; |
| 192 | uint32_t rx_rate; |
| 193 | uint32_t def_method; |
| 194 | uint32_t codec; |
| 195 | uint32_t snd_method; |
| 196 | }; |
| 197 | |
| 198 | int audmgr_open(struct audmgr *am); |
| 199 | int audmgr_close(struct audmgr *am); |
| 200 | int audmgr_enable(struct audmgr *am, struct audmgr_config *cfg); |
| 201 | int audmgr_disable(struct audmgr *am); |
| 202 | |
| 203 | typedef void (*audpp_event_func)(void *private, unsigned id, uint16_t *msg); |
| 204 | typedef void (*audrec_event_func)(void *private, unsigned id, uint16_t *msg); |
| 205 | |
| 206 | /* worst case delay of 1sec for response */ |
| 207 | #define MSM_AUD_DECODER_WAIT_MS 1000 |
| 208 | #define MSM_AUD_MODE_TUNNEL 0x00000100 |
| 209 | #define MSM_AUD_MODE_NONTUNNEL 0x00000200 |
| 210 | #define MSM_AUD_DECODER_MASK 0x0000FFFF |
| 211 | #define MSM_AUD_OP_MASK 0xFFFF0000 |
| 212 | |
| 213 | /*Playback mode*/ |
| 214 | #define NON_TUNNEL_MODE_PLAYBACK 1 |
| 215 | #define TUNNEL_MODE_PLAYBACK 0 |
| 216 | |
| 217 | enum msm_aud_decoder_state { |
| 218 | MSM_AUD_DECODER_STATE_NONE = 0, |
| 219 | MSM_AUD_DECODER_STATE_FAILURE = 1, |
| 220 | MSM_AUD_DECODER_STATE_SUCCESS = 2, |
| 221 | MSM_AUD_DECODER_STATE_CLOSE = 3, |
| 222 | }; |
| 223 | |
| 224 | int audpp_adec_alloc(unsigned dec_attrb, const char **module_name, |
| 225 | unsigned *queueid); |
| 226 | void audpp_adec_free(int decid); |
| 227 | |
| 228 | struct audpp_event_callback { |
| 229 | audpp_event_func fn; |
| 230 | void *private; |
| 231 | }; |
| 232 | |
| 233 | int audpp_register_event_callback(struct audpp_event_callback *eh); |
| 234 | int audpp_unregister_event_callback(struct audpp_event_callback *eh); |
| 235 | int is_audpp_enable(void); |
| 236 | |
| 237 | int audpp_enable(int id, audpp_event_func func, void *private); |
| 238 | void audpp_disable(int id, void *private); |
| 239 | |
| 240 | int audpp_send_queue1(void *cmd, unsigned len); |
| 241 | int audpp_send_queue2(void *cmd, unsigned len); |
| 242 | int audpp_send_queue3(void *cmd, unsigned len); |
| 243 | |
| 244 | int audpp_set_volume_and_pan(unsigned id, unsigned volume, int pan); |
| 245 | int audpp_pause(unsigned id, int pause); |
| 246 | int audpp_flush(unsigned id); |
| 247 | void audpp_avsync(int id, unsigned rate); |
| 248 | unsigned audpp_avsync_sample_count(int id); |
| 249 | unsigned audpp_avsync_byte_count(int id); |
| 250 | int audpp_dsp_set_mbadrc(unsigned id, unsigned enable, |
| 251 | audpp_cmd_cfg_object_params_mbadrc *mbadrc); |
| 252 | int audpp_dsp_set_eq(unsigned id, unsigned enable, |
| 253 | audpp_cmd_cfg_object_params_eqalizer *eq); |
| 254 | int audpp_dsp_set_rx_iir(unsigned id, unsigned enable, |
| 255 | audpp_cmd_cfg_object_params_pcm *iir); |
Sidipotu Ashok | 3144aa2 | 2012-03-16 10:55:24 +0530 | [diff] [blame] | 256 | |
| 257 | int audpp_dsp_set_rx_srs_trumedia_g |
| 258 | (struct audpp_cmd_cfg_object_params_srstm_g *srstm); |
| 259 | int audpp_dsp_set_rx_srs_trumedia_w |
| 260 | (struct audpp_cmd_cfg_object_params_srstm_w *srstm); |
| 261 | int audpp_dsp_set_rx_srs_trumedia_c |
| 262 | (struct audpp_cmd_cfg_object_params_srstm_c *srstm); |
| 263 | int audpp_dsp_set_rx_srs_trumedia_h |
| 264 | (struct audpp_cmd_cfg_object_params_srstm_h *srstm); |
| 265 | int audpp_dsp_set_rx_srs_trumedia_p |
| 266 | (struct audpp_cmd_cfg_object_params_srstm_p *srstm); |
| 267 | int audpp_dsp_set_rx_srs_trumedia_l |
| 268 | (struct audpp_cmd_cfg_object_params_srstm_l *srstm); |
| 269 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 270 | int audpp_dsp_set_vol_pan(unsigned id, |
| 271 | audpp_cmd_cfg_object_params_volume *vol_pan); |
| 272 | int audpp_dsp_set_qconcert_plus(unsigned id, unsigned enable, |
| 273 | audpp_cmd_cfg_object_params_qconcert *qconcert_plus); |
| 274 | int audrectask_enable(unsigned enc_type, audrec_event_func func, void *private); |
| 275 | void audrectask_disable(unsigned enc_type, void *private); |
| 276 | |
| 277 | int audrectask_send_cmdqueue(void *cmd, unsigned len); |
| 278 | int audrectask_send_bitstreamqueue(void *cmd, unsigned len); |
| 279 | |
| 280 | #endif |