Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc23bfdf authored by Zheng Zhang's avatar Zheng Zhang Committed by android-build-merger
Browse files

audio: hal: add hfp volume control for smart pa

am: 0c0f53e2

Change-Id: Ib5146b633debae7236ebc57b8696ac4a839b62d7
parents 7723fe6e 0c0f53e2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ static int32_t hfp_set_volume(struct audio_device *adev, float value)
    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);
+22 −4
Original line number Diff line number Diff line
@@ -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 @@ typedef enum exTfa98xx_Func_Mode exTfa98xx_func_mode_t;

#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 @@ void audio_extn_tfa_98xx_disable_speaker(snd_device_t snd_device)
            }
        }

        if (data->adev->enable_hfp)
            data->set_speaker_volume_step(0, 0);

        tfa_98xx_disable_speaker();
    }

@@ -459,13 +465,25 @@ on_error:

}


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)
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ void audio_extn_tfa_98xx_disable_speaker(snd_device_t snd_device);
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);