platform.c revision 5bc188456348ebdfc5d3c86414952503ec41bd44
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" 2983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 3083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#include "mdm_detect.h" 3183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 32b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 3347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George#define MIXER_XML_PATH "/system/etc/mixer_paths.xml" 34b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LIB_ACDB_LOADER "libacdbloader.so" 3547cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George#define AUDIO_DATA_BLOCK_MIXER_CTL "HDMI EDID" 36b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 37b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_NONE 0 /* Target does not contain 2 mics */ 38b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_ENDFIRE 1 39b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_BROADSIDE 2 40b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 41b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* 42b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * This file will have a maximum of 38 bytes: 43b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 44b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: number of audio blocks 45b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: total length of Short Audio Descriptor (SAD) blocks 46b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Maximum 10 * 3 bytes: SAD blocks 47b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */ 48b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define MAX_SAD_BLOCKS 10 49b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define SAD_BLOCK_SIZE 3 50b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 51b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* EDID format ID for LPCM audio */ 52b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define EDID_FORMAT_LPCM 1 53b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 541b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo/* Retry for delay in FW loading*/ 551b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo#define RETRY_NUMBER 10 561b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo#define RETRY_US 500000 574b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava#define MAX_SND_CARD 8 5853b2cf0c72aa18a5848919e2309731af652e84f9sangwoo 59b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct audio_block_header 60b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 61b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int reserved; 62b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int length; 63b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 64b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 6583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda/* Audio calibration related functions */ 66b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_deallocate_t)(); 6783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 6883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandatypedef int (*acdb_init_t)(char *); 6983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 70b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*acdb_init_t)(); 7183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 72b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_audio_cal_t)(int, int); 73b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_voice_cal_t)(int, int); 7483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandatypedef int (*acdb_reload_vocvoltable_t)(int); 75b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 76b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Audio calibration related functions */ 77b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct platform_data { 78b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev; 79b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_spkr_mode; 80b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_voice_call; 81b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_voice_rec; 82b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int dualmic_config; 83b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent void *acdb_handle; 84b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_init_t acdb_init; 85b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_deallocate_t acdb_deallocate; 86b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_send_audio_cal_t acdb_send_audio_cal; 87b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_send_voice_cal_t acdb_send_voice_cal; 8883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_reload_vocvoltable_t acdb_reload_vocvoltable; 8983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct csd_data *csd; 90299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda bool ext_speaker; 91299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda bool ext_earpiece; 92b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 93b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 94b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const int pcm_device_table[AUDIO_USECASE_MAX][2] = { 9583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE, 9683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda DEEP_BUFFER_PCM_DEVICE}, 9783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, 9883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda LOWLATENCY_PCM_DEVICE}, 9983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {MULTIMEDIA2_PCM_DEVICE, 10083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda MULTIMEDIA2_PCM_DEVICE}, 10183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_OFFLOAD] = {PLAYBACK_OFFLOAD_DEVICE, 10283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda PLAYBACK_OFFLOAD_DEVICE}, 10383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, 10483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda AUDIO_RECORD_PCM_DEVICE}, 10583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, 10683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda LOWLATENCY_PCM_DEVICE}, 10783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_VOICE_CALL] = {VOICE_CALL_PCM_DEVICE, 10883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda VOICE_CALL_PCM_DEVICE}, 1094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOICE2_CALL] = {VOICE2_CALL_PCM_DEVICE, VOICE2_CALL_PCM_DEVICE}, 1104b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOLTE_CALL] = {VOLTE_CALL_PCM_DEVICE, VOLTE_CALL_PCM_DEVICE}, 1114b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_QCHAT_CALL] = {QCHAT_CALL_PCM_DEVICE, QCHAT_CALL_PCM_DEVICE}, 1124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOWLAN_CALL] = {VOWLAN_CALL_PCM_DEVICE, VOWLAN_CALL_PCM_DEVICE}, 1134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_UPLINK] = {AUDIO_RECORD_PCM_DEVICE, 1144b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1154b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, 1164b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, 1184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1198e6e98fc5af6d6f79bc71eb37df470380ae82fadRavi Kumar Alamanda [USECASE_AUDIO_HFP_SCO] = {HFP_PCM_RX, HFP_SCO_RX}, 120b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 121b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 122b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Array to store sound devices */ 123b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const char * const device_table[SND_DEVICE_MAX] = { 124b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_NONE] = "none", 125b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Playback sound devices */ 126b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HANDSET] = "handset", 127b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER] = "speaker", 128b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse", 129b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HEADPHONES] = "headphones", 130b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", 131b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset", 132b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker", 133b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones", 134b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HDMI] = "hdmi", 135b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi", 136b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset", 1379f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb", 138b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus", 139b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones", 140b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones", 141b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset", 142b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 143b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Capture sound devices */ 144b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic", 145b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic", 146b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic", 147b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic", 14834fa769ab5835cefb9a6b842590f5f690c0a52dbEric Laurent [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "speaker-mic-aec", 149b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic", 150b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", 151b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", 152b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", 153b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic", 1549f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb", 155b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic", 156b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_EF] = "voice-dmic-ef", 157b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_BS] = "voice-dmic-bs", 158b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_EF_TMUS] = "voice-dmic-ef-tmus", 159b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF] = "voice-speaker-dmic-ef", 160b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS] = "voice-speaker-dmic-bs", 161b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic", 162b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic", 163b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic", 164b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic", 165b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_EF] = "voice-rec-dmic-ef", 166b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_BS] = "voice-rec-dmic-bs", 167b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE] = "voice-rec-dmic-ef-fluence", 168b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE] = "voice-rec-dmic-bs-fluence", 169b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 170b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 171b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* ACDB IDs (audio DSP path configuration IDs) for each sound device */ 1725bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgestatic int acdb_device_table[SND_DEVICE_MAX] = { 173b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_NONE] = -1, 174b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HANDSET] = 7, 175b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER] = 15, 176b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_REVERSE] = 15, 177b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HEADPHONES] = 10, 178b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10, 1791de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda#ifdef PLATFORM_MSM8084 1801de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda [SND_DEVICE_OUT_VOICE_HANDSET] = 67, 1811de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda [SND_DEVICE_OUT_VOICE_SPEAKER] = 66, 1821de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda#else 183b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET] = 7, 184b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_SPEAKER] = 15, 1851de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda#endif 186b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10, 187b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HDMI] = 18, 188b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 15, 189b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_BT_SCO] = 22, 1909f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_OUT_BT_SCO_WB] = 39, 19183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = ACDB_ID_VOICE_HANDSET_TMUS, 192b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17, 193b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17, 194b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37, 195b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 196b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC] = 4, 197b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_SPEAKER_MIC] = 4, /* ToDo: Check if this needs to changed to 11 */ 198b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC] = 8, 199b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC_AEC] = 40, 200b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 42, 201b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC_AEC] = 47, 202b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11, 203b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8, 204b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HDMI_MIC] = 4, 205b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_BT_SCO_MIC] = 21, 2069f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38, 207b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_CAMCORDER_MIC] = 61, 208b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_EF] = 41, 209b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_BS] = 5, 21083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC_EF_TMUS] = ACDB_ID_VOICE_DMIC_EF_TMUS, 211b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF] = 43, 212b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS] = 12, 213b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16, 214b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36, 215b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16, 216b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_MIC] = 62, 217b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* TODO: Update with proper acdb ids */ 218b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_EF] = 62, 219b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_BS] = 62, 220b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE] = 6, 221b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE] = 5, 222b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 223b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2245bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgestruct snd_device_index { 2255bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George char name[100]; 2265bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George unsigned int index; 2275bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George}; 2285bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 2295bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George#define TO_NAME_INDEX(X) #X, X 2305bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 2315bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George/* Used to get index from parsed sting */ 2325bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgestruct snd_device_index snd_device_name_index[SND_DEVICE_MAX] = { 2335bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HANDSET)}, 2345bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)}, 2355bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_REVERSE)}, 2365bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES)}, 2375bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES)}, 2385bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET)}, 2395bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER)}, 2405bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HEADPHONES)}, 2415bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HDMI)}, 2425bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HDMI)}, 2435bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO)}, 2445bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO_WB)}, 2455bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES)}, 2465bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES)}, 2475bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET)}, 2485bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC)}, 2495bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC)}, 2505bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC)}, 2515bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC)}, 2525bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC)}, 2535bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_MIC)}, 2545bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_HEADSET_MIC)}, 2555bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HDMI_MIC)}, 2565bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC)}, 2575bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB)}, 2585bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_MIC)}, 2595bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC)}, 2605bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC)}, 2615bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC)}, 2625bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC)}, 2635bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George}; 2645bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 2657ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) 2667ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) 2677ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George 268b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT; 269b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic bool is_tmus = false; 270b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 271b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic void check_operator() 272b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 273b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char value[PROPERTY_VALUE_MAX]; 274b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int mccmnc; 275b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("gsm.sim.operator.numeric",value,"0"); 276b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mccmnc = atoi(value); 277b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGD("%s: tmus mccmnc %d", __func__, mccmnc); 278b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent switch(mccmnc) { 279b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* TMUS MCC(310), MNC(490, 260, 026) */ 280b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310490: 281b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310260: 282b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310026: 283b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon /* Add new TMUS MNC(800, 660, 580, 310, 270, 250, 240, 230, 220, 210, 200, 160) */ 284b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310800: 285b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310660: 286b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310580: 287b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310310: 288b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310270: 289b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310250: 290b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310240: 291b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310230: 292b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310220: 293b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310210: 294b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310200: 295b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310160: 296b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent is_tmus = true; 297b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 298b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 299b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 300b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 301b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentbool is_operator_tmus() 302b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 303b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent pthread_once(&check_op_once_ctl, check_operator); 304b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return is_tmus; 305b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 306b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 307b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic int set_echo_reference(struct mixer *mixer, const char* ec_ref) 308b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 309b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 310b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "EC_REF_RX"; 311b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 312b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name); 313b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 314b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 315b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 316b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 317b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 318b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("Setting EC Reference: %s", ec_ref); 319b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mixer_ctl_set_enum_by_string(ctl, ec_ref); 320b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 321b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 322b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 32383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandastatic struct csd_data *open_csd_client(bool i2s_ext_modem) 32483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 32583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct csd_data *csd = calloc(1, sizeof(struct csd_data)); 32683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 32783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW); 32883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->csd_client == NULL) { 32983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT); 33083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 33183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 33283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT); 33383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 33483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->deinit = (deinit_t)dlsym(csd->csd_client, 33583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_deinit"); 33683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->deinit == NULL) { 33783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_deinit", __func__, 33883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda dlerror()); 33983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 34083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 34183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->disable_device = (disable_device_t)dlsym(csd->csd_client, 34283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_disable_device"); 34383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->disable_device == NULL) { 34483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_disable_device", 34583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 34683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 34783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 34883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->enable_device_config = (enable_device_config_t)dlsym(csd->csd_client, 34983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_enable_device_config"); 35083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->enable_device_config == NULL) { 35183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_enable_device_config", 35283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 35383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 35483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 35583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->enable_device = (enable_device_t)dlsym(csd->csd_client, 35683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_enable_device"); 35783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->enable_device == NULL) { 35883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_enable_device", 35983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 36083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 36183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 36283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_voice = (start_voice_t)dlsym(csd->csd_client, 36383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_voice"); 36483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_voice == NULL) { 36583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_voice", 36683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 36783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 36883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 36983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_voice = (stop_voice_t)dlsym(csd->csd_client, 37083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_voice"); 37183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_voice == NULL) { 37283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_voice", 37383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 37483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 37583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 37683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->volume = (volume_t)dlsym(csd->csd_client, 37783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_volume"); 37883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->volume == NULL) { 37983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_volume", 38083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 38183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 38283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 38383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->mic_mute = (mic_mute_t)dlsym(csd->csd_client, 38483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_mic_mute"); 38583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->mic_mute == NULL) { 38683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_mic_mute", 38783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 38883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 38983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 39083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->slow_talk = (slow_talk_t)dlsym(csd->csd_client, 39183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_slow_talk"); 39283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->slow_talk == NULL) { 39383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_slow_talk", 39483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 39583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 39683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 39783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_playback = (start_playback_t)dlsym(csd->csd_client, 39883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_playback"); 39983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_playback == NULL) { 40083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_playback", 40183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 40283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 40383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 40483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_playback = (stop_playback_t)dlsym(csd->csd_client, 40583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_playback"); 40683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_playback == NULL) { 40783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_playback", 40883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 40983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 41083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 41183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_record = (start_record_t)dlsym(csd->csd_client, 41283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_record"); 41383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_record == NULL) { 41483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_record", 41583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 41683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 41783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 41883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_record = (stop_record_t)dlsym(csd->csd_client, 41983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_record"); 42083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_record == NULL) { 42183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_record", 42283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 42383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 42483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 42583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 42683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->get_sample_rate = (get_sample_rate_t)dlsym(csd->csd_client, 42783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_get_sample_rate"); 42883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->get_sample_rate == NULL) { 42983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_get_sample_rate", 43083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 43183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 43283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 43383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 43483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 43583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->init = (init_t)dlsym(csd->csd_client, "csd_client_init"); 43683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 43783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->init == NULL) { 43883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_init", 43983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 44083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 44183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 44283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->init(i2s_ext_modem); 44383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 44483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 44583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return csd; 44683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 44783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaerror: 44883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda free(csd); 44983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd = NULL; 45083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return csd; 45183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 45283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 45383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandavoid close_csd_client(struct csd_data *csd) 45483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 45583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd != NULL) { 45683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->deinit(); 45783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda dlclose(csd->csd_client); 45883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda free(csd); 45983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd = NULL; 46083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 46183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 46283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 46383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandastatic void platform_csd_init(struct platform_data *my_data) 46483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 46583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 46683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct dev_info mdm_detect_info; 46783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 46883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 46983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda /* Call ESOC API to get the number of modems. 47083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda * If the number of modems is not zero, load CSD Client specific 47183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda * symbols. Voice call is handled by MDM and apps processor talks to 47283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda * MDM through CSD Client 47383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda */ 47483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = get_system_info(&mdm_detect_info); 47583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret > 0) { 47683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Failed to get system info, ret %d", __func__, ret); 47783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 47883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGD("%s: num_modems %d\n", __func__, mdm_detect_info.num_modems); 47983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 48083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (mdm_detect_info.num_modems > 0) 48183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->csd = open_csd_client(false /*is_i2s_ext_modem*/); 48283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 48383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->csd = NULL; 48483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 48583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 48683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 487b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid *platform_init(struct audio_device *adev) 488b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 489b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char value[PROPERTY_VALUE_MAX]; 490b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data; 4914b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int retry_num = 0, snd_card_num = 0; 49283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda const char *snd_card_name; 4931b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 4944b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava while (snd_card_num < MAX_SND_CARD) { 4954b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->mixer = mixer_open(snd_card_num); 4961b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 4974b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava while (!adev->mixer && retry_num < RETRY_NUMBER) { 4984b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava usleep(RETRY_US); 4994b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->mixer = mixer_open(snd_card_num); 5004b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava retry_num++; 5014b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 50283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 5034b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!adev->mixer) { 5044b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Unable to open the mixer card: %d", __func__, 5054b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_num); 5064b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava retry_num = 0; 5074b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_num++; 5084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava continue; 5094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 510cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 5114b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_name = mixer_get_name(adev->mixer); 5124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGD("%s: snd_card_name: %s", __func__, snd_card_name); 513a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent 5144b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->audio_route = audio_route_init(snd_card_num, MIXER_XML_PATH); 5154b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!adev->audio_route) { 5164b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Failed to init audio route controls, aborting.", __func__); 5174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return NULL; 5184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 5194b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->snd_card = snd_card_num; 5204b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGD("%s: Opened sound card:%d", __func__, snd_card_num); 5214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava break; 5224b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 5234b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 5244b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (snd_card_num >= MAX_SND_CARD) { 5254b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Unable to find correct sound card, aborting.", __func__); 5261b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo return NULL; 5271b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo } 528b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 529b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data = calloc(1, sizeof(struct platform_data)); 530b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 531b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->adev = adev; 532b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config = DUALMIC_CONFIG_NONE; 533b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_spkr_mode = false; 534b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_call = false; 535b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_rec = false; 536b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 537299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda /* 538299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * The default assumption is that earpiece (handset), speaker and headphones 539299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * devices are connected to internal HW codec and communicated through 540299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * slimbus backend. If any platform communicates with speaker or earpiece 541299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * or headphones through non-slimbus backend such as MI2S or AUXPCM etc., 542299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda * the ext_xxxx flags must be set accordingly. 543299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda */ 544299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda if (strstr(snd_card_name, "tfa9890_stereo")) { 545299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda my_data->ext_speaker = true; 546299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda my_data->ext_earpiece = true; 547299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda } else if (strstr(snd_card_name, "tfa9890")) { 548299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda my_data->ext_speaker = true; 549299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda } 550299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda 551b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.dualmic.config",value,""); 552b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("broadside", value)) { 553b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config = DUALMIC_CONFIG_BROADSIDE; 554b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent adev->acdb_settings |= DMIC_FLAG; 555b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (!strcmp("endfire", value)) { 556b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config = DUALMIC_CONFIG_ENDFIRE; 557b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent adev->acdb_settings |= DMIC_FLAG; 558b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 559b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 560b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 561b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.voicecall",value,""); 562b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 563b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_call = true; 564b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 565b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 566b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.voicerec",value,""); 567b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 568b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_rec = true; 569b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 570b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 571b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.speaker",value,""); 572b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 573b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_spkr_mode = true; 574b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 575b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 576b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 577b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); 578b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_handle == NULL) { 579b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER); 580b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 581b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER); 582b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle, 583b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_deallocate_ACDB"); 58483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_deallocate) 58583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_deallocate_ACDB from %s", 58683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 58783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 588b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle, 589b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_send_audio_cal"); 590b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!my_data->acdb_send_audio_cal) 59183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_send_audio_cal from %s", 592b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, LIB_ACDB_LOADER); 59383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 594b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle, 595b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_send_voice_cal"); 59683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_send_voice_cal) 59783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_send_voice_cal from %s", 59883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 59983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 60083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->acdb_reload_vocvoltable = (acdb_reload_vocvoltable_t)dlsym(my_data->acdb_handle, 60183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "acdb_loader_reload_vocvoltable"); 60283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_reload_vocvoltable) 60383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_reload_vocvoltable from %s", 60483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 60583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 60683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, 60783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "acdb_loader_init_v2"); 60883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->acdb_init == NULL) 60983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror()); 61083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda else 61183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->acdb_init(snd_card_name); 61283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 613b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, 614b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_init_ACDB"); 615b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_init == NULL) 616b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror()); 617b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 618b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_init(); 61983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 6205bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 6215bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George /* Initialize ACDB ID's */ 6225bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George /* Comment - does it make sense to init if acdb handle is NULL */ 6235bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George platform_info_init(); 624b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 625b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 62683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda /* load csd client */ 62783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda platform_csd_init(my_data); 62883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 629b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return my_data; 630b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 631b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 632b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid platform_deinit(void *platform) 633b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 6344b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 6354b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava close_csd_client(my_data->csd); 636b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent free(platform); 637b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 638b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 639b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentconst char *platform_get_snd_device_name(snd_device_t snd_device) 640b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 641b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) 642b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return device_table[snd_device]; 643b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 644b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return ""; 645b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 646b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 647299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamandavoid platform_add_backend_name(void *platform, char *mixer_path, 648299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda snd_device_t snd_device) 649b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 650299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 651299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda 652b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device == SND_DEVICE_IN_BT_SCO_MIC) 653b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent strcat(mixer_path, " bt-sco"); 654b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if(snd_device == SND_DEVICE_OUT_BT_SCO) 655b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent strcat(mixer_path, " bt-sco"); 656b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if (snd_device == SND_DEVICE_OUT_HDMI) 657b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent strcat(mixer_path, " hdmi"); 658b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI) 659b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent strcat(mixer_path, " speaker-and-hdmi"); 6609f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda else if (snd_device == SND_DEVICE_OUT_BT_SCO_WB || 6619f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB) 6629f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda strcat(mixer_path, " bt-sco-wb"); 663299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda else if (my_data->ext_speaker) { 664299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda if (snd_device == SND_DEVICE_OUT_SPEAKER || 665299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda snd_device == SND_DEVICE_OUT_VOICE_SPEAKER || 666299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda snd_device == SND_DEVICE_OUT_SPEAKER_REVERSE) 667299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda strcat(mixer_path, " speaker"); 668299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES) 669299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda strcat(mixer_path, " speaker-and-headphones"); 6701de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda } 6711de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda if (my_data->ext_earpiece && 6721de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda (snd_device == SND_DEVICE_OUT_VOICE_HANDSET || 6731de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda snd_device == SND_DEVICE_OUT_VOICE_HANDSET_TMUS || 6741de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda snd_device == SND_DEVICE_OUT_HANDSET || 6751de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda snd_device == SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET)) { 676299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda strcat(mixer_path, " handset"); 677299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda } 678b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 679b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 680b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) 681b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 682b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int device_id; 683b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (device_type == PCM_PLAYBACK) 684b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent device_id = pcm_device_table[usecase][0]; 685b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 686b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent device_id = pcm_device_table[usecase][1]; 687b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return device_id; 688b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 689b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 6905bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgeint platform_get_snd_device_index(char *snd_device_index_name) 6915bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George{ 6925bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George int ret = 0; 6935bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George int i; 6945bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 6955bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George if (snd_device_index_name == NULL) { 6965bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ALOGE("%s: snd_device_index_name is NULL", __func__); 6975bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -ENODEV; 6985bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 6995bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 7005bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 7015bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George for (i=0; i < SND_DEVICE_MAX; i++) { 7025bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George if(strcmp(snd_device_name_index[i].name, snd_device_index_name) == 0) { 7035bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = snd_device_name_index[i].index; 7045bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 7055bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 7065bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 7075bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ALOGE("%s: Could not find index for snd_device_index_name = %s", 7085bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George __func__, snd_device_index_name); 7095bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -ENODEV; 7105bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgedone: 7115bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George return ret; 7125bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George} 7135bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 7145bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgeint platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id) 7155bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George{ 7165bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George int ret = 0; 7175bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 7185bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { 7195bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ALOGE("%s: Invalid snd_device = %d", 7205bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George __func__, snd_device); 7215bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -EINVAL; 7225bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 7235bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 7245bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 7255bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George acdb_device_table[snd_device] = acdb_id; 7265bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgedone: 7275bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George return ret; 7285bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George} 7295bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 730b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_send_audio_calibration(void *platform, snd_device_t snd_device) 731b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 732b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 733b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int acdb_dev_id, acdb_dev_type; 734b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 735b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_id = acdb_device_table[snd_device]; 736b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (acdb_dev_id < 0) { 737b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not find acdb id for device(%d)", 738b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, snd_device); 739b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 740b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 741b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_send_audio_cal) { 742994a693158202488516c48c22534ae2035b5c8faEric Laurent ("%s: sending audio calibration for snd_device(%d) acdb_id(%d)", 743b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, snd_device, acdb_dev_id); 744b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device >= SND_DEVICE_OUT_BEGIN && 745b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device < SND_DEVICE_OUT_END) 746b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_type = ACDB_DEV_TYPE_OUT; 747b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 748b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_type = ACDB_DEV_TYPE_IN; 749b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type); 750b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 751b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 752b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 753b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 754b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_pre(void *platform) 755b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 75683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 75783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 75883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 75983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL && 76083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->adev->mode == AUDIO_MODE_IN_CALL) { 76183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda /* This must be called before disabling mixer controls on APQ side */ 76283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->disable_device(); 76383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 76483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_client_disable_device, failed, error %d", 76583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, ret); 76683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 76783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 76883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 76983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 77083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 77183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_enable_device_config(void *platform, 77283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t out_snd_device, 77383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t in_snd_device) 77483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 77583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 77683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int acdb_rx_id, acdb_tx_id; 77783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 77883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 77983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd == NULL) 78083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 78183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 78283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id = acdb_device_table[out_snd_device]; 78383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 78483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_tx_id = acdb_device_table[in_snd_device]; 78583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 78683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (acdb_rx_id > 0 && acdb_tx_id > 0) { 78783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id); 78883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 78983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_enable_device_config, failed, error %d", 79083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, ret); 79183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 79283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 79383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 79483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id, acdb_tx_id); 79583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 79683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 79783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 798b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 799b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 800b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_post(void *platform, 801b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t out_snd_device, 802b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t in_snd_device) 803b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 804b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 805b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int acdb_rx_id, acdb_tx_id; 806b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 807b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_send_voice_cal == NULL) { 808b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error for acdb_send_voice_call", __func__); 809b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 810b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_rx_id = acdb_device_table[out_snd_device]; 811b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_tx_id = acdb_device_table[in_snd_device]; 812b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 813b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (acdb_rx_id > 0 && acdb_tx_id > 0) 814b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id); 815b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 816b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 817b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_rx_id, acdb_tx_id); 818b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 819b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 820b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 821b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 822b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 82383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_usecase_route_post(void *platform, 82483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t out_snd_device, 82583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t in_snd_device) 82683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 82783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 82883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int acdb_rx_id, acdb_tx_id; 82983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 83083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 83183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd == NULL) 83283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 83383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 83483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id = acdb_device_table[out_snd_device]; 83583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 83683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_tx_id = acdb_device_table[in_snd_device]; 83783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 83883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (acdb_rx_id > 0 && acdb_tx_id > 0) { 83983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->enable_device(acdb_rx_id, acdb_tx_id, 84083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->adev->acdb_settings); 84183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 84283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_enable_device, failed, error %d", __func__, ret); 84383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 84483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 84583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 84683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id, acdb_tx_id); 84783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 84883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 84983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 85083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 85183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 8524b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_start_voice_call(void *platform, uint32_t vsid) 853b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 85483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 85583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 85683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 85783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 8584b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_voice(vsid); 85983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 86083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_start_voice error %d\n", __func__, ret); 86183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 86283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 86383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 864b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 865b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 8664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_voice_call(void *platform, uint32_t vsid) 867b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 86883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 86983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 87083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 87183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 8724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_voice(vsid); 87383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 87483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_stop_voice error %d\n", __func__, ret); 87583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 87683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 87783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 878b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 879b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 8804b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_get_sample_rate(void *platform, uint32_t *rate) 8814b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 8824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 8834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 8844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 8854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 8864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->get_sample_rate(rate); 8874b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 8884b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_get_sample_rate error %d\n", __func__, ret); 8894b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 8904b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 8914b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 8924b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 8934b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 894b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_voice_volume(void *platform, int volume) 895b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 896b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 897b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 898b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 89953b2cf0c72aa18a5848919e2309731af652e84f9sangwoo const char *mixer_ctl_name = "Voice Rx Gain"; 9004b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int vol_index = 0, ret = 0; 9014b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 9024b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 9034b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_VOLUME_RAMP_DURATION_MS}; 904b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 905b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // Voice volume levels are mapped to adsp volume levels as follows. 906b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // 100 -> 5, 80 -> 4, 60 -> 3, 40 -> 2, 20 -> 1 0 -> 0 907b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // But this values don't changed in kernel. So, below change is need. 9084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava vol_index = (int)percent_to_index(volume, MIN_VOL_INDEX, MAX_VOL_INDEX); 9094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = vol_index; 910b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 911b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 912b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 913b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 914b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 915b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 916b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 9174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Setting voice volume index: %d", set_values[0]); 9184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 9194b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 92083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 92183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->volume(ALL_SESSION_VSID, volume, 92283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda DEFAULT_VOLUME_RAMP_DURATION_MS); 92383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 92483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_volume error %d", __func__, ret); 92583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 92683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 92783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 928b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 929b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 930b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_mic_mute(void *platform, bool state) 931b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 932b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 933b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 934b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 935b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "Voice Tx Mute"; 93653b2cf0c72aa18a5848919e2309731af652e84f9sangwoo int ret = 0; 9374b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 9384b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 9394b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_MUTE_RAMP_DURATION_MS}; 940cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 9414b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (adev->mode != AUDIO_MODE_IN_CALL) 9424b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return 0; 9434b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 9444b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = state; 9454b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 9464b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 9474b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 9484b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 9494b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 9504b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 9514b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Setting voice mute state: %d", state); 9524b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 9534b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 9544b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 9554b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->mic_mute(ALL_SESSION_VSID, state, 9564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_MUTE_RAMP_DURATION_MS); 957a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent if (ret < 0) { 9584b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_mic_mute error %d", __func__, ret); 95953b2cf0c72aa18a5848919e2309731af652e84f9sangwoo } 960cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George } 9614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 9624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 963cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 9644b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_set_device_mute(void *platform, bool state, char *dir) 9654b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 9664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 9674b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct audio_device *adev = my_data->adev; 9684b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct mixer_ctl *ctl; 9694b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava char *mixer_ctl_name = NULL; 9704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 9714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 9724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 9734b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 0}; 9744b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if(dir == NULL) { 9754b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Invalid direction:%s", __func__, dir); 9764b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 9774b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 9784b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 9794b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!strncmp("rx", dir, sizeof("rx"))) { 9804b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_name = "Voice Rx Device Mute"; 9814b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else if (!strncmp("tx", dir, sizeof("tx"))) { 9824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_name = "Voice Tx Device Mute"; 9834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else { 9844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 9854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 9864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 9874b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = state; 9884b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 9894b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 9904b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 9914b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 9924b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 9934b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 9944b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 9954b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("%s: Setting device mute state: %d, mixer ctrl:%s", 9964b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__,state, mixer_ctl_name); 9974b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 9984b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 9994b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 1000b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1001b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1002b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices) 1003b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1004b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1005b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1006b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_mode_t mode = adev->mode; 1007b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 1008b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1009b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: enter: output devices(%#x)", __func__, devices); 1010b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices == AUDIO_DEVICE_NONE || 1011b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_BIT_IN) { 1012b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: Invalid output devices (%#x)", __func__, devices); 1013b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1014b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1015b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1016b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (mode == AUDIO_MODE_IN_CALL) { 1017b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 1018b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 10194b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (adev->voice.tty_mode == TTY_MODE_FULL) 1020b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES; 10214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava else if (adev->voice.tty_mode == TTY_MODE_VCO) 1022b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES; 10234b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava else if (adev->voice.tty_mode == TTY_MODE_HCO) 1024b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET; 1025b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1026b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; 1027b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { 10289f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 10299f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO_WB; 10309f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 10319f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO; 10329f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1033b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { 1034b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; 1035b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { 1036b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (is_operator_tmus()) 1037b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS; 1038b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1039b4d368e0fe6006657ebc4e1f9ba01a072c4ca2c7Eric Laurent snd_device = SND_DEVICE_OUT_VOICE_HANDSET; 1040b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1041b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 1042b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1043b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1044b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1045b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1046b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (popcount(devices) == 2) { 1047b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | 1048b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1049b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; 1050b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | 1051b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1052b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; 1053b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL | 1054b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 1055b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI; 1056b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1057b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Invalid combo device(%#x)", __func__, devices); 1058b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1059b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1060b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 1061b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1062b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1063b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1064b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1065b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (popcount(devices) != 1) { 1066b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Invalid output devices(%#x)", __func__, devices); 1067b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1068b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1069b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1070b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 1071b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1072b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HEADPHONES; 1073b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { 1074b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->speaker_lr_swap) 1075b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE; 1076b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1077b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER; 1078b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { 10799f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 10809f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO_WB; 10819f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 10829f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO; 10839f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1084b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { 1085b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HDMI ; 1086b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { 1087b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HANDSET; 1088b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1089b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown device(s) %#x", __func__, devices); 1090b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1091b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit: 1092b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]); 1093b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return snd_device; 1094b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1095b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1096b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device) 1097b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1098b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1099b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1100b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_source_t source = (adev->active_input == NULL) ? 1101b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_SOURCE_DEFAULT : adev->active_input->source; 1102b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1103b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_mode_t mode = adev->mode; 1104b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_devices_t in_device = ((adev->active_input == NULL) ? 1105b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_NONE : adev->active_input->device) 1106b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent & ~AUDIO_DEVICE_BIT_IN; 1107b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? 1108b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; 1109b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 1110b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1111b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: enter: out_device(%#x) in_device(%#x)", 1112b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, out_device, in_device); 1113b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (mode == AUDIO_MODE_IN_CALL) { 1114b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device == AUDIO_DEVICE_NONE) { 1115b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: No output device set for voice call", __func__); 1116b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1117b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 11184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (adev->voice.tty_mode != TTY_MODE_OFF) { 1119b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 1120b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 11214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava switch (adev->voice.tty_mode) { 1122b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_FULL: 1123b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC; 1124b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1125b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_VCO: 1126b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC; 1127b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1128b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_HCO: 1129b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC; 1130b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1131b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent default: 11324b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode); 1133b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1134b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1135b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1136b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1137b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_EARPIECE || 1138b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { 1139b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->fluence_in_voice_call == false) { 1140b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 11418e6e98fc5af6d6f79bc71eb37df470380ae82fadRavi Kumar Alamanda set_echo_reference(adev->mixer, "SLIM_RX"); 1142b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1143b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) { 1144b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (is_operator_tmus()) 1145b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_DMIC_EF_TMUS; 1146b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1147b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_DMIC_EF; 1148b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if(my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) 1149b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_DMIC_BS; 1150b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1151b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1152b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1153b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1154b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; 1155b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { 11569f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 11579f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 11589f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 11599f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 11609f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1161b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { 1162b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode && 1163b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) { 1164b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF; 1165b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode && 1166b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) { 1167b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS; 1168b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1169b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; 1170b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1171b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1172b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_CAMCORDER) { 1173b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || 1174b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent in_device & AUDIO_DEVICE_IN_BACK_MIC) { 1175b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_CAMCORDER_MIC; 1176b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1177b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) { 1178b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 1179b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) { 1180b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) 1181b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_EF; 1182b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if (my_data->fluence_in_voice_rec) 1183b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE; 1184b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) { 1185b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) 1186b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_BS; 1187b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if (my_data->fluence_in_voice_rec) 1188b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE; 1189b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1190b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1191b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device == SND_DEVICE_NONE) { 1192b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_REC_MIC; 1193b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1194b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1195b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) { 1196b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_SPEAKER) 1197b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent in_device = AUDIO_DEVICE_IN_BACK_MIC; 1198b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->active_input) { 1199b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->active_input->enable_aec) { 1200b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 1201b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; 1202b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 1203b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC; 1204b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 1205b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; 1206b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1207b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent set_echo_reference(adev->mixer, "SLIM_RX"); 1208b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else 1209b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent set_echo_reference(adev->mixer, "NONE"); 1210b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1211b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_DEFAULT) { 1212b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1213b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1214b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1215b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1216b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 1217b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1218b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1219b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1220b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device != AUDIO_DEVICE_NONE && 1221b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) && 1222b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) { 1223b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 1224b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1225b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 1226b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_SPEAKER_MIC; 1227b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 1228b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC; 1229b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { 12309f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 12319f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 12329f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 12339f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 12349f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1235b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) { 1236b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HDMI_MIC; 1237b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1238b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown input device(s) %#x", __func__, in_device); 1239b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Using default handset-mic", __func__); 1240b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1241b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1242b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1243b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { 1244b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1245b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1246b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC; 1247b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { 1248b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_SPEAKER_MIC; 1249b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { 1250b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1251b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) { 12529f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 12539f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 12549f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 12559f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 12569f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1257b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) { 1258b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HDMI_MIC; 1259b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1260b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown output device(s) %#x", __func__, out_device); 1261b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Using default handset-mic", __func__); 1262b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1263b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1264b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1265b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit: 1266b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]); 1267b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return snd_device; 1268b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1269b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1270b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_hdmi_channels(void *platform, int channel_count) 1271b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1272b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1273b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1274b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 1275b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *channel_cnt_str = NULL; 1276b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "HDMI_RX Channels"; 1277b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent switch (channel_count) { 1278b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 8: 1279b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Eight"; break; 1280b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 7: 1281b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Seven"; break; 1282b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 6: 1283b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Six"; break; 1284b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 5: 1285b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Five"; break; 1286b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 4: 1287b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Four"; break; 1288b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 3: 1289b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Three"; break; 1290b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent default: 1291b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Two"; break; 1292b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1293b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 1294b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 1295b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 1296b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 1297b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 1298b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1299b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("HDMI channel count: %s", channel_cnt_str); 1300b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); 1301b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 1302b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1303b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 130447cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew Georgeint platform_edid_get_max_channels(void *platform) 1305b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 130647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct platform_data *my_data = (struct platform_data *)platform; 130747cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct audio_device *adev = my_data->adev; 1308b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE]; 1309b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char *sad = block; 1310b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int num_audio_blocks; 1311b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int channel_count; 1312b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int max_channels = 0; 131347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George int i, ret, count; 1314b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 131547cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct mixer_ctl *ctl; 131647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George 131747cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ctl = mixer_get_ctl_by_name(adev->mixer, AUDIO_DATA_BLOCK_MIXER_CTL); 131847cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (!ctl) { 131947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ALOGE("%s: Could not get ctl for mixer cmd - %s", 132047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George __func__, AUDIO_DATA_BLOCK_MIXER_CTL); 1321b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 1322b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1323b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 132447cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George mixer_ctl_update(ctl); 132547cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George 132647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George count = mixer_ctl_get_num_values(ctl); 1327b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1328b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Read SAD blocks, clamping the maximum size for safety */ 132947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (count > (int)sizeof(block)) 133047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George count = (int)sizeof(block); 1331b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 133247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ret = mixer_ctl_get_array(ctl, block, count); 133347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (ret != 0) { 133447cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ALOGE("%s: mixer_ctl_get_array() failed to get EDID info", __func__); 133547cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George return 0; 133647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George } 1337b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1338b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Calculate the number of SAD blocks */ 133947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George num_audio_blocks = count / SAD_BLOCK_SIZE; 1340b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1341b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent for (i = 0; i < num_audio_blocks; i++) { 1342b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Only consider LPCM blocks */ 134347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if ((sad[0] >> 3) != EDID_FORMAT_LPCM) { 134447cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George sad += 3; 1345b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent continue; 134647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George } 1347b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1348b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_count = (sad[0] & 0x7) + 1; 1349b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_count > max_channels) 1350b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent max_channels = channel_count; 1351b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1352b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Advance to next block */ 1353b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent sad += 3; 1354b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1355b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1356b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return max_channels; 1357b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 13587ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George 13594b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_set_incall_recording_session_id(void *platform, 13604b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t session_id, int rec_mode) 13614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 13624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 13634b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 13644b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct audio_device *adev = my_data->adev; 13654b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct mixer_ctl *ctl; 13664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava const char *mixer_ctl_name = "Voc VSID"; 13674b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int num_ctl_values; 13684b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int i; 13694b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 13704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 13714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 13724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 13734b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 13744b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = -EINVAL; 13754b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else { 13764b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava num_ctl_values = mixer_ctl_get_num_values(ctl); 13774b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava for (i = 0; i < num_ctl_values; i++) { 13784b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (mixer_ctl_set_value(ctl, i, session_id)) { 13794b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Error: invalid session_id: %x", session_id); 13804b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = -EINVAL; 13814b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava break; 13824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 13834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 13844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 13854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 13864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 13874b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_record(ALL_SESSION_VSID, rec_mode); 13884b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 13894b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_start_record failed, error %d", 13904b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 13914b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 13924b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 13934b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 13944b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 13954b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 13964b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 13974b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_incall_recording_usecase(void *platform) 13984b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 13994b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 14004b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 14014b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 14024b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 14034b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_record(ALL_SESSION_VSID); 14044b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 14054b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_stop_record failed, error %d", 14064b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 14074b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 14084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 14094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 14104b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 14114b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 14124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 14134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_start_incall_music_usecase(void *platform) 14144b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 14154b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 14164b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 14174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 14184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 14194b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_playback(ALL_SESSION_VSID); 14204b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 14214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_start_playback failed, error %d", 14224b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 14234b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 14244b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 14254b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 14264b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 14274b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 14284b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 14294b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_incall_music_usecase(void *platform) 14304b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 14314b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 14324b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 14334b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 14344b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 14354b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_playback(ALL_SESSION_VSID); 14364b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 14374b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_stop_playback failed, error %d", 14384b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 14394b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 14404b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 14414b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 14424b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 14434b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 14444b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 14457ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George/* Delay in Us */ 14467ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew Georgeint64_t platform_render_latency(audio_usecase_t usecase) 14477ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George{ 14487ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George switch (usecase) { 14497ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: 14507ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return DEEP_BUFFER_PLATFORM_DELAY; 14517ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: 14527ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return LOW_LATENCY_PLATFORM_DELAY; 14537ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George default: 14547ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return 0; 14557ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George } 14567ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George} 1457