audio: Add get param support and resolve compile errors

- Add get param support in AHAL for Direction of Arrival and Channel
  index from STHAL.
- Correct feature flag enable syntax and resolve compile errors.
- Remove codec loopback and add afe loopback mixer controls in mixer xml.
- Update sound_trigger_platform xml file.

CRs-Fixed: 2225936
Change-Id: I2e477013977a03a599d6bb4a52c66b897e967219
diff --git a/hal/Android.mk b/hal/Android.mk
index 921252c..36bcca9 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -395,12 +395,13 @@
     LOCAL_CFLAGS += -DDYNAMIC_ECNS_ENABLED
 endif
 
-ifeq ($(strip $($AUDIO_FEATURE_ENABLED_KEEP_ALIVE_ARM_FFV)), true)
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_KEEP_ALIVE_ARM_FFV)), true)
     LOCAL_CFLAGS += -DRUN_KEEP_ALIVE_IN_ARM_FFV
 endif
 
-ifeq ($(strip $($AUDIO_FEATURE_ENABLED_FFV_FFV)), true)
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FFV)), true)
     LOCAL_CFLAGS += -DFFV_ENABLED
+    LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio-noship/include/ffv
     LOCAL_SRC_FILES += audio_extn/ffv.c
 endif
 
diff --git a/hal/audio_extn/ffv.c b/hal/audio_extn/ffv.c
index 54ce30c..82140b1 100755
--- a/hal/audio_extn/ffv.c
+++ b/hal/audio_extn/ffv.c
@@ -81,6 +81,7 @@
 
 #define FFV_CHANNEL_MODE_MONO 1
 #define FFV_CHANNEL_MODE_STEREO 2
+#define FFV_CHANNEL_MODE_QUAD 6
 #define FFV_CHANNEL_MODE_HEX 6
 #define FFV_CHANNEL_MODE_OCT 8
 
@@ -407,7 +408,7 @@
     config->period_size = ffvmod.capture_config.period_size;
 }
 
-int32_t audio_extn_ffv_init(struct audio_device *adev)
+int32_t audio_extn_ffv_init(struct audio_device *adev __unused)
 {
     int ret = 0;
 
@@ -487,7 +488,7 @@
            __func__, num_ec_ref_ch, num_tx_in_ch, num_out_ch, frame_len, sample_rate);
     ALOGD("%s: config file path %s", __func__, config_file_path);
     status_type = ffv_init_fn(&ffvmod.handle, num_tx_in_ch, num_out_ch, num_ec_ref_ch,
-                      frame_len, sample_rate, config_file_path, sm_buffer, 0,
+                      frame_len, sample_rate, config_file_path, (char *)sm_buffer, 0,
                       &total_mem_size, key, lic);
     if (status_type) {
         ALOGE("%s: ERROR. ffv_init returned %d", __func__, status_type);
@@ -580,6 +581,8 @@
         return SND_DEVICE_IN_HANDSET_8MIC;
     } else if (ffvmod.capture_config.channels == FFV_CHANNEL_MODE_HEX) {
         return SND_DEVICE_IN_HANDSET_6MIC;
+    } else if (ffvmod.capture_config.channels == FFV_CHANNEL_MODE_QUAD) {
+        return SND_DEVICE_IN_HANDSET_QMIC;
     } else {
         ALOGE("%s: Invalid channels configured for capture", __func__);
         return SND_DEVICE_NONE;
@@ -587,7 +590,7 @@
 }
 
 int audio_extn_ffv_init_ec_ref_loopback(struct audio_device *adev,
-                                        snd_device_t snd_device)
+                                        snd_device_t snd_device __unused)
 {
     struct audio_usecase *uc_info_tx = NULL;
     snd_device_t in_snd_device;
@@ -679,7 +682,7 @@
 }
 
 int audio_extn_ffv_deinit_ec_ref_loopback(struct audio_device *adev,
-                                          snd_device_t snd_device)
+                                          snd_device_t snd_device __unused)
 {
     struct audio_usecase *uc_info_tx = NULL;
     snd_device_t in_snd_device;
@@ -709,7 +712,7 @@
     return ret;
 }
 
-int32_t audio_extn_ffv_read(struct audio_stream_in *stream,
+int32_t audio_extn_ffv_read(struct audio_stream_in *stream __unused,
                        void *buffer, size_t bytes)
 {
     int status = 0;
@@ -717,7 +720,7 @@
     int16_t *process_ec_ref_ptr = NULL;
     size_t in_buf_size, out_buf_size, bytes_to_copy;
     int retry_num = 0;
-    int i, j, ch;
+    int i, ch;
     int total_in_ch, in_ch, ec_ref_ch;
 
     if (!ffvmod.ffv_lib_handle) {
@@ -805,7 +808,7 @@
         total_in_ch = ffvmod.capture_config.channels;
         ec_ref_ch = ffvmod.ec_ref_config.channels;
         in_ch = total_in_ch - ec_ref_ch;
-        for (i = 0; i < ffvmod.capture_config.period_size; i++) {
+        for (i = 0; i < (int)ffvmod.capture_config.period_size; i++) {
             for (ch = 0; ch < in_ch; ch++) {
                 process_in_ptr[i*in_ch+ch] =
                           in_ptr[i*total_in_ch+ch];
@@ -846,7 +849,6 @@
 void audio_extn_ffv_set_parameters(struct audio_device *adev __unused,
                                    struct str_parms *parms)
 {
-    int err;
     int val;
     int ret = 0;
     char value[128];
diff --git a/hal/audio_extn/soundtrigger.c b/hal/audio_extn/soundtrigger.c
index 041eb53..061616c 100644
--- a/hal/audio_extn/soundtrigger.c
+++ b/hal/audio_extn/soundtrigger.c
@@ -79,6 +79,7 @@
     AUDIO_EVENT_SVA_EXEC_MODE_STATUS,
     AUDIO_EVENT_CAPTURE_STREAM_INACTIVE,
     AUDIO_EVENT_CAPTURE_STREAM_ACTIVE,
+    AUDIO_EVENT_GET_PARAM
 } audio_event_type_t;
 
 typedef enum {
@@ -121,6 +122,12 @@
     int device;
 };
 
+struct sound_trigger_get_param_data {
+    char *param;
+    int sm_handle;
+    struct str_parms *reply;
+};
+
 struct audio_event_info {
     union {
         ssr_event_status_t status;
@@ -129,6 +136,7 @@
         struct audio_read_samples_info aud_info;
         char str_value[ST_EVENT_CONFIG_MAX_STR_VALUE];
         struct audio_hal_usecase usecase;
+        struct sound_trigger_get_param_data st_get_param_data;
     } u;
     struct sound_trigger_device_info device_info;
 };
@@ -165,6 +173,8 @@
 #define SOUND_TRIGGER_LIBRARY_PATH "/vendor/lib/hw/sound_trigger.primary.%s.so"
 #endif
 
+#define SVA_PARAM_DIRECTION_OF_ARRIVAL "st_direction_of_arrival"
+#define SVA_PARAM_CHANNEL_INDEX "st_channel_index"
 /*
  * Current proprietary API version used by AHAL. Queried by STHAL
  * for compatibility check with AHAL
@@ -597,7 +607,7 @@
                        struct str_parms *query, struct str_parms *reply)
 {
     audio_event_info_t event;
-    int ret;
+    int ret, val;
     char value[32];
 
     ret = str_parms_get_str(query, "SVA_EXEC_MODE_STATUS", value,
@@ -606,6 +616,22 @@
         st_dev->st_callback(AUDIO_EVENT_SVA_EXEC_MODE_STATUS, &event);
         str_parms_add_int(reply, "SVA_EXEC_MODE_STATUS", event.u.value);
     }
+
+    ret = str_parms_get_int(query, SVA_PARAM_DIRECTION_OF_ARRIVAL, &val);
+    if (ret >= 0) {
+        event.u.st_get_param_data.sm_handle = val;
+        event.u.st_get_param_data.param = SVA_PARAM_DIRECTION_OF_ARRIVAL;
+        event.u.st_get_param_data.reply = reply;
+        st_dev->st_callback(AUDIO_EVENT_GET_PARAM, &event);
+    }
+
+    ret = str_parms_get_int(query, SVA_PARAM_CHANNEL_INDEX, &val);
+    if (ret >= 0) {
+        event.u.st_get_param_data.sm_handle = val;
+        event.u.st_get_param_data.param = SVA_PARAM_CHANNEL_INDEX;
+        event.u.st_get_param_data.reply = reply;
+        st_dev->st_callback(AUDIO_EVENT_GET_PARAM, &event);
+    }
 }
 
 int audio_extn_sound_trigger_init(struct audio_device *adev)