1 /* 2 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. 3 * Not a Contribution. 4 * 5 * Copyright (C) 2013 The Android Open Source Project 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 #ifndef QCOM_AUDIO_PLATFORM_H 21 #define QCOM_AUDIO_PLATFORM_H 22 #include <sound/voice_params.h> 23 24 enum { 25 FLUENCE_NONE, 26 FLUENCE_DUAL_MIC = 0x1, 27 FLUENCE_QUAD_MIC = 0x2, 28 }; 29 30 enum { 31 FLUENCE_ENDFIRE = 0x1, 32 FLUENCE_BROADSIDE = 0x2, 33 }; 34 35 #define PLATFORM_IMAGE_NAME "modem" 36 37 /* 38 * Below are the devices for which is back end is same, SLIMBUS_0_RX. 39 * All these devices are handled by the internal HW codec. We can 40 * enable any one of these devices at any time. 41 */ 42 #define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \ 43 (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \ 44 AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE) 45 46 /* Sound devices specific to the platform 47 * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound 48 * devices to enable corresponding mixer paths 49 */ 50 enum { 51 SND_DEVICE_NONE = 0, 52 53 /* Playback devices */ 54 SND_DEVICE_MIN, 55 SND_DEVICE_OUT_BEGIN = SND_DEVICE_MIN, 56 SND_DEVICE_OUT_HANDSET = SND_DEVICE_OUT_BEGIN, 57 SND_DEVICE_OUT_SPEAKER, 58 SND_DEVICE_OUT_SPEAKER_REVERSE, 59 SND_DEVICE_OUT_SPEAKER_WSA, 60 SND_DEVICE_OUT_HEADPHONES, 61 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, 62 SND_DEVICE_OUT_VOICE_HANDSET, 63 SND_DEVICE_OUT_VOICE_SPEAKER, 64 SND_DEVICE_OUT_VOICE_SPEAKER_WSA, 65 SND_DEVICE_OUT_VOICE_HEADPHONES, 66 SND_DEVICE_OUT_HDMI, 67 SND_DEVICE_OUT_SPEAKER_AND_HDMI, 68 SND_DEVICE_OUT_BT_SCO, 69 SND_DEVICE_OUT_BT_SCO_WB, 70 SND_DEVICE_OUT_BT_A2DP, 71 SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP, 72 SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES, 73 SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES, 74 SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET, 75 SND_DEVICE_OUT_AFE_PROXY, 76 SND_DEVICE_OUT_USB_HEADSET, 77 SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET, 78 SND_DEVICE_OUT_TRANSMISSION_FM, 79 SND_DEVICE_OUT_ANC_HEADSET, 80 SND_DEVICE_OUT_ANC_FB_HEADSET, 81 SND_DEVICE_OUT_VOICE_ANC_HEADSET, 82 SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET, 83 SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET, 84 SND_DEVICE_OUT_ANC_HANDSET, 85 SND_DEVICE_OUT_SPEAKER_PROTECTED, 86 #ifdef RECORD_PLAY_CONCURRENCY 87 SND_DEVICE_OUT_VOIP_HANDSET, 88 SND_DEVICE_OUT_VOIP_SPEAKER, 89 SND_DEVICE_OUT_VOIP_HEADPHONES, 90 #endif 91 SND_DEVICE_OUT_END, 92 93 /* 94 * Note: IN_BEGIN should be same as OUT_END because total number of devices 95 * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices. 96 */ 97 /* Capture devices */ 98 SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END, 99 SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN, 100 SND_DEVICE_IN_HANDSET_MIC_AEC, 101 SND_DEVICE_IN_HANDSET_MIC_NS, 102 SND_DEVICE_IN_HANDSET_MIC_AEC_NS, 103 SND_DEVICE_IN_HANDSET_DMIC, 104 SND_DEVICE_IN_HANDSET_DMIC_AEC, 105 SND_DEVICE_IN_HANDSET_DMIC_NS, 106 SND_DEVICE_IN_HANDSET_DMIC_AEC_NS, 107 SND_DEVICE_IN_SPEAKER_MIC, 108 SND_DEVICE_IN_SPEAKER_MIC_AEC, 109 SND_DEVICE_IN_SPEAKER_MIC_NS, 110 SND_DEVICE_IN_SPEAKER_MIC_AEC_NS, 111 SND_DEVICE_IN_SPEAKER_DMIC, 112 SND_DEVICE_IN_SPEAKER_DMIC_AEC, 113 SND_DEVICE_IN_SPEAKER_DMIC_NS, 114 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS, 115 SND_DEVICE_IN_HEADSET_MIC, 116 SND_DEVICE_IN_HEADSET_MIC_FLUENCE, 117 SND_DEVICE_IN_VOICE_SPEAKER_MIC, 118 SND_DEVICE_IN_VOICE_HEADSET_MIC, 119 SND_DEVICE_IN_HDMI_MIC, 120 SND_DEVICE_IN_BT_SCO_MIC, 121 SND_DEVICE_IN_BT_SCO_MIC_NREC, 122 SND_DEVICE_IN_BT_SCO_MIC_WB, 123 SND_DEVICE_IN_BT_SCO_MIC_WB_NREC, 124 SND_DEVICE_IN_CAMCORDER_MIC, 125 SND_DEVICE_IN_VOICE_DMIC, 126 SND_DEVICE_IN_VOICE_SPEAKER_DMIC, 127 SND_DEVICE_IN_VOICE_SPEAKER_QMIC, 128 SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC, 129 SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC, 130 SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC, 131 SND_DEVICE_IN_VOICE_REC_MIC, 132 SND_DEVICE_IN_VOICE_REC_MIC_NS, 133 SND_DEVICE_IN_VOICE_REC_DMIC_STEREO, 134 SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE, 135 SND_DEVICE_IN_USB_HEADSET_MIC, 136 SND_DEVICE_IN_CAPTURE_FM, 137 SND_DEVICE_IN_AANC_HANDSET_MIC, 138 SND_DEVICE_IN_QUAD_MIC, 139 SND_DEVICE_IN_HANDSET_STEREO_DMIC, 140 SND_DEVICE_IN_SPEAKER_STEREO_DMIC, 141 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK, 142 SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE, 143 SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE, 144 SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE, 145 SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE, 146 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE, 147 SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC, 148 SND_DEVICE_IN_HANDSET_QMIC, 149 SND_DEVICE_IN_SPEAKER_QMIC_AEC, 150 SND_DEVICE_IN_SPEAKER_QMIC_NS, 151 SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS, 152 SND_DEVICE_IN_END, 153 154 SND_DEVICE_MAX = SND_DEVICE_IN_END, 155 156 }; 157 158 #define DEFAULT_OUTPUT_SAMPLING_RATE 48000 159 160 #define ALL_SESSION_VSID 0xFFFFFFFF 161 #define DEFAULT_MUTE_RAMP_DURATION 500 162 #define DEFAULT_VOLUME_RAMP_DURATION_MS 20 163 #define MIXER_PATH_MAX_LENGTH 100 164 165 #define MAX_VOL_INDEX 5 166 #define MIN_VOL_INDEX 0 167 #define percent_to_index(val, min, max) \ 168 ((val) * ((max) - (min)) * 0.01 + (min) + .5) 169 170 /* 171 * tinyAlsa library interprets period size as number of frames 172 * one frame = channel_count * sizeof (pcm sample) 173 * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes 174 * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes 175 * We should take care of returning proper size when AudioFlinger queries for 176 * the buffer size of an input/output stream 177 */ 178 #define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960 179 #define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 4 180 #define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240 181 #define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2 182 183 #define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000 184 #define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240 185 #define LOW_LATENCY_CAPTURE_USE_CASE 1 186 187 #define HDMI_MULTI_PERIOD_SIZE 336 188 #define HDMI_MULTI_PERIOD_COUNT 8 189 #define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6 190 #define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2) 191 192 #define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20 193 #define AUDIO_CAPTURE_PERIOD_COUNT 2 194 195 #define DEVICE_NAME_MAX_SIZE 128 196 #define HW_INFO_ARRAY_MAX_SIZE 32 197 198 #define DEEP_BUFFER_PCM_DEVICE 0 199 #define AUDIO_RECORD_PCM_DEVICE 0 200 #define MULTIMEDIA2_PCM_DEVICE 1 201 #define FM_PLAYBACK_PCM_DEVICE 5 202 #define FM_CAPTURE_PCM_DEVICE 6 203 #define HFP_PCM_RX 5 204 #define HFP_SCO_RX 17 205 #define HFP_ASM_RX_TX 18 206 #define HFP_ASM_RX_TX_SESSION2 36 207 208 #define INCALL_MUSIC_UPLINK_PCM_DEVICE 1 209 #define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16 210 #define SPKR_PROT_CALIB_RX_PCM_DEVICE 5 211 #define SPKR_PROT_CALIB_TX_PCM_DEVICE 22 212 #define PLAYBACK_OFFLOAD_DEVICE 9 213 #define COMPRESS_VOIP_CALL_PCM_DEVICE 3 214 215 /* Define macro for Internal FM volume mixer */ 216 #define FM_RX_VOLUME "Internal FM RX Volume" 217 218 #define LOWLATENCY_PCM_DEVICE 12 219 #define EC_REF_RX "I2S_RX" 220 #define COMPRESS_CAPTURE_DEVICE 19 221 222 #define VOICE_CALL_PCM_DEVICE 2 223 #define VOICE2_CALL_PCM_DEVICE 13 224 #define VOLTE_CALL_PCM_DEVICE 15 225 #define QCHAT_CALL_PCM_DEVICE 26 226 #define QCHAT_CALL_PCM_DEVICE_OF_EXT_CODEC 28 227 #define VOWLAN_CALL_PCM_DEVICE 16 228 229 #define LIB_CSD_CLIENT "libcsd-client.so" 230 /* CSD-CLIENT related functions */ 231 typedef int (*init_t)(); 232 typedef int (*deinit_t)(); 233 typedef int (*disable_device_t)(); 234 typedef int (*enable_device_config_t)(int, int); 235 typedef int (*enable_device_t)(int, int, uint32_t); 236 typedef int (*volume_t)(uint32_t, int); 237 typedef int (*mic_mute_t)(uint32_t, int); 238 typedef int (*slow_talk_t)(uint32_t, uint8_t); 239 typedef int (*start_voice_t)(uint32_t); 240 typedef int (*stop_voice_t)(uint32_t); 241 typedef int (*start_playback_t)(uint32_t); 242 typedef int (*stop_playback_t)(uint32_t); 243 typedef int (*set_lch_t)(uint32_t, enum voice_lch_mode); 244 typedef int (*start_record_t)(uint32_t, int); 245 typedef int (*stop_record_t)(uint32_t); 246 /* CSD Client structure */ 247 struct csd_data { 248 void *csd_client; 249 init_t init; 250 deinit_t deinit; 251 disable_device_t disable_device; 252 enable_device_config_t enable_device_config; 253 enable_device_t enable_device; 254 volume_t volume; 255 mic_mute_t mic_mute; 256 slow_talk_t slow_talk; 257 start_voice_t start_voice; 258 stop_voice_t stop_voice; 259 start_playback_t start_playback; 260 stop_playback_t stop_playback; 261 set_lch_t set_lch; 262 start_record_t start_record; 263 stop_record_t stop_record; 264 }; 265 266 int platform_get_subsys_image_name (char *buf); 267 268 269 #define ENUM_TO_STRING(X) #X 270 271 struct audio_device_to_audio_interface { 272 audio_devices_t device; 273 char device_name[100]; 274 char interface_name[100]; 275 }; 276 #endif // QCOM_AUDIO_PLATFORM_H 277