hal: check if separate backend is used for voice headset
If conc. capture is disabled, we select voice headphones irrespective
of if whether separate backend is used for voice headset or not
Add check all backends match API to support both capture and playback
devices, and use it to check if separate backend is added for
headset-mic and select the device accordingly.
Change-Id: I405b52fbf14ca800bd188a62ba83bf82aa61ea1f
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 9ef7795..8032d68 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -4206,6 +4206,40 @@
return result;
}
+bool platform_check_all_backends_match(snd_device_t snd_device1, snd_device_t snd_device2)
+{
+ bool result = true;
+
+ if ((snd_device1 < SND_DEVICE_MIN) || (snd_device1 >= SND_DEVICE_MAX)) {
+ ALOGE("%s: Invalid snd_device = %s", __func__,
+ platform_get_snd_device_name(snd_device1));
+ return false;
+ }
+
+ if ((snd_device2 < SND_DEVICE_MIN) || (snd_device2 >= SND_DEVICE_MAX)) {
+ ALOGE("%s: Invalid snd_device = %s", __func__,
+ platform_get_snd_device_name(snd_device2));
+ return false;
+ }
+
+ const char * be_itf1 = hw_interface_table[snd_device1];
+ const char * be_itf2 = hw_interface_table[snd_device2];
+
+ if (snd_device1 < SND_DEVICE_OUT_END && snd_device2 < SND_DEVICE_OUT_END)
+ return platform_check_backends_match(snd_device1, snd_device2);
+ else if (snd_device1 >= SND_DEVICE_IN_BEGIN && snd_device2 >= SND_DEVICE_IN_BEGIN) {
+ if (NULL != be_itf1 && NULL != be_itf2) {
+ if (strcmp(be_itf2, be_itf1))
+ result = false;
+ }
+ } else {
+ result = false;
+ }
+
+ ALOGV("%s: be_itf1 = %s, be_itf2 = %s, match %d", __func__, be_itf1, be_itf2, result);
+ return result;
+}
+
int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
{
int device_id = -1;
@@ -5914,8 +5948,8 @@
snd_device = SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET;
else
snd_device = SND_DEVICE_OUT_VOICE_ANC_HEADSET;
- } else if (audio_extn_is_concurrent_capture_enabled() &&
- (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET)) {
+ } else if (!platform_check_all_backends_match(SND_DEVICE_IN_VOICE_HEADSET_MIC,
+ SND_DEVICE_IN_SPEAKER_MIC) && (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET)) {
//Separate backend is added for headset-mic as part of concurrent capture
snd_device = SND_DEVICE_OUT_VOICE_HEADSET;
} else {