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/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;
}