hal: Fix ADM Sample Rate and echo reference path for HFP

* Update ADM Sample rate to 8000/16000 based on BT NB/WB
* Use Mono channel echo reference instead of multi-channel
  echo reference

Change-Id: I6ec1e50dd3066bdca3b8bbf9fe3064de747aa586
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index 374e9dc..3b084ae 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -83,7 +83,6 @@
     struct pcm *hfp_sco_tx;
     struct pcm *hfp_pcm_rx;
     struct pcm *hfp_pcm_tx;
-    struct pcm *hfp_ext_ec_tx;
     bool is_hfp_running;
     float hfp_volume;
     int32_t hfp_pcm_dev_id;
@@ -97,7 +96,6 @@
     .hfp_sco_tx = NULL,
     .hfp_pcm_rx = NULL,
     .hfp_pcm_tx = NULL,
-    .hfp_ext_ec_tx = NULL,
     .is_hfp_running = 0,
     .hfp_volume = 0,
     .hfp_pcm_dev_id = HFP_ASM_RX_TX,
@@ -290,7 +288,6 @@
     int32_t ret = 0;
     struct audio_usecase *uc_info;
     int32_t pcm_dev_rx_id, pcm_dev_tx_id, pcm_dev_asm_rx_id, pcm_dev_asm_tx_id;
-    int32_t pcm_ext_ec_ref_id;
 
     ALOGD("%s: enter", __func__);
 
@@ -400,27 +397,6 @@
         goto exit;
     }
 
-#ifdef PLATFORM_AUTO
-    /* echo reference path for single-mic/multi-mic surround ECNS hfp calls */
-    pcm_ext_ec_ref_id = HFP_EXT_EC_REF_TX;
-    ALOGD("%s: Opening PCM capture device card_id(%d) device_id(%d)",
-            __func__, adev->snd_card, pcm_ext_ec_ref_id);
-    hfpmod.hfp_ext_ec_tx = pcm_open(adev->snd_card,
-                                    pcm_ext_ec_ref_id,
-                                    PCM_IN, &pcm_config_hfp);
-    if (hfpmod.hfp_ext_ec_tx && !pcm_is_ready(hfpmod.hfp_ext_ec_tx)) {
-        ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_ext_ec_tx));
-        ret = -EIO;
-        goto exit;
-    }
-
-    if (pcm_start(hfpmod.hfp_ext_ec_tx) < 0) {
-        ALOGE("%s: pcm start for hfp ext ec tx failed", __func__);
-        ret = -EINVAL;
-        goto exit;
-    }
-#endif
-
     hfpmod.is_hfp_running = true;
     hfp_set_volume(adev, hfpmod.hfp_volume);
 
@@ -465,14 +441,6 @@
         hfpmod.hfp_pcm_tx = NULL;
     }
 
-#ifdef PLATFORM_AUTO
-    /* echo reference path for single-mic/multi-mic surround ECNS hfp calls */
-    if (hfpmod.hfp_ext_ec_tx) {
-        pcm_close(hfpmod.hfp_ext_ec_tx);
-        hfpmod.hfp_ext_ec_tx = NULL;
-    }
-#endif
-
     uc_info = fp_get_usecase_from_list(adev, hfpmod.ucid);
     if (uc_info == NULL) {
         ALOGE("%s: Could not find the usecase (%d) in the list",
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index e56fee3..c71aaec 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -910,13 +910,13 @@
         case USECASE_AUDIO_HFP_SCO_WB:
             audio_extn_btsco_get_sample_rate(usecase->out_snd_device,
                                              &usecase->out_app_type_cfg.sample_rate);
-            usecase->in_app_type_cfg.sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+            usecase->in_app_type_cfg.sample_rate = usecase->out_app_type_cfg.sample_rate;
             break;
         case USECASE_AUDIO_HFP_SCO_DOWNLINK:
         case USECASE_AUDIO_HFP_SCO_WB_DOWNLINK:
             audio_extn_btsco_get_sample_rate(usecase->in_snd_device,
                                              &usecase->in_app_type_cfg.sample_rate);
-            usecase->out_app_type_cfg.sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+            usecase->out_app_type_cfg.sample_rate = usecase->in_app_type_cfg.sample_rate;
             break;
         default:
             ALOGE("%s: usecase id (%d) not supported, use default sample rate",
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index ed23aca..c5ae09b 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -1911,9 +1911,6 @@
         else if (compare_device_type(out_devices, AUDIO_DEVICE_OUT_USB_HEADSET))
             strlcat(ec_ref_mixer_path, " usb-headphones",
                     MIXER_PATH_MAX_LENGTH);
-        else if (compare_device_type(out_devices, AUDIO_DEVICE_OUT_BUS))
-            strlcpy(ec_ref_mixer_path, "multi-mic-echo-reference",
-                    MIXER_PATH_MAX_LENGTH);
         else if (adev->snd_dev_ref_cnt[SND_DEVICE_OUT_BT_SCO_WB] > 0)
             strlcat(ec_ref_mixer_path, " bt-sco-wb",
                     MIXER_PATH_MAX_LENGTH);
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index be138c0..749c9f5 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -626,7 +626,6 @@
 #elif PLATFORM_AUTO
 #define HFP_SCO_RX 29
 #define HFP_ASM_RX_TX 36
-#define HFP_EXT_EC_REF_TX 1
 #elif defined (PLATFORM_MSMFALCON) || defined (PLATFORM_MSM8937) || \
       defined (PLATFORM_MSM8953)
 #define HFP_SCO_RX 17