hal: Add support for Mic break detection

Send request to driver, to enable mic break detection algorithm in ADSP
based on system feature flag during the start of a voice call.

Bug: 69979011
Test: Built and verified with calls that without changes to ACDB files,
mixer toggle is harmless.  ACDB modification testing in progress.
Change-Id: Ifef68005741f3ae538a7b3c414bc8cd0f817915c
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 7bbdb66..d7aeb68 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -5676,6 +5676,8 @@
         }
     }
 
+    adev->mic_break_enabled = property_get_bool("vendor.audio.mic_break", false);
+
     // commented as full set of app type cfg is sent from platform
     // audio_extn_utils_send_default_app_type_cfg(adev->platform, adev->mixer);
     audio_device_ref_count++;
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index a42a458..921c249 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -328,6 +328,7 @@
     bool mic_muted;
     bool enable_voicerx;
     bool enable_hfp;
+    bool mic_break_enabled;
 
     int snd_card;
     void *platform;
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 309b472..d92243e 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -1621,6 +1621,11 @@
     return 0;
 }
 
+int platform_set_mic_break_det(void *platform __unused, bool enable __unused)
+{
+    return 0;
+}
+
 int platform_get_sample_rate(void *platform __unused, uint32_t *rate __unused)
 {
     return 0;
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 5f52c1c..60c0fdd 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -2311,6 +2311,26 @@
     return ret;
 }
 
+int platform_set_mic_break_det(void *platform, bool enable)
+{
+    int ret = 0;
+    struct platform_data *my_data = (struct platform_data *)platform;
+    struct audio_device *adev = my_data->adev;
+    const char *mixer_ctl_name = "Voice Mic Break Enable";
+    struct mixer_ctl *ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+    if (!ctl) {
+        ALOGE("%s: Could not get ctl for mixer cmd - %s",
+              __func__, mixer_ctl_name);
+        return -EINVAL;
+    }
+
+    ret = mixer_ctl_set_value(ctl, 0, enable);
+    if(ret)
+        ALOGE("%s: Failed to set mixer ctl: %s", __func__, mixer_ctl_name);
+
+    return ret;
+}
+
 int platform_get_sample_rate(void *platform, uint32_t *rate)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 1967233..1a7d2c3 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -73,6 +73,7 @@
                                                   snd_device_t in_snd_device);
 int platform_start_voice_call(void *platform, uint32_t vsid);
 int platform_stop_voice_call(void *platform, uint32_t vsid);
+int platform_set_mic_break_det(void *platform, bool enable);
 int platform_set_voice_volume(void *platform, int volume);
 void platform_set_speaker_gain_in_combo(struct audio_device *adev,
                                         snd_device_t snd_device,
diff --git a/hal/voice.c b/hal/voice.c
index e6bf47f..f456ce1 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -207,6 +207,9 @@
         goto error_start_voice;
     }
 
+    if (adev->mic_break_enabled)
+        platform_set_mic_break_det(adev->platform, true);
+
     pcm_start(session->pcm_tx);
     pcm_start(session->pcm_rx);