audio: hal: add customized external smart pa code
add customized external smart pa control code
Change-Id: I667648a98f887bc488827fada6a00f9f987ff513
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index d25dd0a..914c520 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -53,6 +53,7 @@
#include "voice_extn.h"
#include "sound/compress_params.h"
+#include "audio_extn/tfa_98xx.h"
/* COMPRESS_OFFLOAD_FRAGMENT_SIZE must be more than 8KB and a multiple of 32KB if more than 32KB.
* COMPRESS_OFFLOAD_FRAGMENT_SIZE * COMPRESS_OFFLOAD_NUM_FRAGMENTS must be less than 8MB. */
@@ -531,6 +532,18 @@
return id;
}
+static int audio_ssr_status(struct audio_device *adev)
+{
+ int ret = 0;
+ struct mixer_ctl *ctl;
+ const char *mixer_ctl_name = "Audio SSR Status";
+
+ ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+ ret = mixer_ctl_get_value(ctl, 0);
+ ALOGD("%s: value: %d", __func__, ret);
+ return ret;
+}
+
int enable_audio_route(struct audio_device *adev,
struct audio_usecase *usecase)
{
@@ -659,6 +672,8 @@
ALOGE("%s: device ref cnt is already 0", __func__);
return -EINVAL;
}
+ audio_extn_tfa_98xx_disable_speaker(snd_device);
+
adev->snd_dev_ref_cnt[snd_device]--;
if (adev->snd_dev_ref_cnt[snd_device] == 0) {
audio_extn_dsm_feedback_enable(adev, snd_device, false);
@@ -1169,6 +1184,8 @@
usecase->in_snd_device = in_snd_device;
usecase->out_snd_device = out_snd_device;
+ audio_extn_tfa_98xx_set_mode();
+
enable_audio_route(adev, usecase);
/* Applicable only on the targets that has external modem.
@@ -1226,6 +1243,9 @@
ALOGV("%s: enter: usecase(%d)", __func__, in->usecase);
+ if (audio_extn_tfa_98xx_is_supported() && !audio_ssr_status(adev))
+ return -EIO;
+
if (in->card_status == CARD_STATUS_OFFLINE ||
adev->card_status == CARD_STATUS_OFFLINE) {
ALOGW("in->card_status or adev->card_status offline, try again");
@@ -1718,6 +1738,8 @@
}
register_out_stream(out);
audio_extn_perf_lock_release();
+ audio_extn_tfa_98xx_enable_speaker();
+
ALOGV("%s: exit", __func__);
return ret;
error_open:
@@ -2022,6 +2044,7 @@
out->routing_change = true;
}
select_devices(adev, out->usecase);
+ audio_extn_tfa_98xx_update();
}
}
@@ -3262,7 +3285,11 @@
ALOGD("%s: state %d", __func__, (int)state);
pthread_mutex_lock(&adev->lock);
- ret = voice_set_mic_mute(adev, state);
+ if (audio_extn_tfa_98xx_is_supported() && adev->enable_hfp) {
+ ret = audio_extn_hfp_set_mic_mute(adev, state);
+ } else {
+ ret = voice_set_mic_mute(adev, state);
+ }
adev->mic_muted = state;
pthread_mutex_unlock(&adev->lock);
@@ -3304,6 +3331,9 @@
if (check_input_parameters(config->sample_rate, config->format, channel_count) != 0)
return -EINVAL;
+ if (audio_extn_tfa_98xx_is_supported() && audio_extn_hfp_is_active(adev))
+ return -EINVAL;
+
in = (struct stream_in *)calloc(1, sizeof(struct stream_in));
pthread_mutex_init(&in->lock, (const pthread_mutexattr_t *) NULL);
@@ -3602,6 +3632,8 @@
if (!adev)
return 0;
+ audio_extn_tfa_98xx_deinit();
+
audio_extn_snd_mon_unregister_listener(adev);
pthread_mutex_lock(&adev_init_lock);
@@ -3833,6 +3865,8 @@
ALOGV("new period_multiplier = %d", af_period_multiplier);
}
+ audio_extn_tfa_98xx_init(adev);
+
pthread_mutex_unlock(&adev_init_lock);
if (adev->adm_init)