1 /* 2 * Copyright (C) 2013-2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef QCOM_AUDIO_PLATFORM_H 18 #define QCOM_AUDIO_PLATFORM_H 19 20 enum { 21 FLUENCE_DISABLE, /* Target dosent support fluence */ 22 FLUENCE_ENABLE = 0x1, /* Target supports fluence */ 23 FLUENCE_PRO_ENABLE = 0x2, /* Target supports fluence pro */ 24 }; 25 26 enum { 27 SOURCE_MONO_MIC = 0x1, /* Target contains 1 mic */ 28 SOURCE_DUAL_MIC = 0x2, /* Target contains 2 mics */ 29 SOURCE_THREE_MIC = 0x4, /* Target contains 3 mics */ 30 SOURCE_QUAD_MIC = 0x8, /* Target contains 4 mics */ 31 }; 32 33 /* 34 * Below are the devices for which is back end is same, SLIMBUS_0_RX. 35 * All these devices are handled by the internal HW codec. We can 36 * enable any one of these devices at any time 37 */ 38 #define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \ 39 (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \ 40 AUDIO_DEVICE_OUT_SPEAKER_SAFE | \ 41 AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE | \ 42 AUDIO_DEVICE_OUT_LINE) 43 44 /* Sound devices specific to the platform 45 * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound 46 * devices to enable corresponding mixer paths 47 */ 48 enum { 49 SND_DEVICE_NONE = 0, 50 51 /* Playback devices */ 52 SND_DEVICE_MIN, 53 SND_DEVICE_OUT_BEGIN = SND_DEVICE_MIN, 54 SND_DEVICE_OUT_HANDSET = SND_DEVICE_OUT_BEGIN, 55 SND_DEVICE_OUT_SPEAKER, 56 SND_DEVICE_OUT_SPEAKER_REVERSE, 57 SND_DEVICE_OUT_SPEAKER_SAFE, 58 SND_DEVICE_OUT_HEADPHONES, 59 SND_DEVICE_OUT_LINE, 60 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, 61 SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES, 62 SND_DEVICE_OUT_SPEAKER_AND_LINE, 63 SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE, 64 SND_DEVICE_OUT_VOICE_HANDSET, 65 SND_DEVICE_OUT_VOICE_SPEAKER, 66 SND_DEVICE_OUT_VOICE_HEADPHONES, 67 SND_DEVICE_OUT_VOICE_LINE, 68 SND_DEVICE_OUT_HDMI, 69 SND_DEVICE_OUT_SPEAKER_AND_HDMI, 70 SND_DEVICE_OUT_BT_SCO, 71 SND_DEVICE_OUT_BT_SCO_WB, 72 SND_DEVICE_OUT_VOICE_HANDSET_TMUS, 73 SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES, 74 SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES, 75 SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET, 76 SND_DEVICE_OUT_VOICE_HAC_HANDSET, 77 SND_DEVICE_OUT_VOICE_TX, 78 SND_DEVICE_OUT_SPEAKER_PROTECTED, 79 SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED, 80 SND_DEVICE_OUT_VOICE_SPEAKER_HFP, 81 SND_DEVICE_OUT_END, 82 83 /* 84 * Note: IN_BEGIN should be same as OUT_END because total number of devices 85 * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices. 86 */ 87 /* Capture devices */ 88 SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END, 89 SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN, 90 SND_DEVICE_IN_HANDSET_MIC_AEC, 91 SND_DEVICE_IN_HANDSET_MIC_NS, 92 SND_DEVICE_IN_HANDSET_MIC_AEC_NS, 93 SND_DEVICE_IN_HANDSET_DMIC, 94 SND_DEVICE_IN_HANDSET_DMIC_AEC, 95 SND_DEVICE_IN_HANDSET_DMIC_NS, 96 SND_DEVICE_IN_HANDSET_DMIC_AEC_NS, 97 SND_DEVICE_IN_HANDSET_DMIC_STEREO, 98 99 SND_DEVICE_IN_SPEAKER_MIC, 100 SND_DEVICE_IN_SPEAKER_MIC_AEC, 101 SND_DEVICE_IN_SPEAKER_MIC_NS, 102 SND_DEVICE_IN_SPEAKER_MIC_AEC_NS, 103 SND_DEVICE_IN_SPEAKER_DMIC, 104 SND_DEVICE_IN_SPEAKER_DMIC_AEC, 105 SND_DEVICE_IN_SPEAKER_DMIC_NS, 106 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS, 107 SND_DEVICE_IN_SPEAKER_DMIC_STEREO, 108 109 SND_DEVICE_IN_HEADSET_MIC, 110 SND_DEVICE_IN_HEADSET_MIC_AEC, 111 112 SND_DEVICE_IN_HDMI_MIC, 113 SND_DEVICE_IN_BT_SCO_MIC, 114 SND_DEVICE_IN_BT_SCO_MIC_NREC, 115 SND_DEVICE_IN_BT_SCO_MIC_WB, 116 SND_DEVICE_IN_BT_SCO_MIC_WB_NREC, 117 SND_DEVICE_IN_CAMCORDER_MIC, 118 119 SND_DEVICE_IN_VOICE_DMIC, 120 SND_DEVICE_IN_VOICE_DMIC_TMUS, 121 SND_DEVICE_IN_VOICE_SPEAKER_MIC, 122 SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP, 123 SND_DEVICE_IN_VOICE_SPEAKER_DMIC, 124 SND_DEVICE_IN_VOICE_HEADSET_MIC, 125 SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC, 126 SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC, 127 SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC, 128 129 SND_DEVICE_IN_VOICE_REC_MIC, 130 SND_DEVICE_IN_VOICE_REC_MIC_NS, 131 SND_DEVICE_IN_VOICE_REC_MIC_AEC, 132 SND_DEVICE_IN_VOICE_REC_DMIC_STEREO, 133 SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE, 134 SND_DEVICE_IN_VOICE_REC_HEADSET_MIC, 135 136 SND_DEVICE_IN_UNPROCESSED_MIC, 137 SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC, 138 SND_DEVICE_IN_UNPROCESSED_STEREO_MIC, 139 SND_DEVICE_IN_UNPROCESSED_THREE_MIC, 140 SND_DEVICE_IN_UNPROCESSED_QUAD_MIC, 141 142 SND_DEVICE_IN_VOICE_RX, 143 144 SND_DEVICE_IN_THREE_MIC, 145 SND_DEVICE_IN_QUAD_MIC, 146 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK, 147 148 SND_DEVICE_IN_HANDSET_TMIC, 149 SND_DEVICE_IN_HANDSET_QMIC, 150 SND_DEVICE_IN_HANDSET_TMIC_AEC, 151 SND_DEVICE_IN_HANDSET_QMIC_AEC, 152 SND_DEVICE_IN_END, 153 154 SND_DEVICE_MAX = SND_DEVICE_IN_END, 155 156 }; 157 158 #define DEVICE_NAME_MAX_SIZE 128 159 #define HW_INFO_ARRAY_MAX_SIZE 32 160 161 #define DEFAULT_OUTPUT_SAMPLING_RATE 48000 162 163 #define ALL_SESSION_VSID 0xFFFFFFFF 164 #define DEFAULT_MUTE_RAMP_DURATION_MS 20 165 #define DEFAULT_VOLUME_RAMP_DURATION_MS 20 166 #define MIXER_PATH_MAX_LENGTH 100 167 168 #define ACDB_ID_VOICE_SPEAKER 15 169 #define ACDB_ID_VOICE_HANDSET 7 170 #define ACDB_ID_VOICE_HANDSET_TMUS 88 171 #define ACDB_ID_VOICE_DMIC_EF_TMUS 89 172 #define ACDB_ID_HEADSET_MIC_AEC 8 173 #define ACDB_ID_VOICE_REC_MIC 62 174 175 #define MAX_VOL_INDEX 5 176 #define MIN_VOL_INDEX 0 177 #define percent_to_index(val, min, max) \ 178 ((val) * ((max) - (min)) * 0.01 + (min) + .5) 179 180 /* 181 * tinyAlsa library interprets period size as number of frames 182 * one frame = channel_count * sizeof (pcm sample) 183 * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes 184 * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes 185 * We should take care of returning proper size when AudioFlinger queries for 186 * the buffer size of an input/output stream 187 */ 188 189 /* 1920 frames(40ms) at 2 buffers gives a good tradeoff between power and latency */ 190 #define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 1920 191 #define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 2 192 193 #define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240 194 #define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2 195 196 #define HDMI_MULTI_PERIOD_SIZE 336 197 #define HDMI_MULTI_PERIOD_COUNT 8 198 #define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6 199 #define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2) 200 201 #define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20 202 #define AUDIO_CAPTURE_PERIOD_COUNT 2 203 204 #define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000 205 #define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240 206 #define LOW_LATENCY_CAPTURE_USE_CASE 1 207 208 #define DEEP_BUFFER_PCM_DEVICE 0 209 #define AUDIO_RECORD_PCM_DEVICE 0 210 #define MULTIMEDIA2_PCM_DEVICE 1 211 212 #define SPKR_PROT_CALIB_RX_PCM_DEVICE 5 213 #define SPKR_PROT_CALIB_TX_PCM_DEVICE 25 214 215 #define MULTIMEDIA3_PCM_DEVICE 4 216 217 #define QUAT_MI2S_PCM_DEVICE 44 218 #define PLAYBACK_OFFLOAD_DEVICE 9 219 #define LOWLATENCY_PCM_DEVICE 15 220 #define VOICE_VSID 0x10C01000 221 222 #ifdef PLATFORM_MSM8x26 223 #define VOICE_CALL_PCM_DEVICE 2 224 #define VOICE2_CALL_PCM_DEVICE 14 225 #define VOLTE_CALL_PCM_DEVICE 17 226 #define QCHAT_CALL_PCM_DEVICE 18 227 #define VOWLAN_CALL_PCM_DEVICE 30 228 #elif PLATFORM_MSM8084 229 #define VOICE_CALL_PCM_DEVICE 20 230 #define VOICE2_CALL_PCM_DEVICE 25 231 #define VOLTE_CALL_PCM_DEVICE 21 232 #define QCHAT_CALL_PCM_DEVICE 33 233 #define VOWLAN_CALL_PCM_DEVICE -1 234 #elif PLATFORM_MSM8996 235 #define VOICE_CALL_PCM_DEVICE 40 236 #define VOICE2_CALL_PCM_DEVICE 41 237 #define VOLTE_CALL_PCM_DEVICE 14 238 #define QCHAT_CALL_PCM_DEVICE 20 239 #define VOWLAN_CALL_PCM_DEVICE 33 240 #else 241 #define VOICE_CALL_PCM_DEVICE 2 242 #define VOICE2_CALL_PCM_DEVICE 22 243 #define VOLTE_CALL_PCM_DEVICE 14 244 #define QCHAT_CALL_PCM_DEVICE 20 245 #define VOWLAN_CALL_PCM_DEVICE 36 246 #endif 247 248 #ifdef PLATFORM_MSM8996 249 #define VOICEMMODE1_CALL_PCM_DEVICE 2 250 #define VOICEMMODE2_CALL_PCM_DEVICE 22 251 #else 252 #define VOICEMMODE1_CALL_PCM_DEVICE 44 253 #define VOICEMMODE2_CALL_PCM_DEVICE 45 254 #endif 255 256 #define AFE_PROXY_PLAYBACK_PCM_DEVICE 7 257 #define AFE_PROXY_RECORD_PCM_DEVICE 8 258 259 #define HFP_PCM_RX 5 260 #ifdef PLATFORM_MSM8x26 261 #ifdef EXTERNAL_BT_SUPPORTED 262 #define HFP_SCO_RX 10 // AUXPCM Hostless 263 #else 264 #define HFP_SCO_RX 28 // INT_HFP_BT Hostless 265 #endif 266 #define HFP_ASM_RX_TX 29 267 #else 268 #define HFP_SCO_RX 23 269 #define HFP_ASM_RX_TX 24 270 #endif 271 272 #define LIB_CSD_CLIENT "libcsd-client.so" 273 #define LIB_MDM_DETECT "libmdmdetect.so" 274 275 #define PLATFORM_CONFIG_KEY_SOUNDCARD_NAME "snd_card_name" 276 #define PLATFORM_CONFIG_KEY_MAX_MIC_COUNT "input_mic_max_count" 277 #define PLATFORM_DEFAULT_MIC_COUNT 2 278 279 /* CSD-CLIENT related functions */ 280 typedef int (*init_t)(bool); 281 typedef int (*deinit_t)(); 282 typedef int (*disable_device_t)(); 283 typedef int (*enable_device_config_t)(int, int); 284 typedef int (*enable_device_t)(int, int, uint32_t); 285 typedef int (*volume_t)(uint32_t, int, uint16_t); 286 typedef int (*mic_mute_t)(uint32_t, int, uint16_t); 287 typedef int (*slow_talk_t)(uint32_t, uint8_t); 288 typedef int (*start_voice_t)(uint32_t); 289 typedef int (*stop_voice_t)(uint32_t); 290 typedef int (*start_playback_t)(uint32_t); 291 typedef int (*stop_playback_t)(uint32_t); 292 typedef int (*start_record_t)(uint32_t, int); 293 typedef int (*stop_record_t)(uint32_t); 294 typedef int (*get_sample_rate_t)(uint32_t *); 295 /* CSD Client structure */ 296 struct csd_data { 297 void *csd_client; 298 init_t init; 299 deinit_t deinit; 300 disable_device_t disable_device; 301 enable_device_config_t enable_device_config; 302 enable_device_t enable_device; 303 volume_t volume; 304 mic_mute_t mic_mute; 305 slow_talk_t slow_talk; 306 start_voice_t start_voice; 307 stop_voice_t stop_voice; 308 start_playback_t start_playback; 309 stop_playback_t stop_playback; 310 start_record_t start_record; 311 stop_record_t stop_record; 312 get_sample_rate_t get_sample_rate; 313 }; 314 315 #define PLATFORM_INFO_XML_PATH "/system/etc/audio_platform_info.xml" 316 #define PLATFORM_INFO_XML_BASE_STRING "/system/etc/audio_platform_info" 317 #endif // QCOM_AUDIO_PLATFORM_H 318