Merge "hal: Add support for PCM in offload path"
diff --git a/Android.mk b/Android.mk
index 9bb3250..c63df05 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,4 +1,4 @@
-ifneq ($(filter mpq8092 msm8960 msm8226 msm8x26 msm8610 msm8974 msm8x74 apq8084,$(TARGET_BOARD_PLATFORM)),)
+ifneq ($(filter mpq8092 msm8960 msm8226 msm8x26 msm8610 msm8974 msm8x74 apq8084 msm8916,$(TARGET_BOARD_PLATFORM)),)
 
 MY_LOCAL_PATH := $(call my-dir)
 
diff --git a/hal/Android.mk b/hal/Android.mk
index a7e0a02..1c3f946 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -8,7 +8,7 @@
 
 AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
 
-ifneq ($(filter msm8974 msm8226 msm8610 apq8084,$(TARGET_BOARD_PLATFORM)),)
+ifneq ($(filter msm8974 msm8226 msm8610 apq8084 msm8916,$(TARGET_BOARD_PLATFORM)),)
   # B-family platform uses msm8974 code base
   AUDIO_PLATFORM = msm8974
   MULTIPLE_HW_VARIANTS_ENABLED := true
@@ -23,6 +23,7 @@
 endif
 endif
 
+
 LOCAL_SRC_FILES := \
 	audio_hw.c \
 	voice.c \
@@ -53,6 +54,10 @@
     LOCAL_SRC_FILES += audio_extn/hfp.c
 endif
 
+ifneq ($(strip $(AUDIO_FEATURE_DISABLED_CUSTOMSTEREO)),true)
+    LOCAL_CFLAGS += -DCUSTOM_STEREO_ENABLED
+endif
+
 ifneq ($(strip $(AUDIO_FEATURE_DISABLED_SSR)),true)
     LOCAL_CFLAGS += -DSSR_ENABLED
     LOCAL_SRC_FILES += audio_extn/ssr.c
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 89903ba..c6a8e68 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -35,18 +35,22 @@
 struct audio_extn_module {
     bool anc_enabled;
     bool aanc_enabled;
+    bool custom_stereo_enabled;
     uint32_t proxy_channel_num;
 };
 
 static struct audio_extn_module aextnmod = {
     .anc_enabled = 0,
     .aanc_enabled = 0,
+    .custom_stereo_enabled = 0,
     .proxy_channel_num = 2,
 };
 
 #define AUDIO_PARAMETER_KEY_ANC        "anc_enabled"
 #define AUDIO_PARAMETER_KEY_WFD        "wfd_channel_cap"
 #define AUDIO_PARAMETER_CAN_OPEN_PROXY "can_open_proxy"
+#define AUDIO_PARAMETER_CUSTOM_STEREO  "stereo_as_dual_mono"
+
 #ifndef FM_ENABLED
 #define audio_extn_fm_set_parameters(adev, parms) (0)
 #else
@@ -60,6 +64,45 @@
                                            struct str_parms *parms);
 #endif
 
+#ifndef CUSTOM_STEREO_ENABLED
+#define audio_extn_customstereo_set_parameters(adev, parms)         (0)
+#else
+void audio_extn_customstereo_set_parameters(struct audio_device *adev,
+                                           struct str_parms *parms)
+{
+    int ret = 0;
+    char value[32]={0};
+    bool custom_stereo_state = false;
+    const char *mixer_ctl_name = "Set Custom Stereo OnOff";
+    struct mixer_ctl *ctl;
+
+    ALOGV("%s", __func__);
+    ret = str_parms_get_str(parms, AUDIO_PARAMETER_CUSTOM_STEREO, value,
+                            sizeof(value));
+    if (ret >= 0) {
+        if (!strncmp("true", value, sizeof("true")) || atoi(value))
+            custom_stereo_state = true;
+
+        if (custom_stereo_state == aextnmod.custom_stereo_enabled)
+            return;
+
+        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;
+        }
+        if (mixer_ctl_set_value(ctl, 0, custom_stereo_state) < 0) {
+            ALOGE("%s: Could not set custom stereo state %d",
+                  __func__, custom_stereo_state);
+            return;
+        }
+        aextnmod.custom_stereo_enabled = custom_stereo_state;
+        ALOGV("%s: Setting custom stereo state success", __func__);
+    }
+}
+#endif /* CUSTOM_STEREO_ENABLED */
+
 #ifndef ANC_HEADSET_ENABLED
 #define audio_extn_set_anc_parameters(adev, parms)       (0)
 #else
@@ -320,15 +363,19 @@
    audio_extn_listen_set_parameters(adev, parms);
    audio_extn_hfp_set_parameters(adev, parms);
    audio_extn_ddp_set_parameters(adev, parms);
+   audio_extn_customstereo_set_parameters(adev, parms);
 }
 
 void audio_extn_get_parameters(const struct audio_device *adev,
                               struct str_parms *query,
                               struct str_parms *reply)
 {
+    char *kv_pairs = NULL;
     audio_extn_get_afe_proxy_parameters(query, reply);
 
-    ALOGD("%s: returns %s", __func__, str_parms_to_str(reply));
+    kv_pairs = str_parms_to_str(reply);
+    ALOGD_IF(kv_pairs != NULL, "%s: returns %s", __func__, kv_pairs);
+    free(kv_pairs);
 }
 
 #ifdef AUXPCM_BT_ENABLED
diff --git a/hal/audio_extn/listen.c b/hal/audio_extn/listen.c
index 9166f8e..91bb04f 100644
--- a/hal/audio_extn/listen.c
+++ b/hal/audio_extn/listen.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -64,6 +64,7 @@
 typedef void (*destroy_listen_hw_t)();
 
 typedef int (*open_listen_session_t)(struct audio_hw_device *,
+                                    struct listen_open_params*,
                                     struct listen_session**);
 
 typedef int (*close_listen_session_t)(struct audio_hw_device *dev,
@@ -119,10 +120,12 @@
 void audio_extn_listen_set_parameters(struct audio_device *adev,
                                struct str_parms *parms)
 {
-    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
-
+    ALOGV("%s: enter", __func__);
     if (listen_dev) {
-        listen_dev->listen_set_parameters(&adev->device, str_parms_to_str(parms));
+         char *kv_pairs = str_parms_to_str(parms);
+         ALOGV_IF(kv_pairs != NULL, "%s: %s", __func__, kv_pairs);
+         listen_dev->listen_set_parameters(&adev->device, kv_pairs);
+         free(kv_pairs);
     }
 
     return;
diff --git a/hal/audio_extn/usb.c b/hal/audio_extn/usb.c
index 88e3cad..699c3b7 100644
--- a/hal/audio_extn/usb.c
+++ b/hal/audio_extn/usb.c
@@ -152,7 +152,7 @@
 
     file_size = st.st_size;
 
-    read_buf = (char *)calloc(1, USB_BUFF_SIZE);
+    read_buf = (char *)calloc(1, USB_BUFF_SIZE + 1);
     err = read(fd, read_buf, USB_BUFF_SIZE);
     str_start = strstr(read_buf, type);
     if (str_start == NULL) {
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 005b2d5..147146c 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -704,6 +704,15 @@
         disable_snd_device(adev, usecase->in_snd_device, false);
     }
 
+    /* Applicable only on the targets that has external modem.
+     * New device information should be sent to modem before enabling
+     * the devices to reduce in-call device switch time.
+     */
+    if (usecase->type == VOICE_CALL)
+        status = platform_switch_voice_call_enable_device_config(adev->platform,
+                                                                 out_snd_device,
+                                                                 in_snd_device);
+
     /* Enable new sound devices */
     if (out_snd_device != SND_DEVICE_NONE) {
         if (usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND)
@@ -1889,11 +1898,10 @@
                 (voice_extn_compress_voip_is_format_supported(in->format)) &&
                 (in->config.rate == 8000 || in->config.rate == 16000) &&
                 (popcount(in->channel_mask) == 1)) {
-                ret = voice_extn_compress_voip_open_input_stream(in);
-                if (ret != 0) {
+                err = voice_extn_compress_voip_open_input_stream(in);
+                if (err != 0) {
                     ALOGE("%s: Compress voip input cannot be opened, error:%d",
-                          __func__, ret);
-                    goto done;
+                          __func__, err);
                 }
             }
         }
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 51d3538..3f4de55 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -434,6 +434,13 @@
                   __func__, dlerror());
             goto error;
         }
+        csd->enable_device_config = (enable_device_config_t)dlsym(csd->csd_client,
+                                               "csd_client_enable_device_config");
+        if (csd->enable_device_config == NULL) {
+            ALOGE("%s: dlsym error %s for csd_client_enable_device_config",
+                  __func__, dlerror());
+            goto error;
+        }
         csd->enable_device = (enable_device_t)dlsym(csd->csd_client,
                                              "csd_client_enable_device");
         if (csd->enable_device == NULL) {
@@ -849,6 +856,32 @@
     return ret;
 }
 
+int platform_switch_voice_call_enable_device_config(void *platform,
+                                                    snd_device_t out_snd_device,
+                                                    snd_device_t in_snd_device)
+{
+    struct platform_data *my_data = (struct platform_data *)platform;
+    int acdb_rx_id, acdb_tx_id;
+    int ret = 0;
+
+    acdb_rx_id = acdb_device_table[out_snd_device];
+    acdb_tx_id = acdb_device_table[in_snd_device];
+
+    if (my_data->csd != NULL) {
+        if (acdb_rx_id > 0 && acdb_tx_id > 0) {
+            ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id);
+            if (ret < 0) {
+                ALOGE("%s: csd_enable_device_config, failed, error %d",
+                      __func__, ret);
+            }
+        } else {
+            ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
+                  acdb_rx_id, acdb_tx_id);
+        }
+    }
+    return ret;
+}
+
 int platform_switch_voice_call_device_post(void *platform,
                                            snd_device_t out_snd_device,
                                            snd_device_t in_snd_device)
@@ -1314,7 +1347,8 @@
         if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
             if (audio_extn_ssr_get_enabled() && channel_count == 6)
                 snd_device = SND_DEVICE_IN_QUAD_MIC;
-            else if (channel_count == 2)
+            else if (my_data->fluence_type & (FLUENCE_DUAL_MIC | FLUENCE_QUAD_MIC) &&
+                    channel_count == 2)
                 snd_device = SND_DEVICE_IN_HANDSET_STEREO_DMIC;
             else
                 snd_device = SND_DEVICE_IN_HANDSET_MIC;
@@ -1499,8 +1533,9 @@
     char value[256] = {0};
     int val;
     int ret = 0, err;
+    char *kv_pairs = str_parms_to_str(parms);
 
-    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
+    ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
 
     err = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_BTSCO, &val);
     if (err >= 0) {
@@ -1545,6 +1580,7 @@
     }
 
     ALOGV("%s: exit with code(%d)", __func__, ret);
+    free(kv_pairs);
     return ret;
 }
 
@@ -1643,6 +1679,7 @@
     char value[256] = {0};
     int ret;
     int fluence_type;
+    char *kv_pairs = NULL;
 
     ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_FLUENCE_TYPE,
                             value, sizeof(value));
@@ -1678,7 +1715,9 @@
         str_parms_add_str(reply, AUDIO_PARAMETER_KEY_VOLUME_BOOST, value);
     }
 
-    ALOGV("%s: exit: returns - %s", __func__, str_parms_to_str(reply));
+    kv_pairs = str_parms_to_str(reply);
+    ALOGV_IF(kv_pairs != NULL, "%s: exit: returns - %s", __func__, kv_pairs);
+    free(kv_pairs);
 }
 
 /* Delay in Us */
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index 3ea068d..9749be4 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -218,6 +218,7 @@
 typedef int (*init_t)();
 typedef int (*deinit_t)();
 typedef int (*disable_device_t)();
+typedef int (*enable_device_config_t)(int, int);
 typedef int (*enable_device_t)(int, int, uint32_t);
 typedef int (*volume_t)(uint32_t, int);
 typedef int (*mic_mute_t)(uint32_t, int);
@@ -234,6 +235,7 @@
     init_t init;
     deinit_t deinit;
     disable_device_t disable_device;
+    enable_device_config_t enable_device_config;
     enable_device_t enable_device;
     volume_t volume;
     mic_mute_t mic_mute;
diff --git a/hal/platform_api.h b/hal/platform_api.h
index f6e06a3..81291a2 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -31,6 +31,9 @@
 int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id);
 int platform_send_audio_calibration(void *platform, snd_device_t snd_device);
 int platform_switch_voice_call_device_pre(void *platform);
+int platform_switch_voice_call_enable_device_config(void *platform,
+                                                    snd_device_t out_snd_device,
+                                                    snd_device_t in_snd_device);
 int platform_switch_voice_call_device_post(void *platform,
                                            snd_device_t out_snd_device,
                                            snd_device_t in_snd_device);
diff --git a/hal/voice.c b/hal/voice.c
index 8783f01..28d44db 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -364,8 +364,9 @@
     char value[32];
     int val;
     int ret = 0, err;
+    char *kv_pairs = str_parms_to_str(parms);
 
-    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
+    ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
 
     ret = voice_extn_set_parameters(adev, parms);
     if (ret != 0)
@@ -413,6 +414,7 @@
 
 done:
     ALOGV("%s: exit with code(%d)", __func__, ret);
+    free(kv_pairs);
     return ret;
 }
 
diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c
index 5c87c9c..47ac2c8 100644
--- a/hal/voice_extn/compress_voip.c
+++ b/hal/voice_extn/compress_voip.c
@@ -59,8 +59,9 @@
     struct pcm *pcm_rx;
     struct pcm *pcm_tx;
     struct stream_out *out_stream;
-    int ref_count;
-    int out_stream_count;
+    uint32_t out_stream_count;
+    uint32_t in_stream_count;
+    uint32_t sample_rate;
 };
 
 #define MODE_IS127              0x2
@@ -78,13 +79,15 @@
 #define AUDIO_PARAMETER_VALUE_VOIP_TRUE             "true"
 #define AUDIO_PARAMETER_KEY_VOIP_CHECK              "voip_flag"
 #define AUDIO_PARAMETER_KEY_VOIP_OUT_STREAM_COUNT   "voip_out_stream_count"
+#define AUDIO_PARAMETER_KEY_VOIP_SAMPLE_RATE        "voip_sample_rate"
 
 static struct voip_data voip_data = {
   .pcm_rx = NULL,
   .pcm_tx = NULL,
   .out_stream = NULL,
-  .ref_count = 0,
-  .out_stream_count = 0
+  .out_stream_count = 0,
+  .in_stream_count = 0,
+  .sample_rate = 0
 };
 
 static int voip_set_volume(struct audio_device *adev, int volume);
@@ -280,10 +283,10 @@
     int i, ret = 0;
     struct audio_usecase *uc_info;
 
-    ALOGD("%s: enter, ref_count=%d", __func__, voip_data.ref_count);
-    voip_data.ref_count--;
+    ALOGD("%s: enter, out_stream_count=%d, in_stream_count=%d",
+           __func__, voip_data.out_stream_count, voip_data.in_stream_count);
 
-    if (!voip_data.ref_count) {
+    if (!voip_data.out_stream_count && !voip_data.in_stream_count) {
         uc_info = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL);
         if (uc_info == NULL) {
             ALOGE("%s: Could not find the usecase (%d) in the list",
@@ -310,8 +313,10 @@
 
         list_remove(&uc_info->list);
         free(uc_info);
+        voip_data.sample_rate = 0;
     } else
-        ALOGV("%s: NO-OP because ref_count=%d", __func__, voip_data.ref_count);
+        ALOGV("%s: NO-OP because out_stream_count=%d, in_stream_count=%d",
+               __func__, voip_data.out_stream_count, voip_data.in_stream_count);
 
     ALOGV("%s: exit: status(%d)", __func__, ret);
     return ret;
@@ -327,12 +332,15 @@
     ALOGD("%s: enter", __func__);
 
     uc_info = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL);
-    if ((uc_info == NULL) && (voip_data.out_stream)) {
+    if (uc_info == NULL) {
         ALOGV("%s: voip usecase is added to the list", __func__);
         uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
         uc_info->id = USECASE_COMPRESS_VOIP_CALL;
         uc_info->type = VOIP_CALL;
-        uc_info->stream.out = voip_data.out_stream;
+        if (voip_data.out_stream)
+            uc_info->stream.out = voip_data.out_stream;
+        else
+            uc_info->stream.out = adev->primary_output;
         uc_info->in_snd_device = SND_DEVICE_NONE;
         uc_info->out_snd_device = SND_DEVICE_NONE;
 
@@ -388,12 +396,15 @@
             ALOGE("%s: error %d\n", __func__, ret);
             goto error_start_voip;
         }
-        voip_data.ref_count = 0;
-    }
-    else
+    } else {
         ALOGV("%s: voip usecase is already enabled", __func__);
+        if (voip_data.out_stream)
+            uc_info->stream.out = voip_data.out_stream;
+        else
+            uc_info->stream.out = adev->primary_output;
+        select_devices(adev, USECASE_COMPRESS_VOIP_CALL);
+    }
 
-    voip_data.ref_count++;
     return 0;
 
 error_start_voip:
@@ -411,8 +422,9 @@
     int ret = 0, err, rate;
     int min_rate, max_rate;
     bool flag;
+    char *kv_pairs = str_parms_to_str(parms);
 
-    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
+    ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
 
     err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_RATE,
                             value, sizeof(value));
@@ -453,6 +465,7 @@
 
 done:
     ALOGV("%s: exit", __func__);
+    free(kv_pairs);
     return ret;
 }
 
@@ -470,6 +483,13 @@
         str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_OUT_STREAM_COUNT,
                           voip_data.out_stream_count);
     }
+
+    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOIP_SAMPLE_RATE,
+                            value, sizeof(value));
+    if (ret >= 0) {
+        str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_SAMPLE_RATE,
+                          voip_data.sample_rate);
+    }
 }
 
 void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
@@ -499,6 +519,7 @@
 {
     int ret, val;
     char value[32]={0};
+    char *kv_pairs = NULL;
 
     ALOGV("%s: enter", __func__);
 
@@ -511,7 +532,9 @@
             str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_CHECK, false);
     }
 
-    ALOGD("%s: exit: return - %s", __func__, str_parms_to_str(reply));
+    kv_pairs = str_parms_to_str(reply);
+    ALOGD_IF(kv_pairs != NULL, "%s: exit: return - %s", __func__, kv_pairs);
+    free(kv_pairs);
 }
 
 int voice_extn_compress_voip_out_get_buffer_size(struct stream_out *out)
@@ -571,9 +594,9 @@
 
     ALOGD("%s: enter", __func__);
 
+    voip_data.out_stream_count--;
     ret = voip_stop_call(adev);
     voip_data.out_stream = NULL;
-    voip_data.out_stream_count--;
 
     ALOGV("%s: exit: status(%d)", __func__, ret);
     return ret;
@@ -595,7 +618,7 @@
 
     voip_data.out_stream = out;
     voip_data.out_stream_count++;
-
+    voip_data.sample_rate = out->sample_rate;
     ret = voip_set_mode(out->dev, out->format);
 
     ALOGV("%s: exit", __func__);
@@ -610,6 +633,7 @@
 
     ALOGD("%s: enter", __func__);
 
+    voip_data.in_stream_count--;
     status = voip_stop_call(adev);
 
     ALOGV("%s: exit: status(%d)", __func__, status);
@@ -625,15 +649,25 @@
 
     ALOGD("%s: enter", __func__);
 
+    if ((voip_data.sample_rate != 0) &&
+        (voip_data.sample_rate != in->config.rate)) {
+        ret = -ENOTSUP;
+        goto done;
+    } else {
+        voip_data.sample_rate = in->config.rate;
+    }
+
     in->usecase = USECASE_COMPRESS_VOIP_CALL;
     if (in->config.rate == 16000)
         in->config = pcm_config_voip_wb;
     else
         in->config = pcm_config_voip_nb;
 
+    voip_data.in_stream_count++;
     ret = voip_set_mode(in->dev, in->format);
 
-    ALOGV("%s: exit", __func__);
+done:
+    ALOGV("%s: exit, ret=%d", __func__, ret);
     return ret;
 }
 
@@ -729,7 +763,8 @@
     if (ret) {
         if ((popcount(config->channel_mask) == 1) &&
             (config->sample_rate == 8000 || config->sample_rate == 16000))
-            ret = true;
+            ret = ((voip_data.sample_rate == 0) ? true:
+                    (voip_data.sample_rate == config->sample_rate));
         else
             ret = false;
     }
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index b8bc2df..5612e0c 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.c
@@ -427,8 +427,9 @@
     char *str;
     int value;
     int ret = 0, err;
+    char *kv_pairs = str_parms_to_str(parms);
 
-    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
+    ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
 
     err = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_VSID, &value);
     if (err >= 0) {
@@ -458,6 +459,7 @@
 
 done:
     ALOGV("%s: exit with code(%d)", __func__, ret);
+    free(kv_pairs);
     return ret;
 }
 
@@ -485,9 +487,10 @@
 {
     int ret;
     char value[VOICE_EXTN_PARAMETER_VALUE_MAX_LEN] = {0};
-    char *str = NULL;
+    char *str = str_parms_to_str(query);
 
-    ALOGV("%s: enter %s", __func__, str_parms_to_str(query));
+    ALOGV_IF(str != NULL, "%s: enter %s", __func__, str);
+    free(str);
 
     ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_AUDIO_MODE, value,
                             sizeof(value));
@@ -507,7 +510,9 @@
     }
     voice_extn_compress_voip_get_parameters(adev, query, reply);
 
-    ALOGV("%s: exit: returns \"%s\"", __func__, str_parms_to_str(reply));
+    str = str_parms_to_str(reply);
+    ALOGV_IF(str != NULL, "%s: exit: returns \"%s\"", __func__, str);
+    free(str);
 }
 
 void voice_extn_out_get_parameters(struct stream_out *out,
diff --git a/mm-audio/aenc-aac/Android.mk b/mm-audio/aenc-aac/Android.mk
index 8ab45b3..7cd804a 100644
--- a/mm-audio/aenc-aac/Android.mk
+++ b/mm-audio/aenc-aac/Android.mk
@@ -24,6 +24,8 @@
 ifeq ($(call is-board-platform,mpq8092),true)
 include $(AENC_AAC_PATH)/qdsp6/Android.mk
 endif
-
+ifeq ($(call is-board-platform,msm8916),true)
+include $(AENC_AAC_PATH)/qdsp6/Android.mk
+endif
 
 endif
diff --git a/mm-audio/aenc-amrnb/Android.mk b/mm-audio/aenc-amrnb/Android.mk
index 2601ede..79474c6 100644
--- a/mm-audio/aenc-amrnb/Android.mk
+++ b/mm-audio/aenc-amrnb/Android.mk
@@ -24,6 +24,8 @@
 ifeq ($(call is-board-platform,mpq8092),true)
 include $(AENC_AMR_PATH)/qdsp6/Android.mk
 endif
-
+ifeq ($(call is-board-platform,msm8916),true)
+include $(AENC_AMR_PATH)/qdsp6/Android.mk
+endif
 
 endif
diff --git a/mm-audio/aenc-evrc/Android.mk b/mm-audio/aenc-evrc/Android.mk
index 2f42d6b..649f860 100644
--- a/mm-audio/aenc-evrc/Android.mk
+++ b/mm-audio/aenc-evrc/Android.mk
@@ -24,6 +24,8 @@
 ifeq ($(call is-board-platform,mpq8092),true)
 include $(AENC_EVRC_PATH)/qdsp6/Android.mk
 endif
-
+ifeq ($(call is-board-platform,msm8916),true)
+include $(AENC_EVRC_PATH)/qdsp6/Android.mk
+endif
 
 endif
diff --git a/mm-audio/aenc-qcelp13/Android.mk b/mm-audio/aenc-qcelp13/Android.mk
index fe18efc..c919f19 100644
--- a/mm-audio/aenc-qcelp13/Android.mk
+++ b/mm-audio/aenc-qcelp13/Android.mk
@@ -24,5 +24,8 @@
 ifeq ($(call is-board-platform,mpq8092),true)
 include $(AENC_QCELP13_PATH)/qdsp6/Android.mk
 endif
+ifeq ($(call is-board-platform,msm8916),true)
+include $(AENC_QCELP13_PATH)/qdsp6/Android.mk
+endif
 
 endif