Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1 | /* |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. |
| 3 | * Not a Contribution. |
| 4 | * |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 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 |
Vidyakumar Athota | 21b3bb9 | 2014-04-25 11:08:08 -0700 | [diff] [blame] | 22 | #include <sound/voice_params.h> |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 23 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 24 | enum { |
| 25 | FLUENCE_NONE, |
| 26 | FLUENCE_DUAL_MIC = 0x1, |
| 27 | FLUENCE_QUAD_MIC = 0x2, |
| 28 | }; |
| 29 | |
Karthik Reddy Katta | d9fff86 | 2014-07-21 21:07:21 +0530 | [diff] [blame] | 30 | enum { |
| 31 | FLUENCE_ENDFIRE = 0x1, |
| 32 | FLUENCE_BROADSIDE = 0x2, |
| 33 | }; |
| 34 | |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 35 | #define PLATFORM_IMAGE_NAME "modem" |
| 36 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 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_HEADPHONES, |
| 60 | SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, |
| 61 | SND_DEVICE_OUT_VOICE_HANDSET, |
| 62 | SND_DEVICE_OUT_VOICE_SPEAKER, |
| 63 | SND_DEVICE_OUT_VOICE_HEADPHONES, |
| 64 | SND_DEVICE_OUT_HDMI, |
| 65 | SND_DEVICE_OUT_SPEAKER_AND_HDMI, |
| 66 | SND_DEVICE_OUT_BT_SCO, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 67 | SND_DEVICE_OUT_BT_SCO_WB, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 68 | SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES, |
| 69 | SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES, |
| 70 | SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET, |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame^] | 71 | SND_DEVICE_OUT_VOICE_TX, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 72 | SND_DEVICE_OUT_AFE_PROXY, |
| 73 | SND_DEVICE_OUT_USB_HEADSET, |
| 74 | SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET, |
| 75 | SND_DEVICE_OUT_TRANSMISSION_FM, |
| 76 | SND_DEVICE_OUT_ANC_HEADSET, |
| 77 | SND_DEVICE_OUT_ANC_FB_HEADSET, |
| 78 | SND_DEVICE_OUT_VOICE_ANC_HEADSET, |
| 79 | SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET, |
| 80 | SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET, |
| 81 | SND_DEVICE_OUT_ANC_HANDSET, |
| 82 | SND_DEVICE_OUT_SPEAKER_PROTECTED, |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 83 | #ifdef RECORD_PLAY_CONCURRENCY |
| 84 | SND_DEVICE_OUT_VOIP_HANDSET, |
| 85 | SND_DEVICE_OUT_VOIP_SPEAKER, |
| 86 | SND_DEVICE_OUT_VOIP_HEADPHONES, |
| 87 | #endif |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 88 | SND_DEVICE_OUT_END, |
| 89 | |
| 90 | /* |
| 91 | * Note: IN_BEGIN should be same as OUT_END because total number of devices |
| 92 | * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices. |
| 93 | */ |
| 94 | /* Capture devices */ |
| 95 | SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END, |
| 96 | SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 97 | SND_DEVICE_IN_HANDSET_MIC_AEC, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 98 | SND_DEVICE_IN_HANDSET_MIC_NS, |
| 99 | SND_DEVICE_IN_HANDSET_MIC_AEC_NS, |
| 100 | SND_DEVICE_IN_HANDSET_DMIC, |
| 101 | SND_DEVICE_IN_HANDSET_DMIC_AEC, |
| 102 | SND_DEVICE_IN_HANDSET_DMIC_NS, |
| 103 | SND_DEVICE_IN_HANDSET_DMIC_AEC_NS, |
| 104 | SND_DEVICE_IN_SPEAKER_MIC, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 105 | SND_DEVICE_IN_SPEAKER_MIC_AEC, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 106 | SND_DEVICE_IN_SPEAKER_MIC_NS, |
| 107 | SND_DEVICE_IN_SPEAKER_MIC_AEC_NS, |
| 108 | SND_DEVICE_IN_SPEAKER_DMIC, |
| 109 | SND_DEVICE_IN_SPEAKER_DMIC_AEC, |
| 110 | SND_DEVICE_IN_SPEAKER_DMIC_NS, |
| 111 | SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS, |
| 112 | SND_DEVICE_IN_HEADSET_MIC, |
| 113 | SND_DEVICE_IN_HEADSET_MIC_FLUENCE, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 114 | SND_DEVICE_IN_VOICE_SPEAKER_MIC, |
| 115 | SND_DEVICE_IN_VOICE_HEADSET_MIC, |
| 116 | SND_DEVICE_IN_HDMI_MIC, |
| 117 | SND_DEVICE_IN_BT_SCO_MIC, |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 118 | SND_DEVICE_IN_BT_SCO_MIC_NREC, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 119 | SND_DEVICE_IN_BT_SCO_MIC_WB, |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 120 | SND_DEVICE_IN_BT_SCO_MIC_WB_NREC, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 121 | SND_DEVICE_IN_CAMCORDER_MIC, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 122 | SND_DEVICE_IN_VOICE_DMIC, |
| 123 | SND_DEVICE_IN_VOICE_SPEAKER_DMIC, |
| 124 | SND_DEVICE_IN_VOICE_SPEAKER_QMIC, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 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 | SND_DEVICE_IN_VOICE_REC_MIC, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 129 | SND_DEVICE_IN_VOICE_REC_MIC_NS, |
| 130 | SND_DEVICE_IN_VOICE_REC_DMIC_STEREO, |
| 131 | SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE, |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame^] | 132 | SND_DEVICE_IN_VOICE_RX, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 133 | SND_DEVICE_IN_USB_HEADSET_MIC, |
| 134 | SND_DEVICE_IN_CAPTURE_FM, |
| 135 | SND_DEVICE_IN_AANC_HANDSET_MIC, |
| 136 | SND_DEVICE_IN_QUAD_MIC, |
| 137 | SND_DEVICE_IN_HANDSET_STEREO_DMIC, |
| 138 | SND_DEVICE_IN_SPEAKER_STEREO_DMIC, |
| 139 | SND_DEVICE_IN_CAPTURE_VI_FEEDBACK, |
Karthik Reddy Katta | d9fff86 | 2014-07-21 21:07:21 +0530 | [diff] [blame] | 140 | SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE, |
| 141 | SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE, |
| 142 | SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE, |
| 143 | SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE, |
| 144 | SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE, |
Sidipotu Ashok | 3bcca23 | 2014-11-07 14:41:58 +0530 | [diff] [blame] | 145 | SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC, |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 146 | SND_DEVICE_IN_HANDSET_QMIC, |
| 147 | SND_DEVICE_IN_SPEAKER_QMIC_AEC, |
| 148 | SND_DEVICE_IN_SPEAKER_QMIC_NS, |
| 149 | SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 150 | SND_DEVICE_IN_END, |
| 151 | |
| 152 | SND_DEVICE_MAX = SND_DEVICE_IN_END, |
| 153 | |
| 154 | }; |
| 155 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 156 | #define DEFAULT_OUTPUT_SAMPLING_RATE 48000 |
| 157 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 158 | #define ALL_SESSION_VSID 0xFFFFFFFF |
| 159 | #define DEFAULT_MUTE_RAMP_DURATION 500 |
| 160 | #define DEFAULT_VOLUME_RAMP_DURATION_MS 20 |
| 161 | #define MIXER_PATH_MAX_LENGTH 100 |
| 162 | |
| 163 | #define MAX_VOL_INDEX 5 |
| 164 | #define MIN_VOL_INDEX 0 |
| 165 | #define percent_to_index(val, min, max) \ |
| 166 | ((val) * ((max) - (min)) * 0.01 + (min) + .5) |
| 167 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 168 | /* |
| 169 | * tinyAlsa library interprets period size as number of frames |
| 170 | * one frame = channel_count * sizeof (pcm sample) |
| 171 | * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes |
| 172 | * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes |
| 173 | * We should take care of returning proper size when AudioFlinger queries for |
| 174 | * the buffer size of an input/output stream |
| 175 | */ |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 176 | #define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960 |
| 177 | #define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 4 |
| 178 | #define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240 |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 179 | #define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2 |
| 180 | |
Ravi Kumar Alamanda | dc9bb15 | 2014-09-08 15:59:58 -0700 | [diff] [blame] | 181 | #define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000 |
| 182 | #define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240 |
Sharad Sangle | 896e7b1 | 2014-11-07 17:06:29 +0530 | [diff] [blame] | 183 | #define LOW_LATENCY_CAPTURE_USE_CASE 1 |
Ravi Kumar Alamanda | dc9bb15 | 2014-09-08 15:59:58 -0700 | [diff] [blame] | 184 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 185 | #define HDMI_MULTI_PERIOD_SIZE 336 |
| 186 | #define HDMI_MULTI_PERIOD_COUNT 8 |
| 187 | #define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6 |
| 188 | #define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2) |
| 189 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 190 | #define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20 |
| 191 | #define AUDIO_CAPTURE_PERIOD_COUNT 2 |
| 192 | |
| 193 | #define DEVICE_NAME_MAX_SIZE 128 |
| 194 | #define HW_INFO_ARRAY_MAX_SIZE 32 |
| 195 | |
| 196 | #define DEEP_BUFFER_PCM_DEVICE 0 |
| 197 | #define AUDIO_RECORD_PCM_DEVICE 0 |
| 198 | #define MULTIMEDIA2_PCM_DEVICE 1 |
| 199 | #define FM_PLAYBACK_PCM_DEVICE 5 |
| 200 | #define FM_CAPTURE_PCM_DEVICE 6 |
| 201 | #define HFP_PCM_RX 5 |
Satya Krishna Pindiproli | 640c91e | 2014-03-14 11:09:09 +0530 | [diff] [blame] | 202 | #define HFP_SCO_RX 17 |
| 203 | #define HFP_ASM_RX_TX 18 |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 204 | |
| 205 | #define INCALL_MUSIC_UPLINK_PCM_DEVICE 1 |
| 206 | #define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16 |
| 207 | #define SPKR_PROT_CALIB_RX_PCM_DEVICE 5 |
| 208 | #define SPKR_PROT_CALIB_TX_PCM_DEVICE 22 |
| 209 | #define PLAYBACK_OFFLOAD_DEVICE 9 |
| 210 | #define COMPRESS_VOIP_CALL_PCM_DEVICE 3 |
| 211 | |
Banajit Goswami | 88d6cc5 | 2014-04-10 17:59:02 -0700 | [diff] [blame] | 212 | /* Define macro for Internal FM volume mixer */ |
| 213 | #define FM_RX_VOLUME "Internal FM RX Volume" |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 214 | |
| 215 | #define LOWLATENCY_PCM_DEVICE 12 |
| 216 | #define EC_REF_RX "I2S_RX" |
| 217 | #define COMPRESS_CAPTURE_DEVICE 19 |
| 218 | |
| 219 | #define VOICE_CALL_PCM_DEVICE 2 |
| 220 | #define VOICE2_CALL_PCM_DEVICE 13 |
| 221 | #define VOLTE_CALL_PCM_DEVICE 15 |
| 222 | #define QCHAT_CALL_PCM_DEVICE 14 |
Karthik Reddy Katta | 3b0a60c | 2014-04-06 14:52:37 +0530 | [diff] [blame] | 223 | #define VOWLAN_CALL_PCM_DEVICE 16 |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 224 | |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame^] | 225 | #define AFE_PROXY_PLAYBACK_PCM_DEVICE 7 |
| 226 | #define AFE_PROXY_RECORD_PCM_DEVICE 8 |
| 227 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 228 | #define LIB_CSD_CLIENT "libcsd-client.so" |
| 229 | /* CSD-CLIENT related functions */ |
| 230 | typedef int (*init_t)(); |
| 231 | typedef int (*deinit_t)(); |
| 232 | typedef int (*disable_device_t)(); |
| 233 | typedef int (*enable_device_config_t)(int, int); |
| 234 | typedef int (*enable_device_t)(int, int, uint32_t); |
| 235 | typedef int (*volume_t)(uint32_t, int); |
| 236 | typedef int (*mic_mute_t)(uint32_t, int); |
| 237 | typedef int (*slow_talk_t)(uint32_t, uint8_t); |
| 238 | typedef int (*start_voice_t)(uint32_t); |
| 239 | typedef int (*stop_voice_t)(uint32_t); |
| 240 | typedef int (*start_playback_t)(uint32_t); |
| 241 | typedef int (*stop_playback_t)(uint32_t); |
Vidyakumar Athota | 21b3bb9 | 2014-04-25 11:08:08 -0700 | [diff] [blame] | 242 | typedef int (*set_lch_t)(uint32_t, enum voice_lch_mode); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 243 | typedef int (*start_record_t)(uint32_t, int); |
| 244 | typedef int (*stop_record_t)(uint32_t); |
| 245 | /* CSD Client structure */ |
| 246 | struct csd_data { |
| 247 | void *csd_client; |
| 248 | init_t init; |
| 249 | deinit_t deinit; |
| 250 | disable_device_t disable_device; |
| 251 | enable_device_config_t enable_device_config; |
| 252 | enable_device_t enable_device; |
| 253 | volume_t volume; |
| 254 | mic_mute_t mic_mute; |
| 255 | slow_talk_t slow_talk; |
| 256 | start_voice_t start_voice; |
| 257 | stop_voice_t stop_voice; |
| 258 | start_playback_t start_playback; |
| 259 | stop_playback_t stop_playback; |
Vidyakumar Athota | 21b3bb9 | 2014-04-25 11:08:08 -0700 | [diff] [blame] | 260 | set_lch_t set_lch; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 261 | start_record_t start_record; |
| 262 | stop_record_t stop_record; |
| 263 | }; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 264 | |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 265 | int platform_get_subsys_image_name (char *buf); |
| 266 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 267 | #endif // QCOM_AUDIO_PLATFORM_H |