platform.c revision 4211fad32ff21574a3935dbe28397c55a1895649
1b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* 24b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava * Copyright (C) 2013-2014 The Android Open Source Project 3b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Licensed under the Apache License, Version 2.0 (the "License"); 5b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * you may not use this file except in compliance with the License. 6b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * You may obtain a copy of the License at 7b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 8b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * http://www.apache.org/licenses/LICENSE-2.0 9b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 10b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Unless required by applicable law or agreed to in writing, software 11b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * distributed under the License is distributed on an "AS IS" BASIS, 12b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * See the License for the specific language governing permissions and 14b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * limitations under the License. 15b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */ 16b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 17b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LOG_TAG "msm8974_platform" 18b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/*#define LOG_NDEBUG 0*/ 19b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LOG_NDDEBUG 0 20b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 21b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <stdlib.h> 22b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <dlfcn.h> 23b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <cutils/log.h> 249f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda#include <cutils/str_parms.h> 25b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <cutils/properties.h> 26b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <audio_hw.h> 27b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <platform_api.h> 28b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include "platform.h" 2963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda#include "audio_extn.h" 30b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 3147cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George#define MIXER_XML_PATH "/system/etc/mixer_paths.xml" 32b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LIB_ACDB_LOADER "libacdbloader.so" 3347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George#define AUDIO_DATA_BLOCK_MIXER_CTL "HDMI EDID" 34b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 35b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_NONE 0 /* Target does not contain 2 mics */ 36b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_ENDFIRE 1 37b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_BROADSIDE 2 38b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 39b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* 40b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * This file will have a maximum of 38 bytes: 41b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 42b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: number of audio blocks 43b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: total length of Short Audio Descriptor (SAD) blocks 44b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Maximum 10 * 3 bytes: SAD blocks 45b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */ 46b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define MAX_SAD_BLOCKS 10 47b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define SAD_BLOCK_SIZE 3 48b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 49b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* EDID format ID for LPCM audio */ 50b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define EDID_FORMAT_LPCM 1 51b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 521b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo/* Retry for delay in FW loading*/ 531b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo#define RETRY_NUMBER 10 541b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo#define RETRY_US 500000 554b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava#define MAX_SND_CARD 8 5653b2cf0c72aa18a5848919e2309731af652e84f9sangwoo 57b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct audio_block_header 58b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 59b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int reserved; 60b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int length; 61b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 62b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 6383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda/* Audio calibration related functions */ 64b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_deallocate_t)(); 6583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 6683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandatypedef int (*acdb_init_t)(char *); 6783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 68b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*acdb_init_t)(); 6983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 70b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_audio_cal_t)(int, int); 71b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_voice_cal_t)(int, int); 7283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandatypedef int (*acdb_reload_vocvoltable_t)(int); 73b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 74b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Audio calibration related functions */ 75b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct platform_data { 76b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev; 77b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_spkr_mode; 78b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_voice_call; 793ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda bool fluence_in_voice_comm; 80b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_voice_rec; 81b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int dualmic_config; 821f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda bool speaker_lr_swap; 831f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda 84b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent void *acdb_handle; 853ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_init_t acdb_init; 863ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_deallocate_t acdb_deallocate; 873ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_send_audio_cal_t acdb_send_audio_cal; 883ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_send_voice_cal_t acdb_send_voice_cal; 8983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_reload_vocvoltable_t acdb_reload_vocvoltable; 9083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct csd_data *csd; 91299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda bool ext_speaker; 92299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda bool ext_earpiece; 93f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda char ec_ref_mixer_path[64]; 94b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 95b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 9698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic int pcm_device_table[AUDIO_USECASE_MAX][2] = { 9783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE, 9883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda DEEP_BUFFER_PCM_DEVICE}, 9983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, 10083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda LOWLATENCY_PCM_DEVICE}, 10183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {MULTIMEDIA2_PCM_DEVICE, 10283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda MULTIMEDIA2_PCM_DEVICE}, 10383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_OFFLOAD] = {PLAYBACK_OFFLOAD_DEVICE, 10483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda PLAYBACK_OFFLOAD_DEVICE}, 105f78a4d928e527e639bc2d174edcdaeeb852e18c0Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_TTS] = {MULTIMEDIA3_PCM_DEVICE, 106f78a4d928e527e639bc2d174edcdaeeb852e18c0Ravi Kumar Alamanda MULTIMEDIA3_PCM_DEVICE}, 10783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, 10883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda AUDIO_RECORD_PCM_DEVICE}, 10983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, 11083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda LOWLATENCY_PCM_DEVICE}, 11183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_VOICE_CALL] = {VOICE_CALL_PCM_DEVICE, 11283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda VOICE_CALL_PCM_DEVICE}, 1134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOICE2_CALL] = {VOICE2_CALL_PCM_DEVICE, VOICE2_CALL_PCM_DEVICE}, 1144b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOLTE_CALL] = {VOLTE_CALL_PCM_DEVICE, VOLTE_CALL_PCM_DEVICE}, 1154b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_QCHAT_CALL] = {QCHAT_CALL_PCM_DEVICE, QCHAT_CALL_PCM_DEVICE}, 1164b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOWLAN_CALL] = {VOWLAN_CALL_PCM_DEVICE, VOWLAN_CALL_PCM_DEVICE}, 1174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_UPLINK] = {AUDIO_RECORD_PCM_DEVICE, 1184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1194b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, 1204b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, 1224b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1238e6e98fc5af6d6f79bc71eb37df470380ae82fadRavi Kumar Alamanda [USECASE_AUDIO_HFP_SCO] = {HFP_PCM_RX, HFP_SCO_RX}, 12499c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 12563863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [USECASE_AUDIO_SPKR_CALIB_RX] = {SPKR_PROT_CALIB_RX_PCM_DEVICE, -1}, 12663863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [USECASE_AUDIO_SPKR_CALIB_TX] = {-1, SPKR_PROT_CALIB_TX_PCM_DEVICE}, 12763863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 12899c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_AFE_PROXY] = {AFE_PROXY_PLAYBACK_PCM_DEVICE, 12999c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda AFE_PROXY_RECORD_PCM_DEVICE}, 13099c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD_AFE_PROXY] = {AFE_PROXY_PLAYBACK_PCM_DEVICE, 13199c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda AFE_PROXY_RECORD_PCM_DEVICE}, 1324211fad32ff21574a3935dbe28397c55a1895649zhaoyang yin [USECASE_AUDIO_DSM_FEEDBACK] = {QUAT_MI2S_PCM_DEVICE, QUAT_MI2S_PCM_DEVICE}, 13399c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 134b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 135b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 136b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Array to store sound devices */ 137b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const char * const device_table[SND_DEVICE_MAX] = { 138b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_NONE] = "none", 139b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Playback sound devices */ 140b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HANDSET] = "handset", 141b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER] = "speaker", 142b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse", 1431b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent [SND_DEVICE_OUT_SPEAKER_SAFE] = "speaker-safe", 144b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HEADPHONES] = "headphones", 14509f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent [SND_DEVICE_OUT_LINE] = "line", 146b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", 147744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_LINE] = "speaker-and-line", 148b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset", 1499d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent [SND_DEVICE_OUT_VOICE_HAC_HANDSET] = "voice-hac-handset", 150b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker", 151b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones", 15209f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent [SND_DEVICE_OUT_VOICE_LINE] = "voice-line", 153b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HDMI] = "hdmi", 154b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi", 155b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset", 1569f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb", 157b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus", 158b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones", 159b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones", 160b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset", 16199c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_TX] = "voice-tx", 16263863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_OUT_SPEAKER_PROTECTED] = "speaker-protected", 16363863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED] = "voice-speaker-protected", 164b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 165b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Capture sound devices */ 166b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic", 1673ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic", 1683ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_NS] = "handset-mic", 1693ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = "handset-mic", 1703ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC] = "dmic-endfire", 1713ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC] = "dmic-endfire", 1723ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_NS] = "dmic-endfire", 1733ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = "dmic-endfire", 1743ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_STEREO] = "dmic-endfire", 1753ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 176b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic", 1773ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "speaker-mic", 1783ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_NS] = "speaker-mic", 1793ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = "speaker-mic", 1803ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC] = "speaker-dmic-endfire", 1813ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = "speaker-dmic-endfire", 1823ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_NS] = "speaker-dmic-endfire", 1833ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = "speaker-dmic-endfire", 1843ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_STEREO] = "speaker-dmic-endfire", 1853ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 186b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic", 187cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic", 1883ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 189b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", 190b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic", 1919f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb", 1923ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 193b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic", 1943ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 1953ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC] = "voice-dmic-ef", 1963ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC_TMUS] = "voice-dmic-ef-tmus", 1973ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", 1983ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef", 1993ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", 200b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic", 201b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic", 202b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic", 2033ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 204b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic", 2053ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_MIC_NS] = "voice-rec-mic", 2063ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = "voice-rec-dmic-ef", 2073ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = "voice-rec-dmic-ef-fluence", 20899c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 20999c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_IN_VOICE_RX] = "voice-rx", 21063863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 21163863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = "vi-feedback", 212b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 213b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 214b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* ACDB IDs (audio DSP path configuration IDs) for each sound device */ 2155bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgestatic int acdb_device_table[SND_DEVICE_MAX] = { 216b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_NONE] = -1, 217b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HANDSET] = 7, 218b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER] = 15, 219b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_REVERSE] = 15, 2201b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent [SND_DEVICE_OUT_SPEAKER_SAFE] = 15, 221b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HEADPHONES] = 10, 222744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_LINE] = 77, 223b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10, 224744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_LINE] = 77, 225235c34827f7b3b8977fe76dea1fb8d818fd74312Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_HANDSET] = ACDB_ID_VOICE_HANDSET, 226235c34827f7b3b8977fe76dea1fb8d818fd74312Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_SPEAKER] = ACDB_ID_VOICE_SPEAKER, 2279d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent [SND_DEVICE_OUT_VOICE_HAC_HANDSET] = 53, 228b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10, 229744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_VOICE_LINE] = 77, 230b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HDMI] = 18, 231b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 15, 232b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_BT_SCO] = 22, 2339f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_OUT_BT_SCO_WB] = 39, 23483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = ACDB_ID_VOICE_HANDSET_TMUS, 235b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17, 236b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17, 237b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37, 23899c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_TX] = 45, 23963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_OUT_SPEAKER_PROTECTED] = 124, 24063863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED] = 101, 241b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 242b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC] = 4, 2433ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC] = 106, 2443ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_NS] = 107, 2453ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = 108, 2463ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC] = 41, 2473ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC] = 109, 2483ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_NS] = 110, 2493ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = 111, 2503ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_STEREO] = 34, 2513ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 2523ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC] = 11, 2533ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 112, 2543ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_NS] = 113, 2553ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = 114, 2563ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC] = 43, 2573ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = 115, 2583ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_NS] = 116, 2593ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = 117, 2603ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_STEREO] = 35, 2613ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 262b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC] = 8, 263cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent [SND_DEVICE_IN_HEADSET_MIC_AEC] = ACDB_ID_HEADSET_MIC_AEC, 2643ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 265b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HDMI_MIC] = 4, 266b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_BT_SCO_MIC] = 21, 2679f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38, 2683ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 269b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_CAMCORDER_MIC] = 61, 2703ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 2713ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC] = 41, 2723ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC_TMUS] = ACDB_ID_VOICE_DMIC_EF_TMUS, 2733ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11, 2743ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 43, 2753ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8, 276b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16, 277b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36, 278b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16, 2793ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 280b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_MIC] = 62, 2813ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_MIC_NS] = 113, 2823ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = 35, 2833ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = 43, 28499c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 28599c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_IN_VOICE_RX] = 44, 28663863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 28763863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = 102, 288b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 289b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 29098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestruct name_to_index { 2915bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George char name[100]; 2925bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George unsigned int index; 2935bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George}; 2945bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 2955bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George#define TO_NAME_INDEX(X) #X, X 2965bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 29798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George/* Used to get index from parsed string */ 29898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic const struct name_to_index snd_device_name_index[SND_DEVICE_MAX] = { 29998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George /* out */ 3005bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HANDSET)}, 3015bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)}, 3025bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_REVERSE)}, 3031b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_SAFE)}, 3045bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES)}, 30509f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_LINE)}, 3065bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES)}, 307744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_LINE)}, 3085bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET)}, 3095bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER)}, 3105bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HEADPHONES)}, 31109f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_LINE)}, 3125bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HDMI)}, 3135bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HDMI)}, 3145bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO)}, 3155bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO_WB)}, 31698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET_TMUS)}, 3179d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HAC_HANDSET)}, 3185bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES)}, 3195bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES)}, 3205bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET)}, 32198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 32298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George /* in */ 32363863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_PROTECTED)}, 32463863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED)}, 3255bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC)}, 32698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC)}, 3273ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_NS)}, 3283ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC_NS)}, 3293ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC)}, 3303ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC)}, 3313ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_NS)}, 3323ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC_NS)}, 3333ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_STEREO)}, 3343ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3353ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC)}, 33698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC)}, 3373ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_NS)}, 3383ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC_NS)}, 3393ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC)}, 3403ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC)}, 3413ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_NS)}, 3423ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS)}, 3433ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_STEREO)}, 3443ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3453ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC)}, 3463ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3475bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HDMI_MIC)}, 3485bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC)}, 3495bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB)}, 3503ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3515bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_MIC)}, 3523ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3533ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC)}, 3543ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC_TMUS)}, 3553ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_MIC)}, 3563ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_DMIC)}, 3573ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_HEADSET_MIC)}, 3585bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC)}, 3595bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC)}, 3605bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC)}, 3613ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3625bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC)}, 3633ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC_NS)}, 3643ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_STEREO)}, 3653ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE)}, 36663863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 36763863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)}, 36898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George}; 36998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 37098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic char * backend_table[SND_DEVICE_MAX] = {0}; 37198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 37298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic const struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { 37398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_DEEP_BUFFER)}, 37498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_LOW_LATENCY)}, 37598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MULTI_CH)}, 37698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD)}, 37798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_RECORD)}, 37898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)}, 37998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOICE_CALL)}, 38098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOICE2_CALL)}, 38198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOLTE_CALL)}, 38298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_QCHAT_CALL)}, 38398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOWLAN_CALL)}, 38498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK)}, 38598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_INCALL_REC_DOWNLINK)}, 38698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK_AND_DOWNLINK)}, 38798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_HFP_SCO)}, 3885bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George}; 3895bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 3907ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) 3917ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) 3927ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George 393b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT; 394b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic bool is_tmus = false; 395b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 396b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic void check_operator() 397b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 398b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char value[PROPERTY_VALUE_MAX]; 399b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int mccmnc; 400b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("gsm.sim.operator.numeric",value,"0"); 401b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mccmnc = atoi(value); 402b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGD("%s: tmus mccmnc %d", __func__, mccmnc); 403b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent switch(mccmnc) { 404b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* TMUS MCC(310), MNC(490, 260, 026) */ 405b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310490: 406b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310260: 407b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310026: 408b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon /* Add new TMUS MNC(800, 660, 580, 310, 270, 250, 240, 230, 220, 210, 200, 160) */ 409b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310800: 410b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310660: 411b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310580: 412b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310310: 413b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310270: 414b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310250: 415b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310240: 416b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310230: 417b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310220: 418b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310210: 419b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310200: 420b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310160: 421b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent is_tmus = true; 422b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 423b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 424b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 425b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 426b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentbool is_operator_tmus() 427b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 428b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent pthread_once(&check_op_once_ctl, check_operator); 429b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return is_tmus; 430b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 431b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 432cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurentvoid platform_set_echo_reference(struct audio_device *adev, bool enable, audio_devices_t out_device) 433b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 434f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)adev->platform; 435cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 436cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent 437f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda if (strcmp(my_data->ec_ref_mixer_path, "")) { 438f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda ALOGV("%s: diabling %s", __func__, my_data->ec_ref_mixer_path); 439f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda audio_route_reset_and_update_path(adev->audio_route, my_data->ec_ref_mixer_path); 440cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } 441cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent 442f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda if (enable) { 443f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda strcpy(my_data->ec_ref_mixer_path, "echo-reference"); 444f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda if (out_device != AUDIO_DEVICE_NONE) { 445f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda snd_device = platform_get_output_snd_device(adev->platform, out_device); 446f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda platform_add_backend_name(adev->platform, my_data->ec_ref_mixer_path, snd_device); 447f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda } 448b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 449f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda ALOGD("%s: enabling %s", __func__, my_data->ec_ref_mixer_path); 450f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda audio_route_apply_and_update_path(adev->audio_route, my_data->ec_ref_mixer_path); 451f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda } 452b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 453b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 45483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandastatic struct csd_data *open_csd_client(bool i2s_ext_modem) 45583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 45683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct csd_data *csd = calloc(1, sizeof(struct csd_data)); 45783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 45883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW); 45983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->csd_client == NULL) { 46083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT); 46183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 46283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 46383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT); 46483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 46583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->deinit = (deinit_t)dlsym(csd->csd_client, 46683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_deinit"); 46783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->deinit == NULL) { 46883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_deinit", __func__, 46983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda dlerror()); 47083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 47183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 47283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->disable_device = (disable_device_t)dlsym(csd->csd_client, 47383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_disable_device"); 47483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->disable_device == NULL) { 47583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_disable_device", 47683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 47783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 47883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 47983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->enable_device_config = (enable_device_config_t)dlsym(csd->csd_client, 48083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_enable_device_config"); 48183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->enable_device_config == NULL) { 48283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_enable_device_config", 48383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 48483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 48583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 48683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->enable_device = (enable_device_t)dlsym(csd->csd_client, 48783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_enable_device"); 48883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->enable_device == NULL) { 48983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_enable_device", 49083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 49183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 49283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 49383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_voice = (start_voice_t)dlsym(csd->csd_client, 49483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_voice"); 49583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_voice == NULL) { 49683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_voice", 49783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 49883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 49983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 50083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_voice = (stop_voice_t)dlsym(csd->csd_client, 50183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_voice"); 50283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_voice == NULL) { 50383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_voice", 50483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 50583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 50683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 50783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->volume = (volume_t)dlsym(csd->csd_client, 50883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_volume"); 50983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->volume == NULL) { 51083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_volume", 51183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 51283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 51383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 51483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->mic_mute = (mic_mute_t)dlsym(csd->csd_client, 51583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_mic_mute"); 51683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->mic_mute == NULL) { 51783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_mic_mute", 51883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 51983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 52083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 52183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->slow_talk = (slow_talk_t)dlsym(csd->csd_client, 52283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_slow_talk"); 52383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->slow_talk == NULL) { 52483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_slow_talk", 52583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 52683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 52783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 52883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_playback = (start_playback_t)dlsym(csd->csd_client, 52983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_playback"); 53083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_playback == NULL) { 53183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_playback", 53283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 53383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 53483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 53583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_playback = (stop_playback_t)dlsym(csd->csd_client, 53683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_playback"); 53783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_playback == NULL) { 53883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_playback", 53983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 54083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 54183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 54283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_record = (start_record_t)dlsym(csd->csd_client, 54383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_record"); 54483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_record == NULL) { 54583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_record", 54683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 54783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 54883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 54983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_record = (stop_record_t)dlsym(csd->csd_client, 55083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_record"); 55183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_record == NULL) { 55283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_record", 55383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 55483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 55583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 55683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 55783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->get_sample_rate = (get_sample_rate_t)dlsym(csd->csd_client, 55883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_get_sample_rate"); 55983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->get_sample_rate == NULL) { 56083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_get_sample_rate", 56183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 56283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 56383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 56483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 56583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 56683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->init = (init_t)dlsym(csd->csd_client, "csd_client_init"); 56783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 56883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->init == NULL) { 56983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_init", 57083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 57183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 57283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 57383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->init(i2s_ext_modem); 57483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 57583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 57683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return csd; 57783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 57883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaerror: 57983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda free(csd); 58083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd = NULL; 58183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return csd; 58283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 58383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 58483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandavoid close_csd_client(struct csd_data *csd) 58583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 58683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd != NULL) { 58783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->deinit(); 58883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda dlclose(csd->csd_client); 58983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda free(csd); 59083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd = NULL; 59183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 59283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 59383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 59483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandastatic void platform_csd_init(struct platform_data *my_data) 59583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 59683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 597ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev int32_t modems, (*count_modems)(void); 598ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev const char *name = "libdetectmodem.so"; 599ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev const char *func = "count_modems"; 600ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev const char *error; 601ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 602ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev my_data->csd = NULL; 603ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 604ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev void *lib = dlopen(name, RTLD_NOW); 605ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev error = dlerror(); 606ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (!lib) { 607ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGE("%s: could not find %s: %s", __func__, name, error); 608ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev return; 609ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev } 610ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 611ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev count_modems = NULL; 612ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev *(void **)(&count_modems) = dlsym(lib, func); 613ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev error = dlerror(); 614ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (!count_modems) { 615ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGE("%s: could not find symbol %s in %s: %s", 616ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev __func__, func, name, error); 617ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev goto done; 61883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 61983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 620ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev modems = count_modems(); 621ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (modems < 0) { 622ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGE("%s: count_modems failed\n", __func__); 623ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev goto done; 624ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev } 625ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 626ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGD("%s: num_modems %d\n", __func__, modems); 627ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (modems > 0) 62883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->csd = open_csd_client(false /*is_i2s_ext_modem*/); 629ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 630ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchevdone: 631ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev dlclose(lib); 63283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 63383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->csd = NULL; 63483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 63583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 63683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 63798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic void set_platform_defaults(struct platform_data * my_data) 63898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 63998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int32_t dev; 64098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George for (dev = 0; dev < SND_DEVICE_MAX; dev++) { 64198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[dev] = NULL; 64298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 64398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 64498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George // TBD - do these go to the platform-info.xml file. 64598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George // will help in avoiding strdups here 64698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_IN_BT_SCO_MIC] = strdup("bt-sco"); 64798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_BT_SCO] = strdup("bt-sco"); 64898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_HDMI] = strdup("hdmi"); 64998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("speaker-and-hdmi"); 65098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("bt-sco-wb"); 65198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_IN_BT_SCO_MIC_WB] = strdup("bt-sco-wb"); 65299c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda backend_table[SND_DEVICE_OUT_VOICE_TX] = strdup("afe-proxy"); 65399c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda backend_table[SND_DEVICE_IN_VOICE_RX] = strdup("afe-proxy"); 65498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 65598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (my_data->ext_speaker) { 65698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_SPEAKER] = strdup("speaker"); 6571b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent backend_table[SND_DEVICE_OUT_SPEAKER_SAFE] = strdup("speaker"); 65898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_VOICE_SPEAKER] = strdup("speaker"); 65998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_SPEAKER_REVERSE] = strdup("speaker"); 66098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 66198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George strdup("speaker-and-headphones"); 662744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent backend_table[SND_DEVICE_OUT_SPEAKER_AND_LINE] = 663744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent strdup("speaker-and-line"); 66498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 66598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 66698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (my_data->ext_earpiece) { 66798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_VOICE_HANDSET] = strdup("handset"); 6689d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent backend_table[SND_DEVICE_OUT_VOICE_HAC_HANDSET] = strdup("handset"); 66998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = strdup("handset"); 67098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_HANDSET] = strdup("handset"); 67198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = strdup("handset"); 67298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 67398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 67498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 675b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid *platform_init(struct audio_device *adev) 676b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 677b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char value[PROPERTY_VALUE_MAX]; 678b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data; 6794b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int retry_num = 0, snd_card_num = 0; 68083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda const char *snd_card_name; 6811b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 6824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava while (snd_card_num < MAX_SND_CARD) { 6834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->mixer = mixer_open(snd_card_num); 6841b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 6854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava while (!adev->mixer && retry_num < RETRY_NUMBER) { 6864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava usleep(RETRY_US); 6874b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->mixer = mixer_open(snd_card_num); 6884b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava retry_num++; 6894b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 69083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 6914b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!adev->mixer) { 6924b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Unable to open the mixer card: %d", __func__, 6934b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_num); 6944b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava retry_num = 0; 6954b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_num++; 6964b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava continue; 6974b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 698cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 6994b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_name = mixer_get_name(adev->mixer); 7004b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGD("%s: snd_card_name: %s", __func__, snd_card_name); 701a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent 7024b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->audio_route = audio_route_init(snd_card_num, MIXER_XML_PATH); 7034b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!adev->audio_route) { 7044b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Failed to init audio route controls, aborting.", __func__); 7054b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return NULL; 7064b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 7074b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->snd_card = snd_card_num; 7084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGD("%s: Opened sound card:%d", __func__, snd_card_num); 7094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava break; 7104b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 7114b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 7124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (snd_card_num >= MAX_SND_CARD) { 7134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Unable to find correct sound card, aborting.", __func__); 7141b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo return NULL; 7151b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo } 716b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 717b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data = calloc(1, sizeof(struct platform_data)); 718b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 719b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->adev = adev; 720b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config = DUALMIC_CONFIG_NONE; 721b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_spkr_mode = false; 722b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_call = false; 7233ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm = false; 724b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_rec = false; 725b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 726299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda /* 727299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * The default assumption is that earpiece (handset), speaker and headphones 728299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * devices are connected to internal HW codec and communicated through 729299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * slimbus backend. If any platform communicates with speaker or earpiece 730299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * or headphones through non-slimbus backend such as MI2S or AUXPCM etc., 731299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * the ext_xxxx flags must be set accordingly. 732299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda */ 733299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda if (strstr(snd_card_name, "tfa9890_stereo")) { 734299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda my_data->ext_speaker = true; 735299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda my_data->ext_earpiece = true; 736299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda } else if (strstr(snd_card_name, "tfa9890")) { 737299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda my_data->ext_speaker = true; 738299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda } 739299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda 740b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.dualmic.config",value,""); 741b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("broadside", value)) { 7423ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda ALOGE("%s: Unsupported dualmic configuration", __func__); 743b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (!strcmp("endfire", value)) { 744b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config = DUALMIC_CONFIG_ENDFIRE; 745b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 746b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 747b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 748b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.voicecall",value,""); 749b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 750b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_call = true; 751b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 752b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 7533ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda property_get("persist.audio.fluence.voicecomm",value,""); 7543ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (!strcmp("true", value)) { 7553ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm = true; 7563ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } 7573ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 758b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.voicerec",value,""); 759b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 760b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_rec = true; 761b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 762b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 763b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.speaker",value,""); 764b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 765b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_spkr_mode = true; 766b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 767b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 768b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 769b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); 770b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_handle == NULL) { 771b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER); 772b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 773b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER); 774b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle, 775b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_deallocate_ACDB"); 77683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_deallocate) 77783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_deallocate_ACDB from %s", 77883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 77983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 780b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle, 781b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_send_audio_cal"); 782b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!my_data->acdb_send_audio_cal) 78383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_send_audio_cal from %s", 784b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, LIB_ACDB_LOADER); 78583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 786b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle, 787b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_send_voice_cal"); 78883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_send_voice_cal) 78983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_send_voice_cal from %s", 79083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 79183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 79283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->acdb_reload_vocvoltable = (acdb_reload_vocvoltable_t)dlsym(my_data->acdb_handle, 79383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "acdb_loader_reload_vocvoltable"); 79483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_reload_vocvoltable) 79583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_reload_vocvoltable from %s", 79683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 79783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 79883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, 79983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "acdb_loader_init_v2"); 80083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->acdb_init == NULL) 80183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror()); 80283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda else 80398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George my_data->acdb_init((char *)snd_card_name); 80483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 805b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, 806b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_init_ACDB"); 807b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_init == NULL) 808b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror()); 809b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 810b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_init(); 81183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 8125bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 813b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 814b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 81598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George set_platform_defaults(my_data); 81698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 81798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George /* Initialize platform specific ids and/or backends*/ 8187aa15ea3dc9353f068c3eeb7f6fa57c28a5cc143Mekala Natarajan platform_info_init(); 81963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda audio_extn_spkr_prot_init(adev); 82098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 82183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda /* load csd client */ 82283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda platform_csd_init(my_data); 82383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 824b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return my_data; 825b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 826b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 827b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid platform_deinit(void *platform) 828b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 8294b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 8304b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava close_csd_client(my_data->csd); 831b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent free(platform); 832b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 833b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 834b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentconst char *platform_get_snd_device_name(snd_device_t snd_device) 835b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 836b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) 837b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return device_table[snd_device]; 838b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 8396402646dbd962f62c37abbb1d435907d54da77ddRavi Kumar Alamanda return "none"; 840b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 841b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 842299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamandavoid platform_add_backend_name(void *platform, char *mixer_path, 843299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda snd_device_t snd_device) 844b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 845299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 846299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda 84798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { 84898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); 84998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return; 8501de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda } 85198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 85298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George const char * suffix = backend_table[snd_device]; 85398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 85498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (suffix != NULL) { 85598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George strcat(mixer_path, " "); 85698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George strcat(mixer_path, suffix); 857299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda } 858b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 859b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 860b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) 861b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 862b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int device_id; 863b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (device_type == PCM_PLAYBACK) 864b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent device_id = pcm_device_table[usecase][0]; 865b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 866b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent device_id = pcm_device_table[usecase][1]; 867b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return device_id; 868b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 869b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 87098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic int find_index(const struct name_to_index * table, int32_t len, 87198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George const char * name) 8725bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George{ 8735bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George int ret = 0; 87498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int32_t i; 8755bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 87698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (table == NULL) { 87798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: table is NULL", __func__); 8785bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -ENODEV; 8795bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 8805bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 8815bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 88298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (name == NULL) { 88398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("null key"); 88498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -ENODEV; 88598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George goto done; 88698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 88798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 88898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George for (i=0; i < len; i++) { 88998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (!strcmp(table[i].name, name)) { 89098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = table[i].index; 8915bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 8925bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 8935bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 89498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: Could not find index for name = %s", 89598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George __func__, name); 8965bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -ENODEV; 8975bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgedone: 8985bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George return ret; 8995bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George} 9005bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 90198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_get_snd_device_index(char *device_name) 90298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 90398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return find_index(snd_device_name_index, SND_DEVICE_MAX, device_name); 90498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 90598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 90698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_get_usecase_index(const char *usecase_name) 90798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 90898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return find_index(usecase_name_index, AUDIO_USECASE_MAX, usecase_name); 90998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 91098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 9115bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgeint platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id) 9125bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George{ 9135bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George int ret = 0; 9145bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 9155bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { 9165bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ALOGE("%s: Invalid snd_device = %d", 9175bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George __func__, snd_device); 9185bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -EINVAL; 9195bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 9205bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 9215bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 9225bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George acdb_device_table[snd_device] = acdb_id; 9235bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgedone: 9245bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George return ret; 9255bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George} 9265bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 92763863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamandaint platform_get_snd_device_acdb_id(snd_device_t snd_device) 92863863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda{ 92963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { 93063863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); 93163863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda return -EINVAL; 93263863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda } 93363863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda return acdb_device_table[snd_device]; 93463863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda} 93563863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 936b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_send_audio_calibration(void *platform, snd_device_t snd_device) 937b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 938b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 939b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int acdb_dev_id, acdb_dev_type; 940b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 941adf0f3b3b518e98fc1056e2788dd936e87331fb1Ravi Kumar Alamanda acdb_dev_id = acdb_device_table[audio_extn_get_spkr_prot_snd_device(snd_device)]; 942b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (acdb_dev_id < 0) { 943b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not find acdb id for device(%d)", 944b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, snd_device); 945b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 946b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 947b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_send_audio_cal) { 9483ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda ALOGD("%s: sending audio calibration for snd_device(%d) acdb_id(%d)", 949b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, snd_device, acdb_dev_id); 950b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device >= SND_DEVICE_OUT_BEGIN && 951b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device < SND_DEVICE_OUT_END) 952b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_type = ACDB_DEV_TYPE_OUT; 953b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 954b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_type = ACDB_DEV_TYPE_IN; 955b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type); 956b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 957b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 958b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 959b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 960b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_pre(void *platform) 961b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 96283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 96383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 96483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 96583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL && 966b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda voice_is_in_call(my_data->adev)) { 96783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda /* This must be called before disabling mixer controls on APQ side */ 96883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->disable_device(); 96983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 97083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_client_disable_device, failed, error %d", 97183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, ret); 97283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 97383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 97483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 97583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 97683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 97783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_enable_device_config(void *platform, 97883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t out_snd_device, 97983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t in_snd_device) 98083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 98183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 98283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int acdb_rx_id, acdb_tx_id; 98383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 98483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 98583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd == NULL) 98683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 98783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 98863863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && 98963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda audio_extn_spkr_prot_is_enabled()) 99063863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda acdb_rx_id = acdb_device_table[SND_DEVICE_OUT_SPEAKER_PROTECTED]; 99163863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda else 99263863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda acdb_rx_id = acdb_device_table[out_snd_device]; 99383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 99483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_tx_id = acdb_device_table[in_snd_device]; 99583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 99683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (acdb_rx_id > 0 && acdb_tx_id > 0) { 99783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id); 99883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 99983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_enable_device_config, failed, error %d", 100083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, ret); 100183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 100283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 100383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 100483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id, acdb_tx_id); 100583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 100683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 100783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1008b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1009b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1010b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_post(void *platform, 1011b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t out_snd_device, 1012b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t in_snd_device) 1013b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1014b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1015b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int acdb_rx_id, acdb_tx_id; 1016b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1017b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_send_voice_cal == NULL) { 1018b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error for acdb_send_voice_call", __func__); 1019b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 102063863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && 102163863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda audio_extn_spkr_prot_is_enabled()) 102263863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda out_snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED; 102363863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 1024b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_rx_id = acdb_device_table[out_snd_device]; 1025b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_tx_id = acdb_device_table[in_snd_device]; 1026b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1027b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (acdb_rx_id > 0 && acdb_tx_id > 0) 1028b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id); 1029b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1030b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 1031b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_rx_id, acdb_tx_id); 1032b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1033b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1034b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 1035b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1036b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 103783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_usecase_route_post(void *platform, 103883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t out_snd_device, 103983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t in_snd_device) 104083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 104183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 104283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int acdb_rx_id, acdb_tx_id; 104383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 104483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 104583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd == NULL) 104683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 104783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 104863863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && 104963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda audio_extn_spkr_prot_is_enabled()) 105063863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda acdb_rx_id = acdb_device_table[SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED]; 105163863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda else 105263863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda acdb_rx_id = acdb_device_table[out_snd_device]; 105383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 105483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_tx_id = acdb_device_table[in_snd_device]; 105583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 105683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (acdb_rx_id > 0 && acdb_tx_id > 0) { 105783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->enable_device(acdb_rx_id, acdb_tx_id, 105883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->adev->acdb_settings); 105983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 106083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_enable_device, failed, error %d", __func__, ret); 106183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 106283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 106383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 106483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id, acdb_tx_id); 106583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 106683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 106783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 106883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 106983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 10704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_start_voice_call(void *platform, uint32_t vsid) 1071b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 107283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 107383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 107483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 107583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 10764b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_voice(vsid); 107783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 107883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_start_voice error %d\n", __func__, ret); 107983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 108083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 108183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1082b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1083b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 10844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_voice_call(void *platform, uint32_t vsid) 1085b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 108683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 108783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 108883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 108983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 10904b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_voice(vsid); 109183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 109283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_stop_voice error %d\n", __func__, ret); 109383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 109483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 109583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1096b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1097b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 10984b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_get_sample_rate(void *platform, uint32_t *rate) 10994b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 11004b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 11014b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 11024b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 11034b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 11044b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->get_sample_rate(rate); 11054b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 11064b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_get_sample_rate error %d\n", __func__, ret); 11074b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 11084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 11094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 11104b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 11114b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 1112b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_voice_volume(void *platform, int volume) 1113b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1114b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1115b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1116b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 111753b2cf0c72aa18a5848919e2309731af652e84f9sangwoo const char *mixer_ctl_name = "Voice Rx Gain"; 11184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int vol_index = 0, ret = 0; 11194b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 11204b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 11214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_VOLUME_RAMP_DURATION_MS}; 1122b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1123b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // Voice volume levels are mapped to adsp volume levels as follows. 1124b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // 100 -> 5, 80 -> 4, 60 -> 3, 40 -> 2, 20 -> 1 0 -> 0 1125b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // But this values don't changed in kernel. So, below change is need. 11264b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava vol_index = (int)percent_to_index(volume, MIN_VOL_INDEX, MAX_VOL_INDEX); 11274b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = vol_index; 1128b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1129b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 1130b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 1131b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 1132b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 1133b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 1134b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 11354b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Setting voice volume index: %d", set_values[0]); 11364b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 11374b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 113883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 113983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->volume(ALL_SESSION_VSID, volume, 114083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda DEFAULT_VOLUME_RAMP_DURATION_MS); 114183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 114283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_volume error %d", __func__, ret); 114383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 114483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 114583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1146b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1147b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1148b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_mic_mute(void *platform, bool state) 1149b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1150b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1151b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1152b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 1153b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "Voice Tx Mute"; 115453b2cf0c72aa18a5848919e2309731af652e84f9sangwoo int ret = 0; 11554b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 11564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 11574b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_MUTE_RAMP_DURATION_MS}; 1158cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 11594b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (adev->mode != AUDIO_MODE_IN_CALL) 11604b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return 0; 11614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 11624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = state; 11634b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 11644b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 11654b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 11664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 11674b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 11684b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 11694b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Setting voice mute state: %d", state); 11704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 11714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 11724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 11734b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->mic_mute(ALL_SESSION_VSID, state, 11744b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_MUTE_RAMP_DURATION_MS); 1175a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent if (ret < 0) { 11764b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_mic_mute error %d", __func__, ret); 117753b2cf0c72aa18a5848919e2309731af652e84f9sangwoo } 1178cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George } 11794b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 11804b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 1181cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 11824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_set_device_mute(void *platform, bool state, char *dir) 11834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 11844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 11854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct audio_device *adev = my_data->adev; 11864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct mixer_ctl *ctl; 11874b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava char *mixer_ctl_name = NULL; 11884b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 11894b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 11904b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 11914b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 0}; 11924b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if(dir == NULL) { 11934b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Invalid direction:%s", __func__, dir); 11944b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 11954b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 11964b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 11974b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!strncmp("rx", dir, sizeof("rx"))) { 11984b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_name = "Voice Rx Device Mute"; 11994b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else if (!strncmp("tx", dir, sizeof("tx"))) { 12004b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_name = "Voice Tx Device Mute"; 12014b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else { 12024b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 12034b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 12044b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 12054b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = state; 12064b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 12074b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 12084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 12094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 12104b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 12114b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 12124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 12134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("%s: Setting device mute state: %d, mixer ctrl:%s", 12144b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__,state, mixer_ctl_name); 12154b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 12164b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 12174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 1218b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1219b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1220b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices) 1221b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1222b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1223b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1224b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_mode_t mode = adev->mode; 1225b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 1226b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1227b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: enter: output devices(%#x)", __func__, devices); 1228b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices == AUDIO_DEVICE_NONE || 1229b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_BIT_IN) { 1230b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: Invalid output devices (%#x)", __func__, devices); 1231b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1232b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1233b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1234b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda if (voice_is_in_call(adev) || adev->enable_voicerx) { 1235b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 123609f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent devices & AUDIO_DEVICE_OUT_WIRED_HEADSET || 123709f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent devices & AUDIO_DEVICE_OUT_LINE) { 1238b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda if (voice_is_in_call(adev) && 1239cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent (adev->voice.tty_mode == TTY_MODE_FULL)) 1240b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES; 1241b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda else if (voice_is_in_call(adev) && 1242cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent (adev->voice.tty_mode == TTY_MODE_VCO)) 1243b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES; 1244b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda else if (voice_is_in_call(adev) && 1245cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent (adev->voice.tty_mode == TTY_MODE_HCO)) 1246b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET; 124709f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent else { 124809f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent if (devices & AUDIO_DEVICE_OUT_LINE) 124909f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent snd_device = SND_DEVICE_OUT_VOICE_LINE; 125009f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent else 125109f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; 125209f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent } 1253b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { 12549f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 12559f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO_WB; 12569f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 12579f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO; 12589f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 12591b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent } else if (devices & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) { 1260b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; 1261b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { 12629d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent if(adev->voice.hac) 12639d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HAC_HANDSET; 12649d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent else if (is_operator_tmus()) 1265b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS; 1266b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1267b4d368e0fe6006657ebc4e1f9ba01a072c4ca2c7Eric Laurent snd_device = SND_DEVICE_OUT_VOICE_HANDSET; 126899c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda } else if (devices & AUDIO_DEVICE_OUT_TELEPHONY_TX) 126999c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_VOICE_TX; 127099c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 1271b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 1272b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1273b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1274b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1275b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1276b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (popcount(devices) == 2) { 1277b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | 1278b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1279b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; 1280b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | 1281b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1282b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; 1283744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_LINE | 1284744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1285744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_LINE; 1286b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL | 1287b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1288b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI; 1289b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1290b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Invalid combo device(%#x)", __func__, devices); 1291b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1292b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1293b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 1294b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1295b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1296b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1297b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1298b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (popcount(devices) != 1) { 1299b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Invalid output devices(%#x)", __func__, devices); 1300b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1301b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1302b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1303b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 1304b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1305b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HEADPHONES; 130609f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent } else if (devices & AUDIO_DEVICE_OUT_LINE) { 130709f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent snd_device = SND_DEVICE_OUT_LINE; 13081b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent } else if (devices & AUDIO_DEVICE_OUT_SPEAKER_SAFE) { 13091b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_SAFE; 1310b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { 13111f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda if (my_data->speaker_lr_swap) 1312b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE; 1313b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1314b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER; 1315b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { 13169f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 13179f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO_WB; 13189f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 13199f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO; 13209f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1321b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { 1322b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HDMI ; 1323b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { 13249d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent /*HAC support for voice-ish audio (eg visual voicemail)*/ 13259d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent if(adev->voice.hac) 13269d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HAC_HANDSET; 13279d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent else 13289d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent snd_device = SND_DEVICE_OUT_HANDSET; 1329b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1330b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown device(s) %#x", __func__, devices); 1331b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1332b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit: 1333b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]); 1334b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return snd_device; 1335b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1336b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1337b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device) 1338b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1339b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1340b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1341b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_source_t source = (adev->active_input == NULL) ? 1342b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_SOURCE_DEFAULT : adev->active_input->source; 1343b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1344b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_mode_t mode = adev->mode; 1345b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_devices_t in_device = ((adev->active_input == NULL) ? 1346b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_NONE : adev->active_input->device) 1347b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent & ~AUDIO_DEVICE_BIT_IN; 1348b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? 1349b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; 1350b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 13513ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda int channel_count = popcount(channel_mask); 1352b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1353b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: enter: out_device(%#x) in_device(%#x)", 1354b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, out_device, in_device); 1355b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda if ((out_device != AUDIO_DEVICE_NONE) && voice_is_in_call(adev)) { 13564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (adev->voice.tty_mode != TTY_MODE_OFF) { 1357b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 135809f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET || 135909f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent out_device & AUDIO_DEVICE_OUT_LINE) { 13604b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava switch (adev->voice.tty_mode) { 1361b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_FULL: 1362b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC; 1363b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1364b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_VCO: 1365b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC; 1366b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1367b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_HCO: 1368b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC; 1369b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1370b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent default: 13714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode); 1372b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1373b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1374b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1375b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1376b991fb007d870cbd682273e5fc7413b9d238a6d9Eric Laurent if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { 1377b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->fluence_in_voice_call == false) { 1378b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1379b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 13803ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (is_operator_tmus()) 13813ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_DMIC_TMUS; 1382b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 13833ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_DMIC; 1384b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1385b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1386b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; 1387b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { 13889f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 13899f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 13909f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 13919f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 13929f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1393b991fb007d870cbd682273e5fc7413b9d238a6d9Eric Laurent } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER || 13941b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent out_device & AUDIO_DEVICE_OUT_SPEAKER_SAFE || 1395b991fb007d870cbd682273e5fc7413b9d238a6d9Eric Laurent out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 1396b991fb007d870cbd682273e5fc7413b9d238a6d9Eric Laurent out_device & AUDIO_DEVICE_OUT_LINE) { 1397b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode && 13983ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 13993ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC; 1400b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1401b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; 1402b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 140399c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda } else if (out_device & AUDIO_DEVICE_OUT_TELEPHONY_TX) 140499c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_RX; 1405b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_CAMCORDER) { 1406b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || 1407b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent in_device & AUDIO_DEVICE_IN_BACK_MIC) { 1408b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_CAMCORDER_MIC; 1409b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1410b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) { 1411b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 14123ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 1413b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) 14143ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_STEREO; 14153ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else if (my_data->fluence_in_voice_rec && 14163ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda adev->active_input->enable_ns) 14173ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE; 1418b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1419b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1420b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device == SND_DEVICE_NONE) { 14213ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (adev->active_input->enable_ns) 14223ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_MIC_NS; 14233ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else 14243ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_MIC; 1425b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1426b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1427b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) { 14281b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent if (out_device & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) 1429b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent in_device = AUDIO_DEVICE_IN_BACK_MIC; 1430b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->active_input) { 14313ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (adev->active_input->enable_aec && 14323ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda adev->active_input->enable_ns) { 14333ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 14343ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_spkr_mode && 14353ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm && 14363ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14373ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS; 14383ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14393ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC_NS; 14403ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 14413ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_voice_comm && 14423ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14433ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC_NS; 14443ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14453ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC_NS; 1446cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 1447cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; 14483ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } 1449cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent platform_set_echo_reference(adev, true, out_device); 14503ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (adev->active_input->enable_aec) { 1451b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 14523ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_spkr_mode && 14533ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm && 14543ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14553ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC; 14563ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14573ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; 1458b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 14593ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_voice_comm && 14603ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14613ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC; 14623ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14633ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC; 1464cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 1465cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; 1466cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } 1467f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda platform_set_echo_reference(adev, true, out_device); 14683ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (adev->active_input->enable_ns) { 14693ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 14703ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_spkr_mode && 14713ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm && 14723ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14733ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS; 14743ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14753ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC_NS; 14763ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 14773ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_voice_comm && 14783ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14793ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_NS; 14803ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14813ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC_NS; 14823ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } 1483cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } 1484b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1485b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_DEFAULT) { 1486b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1487b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1488b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1489b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1490b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 1491b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1492b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1493b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1494b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device != AUDIO_DEVICE_NONE && 1495b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) && 1496b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) { 1497b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 14983ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->dualmic_config != DUALMIC_CONFIG_NONE && 14993ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda channel_count == 2) 15003ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_STEREO; 15013ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else 15023ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC; 1503b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 15043ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->dualmic_config != DUALMIC_CONFIG_NONE && 15053ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda channel_count == 2) 15063ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_STEREO; 15073ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else 15083ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC; 1509b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 1510b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC; 1511b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { 15129f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 15139f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 15149f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 15159f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 15169f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1517b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) { 1518b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HDMI_MIC; 1519b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1520b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown input device(s) %#x", __func__, in_device); 1521b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Using default handset-mic", __func__); 1522b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1523b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1524b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1525b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { 1526b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1527b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1528b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC; 15293ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER || 15301b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent out_device & AUDIO_DEVICE_OUT_SPEAKER_SAFE || 15313ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 153209f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent out_device & AUDIO_DEVICE_OUT_LINE) { 15333ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (channel_count == 2) 15343ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_STEREO; 15353ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else 15363ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC; 1537b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) { 15389f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 15399f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 15409f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 15419f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 15429f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1543b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) { 1544b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HDMI_MIC; 1545b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1546b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown output device(s) %#x", __func__, out_device); 1547b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Using default handset-mic", __func__); 1548b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1549b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1550b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1551b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit: 1552b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]); 1553b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return snd_device; 1554b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1555b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1556b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_hdmi_channels(void *platform, int channel_count) 1557b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1558b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1559b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1560b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 1561b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *channel_cnt_str = NULL; 1562b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "HDMI_RX Channels"; 1563b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent switch (channel_count) { 1564b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 8: 1565b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Eight"; break; 1566b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 7: 1567b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Seven"; break; 1568b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 6: 1569b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Six"; break; 1570b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 5: 1571b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Five"; break; 1572b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 4: 1573b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Four"; break; 1574b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 3: 1575b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Three"; break; 1576b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent default: 1577b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Two"; break; 1578b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1579b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 1580b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 1581b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 1582b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 1583b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 1584b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1585b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("HDMI channel count: %s", channel_cnt_str); 1586b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); 1587b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 1588b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1589b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 159047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew Georgeint platform_edid_get_max_channels(void *platform) 1591b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 159247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct platform_data *my_data = (struct platform_data *)platform; 159347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct audio_device *adev = my_data->adev; 1594b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE]; 1595b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char *sad = block; 1596b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int num_audio_blocks; 1597b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int channel_count; 1598b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int max_channels = 0; 159947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George int i, ret, count; 1600b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 160147cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct mixer_ctl *ctl; 160247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George 160347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ctl = mixer_get_ctl_by_name(adev->mixer, AUDIO_DATA_BLOCK_MIXER_CTL); 160447cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (!ctl) { 160547cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ALOGE("%s: Could not get ctl for mixer cmd - %s", 160647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George __func__, AUDIO_DATA_BLOCK_MIXER_CTL); 1607b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 1608b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1609b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 161047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George mixer_ctl_update(ctl); 161147cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George 161247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George count = mixer_ctl_get_num_values(ctl); 1613b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1614b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Read SAD blocks, clamping the maximum size for safety */ 161547cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (count > (int)sizeof(block)) 161647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George count = (int)sizeof(block); 1617b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 161847cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ret = mixer_ctl_get_array(ctl, block, count); 161947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (ret != 0) { 162047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ALOGE("%s: mixer_ctl_get_array() failed to get EDID info", __func__); 162147cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George return 0; 162247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George } 1623b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1624b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Calculate the number of SAD blocks */ 162547cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George num_audio_blocks = count / SAD_BLOCK_SIZE; 1626b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1627b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent for (i = 0; i < num_audio_blocks; i++) { 1628b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Only consider LPCM blocks */ 162947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if ((sad[0] >> 3) != EDID_FORMAT_LPCM) { 163047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George sad += 3; 1631b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent continue; 163247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George } 1633b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1634b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_count = (sad[0] & 0x7) + 1; 1635b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_count > max_channels) 1636b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent max_channels = channel_count; 1637b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1638b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Advance to next block */ 1639b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent sad += 3; 1640b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1641b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1642b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return max_channels; 1643b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 16447ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George 16454b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_set_incall_recording_session_id(void *platform, 16464b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t session_id, int rec_mode) 16474b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 16484b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 16494b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 16504b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct audio_device *adev = my_data->adev; 16514b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct mixer_ctl *ctl; 16524b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava const char *mixer_ctl_name = "Voc VSID"; 16534b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int num_ctl_values; 16544b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int i; 16554b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 16574b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 16584b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 16594b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 16604b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = -EINVAL; 16614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else { 16624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava num_ctl_values = mixer_ctl_get_num_values(ctl); 16634b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava for (i = 0; i < num_ctl_values; i++) { 16644b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (mixer_ctl_set_value(ctl, i, session_id)) { 16654b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Error: invalid session_id: %x", session_id); 16664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = -EINVAL; 16674b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava break; 16684b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16694b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 16734b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_record(ALL_SESSION_VSID, rec_mode); 16744b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 16754b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_start_record failed, error %d", 16764b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 16774b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16784b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16794b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16804b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 16814b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 16824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_incall_recording_usecase(void *platform) 16844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 16854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 16864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 16874b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16884b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 16894b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_record(ALL_SESSION_VSID); 16904b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 16914b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_stop_record failed, error %d", 16924b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 16934b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16944b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16954b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16964b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 16974b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 16984b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16994b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_start_incall_music_usecase(void *platform) 17004b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 17014b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 17024b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 17034b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 17044b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 17054b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_playback(ALL_SESSION_VSID); 17064b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 17074b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_start_playback failed, error %d", 17084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 17094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 17104b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 17114b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 17124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 17134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 17144b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 17154b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_incall_music_usecase(void *platform) 17164b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 17174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 17184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 17194b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 17204b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 17214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_playback(ALL_SESSION_VSID); 17224b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 17234b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_stop_playback failed, error %d", 17244b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 17254b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 17264b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 17274b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 17284b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 17294b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 17304b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 17317ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George/* Delay in Us */ 17327ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew Georgeint64_t platform_render_latency(audio_usecase_t usecase) 17337ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George{ 17347ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George switch (usecase) { 17357ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: 17367ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return DEEP_BUFFER_PLATFORM_DELAY; 17377ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: 17387ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return LOW_LATENCY_PLATFORM_DELAY; 17397ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George default: 17407ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return 0; 17417ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George } 17427ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George} 174398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 174498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_set_snd_device_backend(snd_device_t device, const char *backend) 174598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 174698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int ret = 0; 174798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 174898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) { 174998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: Invalid snd_device = %d", 175098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George __func__, device); 175198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -EINVAL; 175298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George goto done; 175398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 175498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 175598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (backend_table[device]) { 175698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George free(backend_table[device]); 175798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 175898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[device] = strdup(backend); 175998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgedone: 176098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return ret; 176198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 176298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 176398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id) 176498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 176598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int ret = 0; 176698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((usecase <= USECASE_INVALID) || (usecase >= AUDIO_USECASE_MAX)) { 176798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: invalid usecase case idx %d", __func__, usecase); 176898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -EINVAL; 176998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George goto done; 177098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 177198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 177298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((type != 0) && (type != 1)) { 177398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: invalid usecase type", __func__); 177498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -EINVAL; 177598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 177698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George pcm_device_table[usecase][type] = pcm_id; 177798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgedone: 177898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return ret; 177998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 17801f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda 17811f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamandaint platform_swap_lr_channels(struct audio_device *adev, bool swap_channels) 17821f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda{ 17831f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda // only update if there is active pcm playback on speaker 17841f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda struct audio_usecase *usecase; 17851f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda struct listnode *node; 17861f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)adev->platform; 17871f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda 17881f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda if (my_data->speaker_lr_swap != swap_channels) { 17891f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda my_data->speaker_lr_swap = swap_channels; 17901f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda 17911f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda list_for_each(node, &adev->usecase_list) { 17921f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda usecase = node_to_item(node, struct audio_usecase, list); 17931f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda if (usecase->type == PCM_PLAYBACK && 17941f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER) { 17951f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda const char *mixer_path; 17961f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda if (swap_channels) { 17971f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER_REVERSE); 17981f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda audio_route_apply_and_update_path(adev->audio_route, mixer_path); 17991f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda } else { 18001f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER); 18011f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda audio_route_apply_and_update_path(adev->audio_route, mixer_path); 18021f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda } 18031f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda break; 18041f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda } 18051f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda } 18061f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda } 18071f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda return 0; 18081f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda} 1809