Merge "hal: enable speaker protection in call usecase"
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 64bb2f5..5ab7018 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -210,7 +210,7 @@
     }
 }
 
-int audio_extn_get_fluence_parameters(struct audio_device *adev,
+int audio_extn_get_fluence_parameters(const struct audio_device *adev,
                        struct str_parms *query, struct str_parms *reply)
 {
     int ret = 0, err;
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 95bd3aa..0cef6cb 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -87,7 +87,7 @@
 #else
 void audio_extn_set_fluence_parameters(struct audio_device *adev,
                                            struct str_parms *parms);
-int audio_extn_get_fluence_parameters(struct audio_device *adev,
+int audio_extn_get_fluence_parameters(const struct audio_device *adev,
                   struct str_parms *query, struct str_parms *reply);
 #endif
 
@@ -125,14 +125,13 @@
 #endif
 
 #ifndef SSR_ENABLED
-#define audio_extn_ssr_init(adev, in)                 (0)
+#define audio_extn_ssr_init(in)                       (0)
 #define audio_extn_ssr_deinit()                       (0)
 #define audio_extn_ssr_update_enabled()               (0)
 #define audio_extn_ssr_get_enabled()                  (0)
 #define audio_extn_ssr_read(stream, buffer, bytes)    (0)
 #else
-int32_t audio_extn_ssr_init(struct audio_device *adev,
-                            struct stream_in *in);
+int32_t audio_extn_ssr_init(struct stream_in *in);
 int32_t audio_extn_ssr_deinit();
 void audio_extn_ssr_update_enabled();
 bool audio_extn_ssr_get_enabled();
@@ -234,7 +233,7 @@
 #endif
 
 #ifndef COMPRESS_CAPTURE_ENABLED
-#define audio_extn_compr_cap_init(adev,in)                (0)
+#define audio_extn_compr_cap_init(in)                     (0)
 #define audio_extn_compr_cap_enabled()                    (0)
 #define audio_extn_compr_cap_format_supported(format)     (0)
 #define audio_extn_compr_cap_usecase_supported(usecase)   (0)
@@ -242,8 +241,7 @@
 #define audio_extn_compr_cap_read(in, buffer, bytes)      (0)
 #define audio_extn_compr_cap_deinit()                     (0)
 #else
-void audio_extn_compr_cap_init(struct audio_device *adev,
-                                    struct stream_in *in);
+void audio_extn_compr_cap_init(struct stream_in *in);
 bool audio_extn_compr_cap_enabled();
 bool audio_extn_compr_cap_format_supported(audio_format_t format);
 bool audio_extn_compr_cap_usecase_supported(audio_usecase_t usecase);
@@ -284,7 +282,7 @@
 
 #ifndef HFP_ENABLED
 #define audio_extn_hfp_is_active(adev)                  (0)
-#define audio_extn_hfp_get_usecase()                    (0)
+#define audio_extn_hfp_get_usecase()                    (-1)
 #else
 bool audio_extn_hfp_is_active(struct audio_device *adev);
 audio_usecase_t audio_extn_hfp_get_usecase();
diff --git a/hal/audio_extn/compress_capture.c b/hal/audio_extn/compress_capture.c
index 6559582..47e6a9d 100644
--- a/hal/audio_extn/compress_capture.c
+++ b/hal/audio_extn/compress_capture.c
@@ -51,8 +51,7 @@
 };
 
 
-void audio_extn_compr_cap_init(struct audio_device *adev,
-                            struct stream_in *in)
+void audio_extn_compr_cap_init(struct stream_in *in)
 {
     in->usecase = USECASE_AUDIO_RECORD_COMPRESS;
     in->config.channels = COMPRESS_IN_CONFIG_CHANNELS;
@@ -137,7 +136,7 @@
                     header->frame_size =
                         bytes - sizeof(*header) - header->reserved[0];
                 }
-                ALOGV("c_in_buf: %p, data offset: %p, header size: %u,"
+                ALOGV("c_in_buf: %p, data offset: %p, header size: %zu,"
                     "reserved[0]: %u frame_size: %d", c_in_mod.in_buf,
                         c_in_mod.in_buf + c_in_header,
                         sizeof(*header), header->reserved[0],
diff --git a/hal/audio_extn/dolby.c b/hal/audio_extn/dolby.c
index 650104c..ddd2380 100644
--- a/hal/audio_extn/dolby.c
+++ b/hal/audio_extn/dolby.c
@@ -187,7 +187,7 @@
 
 void send_ddp_endp_params_stream(struct stream_out *out,
                                  int device, int dev_ch_cap,
-                                 bool set_cache)
+                                 bool set_cache __unused)
 {
     int idx, i;
     int ddp_endp_params_data[2*DDP_ENDP_NUM_PARAMS + 1];
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index 3c25c14..5a68016 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -127,7 +127,7 @@
 }
 
 static int32_t start_hfp(struct audio_device *adev,
-                               struct str_parms *parms)
+                         struct str_parms *parms __unused)
 {
     int32_t i, ret = 0;
     struct audio_usecase *uc_info;
@@ -311,7 +311,7 @@
     ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_ENABLE, value,
                             sizeof(value));
     if (ret >= 0) {
-           if(!strncmp(value,"true",sizeof(value)))
+           if (!strncmp(value,"true",sizeof(value)))
                ret = start_hfp(adev,parms);
            else
                stop_hfp(adev);
@@ -324,22 +324,20 @@
            if (rate == 8000){
                hfpmod.ucid = USECASE_AUDIO_HFP_SCO;
                pcm_config_hfp.rate = rate;
-           }
-           else if (rate == 16000){
+           } else if (rate == 16000){
                hfpmod.ucid = USECASE_AUDIO_HFP_SCO_WB;
                pcm_config_hfp.rate = rate;
-           }
-           else
+           } else
                ALOGE("Unsupported rate..");
     }
 
-    if(hfpmod.is_hfp_running) {
+    if (hfpmod.is_hfp_running) {
         memset(value, 0, sizeof(value));
         ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING,
                                 value, sizeof(value));
         if (ret >= 0) {
             val = atoi(value);
-            if(val > 0)
+            if (val > 0)
                 select_devices(adev, hfpmod.ucid);
         }
     }
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index f172b3a..b6bb2c9 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -112,7 +112,7 @@
     struct pcm *pcm_rx;
     struct pcm *pcm_tx;
     int (*client_register_callback)
-    (char *client_name, int (*callback)(int, void *, void *), void *data);
+    (char *client_name, int (*callback)(int), void *data);
     void (*thermal_client_unregister_callback)(int handle);
     int (*thermal_client_request)(char *client_name, int req_data);
     bool spkr_prot_enable;
@@ -519,7 +519,7 @@
     return status.status;
 }
 
-static void* spkr_calibration_thread(void *context)
+static void* spkr_calibration_thread()
 {
     unsigned long sec = 0;
     int t0;
@@ -674,7 +674,7 @@
     return NULL;
 }
 
-static int thermal_client_callback(int temp, void *user_data, void *reserved)
+static int thermal_client_callback(int temp)
 {
     pthread_mutex_lock(&handle.spkr_prot_thermalsync_mutex);
     ALOGD("%s: spkr_prot set t0 %d and signal", __func__, temp);
@@ -719,7 +719,7 @@
     } else {
         /*Query callback function symbol*/
         handle.client_register_callback =
-       (int (*)(char *, int (*)(int, void *, void *),void *))
+       (int (*)(char *, int (*)(int),void *))
         dlsym(handle.thermal_handle, "thermal_client_register_callback");
         handle.thermal_client_unregister_callback =
         (void (*)(int) )
diff --git a/hal/audio_extn/ssr.c b/hal/audio_extn/ssr.c
index f32d217..07b28b0 100644
--- a/hal/audio_extn/ssr.c
+++ b/hal/audio_extn/ssr.c
@@ -63,10 +63,10 @@
 struct ssr_module {
     FILE                *fp_4ch;
     FILE                *fp_6ch;
-    int16_t             **real_coeffs;
-    int16_t             **imag_coeffs;
+    Word16             **real_coeffs;
+    Word16             **imag_coeffs;
     void                *surround_obj;
-    int16_t             *surround_raw_buffer;
+    Word16             *surround_raw_buffer;
     bool                is_ssr_enabled;
 
     void *surround_filters_handle;
@@ -378,8 +378,7 @@
     return (ssrmod.is_ssr_enabled ? true: false);
 }
 
-int32_t audio_extn_ssr_init(struct audio_device *adev,
-                            struct stream_in *in)
+int32_t audio_extn_ssr_init(struct stream_in *in)
 {
     uint32_t ret;
     char c_multi_ch_dump[128] = {0};
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 74032db..1f53aa7 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1148,7 +1148,7 @@
                 ret = false;
                 break;
             } else if (is_offload_usecase(usecase->id) &&
-                       popcount(usecase->stream.out->channel_mask) > 2) {
+                       audio_channel_count_from_out_mask(usecase->stream.out->channel_mask) > 2) {
                 ALOGD("%s: multi-channel(%x) compress offload playback is active, "
                       "no change in HDMI channels", __func__, usecase->stream.out->channel_mask);
                 ret = false;
@@ -1420,7 +1420,8 @@
     return out->sample_rate;
 }
 
-static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
+static int out_set_sample_rate(struct audio_stream *stream __unused,
+                               uint32_t rate __unused)
 {
     return -ENOSYS;
 }
@@ -1434,7 +1435,8 @@
     else if(out->usecase == USECASE_COMPRESS_VOIP_CALL)
         return voice_extn_compress_voip_out_get_buffer_size(out);
 
-    return out->config.period_size * audio_stream_frame_size(stream);
+    return out->config.period_size *
+                audio_stream_out_frame_size((const struct audio_stream_out *)stream);
 }
 
 static uint32_t out_get_channels(const struct audio_stream *stream)
@@ -1451,7 +1453,8 @@
     return out->format;
 }
 
-static int out_set_format(struct audio_stream *stream, audio_format_t format)
+static int out_set_format(struct audio_stream *stream __unused,
+                          audio_format_t format __unused)
 {
     return -ENOSYS;
 }
@@ -1498,7 +1501,8 @@
     return 0;
 }
 
-static int out_dump(const struct audio_stream *stream, int fd)
+static int out_dump(const struct audio_stream *stream __unused,
+                    int fd __unused)
 {
     return 0;
 }
@@ -1810,7 +1814,7 @@
     }
 
     if (is_offload_usecase(out->usecase)) {
-        ALOGD("copl(%p): writing buffer (%d bytes) to compress device", out, bytes);
+        ALOGD("copl(%p): writing buffer (%zu bytes) to compress device", out, bytes);
         if (out->send_new_metadata) {
             ALOGD("copl(%p):send new gapless metadata", out);
             compress_set_gapless_metadata(out->compr, &out->gapless_mdata);
@@ -1862,7 +1866,7 @@
 
     if (ret != 0) {
         if (out->pcm)
-            ALOGE("%s: error %d - %s", __func__, ret, pcm_get_error(out->pcm));
+            ALOGE("%s: error %ld - %s", __func__, ret, pcm_get_error(out->pcm));
         if (out->usecase == USECASE_COMPRESS_VOIP_CALL) {
             pthread_mutex_lock(&adev->lock);
             voice_extn_compress_voip_close_output_stream(&out->stream.common);
@@ -1870,7 +1874,7 @@
             out->standby = true;
         }
         out_standby(&out->stream.common);
-        usleep(bytes * 1000000 / audio_stream_frame_size(&out->stream.common) /
+        usleep(bytes * 1000000 / audio_stream_out_frame_size(stream) /
                         out_get_sample_rate(&out->stream.common));
 
     }
@@ -1908,18 +1912,20 @@
         return -EINVAL;
 }
 
-static int out_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
+static int out_add_audio_effect(const struct audio_stream *stream __unused,
+                                effect_handle_t effect __unused)
 {
     return 0;
 }
 
-static int out_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
+static int out_remove_audio_effect(const struct audio_stream *stream __unused,
+                                   effect_handle_t effect __unused)
 {
     return 0;
 }
 
-static int out_get_next_write_timestamp(const struct audio_stream_out *stream,
-                                        int64_t *timestamp)
+static int out_get_next_write_timestamp(const struct audio_stream_out *stream __unused,
+                                        int64_t *timestamp __unused)
 {
     return -EINVAL;
 }
@@ -1946,7 +1952,7 @@
         }
     } else {
         if (out->pcm) {
-            size_t avail;
+            unsigned int avail;
             if (pcm_get_htimestamp(out->pcm, &avail, timestamp) == 0) {
                 size_t kernel_buffer_size = out->config.period_size * out->config.period_count;
                 int64_t signed_frames = out->written - kernel_buffer_size + avail;
@@ -2066,7 +2072,8 @@
     return in->config.rate;
 }
 
-static int in_set_sample_rate(struct audio_stream *stream, uint32_t rate)
+static int in_set_sample_rate(struct audio_stream *stream __unused,
+                              uint32_t rate __unused)
 {
     return -ENOSYS;
 }
@@ -2080,7 +2087,8 @@
     else if(audio_extn_compr_cap_usecase_supported(in->usecase))
         return audio_extn_compr_cap_get_buffer_size(in->config.format);
 
-    return in->config.period_size * audio_stream_frame_size(stream);
+    return in->config.period_size *
+                audio_stream_in_frame_size((const struct audio_stream_in *)stream);
 }
 
 static uint32_t in_get_channels(const struct audio_stream *stream)
@@ -2097,7 +2105,8 @@
     return in->format;
 }
 
-static int in_set_format(struct audio_stream *stream, audio_format_t format)
+static int in_set_format(struct audio_stream *stream __unused,
+                         audio_format_t format __unused)
 {
     return -ENOSYS;
 }
@@ -2140,7 +2149,8 @@
     return status;
 }
 
-static int in_dump(const struct audio_stream *stream, int fd)
+static int in_dump(const struct audio_stream *stream __unused,
+                   int fd __unused)
 {
     return 0;
 }
@@ -2170,7 +2180,7 @@
                 (in->dev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
                 (voice_extn_compress_voip_is_format_supported(in->format)) &&
                 (in->config.rate == 8000 || in->config.rate == 16000) &&
-                (popcount(in->channel_mask) == 1)) {
+                (audio_channel_count_from_in_mask(in->channel_mask) == 1)) {
                 err = voice_extn_compress_voip_open_input_stream(in);
                 if (err != 0) {
                     ALOGE("%s: Compress voip input cannot be opened, error:%d",
@@ -2226,7 +2236,8 @@
     return str;
 }
 
-static int in_set_gain(struct audio_stream_in *stream, float gain)
+static int in_set_gain(struct audio_stream_in *stream __unused,
+                       float gain __unused)
 {
     return 0;
 }
@@ -2265,7 +2276,8 @@
     }
 
     if (in->pcm) {
-        if (audio_extn_ssr_get_enabled() && popcount(in->channel_mask) == 6)
+        if (audio_extn_ssr_get_enabled() &&
+                audio_channel_count_from_in_mask(in->channel_mask) == 6)
             ret = audio_extn_ssr_read(stream, buffer, bytes);
         else if (audio_extn_compr_cap_usecase_supported(in->usecase))
             ret = audio_extn_compr_cap_read(in, buffer, bytes);
@@ -2300,13 +2312,13 @@
         memset(buffer, 0, bytes);
         in_standby(&in->stream.common);
         ALOGV("%s: read failed status %d- sleeping for buffer duration", __func__, ret);
-        usleep(bytes * 1000000 / audio_stream_frame_size(&in->stream.common) /
+        usleep(bytes * 1000000 / audio_stream_in_frame_size(stream) /
                                    in_get_sample_rate(&in->stream.common));
     }
     return bytes;
 }
 
-static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream)
+static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream __unused)
 {
     return 0;
 }
@@ -2363,7 +2375,8 @@
                                    audio_devices_t devices,
                                    audio_output_flags_t flags,
                                    struct audio_config *config,
-                                   struct audio_stream_out **stream_out)
+                                   struct audio_stream_out **stream_out,
+                                   const char *address __unused)
 {
     struct audio_device *adev = (struct audio_device *)dev;
     struct stream_out *out;
@@ -2389,9 +2402,6 @@
         return -ENOMEM;
     }
 
-    pthread_mutex_init(&out->lock, (const pthread_mutexattr_t *) NULL);
-    pthread_cond_init(&out->cond, (const pthread_condattr_t *) NULL);
-
     if (devices == AUDIO_DEVICE_NONE)
         devices = AUDIO_DEVICE_OUT_SPEAKER;
 
@@ -2430,7 +2440,7 @@
         out->usecase = USECASE_AUDIO_PLAYBACK_MULTI_CH;
         out->config = pcm_config_hdmi_multi;
         out->config.rate = config->sample_rate;
-        out->config.channels = popcount(out->channel_mask);
+        out->config.channels = audio_channel_count_from_out_mask(out->channel_mask);
         out->config.period_size = HDMI_MULTI_PERIOD_BYTES / (out->config.channels * 2);
     } else if ((out->dev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
                (out->flags == (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_VOIP_RX)) &&
@@ -2500,7 +2510,7 @@
         out->compr_config.codec->bit_rate =
                     config->offload_info.bit_rate;
         out->compr_config.codec->ch_in =
-                    popcount(config->channel_mask);
+                audio_channel_count_from_out_mask(config->channel_mask);
         out->compr_config.codec->ch_out = out->compr_config.codec->ch_in;
         out->bit_width = PCM_OUTPUT_BIT_WIDTH;
 
@@ -2609,6 +2619,9 @@
     /* out->muted = false; by calloc() */
     /* out->written = 0; by calloc() */
 
+    pthread_mutex_init(&out->lock, (const pthread_mutexattr_t *) NULL);
+    pthread_cond_init(&out->cond, (const pthread_condattr_t *) NULL);
+
     config->format = out->stream.common.get_format(&out->stream.common);
     config->channel_mask = out->stream.common.get_channels(&out->stream.common);
     config->sample_rate = out->stream.common.get_sample_rate(&out->stream.common);
@@ -2626,7 +2639,7 @@
     return ret;
 }
 
-static void adev_close_output_stream(struct audio_hw_device *dev,
+static void adev_close_output_stream(struct audio_hw_device *dev __unused,
                                      struct audio_stream_out *stream)
 {
     struct stream_out *out = (struct stream_out *)stream;
@@ -2642,8 +2655,7 @@
         if(ret != 0)
             ALOGE("%s: Compress voip output cannot be closed, error:%d",
                   __func__, ret);
-    }
-    else
+    } else
         out_standby(&stream->common);
 
     if (is_offload_usecase(out->usecase)) {
@@ -2665,13 +2677,14 @@
     char *str;
     char value[32];
     int val;
-    int ret = 0, err;
+    int ret;
+    int status = 0;
 
     ALOGD("%s: enter: %s", __func__, kvpairs);
     parms = str_parms_create_str(kvpairs);
 
-    err = str_parms_get_str(parms, "SND_CARD_STATUS", value, sizeof(value));
-    if (err >= 0) {
+    ret = str_parms_get_str(parms, "SND_CARD_STATUS", value, sizeof(value));
+    if (ret >= 0) {
         char *snd_card_status = value+2;
         if (strstr(snd_card_status, "OFFLINE")) {
             struct listnode *node;
@@ -2699,16 +2712,16 @@
     }
 
     pthread_mutex_lock(&adev->lock);
-    ret = voice_set_parameters(adev, parms);
-    if (ret != 0)
+    status = voice_set_parameters(adev, parms);
+    if (status != 0)
         goto done;
 
-    ret = platform_set_parameters(adev->platform, parms);
-    if (ret != 0)
+    status = platform_set_parameters(adev->platform, parms);
+    if (status != 0)
         goto done;
 
-    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_NREC, value, sizeof(value));
-    if (err >= 0) {
+    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_NREC, value, sizeof(value));
+    if (ret >= 0) {
         /* When set to false, HAL should disable EC and NS */
         if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0)
             adev->bluetooth_nrec = true;
@@ -2716,16 +2729,16 @@
             adev->bluetooth_nrec = false;
     }
 
-    err = str_parms_get_str(parms, "screen_state", value, sizeof(value));
-    if (err >= 0) {
+    ret = str_parms_get_str(parms, "screen_state", value, sizeof(value));
+    if (ret >= 0) {
         if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0)
             adev->screen_off = false;
         else
             adev->screen_off = true;
     }
 
-    err = str_parms_get_int(parms, "rotation", &val);
-    if (err >= 0) {
+    ret = str_parms_get_int(parms, "rotation", &val);
+    if (ret >= 0) {
         bool reverse_speakers = false;
         switch(val) {
         // FIXME: note that the code below assumes that the speakers are in the correct placement
@@ -2740,17 +2753,20 @@
             break;
         default:
             ALOGE("%s: unexpected rotation of %d", __func__, val);
+            status = -EINVAL;
         }
-        if (adev->speaker_lr_swap != reverse_speakers) {
-            adev->speaker_lr_swap = reverse_speakers;
-            // only update the selected device if there is active pcm playback
-            struct audio_usecase *usecase;
-            struct listnode *node;
-            list_for_each(node, &adev->usecase_list) {
-                usecase = node_to_item(node, struct audio_usecase, list);
-                if (usecase->type == PCM_PLAYBACK) {
-                    select_devices(adev, usecase->id);
-                    break;
+        if (status == 0) {
+            if (adev->speaker_lr_swap != reverse_speakers) {
+                adev->speaker_lr_swap = reverse_speakers;
+                // only update the selected device if there is active pcm playback
+                struct audio_usecase *usecase;
+                struct listnode *node;
+                list_for_each(node, &adev->usecase_list) {
+                    usecase = node_to_item(node, struct audio_usecase, list);
+                    if (usecase->type == PCM_PLAYBACK) {
+                        select_devices(adev, usecase->id);
+                        break;
+                    }
                 }
             }
         }
@@ -2769,8 +2785,8 @@
 done:
     str_parms_destroy(parms);
     pthread_mutex_unlock(&adev->lock);
-    ALOGV("%s: exit with code(%d)", __func__, ret);
-    return ret;
+    ALOGV("%s: exit with code(%d)", __func__, status);
+    return status;
 }
 
 static char* adev_get_parameters(const struct audio_hw_device *dev,
@@ -2815,7 +2831,7 @@
     return str;
 }
 
-static int adev_init_check(const struct audio_hw_device *dev)
+static int adev_init_check(const struct audio_hw_device *dev __unused)
 {
     return 0;
 }
@@ -2831,23 +2847,26 @@
     return ret;
 }
 
-static int adev_set_master_volume(struct audio_hw_device *dev, float volume)
+static int adev_set_master_volume(struct audio_hw_device *dev __unused,
+                                  float volume __unused)
 {
     return -ENOSYS;
 }
 
-static int adev_get_master_volume(struct audio_hw_device *dev,
-                                  float *volume)
+static int adev_get_master_volume(struct audio_hw_device *dev __unused,
+                                  float *volume __unused)
 {
     return -ENOSYS;
 }
 
-static int adev_set_master_mute(struct audio_hw_device *dev, bool muted)
+static int adev_set_master_mute(struct audio_hw_device *dev __unused,
+                                bool muted __unused)
 {
     return -ENOSYS;
 }
 
-static int adev_get_master_mute(struct audio_hw_device *dev, bool *muted)
+static int adev_get_master_mute(struct audio_hw_device *dev __unused,
+                                bool *muted __unused)
 {
     return -ENOSYS;
 }
@@ -2882,24 +2901,27 @@
     return 0;
 }
 
-static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev,
+static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev __unused,
                                          const struct audio_config *config)
 {
-    int channel_count = popcount(config->channel_mask);
+    int channel_count = audio_channel_count_from_in_mask(config->channel_mask);
 
     return get_input_buffer_size(config->sample_rate, config->format, channel_count);
 }
 
 static int adev_open_input_stream(struct audio_hw_device *dev,
-                                  audio_io_handle_t handle,
+                                  audio_io_handle_t handle __unused,
                                   audio_devices_t devices,
                                   struct audio_config *config,
-                                  struct audio_stream_in **stream_in)
+                                  struct audio_stream_in **stream_in,
+                                  audio_input_flags_t flags __unused,
+                                  const char *address __unused,
+                                  audio_source_t source __unused)
 {
     struct audio_device *adev = (struct audio_device *)dev;
     struct stream_in *in;
     int ret = 0, buffer_size, frame_size;
-    int channel_count = popcount(config->channel_mask);
+    int channel_count = audio_channel_count_from_in_mask(config->channel_mask);
 
 
     *stream_in = NULL;
@@ -2950,22 +2972,21 @@
 
     if (channel_count == 6) {
         if(audio_extn_ssr_get_enabled()) {
-            if(audio_extn_ssr_init(adev, in)) {
+            if(audio_extn_ssr_init(in)) {
                 ALOGE("%s: audio_extn_ssr_init failed", __func__);
                 ret = -EINVAL;
                 goto err_open;
             }
         } else {
-            ret = -EINVAL;
-            goto err_open;
+            ALOGW("%s: surround sound recording is not supported", __func__);
         }
     } else if (audio_extn_compr_cap_enabled() &&
             audio_extn_compr_cap_format_supported(config->format) &&
             (in->dev->mode != AUDIO_MODE_IN_COMMUNICATION)) {
-        audio_extn_compr_cap_init(adev, in);
+        audio_extn_compr_cap_init(in);
     } else {
         in->config.channels = channel_count;
-        frame_size = audio_stream_frame_size((struct audio_stream *)in);
+        frame_size = audio_stream_in_frame_size(&in->stream);
         buffer_size = get_input_buffer_size(config->sample_rate,
                                             config->format,
                                             channel_count);
@@ -2991,7 +3012,7 @@
 {
     int ret;
     struct stream_in *in = (struct stream_in *)stream;
-    struct audio_device *adev = in->dev;
+    struct audio_device *adev = (struct audio_device *)dev;
 
     ALOGD("%s: enter:stream_handle(%p)",__func__, in);
 
@@ -3005,7 +3026,8 @@
     } else
         in_standby(&stream->common);
 
-    if (audio_extn_ssr_get_enabled() && (popcount(in->channel_mask) == 6)) {
+    if (audio_extn_ssr_get_enabled() && 
+            (audio_channel_count_from_in_mask(in->channel_mask) == 6)) {
         audio_extn_ssr_deinit();
     }
 
@@ -3017,7 +3039,8 @@
     return;
 }
 
-static int adev_dump(const audio_hw_device_t *device, int fd)
+static int adev_dump(const audio_hw_device_t *device __unused,
+                     int fd __unused)
 {
     return 0;
 }
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 44caed4..bdb9aae 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -151,7 +151,7 @@
 
 struct stream_app_type_cfg {
     int sample_rate;
-    int bit_width;
+    uint32_t bit_width;
     int app_type;
 };
 
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 60ddb99..2cc923d 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -91,6 +91,7 @@
 
 #define AUDIO_PARAMETER_KEY_FLUENCE_TYPE  "fluence"
 #define AUDIO_PARAMETER_KEY_SLOWTALK      "st_enable"
+#define AUDIO_PARAMETER_KEY_HD_VOICE      "hd_voice"
 #define AUDIO_PARAMETER_KEY_VOLUME_BOOST  "volume_boost"
 
 enum {
@@ -122,6 +123,7 @@
     char fluence_cap[PROPERTY_VALUE_MAX];
     int  fluence_mode;
     bool slowtalk;
+    bool hd_voice;
     /* Audio calibration related functions */
     void                       *acdb_handle;
     int                        voice_feature_set;
@@ -719,6 +721,8 @@
     my_data->fluence_in_audio_rec = false;
     my_data->fluence_type = FLUENCE_NONE;
     my_data->fluence_mode = FLUENCE_ENDFIRE;
+    my_data->slowtalk = false;
+    my_data->hd_voice = false;
 
     property_get("ro.qc.sdk.audio.fluencetype", my_data->fluence_cap, "");
     if (!strncmp("fluencepro", my_data->fluence_cap, sizeof("fluencepro"))) {
@@ -1168,7 +1172,8 @@
     }
     return ret;
 }
-int platform_get_sample_rate(void *platform, uint32_t *rate)
+
+int platform_get_sample_rate(void *platform __unused, uint32_t *rate __unused)
 {
     return 0;
 }
@@ -1820,6 +1825,30 @@
     return ret;
 }
 
+static int set_hd_voice(struct platform_data *my_data, bool state)
+{
+    struct audio_device *adev = my_data->adev;
+    struct mixer_ctl *ctl;
+    const char *mixer_ctl_name = "HD Voice Enable";
+    int ret = 0;
+    uint32_t set_values[ ] = {0,
+                              ALL_SESSION_VSID};
+
+    set_values[0] = state;
+    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);
+        ret = -EINVAL;
+    } else {
+        ALOGV("Setting HD Voice state: %d", state);
+        ret = mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
+        my_data->hd_voice = state;
+    }
+
+    return ret;
+}
+
 int platform_set_parameters(void *platform, struct str_parms *parms)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
@@ -1827,8 +1856,11 @@
     char value[256] = {0};
     int val;
     int ret = 0, err;
+    char *kv_pairs = NULL;
 
-    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
+    kv_pairs = str_parms_to_str(parms);
+    ALOGV("%s: enter: - %s", __func__, kv_pairs);
+    free(kv_pairs);
 
     err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SLOWTALK, value, sizeof(value));
     if (err >= 0) {
@@ -1843,6 +1875,23 @@
             ALOGE("%s: Failed to set slow talk err: %d", __func__, ret);
     }
 
+    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HD_VOICE, value, sizeof(value));
+    if (err >= 0) {
+        bool state = false;
+        if (!strncmp("true", value, sizeof("true"))) {
+            state = true;
+        }
+
+        str_parms_del(parms, AUDIO_PARAMETER_KEY_HD_VOICE);
+        if (my_data->hd_voice != state) {
+            ret = set_hd_voice(my_data, state);
+            if (ret)
+                ALOGE("%s: Failed to set HD voice err: %d", __func__, ret);
+        } else {
+            ALOGV("%s: HD Voice already set to %d", __func__, state);
+        }
+    }
+
     err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST,
                             value, sizeof(value));
     if (err >= 0) {
@@ -1973,6 +2022,7 @@
     char *str = NULL;
     char value[256] = {0};
     int ret;
+    char *kv_pairs = NULL;
 
     ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_SLOWTALK,
                             value, sizeof(value));
@@ -1981,6 +2031,13 @@
                           my_data->slowtalk?"true":"false");
     }
 
+    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_HD_VOICE,
+                            value, sizeof(value));
+    if (ret >= 0) {
+        str_parms_add_str(reply, AUDIO_PARAMETER_KEY_HD_VOICE,
+                          my_data->hd_voice?"true":"false");
+    }
+
     ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOLUME_BOOST,
                             value, sizeof(value));
     if (ret >= 0) {
@@ -1993,7 +2050,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("%s: exit: returns - %s", __func__, kv_pairs);
+    free(kv_pairs);
 }
 
 /* Delay in Us */
@@ -2208,7 +2267,9 @@
     return false;
 }
 
-bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct audio_usecase *usecase) {
+bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev __unused,
+                                              struct audio_usecase *usecase __unused)
+{
     return false;
 }
 
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index a2d6e52..3274888 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -81,8 +81,6 @@
     int  fluence_type;
     int  dualmic_config;
 
-    void *hw_info;
-
     /* Audio calibration related functions */
     void *acdb_handle;
     acdb_init_t acdb_init;
@@ -129,6 +127,8 @@
     [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones",
     [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones",
     [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset",
+    [SND_DEVICE_OUT_USB_HEADSET] = "usb-headphones",
+    [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = "speaker-and-usb-headphones",
 
     /* Capture sound devices */
     [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
@@ -151,6 +151,7 @@
     [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic",
     [SND_DEVICE_IN_VOICE_REC_DMIC] = "voice-rec-dmic-ef",
     [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = "voice-rec-dmic-ef-fluence",
+    [SND_DEVICE_IN_USB_HEADSET_MIC] = "usb-headset-mic",
 };
 
 /* ACDB IDs (audio DSP path configuration IDs) for each sound device */
@@ -170,6 +171,8 @@
     [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17,
     [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17,
     [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37,
+    [SND_DEVICE_OUT_USB_HEADSET] = 45,
+    [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = 14,
 
     [SND_DEVICE_IN_HANDSET_MIC] = 4,
     [SND_DEVICE_IN_SPEAKER_MIC] = 4,
@@ -189,6 +192,7 @@
     [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36,
     [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16,
     [SND_DEVICE_IN_VOICE_REC_MIC] = 62,
+    [SND_DEVICE_IN_USB_HEADSET_MIC] = 44,
     /* TODO: Update with proper acdb ids */
     [SND_DEVICE_IN_VOICE_REC_DMIC] = 62,
     [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = 6,
@@ -231,10 +235,6 @@
     my_data = calloc(1, sizeof(struct platform_data));
 
     snd_card_name = mixer_get_name(adev->mixer);
-    my_data->hw_info = hw_info_init(snd_card_name);
-    if (!my_data->hw_info) {
-        ALOGE("%s: Failed to init hardware info", __func__);
-    }
 
     my_data->adev = adev;
     my_data->fluence_in_spkr_mode = false;
@@ -335,7 +335,6 @@
 {
     struct platform_data *my_data = (struct platform_data *)platform;
 
-    hw_info_deinit(my_data->hw_info);
     free(platform);
 }
 
@@ -354,7 +353,6 @@
 
     if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) {
         strlcpy(device_name, device_table[snd_device], DEVICE_NAME_MAX_SIZE);
-        hw_info_append_hw_type(my_data->hw_info, snd_device, device_name);
     } else {
         strlcpy(device_name, "", DEVICE_NAME_MAX_SIZE);
         return -EINVAL;
@@ -389,17 +387,73 @@
     return device_id;
 }
 
-int platform_get_snd_device_index(char *snd_device_index_name)
+int platform_get_snd_device_index(char *snd_device_index_name __unused)
 {
     return -ENODEV;
 }
 
-int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id)
+int platform_set_snd_device_acdb_id(snd_device_t snd_device __unused,
+                                    unsigned int acdb_id __unused)
 {
     return -ENODEV;
 }
 
-int platform_send_audio_calibration(void *platform, snd_device_t snd_device)
+uint32_t platform_get_compress_offload_buffer_size(audio_offload_info_t* info __unused)
+{
+    ALOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
+int platform_get_snd_device_acdb_id(snd_device_t snd_device __unused)
+{
+    ALOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
+int platform_switch_voice_call_enable_device_config(void *platform __unused,
+                                                    snd_device_t out_snd_device __unused,
+                                                    snd_device_t in_snd_device __unused)
+{
+    ALOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
+int platform_switch_voice_call_usecase_route_post(void *platform __unused,
+                                                  snd_device_t out_snd_device __unused,
+                                                  snd_device_t in_snd_device __unused)
+{
+    ALOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
+int platform_set_incall_recording_session_id(void *platform __unused,
+                                             uint32_t session_id __unused,
+                                             int rec_mode __unused)
+{
+    ALOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
+int platform_stop_incall_recording_usecase(void *platform __unused)
+{
+    ALOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
+int platform_get_sample_rate(void *platform __unused, uint32_t *rate __unused)
+{
+    ALOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
+int platform_get_default_app_type(void *platform __unused)
+{
+    ALOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
+int platform_send_audio_calibration(void *platform, snd_device_t snd_device,
+                                    int app_type __unused, int sample_rate __unused)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
     int acdb_dev_id, acdb_dev_type;
@@ -476,7 +530,7 @@
     return ret;
 }
 
-int platform_start_voice_call(void *platform)
+int platform_start_voice_call(void *platform, uint32_t vsid __unused)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
     int ret = 0;
@@ -496,7 +550,7 @@
     return ret;
 }
 
-int platform_stop_voice_call(void *platform)
+int platform_stop_voice_call(void *platform, uint32_t vsid __unused)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
     int ret = 0;
@@ -559,9 +613,9 @@
     return ret;
 }
 
-int platform_set_device_mute(void *platform, bool state, char *dir)
+int platform_set_device_mute(void *platform __unused, bool state __unused, char *dir __unused)
 {
-    LOGE("%s: Not implemented", __func__);
+    ALOGE("%s: Not implemented", __func__);
     return -ENOSYS;
 }
 
@@ -582,11 +636,11 @@
     if (mode == AUDIO_MODE_IN_CALL) {
         if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
             devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
-            if (adev->tty_mode == TTY_MODE_FULL)
+            if (adev->voice.tty_mode == TTY_MODE_FULL)
                 snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES;
-            else if (adev->tty_mode == TTY_MODE_VCO)
+            else if (adev->voice.tty_mode == TTY_MODE_VCO)
                 snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES;
-            else if (adev->tty_mode == TTY_MODE_HCO)
+            else if (adev->voice.tty_mode == TTY_MODE_HCO)
                 snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET;
             else
                 snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES;
@@ -676,10 +730,10 @@
             ALOGE("%s: No output device set for voice call", __func__);
             goto exit;
         }
-        if (adev->tty_mode != TTY_MODE_OFF) {
+        if (adev->voice.tty_mode != TTY_MODE_OFF) {
             if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
                 out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
-                switch (adev->tty_mode) {
+                switch (adev->voice.tty_mode) {
                 case TTY_MODE_FULL:
                     snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC;
                     break;
@@ -690,7 +744,7 @@
                     snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC;
                     break;
                 default:
-                    ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->tty_mode);
+                    ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode);
                 }
                 goto exit;
             }
@@ -850,7 +904,7 @@
     return 0;
 }
 
-int platform_edid_get_max_channels(void *platform)
+int platform_edid_get_max_channels(void *platform __unused)
 {
     FILE *file;
     struct audio_block_header header;
@@ -896,21 +950,23 @@
     return max_channels;
 }
 
-void platform_get_parameters(void *platform, struct str_parms *query,
-                             struct str_parms *reply)
+void platform_get_parameters(void *platform __unused,
+                             struct str_parms *query __unused,
+                             struct str_parms *reply __unused)
 {
-    LOGE("%s: Not implemented", __func__);
+    ALOGE("%s: Not implemented", __func__);
 }
 
-int platform_set_parameters(void *platform, struct str_parms *parms)
+int platform_set_parameters(void *platform __unused, struct str_parms *parms __unused)
 {
-    LOGE("%s: Not implemented", __func__);
+    ALOGE("%s: Not implemented", __func__);
     return -ENOSYS;
 }
 
-int platform_set_incall_recoding_session_id(void *platform, uint32_t session_id)
+int platform_set_incall_recoding_session_id(void *platform __unused,
+                                            uint32_t session_id __unused)
 {
-    LOGE("%s: Not implemented", __func__);
+    ALOGE("%s: Not implemented", __func__);
     return -ENOSYS;
 }
 
@@ -918,7 +974,19 @@
                         struct voice_session *session __unused,
                         enum voice_lch_mode lch_mode __unused)
 {
-    LOGE("%s: Not implemented", __func__);
+    ALOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
+int platform_start_incall_music_usecase(void *platform __unused)
+{
+    ALOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
+int platform_stop_incall_music_usecase(void *platform __unused)
+{
+    ALOGE("%s: Not implemented", __func__);
     return -ENOSYS;
 }
 
@@ -941,12 +1009,12 @@
     return usecase;
 }
 
-bool platform_listen_device_needs_event(snd_device_t snd_device)
+bool platform_listen_device_needs_event(snd_device_t snd_device __unused)
 {
     return false;
 }
 
-bool platform_listen_usecase_needs_event(audio_usecase_t uc_id)
+bool platform_listen_usecase_needs_event(audio_usecase_t uc_id __unused)
 {
     return false;
 }
@@ -955,7 +1023,9 @@
     return false;
 }
 
-bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct audio_usecase *usecase) {
+bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev __unused,
+                                              struct audio_usecase *usecase __unused)
+{
     return false;
 }
 
@@ -985,3 +1055,19 @@
 {
     return false;
 }
+
+int platform_set_fluence_type(void *platform __unused, char *value __unused)
+{
+    return -ENOSYS;
+}
+
+int platform_get_fluence_type(void *platform __unused, char *value __unused,
+                              uint32_t len __unused)
+{
+    return -ENOSYS;
+}
+
+uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info __unused)
+{
+    return 0;
+}
diff --git a/hal/msm8960/platform.h b/hal/msm8960/platform.h
index e326785..20984d8 100644
--- a/hal/msm8960/platform.h
+++ b/hal/msm8960/platform.h
@@ -55,9 +55,12 @@
     SND_DEVICE_OUT_HDMI,
     SND_DEVICE_OUT_SPEAKER_AND_HDMI,
     SND_DEVICE_OUT_BT_SCO,
+    SND_DEVICE_OUT_BT_SCO_WB,
     SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES,
     SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES,
     SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET,
+    SND_DEVICE_OUT_USB_HEADSET,
+    SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET,
     SND_DEVICE_OUT_END,
 
     /*
@@ -76,6 +79,7 @@
     SND_DEVICE_IN_VOICE_HEADSET_MIC,
     SND_DEVICE_IN_HDMI_MIC,
     SND_DEVICE_IN_BT_SCO_MIC,
+    SND_DEVICE_IN_BT_SCO_MIC_WB,
     SND_DEVICE_IN_CAMCORDER_MIC,
     SND_DEVICE_IN_VOICE_DMIC,
     SND_DEVICE_IN_VOICE_SPEAKER_DMIC,
@@ -86,6 +90,7 @@
     SND_DEVICE_IN_VOICE_REC_MIC,
     SND_DEVICE_IN_VOICE_REC_DMIC,
     SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE,
+    SND_DEVICE_IN_USB_HEADSET_MIC,
     SND_DEVICE_IN_END,
 
     SND_DEVICE_MAX = SND_DEVICE_IN_END,
@@ -96,7 +101,17 @@
 #define SOUND_CARD 0
 
 #define DEFAULT_OUTPUT_SAMPLING_RATE 48000
+
+#define ALL_SESSION_VSID                0xFFFFFFFF
+#define DEFAULT_MUTE_RAMP_DURATION_MS   20
+#define DEFAULT_VOLUME_RAMP_DURATION_MS 20
 #define MIXER_PATH_MAX_LENGTH 100
+
+#define MAX_VOL_INDEX 5
+#define MIN_VOL_INDEX 0
+#define percent_to_index(val, min, max) \
+            ((val) * ((max) - (min)) * 0.01 + (min) + .5)
+
 /*
  * tinyAlsa library interprets period size as number of frames
  * one frame = channel_count * sizeof (pcm sample)
@@ -106,7 +121,7 @@
  * the buffer size of an input/output stream
  */
 #define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960
-#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 8
+#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 4
 #define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240
 #define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2
 
@@ -118,6 +133,8 @@
 #define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
 #define AUDIO_CAPTURE_PERIOD_COUNT 2
 
+#define DEVICE_NAME_MAX_SIZE 128
+
 /* Define macro for Internal FM volume mixer */
 #define FM_RX_VOLUME "Internal FM RX Volume"
 
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 56ee9bb..cf26f68 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -90,6 +90,7 @@
 
 #define AUDIO_PARAMETER_KEY_FLUENCE_TYPE  "fluence"
 #define AUDIO_PARAMETER_KEY_SLOWTALK      "st_enable"
+#define AUDIO_PARAMETER_KEY_HD_VOICE      "hd_voice"
 #define AUDIO_PARAMETER_KEY_VOLUME_BOOST  "volume_boost"
 /* Query external audio device connection status */
 #define AUDIO_PARAMETER_KEY_EXT_AUDIO_DEVICE "ext_audio_device"
@@ -111,7 +112,7 @@
 
 /* Audio calibration related functions */
 typedef void (*acdb_deallocate_t)();
-typedef int  (*acdb_init_t)(char *, char *);
+typedef int  (*acdb_init_t)(const char *, char *);
 typedef void (*acdb_send_audio_cal_t)(int, int, int , int);
 typedef void (*acdb_send_voice_cal_t)(int, int);
 typedef int (*acdb_reload_vocvoltable_t)(int);
@@ -130,6 +131,7 @@
     int  fluence_mode;
     char fluence_cap[PROPERTY_VALUE_MAX];
     bool slowtalk;
+    bool hd_voice;
     bool is_i2s_ext_modem;
     /* Audio calibration related functions */
     void                       *acdb_handle;
@@ -674,7 +676,7 @@
     return plat_data->is_i2s_ext_modem;
 }
 
-static void set_platform_defaults(struct platform_data * my_data)
+static void set_platform_defaults()
 {
     int32_t dev;
     for (dev = 0; dev < SND_DEVICE_MAX; dev++) {
@@ -808,6 +810,8 @@
     my_data->external_mic = false;
     my_data->fluence_type = FLUENCE_NONE;
     my_data->fluence_mode = FLUENCE_ENDFIRE;
+    my_data->slowtalk = false;
+    my_data->hd_voice = false;
 
     property_get("ro.qc.sdk.audio.fluencetype", my_data->fluence_cap, "");
     if (!strncmp("fluencepro", my_data->fluence_cap, sizeof("fluencepro"))) {
@@ -902,7 +906,7 @@
 
 acdb_init_fail:
 
-    set_platform_defaults(my_data);
+    set_platform_defaults();
 
     /* Initialize ACDB ID's */
     if (my_data->is_i2s_ext_modem)
@@ -1031,7 +1035,7 @@
 
     for (i=0; i < len; i++) {
         const char* tn = table[i].name;
-        int32_t len = strlen(tn);
+        size_t len = strlen(tn);
         if (strncmp(tn, name, len) == 0) {
             if (strlen(name) != len) {
                 continue; // substring
@@ -1548,8 +1552,7 @@
                 snd_device = SND_DEVICE_OUT_ANC_FB_HEADSET;
             else
                 snd_device = SND_DEVICE_OUT_ANC_HEADSET;
-        }
-        else
+        } else
             snd_device = SND_DEVICE_OUT_HEADPHONES;
     } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
         if (my_data->external_spk_1)
@@ -1620,7 +1623,7 @@
         }
     }
 
-    if(snd_device != AUDIO_DEVICE_NONE)
+    if (snd_device != AUDIO_DEVICE_NONE)
         goto exit;
 
     if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) ||
@@ -1640,14 +1643,12 @@
                     snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC;
                     break;
                 default:
-                    ALOGE("%s: Invalid TTY mode (%#x)",
-                          __func__, adev->voice.tty_mode);
+                    ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode);
                 }
                 goto exit;
             }
         }
-        if (out_device & AUDIO_DEVICE_OUT_EARPIECE ||
-            out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
+        if (out_device & AUDIO_DEVICE_OUT_EARPIECE) {
             if (out_device & AUDIO_DEVICE_OUT_EARPIECE &&
                 audio_extn_should_use_handset_anc(channel_count)) {
                 snd_device = SND_DEVICE_IN_AANC_HANDSET_MIC;
@@ -1658,7 +1659,6 @@
                 set_echo_reference(adev, true);
             } else {
                 snd_device = SND_DEVICE_IN_VOICE_DMIC;
-                adev->acdb_settings |= DMIC_FLAG;
             }
         } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
             snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC;
@@ -1675,15 +1675,14 @@
                 else
                     snd_device = SND_DEVICE_IN_BT_SCO_MIC;
             }
-        } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
+        } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER ||
+                   out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
             if (my_data->fluence_type != FLUENCE_NONE &&
                 my_data->fluence_in_voice_call &&
                 my_data->fluence_in_spkr_mode) {
                 if(my_data->fluence_type & FLUENCE_QUAD_MIC) {
-                    adev->acdb_settings |= QMIC_FLAG;
                     snd_device = SND_DEVICE_IN_VOICE_SPEAKER_QMIC;
                 } else {
-                    adev->acdb_settings |= DMIC_FLAG;
                     if (my_data->fluence_mode == FLUENCE_BROADSIDE)
                        snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE;
                     else
@@ -1703,13 +1702,11 @@
         if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
             if (channel_count == 2) {
                 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_STEREO;
-                adev->acdb_settings |= DMIC_FLAG;
             } else if (adev->active_input->enable_ns)
                 snd_device = SND_DEVICE_IN_VOICE_REC_MIC_NS;
             else if (my_data->fluence_type != FLUENCE_NONE &&
                      my_data->fluence_in_voice_rec) {
                 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE;
-                adev->acdb_settings |= DMIC_FLAG;
             } else {
                 snd_device = SND_DEVICE_IN_VOICE_REC_MIC;
             }
@@ -1727,13 +1724,11 @@
                             snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE;
                         else
                             snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS;
-                        adev->acdb_settings |= DMIC_FLAG;
                     } else
                         snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC_NS;
                 } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
                     if (my_data->fluence_type & FLUENCE_DUAL_MIC) {
                         snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC_NS;
-                        adev->acdb_settings |= DMIC_FLAG;
                     } else
                         snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC_NS;
                 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
@@ -1748,13 +1743,11 @@
                             snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE;
                         else
                             snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC;
-                        adev->acdb_settings |= DMIC_FLAG;
                     } else
                         snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC;
                 } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
                     if (my_data->fluence_type & FLUENCE_DUAL_MIC) {
                         snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC;
-                        adev->acdb_settings |= DMIC_FLAG;
                     } else
                         snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC;
                 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
@@ -1769,13 +1762,11 @@
                             snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE;
                         else
                             snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS;
-                        adev->acdb_settings |= DMIC_FLAG;
                     } else
                         snd_device = SND_DEVICE_IN_SPEAKER_MIC_NS;
                 } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
                     if (my_data->fluence_type & FLUENCE_DUAL_MIC) {
                         snd_device = SND_DEVICE_IN_HANDSET_DMIC_NS;
-                        adev->acdb_settings |= DMIC_FLAG;
                     } else
                         snd_device = SND_DEVICE_IN_HANDSET_MIC_NS;
                 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
@@ -1850,13 +1841,12 @@
             snd_device = SND_DEVICE_IN_HANDSET_MIC;
         } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
             snd_device = SND_DEVICE_IN_HEADSET_MIC;
-        } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
-            if (channel_count > 1)
+        } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER ||
+                   out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
+            if (channel_count == 2)
                 snd_device = SND_DEVICE_IN_SPEAKER_STEREO_DMIC;
             else
                 snd_device = SND_DEVICE_IN_SPEAKER_MIC;
-        } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
-            snd_device = SND_DEVICE_IN_HANDSET_MIC;
         } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) {
             if (adev->bt_wb_speech_enabled) {
                 if (adev->bluetooth_nrec)
@@ -2005,6 +1995,29 @@
     return ret;
 }
 
+static int set_hd_voice(struct platform_data *my_data, bool state)
+{
+    struct audio_device *adev = my_data->adev;
+    struct mixer_ctl *ctl;
+    char *mixer_ctl_name = "HD Voice Enable";
+    int ret = 0;
+    uint32_t set_values[ ] = {0,
+                              ALL_SESSION_VSID};
+
+    set_values[0] = state;
+    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;
+    } else {
+        ALOGV("Setting HD Voice state: %d", state);
+        ret = mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
+        my_data->hd_voice = state;
+    }
+
+    return ret;
+}
 
 static int update_external_device_status(struct platform_data *my_data,
                                  char* event_name, bool status)
@@ -2058,6 +2071,23 @@
             ALOGE("%s: Failed to set slow talk err: %d", __func__, ret);
     }
 
+    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HD_VOICE, value, sizeof(value));
+    if (err >= 0) {
+        bool state = false;
+        if (!strncmp("true", value, sizeof("true"))) {
+            state = true;
+        }
+
+        str_parms_del(parms, AUDIO_PARAMETER_KEY_HD_VOICE);
+        if (my_data->hd_voice != state) {
+            ret = set_hd_voice(my_data, state);
+            if (ret)
+                ALOGE("%s: Failed to set HD voice err: %d", __func__, ret);
+        } else {
+            ALOGV("%s: HD Voice already set to %d", __func__, state);
+        }
+    }
+
     err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST,
                             value, sizeof(value));
     if (err >= 0) {
@@ -2086,9 +2116,9 @@
         ALOGV("%s: recieved update of external audio device %s %s",
                          __func__,
                          event_name, status_str);
-        if (!strncmp(status_str, "ON", sizeof(status_str)))
+        if (!strncmp(status_str, "ON", sizeof("ON")))
             status = true;
-        else if (!strncmp(status_str, "OFF", sizeof(status_str)))
+        else if (!strncmp(status_str, "OFF", sizeof("OFF")))
             status = false;
         update_external_device_status(my_data, event_name, status);
     }
@@ -2215,6 +2245,13 @@
                           my_data->slowtalk?"true":"false");
     }
 
+    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_HD_VOICE,
+                            value, sizeof(value));
+    if (ret >= 0) {
+        str_parms_add_str(reply, AUDIO_PARAMETER_KEY_HD_VOICE,
+                          my_data->hd_voice?"true":"false");
+    }
+
     ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOLUME_BOOST,
                             value, sizeof(value));
     if (ret >= 0) {
@@ -2460,7 +2497,7 @@
 }
 
 bool platform_check_codec_backend_cfg(struct audio_device* adev,
-                                   struct audio_usecase* usecase,
+                                   struct audio_usecase* usecase __unused,
                                    unsigned int* new_bit_width,
                                    unsigned int* new_sample_rate)
 {
diff --git a/hal/voice.c b/hal/voice.c
index 71fee64..ecad7a7 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -478,7 +478,7 @@
         adev->voice.session[i].pcm_tx = NULL;
         adev->voice.session[i].state.current = CALL_INACTIVE;
         adev->voice.session[i].state.new = CALL_INACTIVE;
-        adev->voice.session[i].vsid = 0;
+        adev->voice.session[i].vsid = VOICE_VSID;
     }
 
     voice_extn_init(adev);
diff --git a/hal/voice.h b/hal/voice.h
index 95609b3..9be8443 100644
--- a/hal/voice.h
+++ b/hal/voice.h
@@ -81,8 +81,8 @@
 void voice_get_parameters(struct audio_device *adev, struct str_parms *query,
                           struct str_parms *reply);
 void voice_init(struct audio_device *adev);
+bool voice_is_in_call(struct audio_device *adev);
 bool voice_is_in_call_rec_stream(struct stream_in *in);
-bool voice_is_call_state_active(struct audio_device *adev);
 int voice_set_mic_mute(struct audio_device *dev, bool state);
 bool voice_get_mic_mute(struct audio_device *dev);
 int voice_set_volume(struct audio_device *adev, float volume);
diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c
index 46aab7d..4ab141d 100644
--- a/hal/voice_extn/compress_voip.c
+++ b/hal/voice_extn/compress_voip.c
@@ -475,8 +475,7 @@
     return ret;
 }
 
-void voice_extn_compress_voip_get_parameters(const struct audio_device *adev,
-                                             struct str_parms *query,
+void voice_extn_compress_voip_get_parameters(struct str_parms *query,
                                              struct str_parms *reply)
 {
     int ret;
@@ -612,6 +611,7 @@
     if (!voip_data.in_stream_count)
         ret = voice_extn_compress_voip_open_input_stream(in);
 
+    adev->active_input = in;
     ret = voip_start_call(adev, &in->config);
     in->pcm = voip_data.pcm_tx;
 
@@ -670,6 +670,7 @@
     ALOGD("%s: enter", __func__);
 
     if(voip_data.in_stream_count > 0) {
+       adev->active_input = NULL;
        voip_data.in_stream_count--;
        status = voip_stop_call(adev);
        in->pcm = NULL;
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index dcbe825..8952522 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.c
@@ -508,7 +508,7 @@
     return ret;
 }
 
-int get_all_call_states_str(const struct audio_device *adev,
+static int get_all_call_states_str(const struct audio_device *adev,
                             char *value)
 {
     int ret = 0;
@@ -562,7 +562,7 @@
         }
         str_parms_add_str(reply, AUDIO_PARAMETER_KEY_ALL_CALL_STATES, value);
     }
-    voice_extn_compress_voip_get_parameters(adev, query, reply);
+    voice_extn_compress_voip_get_parameters(query, reply);
 
     str = str_parms_to_str(reply);
     ALOGV_IF(str != NULL, "%s: exit: returns \"%s\"", __func__, str);
diff --git a/hal/voice_extn/voice_extn.h b/hal/voice_extn/voice_extn.h
index 73da18a..15e5248 100644
--- a/hal/voice_extn/voice_extn.h
+++ b/hal/voice_extn/voice_extn.h
@@ -44,65 +44,65 @@
                                    struct str_parms *query,
                                    struct str_parms *reply);
 #else
-static int voice_extn_start_call(struct audio_device *adev)
+static int voice_extn_start_call(struct audio_device *adev __unused)
 {
     return -ENOSYS;
 }
 
-static int voice_extn_stop_call(struct audio_device *adev)
+static int voice_extn_stop_call(struct audio_device *adev __unused)
 {
     return -ENOSYS;
 }
 
-static int voice_extn_get_session_from_use_case(struct audio_device *adev,
-                                                const audio_usecase_t usecase_id,
-                                                struct voice_session **session)
+static int voice_extn_get_session_from_use_case(struct audio_device *adev __unused,
+                                                const audio_usecase_t usecase_id __unused,
+                                                struct voice_session **session __unused)
 {
     return -ENOSYS;
 }
 
-static void voice_extn_init(struct audio_device *adev)
+static void voice_extn_init(struct audio_device *adev __unused)
 {
 }
 
-static int voice_extn_set_parameters(struct audio_device *adev,
-                                     struct str_parms *parms)
+static int voice_extn_set_parameters(struct audio_device *adev __unused,
+                                     struct str_parms *parms __unused)
 {
     return -ENOSYS;
 }
 
-static void voice_extn_get_parameters(const struct audio_device *adev,
-                                      struct str_parms *query,
-                                      struct str_parms *reply)
+static void voice_extn_get_parameters(const struct audio_device *adev __unused,
+                                      struct str_parms *query __unused,
+                                      struct str_parms *reply __unused)
 {
 }
 
-static int voice_extn_is_call_state_active(struct audio_device *adev,
-                                           bool *is_call_active)
+static int voice_extn_is_call_state_active(struct audio_device *adev __unused,
+                                           bool *is_call_active __unused)
 {
     return -ENOSYS;
 }
 
-static int voice_extn_is_in_call_rec_stream(struct stream_in *in, bool *in_call_rec)
+static int voice_extn_is_in_call_rec_stream(struct stream_in *in __unused, bool *in_call_rec __unused)
 {
     return -ENOSYS;
 }
 
-static int voice_extn_get_active_session_id(struct audio_device *adev,
-                                            uint32_t *session_id)
+static int voice_extn_get_active_session_id(struct audio_device *adev __unused,
+                                            uint32_t *session_id __unused)
 {
     return -ENOSYS;
 }
 
-static void voice_extn_in_get_parameters(struct stream_in *in,
-                                         struct str_parms *query,
-                                         struct str_parms *reply)
+static void voice_extn_in_get_parameters(struct stream_in *in __unused,
+                                         struct str_parms *query __unused,
+                                         struct str_parms *reply __unused)
 {
 }
 
-static void voice_extn_out_get_parameters(struct stream_out *out,
-                                          struct str_parms *query,
-                                          struct str_parms *reply)
+static void voice_extn_out_get_parameters(struct stream_out *out __unused,
+                                          struct str_parms *query __unused,
+                                          struct str_parms *reply __unused)
 {
 }
 #endif
@@ -111,8 +111,8 @@
 int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev,
                                                   struct stream_out *out);
 #else
-static int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev,
-                                                         struct stream_out *out)
+static int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev __unused,
+                                                         struct stream_out *out __unused)
 {
     return -ENOSYS;
 }
@@ -138,8 +138,7 @@
                                             snd_device_t *in_snd_device);
 int voice_extn_compress_voip_set_parameters(struct audio_device *adev,
                                              struct str_parms *parms);
-void voice_extn_compress_voip_get_parameters(const struct audio_device *adev,
-                                             struct str_parms *query,
+void voice_extn_compress_voip_get_parameters(struct str_parms *query,
                                              struct str_parms *reply);
 
 void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
@@ -153,98 +152,97 @@
 bool voice_extn_compress_voip_is_format_supported(audio_format_t format);
 bool voice_extn_compress_voip_is_config_supported(struct audio_config *config);
 #else
-static int voice_extn_compress_voip_close_output_stream(struct audio_stream *stream)
+static int voice_extn_compress_voip_close_output_stream(struct audio_stream *stream __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return -ENOSYS;
 }
 
-static int voice_extn_compress_voip_open_output_stream(struct stream_out *out)
+static int voice_extn_compress_voip_open_output_stream(struct stream_out *out __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return -ENOSYS;
 }
 
-static int voice_extn_compress_voip_close_input_stream(struct audio_stream *stream)
+static int voice_extn_compress_voip_close_input_stream(struct audio_stream *stream __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return -ENOSYS;
 }
 
-static int voice_extn_compress_voip_open_input_stream(struct stream_in *in)
+static int voice_extn_compress_voip_open_input_stream(struct stream_in *in __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return -ENOSYS;
 }
 
-static int voice_extn_compress_voip_out_get_buffer_size(struct stream_out *stream)
+static int voice_extn_compress_voip_out_get_buffer_size(struct stream_out *stream __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return -ENOSYS;
 }
 
-static int voice_extn_compress_voip_in_get_buffer_size(struct stream_in *in)
+static int voice_extn_compress_voip_in_get_buffer_size(struct stream_in *in __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return -ENOSYS;
 }
 
-static int voice_extn_compress_voip_start_input_stream(struct stream_in *in)
+static int voice_extn_compress_voip_start_input_stream(struct stream_in *in __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return -ENOSYS;
 }
 
-static int voice_extn_compress_voip_start_output_stream(struct stream_out *out)
+static int voice_extn_compress_voip_start_output_stream(struct stream_out *out __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return -ENOSYS;
 }
 
-static int voice_extn_compress_voip_set_mic_mute(struct audio_device *adev, bool state)
+static int voice_extn_compress_voip_set_mic_mute(struct audio_device *adev, bool state __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return 0;
 }
 
-static int voice_extn_compress_voip_set_volume(struct audio_device *adev, float volume)
+static int voice_extn_compress_voip_set_volume(struct audio_device *adev __unused, float volume __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return 0;
 }
 
-static int voice_extn_compress_voip_select_devices(struct audio_device *adev,
-                                                   snd_device_t *out_snd_device,
-                                                   snd_device_t *in_snd_device)
+static int voice_extn_compress_voip_select_devices(struct audio_device *adev __unused,
+                                                   snd_device_t *out_snd_device __unused,
+                                                   snd_device_t *in_snd_device __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return -ENOSYS;
 }
 
-static int voice_extn_compress_voip_set_parameters(struct audio_device *adev,
-                                                    struct str_parms *parms)
+static int voice_extn_compress_voip_set_parameters(struct audio_device *adev __unused,
+                                                    struct str_parms *parms __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return -ENOSYS;
 }
 
-static void voice_extn_compress_voip_get_parameters(const struct audio_device *adev,
-                                                    struct str_parms *query,
-                                                    struct str_parms *reply)
+static void voice_extn_compress_voip_get_parameters(struct str_parms *query __unused,
+                                                    struct str_parms *reply __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
 }
 
-static void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
-                                                        struct str_parms *query,
-                                                        struct str_parms *reply)
+static void voice_extn_compress_voip_out_get_parameters(struct stream_out *out __unused,
+                                                        struct str_parms *query __unused,
+                                                        struct str_parms *reply __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
 }
 
-static void voice_extn_compress_voip_in_get_parameters(struct stream_in *in,
-                                                       struct str_parms *query,
-                                                       struct str_parms *reply)
+static void voice_extn_compress_voip_in_get_parameters(struct stream_in *in __unused,
+                                                       struct str_parms *query __unused,
+                                                       struct str_parms *reply __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
 }
@@ -255,19 +253,19 @@
     return false;
 }
 
-static bool voice_extn_compress_voip_is_active(struct audio_device *adev)
+static bool voice_extn_compress_voip_is_active(struct audio_device *adev __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return false;
 }
 
-static bool voice_extn_compress_voip_is_format_supported(audio_format_t format)
+static bool voice_extn_compress_voip_is_format_supported(audio_format_t format __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return true;
 }
 
-static bool voice_extn_compress_voip_is_config_supported(struct audio_config *config)
+static bool voice_extn_compress_voip_is_config_supported(struct audio_config *config __unused)
 {
     ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
     return true;