Use v2 API for speaker calibration upload.
Apply patch received from Qualcomm to use an updated API call for
calibration, which does not interfere with direct PCM audio reads
outside Android HAL.
Test: ran manual PCM capture and was succesful, even afer HAL
initialization.
Bug: 62779926
Change-Id: I0ff5f6f0c98a184acda042b1b0569249dc27dbec
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index 8afb0dc..57b0f53 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -304,6 +304,7 @@
int32_t pcm_dev_rx_id = -1, pcm_dev_tx_id = -1;
struct timespec ts;
int retry_duration;
+ int app_type = 0;
if (!adev) {
ALOGE("%s: Invalid params", __func__);
@@ -472,7 +473,20 @@
handle.pcm_tx = NULL;
/* Clear TX calibration to handset mic */
- platform_send_audio_calibration(adev->platform, SND_DEVICE_IN_HANDSET_MIC);
+ if (platform_supports_app_type_cfg()) {
+ ALOGD("%s: Platform supports APP type configuration, using V2\n", __func__);
+ if (uc_info_tx != NULL) {
+ ALOGD("%s: UC Info TX is not NULL, updating and sending calibration\n", __func__);
+ uc_info_tx->in_snd_device = SND_DEVICE_IN_HANDSET_MIC;
+ uc_info_tx->out_snd_device = SND_DEVICE_NONE;
+ platform_get_default_app_type_v2(adev->platform, PCM_CAPTURE, &app_type);
+ platform_send_audio_calibration_v2(adev->platform, uc_info_tx,
+ app_type, 8000);
+ }
+ } else {
+ ALOGW("%s: Platform does NOT support APP type configuration, using V1\n", __func__);
+ platform_send_audio_calibration(adev->platform, SND_DEVICE_IN_HANDSET_MIC);
+ }
if (!status.status) {
protCfg.mode = MSM_SPKR_PROT_CALIBRATED;
protCfg.r0[SP_V2_SPKR_1] = status.r0[SP_V2_SPKR_1];
@@ -804,6 +818,7 @@
struct audio_usecase *uc_info_tx;
struct audio_device *adev = handle.adev_handle;
int32_t pcm_dev_tx_id = -1, ret = 0;
+ int app_type = 0;
ALOGV("%s: Entry", __func__);
if (!adev) {
@@ -855,7 +870,20 @@
exit:
/* Clear VI feedback cal and replace with handset MIC */
- platform_send_audio_calibration(adev->platform, SND_DEVICE_IN_HANDSET_MIC);
+ if (platform_supports_app_type_cfg()) {
+ ALOGD("%s: Platform supports APP type configuration, using V2\n", __func__);
+ if (uc_info_tx != NULL) {
+ ALOGD("%s: UC Info TX is not NULL, updating and sending calibration\n", __func__);
+ uc_info_tx->in_snd_device = SND_DEVICE_IN_HANDSET_MIC;
+ uc_info_tx->out_snd_device = SND_DEVICE_NONE;
+ platform_get_default_app_type_v2(adev->platform, PCM_CAPTURE, &app_type);
+ platform_send_audio_calibration_v2(adev->platform, uc_info_tx,
+ app_type, 8000);
+ }
+ } else {
+ ALOGW("%s: Platform does not support APP type configuration, using V1\n", __func__);
+ platform_send_audio_calibration(adev->platform, SND_DEVICE_IN_HANDSET_MIC);
+ }
if (ret) {
if (handle.pcm_tx)
pcm_close(handle.pcm_tx);