audio hal: add support for USB_HEADSET device
Add support for USB_HEADSET device in device selection logic where
only USB_DEVICE was supported so far.
Bug: 36220140
Test: check music/video playback, voice/VoIP calls, OK google and
Camcorder with and without USB headset
Change-Id: Ia1a241b9a9cdec6c48c0596a057fabac30b1b16f
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 3ad965e..e5a8854 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1266,7 +1266,7 @@
/* Enable new sound devices */
if (out_snd_device != SND_DEVICE_NONE) {
if ((usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) ||
- (usecase->devices & AUDIO_DEVICE_OUT_USB_DEVICE))
+ (usecase->devices & (AUDIO_DEVICE_OUT_USB_DEVICE|AUDIO_DEVICE_OUT_USB_HEADSET)))
check_and_route_playback_usecases(adev, usecase, out_snd_device);
enable_snd_device(adev, out_snd_device);
}
@@ -3885,17 +3885,17 @@
ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value, sizeof(value));
if (ret >= 0) {
audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10);
- if (device == AUDIO_DEVICE_OUT_USB_DEVICE) {
+ if (audio_is_usb_out_device(device)) {
ret = str_parms_get_str(parms, "card", value, sizeof(value));
if (ret >= 0) {
const int card = atoi(value);
- audio_extn_usb_add_device(AUDIO_DEVICE_OUT_USB_DEVICE, card);
+ audio_extn_usb_add_device(device, card);
}
- } else if (device == AUDIO_DEVICE_IN_USB_DEVICE) {
+ } else if (audio_is_usb_in_device(device)) {
ret = str_parms_get_str(parms, "card", value, sizeof(value));
if (ret >= 0) {
const int card = atoi(value);
- audio_extn_usb_add_device(AUDIO_DEVICE_IN_USB_DEVICE, card);
+ audio_extn_usb_add_device(device, card);
}
}
}
@@ -3903,18 +3903,18 @@
ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, value, sizeof(value));
if (ret >= 0) {
audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10);
- if (device == AUDIO_DEVICE_OUT_USB_DEVICE) {
+ if (audio_is_usb_out_device(device)) {
ret = str_parms_get_str(parms, "card", value, sizeof(value));
if (ret >= 0) {
const int card = atoi(value);
- audio_extn_usb_remove_device(AUDIO_DEVICE_OUT_USB_DEVICE, card);
+ audio_extn_usb_remove_device(device, card);
}
- } else if (device == AUDIO_DEVICE_IN_USB_DEVICE) {
+ } else if (audio_is_usb_in_device(device)) {
ret = str_parms_get_str(parms, "card", value, sizeof(value));
if (ret >= 0) {
const int card = atoi(value);
- audio_extn_usb_remove_device(AUDIO_DEVICE_IN_USB_DEVICE, card);
+ audio_extn_usb_remove_device(device, card);
}
}
}
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 545b209..58f7927 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -2282,8 +2282,10 @@
snd_device = adev->bt_wb_speech_enabled ?
SND_DEVICE_OUT_SPEAKER_AND_BT_SCO_WB :
SND_DEVICE_OUT_SPEAKER_AND_BT_SCO;
- } else if (devices == (AUDIO_DEVICE_OUT_USB_DEVICE |
- AUDIO_DEVICE_OUT_SPEAKER)) {
+ } else if ((devices == (AUDIO_DEVICE_OUT_USB_DEVICE |
+ AUDIO_DEVICE_OUT_SPEAKER)) ||
+ (devices == (AUDIO_DEVICE_OUT_USB_HEADSET |
+ AUDIO_DEVICE_OUT_SPEAKER))) {
snd_device = SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET;
} else if (devices == (AUDIO_DEVICE_OUT_USB_DEVICE |
AUDIO_DEVICE_OUT_SPEAKER_SAFE)) {
@@ -2321,7 +2323,7 @@
else
snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES;
}
- } else if (devices & AUDIO_DEVICE_OUT_USB_DEVICE) {
+ } else if (audio_is_usb_out_device(devices)) {
if (voice_is_in_call(adev)) {
switch (adev->voice.tty_mode) {
case TTY_MODE_FULL:
@@ -2393,7 +2395,7 @@
}
} else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
snd_device = SND_DEVICE_OUT_HDMI ;
- } else if (devices & AUDIO_DEVICE_OUT_USB_DEVICE) {
+ } else if (audio_is_usb_out_device(devices)) {
if (audio_extn_usb_is_capture_supported())
snd_device = SND_DEVICE_OUT_USB_HEADSET;
else
@@ -2450,7 +2452,7 @@
ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode);
}
goto exit;
- } else if (out_device & AUDIO_DEVICE_OUT_USB_DEVICE) {
+ } else if (out_device & (AUDIO_DEVICE_OUT_USB_DEVICE|AUDIO_DEVICE_OUT_USB_HEADSET)) {
switch (adev->voice.tty_mode) {
case TTY_MODE_FULL:
snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_USB_MIC;
@@ -2514,7 +2516,7 @@
}
} else if (out_device & AUDIO_DEVICE_OUT_TELEPHONY_TX) {
snd_device = SND_DEVICE_IN_VOICE_RX;
- } else if (out_device & AUDIO_DEVICE_OUT_USB_DEVICE) {
+ } else if (out_device & (AUDIO_DEVICE_OUT_USB_DEVICE|AUDIO_DEVICE_OUT_USB_HEADSET)) {
if (audio_extn_usb_is_capture_supported()) {
snd_device = SND_DEVICE_IN_VOICE_USB_HEADSET_MIC;
}
@@ -2574,7 +2576,7 @@
}
} else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
snd_device = SND_DEVICE_IN_VOICE_REC_HEADSET_MIC;
- } else if (in_device & AUDIO_DEVICE_IN_USB_DEVICE) {
+ } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_VOICE_RECOG_USB_HEADSET_MIC;
}
} else if (source == AUDIO_SOURCE_UNPROCESSED) {
@@ -2594,7 +2596,7 @@
}
} else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
snd_device = SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC;
- } else if (in_device & AUDIO_DEVICE_IN_USB_DEVICE) {
+ } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_UNPROCESSED_USB_HEADSET_MIC;
}
} else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
@@ -2621,7 +2623,7 @@
}
} else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC;
- } else if (in_device & AUDIO_DEVICE_IN_USB_DEVICE) {
+ } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC_AEC;
}
platform_set_echo_reference(adev, true, out_device);
@@ -2643,7 +2645,7 @@
}
} else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC;
- } else if (in_device & AUDIO_DEVICE_IN_USB_DEVICE) {
+ } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC_AEC;
}
platform_set_echo_reference(adev, true, out_device);
@@ -2726,7 +2728,7 @@
}
} else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) {
snd_device = SND_DEVICE_IN_HDMI_MIC;
- } else if (in_device & AUDIO_DEVICE_IN_USB_DEVICE ) {
+ } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
} else {
ALOGE("%s: Unknown input device(s) %#x", __func__, in_device);
@@ -2768,7 +2770,7 @@
}
} else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
snd_device = SND_DEVICE_IN_HDMI_MIC;
- } else if (out_device & AUDIO_DEVICE_OUT_USB_DEVICE) {
+ } else if (out_device & (AUDIO_DEVICE_OUT_USB_DEVICE|AUDIO_DEVICE_OUT_USB_HEADSET)) {
if (audio_extn_usb_is_capture_supported())
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
else