platform.c revision 299760a41231bd0f6d9991fb189977347365c72b
1b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* 2a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent * Copyright (C) 2013 The Android Open Source Project 3b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Licensed under the Apache License, Version 2.0 (the "License"); 5b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * you may not use this file except in compliance with the License. 6b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * You may obtain a copy of the License at 7b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 8b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * http://www.apache.org/licenses/LICENSE-2.0 9b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 10b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Unless required by applicable law or agreed to in writing, software 11b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * distributed under the License is distributed on an "AS IS" BASIS, 12b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * See the License for the specific language governing permissions and 14b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * limitations under the License. 15b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */ 16b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 17b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LOG_TAG "msm8960_platform" 18b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/*#define LOG_NDEBUG 0*/ 19b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LOG_NDDEBUG 0 20b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 21b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <stdlib.h> 22b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <dlfcn.h> 23b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <cutils/log.h> 24b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <cutils/properties.h> 25b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <audio_hw.h> 26b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <platform_api.h> 27b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include "platform.h" 28b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 29b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LIB_ACDB_LOADER "libacdbloader.so" 30b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LIB_CSD_CLIENT "libcsd-client.so" 31b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 32b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_NONE 0 /* Target does not contain 2 mics */ 33b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_ENDFIRE 1 34b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_BROADSIDE 2 35b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 36b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* 37b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * This is the sysfs path for the HDMI audio data block 38b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */ 39b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define AUDIO_DATA_BLOCK_PATH "/sys/class/graphics/fb1/audio_data_block" 401b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo#define MIXER_XML_PATH "/system/etc/mixer_paths.xml" 41b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 42b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* 43b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * This file will have a maximum of 38 bytes: 44b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 45b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: number of audio blocks 46b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: total length of Short Audio Descriptor (SAD) blocks 47b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Maximum 10 * 3 bytes: SAD blocks 48b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */ 49b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define MAX_SAD_BLOCKS 10 50b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define SAD_BLOCK_SIZE 3 51b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 52b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* EDID format ID for LPCM audio */ 53b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define EDID_FORMAT_LPCM 1 54b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 55b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct audio_block_header 56b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 57b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int reserved; 58b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int length; 59b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 60b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 61b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 62b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_deallocate_t)(); 63b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*acdb_init_t)(); 64b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_audio_cal_t)(int, int); 65b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_voice_cal_t)(int, int); 66b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 67b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_client_init_t)(); 68b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_client_deinit_t)(); 69b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_disable_device_t)(); 70b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_enable_device_t)(int, int, uint32_t); 71b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_volume_t)(int); 72b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_mic_mute_t)(int); 73b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_start_voice_t)(); 74b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_stop_voice_t)(); 75b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 76b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 77b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Audio calibration related functions */ 78b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct platform_data { 79b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev; 80b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_spkr_mode; 81b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_voice_call; 82b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent bool fluence_in_voice_rec; 83b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int dualmic_config; 84b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 85b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent void *acdb_handle; 86b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_init_t acdb_init; 87b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_deallocate_t acdb_deallocate; 88b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_send_audio_cal_t acdb_send_audio_cal; 89b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_send_voice_cal_t acdb_send_voice_cal; 90b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 91b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* CSD Client related functions for voice call */ 92b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent void *csd_client; 93b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent csd_client_init_t csd_client_init; 94b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent csd_client_deinit_t csd_client_deinit; 95b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent csd_disable_device_t csd_disable_device; 96b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent csd_enable_device_t csd_enable_device; 97b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent csd_volume_t csd_volume; 98b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent csd_mic_mute_t csd_mic_mute; 99b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent csd_start_voice_t csd_start_voice; 100b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent csd_stop_voice_t csd_stop_voice; 101b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 102b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 103b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const int pcm_device_table[AUDIO_USECASE_MAX][2] = { 104b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {0, 0}, 105b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {14, 14}, 106b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {1, 1}, 107b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [USECASE_AUDIO_RECORD] = {0, 0}, 108b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [USECASE_AUDIO_RECORD_LOW_LATENCY] = {14, 14}, 109b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [USECASE_VOICE_CALL] = {12, 12}, 110b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 111b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 112b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Array to store sound devices */ 113b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const char * const device_table[SND_DEVICE_MAX] = { 114b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_NONE] = "none", 115b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Playback sound devices */ 116b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HANDSET] = "handset", 117b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER] = "speaker", 118b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse", 119b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HEADPHONES] = "headphones", 120b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", 121b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker", 122b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones", 123b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HDMI] = "hdmi", 124b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi", 125b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset", 1269f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb", 127b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus", 128b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones", 129b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones", 130b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset", 131b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 132b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Capture sound devices */ 133b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic", 134b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic", 135b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic", 136b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic", 137b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "voice-speaker-mic", 138b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic", 139b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", 140b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", 141b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", 142b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic", 1439f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb", 144b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic", 145b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_EF] = "voice-dmic-ef", 146b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_BS] = "voice-dmic-bs", 147b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_EF_TMUS] = "voice-dmic-ef-tmus", 148b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF] = "voice-speaker-dmic-ef", 149b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS] = "voice-speaker-dmic-bs", 150b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic", 151b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic", 152b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic", 153b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic", 154b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_EF] = "voice-rec-dmic-ef", 155b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_BS] = "voice-rec-dmic-bs", 156b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE] = "voice-rec-dmic-ef-fluence", 157b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE] = "voice-rec-dmic-bs-fluence", 158b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 159b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 160b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* ACDB IDs (audio DSP path configuration IDs) for each sound device */ 161b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const int acdb_device_table[SND_DEVICE_MAX] = { 162b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_NONE] = -1, 163b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HANDSET] = 7, 164b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER] = 14, 165b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_REVERSE] = 14, 166b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HEADPHONES] = 10, 167b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10, 168b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_SPEAKER] = 14, 169b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10, 170b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_HDMI] = 18, 171b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 14, 172b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_BT_SCO] = 22, 1739f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_OUT_BT_SCO_WB] = 39, 174b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = 81, 175b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17, 176b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17, 177b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37, 178b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 179b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC] = 4, 180b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_SPEAKER_MIC] = 4, 181b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC] = 8, 182b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HANDSET_MIC_AEC] = 40, 183b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 42, 184b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HEADSET_MIC_AEC] = 47, 185b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11, 186b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8, 187b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_HDMI_MIC] = 4, 188b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_BT_SCO_MIC] = 21, 1899f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38, 190b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_CAMCORDER_MIC] = 61, 191b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_EF] = 6, 192b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_BS] = 5, 193b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_DMIC_EF_TMUS] = 91, 194b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF] = 13, 195b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS] = 12, 196b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16, 197b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36, 198b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16, 199b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_MIC] = 62, 200b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* TODO: Update with proper acdb ids */ 201b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_EF] = 62, 202b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_BS] = 62, 203b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE] = 6, 204b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent [SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE] = 5, 205b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}; 206b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2077ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) 2087ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) 2097ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George 210b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT; 211b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic bool is_tmus = false; 212b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 213b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic void check_operator() 214b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 215b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char value[PROPERTY_VALUE_MAX]; 216b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int mccmnc; 217b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("gsm.sim.operator.numeric",value,"0"); 218b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mccmnc = atoi(value); 219b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGD("%s: tmus mccmnc %d", __func__, mccmnc); 220b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent switch(mccmnc) { 221b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* TMUS MCC(310), MNC(490, 260, 026) */ 222b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310490: 223b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310260: 224b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 310026: 225b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent is_tmus = true; 226b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 227b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 228b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 229b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 230b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentbool is_operator_tmus() 231b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 232b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent pthread_once(&check_op_once_ctl, check_operator); 233b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return is_tmus; 234b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 235b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 236b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic int set_echo_reference(struct mixer *mixer, const char* ec_ref) 237b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 238b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 239b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "EC_REF_RX"; 240b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 241b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name); 242b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 243b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 244b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 245b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 246b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 247b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("Setting EC Reference: %s", ec_ref); 248b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mixer_ctl_set_enum_by_string(ctl, ec_ref); 249b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 250b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 251b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 252b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid *platform_init(struct audio_device *adev) 253b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 254b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char platform[PROPERTY_VALUE_MAX]; 255b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char baseband[PROPERTY_VALUE_MAX]; 256b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char value[PROPERTY_VALUE_MAX]; 257b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data; 258b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 2591b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo adev->mixer = mixer_open(MIXER_CARD); 2601b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 2611b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo if (!adev->mixer) { 2621b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo ALOGE("Unable to open the mixer, aborting."); 2631b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo return NULL; 2641b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo } 2651b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 2661b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo adev->audio_route = audio_route_init(MIXER_CARD, MIXER_XML_PATH); 2671b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo if (!adev->audio_route) { 2681b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo ALOGE("%s: Failed to init audio route controls, aborting.", __func__); 2691b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo return NULL; 2701b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo } 2711b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo 272b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data = calloc(1, sizeof(struct platform_data)); 273b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 274b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->adev = adev; 275b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config = DUALMIC_CONFIG_NONE; 276b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_spkr_mode = false; 277b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_call = false; 278b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_rec = false; 279b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 280b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.dualmic.config",value,""); 281b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("broadside", value)) { 282b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config = DUALMIC_CONFIG_BROADSIDE; 283b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent adev->acdb_settings |= DMIC_FLAG; 284b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (!strcmp("endfire", value)) { 285b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config = DUALMIC_CONFIG_ENDFIRE; 286b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent adev->acdb_settings |= DMIC_FLAG; 287b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 288b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 289b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->dualmic_config != DUALMIC_CONFIG_NONE) { 290b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.voicecall",value,""); 291b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 292b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_call = true; 293b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 294b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 295b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.voicerec",value,""); 296b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 297b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_voice_rec = true; 298b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 299b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 300b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("persist.audio.fluence.speaker",value,""); 301b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("true", value)) { 302b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->fluence_in_spkr_mode = true; 303b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 304b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 305b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 306b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); 307b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_handle == NULL) { 308b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER); 309b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 310b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER); 311b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle, 312b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_deallocate_ACDB"); 313b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle, 314b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_send_audio_cal"); 315b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!my_data->acdb_send_audio_cal) 316b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Could not find the symbol acdb_send_audio_cal from %s", 317b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, LIB_ACDB_LOADER); 318b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle, 319b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_send_voice_cal"); 320b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, 321b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "acdb_loader_init_ACDB"); 322b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_init == NULL) 323b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror()); 324b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 325b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_init(); 326b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 327b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 328b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* If platform is Fusion3, load CSD Client specific symbols 329b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Voice call is handled by MDM and apps processor talks to 330b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * MDM through CSD Client 331b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */ 332b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("ro.board.platform", platform, ""); 333b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent property_get("ro.baseband", baseband, ""); 334b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!strcmp("msm8960", platform) && !strcmp("mdm", baseband)) { 335b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW); 336b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_client == NULL) 337b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT); 338b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 339b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 340b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_client) { 341b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT); 342b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->csd_client_deinit = (csd_client_deinit_t)dlsym(my_data->csd_client, 343b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "csd_client_deinit"); 344b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->csd_disable_device = (csd_disable_device_t)dlsym(my_data->csd_client, 345b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "csd_client_disable_device"); 346b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->csd_enable_device = (csd_enable_device_t)dlsym(my_data->csd_client, 347b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "csd_client_enable_device"); 348b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->csd_start_voice = (csd_start_voice_t)dlsym(my_data->csd_client, 349b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "csd_client_start_voice"); 350b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->csd_stop_voice = (csd_stop_voice_t)dlsym(my_data->csd_client, 351b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "csd_client_stop_voice"); 352b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->csd_volume = (csd_volume_t)dlsym(my_data->csd_client, 353b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "csd_client_volume"); 354b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->csd_mic_mute = (csd_mic_mute_t)dlsym(my_data->csd_client, 355b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "csd_client_mic_mute"); 356b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->csd_client_init = (csd_client_init_t)dlsym(my_data->csd_client, 357b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent "csd_client_init"); 358b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 359b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_client_init == NULL) { 360b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error %s for csd_client_init", __func__, dlerror()); 361b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 362b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->csd_client_init(); 363b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 364b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 365b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 366b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return my_data; 367b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 368b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 369b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid platform_deinit(void *platform) 370b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 371b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent free(platform); 372b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 373b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 374b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentconst char *platform_get_snd_device_name(snd_device_t snd_device) 375b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 376b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) 377b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return device_table[snd_device]; 378b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 379b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return ""; 380b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 381b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 382299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamandavoid platform_add_backend_name(void *platform __unused, char *mixer_path, 383299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda snd_device_t snd_device) 384b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 385b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device == SND_DEVICE_IN_BT_SCO_MIC) 386b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent strcat(mixer_path, " bt-sco"); 387b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if(snd_device == SND_DEVICE_OUT_BT_SCO) 388b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent strcat(mixer_path, " bt-sco"); 389b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if (snd_device == SND_DEVICE_OUT_HDMI) 390b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent strcat(mixer_path, " hdmi"); 391b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI) 392b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent strcat(mixer_path, " speaker-and-hdmi"); 3939f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda else if (snd_device == SND_DEVICE_OUT_BT_SCO_WB || 3949f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB) 3959f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda strcat(mixer_path, " bt-sco-wb"); 396b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 397b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 398b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) 399b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 400b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int device_id; 401b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (device_type == PCM_PLAYBACK) 402b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent device_id = pcm_device_table[usecase][0]; 403b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 404b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent device_id = pcm_device_table[usecase][1]; 405b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return device_id; 406b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 407b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 408b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_send_audio_calibration(void *platform, snd_device_t snd_device) 409b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 410b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 411b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int acdb_dev_id, acdb_dev_type; 412b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 413b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_id = acdb_device_table[snd_device]; 414b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (acdb_dev_id < 0) { 415b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not find acdb id for device(%d)", 416b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, snd_device); 417b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 418b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 419b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->acdb_send_audio_cal) { 420994a693158202488516c48c22534ae2035b5c8faEric Laurent ("%s: sending audio calibration for snd_device(%d) acdb_id(%d)", 421b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, snd_device, acdb_dev_id); 422b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device >= SND_DEVICE_OUT_BEGIN && 423b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device < SND_DEVICE_OUT_END) 424b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_type = ACDB_DEV_TYPE_OUT; 425b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 426b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_dev_type = ACDB_DEV_TYPE_IN; 427b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type); 428b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 429b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 430b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 431b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 432b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_pre(void *platform) 433b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 434b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 435b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int ret = 0; 436b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 437b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_client != NULL) { 438b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* This must be called before disabling the mixer controls on APQ side */ 439b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_disable_device == NULL) { 440b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error for csd_disable_device", __func__); 441b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 442b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ret = my_data->csd_disable_device(); 443b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (ret < 0) { 444b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: csd_client_disable_device, failed, error %d", 445b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, ret); 446b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 447b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 448b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 449b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return ret; 450b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 451b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 452b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_post(void *platform, 453b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t out_snd_device, 454b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t in_snd_device) 455b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 456b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 457b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int acdb_rx_id, acdb_tx_id; 458b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int ret = 0; 459b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 460b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_client) { 461b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_enable_device == NULL) { 462b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error for csd_enable_device", 463b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__); 464b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 465b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_rx_id = acdb_device_table[out_snd_device]; 466b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_tx_id = acdb_device_table[in_snd_device]; 467b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 468b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (acdb_rx_id > 0 || acdb_tx_id > 0) { 469b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ret = my_data->csd_enable_device(acdb_rx_id, acdb_tx_id, 470b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->adev->acdb_settings); 471b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (ret < 0) { 472b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: csd_enable_device, failed, error %d", 473b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, ret); 474b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 475b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 476b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, 477b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent acdb_rx_id, acdb_tx_id); 478b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 479b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 480b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 481b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 482b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return ret; 483b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 484b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 485a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurentint platform_start_voice_call(void *platform) 486b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 487b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 488b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int ret = 0; 489b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 490b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_client) { 491b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_start_voice == NULL) { 492b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("dlsym error for csd_client_start_voice"); 493b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ret = -ENOSYS; 494b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 495b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ret = my_data->csd_start_voice(); 496b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (ret < 0) { 497b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: csd_start_voice error %d\n", __func__, ret); 498b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 499b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 500b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 501b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 502b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return ret; 503b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 504b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 505a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurentint platform_stop_voice_call(void *platform) 506b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 507b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 508b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int ret = 0; 509b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 510b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_client) { 511b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_stop_voice == NULL) { 512b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("dlsym error for csd_stop_voice"); 513b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 514b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ret = my_data->csd_stop_voice(); 515b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (ret < 0) { 516b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: csd_stop_voice error %d\n", __func__, ret); 517b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 518b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 519b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 520b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 521b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return ret; 522b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 523b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 524b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_voice_volume(void *platform, int volume) 525b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 526b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 527b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int ret = 0; 528b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 529b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_client) { 530b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_volume == NULL) { 531b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error for csd_volume", __func__); 532b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 533b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ret = my_data->csd_volume(volume); 534b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (ret < 0) { 535b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: csd_volume error %d", __func__, ret); 536b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 537b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 538b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 539b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: No CSD Client present", __func__); 540b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 541b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 542b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return ret; 543b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 544b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 545b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_mic_mute(void *platform, bool state) 546b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 547b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 548b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int ret = 0; 549b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 550b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->adev->mode == AUDIO_MODE_IN_CALL) { 551b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_client) { 552b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->csd_mic_mute == NULL) { 553b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: dlsym error for csd_mic_mute", __func__); 554b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 555b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ret = my_data->csd_mic_mute(state); 556b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (ret < 0) { 557b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: csd_mic_mute error %d", __func__, ret); 558b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 559b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 560b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 561b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: No CSD Client present", __func__); 562b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 563b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 564b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 565b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return ret; 566b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 567b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 568b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices) 569b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 570b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 571b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 572b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_mode_t mode = adev->mode; 573b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 574b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 575b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: enter: output devices(%#x)", __func__, devices); 576b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices == AUDIO_DEVICE_NONE || 577b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_BIT_IN) { 578b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: Invalid output devices (%#x)", __func__, devices); 579b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 580b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 581b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 582b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (mode == AUDIO_MODE_IN_CALL) { 583b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 584b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 585b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->tty_mode == TTY_MODE_FULL) 586b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES; 587b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if (adev->tty_mode == TTY_MODE_VCO) 588b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES; 589b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if (adev->tty_mode == TTY_MODE_HCO) 590b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET; 591b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 592b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; 593b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { 5949f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 5959f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO_WB; 5969f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 5979f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO; 5989f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 599b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { 600b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; 601b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { 602b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (is_operator_tmus()) 603b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS; 604b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 605b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HANDSET; 606b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 607b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 608b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 609b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 610b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 611b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 612b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (popcount(devices) == 2) { 613b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | 614b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 615b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; 616b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | 617b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 618b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; 619b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL | 620b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_OUT_SPEAKER)) { 621b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI; 622b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 623b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Invalid combo device(%#x)", __func__, devices); 624b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 625b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 626b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 627b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 628b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 629b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 630b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 631b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (popcount(devices) != 1) { 632b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Invalid output devices(%#x)", __func__, devices); 633b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 634b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 635b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 636b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 637b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 638b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HEADPHONES; 639b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { 640b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->speaker_lr_swap) 641b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE; 642b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 643b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_SPEAKER; 644b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { 6459f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 6469f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO_WB; 6479f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 6489f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_OUT_BT_SCO; 6499f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 650b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { 651b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HDMI ; 652b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { 653b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_OUT_HANDSET; 654b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 655b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown device(s) %#x", __func__, devices); 656b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 657b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit: 658b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]); 659b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return snd_device; 660b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 661b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 662b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device) 663b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 664b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 665b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 666b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_source_t source = (adev->active_input == NULL) ? 667b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_SOURCE_DEFAULT : adev->active_input->source; 668b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 669b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_mode_t mode = adev->mode; 670b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_devices_t in_device = ((adev->active_input == NULL) ? 671b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_DEVICE_NONE : adev->active_input->device) 672b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent & ~AUDIO_DEVICE_BIT_IN; 673b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? 674b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; 675b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device_t snd_device = SND_DEVICE_NONE; 676b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 677b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: enter: out_device(%#x) in_device(%#x)", 678b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, out_device, in_device); 679b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (mode == AUDIO_MODE_IN_CALL) { 680b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device == AUDIO_DEVICE_NONE) { 681b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: No output device set for voice call", __func__); 682b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 683b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 684a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent if (adev->tty_mode != TTY_MODE_OFF) { 685b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || 686b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 687a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent switch (adev->tty_mode) { 688b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_FULL: 689b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC; 690b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 691b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_VCO: 692b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC; 693b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 694b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case TTY_MODE_HCO: 695b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC; 696b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent break; 697b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent default: 698a609e8ebdfeca875b6d35ccfb3fb8b87710f3499Eric Laurent ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->tty_mode); 699b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 700b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 701b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 702b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 703b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_EARPIECE || 704b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { 705b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->fluence_in_voice_call == false) { 706b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 707b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 708b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) { 709b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (is_operator_tmus()) 710b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_DMIC_EF_TMUS; 711b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 712b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_DMIC_EF; 713b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if(my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) 714b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_DMIC_BS; 715b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else 716b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 717b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 718b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 719b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; 720b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { 7219f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 7229f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 7239f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 7249f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 7259f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 726b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { 727b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode && 728b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) { 729b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF; 730b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode && 731b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) { 732b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS; 733b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 734b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; 735b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 736b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 737b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_CAMCORDER) { 738b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || 739b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent in_device & AUDIO_DEVICE_IN_BACK_MIC) { 740b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_CAMCORDER_MIC; 741b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 742b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) { 743b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 744b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) { 745b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) 746b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_EF; 747b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if (my_data->fluence_in_voice_rec) 748b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE; 749b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) { 750b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) 751b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_BS; 752b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent else if (my_data->fluence_in_voice_rec) 753b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE; 754b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 755b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 756b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device == SND_DEVICE_NONE) { 757b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_VOICE_REC_MIC; 758b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 759b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 760b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) { 761b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_SPEAKER) 762b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent in_device = AUDIO_DEVICE_IN_BACK_MIC; 763b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->active_input) { 764b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (adev->active_input->enable_aec) { 765b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 766b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; 767b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 768b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC; 769b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 770b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; 771b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 772b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent set_echo_reference(adev->mixer, "SLIM_RX"); 773b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else 774b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent set_echo_reference(adev->mixer, "NONE"); 775b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 776b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (source == AUDIO_SOURCE_DEFAULT) { 777b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 778b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 779b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 780b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 781b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (snd_device != SND_DEVICE_NONE) { 782b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent goto exit; 783b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 784b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 785b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device != AUDIO_DEVICE_NONE && 786b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) && 787b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) { 788b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { 789b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 790b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { 791b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_SPEAKER_MIC; 792b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { 793b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC; 794b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { 7959f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 7969f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 7979f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 7989f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 7999f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 800b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) { 801b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HDMI_MIC; 802b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 803b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown input device(s) %#x", __func__, in_device); 804b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Using default handset-mic", __func__); 805b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 806b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 807b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 808b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { 809b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 810b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { 811b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HEADSET_MIC; 812b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { 813b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_SPEAKER_MIC; 814b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { 815b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 816b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) { 8179f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda if (adev->bt_wb_speech_enabled) { 8189f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; 8199f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } else { 8209f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda snd_device = SND_DEVICE_IN_BT_SCO_MIC; 8219f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda } 822b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) { 823b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HDMI_MIC; 824b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } else { 825b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Unknown output device(s) %#x", __func__, out_device); 826b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGW("%s: Using default handset-mic", __func__); 827b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent snd_device = SND_DEVICE_IN_HANDSET_MIC; 828b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 829b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 830b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit: 831b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]); 832b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return snd_device; 833b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 834b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 835b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_hdmi_channels(void *platform, int channel_count) 836b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 837b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct platform_data *my_data = (struct platform_data *)platform; 838b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_device *adev = my_data->adev; 839b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct mixer_ctl *ctl; 840b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *channel_cnt_str = NULL; 841b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent const char *mixer_ctl_name = "HDMI_RX Channels"; 842b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent switch (channel_count) { 843b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 8: 844b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Eight"; break; 845b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 7: 846b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Seven"; break; 847b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 6: 848b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Six"; break; 849b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 5: 850b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Five"; break; 851b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 4: 852b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Four"; break; 853b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent case 3: 854b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Three"; break; 855b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent default: 856b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_cnt_str = "Two"; break; 857b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 858b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); 859b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (!ctl) { 860b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("%s: Could not get ctl for mixer cmd - %s", 861b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent __func__, mixer_ctl_name); 862b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return -EINVAL; 863b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 864b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGV("HDMI channel count: %s", channel_cnt_str); 865b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); 866b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 867b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 868b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 86947cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew Georgeint platform_edid_get_max_channels(void *platform) 870b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{ 871b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent FILE *file; 872b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent struct audio_block_header header; 873b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE]; 874b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent char *sad = block; 875b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int num_audio_blocks; 876b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int channel_count; 877b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int max_channels = 0; 878b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent int i; 879b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 880b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent file = fopen(AUDIO_DATA_BLOCK_PATH, "rb"); 881b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (file == NULL) { 882b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent ALOGE("Unable to open '%s'", AUDIO_DATA_BLOCK_PATH); 883b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return 0; 884b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 885b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 886b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Read audio block header */ 887b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent fread(&header, 1, sizeof(header), file); 888b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 889b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Read SAD blocks, clamping the maximum size for safety */ 890b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (header.length > (int)sizeof(block)) 891b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent header.length = (int)sizeof(block); 892b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent fread(&block, header.length, 1, file); 893b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 894b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent fclose(file); 895b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 896b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Calculate the number of SAD blocks */ 897b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent num_audio_blocks = header.length / SAD_BLOCK_SIZE; 898b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 899b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent for (i = 0; i < num_audio_blocks; i++) { 900b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Only consider LPCM blocks */ 901b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if ((sad[0] >> 3) != EDID_FORMAT_LPCM) 902b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent continue; 903b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 904b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent channel_count = (sad[0] & 0x7) + 1; 905b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent if (channel_count > max_channels) 906b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent max_channels = channel_count; 907b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 908b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent /* Advance to next block */ 909b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent sad += 3; 910b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent } 911b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent 912b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent return max_channels; 913b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent} 9147ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George 9157ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George/* Delay in Us */ 9167ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew Georgeint64_t platform_render_latency(audio_usecase_t usecase) 9177ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George{ 9187ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George switch (usecase) { 9197ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: 9207ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return DEEP_BUFFER_PLATFORM_DELAY; 9217ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: 9227ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return LOW_LATENCY_PLATFORM_DELAY; 9237ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George default: 9247ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George return 0; 9257ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George } 9267ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George} 92783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 92883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_enable_device_config(void *platform, 92983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t out_snd_device, 93083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t in_snd_device) 93183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 93283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return 0; 93383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 93483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda 93583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_usecase_route_post(void *platform, 93683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t out_snd_device, 93783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda snd_device_t in_snd_device) 93883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{ 93983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda return 0; 94083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda} 941