hal: Add support for AFE sidetone
Add support for AFE sidetone for USB and non-USB
devices when device sidetone is not available or
not supported.
Change-Id: Iaacaa61fc1eddacb1fe9d58ef194d8f980d8f934
Signed-off-by: Vikram Panduranga <vpandura@codeaurora.org>
CRs-Fixed: 1061420
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 90fffb4..1ad95c8 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -132,6 +132,9 @@
#define MAX_SET_CAL_BYTE_SIZE 65536
+/* Mixer path names */
+#define AFE_SIDETONE_MIXER_PATH "afe-sidetone"
+
#define AUDIO_PARAMETER_KEY_FLUENCE_TYPE "fluence"
#define AUDIO_PARAMETER_KEY_SLOWTALK "st_enable"
#define AUDIO_PARAMETER_KEY_HD_VOICE "hd_voice"
@@ -5913,18 +5916,36 @@
ALOGI("Debug: Disable sidetone");
} else {
ret = audio_extn_usb_enable_sidetone(out_snd_device, enable);
- if (ret)
- ALOGI("%s: usb device %d does not support device sidetone\n",
- __func__, out_snd_device);
- }
+ if (ret) {
+ /*fall back to AFE sidetone*/
+ ALOGV("%s: No USB sidetone supported, switching to AFE sidetone",
+ __func__);
+
+ if (enable)
+ audio_route_apply_and_update_path(adev->audio_route, AFE_SIDETONE_MIXER_PATH);
+ else
+ audio_route_reset_and_update_path(adev->audio_route, AFE_SIDETONE_MIXER_PATH);
+ }
+ }
} else {
ALOGV("%s: sidetone out device(%d) mixer cmd = %s\n",
__func__, out_snd_device, str);
- if (enable)
- audio_route_apply_and_update_path(adev->audio_route, str);
- else
- audio_route_reset_and_update_path(adev->audio_route, str);
+ if (enable) {
+ ret = audio_route_apply_and_update_path(adev->audio_route, str);
+ if (ret) {
+ ALOGV("%s: No device sidetone supported, switching to AFE sidetone",
+ __func__);
+ audio_route_apply_and_update_path(adev->audio_route, AFE_SIDETONE_MIXER_PATH);
+ }
+ } else {
+ ret = audio_route_reset_and_update_path(adev->audio_route, str);
+ if (ret) {
+ ALOGV("%s: No device sidetone supported, switching to AFE sidetone",
+ __func__);
+ audio_route_reset_and_update_path(adev->audio_route, AFE_SIDETONE_MIXER_PATH);
+ }
+ }
}
return 0;
}
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index ffcb862..31a9f14 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -113,6 +113,9 @@
#define MAX_SET_CAL_BYTE_SIZE 65536
+/* Mixer path names */
+#define AFE_SIDETONE_MIXER_PATH "afe-sidetone"
+
#define AUDIO_PARAMETER_KEY_FLUENCE_TYPE "fluence"
#define AUDIO_PARAMETER_KEY_SLOWTALK "st_enable"
#define AUDIO_PARAMETER_KEY_HD_VOICE "hd_voice"
@@ -5761,18 +5764,37 @@
ALOGI("Debug: Disable sidetone");
} else {
ret = audio_extn_usb_enable_sidetone(out_snd_device, enable);
- if (ret)
- ALOGI("%s: usb device %d does not support device sidetone\n",
- __func__, out_snd_device);
+ if (ret) {
+ /*fall back to AFE sidetone*/
+ ALOGV("%s: No USB sidetone supported, switching to AFE sidetone",
+ __func__);
+
+ if (enable)
+ audio_route_apply_and_update_path(adev->audio_route, AFE_SIDETONE_MIXER_PATH);
+ else
+ audio_route_reset_and_update_path(adev->audio_route, AFE_SIDETONE_MIXER_PATH);
+ }
}
} else {
ALOGV("%s: sidetone out device(%d) mixer cmd = %s\n",
__func__, out_snd_device, str);
- if (enable)
- audio_route_apply_and_update_path(adev->audio_route, str);
- else
- audio_route_reset_and_update_path(adev->audio_route, str);
+ if (enable) {
+ ret = audio_route_apply_and_update_path(adev->audio_route, str);
+ if (ret) {
+ ALOGV("%s: No device sidetone supported, switching to AFE sidetone",
+ __func__);
+ audio_route_apply_and_update_path(adev->audio_route, AFE_SIDETONE_MIXER_PATH);
+ }
+ }
+ else {
+ ret = audio_route_reset_and_update_path(adev->audio_route, str);
+ if (ret) {
+ ALOGV("%s: No device sidetone supported, switching to AFE sidetone",
+ __func__);
+ audio_route_reset_and_update_path(adev->audio_route, AFE_SIDETONE_MIXER_PATH);
+ }
+ }
}
return 0;
}