Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1 | /* |
vivek mehta | a51fd40 | 2016-02-04 19:49:33 -0800 | [diff] [blame] | 2 | * Copyright (C) 2013-2016 The Android Open Source Project |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 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 | */ |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 16 | #define LOG_TAG "msm8974_platform" |
| 17 | /*#define LOG_NDEBUG 0*/ |
| 18 | #define LOG_NDDEBUG 0 |
| 19 | |
| 20 | #include <stdlib.h> |
| 21 | #include <dlfcn.h> |
| 22 | #include <cutils/log.h> |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 23 | #include <cutils/str_parms.h> |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 24 | #include <cutils/properties.h> |
| 25 | #include <audio_hw.h> |
| 26 | #include <platform_api.h> |
| 27 | #include "platform.h" |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 28 | #include "audio_extn.h" |
vivek mehta | 1a9b7c0 | 2015-06-25 11:49:38 -0700 | [diff] [blame] | 29 | #include <linux/msm_audio.h> |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 30 | |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 31 | #define MIXER_XML_PATH "/system/etc/mixer_paths.xml" |
Uday Kishore Pasupuleti | 11dd223 | 2015-06-24 14:18:01 -0700 | [diff] [blame] | 32 | #define MIXER_XML_PATH_WCD9330 "/system/etc/mixer_paths_wcd9330.xml" |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 33 | #define LIB_ACDB_LOADER "libacdbloader.so" |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 34 | #define AUDIO_DATA_BLOCK_MIXER_CTL "HDMI EDID" |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 35 | #define CVD_VERSION_MIXER_CTL "CVD Version" |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 36 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 37 | |
| 38 | /* |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 39 | * This file will have a maximum of 38 bytes: |
| 40 | * |
| 41 | * 4 bytes: number of audio blocks |
| 42 | * 4 bytes: total length of Short Audio Descriptor (SAD) blocks |
| 43 | * Maximum 10 * 3 bytes: SAD blocks |
| 44 | */ |
| 45 | #define MAX_SAD_BLOCKS 10 |
| 46 | #define SAD_BLOCK_SIZE 3 |
| 47 | |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 48 | #define MAX_CVD_VERSION_STRING_SIZE 100 |
| 49 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 50 | /* EDID format ID for LPCM audio */ |
| 51 | #define EDID_FORMAT_LPCM 1 |
| 52 | |
sangwoo | 1b9f4b3 | 2013-06-21 18:22:55 -0700 | [diff] [blame] | 53 | /* Retry for delay in FW loading*/ |
| 54 | #define RETRY_NUMBER 10 |
| 55 | #define RETRY_US 500000 |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 56 | #define MAX_SND_CARD 8 |
sangwoo | 53b2cf0 | 2013-07-25 19:18:44 -0700 | [diff] [blame] | 57 | |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 58 | #define MAX_SND_CARD_NAME_LEN 31 |
| 59 | |
vivek mehta | 1a9b7c0 | 2015-06-25 11:49:38 -0700 | [diff] [blame] | 60 | #define DEFAULT_APP_TYPE_RX_PATH 0x11130 |
| 61 | |
keunhui.park | c5aaa0e | 2015-07-13 10:57:37 +0900 | [diff] [blame] | 62 | #define TOSTRING_(x) #x |
| 63 | #define TOSTRING(x) TOSTRING_(x) |
| 64 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 65 | struct audio_block_header |
| 66 | { |
| 67 | int reserved; |
| 68 | int length; |
| 69 | }; |
| 70 | |
vivek mehta | 1a9b7c0 | 2015-06-25 11:49:38 -0700 | [diff] [blame] | 71 | enum { |
| 72 | CAL_MODE_SEND = 0x1, |
| 73 | CAL_MODE_PERSIST = 0x2, |
| 74 | CAL_MODE_RTAC = 0x4 |
| 75 | }; |
| 76 | |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 77 | #define PLATFORM_CONFIG_KEY_OPERATOR_INFO "operator_info" |
| 78 | |
| 79 | struct operator_info { |
| 80 | struct listnode list; |
| 81 | char *name; |
| 82 | char *mccmnc; |
| 83 | }; |
| 84 | |
| 85 | struct operator_specific_device { |
| 86 | struct listnode list; |
| 87 | char *operator; |
| 88 | char *mixer_path; |
| 89 | int acdb_id; |
| 90 | }; |
| 91 | |
| 92 | static struct listnode operator_info_list; |
| 93 | static struct listnode *operator_specific_device_table[SND_DEVICE_MAX]; |
| 94 | |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 95 | /* Audio calibration related functions */ |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 96 | typedef void (*acdb_deallocate_t)(); |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 97 | typedef int (*acdb_init_v2_cvd_t)(char *, char *); |
| 98 | typedef int (*acdb_init_v2_t)(char *); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 99 | typedef int (*acdb_init_t)(); |
| 100 | typedef void (*acdb_send_audio_cal_t)(int, int); |
| 101 | typedef void (*acdb_send_voice_cal_t)(int, int); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 102 | typedef int (*acdb_reload_vocvoltable_t)(int); |
vivek mehta | 1a9b7c0 | 2015-06-25 11:49:38 -0700 | [diff] [blame] | 103 | typedef int (*acdb_send_gain_dep_cal_t)(int, int, int, int, int); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 104 | |
| 105 | /* Audio calibration related functions */ |
| 106 | struct platform_data { |
| 107 | struct audio_device *adev; |
| 108 | bool fluence_in_spkr_mode; |
| 109 | bool fluence_in_voice_call; |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 110 | bool fluence_in_voice_comm; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 111 | bool fluence_in_voice_rec; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 112 | /* 0 = no fluence, 1 = fluence, 2 = fluence pro */ |
| 113 | int fluence_type; |
| 114 | int source_mic_type; |
Ravi Kumar Alamanda | 1f60cf8 | 2015-04-23 19:45:17 -0700 | [diff] [blame] | 115 | bool speaker_lr_swap; |
| 116 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 117 | void *acdb_handle; |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 118 | acdb_deallocate_t acdb_deallocate; |
| 119 | acdb_send_audio_cal_t acdb_send_audio_cal; |
| 120 | acdb_send_voice_cal_t acdb_send_voice_cal; |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 121 | acdb_reload_vocvoltable_t acdb_reload_vocvoltable; |
vivek mehta | 1a9b7c0 | 2015-06-25 11:49:38 -0700 | [diff] [blame] | 122 | acdb_send_gain_dep_cal_t acdb_send_gain_dep_cal; |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 123 | struct csd_data *csd; |
Ravi Kumar Alamanda | f282901 | 2014-11-12 16:16:10 -0800 | [diff] [blame] | 124 | char ec_ref_mixer_path[64]; |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 125 | |
| 126 | char *snd_card_name; |
keunhui.park | c5aaa0e | 2015-07-13 10:57:37 +0900 | [diff] [blame] | 127 | int max_vol_index; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 128 | int max_mic_count; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 129 | }; |
| 130 | |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 131 | static int pcm_device_table[AUDIO_USECASE_MAX][2] = { |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 132 | [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE, |
| 133 | DEEP_BUFFER_PCM_DEVICE}, |
| 134 | [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, |
| 135 | LOWLATENCY_PCM_DEVICE}, |
| 136 | [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {MULTIMEDIA2_PCM_DEVICE, |
| 137 | MULTIMEDIA2_PCM_DEVICE}, |
| 138 | [USECASE_AUDIO_PLAYBACK_OFFLOAD] = {PLAYBACK_OFFLOAD_DEVICE, |
| 139 | PLAYBACK_OFFLOAD_DEVICE}, |
Ravi Kumar Alamanda | 2bc7b02 | 2015-06-25 20:08:01 -0700 | [diff] [blame] | 140 | [USECASE_AUDIO_PLAYBACK_TTS] = {MULTIMEDIA2_PCM_DEVICE, |
| 141 | MULTIMEDIA2_PCM_DEVICE}, |
| 142 | [USECASE_AUDIO_PLAYBACK_ULL] = {MULTIMEDIA3_PCM_DEVICE, |
| 143 | MULTIMEDIA3_PCM_DEVICE}, |
| 144 | |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 145 | [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, |
| 146 | AUDIO_RECORD_PCM_DEVICE}, |
| 147 | [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, |
| 148 | LOWLATENCY_PCM_DEVICE}, |
Ravi Kumar Alamanda | 2bc7b02 | 2015-06-25 20:08:01 -0700 | [diff] [blame] | 149 | |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 150 | [USECASE_VOICE_CALL] = {VOICE_CALL_PCM_DEVICE, |
| 151 | VOICE_CALL_PCM_DEVICE}, |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 152 | [USECASE_VOICE2_CALL] = {VOICE2_CALL_PCM_DEVICE, VOICE2_CALL_PCM_DEVICE}, |
| 153 | [USECASE_VOLTE_CALL] = {VOLTE_CALL_PCM_DEVICE, VOLTE_CALL_PCM_DEVICE}, |
| 154 | [USECASE_QCHAT_CALL] = {QCHAT_CALL_PCM_DEVICE, QCHAT_CALL_PCM_DEVICE}, |
| 155 | [USECASE_VOWLAN_CALL] = {VOWLAN_CALL_PCM_DEVICE, VOWLAN_CALL_PCM_DEVICE}, |
vivek mehta | a51fd40 | 2016-02-04 19:49:33 -0800 | [diff] [blame] | 156 | [USECASE_VOICEMMODE1_CALL] = {VOICEMMODE1_CALL_PCM_DEVICE, |
| 157 | VOICEMMODE1_CALL_PCM_DEVICE}, |
| 158 | [USECASE_VOICEMMODE2_CALL] = {VOICEMMODE2_CALL_PCM_DEVICE, |
| 159 | VOICEMMODE2_CALL_PCM_DEVICE}, |
| 160 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 161 | [USECASE_INCALL_REC_UPLINK] = {AUDIO_RECORD_PCM_DEVICE, |
| 162 | AUDIO_RECORD_PCM_DEVICE}, |
| 163 | [USECASE_INCALL_REC_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, |
| 164 | AUDIO_RECORD_PCM_DEVICE}, |
| 165 | [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, |
| 166 | AUDIO_RECORD_PCM_DEVICE}, |
Ravi Kumar Alamanda | 8e6e98f | 2013-11-05 15:57:39 -0800 | [diff] [blame] | 167 | [USECASE_AUDIO_HFP_SCO] = {HFP_PCM_RX, HFP_SCO_RX}, |
Ravi Kumar Alamanda | 99c752d | 2014-08-20 17:55:26 -0700 | [diff] [blame] | 168 | |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 169 | [USECASE_AUDIO_SPKR_CALIB_RX] = {SPKR_PROT_CALIB_RX_PCM_DEVICE, -1}, |
| 170 | [USECASE_AUDIO_SPKR_CALIB_TX] = {-1, SPKR_PROT_CALIB_TX_PCM_DEVICE}, |
| 171 | |
Ravi Kumar Alamanda | 99c752d | 2014-08-20 17:55:26 -0700 | [diff] [blame] | 172 | [USECASE_AUDIO_PLAYBACK_AFE_PROXY] = {AFE_PROXY_PLAYBACK_PCM_DEVICE, |
| 173 | AFE_PROXY_RECORD_PCM_DEVICE}, |
| 174 | [USECASE_AUDIO_RECORD_AFE_PROXY] = {AFE_PROXY_PLAYBACK_PCM_DEVICE, |
| 175 | AFE_PROXY_RECORD_PCM_DEVICE}, |
zhaoyang yin | 4211fad | 2015-06-04 21:13:25 +0800 | [diff] [blame] | 176 | [USECASE_AUDIO_DSM_FEEDBACK] = {QUAT_MI2S_PCM_DEVICE, QUAT_MI2S_PCM_DEVICE}, |
Ravi Kumar Alamanda | 99c752d | 2014-08-20 17:55:26 -0700 | [diff] [blame] | 177 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | /* Array to store sound devices */ |
| 181 | static const char * const device_table[SND_DEVICE_MAX] = { |
| 182 | [SND_DEVICE_NONE] = "none", |
| 183 | /* Playback sound devices */ |
| 184 | [SND_DEVICE_OUT_HANDSET] = "handset", |
| 185 | [SND_DEVICE_OUT_SPEAKER] = "speaker", |
| 186 | [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse", |
Eric Laurent | 1b0d8ce | 2014-09-11 09:59:28 -0700 | [diff] [blame] | 187 | [SND_DEVICE_OUT_SPEAKER_SAFE] = "speaker-safe", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 188 | [SND_DEVICE_OUT_HEADPHONES] = "headphones", |
Eric Laurent | 09f2e0e | 2014-07-29 16:02:32 -0500 | [diff] [blame] | 189 | [SND_DEVICE_OUT_LINE] = "line", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 190 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", |
Ravi Kumar Alamanda | 3b86d47 | 2015-06-08 00:35:57 -0700 | [diff] [blame] | 191 | [SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES] = "speaker-safe-and-headphones", |
Eric Laurent | 744996b | 2014-10-01 11:40:40 -0500 | [diff] [blame] | 192 | [SND_DEVICE_OUT_SPEAKER_AND_LINE] = "speaker-and-line", |
Ravi Kumar Alamanda | 3b86d47 | 2015-06-08 00:35:57 -0700 | [diff] [blame] | 193 | [SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE] = "speaker-safe-and-line", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 194 | [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset", |
Eric Laurent | 9d0d3f1 | 2014-07-25 12:40:29 -0500 | [diff] [blame] | 195 | [SND_DEVICE_OUT_VOICE_HAC_HANDSET] = "voice-hac-handset", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 196 | [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker", |
| 197 | [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones", |
Eric Laurent | 09f2e0e | 2014-07-29 16:02:32 -0500 | [diff] [blame] | 198 | [SND_DEVICE_OUT_VOICE_LINE] = "voice-line", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 199 | [SND_DEVICE_OUT_HDMI] = "hdmi", |
| 200 | [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi", |
| 201 | [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset", |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 202 | [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 203 | [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus", |
| 204 | [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones", |
| 205 | [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones", |
| 206 | [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset", |
Ravi Kumar Alamanda | 99c752d | 2014-08-20 17:55:26 -0700 | [diff] [blame] | 207 | [SND_DEVICE_OUT_VOICE_TX] = "voice-tx", |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 208 | [SND_DEVICE_OUT_SPEAKER_PROTECTED] = "speaker-protected", |
| 209 | [SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED] = "voice-speaker-protected", |
Uday Kishore Pasupuleti | 7629719 | 2015-09-18 08:39:43 -0700 | [diff] [blame] | 210 | [SND_DEVICE_OUT_VOICE_SPEAKER_HFP] = "voice-speaker-hfp", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 211 | |
| 212 | /* Capture sound devices */ |
| 213 | [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 214 | [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic", |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 215 | [SND_DEVICE_IN_HANDSET_MIC_NS] = "handset-mic", |
| 216 | [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = "handset-mic", |
| 217 | [SND_DEVICE_IN_HANDSET_DMIC] = "dmic-endfire", |
| 218 | [SND_DEVICE_IN_HANDSET_DMIC_AEC] = "dmic-endfire", |
| 219 | [SND_DEVICE_IN_HANDSET_DMIC_NS] = "dmic-endfire", |
| 220 | [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = "dmic-endfire", |
| 221 | [SND_DEVICE_IN_HANDSET_DMIC_STEREO] = "dmic-endfire", |
| 222 | |
| 223 | [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic", |
| 224 | [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "speaker-mic", |
| 225 | [SND_DEVICE_IN_SPEAKER_MIC_NS] = "speaker-mic", |
| 226 | [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = "speaker-mic", |
| 227 | [SND_DEVICE_IN_SPEAKER_DMIC] = "speaker-dmic-endfire", |
| 228 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = "speaker-dmic-endfire", |
| 229 | [SND_DEVICE_IN_SPEAKER_DMIC_NS] = "speaker-dmic-endfire", |
| 230 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = "speaker-dmic-endfire", |
| 231 | [SND_DEVICE_IN_SPEAKER_DMIC_STEREO] = "speaker-dmic-endfire", |
| 232 | |
| 233 | [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic", |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 234 | [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic", |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 235 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 236 | [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", |
| 237 | [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic", |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 238 | [SND_DEVICE_IN_BT_SCO_MIC_NREC] = "bt-sco-mic", |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 239 | [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb", |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 240 | [SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = "bt-sco-mic-wb", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 241 | [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic", |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 242 | |
| 243 | [SND_DEVICE_IN_VOICE_DMIC] = "voice-dmic-ef", |
| 244 | [SND_DEVICE_IN_VOICE_DMIC_TMUS] = "voice-dmic-ef-tmus", |
| 245 | [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", |
| 246 | [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef", |
Uday Kishore Pasupuleti | 7629719 | 2015-09-18 08:39:43 -0700 | [diff] [blame] | 247 | [SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP] = "voice-speaker-mic-hfp", |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 248 | [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 249 | [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic", |
| 250 | [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic", |
| 251 | [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic", |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 252 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 253 | [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic", |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 254 | [SND_DEVICE_IN_VOICE_REC_MIC_NS] = "voice-rec-mic", |
| 255 | [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = "voice-rec-dmic-ef", |
| 256 | [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = "voice-rec-dmic-ef-fluence", |
Jean-Michel Trivi | 8c83fe8 | 2015-09-25 15:06:53 -0700 | [diff] [blame] | 257 | [SND_DEVICE_IN_VOICE_REC_HEADSET_MIC] = "headset-mic", |
Ravi Kumar Alamanda | 99c752d | 2014-08-20 17:55:26 -0700 | [diff] [blame] | 258 | |
rago | 90fb961 | 2015-12-02 11:37:53 -0800 | [diff] [blame] | 259 | [SND_DEVICE_IN_UNPROCESSED_MIC] = "voice-rec-mic", |
| 260 | [SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC] = "headset-mic", |
| 261 | |
Ravi Kumar Alamanda | 99c752d | 2014-08-20 17:55:26 -0700 | [diff] [blame] | 262 | [SND_DEVICE_IN_VOICE_RX] = "voice-rx", |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 263 | |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 264 | [SND_DEVICE_IN_THREE_MIC] = "three-mic", |
| 265 | [SND_DEVICE_IN_QUAD_MIC] = "quad-mic", |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 266 | [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = "vi-feedback", |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 267 | [SND_DEVICE_IN_HANDSET_TMIC] = "three-mic", |
| 268 | [SND_DEVICE_IN_HANDSET_QMIC] = "quad-mic", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 269 | }; |
| 270 | |
| 271 | /* ACDB IDs (audio DSP path configuration IDs) for each sound device */ |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 272 | static int acdb_device_table[SND_DEVICE_MAX] = { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 273 | [SND_DEVICE_NONE] = -1, |
| 274 | [SND_DEVICE_OUT_HANDSET] = 7, |
| 275 | [SND_DEVICE_OUT_SPEAKER] = 15, |
| 276 | [SND_DEVICE_OUT_SPEAKER_REVERSE] = 15, |
Eric Laurent | 1b0d8ce | 2014-09-11 09:59:28 -0700 | [diff] [blame] | 277 | [SND_DEVICE_OUT_SPEAKER_SAFE] = 15, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 278 | [SND_DEVICE_OUT_HEADPHONES] = 10, |
Eric Laurent | 744996b | 2014-10-01 11:40:40 -0500 | [diff] [blame] | 279 | [SND_DEVICE_OUT_LINE] = 77, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 280 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10, |
Ravi Kumar Alamanda | 3b86d47 | 2015-06-08 00:35:57 -0700 | [diff] [blame] | 281 | [SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES] = 10, |
Eric Laurent | 744996b | 2014-10-01 11:40:40 -0500 | [diff] [blame] | 282 | [SND_DEVICE_OUT_SPEAKER_AND_LINE] = 77, |
Ravi Kumar Alamanda | 3b86d47 | 2015-06-08 00:35:57 -0700 | [diff] [blame] | 283 | [SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE] = 77, |
Ravi Kumar Alamanda | 235c348 | 2014-08-21 17:32:44 -0700 | [diff] [blame] | 284 | [SND_DEVICE_OUT_VOICE_HANDSET] = ACDB_ID_VOICE_HANDSET, |
| 285 | [SND_DEVICE_OUT_VOICE_SPEAKER] = ACDB_ID_VOICE_SPEAKER, |
Eric Laurent | 9d0d3f1 | 2014-07-25 12:40:29 -0500 | [diff] [blame] | 286 | [SND_DEVICE_OUT_VOICE_HAC_HANDSET] = 53, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 287 | [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10, |
Eric Laurent | 744996b | 2014-10-01 11:40:40 -0500 | [diff] [blame] | 288 | [SND_DEVICE_OUT_VOICE_LINE] = 77, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 289 | [SND_DEVICE_OUT_HDMI] = 18, |
| 290 | [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 15, |
| 291 | [SND_DEVICE_OUT_BT_SCO] = 22, |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 292 | [SND_DEVICE_OUT_BT_SCO_WB] = 39, |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 293 | [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = ACDB_ID_VOICE_HANDSET_TMUS, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 294 | [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17, |
| 295 | [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17, |
| 296 | [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37, |
Ravi Kumar Alamanda | 99c752d | 2014-08-20 17:55:26 -0700 | [diff] [blame] | 297 | [SND_DEVICE_OUT_VOICE_TX] = 45, |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 298 | [SND_DEVICE_OUT_SPEAKER_PROTECTED] = 124, |
| 299 | [SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED] = 101, |
Uday Kishore Pasupuleti | e9ef478 | 2015-09-21 08:33:55 -0700 | [diff] [blame] | 300 | [SND_DEVICE_OUT_VOICE_SPEAKER_HFP] = ACDB_ID_VOICE_SPEAKER, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 301 | |
| 302 | [SND_DEVICE_IN_HANDSET_MIC] = 4, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 303 | [SND_DEVICE_IN_HANDSET_MIC_AEC] = 106, |
| 304 | [SND_DEVICE_IN_HANDSET_MIC_NS] = 107, |
| 305 | [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = 108, |
| 306 | [SND_DEVICE_IN_HANDSET_DMIC] = 41, |
| 307 | [SND_DEVICE_IN_HANDSET_DMIC_AEC] = 109, |
| 308 | [SND_DEVICE_IN_HANDSET_DMIC_NS] = 110, |
| 309 | [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = 111, |
| 310 | [SND_DEVICE_IN_HANDSET_DMIC_STEREO] = 34, |
| 311 | |
| 312 | [SND_DEVICE_IN_SPEAKER_MIC] = 11, |
| 313 | [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 112, |
| 314 | [SND_DEVICE_IN_SPEAKER_MIC_NS] = 113, |
| 315 | [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = 114, |
| 316 | [SND_DEVICE_IN_SPEAKER_DMIC] = 43, |
| 317 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = 115, |
| 318 | [SND_DEVICE_IN_SPEAKER_DMIC_NS] = 116, |
| 319 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = 117, |
| 320 | [SND_DEVICE_IN_SPEAKER_DMIC_STEREO] = 35, |
| 321 | |
rago | 90fb961 | 2015-12-02 11:37:53 -0800 | [diff] [blame] | 322 | [SND_DEVICE_IN_HEADSET_MIC] = ACDB_ID_HEADSET_MIC_AEC, |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 323 | [SND_DEVICE_IN_HEADSET_MIC_AEC] = ACDB_ID_HEADSET_MIC_AEC, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 324 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 325 | [SND_DEVICE_IN_HDMI_MIC] = 4, |
| 326 | [SND_DEVICE_IN_BT_SCO_MIC] = 21, |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 327 | [SND_DEVICE_IN_BT_SCO_MIC_NREC] = 21, |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 328 | [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38, |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 329 | [SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = 38, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 330 | [SND_DEVICE_IN_CAMCORDER_MIC] = 61, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 331 | |
| 332 | [SND_DEVICE_IN_VOICE_DMIC] = 41, |
| 333 | [SND_DEVICE_IN_VOICE_DMIC_TMUS] = ACDB_ID_VOICE_DMIC_EF_TMUS, |
| 334 | [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11, |
Uday Kishore Pasupuleti | e9ef478 | 2015-09-21 08:33:55 -0700 | [diff] [blame] | 335 | [SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP] = 11, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 336 | [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 43, |
rago | 90fb961 | 2015-12-02 11:37:53 -0800 | [diff] [blame] | 337 | [SND_DEVICE_IN_VOICE_HEADSET_MIC] = ACDB_ID_HEADSET_MIC_AEC, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 338 | [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16, |
| 339 | [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36, |
| 340 | [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 341 | |
rago | 90fb961 | 2015-12-02 11:37:53 -0800 | [diff] [blame] | 342 | [SND_DEVICE_IN_VOICE_REC_MIC] = ACDB_ID_VOICE_REC_MIC, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 343 | [SND_DEVICE_IN_VOICE_REC_MIC_NS] = 113, |
| 344 | [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = 35, |
| 345 | [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = 43, |
rago | 90fb961 | 2015-12-02 11:37:53 -0800 | [diff] [blame] | 346 | [SND_DEVICE_IN_VOICE_REC_HEADSET_MIC] = ACDB_ID_HEADSET_MIC_AEC, |
| 347 | |
| 348 | [SND_DEVICE_IN_UNPROCESSED_MIC] = ACDB_ID_VOICE_REC_MIC, |
| 349 | [SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC] = ACDB_ID_HEADSET_MIC_AEC, |
Ravi Kumar Alamanda | 99c752d | 2014-08-20 17:55:26 -0700 | [diff] [blame] | 350 | |
| 351 | [SND_DEVICE_IN_VOICE_RX] = 44, |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 352 | |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 353 | [SND_DEVICE_IN_THREE_MIC] = 46, |
| 354 | [SND_DEVICE_IN_QUAD_MIC] = 46, |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 355 | [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = 102, |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 356 | [SND_DEVICE_IN_HANDSET_TMIC] = 125, |
| 357 | [SND_DEVICE_IN_HANDSET_QMIC] = 125, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 358 | }; |
| 359 | |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 360 | struct name_to_index { |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 361 | char name[100]; |
| 362 | unsigned int index; |
| 363 | }; |
| 364 | |
| 365 | #define TO_NAME_INDEX(X) #X, X |
| 366 | |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 367 | /* Used to get index from parsed string */ |
| 368 | static const struct name_to_index snd_device_name_index[SND_DEVICE_MAX] = { |
| 369 | /* out */ |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 370 | {TO_NAME_INDEX(SND_DEVICE_OUT_HANDSET)}, |
| 371 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)}, |
| 372 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_REVERSE)}, |
Eric Laurent | 1b0d8ce | 2014-09-11 09:59:28 -0700 | [diff] [blame] | 373 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_SAFE)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 374 | {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES)}, |
Eric Laurent | 09f2e0e | 2014-07-29 16:02:32 -0500 | [diff] [blame] | 375 | {TO_NAME_INDEX(SND_DEVICE_OUT_LINE)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 376 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES)}, |
Ravi Kumar Alamanda | 3b86d47 | 2015-06-08 00:35:57 -0700 | [diff] [blame] | 377 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES)}, |
Eric Laurent | 744996b | 2014-10-01 11:40:40 -0500 | [diff] [blame] | 378 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_LINE)}, |
Ravi Kumar Alamanda | 3b86d47 | 2015-06-08 00:35:57 -0700 | [diff] [blame] | 379 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 380 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET)}, |
| 381 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER)}, |
Uday Kishore Pasupuleti | e9ef478 | 2015-09-21 08:33:55 -0700 | [diff] [blame] | 382 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_HFP)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 383 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HEADPHONES)}, |
Eric Laurent | 09f2e0e | 2014-07-29 16:02:32 -0500 | [diff] [blame] | 384 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_LINE)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 385 | {TO_NAME_INDEX(SND_DEVICE_OUT_HDMI)}, |
| 386 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HDMI)}, |
| 387 | {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO)}, |
| 388 | {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO_WB)}, |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 389 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET_TMUS)}, |
Eric Laurent | 9d0d3f1 | 2014-07-25 12:40:29 -0500 | [diff] [blame] | 390 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HAC_HANDSET)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 391 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES)}, |
| 392 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES)}, |
| 393 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET)}, |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 394 | |
| 395 | /* in */ |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 396 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_PROTECTED)}, |
| 397 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 398 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC)}, |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 399 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC)}, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 400 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_NS)}, |
| 401 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC_NS)}, |
| 402 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC)}, |
| 403 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC)}, |
| 404 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_NS)}, |
| 405 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC_NS)}, |
| 406 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_STEREO)}, |
| 407 | |
| 408 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC)}, |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 409 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC)}, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 410 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_NS)}, |
| 411 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC_NS)}, |
| 412 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC)}, |
| 413 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC)}, |
| 414 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_NS)}, |
| 415 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS)}, |
| 416 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_STEREO)}, |
| 417 | |
| 418 | {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC)}, |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 419 | {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC_AEC)}, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 420 | |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 421 | {TO_NAME_INDEX(SND_DEVICE_IN_HDMI_MIC)}, |
| 422 | {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC)}, |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 423 | {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_NREC)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 424 | {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB)}, |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 425 | {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB_NREC)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 426 | {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_MIC)}, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 427 | |
| 428 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC)}, |
| 429 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC_TMUS)}, |
| 430 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_MIC)}, |
Uday Kishore Pasupuleti | e9ef478 | 2015-09-21 08:33:55 -0700 | [diff] [blame] | 431 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP)}, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 432 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_DMIC)}, |
| 433 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_HEADSET_MIC)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 434 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC)}, |
| 435 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC)}, |
| 436 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC)}, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 437 | |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 438 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC)}, |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 439 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC_NS)}, |
| 440 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_STEREO)}, |
| 441 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE)}, |
Jean-Michel Trivi | 8c83fe8 | 2015-09-25 15:06:53 -0700 | [diff] [blame] | 442 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_HEADSET_MIC)}, |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 443 | |
rago | 90fb961 | 2015-12-02 11:37:53 -0800 | [diff] [blame] | 444 | {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_MIC)}, |
| 445 | {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC)}, |
| 446 | |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 447 | {TO_NAME_INDEX(SND_DEVICE_IN_THREE_MIC)}, |
| 448 | {TO_NAME_INDEX(SND_DEVICE_IN_QUAD_MIC)}, |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 449 | {TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)}, |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 450 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_TMIC)}, |
| 451 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_QMIC)}, |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 452 | }; |
| 453 | |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 454 | static char * backend_tag_table[SND_DEVICE_MAX] = {0}; |
| 455 | static char * hw_interface_table[SND_DEVICE_MAX] = {0}; |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 456 | |
| 457 | static const struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { |
| 458 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_DEEP_BUFFER)}, |
| 459 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_LOW_LATENCY)}, |
| 460 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MULTI_CH)}, |
| 461 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD)}, |
Ravi Kumar Alamanda | 2bc7b02 | 2015-06-25 20:08:01 -0700 | [diff] [blame] | 462 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_TTS)}, |
| 463 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_ULL)}, |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 464 | {TO_NAME_INDEX(USECASE_AUDIO_RECORD)}, |
| 465 | {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)}, |
| 466 | {TO_NAME_INDEX(USECASE_VOICE_CALL)}, |
| 467 | {TO_NAME_INDEX(USECASE_VOICE2_CALL)}, |
| 468 | {TO_NAME_INDEX(USECASE_VOLTE_CALL)}, |
| 469 | {TO_NAME_INDEX(USECASE_QCHAT_CALL)}, |
| 470 | {TO_NAME_INDEX(USECASE_VOWLAN_CALL)}, |
| 471 | {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK)}, |
| 472 | {TO_NAME_INDEX(USECASE_INCALL_REC_DOWNLINK)}, |
| 473 | {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK_AND_DOWNLINK)}, |
| 474 | {TO_NAME_INDEX(USECASE_AUDIO_HFP_SCO)}, |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 475 | }; |
| 476 | |
Haynes Mathew George | 7ff216f | 2013-09-11 19:51:41 -0700 | [diff] [blame] | 477 | #define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) |
| 478 | #define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) |
| 479 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 480 | static pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT; |
| 481 | static bool is_tmus = false; |
| 482 | |
| 483 | static void check_operator() |
| 484 | { |
| 485 | char value[PROPERTY_VALUE_MAX]; |
| 486 | int mccmnc; |
| 487 | property_get("gsm.sim.operator.numeric",value,"0"); |
| 488 | mccmnc = atoi(value); |
| 489 | ALOGD("%s: tmus mccmnc %d", __func__, mccmnc); |
| 490 | switch(mccmnc) { |
| 491 | /* TMUS MCC(310), MNC(490, 260, 026) */ |
| 492 | case 310490: |
| 493 | case 310260: |
| 494 | case 310026: |
sangwon.jeon | b891db5 | 2013-09-14 17:39:15 +0900 | [diff] [blame] | 495 | /* Add new TMUS MNC(800, 660, 580, 310, 270, 250, 240, 230, 220, 210, 200, 160) */ |
| 496 | case 310800: |
| 497 | case 310660: |
| 498 | case 310580: |
| 499 | case 310310: |
| 500 | case 310270: |
| 501 | case 310250: |
| 502 | case 310240: |
| 503 | case 310230: |
| 504 | case 310220: |
| 505 | case 310210: |
| 506 | case 310200: |
| 507 | case 310160: |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 508 | is_tmus = true; |
| 509 | break; |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | bool is_operator_tmus() |
| 514 | { |
| 515 | pthread_once(&check_op_once_ctl, check_operator); |
| 516 | return is_tmus; |
| 517 | } |
| 518 | |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 519 | static char *get_current_operator() |
| 520 | { |
| 521 | struct listnode *node; |
| 522 | struct operator_info *info_item; |
| 523 | char mccmnc[PROPERTY_VALUE_MAX]; |
| 524 | char *ret = NULL; |
| 525 | |
| 526 | property_get("gsm.sim.operator.numeric",mccmnc,"0"); |
| 527 | |
| 528 | list_for_each(node, &operator_info_list) { |
| 529 | info_item = node_to_item(node, struct operator_info, list); |
| 530 | if (strstr(info_item->mccmnc, mccmnc) != NULL) { |
| 531 | ret = info_item->name; |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | return ret; |
| 536 | } |
| 537 | |
| 538 | static struct operator_specific_device *get_operator_specific_device(snd_device_t snd_device) |
| 539 | { |
| 540 | struct listnode *node; |
| 541 | struct operator_specific_device *ret = NULL; |
| 542 | struct operator_specific_device *device_item; |
| 543 | char *operator_name; |
| 544 | |
| 545 | operator_name = get_current_operator(); |
| 546 | if (operator_name == NULL) |
| 547 | return ret; |
| 548 | |
| 549 | list_for_each(node, operator_specific_device_table[snd_device]) { |
| 550 | device_item = node_to_item(node, struct operator_specific_device, list); |
| 551 | if (strcmp(operator_name, device_item->operator) == 0) { |
| 552 | ret = device_item; |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | return ret; |
| 557 | } |
| 558 | |
| 559 | |
| 560 | static int get_operator_specific_device_acdb_id(snd_device_t snd_device) |
| 561 | { |
| 562 | struct operator_specific_device *device; |
| 563 | int ret = acdb_device_table[snd_device]; |
| 564 | |
| 565 | device = get_operator_specific_device(snd_device); |
| 566 | if (device != NULL) |
| 567 | ret = device->acdb_id; |
| 568 | |
| 569 | return ret; |
| 570 | } |
| 571 | |
| 572 | static const char *get_operator_specific_device_mixer_path(snd_device_t snd_device) |
| 573 | { |
| 574 | struct operator_specific_device *device; |
| 575 | const char *ret = device_table[snd_device]; |
| 576 | |
| 577 | device = get_operator_specific_device(snd_device); |
| 578 | if (device != NULL) |
| 579 | ret = device->mixer_path; |
| 580 | |
| 581 | return ret; |
| 582 | } |
| 583 | |
vivek mehta | 1a9b7c0 | 2015-06-25 11:49:38 -0700 | [diff] [blame] | 584 | bool platform_send_gain_dep_cal(void *platform, int level) |
| 585 | { |
| 586 | bool ret_val = false; |
| 587 | struct platform_data *my_data = (struct platform_data *)platform; |
| 588 | struct audio_device *adev = my_data->adev; |
| 589 | int acdb_dev_id, app_type; |
| 590 | int acdb_dev_type = MSM_SNDDEV_CAP_RX; |
| 591 | int mode = CAL_MODE_RTAC; |
| 592 | struct listnode *node; |
| 593 | struct audio_usecase *usecase; |
vivek mehta | 1a9b7c0 | 2015-06-25 11:49:38 -0700 | [diff] [blame] | 594 | |
| 595 | if (my_data->acdb_send_gain_dep_cal == NULL) { |
| 596 | ALOGE("%s: dlsym error for acdb_send_gain_dep_cal", __func__); |
| 597 | return ret_val; |
| 598 | } |
| 599 | |
| 600 | if (!voice_is_in_call(adev)) { |
| 601 | ALOGV("%s: Not Voice call usecase, apply new cal for level %d", |
| 602 | __func__, level); |
| 603 | app_type = DEFAULT_APP_TYPE_RX_PATH; |
| 604 | |
| 605 | // find the current active sound device |
| 606 | list_for_each(node, &adev->usecase_list) { |
| 607 | usecase = node_to_item(node, struct audio_usecase, list); |
| 608 | |
| 609 | if (usecase != NULL && |
| 610 | usecase->type == PCM_PLAYBACK && |
| 611 | (usecase->stream.out->devices == AUDIO_DEVICE_OUT_SPEAKER)) { |
| 612 | |
| 613 | ALOGV("%s: out device is %d", __func__, usecase->out_snd_device); |
vivek mehta | 4cb8298 | 2015-07-13 12:05:49 -0700 | [diff] [blame] | 614 | if (audio_extn_spkr_prot_is_enabled()) { |
| 615 | acdb_dev_id = audio_extn_spkr_prot_get_acdb_id(usecase->out_snd_device); |
| 616 | } else { |
| 617 | acdb_dev_id = acdb_device_table[usecase->out_snd_device]; |
| 618 | } |
| 619 | |
vivek mehta | 1a9b7c0 | 2015-06-25 11:49:38 -0700 | [diff] [blame] | 620 | if (!my_data->acdb_send_gain_dep_cal(acdb_dev_id, app_type, |
| 621 | acdb_dev_type, mode, level)) { |
| 622 | // set ret_val true if at least one calibration is set successfully |
| 623 | ret_val = true; |
| 624 | } else { |
| 625 | ALOGE("%s: my_data->acdb_send_gain_dep_cal failed ", __func__); |
| 626 | } |
| 627 | } else { |
| 628 | ALOGW("%s: Usecase list is empty", __func__); |
| 629 | } |
| 630 | } |
| 631 | } else { |
| 632 | ALOGW("%s: Voice call in progress .. ignore setting new cal", |
| 633 | __func__); |
| 634 | } |
| 635 | return ret_val; |
| 636 | } |
| 637 | |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 638 | void platform_set_echo_reference(struct audio_device *adev, bool enable, audio_devices_t out_device) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 639 | { |
Ravi Kumar Alamanda | f282901 | 2014-11-12 16:16:10 -0800 | [diff] [blame] | 640 | struct platform_data *my_data = (struct platform_data *)adev->platform; |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 641 | snd_device_t snd_device = SND_DEVICE_NONE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 642 | |
Ravi Kumar Alamanda | f282901 | 2014-11-12 16:16:10 -0800 | [diff] [blame] | 643 | if (strcmp(my_data->ec_ref_mixer_path, "")) { |
| 644 | ALOGV("%s: diabling %s", __func__, my_data->ec_ref_mixer_path); |
| 645 | audio_route_reset_and_update_path(adev->audio_route, my_data->ec_ref_mixer_path); |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 646 | } |
| 647 | |
Ravi Kumar Alamanda | f282901 | 2014-11-12 16:16:10 -0800 | [diff] [blame] | 648 | if (enable) { |
| 649 | strcpy(my_data->ec_ref_mixer_path, "echo-reference"); |
| 650 | if (out_device != AUDIO_DEVICE_NONE) { |
| 651 | snd_device = platform_get_output_snd_device(adev->platform, out_device); |
| 652 | platform_add_backend_name(adev->platform, my_data->ec_ref_mixer_path, snd_device); |
| 653 | } |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 654 | |
Ravi Kumar Alamanda | f282901 | 2014-11-12 16:16:10 -0800 | [diff] [blame] | 655 | ALOGD("%s: enabling %s", __func__, my_data->ec_ref_mixer_path); |
| 656 | audio_route_apply_and_update_path(adev->audio_route, my_data->ec_ref_mixer_path); |
| 657 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 658 | } |
| 659 | |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 660 | static struct csd_data *open_csd_client(bool i2s_ext_modem) |
| 661 | { |
| 662 | struct csd_data *csd = calloc(1, sizeof(struct csd_data)); |
| 663 | |
| 664 | csd->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW); |
| 665 | if (csd->csd_client == NULL) { |
| 666 | ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT); |
| 667 | goto error; |
| 668 | } else { |
| 669 | ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT); |
| 670 | |
| 671 | csd->deinit = (deinit_t)dlsym(csd->csd_client, |
| 672 | "csd_client_deinit"); |
| 673 | if (csd->deinit == NULL) { |
| 674 | ALOGE("%s: dlsym error %s for csd_client_deinit", __func__, |
| 675 | dlerror()); |
| 676 | goto error; |
| 677 | } |
| 678 | csd->disable_device = (disable_device_t)dlsym(csd->csd_client, |
| 679 | "csd_client_disable_device"); |
| 680 | if (csd->disable_device == NULL) { |
| 681 | ALOGE("%s: dlsym error %s for csd_client_disable_device", |
| 682 | __func__, dlerror()); |
| 683 | goto error; |
| 684 | } |
| 685 | csd->enable_device_config = (enable_device_config_t)dlsym(csd->csd_client, |
| 686 | "csd_client_enable_device_config"); |
| 687 | if (csd->enable_device_config == NULL) { |
| 688 | ALOGE("%s: dlsym error %s for csd_client_enable_device_config", |
| 689 | __func__, dlerror()); |
| 690 | goto error; |
| 691 | } |
| 692 | csd->enable_device = (enable_device_t)dlsym(csd->csd_client, |
| 693 | "csd_client_enable_device"); |
| 694 | if (csd->enable_device == NULL) { |
| 695 | ALOGE("%s: dlsym error %s for csd_client_enable_device", |
| 696 | __func__, dlerror()); |
| 697 | goto error; |
| 698 | } |
| 699 | csd->start_voice = (start_voice_t)dlsym(csd->csd_client, |
| 700 | "csd_client_start_voice"); |
| 701 | if (csd->start_voice == NULL) { |
| 702 | ALOGE("%s: dlsym error %s for csd_client_start_voice", |
| 703 | __func__, dlerror()); |
| 704 | goto error; |
| 705 | } |
| 706 | csd->stop_voice = (stop_voice_t)dlsym(csd->csd_client, |
| 707 | "csd_client_stop_voice"); |
| 708 | if (csd->stop_voice == NULL) { |
| 709 | ALOGE("%s: dlsym error %s for csd_client_stop_voice", |
| 710 | __func__, dlerror()); |
| 711 | goto error; |
| 712 | } |
| 713 | csd->volume = (volume_t)dlsym(csd->csd_client, |
| 714 | "csd_client_volume"); |
| 715 | if (csd->volume == NULL) { |
| 716 | ALOGE("%s: dlsym error %s for csd_client_volume", |
| 717 | __func__, dlerror()); |
| 718 | goto error; |
| 719 | } |
| 720 | csd->mic_mute = (mic_mute_t)dlsym(csd->csd_client, |
| 721 | "csd_client_mic_mute"); |
| 722 | if (csd->mic_mute == NULL) { |
| 723 | ALOGE("%s: dlsym error %s for csd_client_mic_mute", |
| 724 | __func__, dlerror()); |
| 725 | goto error; |
| 726 | } |
| 727 | csd->slow_talk = (slow_talk_t)dlsym(csd->csd_client, |
| 728 | "csd_client_slow_talk"); |
| 729 | if (csd->slow_talk == NULL) { |
| 730 | ALOGE("%s: dlsym error %s for csd_client_slow_talk", |
| 731 | __func__, dlerror()); |
| 732 | goto error; |
| 733 | } |
| 734 | csd->start_playback = (start_playback_t)dlsym(csd->csd_client, |
| 735 | "csd_client_start_playback"); |
| 736 | if (csd->start_playback == NULL) { |
| 737 | ALOGE("%s: dlsym error %s for csd_client_start_playback", |
| 738 | __func__, dlerror()); |
| 739 | goto error; |
| 740 | } |
| 741 | csd->stop_playback = (stop_playback_t)dlsym(csd->csd_client, |
| 742 | "csd_client_stop_playback"); |
| 743 | if (csd->stop_playback == NULL) { |
| 744 | ALOGE("%s: dlsym error %s for csd_client_stop_playback", |
| 745 | __func__, dlerror()); |
| 746 | goto error; |
| 747 | } |
| 748 | csd->start_record = (start_record_t)dlsym(csd->csd_client, |
| 749 | "csd_client_start_record"); |
| 750 | if (csd->start_record == NULL) { |
| 751 | ALOGE("%s: dlsym error %s for csd_client_start_record", |
| 752 | __func__, dlerror()); |
| 753 | goto error; |
| 754 | } |
| 755 | csd->stop_record = (stop_record_t)dlsym(csd->csd_client, |
| 756 | "csd_client_stop_record"); |
| 757 | if (csd->stop_record == NULL) { |
| 758 | ALOGE("%s: dlsym error %s for csd_client_stop_record", |
| 759 | __func__, dlerror()); |
| 760 | goto error; |
| 761 | } |
| 762 | |
| 763 | csd->get_sample_rate = (get_sample_rate_t)dlsym(csd->csd_client, |
| 764 | "csd_client_get_sample_rate"); |
| 765 | if (csd->get_sample_rate == NULL) { |
| 766 | ALOGE("%s: dlsym error %s for csd_client_get_sample_rate", |
| 767 | __func__, dlerror()); |
| 768 | |
| 769 | goto error; |
| 770 | } |
| 771 | |
| 772 | csd->init = (init_t)dlsym(csd->csd_client, "csd_client_init"); |
| 773 | |
| 774 | if (csd->init == NULL) { |
| 775 | ALOGE("%s: dlsym error %s for csd_client_init", |
| 776 | __func__, dlerror()); |
| 777 | goto error; |
| 778 | } else { |
| 779 | csd->init(i2s_ext_modem); |
| 780 | } |
| 781 | } |
| 782 | return csd; |
| 783 | |
| 784 | error: |
| 785 | free(csd); |
| 786 | csd = NULL; |
| 787 | return csd; |
| 788 | } |
| 789 | |
| 790 | void close_csd_client(struct csd_data *csd) |
| 791 | { |
| 792 | if (csd != NULL) { |
| 793 | csd->deinit(); |
| 794 | dlclose(csd->csd_client); |
| 795 | free(csd); |
| 796 | csd = NULL; |
| 797 | } |
| 798 | } |
| 799 | |
| 800 | static void platform_csd_init(struct platform_data *my_data) |
| 801 | { |
| 802 | #ifdef PLATFORM_MSM8084 |
Iliyan Malchev | ae9a10c | 2014-08-09 13:07:21 -0700 | [diff] [blame] | 803 | int32_t modems, (*count_modems)(void); |
| 804 | const char *name = "libdetectmodem.so"; |
| 805 | const char *func = "count_modems"; |
| 806 | const char *error; |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 807 | |
Iliyan Malchev | ae9a10c | 2014-08-09 13:07:21 -0700 | [diff] [blame] | 808 | my_data->csd = NULL; |
| 809 | |
| 810 | void *lib = dlopen(name, RTLD_NOW); |
| 811 | error = dlerror(); |
| 812 | if (!lib) { |
| 813 | ALOGE("%s: could not find %s: %s", __func__, name, error); |
| 814 | return; |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 815 | } |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 816 | |
Iliyan Malchev | ae9a10c | 2014-08-09 13:07:21 -0700 | [diff] [blame] | 817 | count_modems = NULL; |
| 818 | *(void **)(&count_modems) = dlsym(lib, func); |
| 819 | error = dlerror(); |
| 820 | if (!count_modems) { |
| 821 | ALOGE("%s: could not find symbol %s in %s: %s", |
| 822 | __func__, func, name, error); |
| 823 | goto done; |
| 824 | } |
| 825 | |
| 826 | modems = count_modems(); |
| 827 | if (modems < 0) { |
| 828 | ALOGE("%s: count_modems failed\n", __func__); |
| 829 | goto done; |
| 830 | } |
| 831 | |
| 832 | ALOGD("%s: num_modems %d\n", __func__, modems); |
| 833 | if (modems > 0) |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 834 | my_data->csd = open_csd_client(false /*is_i2s_ext_modem*/); |
Iliyan Malchev | ae9a10c | 2014-08-09 13:07:21 -0700 | [diff] [blame] | 835 | |
| 836 | done: |
| 837 | dlclose(lib); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 838 | #else |
| 839 | my_data->csd = NULL; |
| 840 | #endif |
| 841 | } |
| 842 | |
Eric Laurent | c633338 | 2015-09-14 12:43:44 -0700 | [diff] [blame] | 843 | static void set_platform_defaults(struct platform_data * my_data) |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 844 | { |
| 845 | int32_t dev; |
| 846 | for (dev = 0; dev < SND_DEVICE_MAX; dev++) { |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 847 | backend_tag_table[dev] = NULL; |
| 848 | hw_interface_table[dev] = NULL; |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 849 | operator_specific_device_table[dev] = NULL; |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 850 | } |
| 851 | |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 852 | // To overwrite these go to the audio_platform_info.xml file. |
| 853 | backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC] = strdup("bt-sco"); |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 854 | backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_NREC] = strdup("bt-sco"); |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 855 | backend_tag_table[SND_DEVICE_OUT_BT_SCO] = strdup("bt-sco"); |
| 856 | backend_tag_table[SND_DEVICE_OUT_HDMI] = strdup("hdmi"); |
| 857 | backend_tag_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("speaker-and-hdmi"); |
| 858 | backend_tag_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("bt-sco-wb"); |
| 859 | backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_WB] = strdup("bt-sco-wb"); |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 860 | backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = strdup("bt-sco-wb"); |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 861 | backend_tag_table[SND_DEVICE_OUT_VOICE_TX] = strdup("afe-proxy"); |
| 862 | backend_tag_table[SND_DEVICE_IN_VOICE_RX] = strdup("afe-proxy"); |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 863 | |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 864 | hw_interface_table[SND_DEVICE_OUT_HANDSET] = strdup("SLIMBUS_0_RX"); |
| 865 | hw_interface_table[SND_DEVICE_OUT_SPEAKER] = strdup("SLIMBUS_0_RX"); |
| 866 | hw_interface_table[SND_DEVICE_OUT_SPEAKER_REVERSE] = strdup("SLIMBUS_0_RX"); |
| 867 | hw_interface_table[SND_DEVICE_OUT_SPEAKER_SAFE] = strdup("SLIMBUS_0_RX"); |
| 868 | hw_interface_table[SND_DEVICE_OUT_HEADPHONES] = strdup("SLIMBUS_0_RX"); |
| 869 | hw_interface_table[SND_DEVICE_OUT_LINE] = strdup("SLIMBUS_0_RX"); |
| 870 | hw_interface_table[SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = strdup("SLIMBUS_0_RX"); |
Ravi Kumar Alamanda | 3b86d47 | 2015-06-08 00:35:57 -0700 | [diff] [blame] | 871 | hw_interface_table[SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES] = strdup("SLIMBUS_0_RX"); |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 872 | hw_interface_table[SND_DEVICE_OUT_SPEAKER_AND_LINE] = strdup("SLIMBUS_0_RX"); |
Ravi Kumar Alamanda | 3b86d47 | 2015-06-08 00:35:57 -0700 | [diff] [blame] | 873 | hw_interface_table[SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE] = strdup("SLIMBUS_0_RX"); |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 874 | hw_interface_table[SND_DEVICE_OUT_VOICE_HANDSET] = strdup("SLIMBUS_0_RX"); |
| 875 | hw_interface_table[SND_DEVICE_OUT_VOICE_HAC_HANDSET] = strdup("SLIMBUS_0_RX"); |
| 876 | hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER] = strdup("SLIMBUS_0_RX"); |
| 877 | hw_interface_table[SND_DEVICE_OUT_VOICE_HEADPHONES] = strdup("SLIMBUS_0_RX"); |
| 878 | hw_interface_table[SND_DEVICE_OUT_VOICE_LINE] = strdup("SLIMBUS_0_RX"); |
| 879 | hw_interface_table[SND_DEVICE_OUT_HDMI] = strdup("HDMI_RX"); |
| 880 | hw_interface_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("SLIMBUS_0_RX-and-HDMI_RX"); |
| 881 | hw_interface_table[SND_DEVICE_OUT_BT_SCO] = strdup("SEC_AUX_PCM_RX"); |
| 882 | hw_interface_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("SEC_AUX_PCM_RX"); |
| 883 | hw_interface_table[SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = strdup("SLIMBUS_0_RX"); |
| 884 | hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = strdup("SLIMBUS_0_RX"); |
| 885 | hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = strdup("SLIMBUS_0_RX"); |
| 886 | hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = strdup("SLIMBUS_0_RX"); |
| 887 | hw_interface_table[SND_DEVICE_OUT_VOICE_TX] = strdup("AFE_PCM_RX"); |
| 888 | hw_interface_table[SND_DEVICE_OUT_SPEAKER_PROTECTED] = strdup("SLIMBUS_0_RX"); |
| 889 | hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED] = strdup("SLIMBUS_0_RX"); |
Eric Laurent | c633338 | 2015-09-14 12:43:44 -0700 | [diff] [blame] | 890 | |
| 891 | my_data->max_mic_count = PLATFORM_DEFAULT_MIC_COUNT; |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 892 | } |
| 893 | |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 894 | void get_cvd_version(char *cvd_version, struct audio_device *adev) |
| 895 | { |
| 896 | struct mixer_ctl *ctl; |
| 897 | int count; |
| 898 | int ret = 0; |
| 899 | |
| 900 | ctl = mixer_get_ctl_by_name(adev->mixer, CVD_VERSION_MIXER_CTL); |
| 901 | if (!ctl) { |
| 902 | ALOGE("%s: Could not get ctl for mixer cmd - %s", __func__, CVD_VERSION_MIXER_CTL); |
| 903 | goto done; |
| 904 | } |
| 905 | mixer_ctl_update(ctl); |
| 906 | |
| 907 | count = mixer_ctl_get_num_values(ctl); |
| 908 | if (count > MAX_CVD_VERSION_STRING_SIZE) |
| 909 | count = MAX_CVD_VERSION_STRING_SIZE - 1; |
| 910 | |
| 911 | ret = mixer_ctl_get_array(ctl, cvd_version, count); |
| 912 | if (ret != 0) { |
| 913 | ALOGE("%s: ERROR! mixer_ctl_get_array() failed to get CVD Version", __func__); |
| 914 | goto done; |
| 915 | } |
| 916 | |
| 917 | done: |
| 918 | return; |
| 919 | } |
| 920 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 921 | void *platform_init(struct audio_device *adev) |
| 922 | { |
| 923 | char value[PROPERTY_VALUE_MAX]; |
| 924 | struct platform_data *my_data; |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 925 | int retry_num = 0, snd_card_num = 0; |
vivek mehta | 65ad12d | 2015-08-13 18:32:48 -0700 | [diff] [blame] | 926 | bool dual_mic_config = false; |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 927 | const char *snd_card_name; |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 928 | char *cvd_version = NULL; |
sangwoo | 1b9f4b3 | 2013-06-21 18:22:55 -0700 | [diff] [blame] | 929 | |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 930 | my_data = calloc(1, sizeof(struct platform_data)); |
| 931 | |
| 932 | my_data->adev = adev; |
| 933 | |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 934 | list_init(&operator_info_list); |
| 935 | |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 936 | set_platform_defaults(my_data); |
| 937 | |
| 938 | /* Initialize platform specific ids and/or backends*/ |
| 939 | platform_info_init(my_data); |
| 940 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 941 | while (snd_card_num < MAX_SND_CARD) { |
| 942 | adev->mixer = mixer_open(snd_card_num); |
sangwoo | 1b9f4b3 | 2013-06-21 18:22:55 -0700 | [diff] [blame] | 943 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 944 | while (!adev->mixer && retry_num < RETRY_NUMBER) { |
| 945 | usleep(RETRY_US); |
| 946 | adev->mixer = mixer_open(snd_card_num); |
| 947 | retry_num++; |
| 948 | } |
| 949 | |
| 950 | if (!adev->mixer) { |
| 951 | ALOGE("%s: Unable to open the mixer card: %d", __func__, |
| 952 | snd_card_num); |
| 953 | retry_num = 0; |
| 954 | snd_card_num++; |
| 955 | continue; |
| 956 | } |
| 957 | |
| 958 | snd_card_name = mixer_get_name(adev->mixer); |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 959 | |
| 960 | /* validate the sound card name */ |
| 961 | if (my_data->snd_card_name != NULL && |
| 962 | strncmp(snd_card_name, my_data->snd_card_name, MAX_SND_CARD_NAME_LEN) != 0) { |
| 963 | ALOGI("%s: found valid sound card %s, but not primary sound card %s", |
| 964 | __func__, snd_card_name, my_data->snd_card_name); |
| 965 | retry_num = 0; |
| 966 | snd_card_num++; |
| 967 | continue; |
| 968 | } |
| 969 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 970 | ALOGD("%s: snd_card_name: %s", __func__, snd_card_name); |
| 971 | |
Uday Kishore Pasupuleti | 11dd223 | 2015-06-24 14:18:01 -0700 | [diff] [blame] | 972 | if (!strncmp(snd_card_name, "msm8226-tomtom-snd-card", |
| 973 | sizeof("msm8226-tomtom-snd-card"))) { |
| 974 | ALOGD("%s: Call MIXER_XML_PATH_WCD9330", __func__); |
| 975 | adev->audio_route = audio_route_init(snd_card_num, |
| 976 | MIXER_XML_PATH_WCD9330); |
| 977 | } else { |
| 978 | adev->audio_route = audio_route_init(snd_card_num, MIXER_XML_PATH); |
| 979 | } |
| 980 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 981 | if (!adev->audio_route) { |
| 982 | ALOGE("%s: Failed to init audio route controls, aborting.", __func__); |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 983 | goto init_failed; |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 984 | } |
| 985 | adev->snd_card = snd_card_num; |
| 986 | ALOGD("%s: Opened sound card:%d", __func__, snd_card_num); |
| 987 | break; |
sangwoo | 1b9f4b3 | 2013-06-21 18:22:55 -0700 | [diff] [blame] | 988 | } |
| 989 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 990 | if (snd_card_num >= MAX_SND_CARD) { |
| 991 | ALOGE("%s: Unable to find correct sound card, aborting.", __func__); |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 992 | goto init_failed; |
sangwoo | 1b9f4b3 | 2013-06-21 18:22:55 -0700 | [diff] [blame] | 993 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 994 | |
keunhui.park | c5aaa0e | 2015-07-13 10:57:37 +0900 | [diff] [blame] | 995 | //set max volume step for voice call |
| 996 | property_get("ro.config.vc_call_vol_steps", value, TOSTRING(MAX_VOL_INDEX)); |
| 997 | my_data->max_vol_index = atoi(value); |
| 998 | |
vivek mehta | 65ad12d | 2015-08-13 18:32:48 -0700 | [diff] [blame] | 999 | property_get("persist.audio.dualmic.config",value,""); |
| 1000 | if (!strcmp("endfire", value)) { |
| 1001 | dual_mic_config = true; |
| 1002 | } |
| 1003 | |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1004 | my_data->source_mic_type = SOURCE_DUAL_MIC; |
| 1005 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1006 | my_data->fluence_in_spkr_mode = false; |
| 1007 | my_data->fluence_in_voice_call = false; |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 1008 | my_data->fluence_in_voice_comm = false; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1009 | my_data->fluence_in_voice_rec = false; |
| 1010 | |
vivek mehta | 65ad12d | 2015-08-13 18:32:48 -0700 | [diff] [blame] | 1011 | property_get("ro.qc.sdk.audio.fluencetype", value, "none"); |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1012 | if (!strcmp("fluencepro", value)) { |
| 1013 | my_data->fluence_type = FLUENCE_PRO_ENABLE; |
vivek mehta | 65ad12d | 2015-08-13 18:32:48 -0700 | [diff] [blame] | 1014 | } else if (!strcmp("fluence", value) || (dual_mic_config)) { |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1015 | my_data->fluence_type = FLUENCE_ENABLE; |
| 1016 | } else if (!strcmp("none", value)) { |
| 1017 | my_data->fluence_type = FLUENCE_DISABLE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1018 | } |
| 1019 | |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1020 | if (my_data->fluence_type != FLUENCE_DISABLE) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1021 | property_get("persist.audio.fluence.voicecall",value,""); |
| 1022 | if (!strcmp("true", value)) { |
| 1023 | my_data->fluence_in_voice_call = true; |
| 1024 | } |
| 1025 | |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 1026 | property_get("persist.audio.fluence.voicecomm",value,""); |
| 1027 | if (!strcmp("true", value)) { |
| 1028 | my_data->fluence_in_voice_comm = true; |
| 1029 | } |
| 1030 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1031 | property_get("persist.audio.fluence.voicerec",value,""); |
| 1032 | if (!strcmp("true", value)) { |
| 1033 | my_data->fluence_in_voice_rec = true; |
| 1034 | } |
| 1035 | |
| 1036 | property_get("persist.audio.fluence.speaker",value,""); |
| 1037 | if (!strcmp("true", value)) { |
| 1038 | my_data->fluence_in_spkr_mode = true; |
| 1039 | } |
| 1040 | } |
| 1041 | |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1042 | // support max to mono, example if max count is 3, usecase supports Three, dual and mono mic |
| 1043 | switch (my_data->max_mic_count) { |
| 1044 | case 4: |
| 1045 | my_data->source_mic_type |= SOURCE_QUAD_MIC; |
| 1046 | case 3: |
| 1047 | my_data->source_mic_type |= SOURCE_THREE_MIC; |
| 1048 | case 2: |
| 1049 | my_data->source_mic_type |= SOURCE_DUAL_MIC; |
| 1050 | case 1: |
| 1051 | my_data->source_mic_type |= SOURCE_MONO_MIC; |
| 1052 | break; |
| 1053 | default: |
| 1054 | ALOGE("%s: max_mic_count (%d), is not supported, setting to default", |
| 1055 | __func__, my_data->max_mic_count); |
| 1056 | my_data->source_mic_type = SOURCE_MONO_MIC|SOURCE_DUAL_MIC; |
| 1057 | break; |
| 1058 | } |
| 1059 | |
| 1060 | ALOGV("%s: Fluence_Type(%d) max_mic_count(%d) mic_type(0x%x) fluence_in_voice_call(%d)" |
| 1061 | " fluence_in_voice_comm(%d) fluence_in_voice_rec(%d) fluence_in_spkr_mode(%d) ", |
| 1062 | __func__, my_data->fluence_type, my_data->max_mic_count, my_data->source_mic_type, |
| 1063 | my_data->fluence_in_voice_call, my_data->fluence_in_voice_comm, |
| 1064 | my_data->fluence_in_voice_rec, my_data->fluence_in_spkr_mode); |
| 1065 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1066 | my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); |
| 1067 | if (my_data->acdb_handle == NULL) { |
| 1068 | ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER); |
| 1069 | } else { |
| 1070 | ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER); |
| 1071 | my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle, |
| 1072 | "acdb_loader_deallocate_ACDB"); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1073 | if (!my_data->acdb_deallocate) |
| 1074 | ALOGE("%s: Could not find the symbol acdb_loader_deallocate_ACDB from %s", |
| 1075 | __func__, LIB_ACDB_LOADER); |
| 1076 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1077 | my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle, |
| 1078 | "acdb_loader_send_audio_cal"); |
| 1079 | if (!my_data->acdb_send_audio_cal) |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1080 | ALOGE("%s: Could not find the symbol acdb_send_audio_cal from %s", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1081 | __func__, LIB_ACDB_LOADER); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1082 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1083 | my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle, |
| 1084 | "acdb_loader_send_voice_cal"); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1085 | if (!my_data->acdb_send_voice_cal) |
| 1086 | ALOGE("%s: Could not find the symbol acdb_loader_send_voice_cal from %s", |
| 1087 | __func__, LIB_ACDB_LOADER); |
| 1088 | |
| 1089 | my_data->acdb_reload_vocvoltable = (acdb_reload_vocvoltable_t)dlsym(my_data->acdb_handle, |
| 1090 | "acdb_loader_reload_vocvoltable"); |
| 1091 | if (!my_data->acdb_reload_vocvoltable) |
| 1092 | ALOGE("%s: Could not find the symbol acdb_loader_reload_vocvoltable from %s", |
| 1093 | __func__, LIB_ACDB_LOADER); |
vivek mehta | 1a9b7c0 | 2015-06-25 11:49:38 -0700 | [diff] [blame] | 1094 | |
| 1095 | my_data->acdb_send_gain_dep_cal = (acdb_send_gain_dep_cal_t)dlsym(my_data->acdb_handle, |
| 1096 | "acdb_loader_send_gain_dep_cal"); |
| 1097 | if (!my_data->acdb_send_gain_dep_cal) |
| 1098 | ALOGV("%s: Could not find the symbol acdb_loader_send_gain_dep_cal from %s", |
| 1099 | __func__, LIB_ACDB_LOADER); |
| 1100 | |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 1101 | #if defined (PLATFORM_MSM8994) |
| 1102 | acdb_init_v2_cvd_t acdb_init; |
| 1103 | acdb_init = (acdb_init_v2_cvd_t)dlsym(my_data->acdb_handle, |
| 1104 | "acdb_loader_init_v2"); |
| 1105 | if (acdb_init == NULL) { |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1106 | ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror()); |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 1107 | goto acdb_init_fail; |
| 1108 | } |
| 1109 | |
| 1110 | cvd_version = calloc(1, MAX_CVD_VERSION_STRING_SIZE); |
| 1111 | get_cvd_version(cvd_version, adev); |
| 1112 | if (!cvd_version) |
| 1113 | ALOGE("failed to allocate cvd_version"); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1114 | else |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 1115 | acdb_init((char *)snd_card_name, cvd_version); |
| 1116 | free(cvd_version); |
| 1117 | #elif defined (PLATFORM_MSM8084) |
| 1118 | acdb_init_v2_t acdb_init; |
| 1119 | acdb_init = (acdb_init_v2_t)dlsym(my_data->acdb_handle, |
| 1120 | "acdb_loader_init_v2"); |
| 1121 | if (acdb_init == NULL) { |
| 1122 | ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror()); |
| 1123 | goto acdb_init_fail; |
| 1124 | } |
| 1125 | acdb_init((char *)snd_card_name); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1126 | #else |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 1127 | acdb_init_t acdb_init; |
| 1128 | acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1129 | "acdb_loader_init_ACDB"); |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 1130 | if (acdb_init == NULL) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1131 | ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror()); |
| 1132 | else |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 1133 | acdb_init(); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1134 | #endif |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1135 | } |
| 1136 | |
Ravi Kumar Alamanda | 5c049df | 2015-07-01 16:23:03 +0900 | [diff] [blame] | 1137 | acdb_init_fail: |
| 1138 | |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 1139 | audio_extn_spkr_prot_init(adev); |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1140 | |
Ravi Kumar Alamanda | 7631557 | 2015-04-23 13:13:56 -0700 | [diff] [blame] | 1141 | audio_extn_hwdep_cal_send(adev->snd_card, my_data->acdb_handle); |
| 1142 | |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1143 | /* load csd client */ |
| 1144 | platform_csd_init(my_data); |
| 1145 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1146 | return my_data; |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 1147 | |
| 1148 | init_failed: |
| 1149 | if (my_data) |
| 1150 | free(my_data); |
| 1151 | return NULL; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1152 | } |
| 1153 | |
| 1154 | void platform_deinit(void *platform) |
| 1155 | { |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 1156 | int32_t dev; |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1157 | struct operator_info *info_item; |
| 1158 | struct operator_specific_device *device_item; |
| 1159 | struct listnode *node; |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 1160 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1161 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1162 | close_csd_client(my_data->csd); |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 1163 | |
| 1164 | for (dev = 0; dev < SND_DEVICE_MAX; dev++) { |
| 1165 | if (backend_tag_table[dev]) |
| 1166 | free(backend_tag_table[dev]); |
| 1167 | if (hw_interface_table[dev]) |
| 1168 | free(hw_interface_table[dev]); |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1169 | if (operator_specific_device_table[dev]) { |
| 1170 | while (!list_empty(operator_specific_device_table[dev])) { |
| 1171 | node = list_head(operator_specific_device_table[dev]); |
| 1172 | list_remove(node); |
| 1173 | device_item = node_to_item(node, struct operator_specific_device, list); |
| 1174 | free(device_item->operator); |
| 1175 | free(device_item->mixer_path); |
| 1176 | free(device_item); |
| 1177 | } |
| 1178 | free(operator_specific_device_table[dev]); |
| 1179 | } |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 1180 | } |
| 1181 | |
| 1182 | if (my_data->snd_card_name) |
| 1183 | free(my_data->snd_card_name); |
| 1184 | |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1185 | while (!list_empty(&operator_info_list)) { |
| 1186 | node = list_head(&operator_info_list); |
| 1187 | list_remove(node); |
| 1188 | info_item = node_to_item(node, struct operator_info, list); |
| 1189 | free(info_item->name); |
| 1190 | free(info_item->mccmnc); |
| 1191 | free(info_item); |
| 1192 | } |
| 1193 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1194 | free(platform); |
| 1195 | } |
| 1196 | |
| 1197 | const char *platform_get_snd_device_name(snd_device_t snd_device) |
| 1198 | { |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1199 | if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) { |
| 1200 | if (operator_specific_device_table[snd_device] != NULL) { |
| 1201 | return get_operator_specific_device_mixer_path(snd_device); |
| 1202 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1203 | return device_table[snd_device]; |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1204 | } else |
Ravi Kumar Alamanda | 6402646 | 2014-09-15 00:08:58 -0700 | [diff] [blame] | 1205 | return "none"; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1206 | } |
| 1207 | |
Ravi Kumar Alamanda | 299760a | 2013-11-01 17:29:09 -0500 | [diff] [blame] | 1208 | void platform_add_backend_name(void *platform, char *mixer_path, |
| 1209 | snd_device_t snd_device) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1210 | { |
Ravi Kumar Alamanda | 299760a | 2013-11-01 17:29:09 -0500 | [diff] [blame] | 1211 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1212 | |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1213 | if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { |
| 1214 | ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); |
| 1215 | return; |
Ravi Kumar Alamanda | 1de6e5a | 2014-06-19 21:55:39 -0500 | [diff] [blame] | 1216 | } |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1217 | |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 1218 | const char * suffix = backend_tag_table[snd_device]; |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1219 | |
| 1220 | if (suffix != NULL) { |
| 1221 | strcat(mixer_path, " "); |
| 1222 | strcat(mixer_path, suffix); |
Ravi Kumar Alamanda | 299760a | 2013-11-01 17:29:09 -0500 | [diff] [blame] | 1223 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1224 | } |
| 1225 | |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 1226 | bool platform_check_backends_match(snd_device_t snd_device1, snd_device_t snd_device2) |
| 1227 | { |
| 1228 | bool result = true; |
| 1229 | |
| 1230 | ALOGV("%s: snd_device1 = %s, snd_device2 = %s", __func__, |
| 1231 | platform_get_snd_device_name(snd_device1), |
| 1232 | platform_get_snd_device_name(snd_device2)); |
| 1233 | |
| 1234 | if ((snd_device1 < SND_DEVICE_MIN) || (snd_device1 >= SND_DEVICE_MAX)) { |
| 1235 | ALOGE("%s: Invalid snd_device = %s", __func__, |
| 1236 | platform_get_snd_device_name(snd_device1)); |
| 1237 | return false; |
| 1238 | } |
| 1239 | if ((snd_device2 < SND_DEVICE_MIN) || (snd_device2 >= SND_DEVICE_MAX)) { |
| 1240 | ALOGE("%s: Invalid snd_device = %s", __func__, |
| 1241 | platform_get_snd_device_name(snd_device2)); |
| 1242 | return false; |
| 1243 | } |
| 1244 | const char * be_itf1 = hw_interface_table[snd_device1]; |
| 1245 | const char * be_itf2 = hw_interface_table[snd_device2]; |
| 1246 | |
| 1247 | if (NULL != be_itf1 && NULL != be_itf2) { |
Eric Laurent | e63e61d | 2015-09-10 12:19:33 -0700 | [diff] [blame] | 1248 | if ((NULL == strstr(be_itf2, be_itf1)) && (NULL == strstr(be_itf1, be_itf2))) |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 1249 | result = false; |
| 1250 | } |
| 1251 | |
| 1252 | ALOGV("%s: be_itf1 = %s, be_itf2 = %s, match %d", __func__, be_itf1, be_itf2, result); |
| 1253 | return result; |
| 1254 | } |
| 1255 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1256 | int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) |
| 1257 | { |
| 1258 | int device_id; |
| 1259 | if (device_type == PCM_PLAYBACK) |
| 1260 | device_id = pcm_device_table[usecase][0]; |
| 1261 | else |
| 1262 | device_id = pcm_device_table[usecase][1]; |
| 1263 | return device_id; |
| 1264 | } |
| 1265 | |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1266 | static int find_index(const struct name_to_index * table, int32_t len, |
| 1267 | const char * name) |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 1268 | { |
| 1269 | int ret = 0; |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1270 | int32_t i; |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 1271 | |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1272 | if (table == NULL) { |
| 1273 | ALOGE("%s: table is NULL", __func__); |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 1274 | ret = -ENODEV; |
| 1275 | goto done; |
| 1276 | } |
| 1277 | |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1278 | if (name == NULL) { |
| 1279 | ALOGE("null key"); |
| 1280 | ret = -ENODEV; |
| 1281 | goto done; |
| 1282 | } |
| 1283 | |
| 1284 | for (i=0; i < len; i++) { |
| 1285 | if (!strcmp(table[i].name, name)) { |
| 1286 | ret = table[i].index; |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 1287 | goto done; |
| 1288 | } |
| 1289 | } |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1290 | ALOGE("%s: Could not find index for name = %s", |
| 1291 | __func__, name); |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 1292 | ret = -ENODEV; |
| 1293 | done: |
| 1294 | return ret; |
| 1295 | } |
| 1296 | |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1297 | int platform_get_snd_device_index(char *device_name) |
| 1298 | { |
| 1299 | return find_index(snd_device_name_index, SND_DEVICE_MAX, device_name); |
| 1300 | } |
| 1301 | |
| 1302 | int platform_get_usecase_index(const char *usecase_name) |
| 1303 | { |
| 1304 | return find_index(usecase_name_index, AUDIO_USECASE_MAX, usecase_name); |
| 1305 | } |
| 1306 | |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1307 | void platform_add_operator_specific_device(snd_device_t snd_device, |
| 1308 | const char *operator, |
| 1309 | const char *mixer_path, |
| 1310 | unsigned int acdb_id) |
| 1311 | { |
| 1312 | struct operator_specific_device *device; |
| 1313 | |
| 1314 | if (operator_specific_device_table[snd_device] == NULL) { |
| 1315 | operator_specific_device_table[snd_device] = |
| 1316 | (struct listnode *)calloc(1, sizeof(struct listnode)); |
| 1317 | list_init(operator_specific_device_table[snd_device]); |
| 1318 | } |
| 1319 | |
| 1320 | device = (struct operator_specific_device *)calloc(1, sizeof(struct operator_specific_device)); |
| 1321 | |
| 1322 | device->operator = strdup(operator); |
| 1323 | device->mixer_path = strdup(mixer_path); |
| 1324 | device->acdb_id = acdb_id; |
| 1325 | |
| 1326 | list_add_tail(operator_specific_device_table[snd_device], &device->list); |
| 1327 | |
| 1328 | ALOGD("%s : deivce[%s] -> operator[%s] mixer_path[%s] acdb_id [%d]", __func__, |
| 1329 | platform_get_snd_device_name(snd_device), operator, mixer_path, acdb_id); |
| 1330 | |
| 1331 | } |
| 1332 | |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 1333 | int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id) |
| 1334 | { |
| 1335 | int ret = 0; |
| 1336 | |
| 1337 | if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { |
| 1338 | ALOGE("%s: Invalid snd_device = %d", |
| 1339 | __func__, snd_device); |
| 1340 | ret = -EINVAL; |
| 1341 | goto done; |
| 1342 | } |
| 1343 | |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 1344 | ALOGV("%s: acdb_device_table[%s]: old = %d new = %d", __func__, |
| 1345 | platform_get_snd_device_name(snd_device), acdb_device_table[snd_device], acdb_id); |
Haynes Mathew George | 5bc1884 | 2014-06-16 16:36:20 -0700 | [diff] [blame] | 1346 | acdb_device_table[snd_device] = acdb_id; |
| 1347 | done: |
| 1348 | return ret; |
| 1349 | } |
| 1350 | |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 1351 | int platform_get_snd_device_acdb_id(snd_device_t snd_device) |
| 1352 | { |
| 1353 | if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { |
| 1354 | ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); |
| 1355 | return -EINVAL; |
| 1356 | } |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1357 | |
| 1358 | if (operator_specific_device_table[snd_device] != NULL) |
| 1359 | return get_operator_specific_device_acdb_id(snd_device); |
| 1360 | else |
| 1361 | return acdb_device_table[snd_device]; |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 1362 | } |
| 1363 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1364 | int platform_send_audio_calibration(void *platform, snd_device_t snd_device) |
| 1365 | { |
| 1366 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1367 | int acdb_dev_id, acdb_dev_type; |
| 1368 | |
Ravi Kumar Alamanda | adf0f3b | 2015-06-04 02:34:02 -0700 | [diff] [blame] | 1369 | acdb_dev_id = acdb_device_table[audio_extn_get_spkr_prot_snd_device(snd_device)]; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1370 | if (acdb_dev_id < 0) { |
| 1371 | ALOGE("%s: Could not find acdb id for device(%d)", |
| 1372 | __func__, snd_device); |
| 1373 | return -EINVAL; |
| 1374 | } |
| 1375 | if (my_data->acdb_send_audio_cal) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 1376 | ALOGD("%s: sending audio calibration for snd_device(%d) acdb_id(%d)", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1377 | __func__, snd_device, acdb_dev_id); |
| 1378 | if (snd_device >= SND_DEVICE_OUT_BEGIN && |
| 1379 | snd_device < SND_DEVICE_OUT_END) |
| 1380 | acdb_dev_type = ACDB_DEV_TYPE_OUT; |
| 1381 | else |
| 1382 | acdb_dev_type = ACDB_DEV_TYPE_IN; |
| 1383 | my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type); |
| 1384 | } |
| 1385 | return 0; |
| 1386 | } |
| 1387 | |
| 1388 | int platform_switch_voice_call_device_pre(void *platform) |
| 1389 | { |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1390 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1391 | int ret = 0; |
| 1392 | |
| 1393 | if (my_data->csd != NULL && |
Ravi Kumar Alamanda | b09e4a0 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 1394 | voice_is_in_call(my_data->adev)) { |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1395 | /* This must be called before disabling mixer controls on APQ side */ |
| 1396 | ret = my_data->csd->disable_device(); |
| 1397 | if (ret < 0) { |
| 1398 | ALOGE("%s: csd_client_disable_device, failed, error %d", |
| 1399 | __func__, ret); |
| 1400 | } |
| 1401 | } |
| 1402 | return ret; |
| 1403 | } |
| 1404 | |
| 1405 | int platform_switch_voice_call_enable_device_config(void *platform, |
| 1406 | snd_device_t out_snd_device, |
| 1407 | snd_device_t in_snd_device) |
| 1408 | { |
| 1409 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1410 | int acdb_rx_id, acdb_tx_id; |
| 1411 | int ret = 0; |
| 1412 | |
| 1413 | if (my_data->csd == NULL) |
| 1414 | return ret; |
| 1415 | |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 1416 | if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && |
| 1417 | audio_extn_spkr_prot_is_enabled()) |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1418 | acdb_rx_id = platform_get_snd_device_acdb_id(SND_DEVICE_OUT_SPEAKER_PROTECTED); |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 1419 | else |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1420 | acdb_rx_id = platform_get_snd_device_acdb_id(out_snd_device); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1421 | |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1422 | acdb_tx_id = platform_get_snd_device_acdb_id(in_snd_device); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1423 | |
| 1424 | if (acdb_rx_id > 0 && acdb_tx_id > 0) { |
| 1425 | ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id); |
| 1426 | if (ret < 0) { |
| 1427 | ALOGE("%s: csd_enable_device_config, failed, error %d", |
| 1428 | __func__, ret); |
| 1429 | } |
| 1430 | } else { |
| 1431 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 1432 | acdb_rx_id, acdb_tx_id); |
| 1433 | } |
| 1434 | |
| 1435 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1436 | } |
| 1437 | |
| 1438 | int platform_switch_voice_call_device_post(void *platform, |
| 1439 | snd_device_t out_snd_device, |
| 1440 | snd_device_t in_snd_device) |
| 1441 | { |
| 1442 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1443 | int acdb_rx_id, acdb_tx_id; |
| 1444 | |
| 1445 | if (my_data->acdb_send_voice_cal == NULL) { |
| 1446 | ALOGE("%s: dlsym error for acdb_send_voice_call", __func__); |
| 1447 | } else { |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 1448 | if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && |
| 1449 | audio_extn_spkr_prot_is_enabled()) |
| 1450 | out_snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED; |
| 1451 | |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1452 | acdb_rx_id = platform_get_snd_device_acdb_id(out_snd_device); |
| 1453 | acdb_tx_id = platform_get_snd_device_acdb_id(in_snd_device); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1454 | |
| 1455 | if (acdb_rx_id > 0 && acdb_tx_id > 0) |
| 1456 | my_data->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id); |
| 1457 | else |
| 1458 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 1459 | acdb_rx_id, acdb_tx_id); |
| 1460 | } |
| 1461 | |
| 1462 | return 0; |
| 1463 | } |
| 1464 | |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1465 | int platform_switch_voice_call_usecase_route_post(void *platform, |
| 1466 | snd_device_t out_snd_device, |
| 1467 | snd_device_t in_snd_device) |
| 1468 | { |
| 1469 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1470 | int acdb_rx_id, acdb_tx_id; |
| 1471 | int ret = 0; |
| 1472 | |
| 1473 | if (my_data->csd == NULL) |
| 1474 | return ret; |
| 1475 | |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 1476 | if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && |
| 1477 | audio_extn_spkr_prot_is_enabled()) |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1478 | acdb_rx_id = platform_get_snd_device_acdb_id(SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED); |
Ravi Kumar Alamanda | 6386300 | 2015-04-22 11:15:25 -0700 | [diff] [blame] | 1479 | else |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1480 | acdb_rx_id = platform_get_snd_device_acdb_id(out_snd_device); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1481 | |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 1482 | acdb_tx_id = platform_get_snd_device_acdb_id(in_snd_device); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1483 | |
| 1484 | if (acdb_rx_id > 0 && acdb_tx_id > 0) { |
| 1485 | ret = my_data->csd->enable_device(acdb_rx_id, acdb_tx_id, |
| 1486 | my_data->adev->acdb_settings); |
| 1487 | if (ret < 0) { |
| 1488 | ALOGE("%s: csd_enable_device, failed, error %d", __func__, ret); |
| 1489 | } |
| 1490 | } else { |
| 1491 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 1492 | acdb_rx_id, acdb_tx_id); |
| 1493 | } |
| 1494 | |
| 1495 | return ret; |
| 1496 | } |
| 1497 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1498 | int platform_start_voice_call(void *platform, uint32_t vsid) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1499 | { |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1500 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1501 | int ret = 0; |
| 1502 | |
| 1503 | if (my_data->csd != NULL) { |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1504 | ret = my_data->csd->start_voice(vsid); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1505 | if (ret < 0) { |
| 1506 | ALOGE("%s: csd_start_voice error %d\n", __func__, ret); |
| 1507 | } |
| 1508 | } |
| 1509 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1510 | } |
| 1511 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1512 | int platform_stop_voice_call(void *platform, uint32_t vsid) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1513 | { |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1514 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1515 | int ret = 0; |
| 1516 | |
| 1517 | if (my_data->csd != NULL) { |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1518 | ret = my_data->csd->stop_voice(vsid); |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1519 | if (ret < 0) { |
| 1520 | ALOGE("%s: csd_stop_voice error %d\n", __func__, ret); |
| 1521 | } |
| 1522 | } |
| 1523 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1524 | } |
| 1525 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1526 | int platform_get_sample_rate(void *platform, uint32_t *rate) |
| 1527 | { |
| 1528 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1529 | int ret = 0; |
| 1530 | |
| 1531 | if (my_data->csd != NULL) { |
| 1532 | ret = my_data->csd->get_sample_rate(rate); |
| 1533 | if (ret < 0) { |
| 1534 | ALOGE("%s: csd_get_sample_rate error %d\n", __func__, ret); |
| 1535 | } |
| 1536 | } |
| 1537 | return ret; |
| 1538 | } |
| 1539 | |
vivek mehta | b650641 | 2015-08-07 16:55:17 -0700 | [diff] [blame] | 1540 | void platform_set_speaker_gain_in_combo(struct audio_device *adev, |
| 1541 | snd_device_t snd_device, |
| 1542 | bool enable) |
| 1543 | { |
| 1544 | const char* name; |
| 1545 | switch (snd_device) { |
| 1546 | case SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES: |
| 1547 | if (enable) |
| 1548 | name = "spkr-gain-in-headphone-combo"; |
| 1549 | else |
| 1550 | name = "speaker-gain-default"; |
| 1551 | break; |
| 1552 | case SND_DEVICE_OUT_SPEAKER_AND_LINE: |
| 1553 | if (enable) |
| 1554 | name = "spkr-gain-in-line-combo"; |
| 1555 | else |
| 1556 | name = "speaker-gain-default"; |
| 1557 | break; |
| 1558 | case SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES: |
| 1559 | if (enable) |
| 1560 | name = "spkr-safe-gain-in-headphone-combo"; |
| 1561 | else |
| 1562 | name = "speaker-safe-gain-default"; |
| 1563 | break; |
| 1564 | case SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE: |
| 1565 | if (enable) |
| 1566 | name = "spkr-safe-gain-in-line-combo"; |
| 1567 | else |
| 1568 | name = "speaker-safe-gain-default"; |
| 1569 | break; |
| 1570 | default: |
| 1571 | return; |
| 1572 | } |
| 1573 | |
| 1574 | audio_route_apply_and_update_path(adev->audio_route, name); |
| 1575 | } |
| 1576 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1577 | int platform_set_voice_volume(void *platform, int volume) |
| 1578 | { |
| 1579 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1580 | struct audio_device *adev = my_data->adev; |
| 1581 | struct mixer_ctl *ctl; |
sangwoo | 53b2cf0 | 2013-07-25 19:18:44 -0700 | [diff] [blame] | 1582 | const char *mixer_ctl_name = "Voice Rx Gain"; |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1583 | int vol_index = 0, ret = 0; |
| 1584 | uint32_t set_values[ ] = {0, |
| 1585 | ALL_SESSION_VSID, |
| 1586 | DEFAULT_VOLUME_RAMP_DURATION_MS}; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1587 | |
| 1588 | // Voice volume levels are mapped to adsp volume levels as follows. |
| 1589 | // 100 -> 5, 80 -> 4, 60 -> 3, 40 -> 2, 20 -> 1 0 -> 0 |
| 1590 | // But this values don't changed in kernel. So, below change is need. |
keunhui.park | c5aaa0e | 2015-07-13 10:57:37 +0900 | [diff] [blame] | 1591 | vol_index = (int)percent_to_index(volume, MIN_VOL_INDEX, my_data->max_vol_index); |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1592 | set_values[0] = vol_index; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1593 | |
| 1594 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 1595 | if (!ctl) { |
| 1596 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 1597 | __func__, mixer_ctl_name); |
| 1598 | return -EINVAL; |
| 1599 | } |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1600 | ALOGV("Setting voice volume index: %d", set_values[0]); |
| 1601 | mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
| 1602 | |
Ravi Kumar Alamanda | 83281a9 | 2014-05-19 18:14:57 -0700 | [diff] [blame] | 1603 | if (my_data->csd != NULL) { |
| 1604 | ret = my_data->csd->volume(ALL_SESSION_VSID, volume, |
| 1605 | DEFAULT_VOLUME_RAMP_DURATION_MS); |
| 1606 | if (ret < 0) { |
| 1607 | ALOGE("%s: csd_volume error %d", __func__, ret); |
| 1608 | } |
| 1609 | } |
| 1610 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1611 | } |
| 1612 | |
| 1613 | int platform_set_mic_mute(void *platform, bool state) |
| 1614 | { |
| 1615 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1616 | struct audio_device *adev = my_data->adev; |
| 1617 | struct mixer_ctl *ctl; |
| 1618 | const char *mixer_ctl_name = "Voice Tx Mute"; |
sangwoo | 53b2cf0 | 2013-07-25 19:18:44 -0700 | [diff] [blame] | 1619 | int ret = 0; |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1620 | uint32_t set_values[ ] = {0, |
| 1621 | ALL_SESSION_VSID, |
| 1622 | DEFAULT_MUTE_RAMP_DURATION_MS}; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1623 | |
Uday Kishore Pasupuleti | a1f4805 | 2015-09-08 22:49:18 +0900 | [diff] [blame] | 1624 | if (adev->mode != AUDIO_MODE_IN_CALL && |
| 1625 | adev->mode != AUDIO_MODE_IN_COMMUNICATION) |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1626 | return 0; |
| 1627 | |
Uday Kishore Pasupuleti | a1f4805 | 2015-09-08 22:49:18 +0900 | [diff] [blame] | 1628 | if (adev->enable_hfp) |
| 1629 | mixer_ctl_name = "HFP Tx Mute"; |
| 1630 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1631 | set_values[0] = state; |
| 1632 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 1633 | if (!ctl) { |
| 1634 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 1635 | __func__, mixer_ctl_name); |
| 1636 | return -EINVAL; |
| 1637 | } |
| 1638 | ALOGV("Setting voice mute state: %d", state); |
| 1639 | mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
| 1640 | |
| 1641 | if (my_data->csd != NULL) { |
| 1642 | ret = my_data->csd->mic_mute(ALL_SESSION_VSID, state, |
| 1643 | DEFAULT_MUTE_RAMP_DURATION_MS); |
sangwoo | 53b2cf0 | 2013-07-25 19:18:44 -0700 | [diff] [blame] | 1644 | if (ret < 0) { |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1645 | ALOGE("%s: csd_mic_mute error %d", __func__, ret); |
sangwoo | 53b2cf0 | 2013-07-25 19:18:44 -0700 | [diff] [blame] | 1646 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1647 | } |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1648 | return ret; |
| 1649 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1650 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1651 | int platform_set_device_mute(void *platform, bool state, char *dir) |
| 1652 | { |
| 1653 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1654 | struct audio_device *adev = my_data->adev; |
| 1655 | struct mixer_ctl *ctl; |
| 1656 | char *mixer_ctl_name = NULL; |
| 1657 | int ret = 0; |
| 1658 | uint32_t set_values[ ] = {0, |
| 1659 | ALL_SESSION_VSID, |
| 1660 | 0}; |
| 1661 | if(dir == NULL) { |
| 1662 | ALOGE("%s: Invalid direction:%s", __func__, dir); |
| 1663 | return -EINVAL; |
| 1664 | } |
| 1665 | |
| 1666 | if (!strncmp("rx", dir, sizeof("rx"))) { |
| 1667 | mixer_ctl_name = "Voice Rx Device Mute"; |
| 1668 | } else if (!strncmp("tx", dir, sizeof("tx"))) { |
| 1669 | mixer_ctl_name = "Voice Tx Device Mute"; |
| 1670 | } else { |
| 1671 | return -EINVAL; |
| 1672 | } |
| 1673 | |
| 1674 | set_values[0] = state; |
| 1675 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 1676 | if (!ctl) { |
| 1677 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 1678 | __func__, mixer_ctl_name); |
| 1679 | return -EINVAL; |
| 1680 | } |
| 1681 | |
| 1682 | ALOGV("%s: Setting device mute state: %d, mixer ctrl:%s", |
| 1683 | __func__,state, mixer_ctl_name); |
| 1684 | mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
| 1685 | |
| 1686 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1687 | } |
| 1688 | |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 1689 | bool platform_can_split_snd_device(snd_device_t snd_device, |
| 1690 | int *num_devices, |
| 1691 | snd_device_t *new_snd_devices) |
| 1692 | { |
| 1693 | bool status = false; |
| 1694 | |
| 1695 | if (NULL == num_devices || NULL == new_snd_devices) { |
| 1696 | ALOGE("%s: NULL pointer ..", __func__); |
| 1697 | return false; |
| 1698 | } |
| 1699 | |
| 1700 | /* |
| 1701 | * If wired headset/headphones/line devices share the same backend |
| 1702 | * with speaker/earpiece this routine returns false. |
| 1703 | */ |
| 1704 | if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES && |
| 1705 | !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_HEADPHONES)) { |
| 1706 | *num_devices = 2; |
| 1707 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER; |
| 1708 | new_snd_devices[1] = SND_DEVICE_OUT_HEADPHONES; |
| 1709 | status = true; |
| 1710 | } else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_LINE && |
| 1711 | !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_LINE)) { |
| 1712 | *num_devices = 2; |
| 1713 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER; |
| 1714 | new_snd_devices[1] = SND_DEVICE_OUT_LINE; |
| 1715 | status = true; |
Ravi Kumar Alamanda | 3b86d47 | 2015-06-08 00:35:57 -0700 | [diff] [blame] | 1716 | } else if (snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES && |
| 1717 | !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER_SAFE, SND_DEVICE_OUT_HEADPHONES)) { |
| 1718 | *num_devices = 2; |
| 1719 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER_SAFE; |
| 1720 | new_snd_devices[1] = SND_DEVICE_OUT_HEADPHONES; |
| 1721 | status = true; |
| 1722 | } else if (snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE && |
| 1723 | !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER_SAFE, SND_DEVICE_OUT_LINE)) { |
| 1724 | *num_devices = 2; |
| 1725 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER_SAFE; |
| 1726 | new_snd_devices[1] = SND_DEVICE_OUT_LINE; |
| 1727 | status = true; |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 1728 | } |
| 1729 | return status; |
| 1730 | } |
| 1731 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1732 | snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices) |
| 1733 | { |
| 1734 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1735 | struct audio_device *adev = my_data->adev; |
| 1736 | audio_mode_t mode = adev->mode; |
| 1737 | snd_device_t snd_device = SND_DEVICE_NONE; |
| 1738 | |
| 1739 | ALOGV("%s: enter: output devices(%#x)", __func__, devices); |
| 1740 | if (devices == AUDIO_DEVICE_NONE || |
| 1741 | devices & AUDIO_DEVICE_BIT_IN) { |
| 1742 | ALOGV("%s: Invalid output devices (%#x)", __func__, devices); |
| 1743 | goto exit; |
| 1744 | } |
| 1745 | |
Eric Laurent | 1b49155 | 2015-09-15 17:52:41 -0700 | [diff] [blame] | 1746 | if (popcount(devices) == 2) { |
| 1747 | if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | |
| 1748 | AUDIO_DEVICE_OUT_SPEAKER) || |
| 1749 | devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | |
| 1750 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 1751 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; |
| 1752 | } else if (devices == (AUDIO_DEVICE_OUT_LINE | |
| 1753 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 1754 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_LINE; |
| 1755 | } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | |
| 1756 | AUDIO_DEVICE_OUT_SPEAKER_SAFE) || |
| 1757 | devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | |
| 1758 | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) { |
| 1759 | snd_device = SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES; |
| 1760 | } else if (devices == (AUDIO_DEVICE_OUT_LINE | |
| 1761 | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) { |
| 1762 | snd_device = SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE; |
| 1763 | } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL | |
| 1764 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 1765 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI; |
| 1766 | } else { |
| 1767 | ALOGE("%s: Invalid combo device(%#x)", __func__, devices); |
| 1768 | goto exit; |
| 1769 | } |
| 1770 | if (snd_device != SND_DEVICE_NONE) { |
| 1771 | goto exit; |
| 1772 | } |
| 1773 | } |
| 1774 | |
| 1775 | if (popcount(devices) != 1) { |
| 1776 | ALOGE("%s: Invalid output devices(%#x)", __func__, devices); |
| 1777 | goto exit; |
| 1778 | } |
| 1779 | |
Ravi Kumar Alamanda | b09e4a0 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 1780 | if (voice_is_in_call(adev) || adev->enable_voicerx) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1781 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
Eric Laurent | 09f2e0e | 2014-07-29 16:02:32 -0500 | [diff] [blame] | 1782 | devices & AUDIO_DEVICE_OUT_WIRED_HEADSET || |
| 1783 | devices & AUDIO_DEVICE_OUT_LINE) { |
Ravi Kumar Alamanda | b09e4a0 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 1784 | if (voice_is_in_call(adev) && |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 1785 | (adev->voice.tty_mode == TTY_MODE_FULL)) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1786 | snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES; |
Ravi Kumar Alamanda | b09e4a0 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 1787 | else if (voice_is_in_call(adev) && |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 1788 | (adev->voice.tty_mode == TTY_MODE_VCO)) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1789 | snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES; |
Ravi Kumar Alamanda | b09e4a0 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 1790 | else if (voice_is_in_call(adev) && |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 1791 | (adev->voice.tty_mode == TTY_MODE_HCO)) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1792 | snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET; |
Eric Laurent | 09f2e0e | 2014-07-29 16:02:32 -0500 | [diff] [blame] | 1793 | else { |
| 1794 | if (devices & AUDIO_DEVICE_OUT_LINE) |
| 1795 | snd_device = SND_DEVICE_OUT_VOICE_LINE; |
| 1796 | else |
| 1797 | snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; |
| 1798 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1799 | } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 1800 | if (adev->bt_wb_speech_enabled) { |
| 1801 | snd_device = SND_DEVICE_OUT_BT_SCO_WB; |
| 1802 | } else { |
| 1803 | snd_device = SND_DEVICE_OUT_BT_SCO; |
| 1804 | } |
Eric Laurent | 1b0d8ce | 2014-09-11 09:59:28 -0700 | [diff] [blame] | 1805 | } else if (devices & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) { |
Uday Kishore Pasupuleti | 7629719 | 2015-09-18 08:39:43 -0700 | [diff] [blame] | 1806 | if (!adev->enable_hfp) { |
| 1807 | snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; |
| 1808 | } else { |
| 1809 | snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_HFP; |
| 1810 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1811 | } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { |
Eric Laurent | 9d0d3f1 | 2014-07-25 12:40:29 -0500 | [diff] [blame] | 1812 | if(adev->voice.hac) |
| 1813 | snd_device = SND_DEVICE_OUT_VOICE_HAC_HANDSET; |
| 1814 | else if (is_operator_tmus()) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1815 | snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS; |
| 1816 | else |
Eric Laurent | b4d368e | 2014-06-25 10:21:54 -0500 | [diff] [blame] | 1817 | snd_device = SND_DEVICE_OUT_VOICE_HANDSET; |
Ravi Kumar Alamanda | 99c752d | 2014-08-20 17:55:26 -0700 | [diff] [blame] | 1818 | } else if (devices & AUDIO_DEVICE_OUT_TELEPHONY_TX) |
| 1819 | snd_device = SND_DEVICE_OUT_VOICE_TX; |
| 1820 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1821 | if (snd_device != SND_DEVICE_NONE) { |
| 1822 | goto exit; |
| 1823 | } |
| 1824 | } |
| 1825 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1826 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 1827 | devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 1828 | snd_device = SND_DEVICE_OUT_HEADPHONES; |
Eric Laurent | 09f2e0e | 2014-07-29 16:02:32 -0500 | [diff] [blame] | 1829 | } else if (devices & AUDIO_DEVICE_OUT_LINE) { |
| 1830 | snd_device = SND_DEVICE_OUT_LINE; |
Eric Laurent | 1b0d8ce | 2014-09-11 09:59:28 -0700 | [diff] [blame] | 1831 | } else if (devices & AUDIO_DEVICE_OUT_SPEAKER_SAFE) { |
| 1832 | snd_device = SND_DEVICE_OUT_SPEAKER_SAFE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1833 | } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { |
Ravi Kumar Alamanda | 1f60cf8 | 2015-04-23 19:45:17 -0700 | [diff] [blame] | 1834 | if (my_data->speaker_lr_swap) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1835 | snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE; |
| 1836 | else |
| 1837 | snd_device = SND_DEVICE_OUT_SPEAKER; |
| 1838 | } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 1839 | if (adev->bt_wb_speech_enabled) { |
| 1840 | snd_device = SND_DEVICE_OUT_BT_SCO_WB; |
| 1841 | } else { |
| 1842 | snd_device = SND_DEVICE_OUT_BT_SCO; |
| 1843 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1844 | } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 1845 | snd_device = SND_DEVICE_OUT_HDMI ; |
| 1846 | } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { |
Eric Laurent | 9d0d3f1 | 2014-07-25 12:40:29 -0500 | [diff] [blame] | 1847 | /*HAC support for voice-ish audio (eg visual voicemail)*/ |
| 1848 | if(adev->voice.hac) |
| 1849 | snd_device = SND_DEVICE_OUT_VOICE_HAC_HANDSET; |
| 1850 | else |
| 1851 | snd_device = SND_DEVICE_OUT_HANDSET; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1852 | } else { |
| 1853 | ALOGE("%s: Unknown device(s) %#x", __func__, devices); |
| 1854 | } |
| 1855 | exit: |
| 1856 | ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]); |
| 1857 | return snd_device; |
| 1858 | } |
| 1859 | |
| 1860 | snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device) |
| 1861 | { |
| 1862 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1863 | struct audio_device *adev = my_data->adev; |
| 1864 | audio_source_t source = (adev->active_input == NULL) ? |
| 1865 | AUDIO_SOURCE_DEFAULT : adev->active_input->source; |
| 1866 | |
| 1867 | audio_mode_t mode = adev->mode; |
| 1868 | audio_devices_t in_device = ((adev->active_input == NULL) ? |
| 1869 | AUDIO_DEVICE_NONE : adev->active_input->device) |
| 1870 | & ~AUDIO_DEVICE_BIT_IN; |
| 1871 | audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? |
| 1872 | AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; |
| 1873 | snd_device_t snd_device = SND_DEVICE_NONE; |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 1874 | int channel_count = popcount(channel_mask); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1875 | |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1876 | ALOGV("%s: enter: out_device(%#x) in_device(%#x) channel_count (%d) channel_mask (0x%x)", |
| 1877 | __func__, out_device, in_device, channel_count, channel_mask); |
Ravi Kumar Alamanda | b09e4a0 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 1878 | if ((out_device != AUDIO_DEVICE_NONE) && voice_is_in_call(adev)) { |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1879 | if (adev->voice.tty_mode != TTY_MODE_OFF) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1880 | if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
Eric Laurent | 09f2e0e | 2014-07-29 16:02:32 -0500 | [diff] [blame] | 1881 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET || |
| 1882 | out_device & AUDIO_DEVICE_OUT_LINE) { |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1883 | switch (adev->voice.tty_mode) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1884 | case TTY_MODE_FULL: |
| 1885 | snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC; |
| 1886 | break; |
| 1887 | case TTY_MODE_VCO: |
| 1888 | snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC; |
| 1889 | break; |
| 1890 | case TTY_MODE_HCO: |
| 1891 | snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC; |
| 1892 | break; |
| 1893 | default: |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 1894 | ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1895 | } |
| 1896 | goto exit; |
| 1897 | } |
| 1898 | } |
Eric Laurent | b991fb0 | 2014-08-29 15:23:17 -0500 | [diff] [blame] | 1899 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1900 | if (my_data->fluence_in_voice_call == false) { |
| 1901 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 1902 | } else { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 1903 | if (is_operator_tmus()) |
| 1904 | snd_device = SND_DEVICE_IN_VOICE_DMIC_TMUS; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1905 | else |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 1906 | snd_device = SND_DEVICE_IN_VOICE_DMIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1907 | } |
| 1908 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 1909 | snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; |
| 1910 | } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 1911 | if (adev->bt_wb_speech_enabled) { |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 1912 | if (adev->bluetooth_nrec) |
| 1913 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB_NREC; |
| 1914 | else |
| 1915 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 1916 | } else { |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 1917 | if (adev->bluetooth_nrec) |
| 1918 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_NREC; |
| 1919 | else |
| 1920 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 1921 | } |
Eric Laurent | b991fb0 | 2014-08-29 15:23:17 -0500 | [diff] [blame] | 1922 | } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER || |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1923 | out_device & AUDIO_DEVICE_OUT_SPEAKER_SAFE || |
| 1924 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 1925 | out_device & AUDIO_DEVICE_OUT_LINE) { |
| 1926 | if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode) { |
| 1927 | if (my_data->source_mic_type & SOURCE_DUAL_MIC) { |
| 1928 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC; |
| 1929 | } else { |
| 1930 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; |
| 1931 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1932 | } |
vivek mehta | fe121d5 | 2015-08-10 23:39:23 -0700 | [diff] [blame] | 1933 | |
| 1934 | //select default |
| 1935 | if (snd_device == SND_DEVICE_NONE) { |
Uday Kishore Pasupuleti | 7629719 | 2015-09-18 08:39:43 -0700 | [diff] [blame] | 1936 | if (!adev->enable_hfp) { |
| 1937 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; |
| 1938 | } else { |
| 1939 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP; |
| 1940 | platform_set_echo_reference(adev, true, out_device); |
| 1941 | } |
vivek mehta | fe121d5 | 2015-08-10 23:39:23 -0700 | [diff] [blame] | 1942 | } |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1943 | } else if (out_device & AUDIO_DEVICE_OUT_TELEPHONY_TX) { |
Ravi Kumar Alamanda | 99c752d | 2014-08-20 17:55:26 -0700 | [diff] [blame] | 1944 | snd_device = SND_DEVICE_IN_VOICE_RX; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1945 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1946 | } else if (source == AUDIO_SOURCE_CAMCORDER) { |
| 1947 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || |
| 1948 | in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 1949 | snd_device = SND_DEVICE_IN_CAMCORDER_MIC; |
| 1950 | } |
| 1951 | } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) { |
| 1952 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1953 | if (my_data->fluence_in_voice_rec && channel_count == 1) { |
| 1954 | if ((my_data->fluence_type == FLUENCE_PRO_ENABLE) && |
| 1955 | (my_data->source_mic_type & SOURCE_QUAD_MIC)) { |
| 1956 | snd_device = SND_DEVICE_IN_HANDSET_QMIC; |
| 1957 | } else if ((my_data->fluence_type == FLUENCE_PRO_ENABLE) && |
| 1958 | (my_data->source_mic_type & SOURCE_THREE_MIC)) { |
| 1959 | snd_device = SND_DEVICE_IN_HANDSET_TMIC; |
| 1960 | } else if (((my_data->fluence_type == FLUENCE_PRO_ENABLE) || |
| 1961 | (my_data->fluence_type == FLUENCE_ENABLE)) && |
| 1962 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 1963 | snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 1964 | } |
| 1965 | platform_set_echo_reference(adev, true, out_device); |
| 1966 | } else if ((channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) && |
| 1967 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
| 1968 | snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_STEREO; |
| 1969 | } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) && |
| 1970 | (my_data->source_mic_type & SOURCE_THREE_MIC)) { |
| 1971 | snd_device = SND_DEVICE_IN_THREE_MIC; |
| 1972 | } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) && |
| 1973 | (my_data->source_mic_type & SOURCE_QUAD_MIC)) { |
| 1974 | snd_device = SND_DEVICE_IN_QUAD_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1975 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1976 | if (snd_device == SND_DEVICE_NONE) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 1977 | if (adev->active_input->enable_ns) |
| 1978 | snd_device = SND_DEVICE_IN_VOICE_REC_MIC_NS; |
| 1979 | else |
| 1980 | snd_device = SND_DEVICE_IN_VOICE_REC_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1981 | } |
Jean-Michel Trivi | 8c83fe8 | 2015-09-25 15:06:53 -0700 | [diff] [blame] | 1982 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 1983 | snd_device = SND_DEVICE_IN_VOICE_REC_HEADSET_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1984 | } |
rago | 90fb961 | 2015-12-02 11:37:53 -0800 | [diff] [blame] | 1985 | } else if (source == AUDIO_SOURCE_UNPROCESSED) { |
| 1986 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
| 1987 | snd_device = SND_DEVICE_IN_UNPROCESSED_MIC; |
| 1988 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 1989 | snd_device = SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC; |
| 1990 | } |
Eric Laurent | 50a38ed | 2015-10-14 18:48:06 -0700 | [diff] [blame] | 1991 | } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION || |
rago | 90fb961 | 2015-12-02 11:37:53 -0800 | [diff] [blame] | 1992 | mode == AUDIO_MODE_IN_COMMUNICATION) { |
Eric Laurent | 1b0d8ce | 2014-09-11 09:59:28 -0700 | [diff] [blame] | 1993 | if (out_device & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1994 | in_device = AUDIO_DEVICE_IN_BACK_MIC; |
| 1995 | if (adev->active_input) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 1996 | if (adev->active_input->enable_aec && |
| 1997 | adev->active_input->enable_ns) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1998 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 1999 | if (my_data->fluence_in_spkr_mode && |
| 2000 | my_data->fluence_in_voice_comm && |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2001 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2002 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2003 | } else { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2004 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC_NS; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2005 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2006 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2007 | if (my_data->fluence_in_voice_comm && |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2008 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2009 | snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC_NS; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2010 | } else { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2011 | snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC_NS; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2012 | } |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 2013 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 2014 | snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2015 | } |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 2016 | platform_set_echo_reference(adev, true, out_device); |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2017 | } else if (adev->active_input->enable_aec) { |
| 2018 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 2019 | if (my_data->fluence_in_spkr_mode && |
| 2020 | my_data->fluence_in_voice_comm && |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2021 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2022 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2023 | } else { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2024 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2025 | } |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2026 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
| 2027 | if (my_data->fluence_in_voice_comm && |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2028 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2029 | snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2030 | } else { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2031 | snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2032 | } |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 2033 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 2034 | snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; |
| 2035 | } |
Ravi Kumar Alamanda | f282901 | 2014-11-12 16:16:10 -0800 | [diff] [blame] | 2036 | platform_set_echo_reference(adev, true, out_device); |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2037 | } else if (adev->active_input->enable_ns) { |
| 2038 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 2039 | if (my_data->fluence_in_spkr_mode && |
| 2040 | my_data->fluence_in_voice_comm && |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2041 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2042 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2043 | } else { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2044 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_NS; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2045 | } |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2046 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
| 2047 | if (my_data->fluence_in_voice_comm && |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2048 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2049 | snd_device = SND_DEVICE_IN_HANDSET_DMIC_NS; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2050 | } else { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2051 | snd_device = SND_DEVICE_IN_HANDSET_MIC_NS; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2052 | } |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2053 | } |
Eric Laurent | cefbbac | 2014-09-04 13:54:10 -0500 | [diff] [blame] | 2054 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2055 | } |
| 2056 | } else if (source == AUDIO_SOURCE_DEFAULT) { |
| 2057 | goto exit; |
| 2058 | } |
| 2059 | |
| 2060 | |
| 2061 | if (snd_device != SND_DEVICE_NONE) { |
| 2062 | goto exit; |
| 2063 | } |
| 2064 | |
| 2065 | if (in_device != AUDIO_DEVICE_NONE && |
| 2066 | !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) && |
| 2067 | !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) { |
| 2068 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2069 | if ((my_data->source_mic_type & SOURCE_QUAD_MIC) && |
| 2070 | (int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) { |
| 2071 | snd_device = SND_DEVICE_IN_QUAD_MIC; |
| 2072 | } else if ((my_data->source_mic_type & SOURCE_THREE_MIC) && |
| 2073 | (int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) { |
| 2074 | snd_device = SND_DEVICE_IN_THREE_MIC; |
| 2075 | } else if ((my_data->source_mic_type & SOURCE_DUAL_MIC) && |
| 2076 | channel_count == 2) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2077 | snd_device = SND_DEVICE_IN_HANDSET_DMIC_STEREO; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2078 | } else if ((my_data->source_mic_type & SOURCE_MONO_MIC) && |
| 2079 | channel_count == 1) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2080 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2081 | } else { |
| 2082 | ALOGE("%s: something wrong (1): source type (%d) channel_count (%d) .." |
| 2083 | " channel mask (0x%x) no combination found .. setting to mono", __func__, |
| 2084 | my_data->source_mic_type, channel_count, channel_mask); |
| 2085 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 2086 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2087 | } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2088 | if ((my_data->source_mic_type & SOURCE_DUAL_MIC) && |
| 2089 | channel_count == 2) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2090 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_STEREO; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2091 | } else if ((my_data->source_mic_type & SOURCE_MONO_MIC) && |
| 2092 | channel_count == 1) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2093 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2094 | } else { |
| 2095 | ALOGE("%s: something wrong (2): source type (%d) channel_count (%d) .." |
| 2096 | " no combination found .. setting to mono", __func__, |
| 2097 | my_data->source_mic_type, channel_count); |
| 2098 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
| 2099 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2100 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 2101 | snd_device = SND_DEVICE_IN_HEADSET_MIC; |
| 2102 | } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 2103 | if (adev->bt_wb_speech_enabled) { |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 2104 | if (adev->bluetooth_nrec) |
| 2105 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB_NREC; |
| 2106 | else |
| 2107 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 2108 | } else { |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 2109 | if (adev->bluetooth_nrec) |
| 2110 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_NREC; |
| 2111 | else |
| 2112 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 2113 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2114 | } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) { |
| 2115 | snd_device = SND_DEVICE_IN_HDMI_MIC; |
| 2116 | } else { |
| 2117 | ALOGE("%s: Unknown input device(s) %#x", __func__, in_device); |
| 2118 | ALOGW("%s: Using default handset-mic", __func__); |
| 2119 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 2120 | } |
| 2121 | } else { |
| 2122 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { |
| 2123 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 2124 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 2125 | snd_device = SND_DEVICE_IN_HEADSET_MIC; |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2126 | } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER || |
Eric Laurent | 1b0d8ce | 2014-09-11 09:59:28 -0700 | [diff] [blame] | 2127 | out_device & AUDIO_DEVICE_OUT_SPEAKER_SAFE || |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2128 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
Eric Laurent | 09f2e0e | 2014-07-29 16:02:32 -0500 | [diff] [blame] | 2129 | out_device & AUDIO_DEVICE_OUT_LINE) { |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2130 | if ((my_data->source_mic_type & SOURCE_DUAL_MIC) && |
| 2131 | channel_count == 2) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2132 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_STEREO; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2133 | } else if ((my_data->source_mic_type & SOURCE_MONO_MIC) && |
| 2134 | channel_count == 1) { |
Ravi Kumar Alamanda | 3ad4e1b | 2014-06-03 00:08:15 -0700 | [diff] [blame] | 2135 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2136 | } else { |
| 2137 | ALOGE("%s: something wrong (3): source type (%d) channel_count (%d) .." |
| 2138 | " no combination found .. setting to mono", __func__, |
| 2139 | my_data->source_mic_type, channel_count); |
| 2140 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
| 2141 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2142 | } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) { |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 2143 | if (adev->bt_wb_speech_enabled) { |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 2144 | if (adev->bluetooth_nrec) |
| 2145 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB_NREC; |
| 2146 | else |
| 2147 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 2148 | } else { |
Ravi Kumar Alamanda | e258e68 | 2015-06-25 13:32:42 -0700 | [diff] [blame] | 2149 | if (adev->bluetooth_nrec) |
| 2150 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_NREC; |
| 2151 | else |
| 2152 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Ravi Kumar Alamanda | 9f30654 | 2014-04-02 15:11:49 -0700 | [diff] [blame] | 2153 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2154 | } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 2155 | snd_device = SND_DEVICE_IN_HDMI_MIC; |
| 2156 | } else { |
| 2157 | ALOGE("%s: Unknown output device(s) %#x", __func__, out_device); |
| 2158 | ALOGW("%s: Using default handset-mic", __func__); |
| 2159 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 2160 | } |
| 2161 | } |
| 2162 | exit: |
| 2163 | ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]); |
| 2164 | return snd_device; |
| 2165 | } |
| 2166 | |
| 2167 | int platform_set_hdmi_channels(void *platform, int channel_count) |
| 2168 | { |
| 2169 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2170 | struct audio_device *adev = my_data->adev; |
| 2171 | struct mixer_ctl *ctl; |
| 2172 | const char *channel_cnt_str = NULL; |
| 2173 | const char *mixer_ctl_name = "HDMI_RX Channels"; |
| 2174 | switch (channel_count) { |
| 2175 | case 8: |
| 2176 | channel_cnt_str = "Eight"; break; |
| 2177 | case 7: |
| 2178 | channel_cnt_str = "Seven"; break; |
| 2179 | case 6: |
| 2180 | channel_cnt_str = "Six"; break; |
| 2181 | case 5: |
| 2182 | channel_cnt_str = "Five"; break; |
| 2183 | case 4: |
| 2184 | channel_cnt_str = "Four"; break; |
| 2185 | case 3: |
| 2186 | channel_cnt_str = "Three"; break; |
| 2187 | default: |
| 2188 | channel_cnt_str = "Two"; break; |
| 2189 | } |
| 2190 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 2191 | if (!ctl) { |
| 2192 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 2193 | __func__, mixer_ctl_name); |
| 2194 | return -EINVAL; |
| 2195 | } |
| 2196 | ALOGV("HDMI channel count: %s", channel_cnt_str); |
| 2197 | mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); |
| 2198 | return 0; |
| 2199 | } |
| 2200 | |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 2201 | int platform_edid_get_max_channels(void *platform) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2202 | { |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 2203 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2204 | struct audio_device *adev = my_data->adev; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2205 | char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE]; |
| 2206 | char *sad = block; |
| 2207 | int num_audio_blocks; |
| 2208 | int channel_count; |
| 2209 | int max_channels = 0; |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 2210 | int i, ret, count; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2211 | |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 2212 | struct mixer_ctl *ctl; |
| 2213 | |
| 2214 | ctl = mixer_get_ctl_by_name(adev->mixer, AUDIO_DATA_BLOCK_MIXER_CTL); |
| 2215 | if (!ctl) { |
| 2216 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 2217 | __func__, AUDIO_DATA_BLOCK_MIXER_CTL); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2218 | return 0; |
| 2219 | } |
| 2220 | |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 2221 | mixer_ctl_update(ctl); |
| 2222 | |
| 2223 | count = mixer_ctl_get_num_values(ctl); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2224 | |
| 2225 | /* Read SAD blocks, clamping the maximum size for safety */ |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 2226 | if (count > (int)sizeof(block)) |
| 2227 | count = (int)sizeof(block); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2228 | |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 2229 | ret = mixer_ctl_get_array(ctl, block, count); |
| 2230 | if (ret != 0) { |
| 2231 | ALOGE("%s: mixer_ctl_get_array() failed to get EDID info", __func__); |
| 2232 | return 0; |
| 2233 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2234 | |
| 2235 | /* Calculate the number of SAD blocks */ |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 2236 | num_audio_blocks = count / SAD_BLOCK_SIZE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2237 | |
| 2238 | for (i = 0; i < num_audio_blocks; i++) { |
| 2239 | /* Only consider LPCM blocks */ |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 2240 | if ((sad[0] >> 3) != EDID_FORMAT_LPCM) { |
| 2241 | sad += 3; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2242 | continue; |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 2243 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 2244 | |
| 2245 | channel_count = (sad[0] & 0x7) + 1; |
| 2246 | if (channel_count > max_channels) |
| 2247 | max_channels = channel_count; |
| 2248 | |
| 2249 | /* Advance to next block */ |
| 2250 | sad += 3; |
| 2251 | } |
| 2252 | |
| 2253 | return max_channels; |
| 2254 | } |
Haynes Mathew George | 7ff216f | 2013-09-11 19:51:41 -0700 | [diff] [blame] | 2255 | |
Vineeta Srivastava | 4b89e37 | 2014-06-19 14:21:42 -0700 | [diff] [blame] | 2256 | int platform_set_incall_recording_session_id(void *platform, |
| 2257 | uint32_t session_id, int rec_mode) |
| 2258 | { |
| 2259 | int ret = 0; |
| 2260 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2261 | struct audio_device *adev = my_data->adev; |
| 2262 | struct mixer_ctl *ctl; |
| 2263 | const char *mixer_ctl_name = "Voc VSID"; |
| 2264 | int num_ctl_values; |
| 2265 | int i; |
| 2266 | |
| 2267 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 2268 | if (!ctl) { |
| 2269 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 2270 | __func__, mixer_ctl_name); |
| 2271 | ret = -EINVAL; |
| 2272 | } else { |
| 2273 | num_ctl_values = mixer_ctl_get_num_values(ctl); |
| 2274 | for (i = 0; i < num_ctl_values; i++) { |
| 2275 | if (mixer_ctl_set_value(ctl, i, session_id)) { |
| 2276 | ALOGV("Error: invalid session_id: %x", session_id); |
| 2277 | ret = -EINVAL; |
| 2278 | break; |
| 2279 | } |
| 2280 | } |
| 2281 | } |
| 2282 | |
| 2283 | if (my_data->csd != NULL) { |
| 2284 | ret = my_data->csd->start_record(ALL_SESSION_VSID, rec_mode); |
| 2285 | if (ret < 0) { |
| 2286 | ALOGE("%s: csd_client_start_record failed, error %d", |
| 2287 | __func__, ret); |
| 2288 | } |
| 2289 | } |
| 2290 | |
| 2291 | return ret; |
| 2292 | } |
| 2293 | |
| 2294 | int platform_stop_incall_recording_usecase(void *platform) |
| 2295 | { |
| 2296 | int ret = 0; |
| 2297 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2298 | |
| 2299 | if (my_data->csd != NULL) { |
| 2300 | ret = my_data->csd->stop_record(ALL_SESSION_VSID); |
| 2301 | if (ret < 0) { |
| 2302 | ALOGE("%s: csd_client_stop_record failed, error %d", |
| 2303 | __func__, ret); |
| 2304 | } |
| 2305 | } |
| 2306 | |
| 2307 | return ret; |
| 2308 | } |
| 2309 | |
| 2310 | int platform_start_incall_music_usecase(void *platform) |
| 2311 | { |
| 2312 | int ret = 0; |
| 2313 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2314 | |
| 2315 | if (my_data->csd != NULL) { |
| 2316 | ret = my_data->csd->start_playback(ALL_SESSION_VSID); |
| 2317 | if (ret < 0) { |
| 2318 | ALOGE("%s: csd_client_start_playback failed, error %d", |
| 2319 | __func__, ret); |
| 2320 | } |
| 2321 | } |
| 2322 | |
| 2323 | return ret; |
| 2324 | } |
| 2325 | |
| 2326 | int platform_stop_incall_music_usecase(void *platform) |
| 2327 | { |
| 2328 | int ret = 0; |
| 2329 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2330 | |
| 2331 | if (my_data->csd != NULL) { |
| 2332 | ret = my_data->csd->stop_playback(ALL_SESSION_VSID); |
| 2333 | if (ret < 0) { |
| 2334 | ALOGE("%s: csd_client_stop_playback failed, error %d", |
| 2335 | __func__, ret); |
| 2336 | } |
| 2337 | } |
| 2338 | |
| 2339 | return ret; |
| 2340 | } |
| 2341 | |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 2342 | int platform_set_parameters(void *platform, struct str_parms *parms) |
| 2343 | { |
| 2344 | struct platform_data *my_data = (struct platform_data *)platform; |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 2345 | char value[128]; |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 2346 | char *kv_pairs = str_parms_to_str(parms); |
| 2347 | int ret = 0, err; |
| 2348 | |
| 2349 | if (kv_pairs == NULL) { |
| 2350 | ret = -EINVAL; |
| 2351 | ALOGE("%s: key-value pair is NULL",__func__); |
| 2352 | goto done; |
| 2353 | } |
| 2354 | |
| 2355 | ALOGV("%s: enter: %s", __func__, kv_pairs); |
| 2356 | |
| 2357 | err = str_parms_get_str(parms, PLATFORM_CONFIG_KEY_SOUNDCARD_NAME, |
| 2358 | value, sizeof(value)); |
| 2359 | if (err >= 0) { |
| 2360 | str_parms_del(parms, PLATFORM_CONFIG_KEY_SOUNDCARD_NAME); |
| 2361 | my_data->snd_card_name = strdup(value); |
| 2362 | ALOGV("%s: sound card name %s", __func__, my_data->snd_card_name); |
| 2363 | } |
| 2364 | |
keunhui.park | 2f7306a | 2015-07-16 16:48:06 +0900 | [diff] [blame] | 2365 | err = str_parms_get_str(parms, PLATFORM_CONFIG_KEY_OPERATOR_INFO, |
| 2366 | value, sizeof(value)); |
| 2367 | if (err >= 0) { |
| 2368 | struct operator_info *info; |
| 2369 | char *str = value; |
| 2370 | char *name; |
| 2371 | |
| 2372 | str_parms_del(parms, PLATFORM_CONFIG_KEY_OPERATOR_INFO); |
| 2373 | info = (struct operator_info *)calloc(1, sizeof(struct operator_info)); |
| 2374 | name = strtok(str, ";"); |
| 2375 | info->name = strdup(name); |
| 2376 | info->mccmnc = strdup(str + strlen(name) + 1); |
| 2377 | |
| 2378 | list_add_tail(&operator_info_list, &info->list); |
| 2379 | ALOGD("%s: add operator[%s] mccmnc[%s]", __func__, info->name, info->mccmnc); |
| 2380 | } |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2381 | |
| 2382 | memset(value, 0, sizeof(value)); |
Eric Laurent | c633338 | 2015-09-14 12:43:44 -0700 | [diff] [blame] | 2383 | err = str_parms_get_str(parms, PLATFORM_CONFIG_KEY_MAX_MIC_COUNT, |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2384 | value, sizeof(value)); |
| 2385 | if (err >= 0) { |
Eric Laurent | c633338 | 2015-09-14 12:43:44 -0700 | [diff] [blame] | 2386 | str_parms_del(parms, PLATFORM_CONFIG_KEY_MAX_MIC_COUNT); |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2387 | my_data->max_mic_count = atoi(value); |
| 2388 | ALOGV("%s: max_mic_count %s/%d", __func__, value, my_data->max_mic_count); |
Prashant Malani | c92c596 | 2015-08-11 15:10:18 -0700 | [diff] [blame] | 2389 | } |
| 2390 | |
Ravi Kumar Alamanda | c4f5731 | 2015-06-26 17:41:02 -0700 | [diff] [blame] | 2391 | done: |
| 2392 | ALOGV("%s: exit with code(%d)", __func__, ret); |
| 2393 | if (kv_pairs != NULL) |
| 2394 | free(kv_pairs); |
| 2395 | |
| 2396 | return ret; |
| 2397 | } |
| 2398 | |
Haynes Mathew George | 7ff216f | 2013-09-11 19:51:41 -0700 | [diff] [blame] | 2399 | /* Delay in Us */ |
| 2400 | int64_t platform_render_latency(audio_usecase_t usecase) |
| 2401 | { |
| 2402 | switch (usecase) { |
| 2403 | case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: |
| 2404 | return DEEP_BUFFER_PLATFORM_DELAY; |
| 2405 | case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: |
| 2406 | return LOW_LATENCY_PLATFORM_DELAY; |
| 2407 | default: |
| 2408 | return 0; |
| 2409 | } |
| 2410 | } |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 2411 | |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 2412 | int platform_set_snd_device_backend(snd_device_t device, const char *backend_tag, |
| 2413 | const char * hw_interface) |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 2414 | { |
| 2415 | int ret = 0; |
| 2416 | |
| 2417 | if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) { |
| 2418 | ALOGE("%s: Invalid snd_device = %d", |
| 2419 | __func__, device); |
| 2420 | ret = -EINVAL; |
| 2421 | goto done; |
| 2422 | } |
| 2423 | |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 2424 | ALOGV("%s: backend_tag_table[%s]: old = %s new = %s", __func__, |
| 2425 | platform_get_snd_device_name(device), |
| 2426 | backend_tag_table[device] != NULL ? backend_tag_table[device]: "null", backend_tag); |
| 2427 | if (backend_tag_table[device]) { |
| 2428 | free(backend_tag_table[device]); |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 2429 | } |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 2430 | backend_tag_table[device] = strdup(backend_tag); |
| 2431 | |
| 2432 | if (hw_interface != NULL) { |
| 2433 | if (hw_interface_table[device]) |
| 2434 | free(hw_interface_table[device]); |
| 2435 | ALOGV("%s: hw_interface_table[%d] = %s", __func__, device, hw_interface); |
| 2436 | hw_interface_table[device] = strdup(hw_interface); |
| 2437 | } |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 2438 | done: |
| 2439 | return ret; |
| 2440 | } |
| 2441 | |
| 2442 | int platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id) |
| 2443 | { |
| 2444 | int ret = 0; |
| 2445 | if ((usecase <= USECASE_INVALID) || (usecase >= AUDIO_USECASE_MAX)) { |
| 2446 | ALOGE("%s: invalid usecase case idx %d", __func__, usecase); |
| 2447 | ret = -EINVAL; |
| 2448 | goto done; |
| 2449 | } |
| 2450 | |
| 2451 | if ((type != 0) && (type != 1)) { |
| 2452 | ALOGE("%s: invalid usecase type", __func__); |
| 2453 | ret = -EINVAL; |
| 2454 | } |
Ravi Kumar Alamanda | b7ea4f5 | 2015-06-08 16:44:05 -0700 | [diff] [blame] | 2455 | ALOGV("%s: pcm_device_table[%d][%d] = %d", __func__, usecase, type, pcm_id); |
Haynes Mathew George | 98c9562 | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 2456 | pcm_device_table[usecase][type] = pcm_id; |
| 2457 | done: |
| 2458 | return ret; |
| 2459 | } |
Ravi Kumar Alamanda | 1f60cf8 | 2015-04-23 19:45:17 -0700 | [diff] [blame] | 2460 | |
Jean-Michel Trivi | 88cbad3 | 2015-09-23 14:51:02 -0700 | [diff] [blame] | 2461 | #define DEFAULT_NOMINAL_SPEAKER_GAIN 20 |
| 2462 | int ramp_speaker_gain(struct audio_device *adev, bool ramp_up, int target_ramp_up_gain) { |
| 2463 | // backup_gain: gain to try to set in case of an error during ramp |
| 2464 | int start_gain, end_gain, step, backup_gain, i; |
| 2465 | bool error = false; |
| 2466 | const struct mixer_ctl *ctl; |
| 2467 | const char *mixer_ctl_name_gain_left = "Left Speaker Gain"; |
| 2468 | const char *mixer_ctl_name_gain_right = "Right Speaker Gain"; |
| 2469 | struct mixer_ctl *ctl_left = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name_gain_left); |
| 2470 | struct mixer_ctl *ctl_right = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name_gain_right); |
| 2471 | if (!ctl_left || !ctl_right) { |
| 2472 | ALOGE("%s: Could not get ctl for mixer cmd - %s or %s, not applying speaker gain ramp", |
| 2473 | __func__, mixer_ctl_name_gain_left, mixer_ctl_name_gain_right); |
| 2474 | return -EINVAL; |
| 2475 | } else if ((mixer_ctl_get_num_values(ctl_left) != 1) |
| 2476 | || (mixer_ctl_get_num_values(ctl_right) != 1)) { |
| 2477 | ALOGE("%s: Unexpected num values for mixer cmd - %s or %s, not applying speaker gain ramp", |
| 2478 | __func__, mixer_ctl_name_gain_left, mixer_ctl_name_gain_right); |
| 2479 | return -EINVAL; |
| 2480 | } |
| 2481 | if (ramp_up) { |
| 2482 | start_gain = 0; |
| 2483 | end_gain = target_ramp_up_gain > 0 ? target_ramp_up_gain : DEFAULT_NOMINAL_SPEAKER_GAIN; |
| 2484 | step = +1; |
| 2485 | backup_gain = end_gain; |
| 2486 | } else { |
| 2487 | // using same gain on left and right |
| 2488 | const int left_gain = mixer_ctl_get_value(ctl_left, 0); |
| 2489 | start_gain = left_gain > 0 ? left_gain : DEFAULT_NOMINAL_SPEAKER_GAIN; |
| 2490 | end_gain = 0; |
| 2491 | step = -1; |
| 2492 | backup_gain = start_gain; |
| 2493 | } |
| 2494 | for (i = start_gain ; i != (end_gain + step) ; i += step) { |
| 2495 | //ALOGV("setting speaker gain to %d", i); |
| 2496 | if (mixer_ctl_set_value(ctl_left, 0, i)) { |
| 2497 | ALOGE("%s: error setting %s to %d during gain ramp", |
| 2498 | __func__, mixer_ctl_name_gain_left, i); |
| 2499 | error = true; |
| 2500 | break; |
| 2501 | } |
| 2502 | if (mixer_ctl_set_value(ctl_right, 0, i)) { |
| 2503 | ALOGE("%s: error setting %s to %d during gain ramp", |
| 2504 | __func__, mixer_ctl_name_gain_right, i); |
| 2505 | error = true; |
| 2506 | break; |
| 2507 | } |
| 2508 | usleep(1000); |
| 2509 | } |
| 2510 | if (error) { |
| 2511 | // an error occured during the ramp, let's still try to go back to a safe volume |
| 2512 | if (mixer_ctl_set_value(ctl_left, 0, backup_gain)) { |
| 2513 | ALOGE("%s: error restoring left gain to %d", __func__, backup_gain); |
| 2514 | } |
| 2515 | if (mixer_ctl_set_value(ctl_right, 0, backup_gain)) { |
| 2516 | ALOGE("%s: error restoring right gain to %d", __func__, backup_gain); |
| 2517 | } |
| 2518 | } |
| 2519 | return start_gain; |
| 2520 | } |
| 2521 | |
Ravi Kumar Alamanda | 1f60cf8 | 2015-04-23 19:45:17 -0700 | [diff] [blame] | 2522 | int platform_swap_lr_channels(struct audio_device *adev, bool swap_channels) |
| 2523 | { |
| 2524 | // only update if there is active pcm playback on speaker |
| 2525 | struct audio_usecase *usecase; |
| 2526 | struct listnode *node; |
| 2527 | struct platform_data *my_data = (struct platform_data *)adev->platform; |
| 2528 | |
| 2529 | if (my_data->speaker_lr_swap != swap_channels) { |
| 2530 | my_data->speaker_lr_swap = swap_channels; |
| 2531 | |
| 2532 | list_for_each(node, &adev->usecase_list) { |
| 2533 | usecase = node_to_item(node, struct audio_usecase, list); |
| 2534 | if (usecase->type == PCM_PLAYBACK && |
Ravi Kumar Alamanda | 425e154 | 2015-09-22 09:11:18 -0700 | [diff] [blame] | 2535 | usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER) { |
| 2536 | /* |
| 2537 | * If acdb tuning is different for SPEAKER_REVERSE, it is must |
| 2538 | * to perform device switch to disable the current backend to |
| 2539 | * enable it with new acdb data. |
| 2540 | */ |
| 2541 | if (acdb_device_table[SND_DEVICE_OUT_SPEAKER] != |
| 2542 | acdb_device_table[SND_DEVICE_OUT_SPEAKER_REVERSE]) { |
Jean-Michel Trivi | 88cbad3 | 2015-09-23 14:51:02 -0700 | [diff] [blame] | 2543 | const int initial_skpr_gain = ramp_speaker_gain(adev, false /*ramp_up*/, -1); |
Ravi Kumar Alamanda | 425e154 | 2015-09-22 09:11:18 -0700 | [diff] [blame] | 2544 | select_devices(adev, usecase->id); |
Jean-Michel Trivi | 88cbad3 | 2015-09-23 14:51:02 -0700 | [diff] [blame] | 2545 | if (initial_skpr_gain != -EINVAL) { |
| 2546 | ramp_speaker_gain(adev, true /*ramp_up*/, initial_skpr_gain); |
| 2547 | } |
Ravi Kumar Alamanda | 1f60cf8 | 2015-04-23 19:45:17 -0700 | [diff] [blame] | 2548 | } else { |
Ravi Kumar Alamanda | 425e154 | 2015-09-22 09:11:18 -0700 | [diff] [blame] | 2549 | const char *mixer_path; |
| 2550 | if (swap_channels) { |
| 2551 | mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER_REVERSE); |
| 2552 | audio_route_apply_and_update_path(adev->audio_route, mixer_path); |
| 2553 | } else { |
| 2554 | mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER); |
| 2555 | audio_route_apply_and_update_path(adev->audio_route, mixer_path); |
| 2556 | } |
Ravi Kumar Alamanda | 1f60cf8 | 2015-04-23 19:45:17 -0700 | [diff] [blame] | 2557 | } |
| 2558 | break; |
| 2559 | } |
| 2560 | } |
| 2561 | } |
| 2562 | return 0; |
| 2563 | } |