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

Commit 15003262 authored by Ravi Kumar Alamanda's avatar Ravi Kumar Alamanda Committed by Gerrit - the friendly Code Review server
Browse files

hal: ensure EC reference is disabled before enabling

Echo cancellation in DSP is not working after device switch
due to state mismatch between tinyalsa and the kernel.
Ensure that EC reference is disabled always before enabling
EC reference for the new device.

CRs-Fixed: 812996
Change-Id: Ia1152402990db836d3f94278a7d36726310dc60c
parent ac981711
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -794,7 +794,8 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
                out_snd_device = platform_get_output_snd_device(adev->platform,
                                            usecase->stream.out->devices);
                if (usecase->stream.out == adev->primary_output &&
                        adev->active_input) {
                        adev->active_input &&
                        out_snd_device != usecase->out_snd_device) {
                    select_devices(adev, adev->active_input->usecase);
                }
            }
@@ -808,6 +809,7 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
                     adev->active_input->source == AUDIO_SOURCE_MIC)) &&
                     adev->primary_output && !adev->primary_output->standby) {
                    out_device = adev->primary_output->devices;
                    platform_set_echo_reference(adev->platform, false);
                } else if (usecase->id == USECASE_AUDIO_RECORD_AFE_PROXY) {
                    out_device = AUDIO_DEVICE_OUT_TELEPHONY_TX;
                }
+8 −9
Original line number Diff line number Diff line
@@ -663,19 +663,18 @@ void platform_set_echo_reference(void *platform, bool enable)
    struct platform_data *my_data = (struct platform_data *)platform;
    struct audio_device *adev = my_data->adev;

    if (enable) {
        my_data->ec_ref_enabled = enable;
        audio_route_apply_and_update_path(adev->audio_route, "echo-reference");
    } else {
    if (my_data->ec_ref_enabled) {
        my_data->ec_ref_enabled = false;
        ALOGD("%s: disabling echo-reference", __func__);
        audio_route_reset_and_update_path(adev->audio_route, "echo-reference");
            my_data->ec_ref_enabled = enable;
        } else {
            ALOGV("EC reference is already disabled : %d", my_data->ec_ref_enabled);
    }

    if (enable) {
        my_data->ec_ref_enabled = true;
        ALOGD("%s: enabling echo-reference", __func__);
        audio_route_apply_and_update_path(adev->audio_route, "echo-reference");
    }

    ALOGV("Setting EC Reference: %d", enable);
}

static struct csd_data *open_csd_client()
+8 −9
Original line number Diff line number Diff line
@@ -588,19 +588,18 @@ void platform_set_echo_reference(void *platform, bool enable)
    struct platform_data *my_data = (struct platform_data *)platform;
    struct audio_device *adev = my_data->adev;

    if (enable) {
         my_data->ec_ref_enabled = enable;
         audio_route_apply_and_update_path(adev->audio_route, "echo-reference");
    } else {
    if (my_data->ec_ref_enabled) {
        my_data->ec_ref_enabled = false;
        ALOGV("%s: disabling echo-reference", __func__);
        audio_route_reset_and_update_path(adev->audio_route, "echo-reference");
             my_data->ec_ref_enabled = enable;
         } else {
             ALOGV("EC Reference is already disabled: %d", my_data->ec_ref_enabled);
    }

    if (enable) {
         my_data->ec_ref_enabled = true;
         ALOGD("%s: enabling echo-reference", __func__);
         audio_route_apply_and_update_path(adev->audio_route, "echo-reference");
    }

    ALOGV("Setting EC Reference: %d", enable);
}

static struct csd_data *open_csd_client(bool i2s_ext_modem)