platform.c revision c698f1313378541ec781a986fc68615ec35536c3
1b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* 2a51fd4083112343fddcc294f850f2d5456f24fd4vivek mehta * Copyright (C) 2013-2016 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#define LOG_TAG "msm8974_platform" 17b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/*#define LOG_NDEBUG 0*/ 18b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LOG_NDDEBUG 0 19b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 20b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <stdlib.h> 21b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <dlfcn.h> 22b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <cutils/log.h> 239f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda#include <cutils/str_parms.h> 24b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <cutils/properties.h> 25b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <audio_hw.h> 26b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <platform_api.h> 27b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include "platform.h" 2863863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda#include "audio_extn.h" 291a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta#include <linux/msm_audio.h> 30b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 3147cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George#define MIXER_XML_PATH "/system/etc/mixer_paths.xml" 3211dd22384f2ae13ec4a7563ce5f0a113cf30a53cUday Kishore Pasupuleti#define MIXER_XML_PATH_WCD9330 "/system/etc/mixer_paths_wcd9330.xml" 33b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LIB_ACDB_LOADER "libacdbloader.so" 3447cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George#define AUDIO_DATA_BLOCK_MIXER_CTL "HDMI EDID" 355c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda#define CVD_VERSION_MIXER_CTL "CVD Version" 36b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 37b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 38b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* 39b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * This file will have a maximum of 38 bytes: 40b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 41b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: number of audio blocks 42b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: total length of Short Audio Descriptor (SAD) blocks 43b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Maximum 10 * 3 bytes: SAD blocks 44b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */ 45b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define MAX_SAD_BLOCKS 10 46b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define SAD_BLOCK_SIZE 3 47b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 485c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda#define MAX_CVD_VERSION_STRING_SIZE 100 495c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda 50b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* EDID format ID for LPCM audio */ 51b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define EDID_FORMAT_LPCM 1 52b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 531b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo/* Retry for delay in FW loading*/ 541b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo#define RETRY_NUMBER 10 551b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo#define RETRY_US 500000 564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava#define MAX_SND_CARD 8 5753b2cf0c72aa18a5848919e2309731af652e84f9sangwoo 58c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda#define MAX_SND_CARD_NAME_LEN 31 59c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 601a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta#define DEFAULT_APP_TYPE_RX_PATH 0x11130 611a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta 62c5aaa0e767b83fa8299861a739a4a1cb8e9bee0fkeunhui.park#define TOSTRING_(x) #x 63c5aaa0e767b83fa8299861a739a4a1cb8e9bee0fkeunhui.park#define TOSTRING(x) TOSTRING_(x) 64c5aaa0e767b83fa8299861a739a4a1cb8e9bee0fkeunhui.park 65b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct audio_block_header 66b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 67b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int reserved; 68b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int length; 69b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 70b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 711a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehtaenum { 721a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta CAL_MODE_SEND = 0x1, 731a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta CAL_MODE_PERSIST = 0x2, 741a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta CAL_MODE_RTAC = 0x4 751a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta}; 761a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta 772f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park#define PLATFORM_CONFIG_KEY_OPERATOR_INFO "operator_info" 782f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 792f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.parkstruct operator_info { 802f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct listnode list; 812f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park char *name; 822f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park char *mccmnc; 832f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park}; 842f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 852f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.parkstruct operator_specific_device { 862f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct listnode list; 872f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park char *operator; 882f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park char *mixer_path; 892f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park int acdb_id; 902f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park}; 912f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 922f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.parkstatic struct listnode operator_info_list; 932f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.parkstatic struct listnode *operator_specific_device_table[SND_DEVICE_MAX]; 942f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 9583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda/* Audio calibration related functions */ 96b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_deallocate_t)(); 97c698f1313378541ec781a986fc68615ec35536c3vivek mehtatypedef int (*acdb_init_v2_cvd_t)(char *, char *, int); 985c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamandatypedef int (*acdb_init_v2_t)(char *); 99b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*acdb_init_t)(); 100b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_audio_cal_t)(int, int); 101b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_voice_cal_t)(int, int); 10283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandatypedef int (*acdb_reload_vocvoltable_t)(int); 1031a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehtatypedef int (*acdb_send_gain_dep_cal_t)(int, int, int, int, int); 104b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 105b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Audio calibration related functions */ 106b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct platform_data { 107b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev; 108b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_spkr_mode; 109b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_voice_call; 1103ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda bool fluence_in_voice_comm; 111b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_voice_rec; 112c92c59683257878fb8dc08d827313b4a865898daPrashant Malani /* 0 = no fluence, 1 = fluence, 2 = fluence pro */ 113c92c59683257878fb8dc08d827313b4a865898daPrashant Malani int fluence_type; 114c92c59683257878fb8dc08d827313b4a865898daPrashant Malani int source_mic_type; 1151f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda bool speaker_lr_swap; 1161f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda 117b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent void *acdb_handle; 1183ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_deallocate_t acdb_deallocate; 1193ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_send_audio_cal_t acdb_send_audio_cal; 1203ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda acdb_send_voice_cal_t acdb_send_voice_cal; 12183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_reload_vocvoltable_t acdb_reload_vocvoltable; 1221a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta acdb_send_gain_dep_cal_t acdb_send_gain_dep_cal; 12383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct csd_data *csd; 124f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda char ec_ref_mixer_path[64]; 125c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 126c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda char *snd_card_name; 127c5aaa0e767b83fa8299861a739a4a1cb8e9bee0fkeunhui.park int max_vol_index; 128c92c59683257878fb8dc08d827313b4a865898daPrashant Malani int max_mic_count; 129b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 130b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 13198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic int pcm_device_table[AUDIO_USECASE_MAX][2] = { 13283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE, 13383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda DEEP_BUFFER_PCM_DEVICE}, 13483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, 13583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda LOWLATENCY_PCM_DEVICE}, 13683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {MULTIMEDIA2_PCM_DEVICE, 13783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda MULTIMEDIA2_PCM_DEVICE}, 13883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_OFFLOAD] = {PLAYBACK_OFFLOAD_DEVICE, 13983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda PLAYBACK_OFFLOAD_DEVICE}, 1402bc7b02259e0edf38432b258594da29571f29713Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_TTS] = {MULTIMEDIA2_PCM_DEVICE, 1412bc7b02259e0edf38432b258594da29571f29713Ravi Kumar Alamanda MULTIMEDIA2_PCM_DEVICE}, 1422bc7b02259e0edf38432b258594da29571f29713Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_ULL] = {MULTIMEDIA3_PCM_DEVICE, 1432bc7b02259e0edf38432b258594da29571f29713Ravi Kumar Alamanda MULTIMEDIA3_PCM_DEVICE}, 1442bc7b02259e0edf38432b258594da29571f29713Ravi Kumar Alamanda 14583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, 14683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda AUDIO_RECORD_PCM_DEVICE}, 14783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, 14883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda LOWLATENCY_PCM_DEVICE}, 1492bc7b02259e0edf38432b258594da29571f29713Ravi Kumar Alamanda 15083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [USECASE_VOICE_CALL] = {VOICE_CALL_PCM_DEVICE, 15183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda VOICE_CALL_PCM_DEVICE}, 1524b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOICE2_CALL] = {VOICE2_CALL_PCM_DEVICE, VOICE2_CALL_PCM_DEVICE}, 1534b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOLTE_CALL] = {VOLTE_CALL_PCM_DEVICE, VOLTE_CALL_PCM_DEVICE}, 1544b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_QCHAT_CALL] = {QCHAT_CALL_PCM_DEVICE, QCHAT_CALL_PCM_DEVICE}, 1554b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_VOWLAN_CALL] = {VOWLAN_CALL_PCM_DEVICE, VOWLAN_CALL_PCM_DEVICE}, 156a51fd4083112343fddcc294f850f2d5456f24fd4vivek mehta [USECASE_VOICEMMODE1_CALL] = {VOICEMMODE1_CALL_PCM_DEVICE, 157a51fd4083112343fddcc294f850f2d5456f24fd4vivek mehta VOICEMMODE1_CALL_PCM_DEVICE}, 158a51fd4083112343fddcc294f850f2d5456f24fd4vivek mehta [USECASE_VOICEMMODE2_CALL] = {VOICEMMODE2_CALL_PCM_DEVICE, 159a51fd4083112343fddcc294f850f2d5456f24fd4vivek mehta VOICEMMODE2_CALL_PCM_DEVICE}, 160a51fd4083112343fddcc294f850f2d5456f24fd4vivek mehta 1614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_UPLINK] = {AUDIO_RECORD_PCM_DEVICE, 1624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1634b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, 1644b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1654b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, 1664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava AUDIO_RECORD_PCM_DEVICE}, 1678e6e98fc5af6d6f79bc71eb37df470380ae82fadRavi Kumar Alamanda [USECASE_AUDIO_HFP_SCO] = {HFP_PCM_RX, HFP_SCO_RX}, 16899c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 16963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [USECASE_AUDIO_SPKR_CALIB_RX] = {SPKR_PROT_CALIB_RX_PCM_DEVICE, -1}, 17063863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [USECASE_AUDIO_SPKR_CALIB_TX] = {-1, SPKR_PROT_CALIB_TX_PCM_DEVICE}, 17163863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 17299c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [USECASE_AUDIO_PLAYBACK_AFE_PROXY] = {AFE_PROXY_PLAYBACK_PCM_DEVICE, 17399c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda AFE_PROXY_RECORD_PCM_DEVICE}, 17499c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [USECASE_AUDIO_RECORD_AFE_PROXY] = {AFE_PROXY_PLAYBACK_PCM_DEVICE, 17599c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda AFE_PROXY_RECORD_PCM_DEVICE}, 1764211fad32ff21574a3935dbe28397c55a1895649zhaoyang yin [USECASE_AUDIO_DSM_FEEDBACK] = {QUAT_MI2S_PCM_DEVICE, QUAT_MI2S_PCM_DEVICE}, 17799c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 178b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 179b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 180b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Array to store sound devices */ 181b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const char * const device_table[SND_DEVICE_MAX] = { 182b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_NONE] = "none", 183b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Playback sound devices */ 184b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HANDSET] = "handset", 185b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER] = "speaker", 186b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse", 1871b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent [SND_DEVICE_OUT_SPEAKER_SAFE] = "speaker-safe", 188b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HEADPHONES] = "headphones", 18909f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent [SND_DEVICE_OUT_LINE] = "line", 190b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", 1913b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda [SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES] = "speaker-safe-and-headphones", 192744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_LINE] = "speaker-and-line", 1933b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda [SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE] = "speaker-safe-and-line", 194b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset", 1959d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent [SND_DEVICE_OUT_VOICE_HAC_HANDSET] = "voice-hac-handset", 196b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker", 197b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones", 19809f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent [SND_DEVICE_OUT_VOICE_LINE] = "voice-line", 199b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HDMI] = "hdmi", 200b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi", 201b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset", 2029f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb", 203b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus", 204b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones", 205b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones", 206b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset", 20799c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_TX] = "voice-tx", 20863863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_OUT_SPEAKER_PROTECTED] = "speaker-protected", 20963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED] = "voice-speaker-protected", 2107629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti [SND_DEVICE_OUT_VOICE_SPEAKER_HFP] = "voice-speaker-hfp", 211b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 212b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Capture sound devices */ 213b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic", 2143ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic", 2153ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_NS] = "handset-mic", 2163ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = "handset-mic", 2173ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC] = "dmic-endfire", 2183ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC] = "dmic-endfire", 2193ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_NS] = "dmic-endfire", 2203ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = "dmic-endfire", 2213ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_STEREO] = "dmic-endfire", 2223ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 223b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic", 2243ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "speaker-mic", 2253ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_NS] = "speaker-mic", 2263ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = "speaker-mic", 2273ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC] = "speaker-dmic-endfire", 2283ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = "speaker-dmic-endfire", 2293ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_NS] = "speaker-dmic-endfire", 2303ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = "speaker-dmic-endfire", 2313ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_STEREO] = "speaker-dmic-endfire", 2323ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 233b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic", 234cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic", 2353ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 236b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", 237b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic", 238e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_NREC] = "bt-sco-mic", 2399f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb", 240e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = "bt-sco-mic-wb", 241b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic", 2423ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 2433ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC] = "voice-dmic-ef", 2443ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC_TMUS] = "voice-dmic-ef-tmus", 2453ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", 2463ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef", 2477629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti [SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP] = "voice-speaker-mic-hfp", 2483ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", 249b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic", 250b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic", 251b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic", 2523ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 253b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic", 2543ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_MIC_NS] = "voice-rec-mic", 2553ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = "voice-rec-dmic-ef", 2563ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = "voice-rec-dmic-ef-fluence", 2578c83fe85b6d1257298208de043acece927787c3fJean-Michel Trivi [SND_DEVICE_IN_VOICE_REC_HEADSET_MIC] = "headset-mic", 25899c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 25990fb96106e9e2db75e214722c797d013e10e5328rago [SND_DEVICE_IN_UNPROCESSED_MIC] = "voice-rec-mic", 26090fb96106e9e2db75e214722c797d013e10e5328rago [SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC] = "headset-mic", 26190fb96106e9e2db75e214722c797d013e10e5328rago 26299c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_IN_VOICE_RX] = "voice-rx", 26363863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 264c92c59683257878fb8dc08d827313b4a865898daPrashant Malani [SND_DEVICE_IN_THREE_MIC] = "three-mic", 265c92c59683257878fb8dc08d827313b4a865898daPrashant Malani [SND_DEVICE_IN_QUAD_MIC] = "quad-mic", 26663863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = "vi-feedback", 267c92c59683257878fb8dc08d827313b4a865898daPrashant Malani [SND_DEVICE_IN_HANDSET_TMIC] = "three-mic", 268c92c59683257878fb8dc08d827313b4a865898daPrashant Malani [SND_DEVICE_IN_HANDSET_QMIC] = "quad-mic", 269b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 270b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 271b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* ACDB IDs (audio DSP path configuration IDs) for each sound device */ 2725bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgestatic int acdb_device_table[SND_DEVICE_MAX] = { 273b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_NONE] = -1, 274b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HANDSET] = 7, 275b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER] = 15, 276b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_REVERSE] = 15, 2771b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent [SND_DEVICE_OUT_SPEAKER_SAFE] = 15, 278b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HEADPHONES] = 10, 279744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_LINE] = 77, 280b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10, 2813b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda [SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES] = 10, 282744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_LINE] = 77, 2833b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda [SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE] = 77, 284235c34827f7b3b8977fe76dea1fb8d818fd74312Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_HANDSET] = ACDB_ID_VOICE_HANDSET, 285235c34827f7b3b8977fe76dea1fb8d818fd74312Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_SPEAKER] = ACDB_ID_VOICE_SPEAKER, 2869d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent [SND_DEVICE_OUT_VOICE_HAC_HANDSET] = 53, 287b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10, 288744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent [SND_DEVICE_OUT_VOICE_LINE] = 77, 289b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HDMI] = 18, 290b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 15, 291b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_BT_SCO] = 22, 2929f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_OUT_BT_SCO_WB] = 39, 29383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = ACDB_ID_VOICE_HANDSET_TMUS, 294b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17, 295b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17, 296b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37, 29799c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_TX] = 45, 29863863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_OUT_SPEAKER_PROTECTED] = 124, 29963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED] = 101, 300e9ef478adc4690c9d074c2dc063f9dc40ef81451Uday Kishore Pasupuleti [SND_DEVICE_OUT_VOICE_SPEAKER_HFP] = ACDB_ID_VOICE_SPEAKER, 301b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 302b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC] = 4, 3033ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC] = 106, 3043ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_NS] = 107, 3053ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = 108, 3063ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC] = 41, 3073ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC] = 109, 3083ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_NS] = 110, 3093ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = 111, 3103ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_HANDSET_DMIC_STEREO] = 34, 3113ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3123ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC] = 11, 3133ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 112, 3143ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_NS] = 113, 3153ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = 114, 3163ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC] = 43, 3173ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = 115, 3183ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_NS] = 116, 3193ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = 117, 3203ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_SPEAKER_DMIC_STEREO] = 35, 3213ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 32290fb96106e9e2db75e214722c797d013e10e5328rago [SND_DEVICE_IN_HEADSET_MIC] = ACDB_ID_HEADSET_MIC_AEC, 323cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent [SND_DEVICE_IN_HEADSET_MIC_AEC] = ACDB_ID_HEADSET_MIC_AEC, 3243ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 325b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HDMI_MIC] = 4, 326b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_BT_SCO_MIC] = 21, 327e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_NREC] = 21, 3289f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38, 329e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = 38, 330b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_CAMCORDER_MIC] = 61, 3313ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 3323ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC] = 41, 3333ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_DMIC_TMUS] = ACDB_ID_VOICE_DMIC_EF_TMUS, 3343ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11, 335e9ef478adc4690c9d074c2dc063f9dc40ef81451Uday Kishore Pasupuleti [SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP] = 11, 3363ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 43, 33790fb96106e9e2db75e214722c797d013e10e5328rago [SND_DEVICE_IN_VOICE_HEADSET_MIC] = ACDB_ID_HEADSET_MIC_AEC, 338b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16, 339b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36, 340b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16, 3413ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 34290fb96106e9e2db75e214722c797d013e10e5328rago [SND_DEVICE_IN_VOICE_REC_MIC] = ACDB_ID_VOICE_REC_MIC, 3433ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_MIC_NS] = 113, 3443ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = 35, 3453ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = 43, 34690fb96106e9e2db75e214722c797d013e10e5328rago [SND_DEVICE_IN_VOICE_REC_HEADSET_MIC] = ACDB_ID_HEADSET_MIC_AEC, 34790fb96106e9e2db75e214722c797d013e10e5328rago 34890fb96106e9e2db75e214722c797d013e10e5328rago [SND_DEVICE_IN_UNPROCESSED_MIC] = ACDB_ID_VOICE_REC_MIC, 34990fb96106e9e2db75e214722c797d013e10e5328rago [SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC] = ACDB_ID_HEADSET_MIC_AEC, 35099c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 35199c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda [SND_DEVICE_IN_VOICE_RX] = 44, 35263863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 353c92c59683257878fb8dc08d827313b4a865898daPrashant Malani [SND_DEVICE_IN_THREE_MIC] = 46, 354c92c59683257878fb8dc08d827313b4a865898daPrashant Malani [SND_DEVICE_IN_QUAD_MIC] = 46, 35563863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = 102, 356c92c59683257878fb8dc08d827313b4a865898daPrashant Malani [SND_DEVICE_IN_HANDSET_TMIC] = 125, 357c92c59683257878fb8dc08d827313b4a865898daPrashant Malani [SND_DEVICE_IN_HANDSET_QMIC] = 125, 358b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 359b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 36098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestruct name_to_index { 3615bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George char name[100]; 3625bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George unsigned int index; 3635bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George}; 3645bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 3655bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George#define TO_NAME_INDEX(X) #X, X 3665bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 36798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George/* Used to get index from parsed string */ 36898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic const struct name_to_index snd_device_name_index[SND_DEVICE_MAX] = { 36998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George /* out */ 3705bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HANDSET)}, 3715bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)}, 3725bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_REVERSE)}, 3731b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_SAFE)}, 3745bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES)}, 37509f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_LINE)}, 3765bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES)}, 3773b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES)}, 378744996b561b92473cc8ba23275811eb1a6b44d5eEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_LINE)}, 3793b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE)}, 3805bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET)}, 3815bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER)}, 382e9ef478adc4690c9d074c2dc063f9dc40ef81451Uday Kishore Pasupuleti {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_HFP)}, 3835bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HEADPHONES)}, 38409f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_LINE)}, 3855bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_HDMI)}, 3865bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HDMI)}, 3875bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO)}, 3885bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO_WB)}, 38998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET_TMUS)}, 3909d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HAC_HANDSET)}, 3915bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES)}, 3925bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES)}, 3935bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET)}, 39498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 39598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George /* in */ 39663863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_PROTECTED)}, 39763863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED)}, 3985bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC)}, 39998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC)}, 4003ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_NS)}, 4013ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC_NS)}, 4023ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC)}, 4033ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC)}, 4043ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_NS)}, 4053ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC_NS)}, 4063ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_STEREO)}, 4073ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 4083ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC)}, 40998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC)}, 4103ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_NS)}, 4113ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC_NS)}, 4123ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC)}, 4133ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC)}, 4143ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_NS)}, 4153ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS)}, 4163ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_STEREO)}, 4173ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 4183ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC)}, 419b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC_AEC)}, 4203ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 4215bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_HDMI_MIC)}, 4225bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC)}, 423e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_NREC)}, 4245bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB)}, 425e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB_NREC)}, 4265bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_MIC)}, 4273ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 4283ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC)}, 4293ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC_TMUS)}, 4303ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_MIC)}, 431e9ef478adc4690c9d074c2dc063f9dc40ef81451Uday Kishore Pasupuleti {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP)}, 4323ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_DMIC)}, 4333ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_HEADSET_MIC)}, 4345bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC)}, 4355bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC)}, 4365bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC)}, 4373ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 4385bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC)}, 4393ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC_NS)}, 4403ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_STEREO)}, 4413ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE)}, 4428c83fe85b6d1257298208de043acece927787c3fJean-Michel Trivi {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_HEADSET_MIC)}, 44363863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 44490fb96106e9e2db75e214722c797d013e10e5328rago {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_MIC)}, 44590fb96106e9e2db75e214722c797d013e10e5328rago {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC)}, 44690fb96106e9e2db75e214722c797d013e10e5328rago 447c92c59683257878fb8dc08d827313b4a865898daPrashant Malani {TO_NAME_INDEX(SND_DEVICE_IN_THREE_MIC)}, 448c92c59683257878fb8dc08d827313b4a865898daPrashant Malani {TO_NAME_INDEX(SND_DEVICE_IN_QUAD_MIC)}, 44963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda {TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)}, 450c92c59683257878fb8dc08d827313b4a865898daPrashant Malani {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_TMIC)}, 451c92c59683257878fb8dc08d827313b4a865898daPrashant Malani {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_QMIC)}, 45298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George}; 45398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 454b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamandastatic char * backend_tag_table[SND_DEVICE_MAX] = {0}; 455b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamandastatic char * hw_interface_table[SND_DEVICE_MAX] = {0}; 45698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 45798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic const struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { 45898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_DEEP_BUFFER)}, 45998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_LOW_LATENCY)}, 46098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MULTI_CH)}, 46198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD)}, 4622bc7b02259e0edf38432b258594da29571f29713Ravi Kumar Alamanda {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_TTS)}, 4632bc7b02259e0edf38432b258594da29571f29713Ravi Kumar Alamanda {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_ULL)}, 46498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_RECORD)}, 46598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)}, 46698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOICE_CALL)}, 46798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOICE2_CALL)}, 46898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOLTE_CALL)}, 46998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_QCHAT_CALL)}, 47098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_VOWLAN_CALL)}, 47198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK)}, 47298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_INCALL_REC_DOWNLINK)}, 47398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK_AND_DOWNLINK)}, 47498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George {TO_NAME_INDEX(USECASE_AUDIO_HFP_SCO)}, 4755bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George}; 4765bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 4777ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) 4787ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) 4797ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George 480b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT; 481b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic bool is_tmus = false; 482b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 483b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic void check_operator() 484b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 485b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char value[PROPERTY_VALUE_MAX]; 486b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int mccmnc; 487b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("gsm.sim.operator.numeric",value,"0"); 488b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mccmnc = atoi(value); 489b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGD("%s: tmus mccmnc %d", __func__, mccmnc); 490b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent switch(mccmnc) { 491b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* TMUS MCC(310), MNC(490, 260, 026) */ 492b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310490: 493b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310260: 494b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310026: 495b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon /* Add new TMUS MNC(800, 660, 580, 310, 270, 250, 240, 230, 220, 210, 200, 160) */ 496b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310800: 497b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310660: 498b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310580: 499b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310310: 500b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310270: 501b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310250: 502b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310240: 503b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310230: 504b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310220: 505b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310210: 506b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310200: 507b891db5473ab23a0cbc52d566a97c3d3529f8dddsangwon.jeon case 310160: 508b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent is_tmus = true; 509b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 510b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 511b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 512b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 513b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentbool is_operator_tmus() 514b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 515b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent pthread_once(&check_op_once_ctl, check_operator); 516b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return is_tmus; 517b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 518b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 5192f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.parkstatic char *get_current_operator() 5202f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park{ 5212f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct listnode *node; 5222f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct operator_info *info_item; 5232f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park char mccmnc[PROPERTY_VALUE_MAX]; 5242f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park char *ret = NULL; 5252f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5262f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park property_get("gsm.sim.operator.numeric",mccmnc,"0"); 5272f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5282f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park list_for_each(node, &operator_info_list) { 5292f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park info_item = node_to_item(node, struct operator_info, list); 5302f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (strstr(info_item->mccmnc, mccmnc) != NULL) { 5312f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park ret = info_item->name; 5322f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } 5332f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } 5342f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5352f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park return ret; 5362f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park} 5372f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5382f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.parkstatic struct operator_specific_device *get_operator_specific_device(snd_device_t snd_device) 5392f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park{ 5402f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct listnode *node; 5412f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct operator_specific_device *ret = NULL; 5422f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct operator_specific_device *device_item; 5432f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park char *operator_name; 5442f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5452f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park operator_name = get_current_operator(); 5462f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (operator_name == NULL) 5472f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park return ret; 5482f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5492f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park list_for_each(node, operator_specific_device_table[snd_device]) { 5502f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park device_item = node_to_item(node, struct operator_specific_device, list); 5512f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (strcmp(operator_name, device_item->operator) == 0) { 5522f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park ret = device_item; 5532f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } 5542f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } 5552f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5562f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park return ret; 5572f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park} 5582f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5592f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5602f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.parkstatic int get_operator_specific_device_acdb_id(snd_device_t snd_device) 5612f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park{ 5622f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct operator_specific_device *device; 5632f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park int ret = acdb_device_table[snd_device]; 5642f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5652f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park device = get_operator_specific_device(snd_device); 5662f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (device != NULL) 5672f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park ret = device->acdb_id; 5682f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5692f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park return ret; 5702f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park} 5712f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5722f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.parkstatic const char *get_operator_specific_device_mixer_path(snd_device_t snd_device) 5732f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park{ 5742f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct operator_specific_device *device; 5752f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park const char *ret = device_table[snd_device]; 5762f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5772f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park device = get_operator_specific_device(snd_device); 5782f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (device != NULL) 5792f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park ret = device->mixer_path; 5802f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5812f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park return ret; 5822f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park} 5832f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 5841a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehtabool platform_send_gain_dep_cal(void *platform, int level) 5851a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta{ 5861a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta bool ret_val = false; 5871a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta struct platform_data *my_data = (struct platform_data *)platform; 5881a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta struct audio_device *adev = my_data->adev; 5891a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta int acdb_dev_id, app_type; 5901a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta int acdb_dev_type = MSM_SNDDEV_CAP_RX; 5911a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta int mode = CAL_MODE_RTAC; 5921a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta struct listnode *node; 5931a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta struct audio_usecase *usecase; 5941a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta 5951a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta if (my_data->acdb_send_gain_dep_cal == NULL) { 5961a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta ALOGE("%s: dlsym error for acdb_send_gain_dep_cal", __func__); 5971a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta return ret_val; 5981a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta } 5991a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta 6001a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta if (!voice_is_in_call(adev)) { 6011a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta ALOGV("%s: Not Voice call usecase, apply new cal for level %d", 6021a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta __func__, level); 6031a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta app_type = DEFAULT_APP_TYPE_RX_PATH; 6041a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta 6051a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta // find the current active sound device 6061a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta list_for_each(node, &adev->usecase_list) { 6071a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta usecase = node_to_item(node, struct audio_usecase, list); 6081a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta 6091a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta if (usecase != NULL && 6101a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta usecase->type == PCM_PLAYBACK && 6111a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta (usecase->stream.out->devices == AUDIO_DEVICE_OUT_SPEAKER)) { 6121a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta 6131a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta ALOGV("%s: out device is %d", __func__, usecase->out_snd_device); 6144cb8298a322ef5be6f8db002e50c764fdecc2c55vivek mehta if (audio_extn_spkr_prot_is_enabled()) { 6154cb8298a322ef5be6f8db002e50c764fdecc2c55vivek mehta acdb_dev_id = audio_extn_spkr_prot_get_acdb_id(usecase->out_snd_device); 6164cb8298a322ef5be6f8db002e50c764fdecc2c55vivek mehta } else { 6174cb8298a322ef5be6f8db002e50c764fdecc2c55vivek mehta acdb_dev_id = acdb_device_table[usecase->out_snd_device]; 6184cb8298a322ef5be6f8db002e50c764fdecc2c55vivek mehta } 6194cb8298a322ef5be6f8db002e50c764fdecc2c55vivek mehta 6201a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta if (!my_data->acdb_send_gain_dep_cal(acdb_dev_id, app_type, 6211a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta acdb_dev_type, mode, level)) { 6221a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta // set ret_val true if at least one calibration is set successfully 6231a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta ret_val = true; 6241a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta } else { 6251a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta ALOGE("%s: my_data->acdb_send_gain_dep_cal failed ", __func__); 6261a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta } 6271a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta } else { 6281a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta ALOGW("%s: Usecase list is empty", __func__); 6291a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta } 6301a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta } 6311a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta } else { 6321a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta ALOGW("%s: Voice call in progress .. ignore setting new cal", 6331a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta __func__); 6341a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta } 6351a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta return ret_val; 6361a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta} 6371a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta 638cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurentvoid platform_set_echo_reference(struct audio_device *adev, bool enable, audio_devices_t out_device) 639b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 640f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)adev->platform; 641cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 642cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent 643f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda if (strcmp(my_data->ec_ref_mixer_path, "")) { 644f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda ALOGV("%s: diabling %s", __func__, my_data->ec_ref_mixer_path); 645f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda audio_route_reset_and_update_path(adev->audio_route, my_data->ec_ref_mixer_path); 646cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } 647cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent 648f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda if (enable) { 649f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda strcpy(my_data->ec_ref_mixer_path, "echo-reference"); 650f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda if (out_device != AUDIO_DEVICE_NONE) { 651f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda snd_device = platform_get_output_snd_device(adev->platform, out_device); 652f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda platform_add_backend_name(adev->platform, my_data->ec_ref_mixer_path, snd_device); 653f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda } 654b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 655f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda ALOGD("%s: enabling %s", __func__, my_data->ec_ref_mixer_path); 656f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda audio_route_apply_and_update_path(adev->audio_route, my_data->ec_ref_mixer_path); 657f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda } 658b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 659b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 66083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandastatic struct csd_data *open_csd_client(bool i2s_ext_modem) 66183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 66283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct csd_data *csd = calloc(1, sizeof(struct csd_data)); 66383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 66483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW); 66583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->csd_client == NULL) { 66683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT); 66783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 66883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 66983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT); 67083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 67183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->deinit = (deinit_t)dlsym(csd->csd_client, 67283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_deinit"); 67383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->deinit == NULL) { 67483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_deinit", __func__, 67583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda dlerror()); 67683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 67783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 67883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->disable_device = (disable_device_t)dlsym(csd->csd_client, 67983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_disable_device"); 68083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->disable_device == NULL) { 68183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_disable_device", 68283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 68383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 68483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 68583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->enable_device_config = (enable_device_config_t)dlsym(csd->csd_client, 68683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_enable_device_config"); 68783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->enable_device_config == NULL) { 68883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_enable_device_config", 68983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 69083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 69183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 69283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->enable_device = (enable_device_t)dlsym(csd->csd_client, 69383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_enable_device"); 69483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->enable_device == NULL) { 69583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_enable_device", 69683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 69783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 69883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 69983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_voice = (start_voice_t)dlsym(csd->csd_client, 70083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_voice"); 70183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_voice == NULL) { 70283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_voice", 70383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 70483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 70583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 70683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_voice = (stop_voice_t)dlsym(csd->csd_client, 70783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_voice"); 70883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_voice == NULL) { 70983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_voice", 71083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 71183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 71283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 71383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->volume = (volume_t)dlsym(csd->csd_client, 71483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_volume"); 71583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->volume == NULL) { 71683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_volume", 71783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 71883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 71983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 72083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->mic_mute = (mic_mute_t)dlsym(csd->csd_client, 72183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_mic_mute"); 72283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->mic_mute == NULL) { 72383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_mic_mute", 72483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 72583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 72683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 72783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->slow_talk = (slow_talk_t)dlsym(csd->csd_client, 72883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_slow_talk"); 72983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->slow_talk == NULL) { 73083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_slow_talk", 73183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 73283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 73383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 73483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_playback = (start_playback_t)dlsym(csd->csd_client, 73583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_playback"); 73683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_playback == NULL) { 73783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_playback", 73883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 73983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 74083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 74183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_playback = (stop_playback_t)dlsym(csd->csd_client, 74283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_playback"); 74383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_playback == NULL) { 74483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_playback", 74583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 74683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 74783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 74883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->start_record = (start_record_t)dlsym(csd->csd_client, 74983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_start_record"); 75083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->start_record == NULL) { 75183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_start_record", 75283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 75383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 75483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 75583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->stop_record = (stop_record_t)dlsym(csd->csd_client, 75683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_stop_record"); 75783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->stop_record == NULL) { 75883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_stop_record", 75983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 76083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 76183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 76283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 76383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->get_sample_rate = (get_sample_rate_t)dlsym(csd->csd_client, 76483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "csd_client_get_sample_rate"); 76583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->get_sample_rate == NULL) { 76683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_get_sample_rate", 76783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 76883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 76983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 77083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 77183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 77283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->init = (init_t)dlsym(csd->csd_client, "csd_client_init"); 77383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 77483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd->init == NULL) { 77583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for csd_client_init", 77683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, dlerror()); 77783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda goto error; 77883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 77983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->init(i2s_ext_modem); 78083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 78183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 78283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return csd; 78383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 78483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaerror: 78583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda free(csd); 78683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd = NULL; 78783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return csd; 78883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 78983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 79083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandavoid close_csd_client(struct csd_data *csd) 79183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 79283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (csd != NULL) { 79383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd->deinit(); 79483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda dlclose(csd->csd_client); 79583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda free(csd); 79683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda csd = NULL; 79783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 79883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 79983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 80083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandastatic void platform_csd_init(struct platform_data *my_data) 80183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 80283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#ifdef PLATFORM_MSM8084 803ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev int32_t modems, (*count_modems)(void); 804ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev const char *name = "libdetectmodem.so"; 805ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev const char *func = "count_modems"; 806ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev const char *error; 807ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 808ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev my_data->csd = NULL; 809ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 810ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev void *lib = dlopen(name, RTLD_NOW); 811ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev error = dlerror(); 812ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (!lib) { 813ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGE("%s: could not find %s: %s", __func__, name, error); 814ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev return; 815ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev } 816ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 817ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev count_modems = NULL; 818ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev *(void **)(&count_modems) = dlsym(lib, func); 819ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev error = dlerror(); 820ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (!count_modems) { 821ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGE("%s: could not find symbol %s in %s: %s", 822ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev __func__, func, name, error); 823ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev goto done; 82483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 82583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 826ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev modems = count_modems(); 827ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (modems < 0) { 828ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGE("%s: count_modems failed\n", __func__); 829ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev goto done; 830ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev } 831ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 832ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev ALOGD("%s: num_modems %d\n", __func__, modems); 833ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev if (modems > 0) 83483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->csd = open_csd_client(false /*is_i2s_ext_modem*/); 835ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev 836ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchevdone: 837ae9a10c15cf960e9b2b1159ade6414f80689db5fIliyan Malchev dlclose(lib); 83883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 83983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->csd = NULL; 84083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 84183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 84283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 843c633338c83da3760c4965d29af2afd80d3cce840Eric Laurentstatic void set_platform_defaults(struct platform_data * my_data) 84498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 84598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int32_t dev; 84698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George for (dev = 0; dev < SND_DEVICE_MAX; dev++) { 847b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[dev] = NULL; 848b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[dev] = NULL; 8492f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park operator_specific_device_table[dev] = NULL; 85098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 85198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 852b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda // To overwrite these go to the audio_platform_info.xml file. 853b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC] = strdup("bt-sco"); 854e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_NREC] = strdup("bt-sco"); 855b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[SND_DEVICE_OUT_BT_SCO] = strdup("bt-sco"); 856b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[SND_DEVICE_OUT_HDMI] = strdup("hdmi"); 857b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("speaker-and-hdmi"); 858b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("bt-sco-wb"); 859b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_WB] = strdup("bt-sco-wb"); 860e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = strdup("bt-sco-wb"); 861b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[SND_DEVICE_OUT_VOICE_TX] = strdup("afe-proxy"); 862b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[SND_DEVICE_IN_VOICE_RX] = strdup("afe-proxy"); 86398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 864b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_HANDSET] = strdup("SLIMBUS_0_RX"); 865b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_SPEAKER] = strdup("SLIMBUS_0_RX"); 866b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_SPEAKER_REVERSE] = strdup("SLIMBUS_0_RX"); 867b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_SPEAKER_SAFE] = strdup("SLIMBUS_0_RX"); 868b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_HEADPHONES] = strdup("SLIMBUS_0_RX"); 869b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_LINE] = strdup("SLIMBUS_0_RX"); 870b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = strdup("SLIMBUS_0_RX"); 8713b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES] = strdup("SLIMBUS_0_RX"); 872b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_SPEAKER_AND_LINE] = strdup("SLIMBUS_0_RX"); 8733b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE] = strdup("SLIMBUS_0_RX"); 874b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_HANDSET] = strdup("SLIMBUS_0_RX"); 875b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_HAC_HANDSET] = strdup("SLIMBUS_0_RX"); 876b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER] = strdup("SLIMBUS_0_RX"); 877b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_HEADPHONES] = strdup("SLIMBUS_0_RX"); 878b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_LINE] = strdup("SLIMBUS_0_RX"); 879b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_HDMI] = strdup("HDMI_RX"); 880b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("SLIMBUS_0_RX-and-HDMI_RX"); 881b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_BT_SCO] = strdup("SEC_AUX_PCM_RX"); 882b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("SEC_AUX_PCM_RX"); 883b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = strdup("SLIMBUS_0_RX"); 884b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = strdup("SLIMBUS_0_RX"); 885b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = strdup("SLIMBUS_0_RX"); 886b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = strdup("SLIMBUS_0_RX"); 887b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_TX] = strdup("AFE_PCM_RX"); 888b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_SPEAKER_PROTECTED] = strdup("SLIMBUS_0_RX"); 889b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED] = strdup("SLIMBUS_0_RX"); 890c633338c83da3760c4965d29af2afd80d3cce840Eric Laurent 891c633338c83da3760c4965d29af2afd80d3cce840Eric Laurent my_data->max_mic_count = PLATFORM_DEFAULT_MIC_COUNT; 89298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 89398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 8945c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamandavoid get_cvd_version(char *cvd_version, struct audio_device *adev) 8955c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda{ 8965c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda struct mixer_ctl *ctl; 8975c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda int count; 8985c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda int ret = 0; 8995c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda 9005c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda ctl = mixer_get_ctl_by_name(adev->mixer, CVD_VERSION_MIXER_CTL); 9015c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda if (!ctl) { 9025c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda ALOGE("%s: Could not get ctl for mixer cmd - %s", __func__, CVD_VERSION_MIXER_CTL); 9035c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda goto done; 9045c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda } 9055c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda mixer_ctl_update(ctl); 9065c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda 9075c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda count = mixer_ctl_get_num_values(ctl); 9085c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda if (count > MAX_CVD_VERSION_STRING_SIZE) 9095c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda count = MAX_CVD_VERSION_STRING_SIZE - 1; 9105c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda 9115c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda ret = mixer_ctl_get_array(ctl, cvd_version, count); 9125c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda if (ret != 0) { 9135c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda ALOGE("%s: ERROR! mixer_ctl_get_array() failed to get CVD Version", __func__); 9145c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda goto done; 9155c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda } 9165c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda 9175c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamandadone: 9185c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda return; 9195c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda} 9205c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda 921b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid *platform_init(struct audio_device *adev) 922b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 923b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char value[PROPERTY_VALUE_MAX]; 924b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data; 9254b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int retry_num = 0, snd_card_num = 0; 92665ad12de29cc94d65b2efc76588ae69ba941ba98vivek mehta bool dual_mic_config = false; 92783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda const char *snd_card_name; 9285c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda char *cvd_version = NULL; 9291b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 930c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda my_data = calloc(1, sizeof(struct platform_data)); 931c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 932c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda my_data->adev = adev; 933c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 9342f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park list_init(&operator_info_list); 9352f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 936c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda set_platform_defaults(my_data); 937c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 938c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda /* Initialize platform specific ids and/or backends*/ 939c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda platform_info_init(my_data); 940c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 9414b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava while (snd_card_num < MAX_SND_CARD) { 9424b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->mixer = mixer_open(snd_card_num); 9431b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 9444b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava while (!adev->mixer && retry_num < RETRY_NUMBER) { 9454b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava usleep(RETRY_US); 9464b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->mixer = mixer_open(snd_card_num); 9474b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava retry_num++; 9484b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 94983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 9504b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!adev->mixer) { 9514b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Unable to open the mixer card: %d", __func__, 9524b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_num); 9534b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava retry_num = 0; 9544b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_num++; 9554b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava continue; 9564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 957cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 9584b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava snd_card_name = mixer_get_name(adev->mixer); 959c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 960c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda /* validate the sound card name */ 961c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda if (my_data->snd_card_name != NULL && 962c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda strncmp(snd_card_name, my_data->snd_card_name, MAX_SND_CARD_NAME_LEN) != 0) { 963c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda ALOGI("%s: found valid sound card %s, but not primary sound card %s", 964c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda __func__, snd_card_name, my_data->snd_card_name); 965c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda retry_num = 0; 966c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda snd_card_num++; 967c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda continue; 968c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda } 969c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 9704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGD("%s: snd_card_name: %s", __func__, snd_card_name); 971a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent 97211dd22384f2ae13ec4a7563ce5f0a113cf30a53cUday Kishore Pasupuleti if (!strncmp(snd_card_name, "msm8226-tomtom-snd-card", 97311dd22384f2ae13ec4a7563ce5f0a113cf30a53cUday Kishore Pasupuleti sizeof("msm8226-tomtom-snd-card"))) { 97411dd22384f2ae13ec4a7563ce5f0a113cf30a53cUday Kishore Pasupuleti ALOGD("%s: Call MIXER_XML_PATH_WCD9330", __func__); 97511dd22384f2ae13ec4a7563ce5f0a113cf30a53cUday Kishore Pasupuleti adev->audio_route = audio_route_init(snd_card_num, 97611dd22384f2ae13ec4a7563ce5f0a113cf30a53cUday Kishore Pasupuleti MIXER_XML_PATH_WCD9330); 97711dd22384f2ae13ec4a7563ce5f0a113cf30a53cUday Kishore Pasupuleti } else { 97811dd22384f2ae13ec4a7563ce5f0a113cf30a53cUday Kishore Pasupuleti adev->audio_route = audio_route_init(snd_card_num, MIXER_XML_PATH); 97911dd22384f2ae13ec4a7563ce5f0a113cf30a53cUday Kishore Pasupuleti } 98011dd22384f2ae13ec4a7563ce5f0a113cf30a53cUday Kishore Pasupuleti 9814b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!adev->audio_route) { 9824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Failed to init audio route controls, aborting.", __func__); 983c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda goto init_failed; 9844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 9854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava adev->snd_card = snd_card_num; 9864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGD("%s: Opened sound card:%d", __func__, snd_card_num); 9874b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava break; 9884b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 9894b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 9904b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (snd_card_num >= MAX_SND_CARD) { 9914b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Unable to find correct sound card, aborting.", __func__); 992c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda goto init_failed; 9931b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo } 994b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 995c5aaa0e767b83fa8299861a739a4a1cb8e9bee0fkeunhui.park //set max volume step for voice call 996c5aaa0e767b83fa8299861a739a4a1cb8e9bee0fkeunhui.park property_get("ro.config.vc_call_vol_steps", value, TOSTRING(MAX_VOL_INDEX)); 997c5aaa0e767b83fa8299861a739a4a1cb8e9bee0fkeunhui.park my_data->max_vol_index = atoi(value); 998c5aaa0e767b83fa8299861a739a4a1cb8e9bee0fkeunhui.park 99965ad12de29cc94d65b2efc76588ae69ba941ba98vivek mehta property_get("persist.audio.dualmic.config",value,""); 100065ad12de29cc94d65b2efc76588ae69ba941ba98vivek mehta if (!strcmp("endfire", value)) { 100165ad12de29cc94d65b2efc76588ae69ba941ba98vivek mehta dual_mic_config = true; 100265ad12de29cc94d65b2efc76588ae69ba941ba98vivek mehta } 100365ad12de29cc94d65b2efc76588ae69ba941ba98vivek mehta 1004c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->source_mic_type = SOURCE_DUAL_MIC; 1005c92c59683257878fb8dc08d827313b4a865898daPrashant Malani 1006b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_spkr_mode = false; 1007b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_call = false; 10083ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm = false; 1009b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_rec = false; 1010b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 101165ad12de29cc94d65b2efc76588ae69ba941ba98vivek mehta property_get("ro.qc.sdk.audio.fluencetype", value, "none"); 1012c92c59683257878fb8dc08d827313b4a865898daPrashant Malani if (!strcmp("fluencepro", value)) { 1013c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->fluence_type = FLUENCE_PRO_ENABLE; 101465ad12de29cc94d65b2efc76588ae69ba941ba98vivek mehta } else if (!strcmp("fluence", value) || (dual_mic_config)) { 1015c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->fluence_type = FLUENCE_ENABLE; 1016c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if (!strcmp("none", value)) { 1017c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->fluence_type = FLUENCE_DISABLE; 1018b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1019b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1020c92c59683257878fb8dc08d827313b4a865898daPrashant Malani if (my_data->fluence_type != FLUENCE_DISABLE) { 1021b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.voicecall",value,""); 1022b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 1023b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_call = true; 1024b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1025b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 10263ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda property_get("persist.audio.fluence.voicecomm",value,""); 10273ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (!strcmp("true", value)) { 10283ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm = true; 10293ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } 10303ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda 1031b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.voicerec",value,""); 1032b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 1033b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_rec = true; 1034b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1035b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1036b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.speaker",value,""); 1037b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 1038b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_spkr_mode = true; 1039b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1040b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1041b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1042c92c59683257878fb8dc08d827313b4a865898daPrashant Malani // support max to mono, example if max count is 3, usecase supports Three, dual and mono mic 1043c92c59683257878fb8dc08d827313b4a865898daPrashant Malani switch (my_data->max_mic_count) { 1044c92c59683257878fb8dc08d827313b4a865898daPrashant Malani case 4: 1045c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->source_mic_type |= SOURCE_QUAD_MIC; 1046c92c59683257878fb8dc08d827313b4a865898daPrashant Malani case 3: 1047c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->source_mic_type |= SOURCE_THREE_MIC; 1048c92c59683257878fb8dc08d827313b4a865898daPrashant Malani case 2: 1049c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->source_mic_type |= SOURCE_DUAL_MIC; 1050c92c59683257878fb8dc08d827313b4a865898daPrashant Malani case 1: 1051c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->source_mic_type |= SOURCE_MONO_MIC; 1052c92c59683257878fb8dc08d827313b4a865898daPrashant Malani break; 1053c92c59683257878fb8dc08d827313b4a865898daPrashant Malani default: 1054c92c59683257878fb8dc08d827313b4a865898daPrashant Malani ALOGE("%s: max_mic_count (%d), is not supported, setting to default", 1055c92c59683257878fb8dc08d827313b4a865898daPrashant Malani __func__, my_data->max_mic_count); 1056c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->source_mic_type = SOURCE_MONO_MIC|SOURCE_DUAL_MIC; 1057c92c59683257878fb8dc08d827313b4a865898daPrashant Malani break; 1058c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 1059c92c59683257878fb8dc08d827313b4a865898daPrashant Malani 1060c92c59683257878fb8dc08d827313b4a865898daPrashant Malani ALOGV("%s: Fluence_Type(%d) max_mic_count(%d) mic_type(0x%x) fluence_in_voice_call(%d)" 1061c92c59683257878fb8dc08d827313b4a865898daPrashant Malani " fluence_in_voice_comm(%d) fluence_in_voice_rec(%d) fluence_in_spkr_mode(%d) ", 1062c92c59683257878fb8dc08d827313b4a865898daPrashant Malani __func__, my_data->fluence_type, my_data->max_mic_count, my_data->source_mic_type, 1063c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->fluence_in_voice_call, my_data->fluence_in_voice_comm, 1064c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->fluence_in_voice_rec, my_data->fluence_in_spkr_mode); 1065c92c59683257878fb8dc08d827313b4a865898daPrashant Malani 1066b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); 1067b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_handle == NULL) { 1068b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER); 1069b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1070b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER); 1071b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle, 1072b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_deallocate_ACDB"); 107383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_deallocate) 107483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_deallocate_ACDB from %s", 107583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 107683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 1077b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle, 1078b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_send_audio_cal"); 1079b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!my_data->acdb_send_audio_cal) 108083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_send_audio_cal from %s", 1081b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, LIB_ACDB_LOADER); 108283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 1083b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle, 1084b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_send_voice_cal"); 108583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_send_voice_cal) 108683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_send_voice_cal from %s", 108783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 108883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 108983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->acdb_reload_vocvoltable = (acdb_reload_vocvoltable_t)dlsym(my_data->acdb_handle, 109083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda "acdb_loader_reload_vocvoltable"); 109183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (!my_data->acdb_reload_vocvoltable) 109283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Could not find the symbol acdb_loader_reload_vocvoltable from %s", 109383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, LIB_ACDB_LOADER); 10941a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta 10951a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta my_data->acdb_send_gain_dep_cal = (acdb_send_gain_dep_cal_t)dlsym(my_data->acdb_handle, 10961a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta "acdb_loader_send_gain_dep_cal"); 10971a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta if (!my_data->acdb_send_gain_dep_cal) 10981a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta ALOGV("%s: Could not find the symbol acdb_loader_send_gain_dep_cal from %s", 10991a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta __func__, LIB_ACDB_LOADER); 11001a9b7c0f180df7fe390f2839e8214667727aaa49vivek mehta 1101c698f1313378541ec781a986fc68615ec35536c3vivek mehta#if defined (PLATFORM_MSM8994) || (PLATFORM_MSM8996) 11025c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda acdb_init_v2_cvd_t acdb_init; 11035c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda acdb_init = (acdb_init_v2_cvd_t)dlsym(my_data->acdb_handle, 11045c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda "acdb_loader_init_v2"); 11055c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda if (acdb_init == NULL) { 110683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror()); 11075c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda goto acdb_init_fail; 11085c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda } 11095c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda 11105c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda cvd_version = calloc(1, MAX_CVD_VERSION_STRING_SIZE); 11115c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda get_cvd_version(cvd_version, adev); 11125c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda if (!cvd_version) 11135c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda ALOGE("failed to allocate cvd_version"); 111483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda else 1115c698f1313378541ec781a986fc68615ec35536c3vivek mehta acdb_init((char *)snd_card_name, cvd_version, 0); 11165c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda free(cvd_version); 11175c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda#elif defined (PLATFORM_MSM8084) 11185c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda acdb_init_v2_t acdb_init; 11195c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda acdb_init = (acdb_init_v2_t)dlsym(my_data->acdb_handle, 11205c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda "acdb_loader_init_v2"); 11215c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda if (acdb_init == NULL) { 11225c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror()); 11235c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda goto acdb_init_fail; 11245c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda } 11255c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda acdb_init((char *)snd_card_name); 112683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#else 11275c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda acdb_init_t acdb_init; 11285c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, 1129b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_init_ACDB"); 11305c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda if (acdb_init == NULL) 1131b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror()); 1132b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 11335c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda acdb_init(); 113483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda#endif 1135b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1136b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 11375c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamandaacdb_init_fail: 11385c049df87e3fad47fb1a6975e41c68eda9a8b594Ravi Kumar Alamanda 113963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda audio_extn_spkr_prot_init(adev); 114098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 11417631557cda5515b07b06dd0def53e5813f2442f3Ravi Kumar Alamanda audio_extn_hwdep_cal_send(adev->snd_card, my_data->acdb_handle); 11427631557cda5515b07b06dd0def53e5813f2442f3Ravi Kumar Alamanda 114383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda /* load csd client */ 114483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda platform_csd_init(my_data); 114583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 1146b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return my_data; 1147c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 1148c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamandainit_failed: 1149c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda if (my_data) 1150c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda free(my_data); 1151c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda return NULL; 1152b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1153b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1154b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid platform_deinit(void *platform) 1155b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1156c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda int32_t dev; 11572f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct operator_info *info_item; 11582f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct operator_specific_device *device_item; 11592f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct listnode *node; 1160c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 11614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 11624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava close_csd_client(my_data->csd); 1163c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 1164c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda for (dev = 0; dev < SND_DEVICE_MAX; dev++) { 1165c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda if (backend_tag_table[dev]) 1166c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda free(backend_tag_table[dev]); 1167c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda if (hw_interface_table[dev]) 1168c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda free(hw_interface_table[dev]); 11692f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (operator_specific_device_table[dev]) { 11702f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park while (!list_empty(operator_specific_device_table[dev])) { 11712f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park node = list_head(operator_specific_device_table[dev]); 11722f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park list_remove(node); 11732f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park device_item = node_to_item(node, struct operator_specific_device, list); 11742f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park free(device_item->operator); 11752f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park free(device_item->mixer_path); 11762f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park free(device_item); 11772f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } 11782f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park free(operator_specific_device_table[dev]); 11792f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } 1180c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda } 1181c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 1182c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda if (my_data->snd_card_name) 1183c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda free(my_data->snd_card_name); 1184c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 11852f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park while (!list_empty(&operator_info_list)) { 11862f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park node = list_head(&operator_info_list); 11872f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park list_remove(node); 11882f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park info_item = node_to_item(node, struct operator_info, list); 11892f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park free(info_item->name); 11902f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park free(info_item->mccmnc); 11912f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park free(info_item); 11922f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } 11932f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 1194b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent free(platform); 1195b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1196b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1197b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentconst char *platform_get_snd_device_name(snd_device_t snd_device) 1198b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 11992f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) { 12002f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (operator_specific_device_table[snd_device] != NULL) { 12012f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park return get_operator_specific_device_mixer_path(snd_device); 12022f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } 1203b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return device_table[snd_device]; 12042f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } else 12056402646dbd962f62c37abbb1d435907d54da77ddRavi Kumar Alamanda return "none"; 1206b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1207b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1208299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamandavoid platform_add_backend_name(void *platform, char *mixer_path, 1209299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda snd_device_t snd_device) 1210b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1211299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 1212299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda 121398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { 121498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); 121598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return; 12161de6e5aac3120408a003dc8b5f7fdd68c40f436dRavi Kumar Alamanda } 121798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 1218b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda const char * suffix = backend_tag_table[snd_device]; 121998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 122098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (suffix != NULL) { 122198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George strcat(mixer_path, " "); 122298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George strcat(mixer_path, suffix); 1223299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda } 1224b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1225b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1226b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamandabool platform_check_backends_match(snd_device_t snd_device1, snd_device_t snd_device2) 1227b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda{ 1228b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda bool result = true; 1229b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda 1230b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda ALOGV("%s: snd_device1 = %s, snd_device2 = %s", __func__, 1231b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda platform_get_snd_device_name(snd_device1), 1232b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda platform_get_snd_device_name(snd_device2)); 1233b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda 1234b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda if ((snd_device1 < SND_DEVICE_MIN) || (snd_device1 >= SND_DEVICE_MAX)) { 1235b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda ALOGE("%s: Invalid snd_device = %s", __func__, 1236b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda platform_get_snd_device_name(snd_device1)); 1237b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda return false; 1238b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda } 1239b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda if ((snd_device2 < SND_DEVICE_MIN) || (snd_device2 >= SND_DEVICE_MAX)) { 1240b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda ALOGE("%s: Invalid snd_device = %s", __func__, 1241b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda platform_get_snd_device_name(snd_device2)); 1242b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda return false; 1243b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda } 1244b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda const char * be_itf1 = hw_interface_table[snd_device1]; 1245b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda const char * be_itf2 = hw_interface_table[snd_device2]; 1246b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda 1247b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda if (NULL != be_itf1 && NULL != be_itf2) { 1248e63e61d40e171b60b8345f2a47022d066aa589f2Eric Laurent if ((NULL == strstr(be_itf2, be_itf1)) && (NULL == strstr(be_itf1, be_itf2))) 1249b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda result = false; 1250b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda } 1251b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda 1252b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda ALOGV("%s: be_itf1 = %s, be_itf2 = %s, match %d", __func__, be_itf1, be_itf2, result); 1253b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda return result; 1254b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda} 1255b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda 1256b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) 1257b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1258b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int device_id; 1259b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (device_type == PCM_PLAYBACK) 1260b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent device_id = pcm_device_table[usecase][0]; 1261b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1262b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent device_id = pcm_device_table[usecase][1]; 1263b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return device_id; 1264b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1265b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 126698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgestatic int find_index(const struct name_to_index * table, int32_t len, 126798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George const char * name) 12685bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George{ 12695bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George int ret = 0; 127098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int32_t i; 12715bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 127298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (table == NULL) { 127398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: table is NULL", __func__); 12745bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -ENODEV; 12755bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 12765bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 12775bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 127898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (name == NULL) { 127998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("null key"); 128098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -ENODEV; 128198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George goto done; 128298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 128398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 128498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George for (i=0; i < len; i++) { 128598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if (!strcmp(table[i].name, name)) { 128698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = table[i].index; 12875bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 12885bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 12895bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 129098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: Could not find index for name = %s", 129198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George __func__, name); 12925bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -ENODEV; 12935bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgedone: 12945bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George return ret; 12955bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George} 12965bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 129798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_get_snd_device_index(char *device_name) 129898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 129998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return find_index(snd_device_name_index, SND_DEVICE_MAX, device_name); 130098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 130198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 130298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_get_usecase_index(const char *usecase_name) 130398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 130498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return find_index(usecase_name_index, AUDIO_USECASE_MAX, usecase_name); 130598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 130698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 13072f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.parkvoid platform_add_operator_specific_device(snd_device_t snd_device, 13082f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park const char *operator, 13092f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park const char *mixer_path, 13102f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park unsigned int acdb_id) 13112f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park{ 13122f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct operator_specific_device *device; 13132f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 13142f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (operator_specific_device_table[snd_device] == NULL) { 13152f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park operator_specific_device_table[snd_device] = 13162f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park (struct listnode *)calloc(1, sizeof(struct listnode)); 13172f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park list_init(operator_specific_device_table[snd_device]); 13182f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } 13192f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 13202f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park device = (struct operator_specific_device *)calloc(1, sizeof(struct operator_specific_device)); 13212f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 13222f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park device->operator = strdup(operator); 13232f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park device->mixer_path = strdup(mixer_path); 13242f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park device->acdb_id = acdb_id; 13252f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 13262f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park list_add_tail(operator_specific_device_table[snd_device], &device->list); 13272f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 13282f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park ALOGD("%s : deivce[%s] -> operator[%s] mixer_path[%s] acdb_id [%d]", __func__, 13292f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park platform_get_snd_device_name(snd_device), operator, mixer_path, acdb_id); 13302f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 13312f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park} 13322f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 13335bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgeint platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id) 13345bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George{ 13355bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George int ret = 0; 13365bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 13375bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { 13385bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ALOGE("%s: Invalid snd_device = %d", 13395bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George __func__, snd_device); 13405bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George ret = -EINVAL; 13415bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George goto done; 13425bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George } 13435bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 1344b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda ALOGV("%s: acdb_device_table[%s]: old = %d new = %d", __func__, 1345b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda platform_get_snd_device_name(snd_device), acdb_device_table[snd_device], acdb_id); 13465bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George acdb_device_table[snd_device] = acdb_id; 13475bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew Georgedone: 13485bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George return ret; 13495bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George} 13505bc188456348ebdfc5d3c86414952503ec41bd44Haynes Mathew George 135163863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamandaint platform_get_snd_device_acdb_id(snd_device_t snd_device) 135263863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda{ 135363863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { 135463863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); 135563863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda return -EINVAL; 135663863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda } 13572f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 13582f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (operator_specific_device_table[snd_device] != NULL) 13592f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park return get_operator_specific_device_acdb_id(snd_device); 13602f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park else 13612f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park return acdb_device_table[snd_device]; 136263863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda} 136363863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 1364b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_send_audio_calibration(void *platform, snd_device_t snd_device) 1365b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1366b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1367b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int acdb_dev_id, acdb_dev_type; 1368b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1369adf0f3b3b518e98fc1056e2788dd936e87331fb1Ravi Kumar Alamanda acdb_dev_id = acdb_device_table[audio_extn_get_spkr_prot_snd_device(snd_device)]; 1370b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (acdb_dev_id < 0) { 1371b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not find acdb id for device(%d)", 1372b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, snd_device); 1373b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 1374b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1375b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_send_audio_cal) { 13763ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda ALOGD("%s: sending audio calibration for snd_device(%d) acdb_id(%d)", 1377b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, snd_device, acdb_dev_id); 1378b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device >= SND_DEVICE_OUT_BEGIN && 1379b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device < SND_DEVICE_OUT_END) 1380b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_type = ACDB_DEV_TYPE_OUT; 1381b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1382b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_type = ACDB_DEV_TYPE_IN; 1383b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type); 1384b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1385b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 1386b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1387b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1388b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_pre(void *platform) 1389b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 139083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 139183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 139283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 139383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL && 1394b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda voice_is_in_call(my_data->adev)) { 139583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda /* This must be called before disabling mixer controls on APQ side */ 139683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->disable_device(); 139783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 139883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_client_disable_device, failed, error %d", 139983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, ret); 140083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 140183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 140283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 140383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 140483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 140583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_enable_device_config(void *platform, 140683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t out_snd_device, 140783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t in_snd_device) 140883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 140983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 141083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int acdb_rx_id, acdb_tx_id; 141183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 141283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 141383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd == NULL) 141483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 141583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 141663863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && 141763863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda audio_extn_spkr_prot_is_enabled()) 14182f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park acdb_rx_id = platform_get_snd_device_acdb_id(SND_DEVICE_OUT_SPEAKER_PROTECTED); 141963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda else 14202f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park acdb_rx_id = platform_get_snd_device_acdb_id(out_snd_device); 142183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 14222f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park acdb_tx_id = platform_get_snd_device_acdb_id(in_snd_device); 142383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 142483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (acdb_rx_id > 0 && acdb_tx_id > 0) { 142583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id); 142683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 142783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_enable_device_config, failed, error %d", 142883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda __func__, ret); 142983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 143083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 143183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 143283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id, acdb_tx_id); 143383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 143483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 143583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1436b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1437b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1438b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_post(void *platform, 1439b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t out_snd_device, 1440b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t in_snd_device) 1441b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1442b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1443b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int acdb_rx_id, acdb_tx_id; 1444b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1445b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_send_voice_cal == NULL) { 1446b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error for acdb_send_voice_call", __func__); 1447b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 144863863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && 144963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda audio_extn_spkr_prot_is_enabled()) 145063863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda out_snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED; 145163863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda 14522f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park acdb_rx_id = platform_get_snd_device_acdb_id(out_snd_device); 14532f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park acdb_tx_id = platform_get_snd_device_acdb_id(in_snd_device); 1454b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1455b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (acdb_rx_id > 0 && acdb_tx_id > 0) 1456b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id); 1457b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1458b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 1459b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_rx_id, acdb_tx_id); 1460b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1461b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1462b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 1463b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1464b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 146583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_usecase_route_post(void *platform, 146683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t out_snd_device, 146783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t in_snd_device) 146883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 146983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 147083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int acdb_rx_id, acdb_tx_id; 147183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 147283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 147383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd == NULL) 147483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 147583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 147663863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && 147763863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda audio_extn_spkr_prot_is_enabled()) 14782f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park acdb_rx_id = platform_get_snd_device_acdb_id(SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED); 147963863001b659b66a367800c39f4a016ec5d544d7Ravi Kumar Alamanda else 14802f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park acdb_rx_id = platform_get_snd_device_acdb_id(out_snd_device); 148183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 14822f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park acdb_tx_id = platform_get_snd_device_acdb_id(in_snd_device); 148383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 148483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (acdb_rx_id > 0 && acdb_tx_id > 0) { 148583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->enable_device(acdb_rx_id, acdb_tx_id, 148683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda my_data->adev->acdb_settings); 148783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 148883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_enable_device, failed, error %d", __func__, ret); 148983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 149083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } else { 149183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 149283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda acdb_rx_id, acdb_tx_id); 149383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 149483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 149583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 149683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 149783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 14984b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_start_voice_call(void *platform, uint32_t vsid) 1499b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 150083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 150183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 150283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 150383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 15044b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_voice(vsid); 150583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 150683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_start_voice error %d\n", __func__, ret); 150783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 150883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 150983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1510b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1511b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 15124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_voice_call(void *platform, uint32_t vsid) 1513b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 151483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 151583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda int ret = 0; 151683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 151783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 15184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_voice(vsid); 151983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 152083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_stop_voice error %d\n", __func__, ret); 152183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 152283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 152383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1524b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1525b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 15264b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_get_sample_rate(void *platform, uint32_t *rate) 15274b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 15284b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 15294b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 15304b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 15314b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 15324b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->get_sample_rate(rate); 15334b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 15344b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_get_sample_rate error %d\n", __func__, ret); 15354b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 15364b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 15374b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 15384b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 15394b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 1540b65064161c19b4c688f8a436ed002264d9f49055vivek mehtavoid platform_set_speaker_gain_in_combo(struct audio_device *adev, 1541b65064161c19b4c688f8a436ed002264d9f49055vivek mehta snd_device_t snd_device, 1542b65064161c19b4c688f8a436ed002264d9f49055vivek mehta bool enable) 1543b65064161c19b4c688f8a436ed002264d9f49055vivek mehta{ 1544b65064161c19b4c688f8a436ed002264d9f49055vivek mehta const char* name; 1545b65064161c19b4c688f8a436ed002264d9f49055vivek mehta switch (snd_device) { 1546b65064161c19b4c688f8a436ed002264d9f49055vivek mehta case SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES: 1547b65064161c19b4c688f8a436ed002264d9f49055vivek mehta if (enable) 1548b65064161c19b4c688f8a436ed002264d9f49055vivek mehta name = "spkr-gain-in-headphone-combo"; 1549b65064161c19b4c688f8a436ed002264d9f49055vivek mehta else 1550b65064161c19b4c688f8a436ed002264d9f49055vivek mehta name = "speaker-gain-default"; 1551b65064161c19b4c688f8a436ed002264d9f49055vivek mehta break; 1552b65064161c19b4c688f8a436ed002264d9f49055vivek mehta case SND_DEVICE_OUT_SPEAKER_AND_LINE: 1553b65064161c19b4c688f8a436ed002264d9f49055vivek mehta if (enable) 1554b65064161c19b4c688f8a436ed002264d9f49055vivek mehta name = "spkr-gain-in-line-combo"; 1555b65064161c19b4c688f8a436ed002264d9f49055vivek mehta else 1556b65064161c19b4c688f8a436ed002264d9f49055vivek mehta name = "speaker-gain-default"; 1557b65064161c19b4c688f8a436ed002264d9f49055vivek mehta break; 1558b65064161c19b4c688f8a436ed002264d9f49055vivek mehta case SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES: 1559b65064161c19b4c688f8a436ed002264d9f49055vivek mehta if (enable) 1560b65064161c19b4c688f8a436ed002264d9f49055vivek mehta name = "spkr-safe-gain-in-headphone-combo"; 1561b65064161c19b4c688f8a436ed002264d9f49055vivek mehta else 1562b65064161c19b4c688f8a436ed002264d9f49055vivek mehta name = "speaker-safe-gain-default"; 1563b65064161c19b4c688f8a436ed002264d9f49055vivek mehta break; 1564b65064161c19b4c688f8a436ed002264d9f49055vivek mehta case SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE: 1565b65064161c19b4c688f8a436ed002264d9f49055vivek mehta if (enable) 1566b65064161c19b4c688f8a436ed002264d9f49055vivek mehta name = "spkr-safe-gain-in-line-combo"; 1567b65064161c19b4c688f8a436ed002264d9f49055vivek mehta else 1568b65064161c19b4c688f8a436ed002264d9f49055vivek mehta name = "speaker-safe-gain-default"; 1569b65064161c19b4c688f8a436ed002264d9f49055vivek mehta break; 1570b65064161c19b4c688f8a436ed002264d9f49055vivek mehta default: 1571b65064161c19b4c688f8a436ed002264d9f49055vivek mehta return; 1572b65064161c19b4c688f8a436ed002264d9f49055vivek mehta } 1573b65064161c19b4c688f8a436ed002264d9f49055vivek mehta 1574b65064161c19b4c688f8a436ed002264d9f49055vivek mehta audio_route_apply_and_update_path(adev->audio_route, name); 1575b65064161c19b4c688f8a436ed002264d9f49055vivek mehta} 1576b65064161c19b4c688f8a436ed002264d9f49055vivek mehta 1577b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_voice_volume(void *platform, int volume) 1578b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1579b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1580b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1581b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 158253b2cf0c72aa18a5848919e2309731af652e84f9sangwoo const char *mixer_ctl_name = "Voice Rx Gain"; 15834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int vol_index = 0, ret = 0; 15844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 15854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 15864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_VOLUME_RAMP_DURATION_MS}; 1587b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1588b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // Voice volume levels are mapped to adsp volume levels as follows. 1589b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // 100 -> 5, 80 -> 4, 60 -> 3, 40 -> 2, 20 -> 1 0 -> 0 1590b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent // But this values don't changed in kernel. So, below change is need. 1591c5aaa0e767b83fa8299861a739a4a1cb8e9bee0fkeunhui.park vol_index = (int)percent_to_index(volume, MIN_VOL_INDEX, my_data->max_vol_index); 15924b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = vol_index; 1593b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1594b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 1595b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 1596b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 1597b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 1598b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 1599b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 16004b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Setting voice volume index: %d", set_values[0]); 16014b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 16024b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 160383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (my_data->csd != NULL) { 160483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ret = my_data->csd->volume(ALL_SESSION_VSID, volume, 160583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda DEFAULT_VOLUME_RAMP_DURATION_MS); 160683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda if (ret < 0) { 160783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda ALOGE("%s: csd_volume error %d", __func__, ret); 160883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 160983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda } 161083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return ret; 1611b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1612b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1613b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_mic_mute(void *platform, bool state) 1614b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1615b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1616b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1617b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 1618b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "Voice Tx Mute"; 161953b2cf0c72aa18a5848919e2309731af652e84f9sangwoo int ret = 0; 16204b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 16214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 16224b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_MUTE_RAMP_DURATION_MS}; 1623cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 1624a1f480505a2e11b65e8fe6590239bd87b3a33f11Uday Kishore Pasupuleti if (adev->mode != AUDIO_MODE_IN_CALL && 1625a1f480505a2e11b65e8fe6590239bd87b3a33f11Uday Kishore Pasupuleti adev->mode != AUDIO_MODE_IN_COMMUNICATION) 16264b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return 0; 16274b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 1628a1f480505a2e11b65e8fe6590239bd87b3a33f11Uday Kishore Pasupuleti if (adev->enable_hfp) 1629a1f480505a2e11b65e8fe6590239bd87b3a33f11Uday Kishore Pasupuleti mixer_ctl_name = "HFP Tx Mute"; 1630a1f480505a2e11b65e8fe6590239bd87b3a33f11Uday Kishore Pasupuleti 16314b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = state; 16324b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 16334b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 16344b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 16354b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 16364b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 16374b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16384b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Setting voice mute state: %d", state); 16394b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 16404b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16414b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 16424b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->mic_mute(ALL_SESSION_VSID, state, 16434b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava DEFAULT_MUTE_RAMP_DURATION_MS); 1644a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent if (ret < 0) { 16454b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_mic_mute error %d", __func__, ret); 164653b2cf0c72aa18a5848919e2309731af652e84f9sangwoo } 1647cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George } 16484b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 16494b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 1650cedf1ac3c00e331b5f51b077f26c1367544ddd65Haynes Mathew George 16514b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_set_device_mute(void *platform, bool state, char *dir) 16524b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 16534b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 16544b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct audio_device *adev = my_data->adev; 16554b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct mixer_ctl *ctl; 16564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava char *mixer_ctl_name = NULL; 16574b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 16584b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t set_values[ ] = {0, 16594b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALL_SESSION_VSID, 16604b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 0}; 16614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if(dir == NULL) { 16624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Invalid direction:%s", __func__, dir); 16634b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 16644b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16654b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!strncmp("rx", dir, sizeof("rx"))) { 16674b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_name = "Voice Rx Device Mute"; 16684b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else if (!strncmp("tx", dir, sizeof("tx"))) { 16694b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_name = "Voice Tx Device Mute"; 16704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else { 16714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 16724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16734b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16744b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava set_values[0] = state; 16754b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 16764b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 16774b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 16784b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 16794b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return -EINVAL; 16804b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 16814b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("%s: Setting device mute state: %d, mixer ctrl:%s", 16834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__,state, mixer_ctl_name); 16844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); 16854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 16864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 1687b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1688b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1689b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamandabool platform_can_split_snd_device(snd_device_t snd_device, 1690b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda int *num_devices, 1691b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda snd_device_t *new_snd_devices) 1692b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda{ 1693b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda bool status = false; 1694b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda 1695b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda if (NULL == num_devices || NULL == new_snd_devices) { 1696b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda ALOGE("%s: NULL pointer ..", __func__); 1697b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda return false; 1698b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda } 1699b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda 1700b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda /* 1701b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda * If wired headset/headphones/line devices share the same backend 1702b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda * with speaker/earpiece this routine returns false. 1703b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda */ 1704b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES && 1705b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_HEADPHONES)) { 1706b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda *num_devices = 2; 1707b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER; 1708b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda new_snd_devices[1] = SND_DEVICE_OUT_HEADPHONES; 1709b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda status = true; 1710b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda } else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_LINE && 1711b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_LINE)) { 1712b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda *num_devices = 2; 1713b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER; 1714b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda new_snd_devices[1] = SND_DEVICE_OUT_LINE; 1715b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda status = true; 17163b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda } else if (snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES && 17173b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER_SAFE, SND_DEVICE_OUT_HEADPHONES)) { 17183b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda *num_devices = 2; 17193b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER_SAFE; 17203b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda new_snd_devices[1] = SND_DEVICE_OUT_HEADPHONES; 17213b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda status = true; 17223b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda } else if (snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE && 17233b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER_SAFE, SND_DEVICE_OUT_LINE)) { 17243b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda *num_devices = 2; 17253b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER_SAFE; 17263b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda new_snd_devices[1] = SND_DEVICE_OUT_LINE; 17273b86d472a707dd29cd692909fc80cf45a8fec481Ravi Kumar Alamanda status = true; 1728b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda } 1729b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda return status; 1730b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda} 1731b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda 1732b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices) 1733b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1734b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1735b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1736b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_mode_t mode = adev->mode; 1737b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 1738b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1739b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: enter: output devices(%#x)", __func__, devices); 1740b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices == AUDIO_DEVICE_NONE || 1741b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_BIT_IN) { 1742b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: Invalid output devices (%#x)", __func__, devices); 1743b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1744b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1745b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 17461b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent if (popcount(devices) == 2) { 17471b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | 17481b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent AUDIO_DEVICE_OUT_SPEAKER) || 17491b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | 17501b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 17511b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; 17521b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_LINE | 17531b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 17541b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_LINE; 17551b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | 17561b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent AUDIO_DEVICE_OUT_SPEAKER_SAFE) || 17571b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | 17581b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent AUDIO_DEVICE_OUT_SPEAKER_SAFE)) { 17591b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES; 17601b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_LINE | 17611b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent AUDIO_DEVICE_OUT_SPEAKER_SAFE)) { 17621b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE; 17631b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL | 17641b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 17651b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI; 17661b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent } else { 17671b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent ALOGE("%s: Invalid combo device(%#x)", __func__, devices); 17681b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent goto exit; 17691b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent } 17701b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent if (snd_device != SND_DEVICE_NONE) { 17711b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent goto exit; 17721b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent } 17731b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent } 17741b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent 17751b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent if (popcount(devices) != 1) { 17761b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent ALOGE("%s: Invalid output devices(%#x)", __func__, devices); 17771b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent goto exit; 17781b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent } 17791b49155ca2a0b056d09f159861ad0d251a36116dEric Laurent 1780b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda if (voice_is_in_call(adev) || adev->enable_voicerx) { 1781b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 178209f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent devices & AUDIO_DEVICE_OUT_WIRED_HEADSET || 178309f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent devices & AUDIO_DEVICE_OUT_LINE) { 1784b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda if (voice_is_in_call(adev) && 1785cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent (adev->voice.tty_mode == TTY_MODE_FULL)) 1786b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES; 1787b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda else if (voice_is_in_call(adev) && 1788cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent (adev->voice.tty_mode == TTY_MODE_VCO)) 1789b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES; 1790b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda else if (voice_is_in_call(adev) && 1791cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent (adev->voice.tty_mode == TTY_MODE_HCO)) 1792b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET; 179309f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent else { 179409f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent if (devices & AUDIO_DEVICE_OUT_LINE) 179509f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent snd_device = SND_DEVICE_OUT_VOICE_LINE; 179609f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent else 179709f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; 179809f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent } 1799b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { 18009f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 18019f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO_WB; 18029f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 18039f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO; 18049f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 18051b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent } else if (devices & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) { 18067629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti if (!adev->enable_hfp) { 18077629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; 18087629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti } else { 18097629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_HFP; 18107629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti } 1811b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { 18129d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent if(adev->voice.hac) 18139d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HAC_HANDSET; 18149d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent else if (is_operator_tmus()) 1815b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS; 1816b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1817b4d368e0fe6006657ebc4e1f9ba01a072c4ca2c7Eric Laurent snd_device = SND_DEVICE_OUT_VOICE_HANDSET; 181899c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda } else if (devices & AUDIO_DEVICE_OUT_TELEPHONY_TX) 181999c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_VOICE_TX; 182099c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda 1821b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 1822b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1823b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1824b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1825b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1826b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 1827b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1828b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HEADPHONES; 182909f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent } else if (devices & AUDIO_DEVICE_OUT_LINE) { 183009f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent snd_device = SND_DEVICE_OUT_LINE; 18311b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent } else if (devices & AUDIO_DEVICE_OUT_SPEAKER_SAFE) { 18321b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_SAFE; 1833b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { 18341f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda if (my_data->speaker_lr_swap) 1835b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE; 1836b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 1837b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER; 1838b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { 18399f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 18409f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO_WB; 18419f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 18429f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO; 18439f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1844b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { 1845b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HDMI ; 1846b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { 18479d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent /*HAC support for voice-ish audio (eg visual voicemail)*/ 18489d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent if(adev->voice.hac) 18499d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HAC_HANDSET; 18509d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent else 18519d0d3f1537b5d157a2c31e0744303524b846446eEric Laurent snd_device = SND_DEVICE_OUT_HANDSET; 1852b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 1853b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown device(s) %#x", __func__, devices); 1854b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1855b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit: 1856b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]); 1857b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return snd_device; 1858b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 1859b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1860b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device) 1861b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 1862b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 1863b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 1864b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_source_t source = (adev->active_input == NULL) ? 1865b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_SOURCE_DEFAULT : adev->active_input->source; 1866b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1867b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_mode_t mode = adev->mode; 1868b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_devices_t in_device = ((adev->active_input == NULL) ? 1869b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_NONE : adev->active_input->device) 1870b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent & ~AUDIO_DEVICE_BIT_IN; 1871b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? 1872b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; 1873b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 18743ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda int channel_count = popcount(channel_mask); 1875b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 1876c92c59683257878fb8dc08d827313b4a865898daPrashant Malani ALOGV("%s: enter: out_device(%#x) in_device(%#x) channel_count (%d) channel_mask (0x%x)", 1877c92c59683257878fb8dc08d827313b4a865898daPrashant Malani __func__, out_device, in_device, channel_count, channel_mask); 1878b09e4a04c7a8ca770affbf48f154222ccd083f4bRavi Kumar Alamanda if ((out_device != AUDIO_DEVICE_NONE) && voice_is_in_call(adev)) { 18794b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (adev->voice.tty_mode != TTY_MODE_OFF) { 1880b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 188109f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET || 188209f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent out_device & AUDIO_DEVICE_OUT_LINE) { 18834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava switch (adev->voice.tty_mode) { 1884b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_FULL: 1885b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC; 1886b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1887b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_VCO: 1888b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC; 1889b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1890b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_HCO: 1891b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC; 1892b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 1893b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent default: 18944b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode); 1895b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1896b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 1897b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1898b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1899b991fb007d870cbd682273e5fc7413b9d238a6d9Eric Laurent if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { 1900b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->fluence_in_voice_call == false) { 1901b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 1902b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 19033ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (is_operator_tmus()) 19043ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_DMIC_TMUS; 1905b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 19063ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_DMIC; 1907b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1908b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 1909b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; 1910b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { 19119f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 1912e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda if (adev->bluetooth_nrec) 1913e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB_NREC; 1914e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda else 1915e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 19169f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 1917e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda if (adev->bluetooth_nrec) 1918e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_NREC; 1919e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda else 1920e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 19219f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 1922b991fb007d870cbd682273e5fc7413b9d238a6d9Eric Laurent } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER || 1923c92c59683257878fb8dc08d827313b4a865898daPrashant Malani out_device & AUDIO_DEVICE_OUT_SPEAKER_SAFE || 1924c92c59683257878fb8dc08d827313b4a865898daPrashant Malani out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 1925c92c59683257878fb8dc08d827313b4a865898daPrashant Malani out_device & AUDIO_DEVICE_OUT_LINE) { 1926c92c59683257878fb8dc08d827313b4a865898daPrashant Malani if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode) { 1927c92c59683257878fb8dc08d827313b4a865898daPrashant Malani if (my_data->source_mic_type & SOURCE_DUAL_MIC) { 1928c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC; 1929c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else { 1930c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; 1931c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 1932b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1933fe121d53e92525681e6cd922874c75be6d2efe7avivek mehta 1934fe121d53e92525681e6cd922874c75be6d2efe7avivek mehta //select default 1935fe121d53e92525681e6cd922874c75be6d2efe7avivek mehta if (snd_device == SND_DEVICE_NONE) { 19367629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti if (!adev->enable_hfp) { 19377629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; 19387629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti } else { 19397629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP; 19407629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti platform_set_echo_reference(adev, true, out_device); 19417629719778eab7ca3729f26f2e5ad5120faa9c71Uday Kishore Pasupuleti } 1942fe121d53e92525681e6cd922874c75be6d2efe7avivek mehta } 1943c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if (out_device & AUDIO_DEVICE_OUT_TELEPHONY_TX) { 194499c752d87eb818fc3cfb2e5c6790b1ea0bc88da5Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_RX; 1945c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 1946b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_CAMCORDER) { 1947b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || 1948b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent in_device & AUDIO_DEVICE_IN_BACK_MIC) { 1949b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_CAMCORDER_MIC; 1950b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1951b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) { 1952b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 1953c92c59683257878fb8dc08d827313b4a865898daPrashant Malani if (my_data->fluence_in_voice_rec && channel_count == 1) { 1954c92c59683257878fb8dc08d827313b4a865898daPrashant Malani if ((my_data->fluence_type == FLUENCE_PRO_ENABLE) && 1955c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_QUAD_MIC)) { 1956c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_HANDSET_QMIC; 1957c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if ((my_data->fluence_type == FLUENCE_PRO_ENABLE) && 1958c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_THREE_MIC)) { 1959c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_HANDSET_TMIC; 1960c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if (((my_data->fluence_type == FLUENCE_PRO_ENABLE) || 1961c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->fluence_type == FLUENCE_ENABLE)) && 1962c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_DUAL_MIC)) { 19633ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE; 1964c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 1965c92c59683257878fb8dc08d827313b4a865898daPrashant Malani platform_set_echo_reference(adev, true, out_device); 1966c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if ((channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) && 1967c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_DUAL_MIC)) { 1968c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_STEREO; 1969c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) && 1970c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_THREE_MIC)) { 1971c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_THREE_MIC; 1972c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) && 1973c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_QUAD_MIC)) { 1974c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_QUAD_MIC; 1975b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 1976b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device == SND_DEVICE_NONE) { 19773ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (adev->active_input->enable_ns) 19783ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_MIC_NS; 19793ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda else 19803ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_VOICE_REC_MIC; 1981b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 19828c83fe85b6d1257298208de043acece927787c3fJean-Michel Trivi } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 19838c83fe85b6d1257298208de043acece927787c3fJean-Michel Trivi snd_device = SND_DEVICE_IN_VOICE_REC_HEADSET_MIC; 1984b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 198590fb96106e9e2db75e214722c797d013e10e5328rago } else if (source == AUDIO_SOURCE_UNPROCESSED) { 198690fb96106e9e2db75e214722c797d013e10e5328rago if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 198790fb96106e9e2db75e214722c797d013e10e5328rago snd_device = SND_DEVICE_IN_UNPROCESSED_MIC; 198890fb96106e9e2db75e214722c797d013e10e5328rago } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 198990fb96106e9e2db75e214722c797d013e10e5328rago snd_device = SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC; 199090fb96106e9e2db75e214722c797d013e10e5328rago } 199150a38ed90672924763c4cb18773fca64588faeccEric Laurent } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION || 199290fb96106e9e2db75e214722c797d013e10e5328rago mode == AUDIO_MODE_IN_COMMUNICATION) { 19931b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent if (out_device & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) 1994b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent in_device = AUDIO_DEVICE_IN_BACK_MIC; 1995b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->active_input) { 19963ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (adev->active_input->enable_aec && 19973ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda adev->active_input->enable_ns) { 19983ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 19993ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_spkr_mode && 20003ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm && 2001c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_DUAL_MIC)) { 20023ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS; 2003c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else { 20043ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC_NS; 2005c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 20063ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 20073ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_voice_comm && 2008c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_DUAL_MIC)) { 20093ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC_NS; 2010c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else { 20113ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC_NS; 2012c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 2013cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 2014cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; 20153ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } 2016cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent platform_set_echo_reference(adev, true, out_device); 20173ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (adev->active_input->enable_aec) { 2018b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 20193ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_spkr_mode && 20203ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm && 2021c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_DUAL_MIC)) { 20223ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC; 2023c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else { 20243ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; 2025c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 2026b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 20273ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_voice_comm && 2028c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_DUAL_MIC)) { 20293ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC; 2030c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else { 20313ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC; 2032c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 2033cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 2034cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; 2035cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } 2036f28290178598c01d29f152a46483e5e8bd67b0e0Ravi Kumar Alamanda platform_set_echo_reference(adev, true, out_device); 20373ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (adev->active_input->enable_ns) { 20383ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 20393ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_spkr_mode && 20403ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda my_data->fluence_in_voice_comm && 2041c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_DUAL_MIC)) { 20423ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS; 2043c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else { 20443ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC_NS; 2045c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 20463ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 20473ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda if (my_data->fluence_in_voice_comm && 2048c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (my_data->source_mic_type & SOURCE_DUAL_MIC)) { 20493ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_NS; 2050c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else { 20513ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_MIC_NS; 2052c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 20533ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } 2054cefbbac40220d4e7690d204eecff5f6ae3f63069Eric Laurent } 2055b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 2056b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_DEFAULT) { 2057b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 2058b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 2059b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2060b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2061b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 2062b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 2063b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 2064b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2065b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device != AUDIO_DEVICE_NONE && 2066b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) && 2067b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) { 2068b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 2069c92c59683257878fb8dc08d827313b4a865898daPrashant Malani if ((my_data->source_mic_type & SOURCE_QUAD_MIC) && 2070c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) { 2071c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_QUAD_MIC; 2072c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if ((my_data->source_mic_type & SOURCE_THREE_MIC) && 2073c92c59683257878fb8dc08d827313b4a865898daPrashant Malani (int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) { 2074c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_THREE_MIC; 2075c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if ((my_data->source_mic_type & SOURCE_DUAL_MIC) && 2076c92c59683257878fb8dc08d827313b4a865898daPrashant Malani channel_count == 2) { 20773ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_HANDSET_DMIC_STEREO; 2078c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if ((my_data->source_mic_type & SOURCE_MONO_MIC) && 2079c92c59683257878fb8dc08d827313b4a865898daPrashant Malani channel_count == 1) { 2080dae4471837fcdbd9356e3745b66f23f921fb531bvivek mehta snd_device = SND_DEVICE_IN_HANDSET_MIC; 2081c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else { 2082c92c59683257878fb8dc08d827313b4a865898daPrashant Malani ALOGE("%s: something wrong (1): source type (%d) channel_count (%d) .." 2083c92c59683257878fb8dc08d827313b4a865898daPrashant Malani " channel mask (0x%x) no combination found .. setting to mono", __func__, 2084c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->source_mic_type, channel_count, channel_mask); 2085c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_HANDSET_MIC; 2086c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 2087b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 2088c92c59683257878fb8dc08d827313b4a865898daPrashant Malani if ((my_data->source_mic_type & SOURCE_DUAL_MIC) && 2089c92c59683257878fb8dc08d827313b4a865898daPrashant Malani channel_count == 2) { 20903ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_STEREO; 2091c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if ((my_data->source_mic_type & SOURCE_MONO_MIC) && 2092c92c59683257878fb8dc08d827313b4a865898daPrashant Malani channel_count == 1) { 2093c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_SPEAKER_MIC; 2094c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else { 2095c92c59683257878fb8dc08d827313b4a865898daPrashant Malani ALOGE("%s: something wrong (2): source type (%d) channel_count (%d) .." 2096c92c59683257878fb8dc08d827313b4a865898daPrashant Malani " no combination found .. setting to mono", __func__, 2097c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->source_mic_type, channel_count); 20983ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC; 2099c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 2100b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 2101b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC; 2102b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { 21039f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 2104e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda if (adev->bluetooth_nrec) 2105e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB_NREC; 2106e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda else 2107e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 21089f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 2109e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda if (adev->bluetooth_nrec) 2110e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_NREC; 2111e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda else 2112e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 21139f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 2114b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) { 2115b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HDMI_MIC; 2116b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 2117b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown input device(s) %#x", __func__, in_device); 2118b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Using default handset-mic", __func__); 2119b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 2120b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 2121b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 2122b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { 2123b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 2124b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 2125b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC; 21263ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER || 21271b0d8ce4ec97a57b38a401dbd1e16ac5cf4c4671Eric Laurent out_device & AUDIO_DEVICE_OUT_SPEAKER_SAFE || 21283ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 212909f2e0e6bf8accf1728ca89e780702d53f2c5b6dEric Laurent out_device & AUDIO_DEVICE_OUT_LINE) { 2130c92c59683257878fb8dc08d827313b4a865898daPrashant Malani if ((my_data->source_mic_type & SOURCE_DUAL_MIC) && 2131c92c59683257878fb8dc08d827313b4a865898daPrashant Malani channel_count == 2) { 21323ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_DMIC_STEREO; 2133c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else if ((my_data->source_mic_type & SOURCE_MONO_MIC) && 2134c92c59683257878fb8dc08d827313b4a865898daPrashant Malani channel_count == 1) { 2135c92c59683257878fb8dc08d827313b4a865898daPrashant Malani snd_device = SND_DEVICE_IN_SPEAKER_MIC; 2136c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } else { 2137c92c59683257878fb8dc08d827313b4a865898daPrashant Malani ALOGE("%s: something wrong (3): source type (%d) channel_count (%d) .." 2138c92c59683257878fb8dc08d827313b4a865898daPrashant Malani " no combination found .. setting to mono", __func__, 2139c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->source_mic_type, channel_count); 21403ad4e1b9949d04ad90d053458b10fa4dfbfa088eRavi Kumar Alamanda snd_device = SND_DEVICE_IN_SPEAKER_MIC; 2141c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 2142b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) { 21439f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 2144e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda if (adev->bluetooth_nrec) 2145e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB_NREC; 2146e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda else 2147e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 21489f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 2149e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda if (adev->bluetooth_nrec) 2150e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_NREC; 2151e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda else 2152e258e6871b27aa4b63b4b44fe2e318ded4d4e511Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 21539f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 2154b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) { 2155b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HDMI_MIC; 2156b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 2157b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown output device(s) %#x", __func__, out_device); 2158b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Using default handset-mic", __func__); 2159b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 2160b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 2161b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 2162b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit: 2163b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]); 2164b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return snd_device; 2165b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 2166b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2167b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_hdmi_channels(void *platform, int channel_count) 2168b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 2169b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 2170b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 2171b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 2172b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *channel_cnt_str = NULL; 2173b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "HDMI_RX Channels"; 2174b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent switch (channel_count) { 2175b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 8: 2176b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Eight"; break; 2177b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 7: 2178b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Seven"; break; 2179b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 6: 2180b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Six"; break; 2181b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 5: 2182b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Five"; break; 2183b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 4: 2184b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Four"; break; 2185b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 3: 2186b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Three"; break; 2187b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent default: 2188b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Two"; break; 2189b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 2190b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 2191b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 2192b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 2193b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 2194b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 2195b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 2196b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("HDMI channel count: %s", channel_cnt_str); 2197b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); 2198b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 2199b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 2200b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 220147cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew Georgeint platform_edid_get_max_channels(void *platform) 2202b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 220347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct platform_data *my_data = (struct platform_data *)platform; 220447cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct audio_device *adev = my_data->adev; 2205b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE]; 2206b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char *sad = block; 2207b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int num_audio_blocks; 2208b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int channel_count; 2209b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int max_channels = 0; 221047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George int i, ret, count; 2211b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 221247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George struct mixer_ctl *ctl; 221347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George 221447cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ctl = mixer_get_ctl_by_name(adev->mixer, AUDIO_DATA_BLOCK_MIXER_CTL); 221547cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (!ctl) { 221647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ALOGE("%s: Could not get ctl for mixer cmd - %s", 221747cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George __func__, AUDIO_DATA_BLOCK_MIXER_CTL); 2218b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 2219b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 2220b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 222147cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George mixer_ctl_update(ctl); 222247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George 222347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George count = mixer_ctl_get_num_values(ctl); 2224b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2225b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Read SAD blocks, clamping the maximum size for safety */ 222647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (count > (int)sizeof(block)) 222747cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George count = (int)sizeof(block); 2228b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 222947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ret = mixer_ctl_get_array(ctl, block, count); 223047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if (ret != 0) { 223147cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George ALOGE("%s: mixer_ctl_get_array() failed to get EDID info", __func__); 223247cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George return 0; 223347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George } 2234b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2235b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Calculate the number of SAD blocks */ 223647cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George num_audio_blocks = count / SAD_BLOCK_SIZE; 2237b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2238b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent for (i = 0; i < num_audio_blocks; i++) { 2239b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Only consider LPCM blocks */ 224047cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George if ((sad[0] >> 3) != EDID_FORMAT_LPCM) { 224147cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George sad += 3; 2242b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent continue; 224347cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew George } 2244b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2245b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_count = (sad[0] & 0x7) + 1; 2246b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_count > max_channels) 2247b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent max_channels = channel_count; 2248b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2249b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Advance to next block */ 2250b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent sad += 3; 2251b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 2252b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2253b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return max_channels; 2254b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 22557ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George 22564b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_set_incall_recording_session_id(void *platform, 22574b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava uint32_t session_id, int rec_mode) 22584b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 22594b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 22604b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 22614b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct audio_device *adev = my_data->adev; 22624b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct mixer_ctl *ctl; 22634b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava const char *mixer_ctl_name = "Voc VSID"; 22644b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int num_ctl_values; 22654b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int i; 22664b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 22674b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 22684b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (!ctl) { 22694b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: Could not get ctl for mixer cmd - %s", 22704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, mixer_ctl_name); 22714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = -EINVAL; 22724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } else { 22734b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava num_ctl_values = mixer_ctl_get_num_values(ctl); 22744b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava for (i = 0; i < num_ctl_values; i++) { 22754b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (mixer_ctl_set_value(ctl, i, session_id)) { 22764b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGV("Error: invalid session_id: %x", session_id); 22774b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = -EINVAL; 22784b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava break; 22794b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 22804b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 22814b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 22824b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 22834b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 22844b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_record(ALL_SESSION_VSID, rec_mode); 22854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 22864b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_start_record failed, error %d", 22874b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 22884b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 22894b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 22904b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 22914b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 22924b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 22934b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 22944b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_incall_recording_usecase(void *platform) 22954b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 22964b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 22974b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 22984b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 22994b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 23004b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_record(ALL_SESSION_VSID); 23014b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 23024b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_stop_record failed, error %d", 23034b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 23044b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 23054b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 23064b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 23074b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 23084b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 23094b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 23104b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_start_incall_music_usecase(void *platform) 23114b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 23124b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 23134b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 23144b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 23154b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 23164b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->start_playback(ALL_SESSION_VSID); 23174b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 23184b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_start_playback failed, error %d", 23194b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 23204b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 23214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 23224b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 23234b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 23244b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 23254b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 23264b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_incall_music_usecase(void *platform) 23274b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{ 23284b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava int ret = 0; 23294b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava struct platform_data *my_data = (struct platform_data *)platform; 23304b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 23314b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (my_data->csd != NULL) { 23324b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ret = my_data->csd->stop_playback(ALL_SESSION_VSID); 23334b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava if (ret < 0) { 23344b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava ALOGE("%s: csd_client_stop_playback failed, error %d", 23354b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava __func__, ret); 23364b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 23374b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava } 23384b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 23394b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava return ret; 23404b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava} 23414b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava 2342c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamandaint platform_set_parameters(void *platform, struct str_parms *parms) 2343c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda{ 2344c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)platform; 23452f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park char value[128]; 2346c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda char *kv_pairs = str_parms_to_str(parms); 2347c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda int ret = 0, err; 2348c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 2349c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda if (kv_pairs == NULL) { 2350c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda ret = -EINVAL; 2351c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda ALOGE("%s: key-value pair is NULL",__func__); 2352c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda goto done; 2353c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda } 2354c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 2355c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda ALOGV("%s: enter: %s", __func__, kv_pairs); 2356c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 2357c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda err = str_parms_get_str(parms, PLATFORM_CONFIG_KEY_SOUNDCARD_NAME, 2358c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda value, sizeof(value)); 2359c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda if (err >= 0) { 2360c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda str_parms_del(parms, PLATFORM_CONFIG_KEY_SOUNDCARD_NAME); 2361c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda my_data->snd_card_name = strdup(value); 2362c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda ALOGV("%s: sound card name %s", __func__, my_data->snd_card_name); 2363c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda } 2364c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 23652f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park err = str_parms_get_str(parms, PLATFORM_CONFIG_KEY_OPERATOR_INFO, 23662f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park value, sizeof(value)); 23672f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park if (err >= 0) { 23682f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park struct operator_info *info; 23692f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park char *str = value; 23702f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park char *name; 23712f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 23722f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park str_parms_del(parms, PLATFORM_CONFIG_KEY_OPERATOR_INFO); 23732f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park info = (struct operator_info *)calloc(1, sizeof(struct operator_info)); 23742f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park name = strtok(str, ";"); 23752f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park info->name = strdup(name); 23762f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park info->mccmnc = strdup(str + strlen(name) + 1); 23772f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park 23782f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park list_add_tail(&operator_info_list, &info->list); 23792f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park ALOGD("%s: add operator[%s] mccmnc[%s]", __func__, info->name, info->mccmnc); 23802f7306a9dae56a1204e8ec090198ce76b167bfa9keunhui.park } 2381c92c59683257878fb8dc08d827313b4a865898daPrashant Malani 2382c92c59683257878fb8dc08d827313b4a865898daPrashant Malani memset(value, 0, sizeof(value)); 2383c633338c83da3760c4965d29af2afd80d3cce840Eric Laurent err = str_parms_get_str(parms, PLATFORM_CONFIG_KEY_MAX_MIC_COUNT, 2384c92c59683257878fb8dc08d827313b4a865898daPrashant Malani value, sizeof(value)); 2385c92c59683257878fb8dc08d827313b4a865898daPrashant Malani if (err >= 0) { 2386c633338c83da3760c4965d29af2afd80d3cce840Eric Laurent str_parms_del(parms, PLATFORM_CONFIG_KEY_MAX_MIC_COUNT); 2387c92c59683257878fb8dc08d827313b4a865898daPrashant Malani my_data->max_mic_count = atoi(value); 2388c92c59683257878fb8dc08d827313b4a865898daPrashant Malani ALOGV("%s: max_mic_count %s/%d", __func__, value, my_data->max_mic_count); 2389c92c59683257878fb8dc08d827313b4a865898daPrashant Malani } 2390c92c59683257878fb8dc08d827313b4a865898daPrashant Malani 2391c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamandadone: 2392c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda ALOGV("%s: exit with code(%d)", __func__, ret); 2393c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda if (kv_pairs != NULL) 2394c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda free(kv_pairs); 2395c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 2396c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda return ret; 2397c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda} 2398c4f57314a49fb83ed602395d9fe0c0164c9e863dRavi Kumar Alamanda 23997ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George/* Delay in Us */ 24007ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew Georgeint64_t platform_render_latency(audio_usecase_t usecase) 24017ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George{ 24027ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George switch (usecase) { 24037ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: 24047ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return DEEP_BUFFER_PLATFORM_DELAY; 24057ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: 24067ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return LOW_LATENCY_PLATFORM_DELAY; 24077ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George default: 24087ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return 0; 24097ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George } 24107ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George} 241198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 2412b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamandaint platform_set_snd_device_backend(snd_device_t device, const char *backend_tag, 2413b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda const char * hw_interface) 241498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 241598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int ret = 0; 241698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 241798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) { 241898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: Invalid snd_device = %d", 241998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George __func__, device); 242098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -EINVAL; 242198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George goto done; 242298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 242398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 2424b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda ALOGV("%s: backend_tag_table[%s]: old = %s new = %s", __func__, 2425b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda platform_get_snd_device_name(device), 2426b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[device] != NULL ? backend_tag_table[device]: "null", backend_tag); 2427b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda if (backend_tag_table[device]) { 2428b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda free(backend_tag_table[device]); 2429b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda } 2430b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda backend_tag_table[device] = strdup(backend_tag); 2431b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda 2432b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda if (hw_interface != NULL) { 2433b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda if (hw_interface_table[device]) 2434b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda free(hw_interface_table[device]); 2435b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda ALOGV("%s: hw_interface_table[%d] = %s", __func__, device, hw_interface); 2436b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda hw_interface_table[device] = strdup(hw_interface); 243798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 243898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgedone: 243998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return ret; 244098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 244198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 244298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgeint platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id) 244398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George{ 244498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George int ret = 0; 244598c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((usecase <= USECASE_INVALID) || (usecase >= AUDIO_USECASE_MAX)) { 244698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: invalid usecase case idx %d", __func__, usecase); 244798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -EINVAL; 244898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George goto done; 244998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 245098c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George 245198c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George if ((type != 0) && (type != 1)) { 245298c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ALOGE("%s: invalid usecase type", __func__); 245398c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George ret = -EINVAL; 245498c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George } 2455b7ea4f581dab56101215e97692c265931addad80Ravi Kumar Alamanda ALOGV("%s: pcm_device_table[%d][%d] = %d", __func__, usecase, type, pcm_id); 245698c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George pcm_device_table[usecase][type] = pcm_id; 245798c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew Georgedone: 245898c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George return ret; 245998c95622da1e906d32dde6b6651ed5b270b9b5f1Haynes Mathew George} 24601f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda 246188cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi#define DEFAULT_NOMINAL_SPEAKER_GAIN 20 246288cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Triviint ramp_speaker_gain(struct audio_device *adev, bool ramp_up, int target_ramp_up_gain) { 246388cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi // backup_gain: gain to try to set in case of an error during ramp 246488cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi int start_gain, end_gain, step, backup_gain, i; 246588cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi bool error = false; 246688cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi const struct mixer_ctl *ctl; 246788cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi const char *mixer_ctl_name_gain_left = "Left Speaker Gain"; 246888cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi const char *mixer_ctl_name_gain_right = "Right Speaker Gain"; 246988cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi struct mixer_ctl *ctl_left = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name_gain_left); 247088cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi struct mixer_ctl *ctl_right = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name_gain_right); 247188cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi if (!ctl_left || !ctl_right) { 247288cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi ALOGE("%s: Could not get ctl for mixer cmd - %s or %s, not applying speaker gain ramp", 247388cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi __func__, mixer_ctl_name_gain_left, mixer_ctl_name_gain_right); 247488cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi return -EINVAL; 247588cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } else if ((mixer_ctl_get_num_values(ctl_left) != 1) 247688cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi || (mixer_ctl_get_num_values(ctl_right) != 1)) { 247788cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi ALOGE("%s: Unexpected num values for mixer cmd - %s or %s, not applying speaker gain ramp", 247888cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi __func__, mixer_ctl_name_gain_left, mixer_ctl_name_gain_right); 247988cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi return -EINVAL; 248088cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } 248188cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi if (ramp_up) { 248288cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi start_gain = 0; 248388cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi end_gain = target_ramp_up_gain > 0 ? target_ramp_up_gain : DEFAULT_NOMINAL_SPEAKER_GAIN; 248488cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi step = +1; 248588cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi backup_gain = end_gain; 248688cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } else { 248788cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi // using same gain on left and right 248888cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi const int left_gain = mixer_ctl_get_value(ctl_left, 0); 248988cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi start_gain = left_gain > 0 ? left_gain : DEFAULT_NOMINAL_SPEAKER_GAIN; 249088cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi end_gain = 0; 249188cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi step = -1; 249288cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi backup_gain = start_gain; 249388cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } 249488cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi for (i = start_gain ; i != (end_gain + step) ; i += step) { 249588cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi //ALOGV("setting speaker gain to %d", i); 249688cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi if (mixer_ctl_set_value(ctl_left, 0, i)) { 249788cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi ALOGE("%s: error setting %s to %d during gain ramp", 249888cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi __func__, mixer_ctl_name_gain_left, i); 249988cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi error = true; 250088cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi break; 250188cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } 250288cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi if (mixer_ctl_set_value(ctl_right, 0, i)) { 250388cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi ALOGE("%s: error setting %s to %d during gain ramp", 250488cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi __func__, mixer_ctl_name_gain_right, i); 250588cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi error = true; 250688cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi break; 250788cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } 250888cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi usleep(1000); 250988cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } 251088cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi if (error) { 251188cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi // an error occured during the ramp, let's still try to go back to a safe volume 251288cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi if (mixer_ctl_set_value(ctl_left, 0, backup_gain)) { 251388cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi ALOGE("%s: error restoring left gain to %d", __func__, backup_gain); 251488cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } 251588cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi if (mixer_ctl_set_value(ctl_right, 0, backup_gain)) { 251688cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi ALOGE("%s: error restoring right gain to %d", __func__, backup_gain); 251788cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } 251888cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } 251988cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi return start_gain; 252088cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi} 252188cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi 25221f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamandaint platform_swap_lr_channels(struct audio_device *adev, bool swap_channels) 25231f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda{ 25241f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda // only update if there is active pcm playback on speaker 25251f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda struct audio_usecase *usecase; 25261f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda struct listnode *node; 25271f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda struct platform_data *my_data = (struct platform_data *)adev->platform; 25281f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda 25291f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda if (my_data->speaker_lr_swap != swap_channels) { 25301f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda my_data->speaker_lr_swap = swap_channels; 25311f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda 25321f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda list_for_each(node, &adev->usecase_list) { 25331f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda usecase = node_to_item(node, struct audio_usecase, list); 25341f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda if (usecase->type == PCM_PLAYBACK && 2535425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER) { 2536425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda /* 2537425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda * If acdb tuning is different for SPEAKER_REVERSE, it is must 2538425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda * to perform device switch to disable the current backend to 2539425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda * enable it with new acdb data. 2540425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda */ 2541425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda if (acdb_device_table[SND_DEVICE_OUT_SPEAKER] != 2542425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda acdb_device_table[SND_DEVICE_OUT_SPEAKER_REVERSE]) { 254388cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi const int initial_skpr_gain = ramp_speaker_gain(adev, false /*ramp_up*/, -1); 2544425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda select_devices(adev, usecase->id); 254588cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi if (initial_skpr_gain != -EINVAL) { 254688cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi ramp_speaker_gain(adev, true /*ramp_up*/, initial_skpr_gain); 254788cbad341d2dd920ac74c2296f319482bd53a33dJean-Michel Trivi } 25481f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda } else { 2549425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda const char *mixer_path; 2550425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda if (swap_channels) { 2551425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER_REVERSE); 2552425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda audio_route_apply_and_update_path(adev->audio_route, mixer_path); 2553425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda } else { 2554425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER); 2555425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda audio_route_apply_and_update_path(adev->audio_route, mixer_path); 2556425e154c046554deb7ba766e89b943e8870ee251Ravi Kumar Alamanda } 25571f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda } 25581f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda break; 25591f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda } 25601f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda } 25611f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda } 25621f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda return 0; 25631f60cf8ce4276473878a22956ae546911353ebd2Ravi Kumar Alamanda} 2564