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

Commit ceb286c3 authored by kunleiz's avatar kunleiz Committed by Gerrit - the friendly Code Review server
Browse files

hal: set different echo reference based on output device

1. Set specific echo reference when using different
   output device.
2. Set default echo reference when specific echo
   reference route path does not exist.

CRs-Fixed: 2366229
Change-Id: I0b75bf2a0ee54bb5110b663fb86482b939793c98
parent 70e57616
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -1473,7 +1473,7 @@ void platform_set_gsm_mode(void *platform, bool enable)
}

void platform_set_echo_reference(struct audio_device *adev, bool enable,
                                 audio_devices_t out_device __unused)
                                 audio_devices_t out_device)
{
    struct platform_data *my_data = (struct platform_data *)adev->platform;
    char ec_ref_mixer_path[MIXER_PATH_MAX_LENGTH] = "echo-reference";
@@ -1491,9 +1491,11 @@ void platform_set_echo_reference(struct audio_device *adev, bool enable,
            if (adev->mode == AUDIO_MODE_IN_COMMUNICATION)
                strlcat(ec_ref_mixer_path, "-voip", MIXER_PATH_MAX_LENGTH);    
        }        
        strlcpy(my_data->ec_ref_mixer_path, ec_ref_mixer_path,
                    MIXER_PATH_MAX_LENGTH);
        /*
         * If native audio device reference count > 0, then apply codec EC otherwise
         * fallback to Speakers with VBat if enabled or default
         * apply EC based on output device.
         */
        if (adev->snd_dev_ref_cnt[SND_DEVICE_OUT_HEADPHONES_44_1] > 0)
            strlcat(ec_ref_mixer_path, " headphones-44.1",
@@ -1504,12 +1506,24 @@ void platform_set_echo_reference(struct audio_device *adev, bool enable,
        else if (adev->snd_dev_ref_cnt[SND_DEVICE_OUT_DISPLAY_PORT] > 0)
            strlcat(ec_ref_mixer_path, " display-port",
                    MIXER_PATH_MAX_LENGTH);
        else if (out_device & AUDIO_DEVICE_OUT_EARPIECE)
            strlcat(ec_ref_mixer_path, " handset",
                    MIXER_PATH_MAX_LENGTH);
        else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE)
            strlcat(ec_ref_mixer_path, " headphones",
                    MIXER_PATH_MAX_LENGTH);
        else if (out_device & AUDIO_DEVICE_OUT_USB_HEADSET)
            strlcat(ec_ref_mixer_path, " usb-headphones",
                    MIXER_PATH_MAX_LENGTH);

        if (audio_route_apply_and_update_path(adev->audio_route,
                                              ec_ref_mixer_path) == 0)
            strlcpy(my_data->ec_ref_mixer_path, ec_ref_mixer_path,
                    MIXER_PATH_MAX_LENGTH);
        else
            audio_route_apply_and_update_path(adev->audio_route, my_data->ec_ref_mixer_path);

        ALOGD("%s: enabling %s", __func__, my_data->ec_ref_mixer_path);
        audio_route_apply_and_update_path(adev->audio_route, my_data->ec_ref_mixer_path);
    }
}