Merge "hal: Add support for Backend port specific channel map"
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 433743e..3b70c2b 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -2136,8 +2136,9 @@
void *hw_info = NULL;
struct mixer *mixer = NULL;
int retry_num = 0;
- int snd_card_num = 0, min_snd_card_num = 0;
+ int snd_card_num = 0;
char* snd_card_name = NULL;
+ int snd_card_detection_info[MAX_SND_CARD] = {0};
if (!mixer_handle) {
ALOGE("invalid mixer handle");
@@ -2145,26 +2146,29 @@
}
*mixer_handle = NULL;
/*
- * Try with all the sound cards ( 0 to 8 ) and if none of them were detected
+ * Try with all the sound cards ( 0 to 7 ) and if none of them were detected
* sleep for 1 sec and try detections with sound card 0 again.
* If sound card gets detected, check if it is relevant, if not check with the
* other sound cards. To ensure that the irrelevant sound card is not check again,
* we maintain it in min_snd_card_num.
*/
while (retry_num < RETRY_NUMBER) {
-
- while (snd_card_num <= MAX_SND_CARD) {
- mixer = mixer_open(snd_card_num);
- if (!mixer)
- snd_card_num++;
- else
- break;
+ snd_card_num = 0;
+ while (snd_card_num < MAX_SND_CARD) {
+ if (snd_card_detection_info[snd_card_num] == 0) {
+ mixer = mixer_open(snd_card_num);
+ if (!mixer)
+ snd_card_num++;
+ else
+ break;
+ } else
+ snd_card_num++;
}
if (!mixer) {
usleep(RETRY_US);
- snd_card_num = min_snd_card_num;
retry_num++;
+ ALOGD("%s: retry, retry_num %d", __func__, retry_num);
continue;
}
@@ -2175,18 +2179,13 @@
return -1;
}
ALOGD("%s: snd_card_name: %s", __func__, snd_card_name);
-
+ snd_card_detection_info[snd_card_num] = 1;
hw_info = hw_info_init(snd_card_name);
if (hw_info) {
ALOGD("%s: Opened sound card:%d", __func__, snd_card_num);
break;
}
- ALOGE("%s: Failed to init hardware info", __func__);
- min_snd_card_num++;
- snd_card_num = min_snd_card_num;
-
- if (snd_card_num >= MAX_SND_CARD)
- break;
+ ALOGE("%s: Failed to init hardware info, snd_card_num:%d", __func__, snd_card_num);
free(snd_card_name);
snd_card_name = NULL;
@@ -2200,7 +2199,7 @@
if (hw_info)
hw_info_deinit(hw_info);
- if ((snd_card_num >= MAX_SND_CARD) || (retry_num >= RETRY_NUMBER)) {
+ if (retry_num >= RETRY_NUMBER) {
ALOGE("%s: Unable to find correct sound card, aborting.", __func__);
return -1;
}
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 967afdc..8f27e86 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -7085,6 +7085,7 @@
struct listnode *node;
struct audio_usecase *usecase = NULL;
int ret = 0;
+
pthread_mutex_lock(&adev->lock);
if (adev->mode != mode) {
ALOGD("%s: mode %d\n", __func__, mode);
@@ -7111,6 +7112,11 @@
voice_stop_call(adev);
platform_set_gsm_mode(adev->platform, false);
adev->current_call_output = NULL;
+ // restore device for other active usecases after stop call
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ select_devices(adev, usecase->id);
+ }
}
}
pthread_mutex_unlock(&adev->lock);
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 575126c..72a1b41 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -4679,9 +4679,11 @@
} 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;
- }
+ if (audio_extn_usb_is_capture_supported()) {
+ snd_device = SND_DEVICE_IN_VOICE_USB_HEADSET_MIC;
+ } else {
+ snd_device = SND_DEVICE_IN_HANDSET_MIC;
+ }
}
} else if (my_data->use_generic_handset == true && // system prop is enabled
(my_data->source_mic_type & SOURCE_QUAD_MIC) && // AND 4mic is available