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

Commit 225af833 authored by vivek mehta's avatar vivek mehta Committed by android-build-merger
Browse files

hal: retry failed MBDRC cal level am: fb4d7bd3 am: 1e36603d

am: 08f0520a

Change-Id: I8252e33621e5a28f881d91673993a7f849099d76
parents f3878bf6 08f0520a
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -233,6 +233,8 @@ static int set_voice_volume_l(struct audio_device *adev, float volume);
static struct audio_device *adev = NULL;
static pthread_mutex_t adev_init_lock;
static unsigned int audio_device_ref_count;
//cache last MBDRC cal step level
static int last_known_cal_step = -1 ;

static bool may_use_noirq_mode(struct audio_device *adev, audio_usecase_t uc_id,
                               int flags __unused)
@@ -380,6 +382,13 @@ bool audio_hw_send_gain_dep_calibration(int level) {
        pthread_mutex_lock(&adev->lock);
        ret_val = platform_send_gain_dep_cal(adev->platform, level);
        pthread_mutex_unlock(&adev->lock);

        // if cal set fails, cache level info
        // if cal set succeds, reset known last cal set
        if (!ret_val)
            last_known_cal_step = level;
        else if (last_known_cal_step != -1)
            last_known_cal_step = -1;
    } else {
        ALOGE("%s: %s is NULL", __func__, adev == NULL ? "adev" : "adev->platform");
    }
@@ -1995,6 +2004,11 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
            out->standby = true;
            goto exit;
        }

        if (last_known_cal_step != -1) {
            ALOGD("%s: retry previous failed cal level set", __func__);
            audio_hw_send_gain_dep_calibration(last_known_cal_step);
        }
    }

    if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD) {
+1 −1
Original line number Diff line number Diff line
@@ -599,7 +599,7 @@ static const char *get_operator_specific_device_mixer_path(snd_device_t snd_devi

bool platform_send_gain_dep_cal(void *platform __unused, int level __unused)
{
    return 0;
    return true;
}

void platform_set_echo_reference(struct audio_device *adev, bool enable,
+1 −1
Original line number Diff line number Diff line
@@ -1072,7 +1072,7 @@ int platform_swap_lr_channels(struct audio_device *adev, bool swap_channels)
bool platform_send_gain_dep_cal(void *platform __unused,
                                int level __unused)
{
    return 0;
    return true;
}

bool platform_can_split_snd_device(snd_device_t in_snd_device __unused,
+5 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@

#define AHAL_GAIN_DEPENDENT_INTERFACE_FUNCTION "audio_hw_send_gain_dep_calibration"
#define AHAL_GAIN_GET_MAPPING_TABLE "audio_hw_get_gain_level_mapping"
#define DEFAULT_CAL_STEP 0

enum {
    VOL_LISTENER_STATE_UNINITIALIZED,
@@ -232,7 +233,7 @@ static void check_and_set_gain_dep_cal()
    // 4. if new value is different than the current value then load new calibration

    struct listnode *node = NULL;
    float new_vol = 0.0;
    float new_vol = -1.0;
    int max_level = 0;
    vol_listener_context_t *context = NULL;
    if (dumping_enabled) {
@@ -261,7 +262,9 @@ static void check_and_set_gain_dep_cal()

            if (new_vol >= 1 && total_volume_cal_step > 0) { // max amplitude, use highest DRC level
                gain_dep_cal_level = volume_curve_gain_mapping_table[total_volume_cal_step - 1].level;
            } else if (new_vol <= 0) {
            } else if (new_vol == -1) {
                gain_dep_cal_level = DEFAULT_CAL_STEP;
            } else if (new_vol == 0) {
                gain_dep_cal_level = volume_curve_gain_mapping_table[0].level;
            } else {
                for (max_level = 0; max_level + 1 < total_volume_cal_step; max_level++) {