Merge "audio:hal: Fix compilation error on a2dp.c"
diff --git a/configs/sdm845/audio_policy_configuration.xml b/configs/sdm845/audio_policy_configuration.xml
index 9bb9486..024a471 100644
--- a/configs/sdm845/audio_policy_configuration.xml
+++ b/configs/sdm845/audio_policy_configuration.xml
@@ -323,7 +323,7 @@
<route type="mix" sink="Line"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,dsd_compress_passthrough,voip_rx,mmap_no_irq_out"/>
<route type="mix" sink="HDMI"
- sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,compress_passthrough"/>
+ sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,compress_passthrough,voip_rx"/>
<route type="mix" sink="Proxy"
sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload"/>
<route type="mix" sink="FM"
diff --git a/configs/sdm845/mixer_paths_tavil.xml b/configs/sdm845/mixer_paths_tavil.xml
index d5d2878..4a05733 100644
--- a/configs/sdm845/mixer_paths_tavil.xml
+++ b/configs/sdm845/mixer_paths_tavil.xml
@@ -229,6 +229,8 @@
<ctl name="VoiceMMode1_Tx Mixer AFE_PCM_TX_MMode1" value="0" />
<ctl name="USB_AUDIO_RX_Voice Mixer VoiceMMode1" value="0" />
<ctl name="VoiceMMode1_Tx Mixer USB_AUDIO_TX_MMode1" value="0" />
+ <!-- Multimode Voice1 Display-Port -->
+ <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode1" value="0" />
<!-- Miltimode Voice1 end-->
<!-- Multimode Voice2 -->
@@ -243,6 +245,8 @@
<ctl name="VoiceMMode2_Tx Mixer AFE_PCM_TX_MMode2" value="0" />
<ctl name="USB_AUDIO_RX_Voice Mixer VoiceMMode2" value="0" />
<ctl name="VoiceMMode2_Tx Mixer USB_AUDIO_TX_MMode2" value="0" />
+ <!-- Multimode Voice2 Display-Port -->
+ <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode2" value="0" />
<!-- Multimode Voice2 end-->
<!-- Voice external ec. reference -->
@@ -535,6 +539,10 @@
<ctl name="AUDIO_REF_EC_UL1 MUX" value="SLIM_6_RX" />
</path>
+ <path name="echo-reference display-port">
+ <ctl name="AUDIO_REF_EC_UL1 MUX" value="DISPLAY_PORT" />
+ </path>
+
<path name="echo-reference headphones-44.1">
</path>
@@ -1621,6 +1629,16 @@
<ctl name="VoiceMMode1_Tx Mixer USB_AUDIO_TX_MMode1" value="1" />
</path>
+ <path name="voicemmode1-call display-port-and-usb-headset-mic">
+ <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode1" value="1" />
+ <ctl name="VoiceMMode1_Tx Mixer USB_AUDIO_TX_MMode1" value="1" />
+ </path>
+
+ <path name="voicemmode1-call display-port">
+ <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode1" value="1" />
+ <ctl name="VoiceMMode1_Tx Mixer SLIM_0_TX_MMode1" value="1" />
+ </path>
+
<path name="voicemmode2-call">
<ctl name="SLIM_0_RX_Voice Mixer VoiceMMode2" value="1" />
<ctl name="VoiceMMode2_Tx Mixer SLIM_0_TX_MMode2" value="1" />
@@ -1656,6 +1674,16 @@
<ctl name="VoiceMMode2_Tx Mixer USB_AUDIO_TX_MMode2" value="1" />
</path>
+ <path name="voicemmode2-call display-port-and-usb-headset-mic">
+ <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode2" value="1" />
+ <ctl name="VoiceMMode2_Tx Mixer USB_AUDIO_TX_MMode2" value="1" />
+ </path>
+
+ <path name="voicemmode2-call display-port">
+ <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode2" value="1" />
+ <ctl name="VoiceMMode2_Tx Mixer SLIM_0_TX_MMode2" value="1" />
+ </path>
+
<!-- VoIP Rx settings -->
<path name="audio-playback-voip">
<ctl name="SLIMBUS_0_RX Audio Mixer MultiMedia10" value="1" />
diff --git a/configs/sdm845/sdm845.mk b/configs/sdm845/sdm845.mk
index 83751da..38a84c1 100644
--- a/configs/sdm845/sdm845.mk
+++ b/configs/sdm845/sdm845.mk
@@ -231,6 +231,9 @@
PRODUCT_PROPERTY_OVERRIDES += \
vendor.audio.adm.buffering.ms=2
+#enable use of display-port for voice usecases
+vendor.audio.enable.dp.for.voice=false
+
# for HIDL related packages
PRODUCT_PACKAGES += \
android.hardware.audio@2.0-service \
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index f39abf9..c5ee848 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -525,6 +525,7 @@
bool bt_sco_on;
struct audio_device_config_param *device_cfg_params;
unsigned int interactive_usecase_state;
+ bool dp_allowed_for_voice;
};
int select_devices(struct audio_device *adev,
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 4692e7f..891f262 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -136,6 +136,11 @@
/* Query external audio device connection status */
#define AUDIO_PARAMETER_KEY_EXT_AUDIO_DEVICE "ext_audio_device"
+/* Query whether it is ok to select display-port as output
+ * device for voice usecase
+ */
+#define AUDIO_PARAMETER_KEY_DP_FOR_VOICE_USECASE "dp_for_voice"
+
#define EVENT_EXTERNAL_SPK_1 "qc_ext_spk_1"
#define EVENT_EXTERNAL_SPK_2 "qc_ext_spk_2"
#define EVENT_EXTERNAL_MIC "qc_ext_mic"
@@ -1137,6 +1142,9 @@
else if (adev->snd_dev_ref_cnt[SND_DEVICE_OUT_SPEAKER_VBAT] > 0)
strlcpy(my_data->ec_ref_mixer_path, "echo-reference speaker-vbat",
sizeof(my_data->ec_ref_mixer_path));
+ else if (adev->snd_dev_ref_cnt[SND_DEVICE_OUT_DISPLAY_PORT] > 0)
+ strlcpy(my_data->ec_ref_mixer_path, "echo-reference display-port",
+ sizeof(my_data->ec_ref_mixer_path));
else
strlcpy(my_data->ec_ref_mixer_path, "echo-reference",
sizeof(my_data->ec_ref_mixer_path));
@@ -2017,6 +2025,9 @@
return NULL;
}
+ adev->dp_allowed_for_voice =
+ property_get_bool("vendor.audio.enable.dp.for.voice", false);
+
my_data->adev = adev;
my_data->fluence_in_spkr_mode = false;
my_data->fluence_in_voice_call = false;
@@ -2582,6 +2593,18 @@
if (suffix != NULL) {
strlcat(mixer_path, " ", MIXER_PATH_MAX_LENGTH);
strlcat(mixer_path, suffix, MIXER_PATH_MAX_LENGTH);
+
+ /* if we can use display-port for voice call and usb mic
+ * is connected, choose dp_rx, usb_tx audio route
+ */
+ if (usecase->type == VOICE_CALL) {
+ struct audio_device *adev = usecase->stream.out->dev;
+ if ((snd_device == SND_DEVICE_OUT_DISPLAY_PORT) &&
+ adev->dp_allowed_for_voice &&
+ (usecase->in_snd_device == SND_DEVICE_IN_VOICE_USB_HEADSET_MIC)) {
+ strlcat(mixer_path, "-and-usb-headset-mic", MIXER_PATH_MAX_LENGTH);
+ }
+ }
}
}
@@ -3773,6 +3796,17 @@
} else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
snd_device = SND_DEVICE_OUT_USB_HEADSET;
+ } else if ((devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) &&
+ adev->dp_allowed_for_voice) {
+ switch(my_data->ext_disp_type) {
+ case EXT_DISPLAY_TYPE_DP:
+ snd_device = SND_DEVICE_OUT_DISPLAY_PORT;
+ break;
+ default:
+ ALOGE("%s: Invalid disp_type %d", __func__,
+ my_data->ext_disp_type);
+ goto exit;
+ }
} else if (devices & AUDIO_DEVICE_OUT_FM_TX) {
snd_device = SND_DEVICE_OUT_TRANSMISSION_FM;
} else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
@@ -4127,6 +4161,15 @@
else
snd_device = SND_DEVICE_IN_BT_SCO_MIC;
}
+ } else if ((out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) &&
+ adev->dp_allowed_for_voice) {
+ if (audio_extn_usb_is_capture_supported())
+ snd_device = SND_DEVICE_IN_VOICE_USB_HEADSET_MIC;
+ else
+ snd_device = SND_DEVICE_IN_HANDSET_MIC;
+
+ if (voice_is_in_call(adev))
+ platform_set_echo_reference(adev, true, out_device);
} else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
if (my_data->fluence_type != FLUENCE_NONE &&
(my_data->fluence_in_voice_call ||
@@ -5083,6 +5126,7 @@
struct str_parms *reply)
{
struct platform_data *my_data = (struct platform_data *)platform;
+ struct audio_device *adev = my_data->adev;
char value[512] = {0};
int ret;
char *kv_pairs = NULL;
@@ -5115,6 +5159,19 @@
str_parms_add_str(reply, AUDIO_PARAMETER_KEY_VOLUME_BOOST, value);
}
+ ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_DP_FOR_VOICE_USECASE,
+ value, sizeof(value));
+
+ if (ret >= 0) {
+ if (my_data->ext_disp_type == EXT_DISPLAY_TYPE_DP &&
+ adev->dp_allowed_for_voice)
+ strlcpy(value, "true", sizeof(value));
+ else
+ strlcpy(value, "false", sizeof(value));
+
+ str_parms_add_str(reply, AUDIO_PARAMETER_KEY_DP_FOR_VOICE_USECASE, value);
+ }
+
/* Handle audio calibration keys */
get_audiocal(platform, query, reply);
native_audio_get_params(query, reply, value, sizeof(value));
diff --git a/hal/voice.c b/hal/voice.c
index b3645be..f9e3562 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -216,8 +216,16 @@
uc_info->id = usecase_id;
uc_info->type = VOICE_CALL;
- uc_info->stream.out = adev->current_call_output ;
- uc_info->devices = adev->current_call_output ->devices;
+ uc_info->stream.out = adev->current_call_output;
+ uc_info->devices = adev->current_call_output->devices;
+
+ if (popcount(uc_info->devices) == 2) {
+ ALOGE("%s: Invalid combo device(%#x) for voice call", __func__,
+ uc_info->devices);
+ ret = -EIO;
+ goto error_start_voice;
+ }
+
uc_info->in_snd_device = SND_DEVICE_NONE;
uc_info->out_snd_device = SND_DEVICE_NONE;
diff --git a/qahw/Makefile.am b/qahw/Makefile.am
index b6ebd8b..2f33c9f 100644
--- a/qahw/Makefile.am
+++ b/qahw/Makefile.am
@@ -15,6 +15,7 @@
libqahwwrapper_la_CFLAGS = $(AM_CFLAGS)
libqahwwrapper_la_CFLAGS += -include stddef.h
+libqahwwrapper_la_CFLAGS += -Dstrlcpy=g_strlcpy $(GLIB_CFLAGS) -include glib.h
libqahwwrapper_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\)
-libqahwwrapper_la_CFLAGS += -Werror
-libqahwwrapper_la_LDFLAGS = -shared -avoid-version -llog -lcutils -lhardware
+libqahwwrapper_la_CFLAGS += -Werror -Wall
+libqahwwrapper_la_LDFLAGS = -shared -avoid-version -llog -lcutils -lhardware $(GLIB_LIBS)
diff --git a/qahw/configure.ac b/qahw/configure.ac
index c87447e..04fde19 100644
--- a/qahw/configure.ac
+++ b/qahw/configure.ac
@@ -29,6 +29,22 @@
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
+AC_ARG_WITH([glib],
+ AC_HELP_STRING([--with-glib],
+ [enable glib, Build against glib. Use this when building for HLOS systems which use glib]))
+
+if (test "x${with_glib}" = "xyes"); then
+ PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
+ AC_MSG_ERROR(GThread >= 2.16 is required))
+ PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
+ AC_MSG_ERROR(GLib >= 2.16 is required))
+ GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
+ GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
+
+ AC_SUBST(GLIB_CFLAGS)
+ AC_SUBST(GLIB_LIBS)
+fi
+
AC_CONFIG_FILES([ \
Makefile
])