Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1 | /* |
Shiv Maliyappanahalli | 3e064fd | 2013-12-16 15:54:40 -0800 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 3 | * Not a Contribution. |
| 4 | * |
Shiv Maliyappanahalli | 8911f28 | 2014-01-10 15:56:19 -0800 | [diff] [blame] | 5 | * Copyright (C) 2013 The Android Open Source Project |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
| 20 | #define LOG_TAG "msm8974_platform" |
| 21 | /*#define LOG_NDEBUG 0*/ |
| 22 | #define LOG_NDDEBUG 0 |
| 23 | |
| 24 | #include <stdlib.h> |
| 25 | #include <dlfcn.h> |
| 26 | #include <cutils/log.h> |
| 27 | #include <cutils/properties.h> |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 28 | #include <cutils/str_parms.h> |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 29 | #include <audio_hw.h> |
| 30 | #include <platform_api.h> |
| 31 | #include "platform.h" |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 32 | #include "audio_extn.h" |
Narsinga Rao Chella | 05573b7 | 2013-11-15 15:21:40 -0800 | [diff] [blame] | 33 | #include "voice_extn.h" |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 34 | |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 35 | #define MIXER_XML_PATH "/system/etc/mixer_paths.xml" |
Damir Didjusto | f1d46c7 | 2013-11-06 17:59:04 -0800 | [diff] [blame] | 36 | #define MIXER_XML_PATH_AUXPCM "/system/etc/mixer_paths_auxpcm.xml" |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 37 | #define LIB_ACDB_LOADER "libacdbloader.so" |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 38 | #define AUDIO_DATA_BLOCK_MIXER_CTL "HDMI EDID" |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 39 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 40 | /* |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 41 | * This file will have a maximum of 38 bytes: |
| 42 | * |
| 43 | * 4 bytes: number of audio blocks |
| 44 | * 4 bytes: total length of Short Audio Descriptor (SAD) blocks |
| 45 | * Maximum 10 * 3 bytes: SAD blocks |
| 46 | */ |
| 47 | #define MAX_SAD_BLOCKS 10 |
| 48 | #define SAD_BLOCK_SIZE 3 |
| 49 | |
| 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 |
Apoorv Raghuvanshi | 84fa2fe | 2013-12-04 11:57:47 -0800 | [diff] [blame] | 56 | #define MAX_SND_CARD 8 |
sangwoo | 1b9f4b3 | 2013-06-21 18:22:55 -0700 | [diff] [blame] | 57 | |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 58 | #define SAMPLE_RATE_8KHZ 8000 |
| 59 | #define SAMPLE_RATE_16KHZ 16000 |
| 60 | |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 61 | #define AUDIO_PARAMETER_KEY_FLUENCE_TYPE "fluence" |
| 62 | #define AUDIO_PARAMETER_KEY_BTSCO "bt_samplerate" |
| 63 | #define AUDIO_PARAMETER_KEY_SLOWTALK "st_enable" |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 64 | #define AUDIO_PARAMETER_KEY_VOLUME_BOOST "volume_boost" |
| 65 | |
| 66 | enum { |
| 67 | VOICE_FEATURE_SET_DEFAULT, |
| 68 | VOICE_FEATURE_SET_VOLUME_BOOST |
| 69 | }; |
sangwoo | 53b2cf0 | 2013-07-25 19:18:44 -0700 | [diff] [blame] | 70 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 71 | struct audio_block_header |
| 72 | { |
| 73 | int reserved; |
| 74 | int length; |
| 75 | }; |
| 76 | |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 77 | /* Audio calibration related functions */ |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 78 | typedef void (*acdb_deallocate_t)(); |
Ben Romberger | 490d347 | 2014-01-15 17:11:59 -0800 | [diff] [blame] | 79 | typedef int (*acdb_init_t)(char *); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 80 | typedef void (*acdb_send_audio_cal_t)(int, int); |
| 81 | typedef void (*acdb_send_voice_cal_t)(int, int); |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 82 | typedef int (*acdb_reload_vocvoltable_t)(int); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 83 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 84 | struct platform_data { |
| 85 | struct audio_device *adev; |
| 86 | bool fluence_in_spkr_mode; |
| 87 | bool fluence_in_voice_call; |
| 88 | bool fluence_in_voice_rec; |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 89 | bool fluence_in_audio_rec; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 90 | int fluence_type; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 91 | int btsco_sample_rate; |
| 92 | bool slowtalk; |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 93 | /* Audio calibration related functions */ |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 94 | void *acdb_handle; |
| 95 | int voice_feature_set; |
| 96 | acdb_init_t acdb_init; |
| 97 | acdb_deallocate_t acdb_deallocate; |
| 98 | acdb_send_audio_cal_t acdb_send_audio_cal; |
| 99 | acdb_send_voice_cal_t acdb_send_voice_cal; |
| 100 | acdb_reload_vocvoltable_t acdb_reload_vocvoltable; |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 101 | |
| 102 | void *hw_info; |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 103 | struct csd_data *csd; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | static const int pcm_device_table[AUDIO_USECASE_MAX][2] = { |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 107 | [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE, |
| 108 | DEEP_BUFFER_PCM_DEVICE}, |
| 109 | [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, |
Preetam Singh Ranawat | de84f1a | 2013-11-01 14:58:16 -0700 | [diff] [blame] | 110 | LOWLATENCY_PCM_DEVICE}, |
| 111 | [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {MULTIMEDIA2_PCM_DEVICE, |
| 112 | MULTIMEDIA2_PCM_DEVICE}, |
Krishnankutty Kolathappilly | a43f96e | 2013-11-01 12:17:53 -0700 | [diff] [blame] | 113 | [USECASE_AUDIO_PLAYBACK_OFFLOAD] = |
| 114 | {PLAYBACK_OFFLOAD_DEVICE, PLAYBACK_OFFLOAD_DEVICE}, |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 115 | [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE}, |
Mingming Yin | e62d784 | 2013-10-25 16:26:03 -0700 | [diff] [blame] | 116 | [USECASE_AUDIO_RECORD_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, COMPRESS_CAPTURE_DEVICE}, |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 117 | [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, |
| 118 | LOWLATENCY_PCM_DEVICE}, |
Preetam Singh Ranawat | de84f1a | 2013-11-01 14:58:16 -0700 | [diff] [blame] | 119 | [USECASE_AUDIO_RECORD_FM_VIRTUAL] = {MULTIMEDIA2_PCM_DEVICE, |
| 120 | MULTIMEDIA2_PCM_DEVICE}, |
Apoorv Raghuvanshi | 6e26284 | 2013-10-06 14:39:35 -0700 | [diff] [blame] | 121 | [USECASE_AUDIO_PLAYBACK_FM] = {FM_PLAYBACK_PCM_DEVICE, FM_CAPTURE_PCM_DEVICE}, |
Vimal Puthanveed | 5b4d3f1 | 2013-11-05 15:57:39 -0800 | [diff] [blame] | 122 | [USECASE_AUDIO_HFP_SCO] = {HFP_PCM_RX, HFP_SCO_RX}, |
Vimal Puthanveed | 47e6485 | 2013-12-20 13:23:39 -0800 | [diff] [blame] | 123 | [USECASE_AUDIO_HFP_SCO_WB] = {HFP_PCM_RX, HFP_SCO_RX}, |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 124 | [USECASE_VOICE_CALL] = {VOICE_CALL_PCM_DEVICE, VOICE_CALL_PCM_DEVICE}, |
| 125 | [USECASE_VOICE2_CALL] = {VOICE2_CALL_PCM_DEVICE, VOICE2_CALL_PCM_DEVICE}, |
| 126 | [USECASE_VOLTE_CALL] = {VOLTE_CALL_PCM_DEVICE, VOLTE_CALL_PCM_DEVICE}, |
| 127 | [USECASE_QCHAT_CALL] = {QCHAT_CALL_PCM_DEVICE, QCHAT_CALL_PCM_DEVICE}, |
Narsinga Rao Chella | 05573b7 | 2013-11-15 15:21:40 -0800 | [diff] [blame] | 128 | [USECASE_COMPRESS_VOIP_CALL] = {COMPRESS_VOIP_CALL_PCM_DEVICE, COMPRESS_VOIP_CALL_PCM_DEVICE}, |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 129 | [USECASE_INCALL_REC_UPLINK] = {AUDIO_RECORD_PCM_DEVICE, |
| 130 | AUDIO_RECORD_PCM_DEVICE}, |
| 131 | [USECASE_INCALL_REC_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, |
| 132 | AUDIO_RECORD_PCM_DEVICE}, |
| 133 | [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, |
| 134 | AUDIO_RECORD_PCM_DEVICE}, |
Helen Zeng | e56b485 | 2013-12-03 16:54:40 -0800 | [diff] [blame] | 135 | [USECASE_INCALL_REC_UPLINK_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, |
| 136 | COMPRESS_CAPTURE_DEVICE}, |
| 137 | [USECASE_INCALL_REC_DOWNLINK_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, |
| 138 | COMPRESS_CAPTURE_DEVICE}, |
| 139 | [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, |
| 140 | COMPRESS_CAPTURE_DEVICE}, |
Shiv Maliyappanahalli | f3b9a42 | 2013-10-22 16:38:08 -0700 | [diff] [blame] | 141 | [USECASE_INCALL_MUSIC_UPLINK] = {INCALL_MUSIC_UPLINK_PCM_DEVICE, |
| 142 | INCALL_MUSIC_UPLINK_PCM_DEVICE}, |
| 143 | [USECASE_INCALL_MUSIC_UPLINK2] = {INCALL_MUSIC_UPLINK2_PCM_DEVICE, |
| 144 | INCALL_MUSIC_UPLINK2_PCM_DEVICE}, |
Gopikrishnaiah Anandan | f538cef | 2013-10-28 14:06:03 -0700 | [diff] [blame] | 145 | [USECASE_AUDIO_SPKR_CALIB_RX] = {SPKR_PROT_CALIB_RX_PCM_DEVICE, -1}, |
| 146 | [USECASE_AUDIO_SPKR_CALIB_TX] = {-1, SPKR_PROT_CALIB_TX_PCM_DEVICE}, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | /* Array to store sound devices */ |
| 150 | static const char * const device_table[SND_DEVICE_MAX] = { |
| 151 | [SND_DEVICE_NONE] = "none", |
| 152 | /* Playback sound devices */ |
| 153 | [SND_DEVICE_OUT_HANDSET] = "handset", |
| 154 | [SND_DEVICE_OUT_SPEAKER] = "speaker", |
| 155 | [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse", |
| 156 | [SND_DEVICE_OUT_HEADPHONES] = "headphones", |
| 157 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", |
| 158 | [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset", |
| 159 | [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker", |
| 160 | [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones", |
| 161 | [SND_DEVICE_OUT_HDMI] = "hdmi", |
| 162 | [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi", |
| 163 | [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset", |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 164 | [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 165 | [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones", |
| 166 | [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones", |
| 167 | [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset", |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 168 | [SND_DEVICE_OUT_AFE_PROXY] = "afe-proxy", |
| 169 | [SND_DEVICE_OUT_USB_HEADSET] = "usb-headphones", |
| 170 | [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = "speaker-and-usb-headphones", |
Apoorv Raghuvanshi | 6e26284 | 2013-10-06 14:39:35 -0700 | [diff] [blame] | 171 | [SND_DEVICE_OUT_TRANSMISSION_FM] = "transmission-fm", |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 172 | [SND_DEVICE_OUT_ANC_HEADSET] = "anc-headphones", |
| 173 | [SND_DEVICE_OUT_ANC_FB_HEADSET] = "anc-fb-headphones", |
| 174 | [SND_DEVICE_OUT_VOICE_ANC_HEADSET] = "voice-anc-headphones", |
| 175 | [SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET] = "voice-anc-fb-headphones", |
| 176 | [SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = "speaker-and-anc-headphones", |
| 177 | [SND_DEVICE_OUT_ANC_HANDSET] = "anc-handset", |
Gopikrishnaiah Anandan | f538cef | 2013-10-28 14:06:03 -0700 | [diff] [blame] | 178 | [SND_DEVICE_OUT_SPEAKER_PROTECTED] = "speaker-protected", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 179 | |
| 180 | /* Capture sound devices */ |
| 181 | [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 182 | [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic", |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 183 | [SND_DEVICE_IN_HANDSET_MIC_NS] = "handset-mic", |
| 184 | [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = "handset-mic", |
| 185 | [SND_DEVICE_IN_HANDSET_DMIC] = "dmic-endfire", |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 186 | [SND_DEVICE_IN_HANDSET_DMIC_AEC] = "dmic-endfire", |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 187 | [SND_DEVICE_IN_HANDSET_DMIC_NS] = "dmic-endfire", |
| 188 | [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = "dmic-endfire", |
| 189 | [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic", |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 190 | [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "speaker-mic", |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 191 | [SND_DEVICE_IN_SPEAKER_MIC_NS] = "speaker-mic", |
| 192 | [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = "speaker-mic", |
| 193 | [SND_DEVICE_IN_SPEAKER_DMIC] = "speaker-dmic-endfire", |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 194 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = "speaker-dmic-endfire", |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 195 | [SND_DEVICE_IN_SPEAKER_DMIC_NS] = "speaker-dmic-endfire", |
| 196 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = "speaker-dmic-endfire", |
| 197 | [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic", |
| 198 | [SND_DEVICE_IN_HEADSET_MIC_FLUENCE] = "headset-mic", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 199 | [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", |
| 200 | [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", |
| 201 | [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", |
| 202 | [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic", |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 203 | [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 204 | [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic", |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 205 | [SND_DEVICE_IN_VOICE_DMIC] = "voice-dmic-ef", |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 206 | [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef", |
Vidyakumar Athota | adfe4e3 | 2013-12-13 14:51:26 -0800 | [diff] [blame] | 207 | [SND_DEVICE_IN_VOICE_SPEAKER_QMIC] = "voice-speaker-qmic", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 208 | [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic", |
| 209 | [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic", |
| 210 | [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic", |
| 211 | [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic", |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 212 | [SND_DEVICE_IN_VOICE_REC_MIC_NS] = "voice-rec-mic", |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 213 | [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = "voice-rec-dmic-ef", |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 214 | [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = "voice-rec-dmic-ef-fluence", |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 215 | [SND_DEVICE_IN_USB_HEADSET_MIC] = "usb-headset-mic", |
Apoorv Raghuvanshi | 6e26284 | 2013-10-06 14:39:35 -0700 | [diff] [blame] | 216 | [SND_DEVICE_IN_CAPTURE_FM] = "capture-fm", |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 217 | [SND_DEVICE_IN_AANC_HANDSET_MIC] = "aanc-handset-mic", |
Apoorv Raghuvanshi | 6178a3f | 2013-10-19 12:38:54 -0700 | [diff] [blame] | 218 | [SND_DEVICE_IN_QUAD_MIC] = "quad-mic", |
Apoorv Raghuvanshi | 6bd8dbf | 2013-10-19 18:37:52 -0700 | [diff] [blame] | 219 | [SND_DEVICE_IN_HANDSET_STEREO_DMIC] = "handset-stereo-dmic-ef", |
| 220 | [SND_DEVICE_IN_SPEAKER_STEREO_DMIC] = "speaker-stereo-dmic-ef", |
Gopikrishnaiah Anandan | f538cef | 2013-10-28 14:06:03 -0700 | [diff] [blame] | 221 | [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = "vi-feedback", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 222 | }; |
| 223 | |
| 224 | /* ACDB IDs (audio DSP path configuration IDs) for each sound device */ |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 225 | static int acdb_device_table[SND_DEVICE_MAX] = { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 226 | [SND_DEVICE_NONE] = -1, |
| 227 | [SND_DEVICE_OUT_HANDSET] = 7, |
Vidyakumar Athota | c29d4ab | 2013-11-14 16:58:02 -0800 | [diff] [blame] | 228 | [SND_DEVICE_OUT_SPEAKER] = 14, |
| 229 | [SND_DEVICE_OUT_SPEAKER_REVERSE] = 14, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 230 | [SND_DEVICE_OUT_HEADPHONES] = 10, |
| 231 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10, |
| 232 | [SND_DEVICE_OUT_VOICE_HANDSET] = 7, |
Vidyakumar Athota | c29d4ab | 2013-11-14 16:58:02 -0800 | [diff] [blame] | 233 | [SND_DEVICE_OUT_VOICE_SPEAKER] = 14, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 234 | [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10, |
| 235 | [SND_DEVICE_OUT_HDMI] = 18, |
Vidyakumar Athota | c29d4ab | 2013-11-14 16:58:02 -0800 | [diff] [blame] | 236 | [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 14, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 237 | [SND_DEVICE_OUT_BT_SCO] = 22, |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 238 | [SND_DEVICE_OUT_BT_SCO_WB] = 39, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 239 | [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17, |
| 240 | [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17, |
| 241 | [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37, |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 242 | [SND_DEVICE_OUT_AFE_PROXY] = 0, |
Vidyakumar Athota | b952220 | 2014-01-14 20:08:27 -0800 | [diff] [blame] | 243 | [SND_DEVICE_OUT_USB_HEADSET] = 45, |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 244 | [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = 14, |
Apoorv Raghuvanshi | 6e26284 | 2013-10-06 14:39:35 -0700 | [diff] [blame] | 245 | [SND_DEVICE_OUT_TRANSMISSION_FM] = 0, |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 246 | [SND_DEVICE_OUT_ANC_HEADSET] = 26, |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 247 | [SND_DEVICE_OUT_ANC_FB_HEADSET] = 27, |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 248 | [SND_DEVICE_OUT_VOICE_ANC_HEADSET] = 26, |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 249 | [SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET] = 27, |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 250 | [SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = 26, |
| 251 | [SND_DEVICE_OUT_ANC_HANDSET] = 103, |
Gopikrishnaiah Anandan | f538cef | 2013-10-28 14:06:03 -0700 | [diff] [blame] | 252 | [SND_DEVICE_OUT_SPEAKER_PROTECTED] = 101, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 253 | |
| 254 | [SND_DEVICE_IN_HANDSET_MIC] = 4, |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 255 | [SND_DEVICE_IN_HANDSET_MIC_AEC] = 106, |
| 256 | [SND_DEVICE_IN_HANDSET_MIC_NS] = 107, |
| 257 | [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = 108, |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 258 | [SND_DEVICE_IN_HANDSET_DMIC] = 41, |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 259 | [SND_DEVICE_IN_HANDSET_DMIC_AEC] = 109, |
| 260 | [SND_DEVICE_IN_HANDSET_DMIC_NS] = 110, |
| 261 | [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = 111, |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 262 | [SND_DEVICE_IN_SPEAKER_MIC] = 11, |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 263 | [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 112, |
| 264 | [SND_DEVICE_IN_SPEAKER_MIC_NS] = 113, |
| 265 | [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = 114, |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 266 | [SND_DEVICE_IN_SPEAKER_DMIC] = 43, |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 267 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = 115, |
| 268 | [SND_DEVICE_IN_SPEAKER_DMIC_NS] = 116, |
| 269 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = 117, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 270 | [SND_DEVICE_IN_HEADSET_MIC] = 8, |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 271 | [SND_DEVICE_IN_HEADSET_MIC_FLUENCE] = 47, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 272 | [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11, |
| 273 | [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8, |
| 274 | [SND_DEVICE_IN_HDMI_MIC] = 4, |
| 275 | [SND_DEVICE_IN_BT_SCO_MIC] = 21, |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 276 | [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38, |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 277 | [SND_DEVICE_IN_CAMCORDER_MIC] = 4, |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 278 | [SND_DEVICE_IN_VOICE_DMIC] = 41, |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 279 | [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 43, |
Vidyakumar Athota | adfe4e3 | 2013-12-13 14:51:26 -0800 | [diff] [blame] | 280 | [SND_DEVICE_IN_VOICE_SPEAKER_QMIC] = 19, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 281 | [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16, |
| 282 | [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36, |
| 283 | [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16, |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 284 | [SND_DEVICE_IN_VOICE_REC_MIC] = 4, |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 285 | [SND_DEVICE_IN_VOICE_REC_MIC_NS] = 107, |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 286 | [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = 34, |
| 287 | [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = 41, |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 288 | [SND_DEVICE_IN_USB_HEADSET_MIC] = 44, |
Apoorv Raghuvanshi | 6e26284 | 2013-10-06 14:39:35 -0700 | [diff] [blame] | 289 | [SND_DEVICE_IN_CAPTURE_FM] = 0, |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 290 | [SND_DEVICE_IN_AANC_HANDSET_MIC] = 104, |
Apoorv Raghuvanshi | 6178a3f | 2013-10-19 12:38:54 -0700 | [diff] [blame] | 291 | [SND_DEVICE_IN_QUAD_MIC] = 46, |
Apoorv Raghuvanshi | 6bd8dbf | 2013-10-19 18:37:52 -0700 | [diff] [blame] | 292 | [SND_DEVICE_IN_HANDSET_STEREO_DMIC] = 34, |
| 293 | [SND_DEVICE_IN_SPEAKER_STEREO_DMIC] = 35, |
Gopikrishnaiah Anandan | f538cef | 2013-10-28 14:06:03 -0700 | [diff] [blame] | 294 | [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = 102, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 295 | }; |
| 296 | |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 297 | struct snd_device_index { |
| 298 | char name[100]; |
| 299 | unsigned int index; |
| 300 | }; |
| 301 | |
| 302 | #define TO_NAME_INDEX(X) #X, X |
| 303 | |
| 304 | /* Used to get index from parsed sting */ |
| 305 | struct snd_device_index snd_device_name_index[SND_DEVICE_MAX] = { |
| 306 | {TO_NAME_INDEX(SND_DEVICE_OUT_HANDSET)}, |
| 307 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)}, |
| 308 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_REVERSE)}, |
| 309 | {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES)}, |
| 310 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES)}, |
| 311 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET)}, |
| 312 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER)}, |
| 313 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HEADPHONES)}, |
| 314 | {TO_NAME_INDEX(SND_DEVICE_OUT_HDMI)}, |
| 315 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HDMI)}, |
| 316 | {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO)}, |
| 317 | {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO_WB)}, |
| 318 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES)}, |
| 319 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES)}, |
| 320 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET)}, |
| 321 | {TO_NAME_INDEX(SND_DEVICE_OUT_AFE_PROXY)}, |
| 322 | {TO_NAME_INDEX(SND_DEVICE_OUT_USB_HEADSET)}, |
| 323 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET)}, |
| 324 | {TO_NAME_INDEX(SND_DEVICE_OUT_TRANSMISSION_FM)}, |
| 325 | {TO_NAME_INDEX(SND_DEVICE_OUT_ANC_HEADSET)}, |
| 326 | {TO_NAME_INDEX(SND_DEVICE_OUT_ANC_FB_HEADSET)}, |
| 327 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_ANC_HEADSET)}, |
| 328 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET)}, |
| 329 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET)}, |
| 330 | {TO_NAME_INDEX(SND_DEVICE_OUT_ANC_HANDSET)}, |
| 331 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_PROTECTED)}, |
| 332 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC)}, |
| 333 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC)}, |
| 334 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_NS)}, |
| 335 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC_NS)}, |
| 336 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC)}, |
| 337 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC)}, |
| 338 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_NS)}, |
| 339 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC_NS)}, |
| 340 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC)}, |
| 341 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC)}, |
| 342 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_NS)}, |
| 343 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC_NS)}, |
| 344 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC)}, |
| 345 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC)}, |
| 346 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_NS)}, |
| 347 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS)}, |
| 348 | {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC)}, |
| 349 | {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC_FLUENCE)}, |
| 350 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_MIC)}, |
| 351 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_HEADSET_MIC)}, |
| 352 | {TO_NAME_INDEX(SND_DEVICE_IN_HDMI_MIC)}, |
| 353 | {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC)}, |
| 354 | {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB)}, |
| 355 | {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_MIC)}, |
| 356 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC)}, |
| 357 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_DMIC)}, |
| 358 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_QMIC)}, |
| 359 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC)}, |
| 360 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC)}, |
| 361 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC)}, |
| 362 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC)}, |
| 363 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC_NS)}, |
| 364 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_STEREO)}, |
| 365 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE)}, |
| 366 | {TO_NAME_INDEX(SND_DEVICE_IN_USB_HEADSET_MIC)}, |
| 367 | {TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_FM)}, |
| 368 | {TO_NAME_INDEX(SND_DEVICE_IN_AANC_HANDSET_MIC)}, |
| 369 | {TO_NAME_INDEX(SND_DEVICE_IN_QUAD_MIC)}, |
| 370 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_STEREO_DMIC)}, |
| 371 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_STEREO_DMIC)}, |
| 372 | {TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)}, |
| 373 | }; |
| 374 | |
Haynes Mathew George | 7ff216f | 2013-09-11 19:51:41 -0700 | [diff] [blame] | 375 | #define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) |
| 376 | #define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) |
| 377 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 378 | static int set_echo_reference(struct mixer *mixer, const char* ec_ref) |
| 379 | { |
| 380 | struct mixer_ctl *ctl; |
| 381 | const char *mixer_ctl_name = "EC_REF_RX"; |
| 382 | |
| 383 | ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name); |
| 384 | if (!ctl) { |
| 385 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 386 | __func__, mixer_ctl_name); |
| 387 | return -EINVAL; |
| 388 | } |
| 389 | ALOGV("Setting EC Reference: %s", ec_ref); |
| 390 | mixer_ctl_set_enum_by_string(ctl, ec_ref); |
| 391 | return 0; |
| 392 | } |
| 393 | |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 394 | static struct csd_data *open_csd_client() |
| 395 | { |
| 396 | struct csd_data *csd = calloc(1, sizeof(struct csd_data)); |
| 397 | |
| 398 | csd->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW); |
| 399 | if (csd->csd_client == NULL) { |
| 400 | ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT); |
| 401 | goto error; |
| 402 | } else { |
| 403 | ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT); |
| 404 | |
| 405 | csd->deinit = (deinit_t)dlsym(csd->csd_client, |
| 406 | "csd_client_deinit"); |
| 407 | if (csd->deinit == NULL) { |
| 408 | ALOGE("%s: dlsym error %s for csd_client_deinit", __func__, |
| 409 | dlerror()); |
| 410 | goto error; |
| 411 | } |
| 412 | csd->disable_device = (disable_device_t)dlsym(csd->csd_client, |
| 413 | "csd_client_disable_device"); |
| 414 | if (csd->disable_device == NULL) { |
| 415 | ALOGE("%s: dlsym error %s for csd_client_disable_device", |
| 416 | __func__, dlerror()); |
| 417 | goto error; |
| 418 | } |
Vidyakumar Athota | 545dbd3 | 2013-11-13 17:30:53 -0800 | [diff] [blame] | 419 | csd->enable_device_config = (enable_device_config_t)dlsym(csd->csd_client, |
| 420 | "csd_client_enable_device_config"); |
| 421 | if (csd->enable_device_config == NULL) { |
| 422 | ALOGE("%s: dlsym error %s for csd_client_enable_device_config", |
| 423 | __func__, dlerror()); |
| 424 | goto error; |
| 425 | } |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 426 | csd->enable_device = (enable_device_t)dlsym(csd->csd_client, |
| 427 | "csd_client_enable_device"); |
| 428 | if (csd->enable_device == NULL) { |
| 429 | ALOGE("%s: dlsym error %s for csd_client_enable_device", |
| 430 | __func__, dlerror()); |
| 431 | goto error; |
| 432 | } |
| 433 | csd->start_voice = (start_voice_t)dlsym(csd->csd_client, |
| 434 | "csd_client_start_voice"); |
| 435 | if (csd->start_voice == NULL) { |
| 436 | ALOGE("%s: dlsym error %s for csd_client_start_voice", |
| 437 | __func__, dlerror()); |
| 438 | goto error; |
| 439 | } |
| 440 | csd->stop_voice = (stop_voice_t)dlsym(csd->csd_client, |
| 441 | "csd_client_stop_voice"); |
| 442 | if (csd->stop_voice == NULL) { |
| 443 | ALOGE("%s: dlsym error %s for csd_client_stop_voice", |
| 444 | __func__, dlerror()); |
| 445 | goto error; |
| 446 | } |
| 447 | csd->volume = (volume_t)dlsym(csd->csd_client, |
| 448 | "csd_client_volume"); |
| 449 | if (csd->volume == NULL) { |
| 450 | ALOGE("%s: dlsym error %s for csd_client_volume", |
| 451 | __func__, dlerror()); |
| 452 | goto error; |
| 453 | } |
| 454 | csd->mic_mute = (mic_mute_t)dlsym(csd->csd_client, |
| 455 | "csd_client_mic_mute"); |
| 456 | if (csd->mic_mute == NULL) { |
| 457 | ALOGE("%s: dlsym error %s for csd_client_mic_mute", |
| 458 | __func__, dlerror()); |
| 459 | goto error; |
| 460 | } |
| 461 | csd->slow_talk = (slow_talk_t)dlsym(csd->csd_client, |
| 462 | "csd_client_slow_talk"); |
| 463 | if (csd->slow_talk == NULL) { |
| 464 | ALOGE("%s: dlsym error %s for csd_client_slow_talk", |
| 465 | __func__, dlerror()); |
| 466 | goto error; |
| 467 | } |
| 468 | csd->start_playback = (start_playback_t)dlsym(csd->csd_client, |
| 469 | "csd_client_start_playback"); |
| 470 | if (csd->start_playback == NULL) { |
| 471 | ALOGE("%s: dlsym error %s for csd_client_start_playback", |
| 472 | __func__, dlerror()); |
| 473 | goto error; |
| 474 | } |
| 475 | csd->stop_playback = (stop_playback_t)dlsym(csd->csd_client, |
| 476 | "csd_client_stop_playback"); |
| 477 | if (csd->stop_playback == NULL) { |
| 478 | ALOGE("%s: dlsym error %s for csd_client_stop_playback", |
| 479 | __func__, dlerror()); |
| 480 | goto error; |
| 481 | } |
| 482 | csd->start_record = (start_record_t)dlsym(csd->csd_client, |
| 483 | "csd_client_start_record"); |
| 484 | if (csd->start_record == NULL) { |
| 485 | ALOGE("%s: dlsym error %s for csd_client_start_record", |
| 486 | __func__, dlerror()); |
| 487 | goto error; |
| 488 | } |
| 489 | csd->stop_record = (stop_record_t)dlsym(csd->csd_client, |
| 490 | "csd_client_stop_record"); |
| 491 | if (csd->stop_record == NULL) { |
| 492 | ALOGE("%s: dlsym error %s for csd_client_stop_record", |
| 493 | __func__, dlerror()); |
| 494 | goto error; |
| 495 | } |
| 496 | csd->init = (init_t)dlsym(csd->csd_client, "csd_client_init"); |
| 497 | |
| 498 | if (csd->init == NULL) { |
| 499 | ALOGE("%s: dlsym error %s for csd_client_init", |
| 500 | __func__, dlerror()); |
| 501 | goto error; |
| 502 | } else { |
| 503 | csd->init(); |
| 504 | } |
| 505 | } |
| 506 | return csd; |
| 507 | |
| 508 | error: |
| 509 | free(csd); |
| 510 | csd = NULL; |
| 511 | return csd; |
| 512 | } |
| 513 | |
| 514 | void close_csd_client(struct csd_data *csd) |
| 515 | { |
| 516 | if (csd != NULL) { |
| 517 | csd->deinit(); |
| 518 | dlclose(csd->csd_client); |
| 519 | free(csd); |
| 520 | csd = NULL; |
| 521 | } |
| 522 | } |
| 523 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 524 | void *platform_init(struct audio_device *adev) |
| 525 | { |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 526 | char platform[PROPERTY_VALUE_MAX]; |
| 527 | char baseband[PROPERTY_VALUE_MAX]; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 528 | char value[PROPERTY_VALUE_MAX]; |
Apoorv Raghuvanshi | 84fa2fe | 2013-12-04 11:57:47 -0800 | [diff] [blame] | 529 | struct platform_data *my_data = NULL; |
| 530 | int retry_num = 0, snd_card_num = 0; |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 531 | const char *snd_card_name; |
sangwoo | 1b9f4b3 | 2013-06-21 18:22:55 -0700 | [diff] [blame] | 532 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 533 | my_data = calloc(1, sizeof(struct platform_data)); |
| 534 | |
Apoorv Raghuvanshi | 84fa2fe | 2013-12-04 11:57:47 -0800 | [diff] [blame] | 535 | while (snd_card_num < MAX_SND_CARD) { |
| 536 | adev->mixer = mixer_open(snd_card_num); |
| 537 | |
| 538 | while (!adev->mixer && retry_num < RETRY_NUMBER) { |
| 539 | usleep(RETRY_US); |
| 540 | adev->mixer = mixer_open(snd_card_num); |
| 541 | retry_num++; |
| 542 | } |
| 543 | |
| 544 | if (!adev->mixer) { |
| 545 | ALOGE("%s: Unable to open the mixer card: %d", __func__, |
| 546 | snd_card_num); |
| 547 | retry_num = 0; |
| 548 | snd_card_num++; |
| 549 | continue; |
| 550 | } |
| 551 | |
| 552 | snd_card_name = mixer_get_name(adev->mixer); |
| 553 | ALOGV("%s: snd_card_name: %s", __func__, snd_card_name); |
| 554 | |
| 555 | my_data->hw_info = hw_info_init(snd_card_name); |
| 556 | if (!my_data->hw_info) { |
| 557 | ALOGE("%s: Failed to init hardware info", __func__); |
| 558 | } else { |
| 559 | if (audio_extn_read_xml(adev, snd_card_num, MIXER_XML_PATH, |
| 560 | MIXER_XML_PATH_AUXPCM) == -ENOSYS) |
| 561 | adev->audio_route = audio_route_init(snd_card_num, |
| 562 | MIXER_XML_PATH); |
| 563 | if (!adev->audio_route) { |
| 564 | ALOGE("%s: Failed to init audio route controls, aborting.", |
| 565 | __func__); |
| 566 | free(my_data); |
| 567 | return NULL; |
| 568 | } |
| 569 | adev->snd_card = snd_card_num; |
| 570 | ALOGD("%s: Opened sound card:%d", __func__, snd_card_num); |
| 571 | break; |
| 572 | } |
| 573 | retry_num = 0; |
| 574 | snd_card_num++; |
| 575 | } |
| 576 | |
| 577 | if (snd_card_num >= MAX_SND_CARD) { |
| 578 | ALOGE("%s: Unable to find correct sound card, aborting.", __func__); |
| 579 | free(my_data); |
| 580 | return NULL; |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 581 | } |
| 582 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 583 | my_data->adev = adev; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 584 | my_data->btsco_sample_rate = SAMPLE_RATE_8KHZ; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 585 | my_data->fluence_in_spkr_mode = false; |
| 586 | my_data->fluence_in_voice_call = false; |
| 587 | my_data->fluence_in_voice_rec = false; |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 588 | my_data->fluence_in_audio_rec = false; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 589 | my_data->fluence_type = FLUENCE_NONE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 590 | |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 591 | property_get("ro.qc.sdk.audio.fluencetype", value, ""); |
| 592 | if (!strncmp("fluencepro", value, sizeof("fluencepro"))) { |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 593 | my_data->fluence_type = FLUENCE_QUAD_MIC | FLUENCE_DUAL_MIC; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 594 | } else if (!strncmp("fluence", value, sizeof("fluence"))) { |
| 595 | my_data->fluence_type = FLUENCE_DUAL_MIC; |
| 596 | } else { |
| 597 | my_data->fluence_type = FLUENCE_NONE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 598 | } |
| 599 | |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 600 | if (my_data->fluence_type != FLUENCE_NONE) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 601 | property_get("persist.audio.fluence.voicecall",value,""); |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 602 | if (!strncmp("true", value, sizeof("true"))) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 603 | my_data->fluence_in_voice_call = true; |
| 604 | } |
| 605 | |
| 606 | property_get("persist.audio.fluence.voicerec",value,""); |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 607 | if (!strncmp("true", value, sizeof("true"))) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 608 | my_data->fluence_in_voice_rec = true; |
| 609 | } |
| 610 | |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 611 | property_get("persist.audio.fluence.audiorec",value,""); |
| 612 | if (!strncmp("true", value, sizeof("true"))) { |
| 613 | my_data->fluence_in_audio_rec = true; |
| 614 | } |
| 615 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 616 | property_get("persist.audio.fluence.speaker",value,""); |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 617 | if (!strncmp("true", value, sizeof("true"))) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 618 | my_data->fluence_in_spkr_mode = true; |
| 619 | } |
| 620 | } |
| 621 | |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 622 | my_data->voice_feature_set = VOICE_FEATURE_SET_DEFAULT; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 623 | my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); |
| 624 | if (my_data->acdb_handle == NULL) { |
| 625 | ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER); |
| 626 | } else { |
| 627 | ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER); |
| 628 | my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle, |
| 629 | "acdb_loader_deallocate_ACDB"); |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 630 | if (!my_data->acdb_deallocate) |
| 631 | ALOGE("%s: Could not find the symbol acdb_loader_deallocate_ACDB from %s", |
| 632 | __func__, LIB_ACDB_LOADER); |
| 633 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 634 | my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle, |
| 635 | "acdb_loader_send_audio_cal"); |
| 636 | if (!my_data->acdb_send_audio_cal) |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 637 | 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] | 638 | __func__, LIB_ACDB_LOADER); |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 639 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 640 | my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle, |
| 641 | "acdb_loader_send_voice_cal"); |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 642 | if (!my_data->acdb_send_voice_cal) |
| 643 | ALOGE("%s: Could not find the symbol acdb_loader_send_voice_cal from %s", |
| 644 | __func__, LIB_ACDB_LOADER); |
| 645 | |
| 646 | my_data->acdb_reload_vocvoltable = (acdb_reload_vocvoltable_t)dlsym(my_data->acdb_handle, |
| 647 | "acdb_loader_reload_vocvoltable"); |
| 648 | if (!my_data->acdb_reload_vocvoltable) |
| 649 | ALOGE("%s: Could not find the symbol acdb_loader_reload_vocvoltable from %s", |
| 650 | __func__, LIB_ACDB_LOADER); |
| 651 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 652 | my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, |
Ben Romberger | 490d347 | 2014-01-15 17:11:59 -0800 | [diff] [blame] | 653 | "acdb_loader_init_v2"); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 654 | if (my_data->acdb_init == NULL) |
Ben Romberger | 490d347 | 2014-01-15 17:11:59 -0800 | [diff] [blame] | 655 | ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror()); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 656 | else |
Ben Romberger | 490d347 | 2014-01-15 17:11:59 -0800 | [diff] [blame] | 657 | my_data->acdb_init(snd_card_name); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 658 | } |
| 659 | |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 660 | /* Initialize ACDB ID's */ |
| 661 | platform_info_init(); |
| 662 | |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 663 | /* If platform is apq8084 and baseband is MDM, load CSD Client specific |
| 664 | * symbols. Voice call is handled by MDM and apps processor talks to |
| 665 | * MDM through CSD Client |
| 666 | */ |
| 667 | property_get("ro.board.platform", platform, ""); |
| 668 | property_get("ro.baseband", baseband, ""); |
| 669 | if (!strncmp("apq8084", platform, sizeof("apq8084")) && |
| 670 | !strncmp("mdm", baseband, sizeof("mdm"))) { |
| 671 | my_data->csd = open_csd_client(); |
| 672 | } |
| 673 | |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 674 | /* init usb */ |
| 675 | audio_extn_usb_init(adev); |
Apoorv Raghuvanshi | 84fa2fe | 2013-12-04 11:57:47 -0800 | [diff] [blame] | 676 | /* update sound cards appropriately */ |
| 677 | audio_extn_usb_set_proxy_sound_card(adev->snd_card); |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 678 | |
Apoorv Raghuvanshi | 6178a3f | 2013-10-19 12:38:54 -0700 | [diff] [blame] | 679 | /* Read one time ssr property */ |
Mingming Yin | 49be803 | 2013-12-19 12:51:25 -0800 | [diff] [blame] | 680 | audio_extn_ssr_update_enabled(); |
Gopikrishnaiah Anandan | f538cef | 2013-10-28 14:06:03 -0700 | [diff] [blame] | 681 | audio_extn_spkr_prot_init(adev); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 682 | return my_data; |
| 683 | } |
| 684 | |
| 685 | void platform_deinit(void *platform) |
| 686 | { |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 687 | struct platform_data *my_data = (struct platform_data *)platform; |
| 688 | |
| 689 | hw_info_deinit(my_data->hw_info); |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 690 | close_csd_client(my_data->csd); |
| 691 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 692 | free(platform); |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 693 | /* deinit usb */ |
| 694 | audio_extn_usb_deinit(); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | const char *platform_get_snd_device_name(snd_device_t snd_device) |
| 698 | { |
| 699 | if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) |
| 700 | return device_table[snd_device]; |
| 701 | else |
| 702 | return ""; |
| 703 | } |
| 704 | |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 705 | int platform_get_snd_device_name_extn(void *platform, snd_device_t snd_device, |
| 706 | char *device_name) |
| 707 | { |
| 708 | struct platform_data *my_data = (struct platform_data *)platform; |
| 709 | |
| 710 | if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) { |
| 711 | strlcpy(device_name, device_table[snd_device], DEVICE_NAME_MAX_SIZE); |
| 712 | hw_info_append_hw_type(my_data->hw_info, snd_device, device_name); |
| 713 | } else { |
| 714 | strlcpy(device_name, "", DEVICE_NAME_MAX_SIZE); |
| 715 | return -EINVAL; |
| 716 | } |
| 717 | |
| 718 | return 0; |
| 719 | } |
| 720 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 721 | void platform_add_backend_name(char *mixer_path, snd_device_t snd_device) |
| 722 | { |
| 723 | if (snd_device == SND_DEVICE_IN_BT_SCO_MIC) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 724 | strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH); |
| 725 | else if (snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB) |
| 726 | strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 727 | else if(snd_device == SND_DEVICE_OUT_BT_SCO) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 728 | strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH); |
| 729 | else if(snd_device == SND_DEVICE_OUT_BT_SCO_WB) |
| 730 | strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 731 | else if (snd_device == SND_DEVICE_OUT_HDMI) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 732 | strlcat(mixer_path, " hdmi", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 733 | else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI) |
| 734 | strcat(mixer_path, " speaker-and-hdmi"); |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 735 | else if (snd_device == SND_DEVICE_OUT_AFE_PROXY) |
| 736 | strlcat(mixer_path, " afe-proxy", MIXER_PATH_MAX_LENGTH); |
| 737 | else if (snd_device == SND_DEVICE_OUT_USB_HEADSET) |
| 738 | strlcat(mixer_path, " usb-headphones", MIXER_PATH_MAX_LENGTH); |
| 739 | else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET) |
| 740 | strlcat(mixer_path, " speaker-and-usb-headphones", |
| 741 | MIXER_PATH_MAX_LENGTH); |
| 742 | else if (snd_device == SND_DEVICE_IN_USB_HEADSET_MIC) |
| 743 | strlcat(mixer_path, " usb-headset-mic", MIXER_PATH_MAX_LENGTH); |
Apoorv Raghuvanshi | 6e26284 | 2013-10-06 14:39:35 -0700 | [diff] [blame] | 744 | else if (snd_device == SND_DEVICE_IN_CAPTURE_FM) |
| 745 | strlcat(mixer_path, " capture-fm", MIXER_PATH_MAX_LENGTH); |
| 746 | else if (snd_device == SND_DEVICE_OUT_TRANSMISSION_FM) |
| 747 | strlcat(mixer_path, " transmission-fm", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) |
| 751 | { |
| 752 | int device_id; |
| 753 | if (device_type == PCM_PLAYBACK) |
| 754 | device_id = pcm_device_table[usecase][0]; |
| 755 | else |
| 756 | device_id = pcm_device_table[usecase][1]; |
| 757 | return device_id; |
| 758 | } |
| 759 | |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 760 | int platform_get_snd_device_index(char *snd_device_index_name) |
| 761 | { |
| 762 | int ret = 0; |
| 763 | int i; |
| 764 | |
| 765 | if (snd_device_index_name == NULL) { |
| 766 | ALOGE("%s: snd_device_index_name is NULL", __func__); |
| 767 | ret = -ENODEV; |
| 768 | goto done; |
| 769 | } |
| 770 | |
| 771 | for (i=0; i < SND_DEVICE_MAX; i++) { |
| 772 | if(strcmp(snd_device_name_index[i].name, snd_device_index_name) == 0) { |
| 773 | ret = snd_device_name_index[i].index; |
| 774 | goto done; |
| 775 | } |
| 776 | } |
| 777 | ALOGE("%s: Could not find index for snd_device_index_name = %s", |
| 778 | __func__, snd_device_index_name); |
| 779 | ret = -ENODEV; |
| 780 | done: |
| 781 | return ret; |
| 782 | } |
| 783 | |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 784 | int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id) |
| 785 | { |
| 786 | int ret = 0; |
| 787 | |
| 788 | if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { |
| 789 | ALOGE("%s: Invalid snd_device = %d", |
| 790 | __func__, snd_device); |
| 791 | ret = -EINVAL; |
| 792 | goto done; |
| 793 | } |
| 794 | |
| 795 | acdb_device_table[snd_device] = acdb_id; |
| 796 | done: |
| 797 | return ret; |
| 798 | } |
| 799 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 800 | int platform_send_audio_calibration(void *platform, snd_device_t snd_device) |
| 801 | { |
| 802 | struct platform_data *my_data = (struct platform_data *)platform; |
| 803 | int acdb_dev_id, acdb_dev_type; |
| 804 | |
| 805 | acdb_dev_id = acdb_device_table[snd_device]; |
| 806 | if (acdb_dev_id < 0) { |
| 807 | ALOGE("%s: Could not find acdb id for device(%d)", |
| 808 | __func__, snd_device); |
| 809 | return -EINVAL; |
| 810 | } |
| 811 | if (my_data->acdb_send_audio_cal) { |
Eric Laurent | 994a693 | 2013-07-17 11:51:42 -0700 | [diff] [blame] | 812 | ("%s: sending audio calibration for snd_device(%d) acdb_id(%d)", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 813 | __func__, snd_device, acdb_dev_id); |
| 814 | if (snd_device >= SND_DEVICE_OUT_BEGIN && |
| 815 | snd_device < SND_DEVICE_OUT_END) |
| 816 | acdb_dev_type = ACDB_DEV_TYPE_OUT; |
| 817 | else |
| 818 | acdb_dev_type = ACDB_DEV_TYPE_IN; |
| 819 | my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type); |
| 820 | } |
| 821 | return 0; |
| 822 | } |
| 823 | |
| 824 | int platform_switch_voice_call_device_pre(void *platform) |
| 825 | { |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 826 | struct platform_data *my_data = (struct platform_data *)platform; |
| 827 | int ret = 0; |
| 828 | |
Vidyakumar Athota | 1fd2179 | 2013-11-15 14:50:57 -0800 | [diff] [blame] | 829 | if (my_data->csd != NULL && |
| 830 | my_data->adev->mode == AUDIO_MODE_IN_CALL) { |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 831 | /* This must be called before disabling mixer controls on APQ side */ |
| 832 | ret = my_data->csd->disable_device(); |
| 833 | if (ret < 0) { |
| 834 | ALOGE("%s: csd_client_disable_device, failed, error %d", |
| 835 | __func__, ret); |
| 836 | } |
| 837 | } |
| 838 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 839 | } |
| 840 | |
Vidyakumar Athota | 545dbd3 | 2013-11-13 17:30:53 -0800 | [diff] [blame] | 841 | int platform_switch_voice_call_enable_device_config(void *platform, |
| 842 | snd_device_t out_snd_device, |
| 843 | snd_device_t in_snd_device) |
| 844 | { |
| 845 | struct platform_data *my_data = (struct platform_data *)platform; |
| 846 | int acdb_rx_id, acdb_tx_id; |
| 847 | int ret = 0; |
| 848 | |
| 849 | acdb_rx_id = acdb_device_table[out_snd_device]; |
| 850 | acdb_tx_id = acdb_device_table[in_snd_device]; |
| 851 | |
| 852 | if (my_data->csd != NULL) { |
| 853 | if (acdb_rx_id > 0 && acdb_tx_id > 0) { |
| 854 | ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id); |
| 855 | if (ret < 0) { |
| 856 | ALOGE("%s: csd_enable_device_config, failed, error %d", |
| 857 | __func__, ret); |
| 858 | } |
| 859 | } else { |
| 860 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 861 | acdb_rx_id, acdb_tx_id); |
| 862 | } |
| 863 | } |
| 864 | return ret; |
| 865 | } |
| 866 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 867 | int platform_switch_voice_call_device_post(void *platform, |
| 868 | snd_device_t out_snd_device, |
| 869 | snd_device_t in_snd_device) |
| 870 | { |
| 871 | struct platform_data *my_data = (struct platform_data *)platform; |
| 872 | int acdb_rx_id, acdb_tx_id; |
| 873 | |
| 874 | if (my_data->acdb_send_voice_cal == NULL) { |
| 875 | ALOGE("%s: dlsym error for acdb_send_voice_call", __func__); |
| 876 | } else { |
Vidyakumar Athota | 1fd2179 | 2013-11-15 14:50:57 -0800 | [diff] [blame] | 877 | acdb_rx_id = acdb_device_table[out_snd_device]; |
| 878 | acdb_tx_id = acdb_device_table[in_snd_device]; |
| 879 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 880 | if (acdb_rx_id > 0 && acdb_tx_id > 0) |
| 881 | my_data->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id); |
| 882 | else |
| 883 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 884 | acdb_rx_id, acdb_tx_id); |
| 885 | } |
| 886 | |
Vidyakumar Athota | 1fd2179 | 2013-11-15 14:50:57 -0800 | [diff] [blame] | 887 | return 0; |
| 888 | } |
| 889 | |
| 890 | int platform_switch_voice_call_usecase_route_post(void *platform, |
| 891 | snd_device_t out_snd_device, |
| 892 | snd_device_t in_snd_device) |
| 893 | { |
| 894 | struct platform_data *my_data = (struct platform_data *)platform; |
| 895 | int acdb_rx_id, acdb_tx_id; |
| 896 | int ret = 0; |
| 897 | |
| 898 | acdb_rx_id = acdb_device_table[out_snd_device]; |
| 899 | acdb_tx_id = acdb_device_table[in_snd_device]; |
| 900 | |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 901 | if (my_data->csd != NULL) { |
Vidyakumar Athota | 1fd2179 | 2013-11-15 14:50:57 -0800 | [diff] [blame] | 902 | if (acdb_rx_id > 0 && acdb_tx_id > 0) { |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 903 | ret = my_data->csd->enable_device(acdb_rx_id, acdb_tx_id, |
| 904 | my_data->adev->acdb_settings); |
| 905 | if (ret < 0) { |
| 906 | ALOGE("%s: csd_enable_device, failed, error %d", |
| 907 | __func__, ret); |
| 908 | } |
| 909 | } else { |
| 910 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 911 | acdb_rx_id, acdb_tx_id); |
| 912 | } |
| 913 | } |
| 914 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 915 | } |
| 916 | |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 917 | int platform_start_voice_call(void *platform, uint32_t vsid) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 918 | { |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 919 | struct platform_data *my_data = (struct platform_data *)platform; |
| 920 | int ret = 0; |
| 921 | |
| 922 | if (my_data->csd != NULL) { |
| 923 | ret = my_data->csd->start_voice(vsid); |
| 924 | if (ret < 0) { |
| 925 | ALOGE("%s: csd_start_voice error %d\n", __func__, ret); |
| 926 | } |
| 927 | } |
| 928 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 929 | } |
| 930 | |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 931 | int platform_stop_voice_call(void *platform, uint32_t vsid) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 932 | { |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 933 | struct platform_data *my_data = (struct platform_data *)platform; |
| 934 | int ret = 0; |
| 935 | |
| 936 | if (my_data->csd != NULL) { |
| 937 | ret = my_data->csd->stop_voice(vsid); |
| 938 | if (ret < 0) { |
| 939 | ALOGE("%s: csd_stop_voice error %d\n", __func__, ret); |
| 940 | } |
| 941 | } |
| 942 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | int platform_set_voice_volume(void *platform, int volume) |
| 946 | { |
| 947 | struct platform_data *my_data = (struct platform_data *)platform; |
| 948 | struct audio_device *adev = my_data->adev; |
| 949 | struct mixer_ctl *ctl; |
sangwoo | 53b2cf0 | 2013-07-25 19:18:44 -0700 | [diff] [blame] | 950 | const char *mixer_ctl_name = "Voice Rx Gain"; |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 951 | int vol_index = 0, ret = 0; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 952 | uint32_t set_values[ ] = {0, |
| 953 | ALL_SESSION_VSID, |
| 954 | DEFAULT_VOLUME_RAMP_DURATION_MS}; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 955 | |
| 956 | // Voice volume levels are mapped to adsp volume levels as follows. |
| 957 | // 100 -> 5, 80 -> 4, 60 -> 3, 40 -> 2, 20 -> 1 0 -> 0 |
| 958 | // But this values don't changed in kernel. So, below change is need. |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 959 | vol_index = (int)percent_to_index(volume, MIN_VOL_INDEX, MAX_VOL_INDEX); |
| 960 | set_values[0] = vol_index; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 961 | |
| 962 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 963 | if (!ctl) { |
| 964 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 965 | __func__, mixer_ctl_name); |
| 966 | return -EINVAL; |
| 967 | } |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 968 | ALOGV("Setting voice volume index: %d", set_values[0]); |
| 969 | mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 970 | |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 971 | if (my_data->csd != NULL) { |
| 972 | ret = my_data->csd->volume(ALL_SESSION_VSID, volume); |
| 973 | if (ret < 0) { |
| 974 | ALOGE("%s: csd_volume error %d", __func__, ret); |
| 975 | } |
| 976 | } |
| 977 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | int platform_set_mic_mute(void *platform, bool state) |
| 981 | { |
| 982 | struct platform_data *my_data = (struct platform_data *)platform; |
| 983 | struct audio_device *adev = my_data->adev; |
| 984 | struct mixer_ctl *ctl; |
| 985 | const char *mixer_ctl_name = "Voice Tx Mute"; |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 986 | int ret = 0; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 987 | uint32_t set_values[ ] = {0, |
| 988 | ALL_SESSION_VSID, |
| 989 | DEFAULT_VOLUME_RAMP_DURATION_MS}; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 990 | |
Narsinga Rao Chella | 05573b7 | 2013-11-15 15:21:40 -0800 | [diff] [blame] | 991 | set_values[0] = state; |
| 992 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 993 | if (!ctl) { |
| 994 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 995 | __func__, mixer_ctl_name); |
| 996 | return -EINVAL; |
| 997 | } |
| 998 | ALOGV("Setting voice mute state: %d", state); |
| 999 | mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1000 | |
Narsinga Rao Chella | 05573b7 | 2013-11-15 15:21:40 -0800 | [diff] [blame] | 1001 | if (my_data->csd != NULL) { |
| 1002 | ret = my_data->csd->mic_mute(ALL_SESSION_VSID, state); |
| 1003 | if (ret < 0) { |
| 1004 | ALOGE("%s: csd_mic_mute error %d", __func__, ret); |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 1005 | } |
| 1006 | } |
| 1007 | return ret; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices) |
| 1011 | { |
| 1012 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1013 | struct audio_device *adev = my_data->adev; |
| 1014 | audio_mode_t mode = adev->mode; |
| 1015 | snd_device_t snd_device = SND_DEVICE_NONE; |
| 1016 | |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 1017 | audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? |
| 1018 | AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; |
| 1019 | int channel_count = popcount(channel_mask); |
| 1020 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1021 | ALOGV("%s: enter: output devices(%#x)", __func__, devices); |
| 1022 | if (devices == AUDIO_DEVICE_NONE || |
| 1023 | devices & AUDIO_DEVICE_BIT_IN) { |
| 1024 | ALOGV("%s: Invalid output devices (%#x)", __func__, devices); |
| 1025 | goto exit; |
| 1026 | } |
| 1027 | |
Mingming Yin | 4a72d65 | 2014-01-03 18:54:18 -0800 | [diff] [blame] | 1028 | if (popcount(devices) == 2) { |
| 1029 | if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | |
| 1030 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 1031 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; |
| 1032 | } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | |
| 1033 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 1034 | if (audio_extn_get_anc_enabled()) |
| 1035 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET; |
| 1036 | else |
| 1037 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; |
| 1038 | } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL | |
| 1039 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 1040 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI; |
| 1041 | } else if (devices == (AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET | |
| 1042 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 1043 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET; |
| 1044 | } else { |
| 1045 | ALOGE("%s: Invalid combo device(%#x)", __func__, devices); |
| 1046 | goto exit; |
| 1047 | } |
| 1048 | if (snd_device != SND_DEVICE_NONE) { |
| 1049 | goto exit; |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | if (popcount(devices) != 1) { |
| 1054 | ALOGE("%s: Invalid output devices(%#x)", __func__, devices); |
| 1055 | goto exit; |
| 1056 | } |
| 1057 | |
Narsinga Rao Chella | 05573b7 | 2013-11-15 15:21:40 -0800 | [diff] [blame] | 1058 | if ((mode == AUDIO_MODE_IN_CALL) || |
| 1059 | voice_extn_compress_voip_is_active(adev)) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1060 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 1061 | devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
Narsinga Rao Chella | 05573b7 | 2013-11-15 15:21:40 -0800 | [diff] [blame] | 1062 | if ((adev->voice.tty_mode != TTY_MODE_OFF) && |
| 1063 | !voice_extn_compress_voip_is_active(adev)) { |
| 1064 | switch (adev->voice.tty_mode) { |
| 1065 | case TTY_MODE_FULL: |
| 1066 | snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES; |
| 1067 | break; |
| 1068 | case TTY_MODE_VCO: |
| 1069 | snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES; |
| 1070 | break; |
| 1071 | case TTY_MODE_HCO: |
| 1072 | snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET; |
| 1073 | break; |
| 1074 | default: |
| 1075 | ALOGE("%s: Invalid TTY mode (%#x)", |
| 1076 | __func__, adev->voice.tty_mode); |
| 1077 | } |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1078 | } else if (audio_extn_get_anc_enabled()) { |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 1079 | if (audio_extn_should_use_fb_anc()) |
| 1080 | snd_device = SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET; |
| 1081 | else |
| 1082 | snd_device = SND_DEVICE_OUT_VOICE_ANC_HEADSET; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1083 | } else { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1084 | snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1085 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1086 | } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1087 | if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ) |
| 1088 | snd_device = SND_DEVICE_OUT_BT_SCO_WB; |
| 1089 | else |
| 1090 | snd_device = SND_DEVICE_OUT_BT_SCO; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1091 | } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { |
| 1092 | snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 1093 | } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET || |
| 1094 | devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) { |
| 1095 | snd_device = SND_DEVICE_OUT_USB_HEADSET; |
Apoorv Raghuvanshi | 6e26284 | 2013-10-06 14:39:35 -0700 | [diff] [blame] | 1096 | } else if (devices & AUDIO_DEVICE_OUT_FM_TX) { |
| 1097 | snd_device = SND_DEVICE_OUT_TRANSMISSION_FM; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1098 | } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { |
Ravi Kumar Alamanda | ceb4082 | 2013-11-06 11:01:47 -0800 | [diff] [blame] | 1099 | if (audio_extn_should_use_handset_anc(channel_count)) |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 1100 | snd_device = SND_DEVICE_OUT_ANC_HANDSET; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1101 | else |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 1102 | snd_device = SND_DEVICE_OUT_VOICE_HANDSET; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1103 | } |
| 1104 | if (snd_device != SND_DEVICE_NONE) { |
| 1105 | goto exit; |
| 1106 | } |
| 1107 | } |
| 1108 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1109 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 1110 | devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 1111 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET |
| 1112 | && audio_extn_get_anc_enabled()) { |
| 1113 | if (audio_extn_should_use_fb_anc()) |
| 1114 | snd_device = SND_DEVICE_OUT_ANC_FB_HEADSET; |
| 1115 | else |
| 1116 | snd_device = SND_DEVICE_OUT_ANC_HEADSET; |
| 1117 | } |
| 1118 | else |
| 1119 | snd_device = SND_DEVICE_OUT_HEADPHONES; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1120 | } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { |
| 1121 | if (adev->speaker_lr_swap) |
| 1122 | snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE; |
| 1123 | else |
| 1124 | snd_device = SND_DEVICE_OUT_SPEAKER; |
| 1125 | } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1126 | if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ) |
| 1127 | snd_device = SND_DEVICE_OUT_BT_SCO_WB; |
| 1128 | else |
| 1129 | snd_device = SND_DEVICE_OUT_BT_SCO; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1130 | } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 1131 | snd_device = SND_DEVICE_OUT_HDMI ; |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 1132 | } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET || |
| 1133 | devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) { |
| 1134 | snd_device = SND_DEVICE_OUT_USB_HEADSET; |
Apoorv Raghuvanshi | 6e26284 | 2013-10-06 14:39:35 -0700 | [diff] [blame] | 1135 | } else if (devices & AUDIO_DEVICE_OUT_FM_TX) { |
| 1136 | snd_device = SND_DEVICE_OUT_TRANSMISSION_FM; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1137 | } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { |
| 1138 | snd_device = SND_DEVICE_OUT_HANDSET; |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 1139 | } else if (devices & AUDIO_DEVICE_OUT_PROXY) { |
| 1140 | ALOGD("%s: setting sink capability for Proxy", __func__); |
| 1141 | audio_extn_set_afe_proxy_channel_mixer(adev); |
| 1142 | snd_device = SND_DEVICE_OUT_AFE_PROXY; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1143 | } else { |
| 1144 | ALOGE("%s: Unknown device(s) %#x", __func__, devices); |
| 1145 | } |
| 1146 | exit: |
| 1147 | ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]); |
| 1148 | return snd_device; |
| 1149 | } |
| 1150 | |
| 1151 | snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device) |
| 1152 | { |
| 1153 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1154 | struct audio_device *adev = my_data->adev; |
| 1155 | audio_source_t source = (adev->active_input == NULL) ? |
| 1156 | AUDIO_SOURCE_DEFAULT : adev->active_input->source; |
| 1157 | |
| 1158 | audio_mode_t mode = adev->mode; |
| 1159 | audio_devices_t in_device = ((adev->active_input == NULL) ? |
| 1160 | AUDIO_DEVICE_NONE : adev->active_input->device) |
| 1161 | & ~AUDIO_DEVICE_BIT_IN; |
| 1162 | audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? |
| 1163 | AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; |
| 1164 | snd_device_t snd_device = SND_DEVICE_NONE; |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 1165 | int channel_count = popcount(channel_mask); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1166 | |
| 1167 | ALOGV("%s: enter: out_device(%#x) in_device(%#x)", |
| 1168 | __func__, out_device, in_device); |
Helen Zeng | 067b96b | 2013-11-26 12:10:29 -0800 | [diff] [blame] | 1169 | if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || |
| 1170 | voice_extn_compress_voip_is_active(adev))) { |
Narsinga Rao Chella | 05573b7 | 2013-11-15 15:21:40 -0800 | [diff] [blame] | 1171 | if ((adev->voice.tty_mode != TTY_MODE_OFF) && |
| 1172 | !voice_extn_compress_voip_is_active(adev)) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1173 | if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 1174 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1175 | switch (adev->voice.tty_mode) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1176 | case TTY_MODE_FULL: |
| 1177 | snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC; |
| 1178 | break; |
| 1179 | case TTY_MODE_VCO: |
| 1180 | snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC; |
| 1181 | break; |
| 1182 | case TTY_MODE_HCO: |
| 1183 | snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC; |
| 1184 | break; |
| 1185 | default: |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1186 | ALOGE("%s: Invalid TTY mode (%#x)", |
| 1187 | __func__, adev->voice.tty_mode); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1188 | } |
| 1189 | goto exit; |
| 1190 | } |
| 1191 | } |
| 1192 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE || |
| 1193 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { |
Apoorv Raghuvanshi | 9eaf94e | 2013-10-04 16:13:44 -0700 | [diff] [blame] | 1194 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE && |
| 1195 | audio_extn_should_use_handset_anc(channel_count)) { |
| 1196 | snd_device = SND_DEVICE_IN_AANC_HANDSET_MIC; |
| 1197 | } else if (my_data->fluence_type == FLUENCE_NONE || |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 1198 | my_data->fluence_in_voice_call == false) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1199 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
Laxminath Kasam | 7294f52 | 2013-12-11 05:07:00 +0530 | [diff] [blame] | 1200 | set_echo_reference(adev->mixer, EC_REF_RX); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1201 | } else { |
Ravi Kumar Alamanda | ceb4082 | 2013-11-06 11:01:47 -0800 | [diff] [blame] | 1202 | snd_device = SND_DEVICE_IN_VOICE_DMIC; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 1203 | adev->acdb_settings |= DMIC_FLAG; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1204 | } |
| 1205 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 1206 | snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; |
| 1207 | } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1208 | if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ) |
| 1209 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 1210 | else |
| 1211 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1212 | } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 1213 | if (my_data->fluence_type != FLUENCE_NONE && |
| 1214 | my_data->fluence_in_voice_call && |
| 1215 | my_data->fluence_in_spkr_mode) { |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 1216 | if(my_data->fluence_type & FLUENCE_QUAD_MIC) { |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 1217 | adev->acdb_settings |= QMIC_FLAG; |
| 1218 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_QMIC; |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 1219 | } else { |
| 1220 | adev->acdb_settings |= DMIC_FLAG; |
| 1221 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 1222 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1223 | } else { |
| 1224 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; |
| 1225 | } |
| 1226 | } |
| 1227 | } else if (source == AUDIO_SOURCE_CAMCORDER) { |
| 1228 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || |
| 1229 | in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 1230 | snd_device = SND_DEVICE_IN_CAMCORDER_MIC; |
| 1231 | } |
| 1232 | } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) { |
| 1233 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 1234 | if (channel_count == 2) { |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 1235 | snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_STEREO; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 1236 | adev->acdb_settings |= DMIC_FLAG; |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 1237 | } else if (adev->active_input->enable_ns) |
| 1238 | snd_device = SND_DEVICE_IN_VOICE_REC_MIC_NS; |
| 1239 | else if (my_data->fluence_type != FLUENCE_NONE && |
| 1240 | my_data->fluence_in_voice_rec) { |
| 1241 | snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE; |
| 1242 | adev->acdb_settings |= DMIC_FLAG; |
| 1243 | } else { |
| 1244 | snd_device = SND_DEVICE_IN_VOICE_REC_MIC; |
| 1245 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1246 | } |
| 1247 | } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) { |
| 1248 | if (out_device & AUDIO_DEVICE_OUT_SPEAKER) |
| 1249 | in_device = AUDIO_DEVICE_IN_BACK_MIC; |
| 1250 | if (adev->active_input) { |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 1251 | if (adev->active_input->enable_aec && |
| 1252 | adev->active_input->enable_ns) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1253 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 1254 | if (my_data->fluence_type & FLUENCE_DUAL_MIC && |
| 1255 | my_data->fluence_in_spkr_mode) { |
| 1256 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS; |
| 1257 | adev->acdb_settings |= DMIC_FLAG; |
| 1258 | } else |
| 1259 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC_NS; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1260 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 1261 | if (my_data->fluence_type & FLUENCE_DUAL_MIC) { |
| 1262 | snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC_NS; |
| 1263 | adev->acdb_settings |= DMIC_FLAG; |
| 1264 | } else |
| 1265 | snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC_NS; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1266 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 1267 | snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1268 | } |
Laxminath Kasam | 7294f52 | 2013-12-11 05:07:00 +0530 | [diff] [blame] | 1269 | set_echo_reference(adev->mixer, EC_REF_RX); |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 1270 | } else if (adev->active_input->enable_aec) { |
| 1271 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 1272 | if (my_data->fluence_type & FLUENCE_DUAL_MIC) { |
| 1273 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC; |
| 1274 | adev->acdb_settings |= DMIC_FLAG; |
| 1275 | } else |
| 1276 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; |
| 1277 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
| 1278 | if (my_data->fluence_type & FLUENCE_DUAL_MIC) { |
| 1279 | snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC; |
| 1280 | adev->acdb_settings |= DMIC_FLAG; |
| 1281 | } else |
| 1282 | snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC; |
| 1283 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 1284 | snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE; |
| 1285 | } |
Laxminath Kasam | 7294f52 | 2013-12-11 05:07:00 +0530 | [diff] [blame] | 1286 | set_echo_reference(adev->mixer, EC_REF_RX); |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 1287 | } else if (adev->active_input->enable_ns) { |
| 1288 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 1289 | if (my_data->fluence_type & FLUENCE_DUAL_MIC) { |
| 1290 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS; |
| 1291 | adev->acdb_settings |= DMIC_FLAG; |
| 1292 | } else |
| 1293 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_NS; |
| 1294 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
| 1295 | if (my_data->fluence_type & FLUENCE_DUAL_MIC) { |
| 1296 | snd_device = SND_DEVICE_IN_HANDSET_DMIC_NS; |
| 1297 | adev->acdb_settings |= DMIC_FLAG; |
| 1298 | } else |
| 1299 | snd_device = SND_DEVICE_IN_HANDSET_MIC_NS; |
| 1300 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 1301 | snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE; |
| 1302 | } |
| 1303 | set_echo_reference(adev->mixer, "NONE"); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1304 | } else |
| 1305 | set_echo_reference(adev->mixer, "NONE"); |
| 1306 | } |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 1307 | } else if (source == AUDIO_SOURCE_MIC) { |
Apoorv Raghuvanshi | c053654 | 2013-11-14 16:25:59 -0800 | [diff] [blame] | 1308 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC && |
| 1309 | channel_count == 1 ) { |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 1310 | if(my_data->fluence_type & FLUENCE_DUAL_MIC && |
| 1311 | my_data->fluence_in_audio_rec) |
| 1312 | snd_device = SND_DEVICE_IN_HANDSET_DMIC; |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 1313 | } |
Mingming Yin | ab42978 | 2013-11-07 11:16:55 -0800 | [diff] [blame] | 1314 | } else if (source == AUDIO_SOURCE_FM_RX || |
Ravi Kumar Alamanda | 198185e | 2013-11-07 15:42:19 -0800 | [diff] [blame] | 1315 | source == AUDIO_SOURCE_FM_RX_A2DP) { |
Preetam Singh Ranawat | de84f1a | 2013-11-01 14:58:16 -0700 | [diff] [blame] | 1316 | snd_device = SND_DEVICE_IN_CAPTURE_FM; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1317 | } else if (source == AUDIO_SOURCE_DEFAULT) { |
| 1318 | goto exit; |
| 1319 | } |
| 1320 | |
| 1321 | |
| 1322 | if (snd_device != SND_DEVICE_NONE) { |
| 1323 | goto exit; |
| 1324 | } |
| 1325 | |
| 1326 | if (in_device != AUDIO_DEVICE_NONE && |
| 1327 | !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) && |
| 1328 | !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) { |
| 1329 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Apoorv Raghuvanshi | 6178a3f | 2013-10-19 12:38:54 -0700 | [diff] [blame] | 1330 | if (audio_extn_ssr_get_enabled() && channel_count == 6) |
| 1331 | snd_device = SND_DEVICE_IN_QUAD_MIC; |
Walter Yang | bc136bd | 2014-01-17 11:24:23 +0800 | [diff] [blame] | 1332 | else if (my_data->fluence_type & (FLUENCE_DUAL_MIC | FLUENCE_QUAD_MIC) && |
| 1333 | channel_count == 2) |
Apoorv Raghuvanshi | 6bd8dbf | 2013-10-19 18:37:52 -0700 | [diff] [blame] | 1334 | snd_device = SND_DEVICE_IN_HANDSET_STEREO_DMIC; |
Apoorv Raghuvanshi | 6178a3f | 2013-10-19 12:38:54 -0700 | [diff] [blame] | 1335 | else |
| 1336 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1337 | } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 1338 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
| 1339 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 1340 | snd_device = SND_DEVICE_IN_HEADSET_MIC; |
| 1341 | } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1342 | if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ) |
| 1343 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 1344 | else |
| 1345 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1346 | } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) { |
| 1347 | snd_device = SND_DEVICE_IN_HDMI_MIC; |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 1348 | } else if (in_device & AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET || |
| 1349 | in_device & AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET) { |
| 1350 | snd_device = SND_DEVICE_IN_USB_HEADSET_MIC; |
Apoorv Raghuvanshi | 6e26284 | 2013-10-06 14:39:35 -0700 | [diff] [blame] | 1351 | } else if (in_device & AUDIO_DEVICE_IN_FM_RX) { |
| 1352 | snd_device = SND_DEVICE_IN_CAPTURE_FM; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1353 | } else { |
| 1354 | ALOGE("%s: Unknown input device(s) %#x", __func__, in_device); |
| 1355 | ALOGW("%s: Using default handset-mic", __func__); |
| 1356 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 1357 | } |
| 1358 | } else { |
| 1359 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { |
| 1360 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 1361 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 1362 | snd_device = SND_DEVICE_IN_HEADSET_MIC; |
| 1363 | } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { |
Apoorv Raghuvanshi | 6bd8dbf | 2013-10-19 18:37:52 -0700 | [diff] [blame] | 1364 | if (channel_count > 1) |
| 1365 | snd_device = SND_DEVICE_IN_SPEAKER_STEREO_DMIC; |
| 1366 | else |
| 1367 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1368 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { |
| 1369 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 1370 | } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) { |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1371 | if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ) |
| 1372 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 1373 | else |
| 1374 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1375 | } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 1376 | snd_device = SND_DEVICE_IN_HDMI_MIC; |
Apoorv Raghuvanshi | 5792d4b | 2013-10-07 18:40:05 -0700 | [diff] [blame] | 1377 | } else if (out_device & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET || |
| 1378 | out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) { |
| 1379 | snd_device = SND_DEVICE_IN_USB_HEADSET_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1380 | } else { |
| 1381 | ALOGE("%s: Unknown output device(s) %#x", __func__, out_device); |
| 1382 | ALOGW("%s: Using default handset-mic", __func__); |
| 1383 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 1384 | } |
| 1385 | } |
| 1386 | exit: |
| 1387 | ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]); |
| 1388 | return snd_device; |
| 1389 | } |
| 1390 | |
| 1391 | int platform_set_hdmi_channels(void *platform, int channel_count) |
| 1392 | { |
| 1393 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1394 | struct audio_device *adev = my_data->adev; |
| 1395 | struct mixer_ctl *ctl; |
| 1396 | const char *channel_cnt_str = NULL; |
| 1397 | const char *mixer_ctl_name = "HDMI_RX Channels"; |
| 1398 | switch (channel_count) { |
| 1399 | case 8: |
| 1400 | channel_cnt_str = "Eight"; break; |
| 1401 | case 7: |
| 1402 | channel_cnt_str = "Seven"; break; |
| 1403 | case 6: |
| 1404 | channel_cnt_str = "Six"; break; |
| 1405 | case 5: |
| 1406 | channel_cnt_str = "Five"; break; |
| 1407 | case 4: |
| 1408 | channel_cnt_str = "Four"; break; |
| 1409 | case 3: |
| 1410 | channel_cnt_str = "Three"; break; |
| 1411 | default: |
| 1412 | channel_cnt_str = "Two"; break; |
| 1413 | } |
| 1414 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 1415 | if (!ctl) { |
| 1416 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 1417 | __func__, mixer_ctl_name); |
| 1418 | return -EINVAL; |
| 1419 | } |
| 1420 | ALOGV("HDMI channel count: %s", channel_cnt_str); |
| 1421 | mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); |
| 1422 | return 0; |
| 1423 | } |
| 1424 | |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 1425 | int platform_edid_get_max_channels(void *platform) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1426 | { |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 1427 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1428 | struct audio_device *adev = my_data->adev; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1429 | char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE]; |
| 1430 | char *sad = block; |
| 1431 | int num_audio_blocks; |
| 1432 | int channel_count; |
| 1433 | int max_channels = 0; |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 1434 | int i, ret, count; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1435 | |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 1436 | struct mixer_ctl *ctl; |
| 1437 | |
| 1438 | ctl = mixer_get_ctl_by_name(adev->mixer, AUDIO_DATA_BLOCK_MIXER_CTL); |
| 1439 | if (!ctl) { |
| 1440 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 1441 | __func__, AUDIO_DATA_BLOCK_MIXER_CTL); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1442 | return 0; |
| 1443 | } |
| 1444 | |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 1445 | mixer_ctl_update(ctl); |
| 1446 | |
| 1447 | count = mixer_ctl_get_num_values(ctl); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1448 | |
| 1449 | /* Read SAD blocks, clamping the maximum size for safety */ |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 1450 | if (count > (int)sizeof(block)) |
| 1451 | count = (int)sizeof(block); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1452 | |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 1453 | ret = mixer_ctl_get_array(ctl, block, count); |
| 1454 | if (ret != 0) { |
| 1455 | ALOGE("%s: mixer_ctl_get_array() failed to get EDID info", __func__); |
| 1456 | return 0; |
| 1457 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1458 | |
| 1459 | /* Calculate the number of SAD blocks */ |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 1460 | num_audio_blocks = count / SAD_BLOCK_SIZE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1461 | |
| 1462 | for (i = 0; i < num_audio_blocks; i++) { |
| 1463 | /* Only consider LPCM blocks */ |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 1464 | if ((sad[0] >> 3) != EDID_FORMAT_LPCM) { |
| 1465 | sad += 3; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1466 | continue; |
Haynes Mathew George | 47cd4cb | 2013-07-19 11:58:50 -0700 | [diff] [blame] | 1467 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1468 | |
| 1469 | channel_count = (sad[0] & 0x7) + 1; |
| 1470 | if (channel_count > max_channels) |
| 1471 | max_channels = channel_count; |
| 1472 | |
| 1473 | /* Advance to next block */ |
| 1474 | sad += 3; |
| 1475 | } |
| 1476 | |
| 1477 | return max_channels; |
| 1478 | } |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1479 | |
| 1480 | static int platform_set_slowtalk(struct platform_data *my_data, bool state) |
| 1481 | { |
| 1482 | int ret = 0; |
| 1483 | struct audio_device *adev = my_data->adev; |
| 1484 | struct mixer_ctl *ctl; |
| 1485 | const char *mixer_ctl_name = "Slowtalk Enable"; |
| 1486 | uint32_t set_values[ ] = {0, |
| 1487 | ALL_SESSION_VSID}; |
| 1488 | |
| 1489 | set_values[0] = state; |
| 1490 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 1491 | if (!ctl) { |
| 1492 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 1493 | __func__, mixer_ctl_name); |
| 1494 | ret = -EINVAL; |
| 1495 | } else { |
| 1496 | ALOGV("Setting slowtalk state: %d", state); |
| 1497 | ret = mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
| 1498 | my_data->slowtalk = state; |
| 1499 | } |
| 1500 | |
Vidyakumar Athota | d9d9ff3 | 2013-11-13 11:46:52 -0800 | [diff] [blame] | 1501 | if (my_data->csd != NULL) { |
| 1502 | ret = my_data->csd->slow_talk(ALL_SESSION_VSID, state); |
| 1503 | if (ret < 0) { |
| 1504 | ALOGE("%s: csd_client_disable_device, failed, error %d", |
| 1505 | __func__, ret); |
| 1506 | } |
| 1507 | } |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1508 | return ret; |
| 1509 | } |
| 1510 | |
| 1511 | int platform_set_parameters(void *platform, struct str_parms *parms) |
| 1512 | { |
| 1513 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1514 | char *str; |
Vidyakumar Athota | 3ade279 | 2013-12-02 11:02:20 -0800 | [diff] [blame] | 1515 | char value[256] = {0}; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1516 | int val; |
Shiv Maliyappanahalli | 3e064fd | 2013-12-16 15:54:40 -0800 | [diff] [blame] | 1517 | int ret = 0, err; |
Krishnankutty Kolathappilly | 061a949 | 2014-01-31 18:12:13 -0800 | [diff] [blame] | 1518 | char *kv_pairs = str_parms_to_str(parms); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1519 | |
Krishnankutty Kolathappilly | 061a949 | 2014-01-31 18:12:13 -0800 | [diff] [blame] | 1520 | ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1521 | |
Shiv Maliyappanahalli | 3e064fd | 2013-12-16 15:54:40 -0800 | [diff] [blame] | 1522 | err = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_BTSCO, &val); |
| 1523 | if (err >= 0) { |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1524 | str_parms_del(parms, AUDIO_PARAMETER_KEY_BTSCO); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1525 | my_data->btsco_sample_rate = val; |
Vidyakumar Athota | 67c4271 | 2013-12-04 14:03:06 -0800 | [diff] [blame] | 1526 | if (val == SAMPLE_RATE_16KHZ) { |
| 1527 | audio_route_apply_path(my_data->adev->audio_route, |
| 1528 | "bt-sco-wb-samplerate"); |
| 1529 | audio_route_update_mixer(my_data->adev->audio_route); |
| 1530 | } |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1531 | } |
| 1532 | |
Shiv Maliyappanahalli | 3e064fd | 2013-12-16 15:54:40 -0800 | [diff] [blame] | 1533 | err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SLOWTALK, value, sizeof(value)); |
| 1534 | if (err >= 0) { |
Vidyakumar Athota | 3ade279 | 2013-12-02 11:02:20 -0800 | [diff] [blame] | 1535 | bool state = false; |
| 1536 | if (!strncmp("true", value, sizeof("true"))) { |
| 1537 | state = true; |
| 1538 | } |
| 1539 | |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1540 | str_parms_del(parms, AUDIO_PARAMETER_KEY_SLOWTALK); |
Vidyakumar Athota | 3ade279 | 2013-12-02 11:02:20 -0800 | [diff] [blame] | 1541 | ret = platform_set_slowtalk(my_data, state); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1542 | if (ret) |
| 1543 | ALOGE("%s: Failed to set slow talk err: %d", __func__, ret); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1544 | } |
| 1545 | |
Shiv Maliyappanahalli | 3e064fd | 2013-12-16 15:54:40 -0800 | [diff] [blame] | 1546 | err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST, |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 1547 | value, sizeof(value)); |
Shiv Maliyappanahalli | 3e064fd | 2013-12-16 15:54:40 -0800 | [diff] [blame] | 1548 | if (err >= 0) { |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 1549 | str_parms_del(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST); |
| 1550 | |
| 1551 | if (my_data->acdb_reload_vocvoltable == NULL) { |
| 1552 | ALOGE("%s: acdb_reload_vocvoltable is NULL", __func__); |
| 1553 | } else if (!strcmp(value, "on")) { |
| 1554 | if (!my_data->acdb_reload_vocvoltable(VOICE_FEATURE_SET_VOLUME_BOOST)) { |
| 1555 | my_data->voice_feature_set = 1; |
| 1556 | } |
| 1557 | } else { |
| 1558 | if (!my_data->acdb_reload_vocvoltable(VOICE_FEATURE_SET_DEFAULT)) { |
| 1559 | my_data->voice_feature_set = 0; |
| 1560 | } |
| 1561 | } |
| 1562 | } |
| 1563 | |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1564 | ALOGV("%s: exit with code(%d)", __func__, ret); |
Krishnankutty Kolathappilly | 061a949 | 2014-01-31 18:12:13 -0800 | [diff] [blame] | 1565 | free(kv_pairs); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1566 | return ret; |
| 1567 | } |
| 1568 | |
Vidyakumar Athota | 2850d53 | 2013-11-19 16:02:12 -0800 | [diff] [blame] | 1569 | int platform_set_incall_recording_session_id(void *platform, |
| 1570 | uint32_t session_id, int rec_mode) |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 1571 | { |
| 1572 | int ret = 0; |
| 1573 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1574 | struct audio_device *adev = my_data->adev; |
| 1575 | struct mixer_ctl *ctl; |
| 1576 | const char *mixer_ctl_name = "Voc VSID"; |
| 1577 | int num_ctl_values; |
| 1578 | int i; |
| 1579 | |
| 1580 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 1581 | if (!ctl) { |
| 1582 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 1583 | __func__, mixer_ctl_name); |
| 1584 | ret = -EINVAL; |
| 1585 | } else { |
| 1586 | num_ctl_values = mixer_ctl_get_num_values(ctl); |
| 1587 | for (i = 0; i < num_ctl_values; i++) { |
| 1588 | if (mixer_ctl_set_value(ctl, i, session_id)) { |
| 1589 | ALOGV("Error: invalid session_id: %x", session_id); |
| 1590 | ret = -EINVAL; |
| 1591 | break; |
| 1592 | } |
| 1593 | } |
| 1594 | } |
| 1595 | |
Vidyakumar Athota | 2850d53 | 2013-11-19 16:02:12 -0800 | [diff] [blame] | 1596 | if (my_data->csd != NULL) { |
| 1597 | ret = my_data->csd->start_record(ALL_SESSION_VSID, rec_mode); |
| 1598 | if (ret < 0) { |
| 1599 | ALOGE("%s: csd_client_start_record failed, error %d", |
| 1600 | __func__, ret); |
| 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | return ret; |
| 1605 | } |
| 1606 | |
| 1607 | int platform_stop_incall_recording_usecase(void *platform) |
| 1608 | { |
| 1609 | int ret = 0; |
| 1610 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1611 | |
| 1612 | if (my_data->csd != NULL) { |
| 1613 | ret = my_data->csd->stop_record(ALL_SESSION_VSID); |
| 1614 | if (ret < 0) { |
| 1615 | ALOGE("%s: csd_client_stop_record failed, error %d", |
| 1616 | __func__, ret); |
| 1617 | } |
| 1618 | } |
| 1619 | |
| 1620 | return ret; |
| 1621 | } |
| 1622 | |
| 1623 | int platform_start_incall_music_usecase(void *platform) |
| 1624 | { |
| 1625 | int ret = 0; |
| 1626 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1627 | |
| 1628 | if (my_data->csd != NULL) { |
| 1629 | ret = my_data->csd->start_playback(ALL_SESSION_VSID); |
| 1630 | if (ret < 0) { |
| 1631 | ALOGE("%s: csd_client_start_playback failed, error %d", |
| 1632 | __func__, ret); |
| 1633 | } |
| 1634 | } |
| 1635 | |
| 1636 | return ret; |
| 1637 | } |
| 1638 | |
| 1639 | int platform_stop_incall_music_usecase(void *platform) |
| 1640 | { |
| 1641 | int ret = 0; |
| 1642 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1643 | |
| 1644 | if (my_data->csd != NULL) { |
| 1645 | ret = my_data->csd->stop_playback(ALL_SESSION_VSID); |
| 1646 | if (ret < 0) { |
| 1647 | ALOGE("%s: csd_client_stop_playback failed, error %d", |
| 1648 | __func__, ret); |
| 1649 | } |
| 1650 | } |
| 1651 | |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 1652 | return ret; |
| 1653 | } |
| 1654 | |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1655 | void platform_get_parameters(void *platform, |
| 1656 | struct str_parms *query, |
| 1657 | struct str_parms *reply) |
| 1658 | { |
| 1659 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1660 | char *str = NULL; |
| 1661 | char value[256] = {0}; |
| 1662 | int ret; |
| 1663 | int fluence_type; |
Krishnankutty Kolathappilly | 061a949 | 2014-01-31 18:12:13 -0800 | [diff] [blame] | 1664 | char *kv_pairs = NULL; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1665 | |
| 1666 | ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_FLUENCE_TYPE, |
| 1667 | value, sizeof(value)); |
| 1668 | if (ret >= 0) { |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 1669 | if (my_data->fluence_type & FLUENCE_QUAD_MIC) { |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1670 | strlcpy(value, "fluencepro", sizeof(value)); |
Ravi Kumar Alamanda | b034ddb | 2013-11-06 15:52:18 -0800 | [diff] [blame] | 1671 | } else if (my_data->fluence_type & FLUENCE_DUAL_MIC) { |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1672 | strlcpy(value, "fluence", sizeof(value)); |
| 1673 | } else { |
| 1674 | strlcpy(value, "none", sizeof(value)); |
| 1675 | } |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1676 | |
| 1677 | str_parms_add_str(reply, AUDIO_PARAMETER_KEY_FLUENCE_TYPE, value); |
| 1678 | } |
| 1679 | |
Shiv Maliyappanahalli | 9d89929 | 2013-11-20 14:43:01 -0800 | [diff] [blame] | 1680 | memset(value, 0, sizeof(value)); |
| 1681 | ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_SLOWTALK, |
| 1682 | value, sizeof(value)); |
| 1683 | if (ret >= 0) { |
Vidyakumar Athota | 3ade279 | 2013-12-02 11:02:20 -0800 | [diff] [blame] | 1684 | str_parms_add_str(reply, AUDIO_PARAMETER_KEY_SLOWTALK, |
| 1685 | my_data->slowtalk?"true":"false"); |
Shiv Maliyappanahalli | 9d89929 | 2013-11-20 14:43:01 -0800 | [diff] [blame] | 1686 | } |
| 1687 | |
Ben Romberger | c1dc70d | 2013-12-19 15:11:17 -0800 | [diff] [blame] | 1688 | ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOLUME_BOOST, |
| 1689 | value, sizeof(value)); |
| 1690 | if (ret >= 0) { |
| 1691 | if (my_data->voice_feature_set == VOICE_FEATURE_SET_VOLUME_BOOST) { |
| 1692 | strlcpy(value, "on", sizeof(value)); |
| 1693 | } else { |
| 1694 | strlcpy(value, "off", sizeof(value)); |
| 1695 | } |
| 1696 | |
| 1697 | str_parms_add_str(reply, AUDIO_PARAMETER_KEY_VOLUME_BOOST, value); |
| 1698 | } |
| 1699 | |
Krishnankutty Kolathappilly | 061a949 | 2014-01-31 18:12:13 -0800 | [diff] [blame] | 1700 | kv_pairs = str_parms_to_str(reply); |
| 1701 | ALOGV_IF(kv_pairs != NULL, "%s: exit: returns - %s", __func__, kv_pairs); |
| 1702 | free(reply); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1703 | } |
| 1704 | |
Haynes Mathew George | 7ff216f | 2013-09-11 19:51:41 -0700 | [diff] [blame] | 1705 | /* Delay in Us */ |
| 1706 | int64_t platform_render_latency(audio_usecase_t usecase) |
| 1707 | { |
| 1708 | switch (usecase) { |
| 1709 | case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: |
| 1710 | return DEEP_BUFFER_PLATFORM_DELAY; |
| 1711 | case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: |
| 1712 | return LOW_LATENCY_PLATFORM_DELAY; |
| 1713 | default: |
| 1714 | return 0; |
| 1715 | } |
| 1716 | } |
Preetam Singh Ranawat | de84f1a | 2013-11-01 14:58:16 -0700 | [diff] [blame] | 1717 | |
Mingming Yin | e62d784 | 2013-10-25 16:26:03 -0700 | [diff] [blame] | 1718 | int platform_update_usecase_from_source(int source, int usecase) |
Preetam Singh Ranawat | de84f1a | 2013-11-01 14:58:16 -0700 | [diff] [blame] | 1719 | { |
Mingming Yin | ab42978 | 2013-11-07 11:16:55 -0800 | [diff] [blame] | 1720 | ALOGV("%s: input source :%d", __func__, source); |
| 1721 | if(source == AUDIO_SOURCE_FM_RX_A2DP) |
Mingming Yin | e62d784 | 2013-10-25 16:26:03 -0700 | [diff] [blame] | 1722 | usecase = USECASE_AUDIO_RECORD_FM_VIRTUAL; |
| 1723 | return usecase; |
Preetam Singh Ranawat | de84f1a | 2013-11-01 14:58:16 -0700 | [diff] [blame] | 1724 | } |
Kiran Kandi | de144c8 | 2013-11-20 15:58:32 -0800 | [diff] [blame] | 1725 | |
| 1726 | bool platform_listen_update_status(snd_device_t snd_device) |
| 1727 | { |
| 1728 | if ((snd_device >= SND_DEVICE_IN_BEGIN) && |
| 1729 | (snd_device < SND_DEVICE_IN_END) && |
| 1730 | (snd_device != SND_DEVICE_IN_CAPTURE_FM) && |
| 1731 | (snd_device != SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)) |
| 1732 | return true; |
| 1733 | else |
| 1734 | return false; |
| 1735 | } |