audio: hal: add hfp volume control for smart pa am: 0c0f53e2ca am: cc23bfdfe7
am: b44dc70fd3
Change-Id: I88f21c393664fd7f92e2fe43908d67c5dc8495b9
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index 2ff7e54..07d5469 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -89,6 +89,7 @@
ALOGD("%s: (%f)\n", __func__, value);
hfpmod.hfp_volume = value;
+ audio_extn_tfa_98xx_set_voice_vol(value);
if (value < 0.0) {
ALOGW("%s: (%f) Under 0.0, assuming 0.0\n", __func__, value);
diff --git a/hal/audio_extn/tfa_98xx.c b/hal/audio_extn/tfa_98xx.c
index 7667410..6e9253a 100644
--- a/hal/audio_extn/tfa_98xx.c
+++ b/hal/audio_extn/tfa_98xx.c
@@ -23,6 +23,7 @@
#include <dlfcn.h>
#include "audio_extn.h"
#include <platform.h>
+#include <math.h>
#define LIB_SPEAKER_BUNDLE "/system/lib/libexTfa98xx.so"
@@ -48,6 +49,8 @@
#define I2S_CLOCK_ENABLE 1
#define I2S_CLOCK_DISABLE 0
+#define HFP_MAX_VOLUME (15.000000)
+#define TFA_98XX_HFP_VSETPS (5.0)
exTfa98xx_audio_mode_t current_audio_mode = Audio_Mode_None;
@@ -335,6 +338,9 @@
}
}
+ if (data->adev->enable_hfp)
+ data->set_speaker_volume_step(0, 0);
+
tfa_98xx_disable_speaker();
}
@@ -459,13 +465,25 @@
}
-
-void audio_extn_tfa_98xx_set_voice_vol(int vol)
+void audio_extn_tfa_98xx_set_voice_vol(float vol)
{
struct speaker_data *data = tfa98xx_speaker_data;
+ int vsteps = 0;
- if (data)
- data->set_speaker_volume_step(vol, vol);
+ if (data) {
+ if (data->adev->enable_hfp) {
+ if (vol < 0.0) {
+ vol = 0.0;
+ } else {
+ vol = ((vol > HFP_MAX_VOLUME) ? 1.0 : (vol / HFP_MAX_VOLUME));
+ }
+ vsteps = (int)floorf((1.0 - vol) * TFA_98XX_HFP_VSETPS);
+ } else {
+ return;
+ }
+ ALOGD("%s: vsteps %d\n", __func__, vsteps);
+ data->set_speaker_volume_step(vsteps, vsteps);
+ }
}
bool audio_extn_tfa_98xx_is_supported(void)
diff --git a/hal/audio_extn/tfa_98xx.h b/hal/audio_extn/tfa_98xx.h
index 3dab88f..444429a 100644
--- a/hal/audio_extn/tfa_98xx.h
+++ b/hal/audio_extn/tfa_98xx.h
@@ -23,7 +23,7 @@
void audio_extn_tfa_98xx_set_mode();
void audio_extn_tfa_98xx_set_mode_bt(void);
void audio_extn_tfa_98xx_update(void);
-void audio_extn_tfa_98xx_set_voice_vol(int vol);
+void audio_extn_tfa_98xx_set_voice_vol(float vol);
int audio_extn_tfa_98xx_init(struct audio_device *adev);
void audio_extn_tfa_98xx_deinit(void);
bool audio_extn_tfa_98xx_is_supported(void);