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" 29b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 3047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George#define MIXER_XML_PATH "/system/etc/mixer_paths.xml" 31b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LIB_ACDB_LOADER "libacdbloader.so" 3247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George#define AUDIO_DATA_BLOCK_MIXER_CTL "HDMI EDID" 33b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 34b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_NONE 0 /* Target does not contain 2 mics */ 35b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_ENDFIRE 1 36b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_BROADSIDE 2 37b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 38b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* 39b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * This file will have a maximum of 38 bytes: 40b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 41b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: number of audio blocks 42b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: total length of Short Audio Descriptor (SAD) blocks 43b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Maximum 10 * 3 bytes: SAD blocks 44b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */ 45b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define MAX_SAD_BLOCKS 10 46b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define SAD_BLOCK_SIZE 3 47b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 48b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* EDID format ID for LPCM audio */ 49b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define EDID_FORMAT_LPCM 1 50b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 511b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo/* Retry for delay in FW loading*/ 521b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo#define RETRY_NUMBER 10 531b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo#define RETRY_US 500000 544b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava#define MAX_SND_CARD 8 5553b2cf0c72aa18a5848919e2309731af652e84f9sangwoo 56b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct audio_block_header 57b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 58b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int reserved; 59b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int length; 60b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 61b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 6283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda/* Audio calibration related functions */ 63b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_deallocate_t)(); 6483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 6583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandatypedef int (*acdb_init_t)(char *); 6683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 67b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*acdb_init_t)(); 6883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 69b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_audio_cal_t)(int, int); 70b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_voice_cal_t)(int, int); 7183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandatypedef int (*acdb_reload_vocvoltable_t)(int); 72b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 73b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Audio calibration related functions */ 74b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct platform_data { 75b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev; 76b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_spkr_mode; 77b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_voice_call; 783ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda bool fluence_in_voice_comm; 79b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_voice_rec; 80b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int dualmic_config; 81b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent void *acdb_handle; 823ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_init_t acdb_init; 833ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_deallocate_t acdb_deallocate; 843ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_send_audio_cal_t acdb_send_audio_cal; 853ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_send_voice_cal_t acdb_send_voice_cal; 8683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_reload_vocvoltable_t acdb_reload_vocvoltable; 8783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct csd_data *csd; 88299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda bool ext_speaker; 89299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda bool ext_earpiece; 90f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda char ec_ref_mixer_path[64]; 91b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 92b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 9398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic int pcm_device_table[AUDIO_USECASE_MAX][2] = { 9483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE, 9583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda DEEP_BUFFER_PCM_DEVICE}, 9683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, 9783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda LOWLATENCY_PCM_DEVICE}, 9883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {MULTIMEDIA2_PCM_DEVICE, 9983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda MULTIMEDIA2_PCM_DEVICE}, 10083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_OFFLOAD] = {PLAYBACK_OFFLOAD_DEVICE, 10183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda PLAYBACK_OFFLOAD_DEVICE}, 10283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, 10383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda AUDIO_RECORD_PCM_DEVICE}, 10483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, 10583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda LOWLATENCY_PCM_DEVICE}, 10683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_VOICE_CALL] = {VOICE_CALL_PCM_DEVICE, 10783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda VOICE_CALL_PCM_DEVICE}, 1084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOICE2_CALL] = {VOICE2_CALL_PCM_DEVICE, VOICE2_CALL_PCM_DEVICE}, 1094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOLTE_CALL] = {VOLTE_CALL_PCM_DEVICE, VOLTE_CALL_PCM_DEVICE}, 1104b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_QCHAT_CALL] = {QCHAT_CALL_PCM_DEVICE, QCHAT_CALL_PCM_DEVICE}, 1114b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOWLAN_CALL] = {VOWLAN_CALL_PCM_DEVICE, VOWLAN_CALL_PCM_DEVICE}, 1124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_UPLINK] = {AUDIO_RECORD_PCM_DEVICE, 1134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1144b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, 1154b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1164b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, 1174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1188e6e98fc5af6d6f79bc71eb37df470380ae82fadRavi Kumar Alamanda [USECASE_AUDIO_HFP_SCO] = {HFP_PCM_RX, HFP_SCO_RX}, 11999c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 12099c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_AFE_PROXY] = {AFE_PROXY_PLAYBACK_PCM_DEVICE, 12199c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda AFE_PROXY_RECORD_PCM_DEVICE}, 12299c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD_AFE_PROXY] = {AFE_PROXY_PLAYBACK_PCM_DEVICE, 12399c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda AFE_PROXY_RECORD_PCM_DEVICE}, 12499c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 125b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 126b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 127b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Array to store sound devices */ 128b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const char * const device_table[SND_DEVICE_MAX] = { 129b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_NONE] = "none", 130b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Playback sound devices */ 131b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HANDSET] = "handset", 132b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER] = "speaker", 133b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse", 1341b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent [SND_DEVICE_OUT_SPEAKER_SAFE] = "speaker-safe", 135b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HEADPHONES] = "headphones", 13609f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent [SND_DEVICE_OUT_LINE] = "line", 137b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", 138744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_LINE] = "speaker-and-line", 139b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset", 1409d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent [SND_DEVICE_OUT_VOICE_HAC_HANDSET] = "voice-hac-handset", 141b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker", 142b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones", 14309f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent [SND_DEVICE_OUT_VOICE_LINE] = "voice-line", 144b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HDMI] = "hdmi", 145b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi", 146b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset", 1479f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb", 148b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus", 149b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones", 150b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones", 151b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset", 15299c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_TX] = "voice-tx", 153b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 154b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Capture sound devices */ 155b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic", 1563ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic", 1573ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_NS] = "handset-mic", 1583ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = "handset-mic", 1593ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC] = "dmic-endfire", 1603ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC] = "dmic-endfire", 1613ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_NS] = "dmic-endfire", 1623ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = "dmic-endfire", 1633ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_STEREO] = "dmic-endfire", 1643ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 165b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic", 1663ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "speaker-mic", 1673ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_NS] = "speaker-mic", 1683ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = "speaker-mic", 1693ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC] = "speaker-dmic-endfire", 1703ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = "speaker-dmic-endfire", 1713ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_NS] = "speaker-dmic-endfire", 1723ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = "speaker-dmic-endfire", 1733ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_STEREO] = "speaker-dmic-endfire", 1743ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 175b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic", 176cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic", 1773ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 178b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", 179b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic", 1809f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb", 1813ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 182b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic", 1833ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 1843ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC] = "voice-dmic-ef", 1853ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC_TMUS] = "voice-dmic-ef-tmus", 1863ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", 1873ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef", 1883ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", 189b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic", 190b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic", 191b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic", 1923ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 193b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic", 1943ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_MIC_NS] = "voice-rec-mic", 1953ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = "voice-rec-dmic-ef", 1963ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = "voice-rec-dmic-ef-fluence", 19799c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 19899c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_IN_VOICE_RX] = "voice-rx", 199b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 200b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 201b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* ACDB IDs (audio DSP path configuration IDs) for each sound device */ 2025bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgestatic int acdb_device_table[SND_DEVICE_MAX] = { 203b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_NONE] = -1, 204b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HANDSET] = 7, 205b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER] = 15, 206b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_REVERSE] = 15, 2071b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent [SND_DEVICE_OUT_SPEAKER_SAFE] = 15, 208b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HEADPHONES] = 10, 209744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_LINE] = 77, 210b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10, 211744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_LINE] = 77, 212235c34827f7b3b8977fe76dea1fb8d818fd74312Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_HANDSET] = ACDB_ID_VOICE_HANDSET, 213235c34827f7b3b8977fe76dea1fb8d818fd74312Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_SPEAKER] = ACDB_ID_VOICE_SPEAKER, 2149d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent [SND_DEVICE_OUT_VOICE_HAC_HANDSET] = 53, 215b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10, 216744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_VOICE_LINE] = 77, 217b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HDMI] = 18, 218b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 15, 219b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_BT_SCO] = 22, 2209f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_OUT_BT_SCO_WB] = 39, 22183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = ACDB_ID_VOICE_HANDSET_TMUS, 222b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17, 223b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17, 224b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37, 22599c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_TX] = 45, 226b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 227b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC] = 4, 2283ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC] = 106, 2293ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_NS] = 107, 2303ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = 108, 2313ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC] = 41, 2323ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC] = 109, 2333ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_NS] = 110, 2343ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = 111, 2353ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_STEREO] = 34, 2363ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 2373ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC] = 11, 2383ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 112, 2393ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_NS] = 113, 2403ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = 114, 2413ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC] = 43, 2423ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = 115, 2433ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_NS] = 116, 2443ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = 117, 2453ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_STEREO] = 35, 2463ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 247b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC] = 8, 248cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent [SND_DEVICE_IN_HEADSET_MIC_AEC] = ACDB_ID_HEADSET_MIC_AEC, 2493ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 250b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HDMI_MIC] = 4, 251b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_BT_SCO_MIC] = 21, 2529f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38, 2533ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 254b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_CAMCORDER_MIC] = 61, 2553ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 2563ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC] = 41, 2573ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC_TMUS] = ACDB_ID_VOICE_DMIC_EF_TMUS, 2583ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11, 2593ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 43, 2603ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8, 261b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16, 262b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36, 263b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16, 2643ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 265b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_MIC] = 62, 2663ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_MIC_NS] = 113, 2673ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = 35, 2683ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = 43, 26999c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 27099c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_IN_VOICE_RX] = 44, 271b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 272b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 27398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestruct name_to_index { 2745bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George char name[100]; 2755bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George unsigned int index; 2765bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George}; 2775bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 2785bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George#define TO_NAME_INDEX(X) #X, X 2795bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 28098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George/* Used to get index from parsed string */ 28198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic const struct name_to_index snd_device_name_index[SND_DEVICE_MAX] = { 28298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George /* out */ 2835bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HANDSET)}, 2845bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)}, 2855bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_REVERSE)}, 2861b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_SAFE)}, 2875bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES)}, 28809f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_LINE)}, 2895bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES)}, 290744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_LINE)}, 2915bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET)}, 2925bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER)}, 2935bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HEADPHONES)}, 29409f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_LINE)}, 2955bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HDMI)}, 2965bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HDMI)}, 2975bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO)}, 2985bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO_WB)}, 29998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET_TMUS)}, 3009d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HAC_HANDSET)}, 3015bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES)}, 3025bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES)}, 3035bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET)}, 30498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 30598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George /* in */ 3065bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC)}, 30798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC)}, 3083ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_NS)}, 3093ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC_NS)}, 3103ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC)}, 3113ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC)}, 3123ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_NS)}, 3133ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC_NS)}, 3143ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_STEREO)}, 3153ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3163ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC)}, 31798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC)}, 3183ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_NS)}, 3193ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC_NS)}, 3203ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC)}, 3213ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC)}, 3223ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_NS)}, 3233ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS)}, 3243ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_STEREO)}, 3253ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3263ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC)}, 3273ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3285bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HDMI_MIC)}, 3295bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC)}, 3305bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB)}, 3313ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3325bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_MIC)}, 3333ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3343ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC)}, 3353ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC_TMUS)}, 3363ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_MIC)}, 3373ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_DMIC)}, 3383ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_HEADSET_MIC)}, 3395bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC)}, 3405bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC)}, 3415bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC)}, 3423ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3435bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC)}, 3443ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC_NS)}, 3453ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_STEREO)}, 3463ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE)}, 34798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George}; 34898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 34998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic char * backend_table[SND_DEVICE_MAX] = {0}; 35098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 35198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic const struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { 35298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_DEEP_BUFFER)}, 35398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_LOW_LATENCY)}, 35498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MULTI_CH)}, 35598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD)}, 35698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_RECORD)}, 35798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)}, 35898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOICE_CALL)}, 35998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOICE2_CALL)}, 36098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOLTE_CALL)}, 36198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_QCHAT_CALL)}, 36298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOWLAN_CALL)}, 36398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK)}, 36498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_INCALL_REC_DOWNLINK)}, 36598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK_AND_DOWNLINK)}, 36698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_HFP_SCO)}, 3675bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George}; 3685bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 3697ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) 3707ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) 3717ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George 372b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT; 373b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic bool is_tmus = false; 374b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 375b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic void check_operator() 376b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 377b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char value[PROPERTY_VALUE_MAX]; 378b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int mccmnc; 379b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("gsm.sim.operator.numeric",value,"0"); 380b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mccmnc = atoi(value); 381b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGD("%s: tmus mccmnc %d", __func__, mccmnc); 382b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent switch(mccmnc) { 383b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* TMUS MCC(310), MNC(490, 260, 026) */ 384b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310490: 385b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310260: 386b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310026: 387b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon /* Add new TMUS MNC(800, 660, 580, 310, 270, 250, 240, 230, 220, 210, 200, 160) */ 388b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310800: 389b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310660: 390b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310580: 391b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310310: 392b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310270: 393b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310250: 394b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310240: 395b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310230: 396b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310220: 397b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310210: 398b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310200: 399b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310160: 400b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent is_tmus = true; 401b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 402b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 403b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 404b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 405b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentbool is_operator_tmus() 406b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 407b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent pthread_once(&check_op_once_ctl, check_operator); 408b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return is_tmus; 409b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 410b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 411cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurentvoid platform_set_echo_reference(struct audio_device *adev, bool enable, audio_devices_t out_device) 412b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 413f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)adev->platform; 414cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 415cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent 416f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda if (strcmp(my_data->ec_ref_mixer_path, "")) { 417f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda ALOGV("%s: diabling %s", __func__, my_data->ec_ref_mixer_path); 418f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda audio_route_reset_and_update_path(adev->audio_route, my_data->ec_ref_mixer_path); 419cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } 420cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent 421f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda if (enable) { 422f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda strcpy(my_data->ec_ref_mixer_path, "echo-reference"); 423f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda if (out_device != AUDIO_DEVICE_NONE) { 424f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda snd_device = platform_get_output_snd_device(adev->platform, out_device); 425f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda platform_add_backend_name(adev->platform, my_data->ec_ref_mixer_path, snd_device); 426f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda } 427b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 428f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda ALOGD("%s: enabling %s", __func__, my_data->ec_ref_mixer_path); 429f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda audio_route_apply_and_update_path(adev->audio_route, my_data->ec_ref_mixer_path); 430f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda } 431b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 432b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 43383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandastatic struct csd_data *open_csd_client(bool i2s_ext_modem) 43483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 43583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct csd_data *csd = calloc(1, sizeof(struct csd_data)); 43683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 43783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW); 43883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->csd_client == NULL) { 43983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT); 44083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 44183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 44283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT); 44383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 44483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->deinit = (deinit_t)dlsym(csd->csd_client, 44583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_deinit"); 44683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->deinit == NULL) { 44783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_deinit", __func__, 44883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda dlerror()); 44983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 45083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 45183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->disable_device = (disable_device_t)dlsym(csd->csd_client, 45283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_disable_device"); 45383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->disable_device == NULL) { 45483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_disable_device", 45583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 45683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 45783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 45883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->enable_device_config = (enable_device_config_t)dlsym(csd->csd_client, 45983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_enable_device_config"); 46083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->enable_device_config == NULL) { 46183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_enable_device_config", 46283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 46383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 46483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 46583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->enable_device = (enable_device_t)dlsym(csd->csd_client, 46683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_enable_device"); 46783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->enable_device == NULL) { 46883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_enable_device", 46983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 47083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 47183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 47283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_voice = (start_voice_t)dlsym(csd->csd_client, 47383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_voice"); 47483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_voice == NULL) { 47583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_voice", 47683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 47783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 47883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 47983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_voice = (stop_voice_t)dlsym(csd->csd_client, 48083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_voice"); 48183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_voice == NULL) { 48283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_voice", 48383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 48483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 48583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 48683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->volume = (volume_t)dlsym(csd->csd_client, 48783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_volume"); 48883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->volume == NULL) { 48983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_volume", 49083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 49183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 49283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 49383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->mic_mute = (mic_mute_t)dlsym(csd->csd_client, 49483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_mic_mute"); 49583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->mic_mute == NULL) { 49683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_mic_mute", 49783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 49883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 49983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 50083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->slow_talk = (slow_talk_t)dlsym(csd->csd_client, 50183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_slow_talk"); 50283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->slow_talk == NULL) { 50383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_slow_talk", 50483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 50583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 50683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 50783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_playback = (start_playback_t)dlsym(csd->csd_client, 50883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_playback"); 50983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_playback == NULL) { 51083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_playback", 51183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 51283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 51383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 51483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_playback = (stop_playback_t)dlsym(csd->csd_client, 51583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_playback"); 51683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_playback == NULL) { 51783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_playback", 51883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 51983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 52083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 52183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_record = (start_record_t)dlsym(csd->csd_client, 52283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_record"); 52383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_record == NULL) { 52483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_record", 52583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 52683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 52783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 52883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_record = (stop_record_t)dlsym(csd->csd_client, 52983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_record"); 53083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_record == NULL) { 53183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_record", 53283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 53383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 53483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 53583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 53683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->get_sample_rate = (get_sample_rate_t)dlsym(csd->csd_client, 53783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_get_sample_rate"); 53883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->get_sample_rate == NULL) { 53983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_get_sample_rate", 54083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 54183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 54283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 54383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 54483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 54583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->init = (init_t)dlsym(csd->csd_client, "csd_client_init"); 54683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 54783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->init == NULL) { 54883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_init", 54983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 55083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 55183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 55283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->init(i2s_ext_modem); 55383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 55483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 55583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return csd; 55683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 55783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaerror: 55883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda free(csd); 55983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd = NULL; 56083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return csd; 56183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 56283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 56383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandavoid close_csd_client(struct csd_data *csd) 56483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 56583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd != NULL) { 56683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->deinit(); 56783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda dlclose(csd->csd_client); 56883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda free(csd); 56983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd = NULL; 57083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 57183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 57283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 57383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandastatic void platform_csd_init(struct platform_data *my_data) 57483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 57583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 576ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev int32_t modems, (*count_modems)(void); 577ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev const char *name = "libdetectmodem.so"; 578ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev const char *func = "count_modems"; 579ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev const char *error; 580ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 581ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev my_data->csd = NULL; 582ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 583ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev void *lib = dlopen(name, RTLD_NOW); 584ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev error = dlerror(); 585ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (!lib) { 586ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGE("%s: could not find %s: %s", __func__, name, error); 587ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev return; 588ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev } 589ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 590ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev count_modems = NULL; 591ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev *(void **)(&count_modems) = dlsym(lib, func); 592ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev error = dlerror(); 593ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (!count_modems) { 594ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGE("%s: could not find symbol %s in %s: %s", 595ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev __func__, func, name, error); 596ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev goto done; 59783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 59883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 599ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev modems = count_modems(); 600ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (modems < 0) { 601ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGE("%s: count_modems failed\n", __func__); 602ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev goto done; 603ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev } 604ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 605ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGD("%s: num_modems %d\n", __func__, modems); 606ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (modems > 0) 60783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->csd = open_csd_client(false /*is_i2s_ext_modem*/); 608ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 609ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchevdone: 610ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev dlclose(lib); 61183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 61283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->csd = NULL; 61383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 61483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 61583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 61698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic void set_platform_defaults(struct platform_data * my_data) 61798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 61898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int32_t dev; 61998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George for (dev = 0; dev < SND_DEVICE_MAX; dev++) { 62098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[dev] = NULL; 62198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 62298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 62398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George // TBD - do these go to the platform-info.xml file. 62498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George // will help in avoiding strdups here 62598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_IN_BT_SCO_MIC] = strdup("bt-sco"); 62698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_BT_SCO] = strdup("bt-sco"); 62798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_HDMI] = strdup("hdmi"); 62898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("speaker-and-hdmi"); 62998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("bt-sco-wb"); 63098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_IN_BT_SCO_MIC_WB] = strdup("bt-sco-wb"); 63199c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda backend_table[SND_DEVICE_OUT_VOICE_TX] = strdup("afe-proxy"); 63299c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda backend_table[SND_DEVICE_IN_VOICE_RX] = strdup("afe-proxy"); 63398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 63498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (my_data->ext_speaker) { 63598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_SPEAKER] = strdup("speaker"); 6361b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent backend_table[SND_DEVICE_OUT_SPEAKER_SAFE] = strdup("speaker"); 63798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_VOICE_SPEAKER] = strdup("speaker"); 63898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_SPEAKER_REVERSE] = strdup("speaker"); 63998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 64098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George strdup("speaker-and-headphones"); 641744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent backend_table[SND_DEVICE_OUT_SPEAKER_AND_LINE] = 642744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent strdup("speaker-and-line"); 64398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 64498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 64598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (my_data->ext_earpiece) { 64698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_VOICE_HANDSET] = strdup("handset"); 6479d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent backend_table[SND_DEVICE_OUT_VOICE_HAC_HANDSET] = strdup("handset"); 64898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = strdup("handset"); 64998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_HANDSET] = strdup("handset"); 65098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = strdup("handset"); 65198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 65298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 65398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 654b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid *platform_init(struct audio_device *adev) 655b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 656b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char value[PROPERTY_VALUE_MAX]; 657b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data; 6584b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int retry_num = 0, snd_card_num = 0; 65983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda const char *snd_card_name; 6601b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 6614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava while (snd_card_num < MAX_SND_CARD) { 6624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->mixer = mixer_open(snd_card_num); 6631b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 6644b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava while (!adev->mixer && retry_num < RETRY_NUMBER) { 6654b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava usleep(RETRY_US); 6664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->mixer = mixer_open(snd_card_num); 6674b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava retry_num++; 6684b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 66983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 6704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!adev->mixer) { 6714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Unable to open the mixer card: %d", __func__, 6724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_num); 6734b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava retry_num = 0; 6744b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_num++; 6754b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava continue; 6764b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 677cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 6784b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_name = mixer_get_name(adev->mixer); 6794b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGD("%s: snd_card_name: %s", __func__, snd_card_name); 680a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent 6814b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->audio_route = audio_route_init(snd_card_num, MIXER_XML_PATH); 6824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!adev->audio_route) { 6834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Failed to init audio route controls, aborting.", __func__); 6844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return NULL; 6854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 6864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->snd_card = snd_card_num; 6874b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGD("%s: Opened sound card:%d", __func__, snd_card_num); 6884b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava break; 6894b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 6904b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 6914b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (snd_card_num >= MAX_SND_CARD) { 6924b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Unable to find correct sound card, aborting.", __func__); 6931b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo return NULL; 6941b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo } 695b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 696b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data = calloc(1, sizeof(struct platform_data)); 697b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 698b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->adev = adev; 699b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config = DUALMIC_CONFIG_NONE; 700b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_spkr_mode = false; 701b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_call = false; 7023ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm = false; 703b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_rec = false; 704b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 705299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda /* 706299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * The default assumption is that earpiece (handset), speaker and headphones 707299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * devices are connected to internal HW codec and communicated through 708299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * slimbus backend. If any platform communicates with speaker or earpiece 709299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * or headphones through non-slimbus backend such as MI2S or AUXPCM etc., 710299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * the ext_xxxx flags must be set accordingly. 711299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda */ 712299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda if (strstr(snd_card_name, "tfa9890_stereo")) { 713299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda my_data->ext_speaker = true; 714299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda my_data->ext_earpiece = true; 715299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda } else if (strstr(snd_card_name, "tfa9890")) { 716299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda my_data->ext_speaker = true; 717299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda } 718299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda 719b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.dualmic.config",value,""); 720b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("broadside", value)) { 7213ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda ALOGE("%s: Unsupported dualmic configuration", __func__); 722b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (!strcmp("endfire", value)) { 723b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config = DUALMIC_CONFIG_ENDFIRE; 724b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 725b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 726b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 727b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.voicecall",value,""); 728b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 729b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_call = true; 730b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 731b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 7323ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda property_get("persist.audio.fluence.voicecomm",value,""); 7333ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (!strcmp("true", value)) { 7343ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm = true; 7353ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } 7363ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 737b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.voicerec",value,""); 738b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 739b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_rec = true; 740b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 741b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 742b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.speaker",value,""); 743b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 744b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_spkr_mode = true; 745b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 746b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 747b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 748b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); 749b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_handle == NULL) { 750b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER); 751b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 752b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER); 753b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle, 754b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_deallocate_ACDB"); 75583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_deallocate) 75683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_deallocate_ACDB from %s", 75783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 75883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 759b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle, 760b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_send_audio_cal"); 761b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!my_data->acdb_send_audio_cal) 76283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_send_audio_cal from %s", 763b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, LIB_ACDB_LOADER); 76483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 765b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle, 766b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_send_voice_cal"); 76783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_send_voice_cal) 76883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_send_voice_cal from %s", 76983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 77083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 77183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->acdb_reload_vocvoltable = (acdb_reload_vocvoltable_t)dlsym(my_data->acdb_handle, 77283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "acdb_loader_reload_vocvoltable"); 77383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_reload_vocvoltable) 77483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_reload_vocvoltable from %s", 77583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 77683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 77783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, 77883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "acdb_loader_init_v2"); 77983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->acdb_init == NULL) 78083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror()); 78183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda else 78298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George my_data->acdb_init((char *)snd_card_name); 78383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 784b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, 785b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_init_ACDB"); 786b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_init == NULL) 787b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror()); 788b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 789b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_init(); 79083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 7915bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 792b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 793b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 79498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George set_platform_defaults(my_data); 79598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 79698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George /* Initialize platform specific ids and/or backends*/ 79798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George platform_info_init(); 79898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 79983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda /* load csd client */ 80083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda platform_csd_init(my_data); 80183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 802b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return my_data; 803b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 804b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 805b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid platform_deinit(void *platform) 806b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 8074b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 8084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava close_csd_client(my_data->csd); 809b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent free(platform); 810b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 811b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 812b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentconst char *platform_get_snd_device_name(snd_device_t snd_device) 813b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 814b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) 815b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return device_table[snd_device]; 816b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 8176402646dbd962f62c37abbb1d435907d54da77ddRavi Kumar Alamanda return "none"; 818b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 819b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 820299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamandavoid platform_add_backend_name(void *platform, char *mixer_path, 821299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda snd_device_t snd_device) 822b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 823299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 824299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda 82598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { 82698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); 82798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return; 8281de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda } 82998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 83098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George const char * suffix = backend_table[snd_device]; 83198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 83298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (suffix != NULL) { 83398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George strcat(mixer_path, " "); 83498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George strcat(mixer_path, suffix); 835299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda } 836b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 837b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 838b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) 839b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 840b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int device_id; 841b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (device_type == PCM_PLAYBACK) 842b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent device_id = pcm_device_table[usecase][0]; 843b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 844b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent device_id = pcm_device_table[usecase][1]; 845b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return device_id; 846b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 847b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 84898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic int find_index(const struct name_to_index * table, int32_t len, 84998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George const char * name) 8505bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George{ 8515bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George int ret = 0; 85298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int32_t i; 8535bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 85498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (table == NULL) { 85598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: table is NULL", __func__); 8565bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -ENODEV; 8575bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 8585bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 8595bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 86098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (name == NULL) { 86198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("null key"); 86298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -ENODEV; 86398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George goto done; 86498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 86598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 86698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George for (i=0; i < len; i++) { 86798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (!strcmp(table[i].name, name)) { 86898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = table[i].index; 8695bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 8705bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 8715bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 87298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: Could not find index for name = %s", 87398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George __func__, name); 8745bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -ENODEV; 8755bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgedone: 8765bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George return ret; 8775bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George} 8785bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 87998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_get_snd_device_index(char *device_name) 88098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 88198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return find_index(snd_device_name_index, SND_DEVICE_MAX, device_name); 88298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 88398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 88498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_get_usecase_index(const char *usecase_name) 88598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 88698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return find_index(usecase_name_index, AUDIO_USECASE_MAX, usecase_name); 88798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 88898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 8895bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgeint platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id) 8905bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George{ 8915bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George int ret = 0; 8925bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 8935bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { 8945bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ALOGE("%s: Invalid snd_device = %d", 8955bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George __func__, snd_device); 8965bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -EINVAL; 8975bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 8985bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 8995bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 9005bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George acdb_device_table[snd_device] = acdb_id; 9015bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgedone: 9025bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George return ret; 9035bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George} 9045bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 905b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_send_audio_calibration(void *platform, snd_device_t snd_device) 906b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 907b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 908b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int acdb_dev_id, acdb_dev_type; 909b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 910b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_id = acdb_device_table[snd_device]; 911b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (acdb_dev_id < 0) { 912b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not find acdb id for device(%d)", 913b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, snd_device); 914b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 915b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 916b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_send_audio_cal) { 9173ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda ALOGD("%s: sending audio calibration for snd_device(%d) acdb_id(%d)", 918b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, snd_device, acdb_dev_id); 919b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device >= SND_DEVICE_OUT_BEGIN && 920b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device < SND_DEVICE_OUT_END) 921b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_type = ACDB_DEV_TYPE_OUT; 922b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 923b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_type = ACDB_DEV_TYPE_IN; 924b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type); 925b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 926b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 927b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 928b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 929b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_pre(void *platform) 930b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 93183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 93283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 93383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 93483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL && 935b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda voice_is_in_call(my_data->adev)) { 93683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda /* This must be called before disabling mixer controls on APQ side */ 93783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->disable_device(); 93883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 93983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_client_disable_device, failed, error %d", 94083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, ret); 94183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 94283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 94383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 94483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 94583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 94683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_enable_device_config(void *platform, 94783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t out_snd_device, 94883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t in_snd_device) 94983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 95083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 95183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int acdb_rx_id, acdb_tx_id; 95283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 95383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 95483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd == NULL) 95583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 95683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 95783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id = acdb_device_table[out_snd_device]; 95883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 95983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_tx_id = acdb_device_table[in_snd_device]; 96083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 96183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (acdb_rx_id > 0 && acdb_tx_id > 0) { 96283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id); 96383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 96483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_enable_device_config, failed, error %d", 96583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, ret); 96683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 96783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 96883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 96983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id, acdb_tx_id); 97083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 97183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 97283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 973b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 974b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 975b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_post(void *platform, 976b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t out_snd_device, 977b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t in_snd_device) 978b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 979b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 980b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int acdb_rx_id, acdb_tx_id; 981b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 982b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_send_voice_cal == NULL) { 983b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error for acdb_send_voice_call", __func__); 984b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 985b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_rx_id = acdb_device_table[out_snd_device]; 986b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_tx_id = acdb_device_table[in_snd_device]; 987b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 988b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (acdb_rx_id > 0 && acdb_tx_id > 0) 989b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id); 990b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 991b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 992b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_rx_id, acdb_tx_id); 993b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 994b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 995b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 996b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 997b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 99883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_usecase_route_post(void *platform, 99983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t out_snd_device, 100083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t in_snd_device) 100183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 100283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 100383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int acdb_rx_id, acdb_tx_id; 100483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 100583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 100683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd == NULL) 100783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 100883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 100983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id = acdb_device_table[out_snd_device]; 101083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 101183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_tx_id = acdb_device_table[in_snd_device]; 101283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 101383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (acdb_rx_id > 0 && acdb_tx_id > 0) { 101483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->enable_device(acdb_rx_id, acdb_tx_id, 101583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->adev->acdb_settings); 101683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 101783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_enable_device, failed, error %d", __func__, ret); 101883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 101983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 102083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 102183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id, acdb_tx_id); 102283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 102383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 102483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 102583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 102683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 10274b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_start_voice_call(void *platform, uint32_t vsid) 1028b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 102983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 103083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 103183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 103283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 10334b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_voice(vsid); 103483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 103583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_start_voice error %d\n", __func__, ret); 103683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 103783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 103883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1039b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1040b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 10414b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_voice_call(void *platform, uint32_t vsid) 1042b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 104383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 104483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 104583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 104683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 10474b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_voice(vsid); 104883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 104983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_stop_voice error %d\n", __func__, ret); 105083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 105183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 105283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1053b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1054b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 10554b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_get_sample_rate(void *platform, uint32_t *rate) 10564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 10574b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 10584b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 10594b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 10604b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 10614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->get_sample_rate(rate); 10624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 10634b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_get_sample_rate error %d\n", __func__, ret); 10644b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 10654b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 10664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 10674b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 10684b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 1069b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_voice_volume(void *platform, int volume) 1070b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1071b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1072b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1073b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 107453b2cf0c72aa18a5848919e2309731af652e84f9sangwoo const char *mixer_ctl_name = "Voice Rx Gain"; 10754b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int vol_index = 0, ret = 0; 10764b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 10774b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 10784b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_VOLUME_RAMP_DURATION_MS}; 1079b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1080b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // Voice volume levels are mapped to adsp volume levels as follows. 1081b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // 100 -> 5, 80 -> 4, 60 -> 3, 40 -> 2, 20 -> 1 0 -> 0 1082b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // But this values don't changed in kernel. So, below change is need. 10834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava vol_index = (int)percent_to_index(volume, MIN_VOL_INDEX, MAX_VOL_INDEX); 10844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = vol_index; 1085b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1086b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 1087b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 1088b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 1089b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 1090b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 1091b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 10924b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Setting voice volume index: %d", set_values[0]); 10934b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 10944b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 109583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 109683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->volume(ALL_SESSION_VSID, volume, 109783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda DEFAULT_VOLUME_RAMP_DURATION_MS); 109883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 109983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_volume error %d", __func__, ret); 110083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 110183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 110283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1103b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1104b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1105b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_mic_mute(void *platform, bool state) 1106b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1107b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1108b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1109b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 1110b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "Voice Tx Mute"; 111153b2cf0c72aa18a5848919e2309731af652e84f9sangwoo int ret = 0; 11124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 11134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 11144b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_MUTE_RAMP_DURATION_MS}; 1115cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 11164b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (adev->mode != AUDIO_MODE_IN_CALL) 11174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return 0; 11184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 11194b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = state; 11204b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 11214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 11224b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 11234b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 11244b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 11254b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 11264b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Setting voice mute state: %d", state); 11274b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 11284b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 11294b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 11304b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->mic_mute(ALL_SESSION_VSID, state, 11314b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_MUTE_RAMP_DURATION_MS); 1132a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent if (ret < 0) { 11334b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_mic_mute error %d", __func__, ret); 113453b2cf0c72aa18a5848919e2309731af652e84f9sangwoo } 1135cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George } 11364b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 11374b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 1138cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 11394b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_set_device_mute(void *platform, bool state, char *dir) 11404b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 11414b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 11424b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct audio_device *adev = my_data->adev; 11434b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct mixer_ctl *ctl; 11444b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava char *mixer_ctl_name = NULL; 11454b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 11464b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 11474b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 11484b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 0}; 11494b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if(dir == NULL) { 11504b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Invalid direction:%s", __func__, dir); 11514b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 11524b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 11534b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 11544b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!strncmp("rx", dir, sizeof("rx"))) { 11554b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_name = "Voice Rx Device Mute"; 11564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else if (!strncmp("tx", dir, sizeof("tx"))) { 11574b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_name = "Voice Tx Device Mute"; 11584b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else { 11594b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 11604b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 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 11704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("%s: Setting device mute state: %d, mixer ctrl:%s", 11714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__,state, mixer_ctl_name); 11724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 11734b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 11744b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 1175b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1176b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1177b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices) 1178b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1179b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1180b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1181b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_mode_t mode = adev->mode; 1182b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 1183b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1184b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: enter: output devices(%#x)", __func__, devices); 1185b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices == AUDIO_DEVICE_NONE || 1186b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_BIT_IN) { 1187b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: Invalid output devices (%#x)", __func__, devices); 1188b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1189b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1190b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1191b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda if (voice_is_in_call(adev) || adev->enable_voicerx) { 1192b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 119309f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent devices & AUDIO_DEVICE_OUT_WIRED_HEADSET || 119409f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent devices & AUDIO_DEVICE_OUT_LINE) { 1195b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda if (voice_is_in_call(adev) && 1196cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent (adev->voice.tty_mode == TTY_MODE_FULL)) 1197b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES; 1198b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda else if (voice_is_in_call(adev) && 1199cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent (adev->voice.tty_mode == TTY_MODE_VCO)) 1200b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES; 1201b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda else if (voice_is_in_call(adev) && 1202cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent (adev->voice.tty_mode == TTY_MODE_HCO)) 1203b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET; 120409f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent else { 120509f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent if (devices & AUDIO_DEVICE_OUT_LINE) 120609f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent snd_device = SND_DEVICE_OUT_VOICE_LINE; 120709f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent else 120809f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; 120909f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent } 1210b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { 12119f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 12129f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO_WB; 12139f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 12149f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO; 12159f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 12161b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent } else if (devices & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) { 1217b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; 1218b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { 12199d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent if(adev->voice.hac) 12209d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HAC_HANDSET; 12219d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent else if (is_operator_tmus()) 1222b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS; 1223b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1224b4d368e0fe6006657ebc4e1f9ba01a072c4ca2c7Eric Laurent snd_device = SND_DEVICE_OUT_VOICE_HANDSET; 122599c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda } else if (devices & AUDIO_DEVICE_OUT_TELEPHONY_TX) 122699c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_VOICE_TX; 122799c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 1228b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 1229b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1230b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1231b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1232b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1233b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (popcount(devices) == 2) { 1234b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | 1235b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1236b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; 1237b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | 1238b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1239b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; 1240744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_LINE | 1241744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1242744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_LINE; 1243b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL | 1244b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1245b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI; 1246b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1247b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Invalid combo device(%#x)", __func__, devices); 1248b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1249b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1250b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 1251b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1252b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1253b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1254b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1255b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (popcount(devices) != 1) { 1256b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Invalid output devices(%#x)", __func__, devices); 1257b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1258b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1259b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1260b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 1261b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1262b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HEADPHONES; 126309f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent } else if (devices & AUDIO_DEVICE_OUT_LINE) { 126409f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent snd_device = SND_DEVICE_OUT_LINE; 12651b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent } else if (devices & AUDIO_DEVICE_OUT_SPEAKER_SAFE) { 12661b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_SAFE; 1267b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { 1268b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->speaker_lr_swap) 1269b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE; 1270b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1271b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER; 1272b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { 12739f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 12749f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO_WB; 12759f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 12769f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO; 12779f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1278b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { 1279b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HDMI ; 1280b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { 12819d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent /*HAC support for voice-ish audio (eg visual voicemail)*/ 12829d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent if(adev->voice.hac) 12839d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HAC_HANDSET; 12849d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent else 12859d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent snd_device = SND_DEVICE_OUT_HANDSET; 1286b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1287b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown device(s) %#x", __func__, devices); 1288b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1289b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit: 1290b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]); 1291b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return snd_device; 1292b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1293b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1294b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device) 1295b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1296b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1297b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1298b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_source_t source = (adev->active_input == NULL) ? 1299b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_SOURCE_DEFAULT : adev->active_input->source; 1300b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1301b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_mode_t mode = adev->mode; 1302b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_devices_t in_device = ((adev->active_input == NULL) ? 1303b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_NONE : adev->active_input->device) 1304b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent & ~AUDIO_DEVICE_BIT_IN; 1305b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? 1306b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; 1307b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 13083ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda int channel_count = popcount(channel_mask); 1309b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1310b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: enter: out_device(%#x) in_device(%#x)", 1311b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, out_device, in_device); 1312b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda if ((out_device != AUDIO_DEVICE_NONE) && voice_is_in_call(adev)) { 13134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (adev->voice.tty_mode != TTY_MODE_OFF) { 1314b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 131509f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET || 131609f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent out_device & AUDIO_DEVICE_OUT_LINE) { 13174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava switch (adev->voice.tty_mode) { 1318b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_FULL: 1319b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC; 1320b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1321b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_VCO: 1322b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC; 1323b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1324b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_HCO: 1325b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC; 1326b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1327b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent default: 13284b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode); 1329b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1330b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1331b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1332b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1333b991fb007d870cbd682273e5fc7413b9d238a6d9Eric Laurent if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { 1334b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->fluence_in_voice_call == false) { 1335b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1336b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 13373ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (is_operator_tmus()) 13383ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_DMIC_TMUS; 1339b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 13403ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_DMIC; 1341b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1342b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1343b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; 1344b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { 13459f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 13469f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 13479f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 13489f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 13499f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1350b991fb007d870cbd682273e5fc7413b9d238a6d9Eric Laurent } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER || 13511b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent out_device & AUDIO_DEVICE_OUT_SPEAKER_SAFE || 1352b991fb007d870cbd682273e5fc7413b9d238a6d9Eric Laurent out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 1353b991fb007d870cbd682273e5fc7413b9d238a6d9Eric Laurent out_device & AUDIO_DEVICE_OUT_LINE) { 1354b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode && 13553ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 13563ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC; 1357b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1358b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; 1359b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 136099c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda } else if (out_device & AUDIO_DEVICE_OUT_TELEPHONY_TX) 136199c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_RX; 1362b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_CAMCORDER) { 1363b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || 1364b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent in_device & AUDIO_DEVICE_IN_BACK_MIC) { 1365b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_CAMCORDER_MIC; 1366b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1367b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) { 1368b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 13693ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 1370b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) 13713ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_STEREO; 13723ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else if (my_data->fluence_in_voice_rec && 13733ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda adev->active_input->enable_ns) 13743ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE; 1375b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1376b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1377b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device == SND_DEVICE_NONE) { 13783ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (adev->active_input->enable_ns) 13793ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_MIC_NS; 13803ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else 13813ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_MIC; 1382b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1383b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1384b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) { 13851b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent if (out_device & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) 1386b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent in_device = AUDIO_DEVICE_IN_BACK_MIC; 1387b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->active_input) { 13883ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (adev->active_input->enable_aec && 13893ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda adev->active_input->enable_ns) { 13903ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 13913ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_spkr_mode && 13923ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm && 13933ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 13943ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS; 13953ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 13963ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC_NS; 13973ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 13983ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_voice_comm && 13993ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14003ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC_NS; 14013ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14023ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC_NS; 1403cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 1404cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; 14053ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } 1406cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent platform_set_echo_reference(adev, true, out_device); 14073ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (adev->active_input->enable_aec) { 1408b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 14093ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_spkr_mode && 14103ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm && 14113ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14123ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC; 14133ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14143ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; 1415b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 14163ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_voice_comm && 14173ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14183ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC; 14193ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14203ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC; 1421cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 1422cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; 1423cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } 1424f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda platform_set_echo_reference(adev, true, out_device); 14253ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (adev->active_input->enable_ns) { 14263ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 14273ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_spkr_mode && 14283ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm && 14293ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14303ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS; 14313ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14323ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC_NS; 14333ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 14343ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_voice_comm && 14353ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 14363ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_NS; 14373ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else 14383ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC_NS; 14393ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } 1440cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } 1441b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1442b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_DEFAULT) { 1443b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1444b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1445b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1446b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1447b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 1448b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1449b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1450b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1451b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device != AUDIO_DEVICE_NONE && 1452b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) && 1453b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) { 1454b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 14553ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->dualmic_config != DUALMIC_CONFIG_NONE && 14563ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda channel_count == 2) 14573ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_STEREO; 14583ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else 14593ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC; 1460b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 14613ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->dualmic_config != DUALMIC_CONFIG_NONE && 14623ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda channel_count == 2) 14633ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_STEREO; 14643ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else 14653ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC; 1466b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 1467b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC; 1468b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { 14699f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 14709f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 14719f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 14729f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 14739f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1474b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) { 1475b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HDMI_MIC; 1476b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1477b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown input device(s) %#x", __func__, in_device); 1478b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Using default handset-mic", __func__); 1479b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1480b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1481b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1482b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { 1483b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1484b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1485b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC; 14863ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER || 14871b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent out_device & AUDIO_DEVICE_OUT_SPEAKER_SAFE || 14883ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 148909f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent out_device & AUDIO_DEVICE_OUT_LINE) { 14903ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (channel_count == 2) 14913ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_STEREO; 14923ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else 14933ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC; 1494b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) { 14959f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 14969f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 14979f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 14989f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 14999f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1500b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) { 1501b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HDMI_MIC; 1502b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1503b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown output device(s) %#x", __func__, out_device); 1504b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Using default handset-mic", __func__); 1505b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1506b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1507b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1508b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit: 1509b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]); 1510b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return snd_device; 1511b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1512b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1513b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_hdmi_channels(void *platform, int channel_count) 1514b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1515b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1516b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1517b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 1518b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *channel_cnt_str = NULL; 1519b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "HDMI_RX Channels"; 1520b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent switch (channel_count) { 1521b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 8: 1522b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Eight"; break; 1523b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 7: 1524b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Seven"; break; 1525b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 6: 1526b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Six"; break; 1527b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 5: 1528b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Five"; break; 1529b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 4: 1530b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Four"; break; 1531b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 3: 1532b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Three"; break; 1533b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent default: 1534b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Two"; break; 1535b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1536b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 1537b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 1538b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 1539b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 1540b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 1541b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1542b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("HDMI channel count: %s", channel_cnt_str); 1543b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); 1544b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 1545b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1546b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 154747cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew Georgeint platform_edid_get_max_channels(void *platform) 1548b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 154947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct platform_data *my_data = (struct platform_data *)platform; 155047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct audio_device *adev = my_data->adev; 1551b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE]; 1552b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char *sad = block; 1553b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int num_audio_blocks; 1554b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int channel_count; 1555b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int max_channels = 0; 155647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George int i, ret, count; 1557b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 155847cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct mixer_ctl *ctl; 155947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George 156047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ctl = mixer_get_ctl_by_name(adev->mixer, AUDIO_DATA_BLOCK_MIXER_CTL); 156147cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (!ctl) { 156247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ALOGE("%s: Could not get ctl for mixer cmd - %s", 156347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George __func__, AUDIO_DATA_BLOCK_MIXER_CTL); 1564b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 1565b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1566b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 156747cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George mixer_ctl_update(ctl); 156847cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George 156947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George count = mixer_ctl_get_num_values(ctl); 1570b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1571b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Read SAD blocks, clamping the maximum size for safety */ 157247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (count > (int)sizeof(block)) 157347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George count = (int)sizeof(block); 1574b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 157547cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ret = mixer_ctl_get_array(ctl, block, count); 157647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (ret != 0) { 157747cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ALOGE("%s: mixer_ctl_get_array() failed to get EDID info", __func__); 157847cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George return 0; 157947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George } 1580b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1581b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Calculate the number of SAD blocks */ 158247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George num_audio_blocks = count / SAD_BLOCK_SIZE; 1583b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1584b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent for (i = 0; i < num_audio_blocks; i++) { 1585b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Only consider LPCM blocks */ 158647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if ((sad[0] >> 3) != EDID_FORMAT_LPCM) { 158747cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George sad += 3; 1588b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent continue; 158947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George } 1590b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1591b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_count = (sad[0] & 0x7) + 1; 1592b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_count > max_channels) 1593b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent max_channels = channel_count; 1594b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1595b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Advance to next block */ 1596b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent sad += 3; 1597b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1598b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1599b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return max_channels; 1600b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 16017ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George 16024b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_set_incall_recording_session_id(void *platform, 16034b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t session_id, int rec_mode) 16044b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 16054b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 16064b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 16074b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct audio_device *adev = my_data->adev; 16084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct mixer_ctl *ctl; 16094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava const char *mixer_ctl_name = "Voc VSID"; 16104b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int num_ctl_values; 16114b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int i; 16124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 16144b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 16154b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 16164b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 16174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = -EINVAL; 16184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else { 16194b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava num_ctl_values = mixer_ctl_get_num_values(ctl); 16204b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava for (i = 0; i < num_ctl_values; i++) { 16214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (mixer_ctl_set_value(ctl, i, session_id)) { 16224b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Error: invalid session_id: %x", session_id); 16234b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = -EINVAL; 16244b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava break; 16254b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16264b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16274b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16284b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16294b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 16304b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_record(ALL_SESSION_VSID, rec_mode); 16314b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 16324b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_start_record failed, error %d", 16334b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 16344b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16354b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16364b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16374b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 16384b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 16394b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16404b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_incall_recording_usecase(void *platform) 16414b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 16424b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 16434b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 16444b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16454b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 16464b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_record(ALL_SESSION_VSID); 16474b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 16484b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_stop_record failed, error %d", 16494b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 16504b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16514b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16524b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16534b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 16544b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 16554b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_start_incall_music_usecase(void *platform) 16574b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 16584b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 16594b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 16604b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 16624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_playback(ALL_SESSION_VSID); 16634b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 16644b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_start_playback failed, error %d", 16654b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 16664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16674b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16684b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16694b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 16704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 16714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_incall_music_usecase(void *platform) 16734b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 16744b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 16754b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 16764b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16774b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 16784b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_playback(ALL_SESSION_VSID); 16794b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 16804b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_stop_playback failed, error %d", 16814b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 16824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 16864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 16874b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16887ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George/* Delay in Us */ 16897ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew Georgeint64_t platform_render_latency(audio_usecase_t usecase) 16907ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George{ 16917ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George switch (usecase) { 16927ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: 16937ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return DEEP_BUFFER_PLATFORM_DELAY; 16947ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: 16957ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return LOW_LATENCY_PLATFORM_DELAY; 16967ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George default: 16977ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return 0; 16987ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George } 16997ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George} 170098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 170198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_set_snd_device_backend(snd_device_t device, const char *backend) 170298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 170398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int ret = 0; 170498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 170598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) { 170698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: Invalid snd_device = %d", 170798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George __func__, device); 170898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -EINVAL; 170998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George goto done; 171098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 171198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 171298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (backend_table[device]) { 171398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George free(backend_table[device]); 171498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 171598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George backend_table[device] = strdup(backend); 171698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgedone: 171798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return ret; 171898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 171998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 172098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id) 172198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 172298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int ret = 0; 172398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((usecase <= USECASE_INVALID) || (usecase >= AUDIO_USECASE_MAX)) { 172498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: invalid usecase case idx %d", __func__, usecase); 172598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -EINVAL; 172698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George goto done; 172798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 172898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 172998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((type != 0) && (type != 1)) { 173098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: invalid usecase type", __func__); 173198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -EINVAL; 173298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 173398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George pcm_device_table[usecase][type] = pcm_id; 173498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgedone: 173598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return ret; 173698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 1737