hal: Add proxy support for BT playback

Changes to read decoded pcm data from DSP via proxy port.

CRs-Fixed: 1081411
Change-Id: Ia60e284de5e30b162dbde1705e263f17f4c5e187
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 0f38b82..ff7560e 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -67,15 +67,7 @@
     bool hifi_audio_enabled;
 };
 
-static struct audio_extn_module aextnmod = {
-    .anc_enabled = 0,
-    .aanc_enabled = 0,
-    .custom_stereo_enabled = 0,
-    .proxy_channel_num = 2,
-    .hpx_enabled = 0,
-    .vbat_enabled = 0,
-    .hifi_audio_enabled = 0,
-};
+static struct audio_extn_module aextnmod;
 
 #define AUDIO_PARAMETER_KEY_ANC        "anc_enabled"
 #define AUDIO_PARAMETER_KEY_WFD        "wfd_channel_cap"
@@ -752,6 +744,17 @@
     return ret;
 }
 
+void audio_extn_init(void)
+{
+    aextnmod.anc_enabled = 0;
+    aextnmod.aanc_enabled = 0;
+    aextnmod.custom_stereo_enabled = 0;
+    aextnmod.proxy_channel_num = 2;
+    aextnmod.hpx_enabled = 0;
+    aextnmod.vbat_enabled = 0;
+    aextnmod.hifi_audio_enabled = 0;
+}
+
 void audio_extn_set_parameters(struct audio_device *adev,
                                struct str_parms *parms)
 {
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 337acd1..3efd337 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -44,6 +44,10 @@
 #define AUDIO_DEVICE_OUT_PROXY 0x40000
 #endif
 
+#ifndef AUDIO_DEVICE_IN_PROXY
+#define AUDIO_DEVICE_IN_PROXY (AUDIO_DEVICE_BIT_IN | 0x1000000)
+#endif
+
 #ifndef INCALL_MUSIC_ENABLED
 #define AUDIO_OUTPUT_FLAG_INCALL_MUSIC 0x8000
 #endif
@@ -501,6 +505,7 @@
 void audio_extn_pm_unvote(void);
 #endif
 
+void audio_extn_init(void);
 void audio_extn_utils_update_streams_cfg_lists(void *platform,
                                   struct mixer *mixer,
                                   struct listnode *streams_output_cfg_list,
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index fb668d5..c9e144f 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -4717,6 +4717,14 @@
             ret = -EINVAL;
             goto err_open;
         }
+    if ((in->device == AUDIO_DEVICE_IN_TELEPHONY_RX) &&
+          (adev->mode != AUDIO_MODE_IN_CALL)) {
+        ret = -EINVAL;
+        goto err_open;
+    }
+
+    if ((in->device == AUDIO_DEVICE_IN_TELEPHONY_RX) ||
+             (in->device == AUDIO_DEVICE_IN_PROXY)) {
         if (config->sample_rate == 0)
             config->sample_rate = AFE_PROXY_SAMPLING_RATE;
         if (config->sample_rate != 48000 && config->sample_rate != 16000 &&
@@ -5015,6 +5023,7 @@
                                                         "visualizer_hal_stop_output");
         }
     }
+    audio_extn_init();
     audio_extn_listen_init(adev, adev->snd_card);
     audio_extn_sound_trigger_init(adev);
     audio_extn_gef_init(adev);