hal: enable speaker protection on APQ8084
-Enable speaker protection compilation flag to support
speaker protection feature for audio playback and voice
calls on APQ8084
-Append speaker-protected backend name to usecase only
for APQ8084 to differentiate with regular voice call as
routing controls are different.
Change-Id: I92ed26c9df0dc2f152e2bbf8b29362e32fff9844
diff --git a/hal/Android.mk b/hal/Android.mk
index 6522bec..87ebeea 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -90,7 +90,7 @@
endif
ifneq ($(strip, $(AUDIO_FEATURE_DISABLED_SPKR_PROTECTION)),true)
-ifneq ($(filter msm8974,$(TARGET_BOARD_PLATFORM)),)
+ifneq ($(filter msm8974 apq8084,$(TARGET_BOARD_PLATFORM)),)
LOCAL_CFLAGS += -DSPKR_PROT_ENABLED
LOCAL_SRC_FILES += audio_extn/spkr_protection.c
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 4787ab3..d6007be 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -305,13 +305,14 @@
if(SND_DEVICE_IN_USB_HEADSET_MIC == snd_device)
audio_extn_usb_start_capture(adev);
- if (snd_device == SND_DEVICE_OUT_SPEAKER &&
+ if ((snd_device == SND_DEVICE_OUT_SPEAKER ||
+ snd_device == SND_DEVICE_OUT_VOICE_SPEAKER) &&
audio_extn_spkr_prot_is_enabled()) {
- if (audio_extn_spkr_prot_start_processing(snd_device)) {
- ALOGE("%s: spkr_start_processing failed", __func__);
- return -EINVAL;
- }
- } else {
+ if (audio_extn_spkr_prot_start_processing(snd_device)) {
+ ALOGE("%s: spkr_start_processing failed", __func__);
+ return -EINVAL;
+ }
+ } else {
ALOGV("%s: snd_device(%d: %s)", __func__,
snd_device, device_name);
if (platform_send_audio_calibration(adev->platform, snd_device) < 0) {
@@ -364,7 +365,8 @@
if(SND_DEVICE_IN_USB_HEADSET_MIC == snd_device)
audio_extn_usb_stop_capture(adev);
- if (snd_device == SND_DEVICE_OUT_SPEAKER &&
+ if ((snd_device == SND_DEVICE_OUT_SPEAKER ||
+ snd_device == SND_DEVICE_OUT_VOICE_SPEAKER) &&
audio_extn_spkr_prot_is_enabled()) {
audio_extn_spkr_prot_stop_processing();
} else
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 0491d10..8777a73 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -839,6 +839,13 @@
strlcat(mixer_path, " capture-fm", MIXER_PATH_MAX_LENGTH);
else if (snd_device == SND_DEVICE_OUT_TRANSMISSION_FM)
strlcat(mixer_path, " transmission-fm", MIXER_PATH_MAX_LENGTH);
+ else if (snd_device == SND_DEVICE_OUT_VOICE_SPEAKER &&
+ audio_extn_spkr_prot_is_enabled() ) {
+ char platform[PROPERTY_VALUE_MAX];
+ property_get("ro.board.platform", platform, "");
+ if (!strncmp("apq8084", platform, sizeof("apq8084")))
+ strlcat(mixer_path, " speaker-protected", MIXER_PATH_MAX_LENGTH);
+ }
}
int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
@@ -997,21 +1004,28 @@
int acdb_rx_id, acdb_tx_id;
int ret = 0;
- acdb_rx_id = acdb_device_table[out_snd_device];
+ if (my_data->csd == NULL)
+ return ret;
+
+ if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER &&
+ audio_extn_spkr_prot_is_enabled())
+ acdb_rx_id = acdb_device_table[SND_DEVICE_OUT_SPEAKER_PROTECTED];
+ else
+ acdb_rx_id = acdb_device_table[out_snd_device];
+
acdb_tx_id = acdb_device_table[in_snd_device];
- if (my_data->csd != NULL) {
- if (acdb_rx_id > 0 && acdb_tx_id > 0) {
- ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id);
- if (ret < 0) {
- ALOGE("%s: csd_enable_device_config, failed, error %d",
- __func__, ret);
- }
- } else {
- ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
- acdb_rx_id, acdb_tx_id);
+ if (acdb_rx_id > 0 && acdb_tx_id > 0) {
+ ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id);
+ if (ret < 0) {
+ ALOGE("%s: csd_enable_device_config, failed, error %d",
+ __func__, ret);
}
+ } else {
+ ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
+ acdb_rx_id, acdb_tx_id);
}
+
return ret;
}
@@ -1046,22 +1060,28 @@
int acdb_rx_id, acdb_tx_id;
int ret = 0;
- acdb_rx_id = acdb_device_table[out_snd_device];
+ if (my_data->csd == NULL)
+ return ret;
+
+ if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER &&
+ audio_extn_spkr_prot_is_enabled())
+ acdb_rx_id = acdb_device_table[SND_DEVICE_OUT_SPEAKER_PROTECTED];
+ else
+ acdb_rx_id = acdb_device_table[out_snd_device];
+
acdb_tx_id = acdb_device_table[in_snd_device];
- if (my_data->csd != NULL) {
- if (acdb_rx_id > 0 && acdb_tx_id > 0) {
- ret = my_data->csd->enable_device(acdb_rx_id, acdb_tx_id,
- my_data->adev->acdb_settings);
- if (ret < 0) {
- ALOGE("%s: csd_enable_device, failed, error %d",
- __func__, ret);
- }
- } else {
- ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
- acdb_rx_id, acdb_tx_id);
+ if (acdb_rx_id > 0 && acdb_tx_id > 0) {
+ ret = my_data->csd->enable_device(acdb_rx_id, acdb_tx_id,
+ my_data->adev->acdb_settings);
+ if (ret < 0) {
+ ALOGE("%s: csd_enable_device, failed, error %d", __func__, ret);
}
+ } else {
+ ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
+ acdb_rx_id, acdb_tx_id);
}
+
return ret;
}