From 7400b215d6c58ff1ef89d5e099a9bb76d23fab08 Mon Sep 17 00:00:00 2001 From: Suprith Malligere Shankaregowda Date: Fri, 22 Mar 2019 19:48:44 +0530 Subject: [PATCH] External Modem based Voice call support 1. Enable csd client related changes 2. PCM device id update for voice call 3. AFE loopback for both voice call rx and tx path Change-Id: I66081f003549a244548a050c2bb13796ee6c79e4 --- configs/msmsteppe_au/mixer_paths_adp.xml | 5 +++ hal/msm8974/platform.c | 24 ++++++++-- hal/msm8974/platform.h | 8 ++++ hal/voice.c | 57 ++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 3 deletions(-) diff --git a/configs/msmsteppe_au/mixer_paths_adp.xml b/configs/msmsteppe_au/mixer_paths_adp.xml index e2de5395..4ac4798c 100644 --- a/configs/msmsteppe_au/mixer_paths_adp.xml +++ b/configs/msmsteppe_au/mixer_paths_adp.xml @@ -755,6 +755,11 @@ + + + + + diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c index 3d890325..31a1e95f 100644 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -2017,7 +2017,9 @@ static bool platform_is_i2s_ext_modem(const char *snd_card_name, !strncmp(snd_card_name, "sdx-tavil-i2s-snd-card", sizeof("sdx-tavil-i2s-snd-card")) || !strncmp(snd_card_name, "sda845-tavil-i2s-snd-card", - sizeof("sda845-tavil-i2s-snd-card"))) { + sizeof("sda845-tavil-i2s-snd-card")) || + !strncmp(snd_card_name, "sa6155-adp-star-snd-card", + sizeof("sa6155-adp-star-snd-card"))) { plat_data->is_i2s_ext_modem = true; } ALOGV("%s, is_i2s_ext_modem:%d soundcard name is %s",__func__, @@ -2026,6 +2028,20 @@ static bool platform_is_i2s_ext_modem(const char *snd_card_name, return plat_data->is_i2s_ext_modem; } +static bool is_auto_snd_card(const char *snd_card_name) +{ + bool is_auto_snd_card = false; + + if (!strncmp(snd_card_name, "sa6155-adp-star-snd-card", + sizeof("sa6155-adp-star-snd-card"))) { + is_auto_snd_card = true; + ALOGV("%s : Auto snd card detected: soundcard name is %s",__func__, + snd_card_name); + } + + return is_auto_snd_card; +} + static void set_platform_defaults(struct platform_data * my_data) { int32_t dev; @@ -2923,7 +2939,8 @@ void *platform_init(struct audio_device *adev) return NULL; } - if (platform_is_i2s_ext_modem(snd_card_name, my_data)) { + if (platform_is_i2s_ext_modem(snd_card_name, my_data) && + !is_auto_snd_card(snd_card_name)) { ALOGD("%s: Call MIXER_XML_PATH_I2S", __func__); adev->audio_route = audio_route_init(adev->snd_card, @@ -3161,7 +3178,7 @@ void *platform_init(struct audio_device *adev) /* Initialize ACDB ID's */ - if (my_data->is_i2s_ext_modem) + if (my_data->is_i2s_ext_modem && !is_auto_snd_card(snd_card_name)) platform_info_init(PLATFORM_INFO_XML_PATH_I2S, my_data, PLATFORM); else if (!strncmp(snd_card_name, "sdm660-snd-card-skush", sizeof("sdm660-snd-card-skush"))) @@ -3360,6 +3377,7 @@ acdb_init_fail: property_get("ro.baseband", baseband, ""); if ((!strncmp("apq8084", platform, sizeof("apq8084")) || !strncmp("msm8996", platform, sizeof("msm8996")) || + !strncmp("sm6150", platform, sizeof("sm6150")) || !strncmp("sdx", platform, sizeof("sdx")) || !strncmp("sdm845", platform, sizeof("sdm845"))) && ( !strncmp("mdm", baseband, (sizeof("mdm")-1)) || diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h index 1d56a7e9..033bd32a 100644 --- a/hal/msm8974/platform.h +++ b/hal/msm8974/platform.h @@ -585,6 +585,14 @@ enum { #define VOLTE_CALL_PCM_DEVICE 15 #define QCHAT_CALL_PCM_DEVICE 37 #define VOWLAN_CALL_PCM_DEVICE 16 +#elif PLATFORM_AUTO +#define HOST_LESS_RX_ID 41 +#define HOST_LESS_TX_ID 42 +#define VOICE_CALL_PCM_DEVICE 8 +#define VOICE2_CALL_PCM_DEVICE -1 +#define VOLTE_CALL_PCM_DEVICE -1 +#define QCHAT_CALL_PCM_DEVICE -1 +#define VOWLAN_CALL_PCM_DEVICE -1 #else #define VOICE_CALL_PCM_DEVICE 2 #define VOICE2_CALL_PCM_DEVICE 22 diff --git a/hal/voice.c b/hal/voice.c index 729ab27f..b136f77a 100644 --- a/hal/voice.c +++ b/hal/voice.c @@ -48,6 +48,10 @@ struct pcm_config pcm_config_voice_call = { .format = PCM_FORMAT_S16_LE, }; +#ifdef PLATFORM_AUTO +struct pcm *voice_loopback_tx = NULL; +struct pcm *voice_loopback_rx = NULL; +#endif static struct voice_session *voice_get_session_from_use_case(struct audio_device *adev, audio_usecase_t usecase_id) { @@ -182,6 +186,16 @@ int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id) session->pcm_tx = NULL; } +#ifdef PLATFORM_AUTO + if(voice_loopback_rx) { + pcm_close(voice_loopback_rx); + voice_loopback_rx = NULL; + } + if(voice_loopback_tx) { + pcm_close(voice_loopback_tx); + voice_loopback_tx = NULL; + } +#endif /* 2. Get and set stream specific mixer controls */ disable_audio_route(adev, uc_info); @@ -201,6 +215,9 @@ int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id) int ret = 0; struct audio_usecase *uc_info; int pcm_dev_rx_id, pcm_dev_tx_id; +#ifdef PLATFORM_AUTO + int pcm_dev_loopback_rx_id, pcm_dev_loopback_tx_id; +#endif uint32_t sample_rate = 8000; struct voice_session *session = NULL; struct pcm_config voice_config = pcm_config_voice_call; @@ -246,6 +263,10 @@ int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id) select_devices(adev, usecase_id); +#ifdef PLATFORM_AUTO + pcm_dev_loopback_rx_id = HOST_LESS_RX_ID; + pcm_dev_loopback_tx_id = HOST_LESS_TX_ID; +#endif pcm_dev_rx_id = platform_get_pcm_device_id(uc_info->id, PCM_PLAYBACK); pcm_dev_tx_id = platform_get_pcm_device_id(uc_info->id, PCM_CAPTURE); @@ -287,6 +308,28 @@ int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id) goto error_start_voice; } +#ifdef PLATFORM_AUTO + voice_loopback_rx = pcm_open(adev->snd_card, + pcm_dev_loopback_rx_id, + PCM_OUT, &voice_config); + if (voice_loopback_rx < 0 || !pcm_is_ready(voice_loopback_rx)) { + ALOGE("%s: Either could not open pcm_dev_loopback_rx_id %d or %s", + __func__, pcm_dev_loopback_rx_id, pcm_get_error(voice_loopback_rx)); + ret = -EIO; + goto error_start_voice; + } + + voice_loopback_tx = pcm_open(adev->snd_card, + pcm_dev_loopback_tx_id, + PCM_IN, &voice_config); + if (voice_loopback_tx < 0 || !pcm_is_ready(voice_loopback_tx)) { + ALOGE("%s: Either could not open pcm_dev_loopback_tx_id or %s", + __func__, pcm_dev_loopback_tx_id, pcm_get_error(voice_loopback_tx)); + ret = -EIO; + goto error_start_voice; + } +#endif + if(adev->mic_break_enabled) platform_set_mic_break_det(adev->platform, true); @@ -302,6 +345,20 @@ int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id) goto error_start_voice; } +#ifdef PLATFORM_AUTO + ret = pcm_start(voice_loopback_tx); + if (ret != 0) { + ALOGE("%s: %s", __func__, pcm_get_error(voice_loopback_tx)); + goto error_start_voice; + } + + ret = pcm_start(voice_loopback_rx); + if (ret != 0) { + ALOGE("%s: %s", __func__, pcm_get_error(voice_loopback_rx)); + goto error_start_voice; + } +#endif + /* Enable aanc only when no calls are active */ if (!voice_is_call_state_active(adev)) voice_check_and_update_aanc_path(adev, uc_info->out_snd_device, true);