From 9c83648c9362b34bbd0dd8b5a7b6d1c52de611a4 Mon Sep 17 00:00:00 2001 From: Sriram Kumar Date: Tue, 27 Oct 2020 20:34:35 +0530 Subject: [PATCH] hal: Add apptype support for HFP client call Add support to send apptype and calibration for HFP client call Change-Id: I71105baa28d98d4646620601a31a5ff373c9e9e9 --- hal/Android.mk | 4 ++++ hal/audio_extn/utils.c | 15 ++++++++++++-- hal/msm8974/platform.c | 46 ++++++++++++++++++++++++++++++++++++++++++ hal/platform_api.h | 1 + 4 files changed, 64 insertions(+), 2 deletions(-) diff --git a/hal/Android.mk b/hal/Android.mk index 4cc91a24..e57b859b 100644 --- a/hal/Android.mk +++ b/hal/Android.mk @@ -126,6 +126,10 @@ ifeq ($(TARGET_BOARD_AUTO),true) LOCAL_CFLAGS += -DPLATFORM_AUTO endif +ifeq ($(TARGET_SUPPORTS_WEARABLES),true) + LOCAL_CFLAGS += -DENABLE_HFP_CALIBRATION +endif + ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DAEMON_SUPPORT)), true) LOCAL_CFLAGS += -DDAEMON_SUPPORT_AUTO endif diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c index 9cd74161..65c8fb71 100755 --- a/hal/audio_extn/utils.c +++ b/hal/audio_extn/utils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. * Not a Contribution. * * Copyright (C) 2014 The Android Open Source Project @@ -1669,6 +1669,9 @@ int audio_extn_utils_send_app_type_cfg(struct audio_device *adev, num_devices = 1; } break; + case PCM_HFP_CALL: + rc = audio_extn_utils_send_app_type_cfg_hfp(adev,usecase); + return rc; default: ALOGI("%s: not a playback/capture path, no need to cfg app type", __func__); rc = 0; @@ -2040,7 +2043,15 @@ void audio_extn_utils_send_audio_calibration(struct audio_device *adev, } else if (type == PCM_CAPTURE && usecase->stream.in != NULL) { platform_send_audio_calibration(adev->platform, usecase, usecase->stream.in->app_type_cfg.app_type); - } else if ((type == PCM_HFP_CALL) || (type == PCM_CAPTURE) || + } else if (type == PCM_HFP_CALL) { + /* when app type is default. the sample rate is not used to send cal */ +#ifdef ENABLE_HFP_CALIBRATION + platform_send_audio_calibration_hfp(adev->platform, usecase->in_snd_device); +#else + platform_send_audio_calibration(adev->platform, usecase, + platform_get_default_app_type_v2(adev->platform, usecase->type)); +#endif + } else if ((type == PCM_CAPTURE) || (type == TRANSCODE_LOOPBACK_RX && usecase->stream.inout != NULL) || (type == ICC_CALL) || (type == SYNTH_LOOPBACK)) { platform_send_audio_calibration(adev->platform, usecase, diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c index 86c1cc90..8571a71e 100755 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -5593,6 +5593,52 @@ int platform_send_audio_calibration(void *platform, struct audio_usecase *usecas return 0; } +int platform_send_audio_calibration_hfp(void *platform, snd_device_t snd_device) +{ + struct platform_data *my_data = (struct platform_data *)platform; + int acdb_dev_id, acdb_dev_type; + int sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; + int app_type = 0; + + acdb_dev_id = platform_get_snd_device_acdb_id(snd_device); + if (acdb_dev_id < 0) { + ALOGE("%s: Could not find acdb id for device(%d)", + __func__, snd_device); + return -EINVAL; + } + + if ((snd_device >= SND_DEVICE_OUT_BEGIN) && + (snd_device < SND_DEVICE_OUT_END)) { + acdb_dev_type = ACDB_DEV_TYPE_OUT; + app_type = DEFAULT_APP_TYPE_RX_PATH; + } else { + acdb_dev_type = ACDB_DEV_TYPE_IN; + app_type = DEFAULT_APP_TYPE_TX_PATH; + } + + if ((my_data->acdb_send_audio_cal_v3) && + ((snd_device == SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP) || + (snd_device == SND_DEVICE_IN_VOICE_SPEAKER_DMIC))) { + /* TX path calibration */ + my_data->acdb_send_audio_cal_v3(acdb_dev_id, ACDB_DEV_TYPE_IN, + DEFAULT_APP_TYPE_TX_PATH, sample_rate, 0); + my_data->acdb_send_audio_cal_v3(acdb_dev_id, ACDB_DEV_TYPE_OUT, + DEFAULT_APP_TYPE_RX_PATH, sample_rate, 0); + } else if ((my_data->acdb_send_audio_cal_v3) && + (snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_HFP)) { + /* RX path calibration */ + my_data->acdb_send_audio_cal_v3(acdb_dev_id, ACDB_DEV_TYPE_IN, + DEFAULT_APP_TYPE_TX_PATH, sample_rate,0 ); + my_data->acdb_send_audio_cal_v3(acdb_dev_id, ACDB_DEV_TYPE_OUT, + DEFAULT_APP_TYPE_RX_PATH, sample_rate,0 ); + } else if (my_data->acdb_send_audio_cal) { + my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type, app_type, + sample_rate); + } + + return 0; +} + int platform_switch_voice_call_device_pre(void *platform) { struct platform_data *my_data = (struct platform_data *)platform; diff --git a/hal/platform_api.h b/hal/platform_api.h index ca727081..29322e16 100644 --- a/hal/platform_api.h +++ b/hal/platform_api.h @@ -182,6 +182,7 @@ int platform_set_native_support(int na_mode); int platform_get_native_support(); int platform_send_audio_calibration(void *platform, struct audio_usecase *usecase, int app_type); +int platform_send_audio_calibration_hfp(void *platform, snd_device_t snd_device); int platform_get_default_app_type(void *platform); int platform_get_default_app_type_v2(void *platform, usecase_type_t type); int platform_switch_voice_call_device_pre(void *platform);