Merge "configs: msm8998: Add support for right speaker as mono device" into audio-userspace.lnx.2.2-dev
diff --git a/hal/audio_extn/usb.c b/hal/audio_extn/usb.c
index f936f99..36fe484 100644
--- a/hal/audio_extn/usb.c
+++ b/hal/audio_extn/usb.c
@@ -854,8 +854,8 @@
     struct usb_card_config *card_info;
     bool is_usb_supported = false;
 
-    ALOGV("%s: from stream: bit-width(%d) sample_rate(%d) ch(%d)",
-           __func__, *bit_width, *sample_rate, *ch);
+    ALOGV("%s: from stream: bit-width(%d) sample_rate(%d) ch(%d) is_playback(%d)",
+           __func__, *bit_width, *sample_rate, *ch, is_playback);
     list_for_each(node_i, &usbmod->usb_card_conf_list) {
         card_info = node_to_item(node_i, struct usb_card_config, list);
         ALOGI_IF(usb_audio_debug_enable,
@@ -882,6 +882,7 @@
 {
     struct usb_card_config *usb_card_info;
     char check_debug_enable[PROPERTY_VALUE_MAX];
+    struct listnode *node_i;
 
     property_get("audio.usb.enable.debug", check_debug_enable, NULL);
     if (atoi(check_debug_enable)) {
@@ -902,6 +903,18 @@
         goto exit;
     }
 
+    list_for_each(node_i, &usbmod->usb_card_conf_list) {
+        usb_card_info = node_to_item(node_i, struct usb_card_config, list);
+        ALOGI_IF(usb_audio_debug_enable,
+                 "%s: list has capability for card_dev_type (0x%x), card_no(%d)",
+                 __func__,  usb_card_info->usb_device_type, usb_card_info->usb_card);
+        /* If we have cached the capability */
+        if ((usb_card_info->usb_device_type == device) && (usb_card_info->usb_card == card)) {
+            ALOGV("%s: capability for device(0x%x), card(%d) is cached, no need to update",
+                  __func__, device, card);
+            goto exit;
+        }
+    }
     usb_card_info = calloc(1, sizeof(struct usb_card_config));
     if (usb_card_info == NULL) {
         ALOGE("%s: error unable to allocate memory",
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index e2386a8..8abd13b 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -4404,7 +4404,8 @@
              */
             ret = str_parms_get_str(parms, "card", value, sizeof(value));
             if (ret >= 0) {
-                audio_extn_usb_add_device(val, atoi(value));
+                audio_extn_usb_add_device(AUDIO_DEVICE_OUT_USB_DEVICE, atoi(value));
+                audio_extn_usb_add_device(AUDIO_DEVICE_IN_USB_DEVICE, atoi(value));
             }
             ALOGV("detected USB connect .. disable proxy");
             adev->allow_afe_proxy_usage = false;