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

Commit 4362e3c1 authored by Steve Kondik's avatar Steve Kondik Committed by Ethan Chen
Browse files

hal: Add support for dedicated VoIP devices

 * Some devices out there have dedicated paths for VoIP, add support
   for these by setting the system property.

Change-Id: I59cd97e78427f811559081a04151c9a2eccf452f
parent 6047cd2b
Loading
Loading
Loading
Loading
+30 −3
Original line number Diff line number Diff line
@@ -203,6 +203,9 @@ static const char * const device_table[SND_DEVICE_MAX] = {
    [SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = "speaker-and-anc-headphones",
    [SND_DEVICE_OUT_ANC_HANDSET] = "anc-handset",
    [SND_DEVICE_OUT_SPEAKER_PROTECTED] = "speaker-protected",
    [SND_DEVICE_OUT_VOIP_HANDSET] = "voip-handset-comm",
    [SND_DEVICE_OUT_VOIP_SPEAKER] = "voip-speaker-comm",
    [SND_DEVICE_OUT_VOIP_HEADPHONES] = "voip-headset-comm",

    /* Capture sound devices */
    [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
@@ -247,6 +250,9 @@ static const char * const device_table[SND_DEVICE_MAX] = {
    [SND_DEVICE_IN_HANDSET_STEREO_DMIC] = "handset-stereo-dmic-ef",
    [SND_DEVICE_IN_SPEAKER_STEREO_DMIC] = "speaker-stereo-dmic-ef",
    [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = "vi-feedback",
    [SND_DEVICE_IN_VOIP_HANDSET_MIC] = "voip-main-mic-comm",
    [SND_DEVICE_IN_VOIP_SPEAKER_MIC] = "voip-sub-mic-comm",
    [SND_DEVICE_IN_VOIP_HEADSET_MIC] = "voip-headset-mic-comm",
};

/* ACDB IDs (audio DSP path configuration IDs) for each sound device */
@@ -1071,16 +1077,26 @@ snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devi
                    snd_device = SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET;
                else
                    snd_device = SND_DEVICE_OUT_VOICE_ANC_HEADSET;
            } else {
                if (voice_extn_compress_voip_is_active(adev) &&
                        voice_extn_dedicated_voip_device_prop_check()) {
                    snd_device = SND_DEVICE_OUT_VOIP_HEADPHONES;
                } else {
                    snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES;
                }
            }
        } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
            if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
                snd_device = SND_DEVICE_OUT_BT_SCO_WB;
            else
                snd_device = SND_DEVICE_OUT_BT_SCO;
        } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
            if (voice_extn_compress_voip_is_active(adev) &&
                    voice_extn_dedicated_voip_device_prop_check()) {
                snd_device = SND_DEVICE_OUT_VOIP_SPEAKER;
            } else {
                snd_device = SND_DEVICE_OUT_VOICE_SPEAKER;
            }
        } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
                   devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
            snd_device = SND_DEVICE_OUT_USB_HEADSET;
@@ -1091,6 +1107,9 @@ snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devi
        } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
            if (audio_extn_should_use_handset_anc(channel_count))
                snd_device = SND_DEVICE_OUT_ANC_HANDSET;
            else if (voice_extn_compress_voip_is_active(adev) &&
                    voice_extn_dedicated_voip_device_prop_check())
                snd_device = SND_DEVICE_OUT_VOIP_HANDSET;
            else
                snd_device = SND_DEVICE_OUT_VOICE_HANDSET;
        } else if (devices & AUDIO_DEVICE_OUT_TELEPHONY_TX)
@@ -1254,7 +1273,15 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
        if (out_device & AUDIO_DEVICE_OUT_SPEAKER)
            in_device = AUDIO_DEVICE_IN_BACK_MIC;
        if (adev->active_input) {
            if (adev->active_input->enable_aec &&
            if (voice_extn_dedicated_voip_device_prop_check()) {
                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                    snd_device = SND_DEVICE_IN_VOIP_SPEAKER_MIC;
                } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
                    snd_device = SND_DEVICE_IN_VOIP_HANDSET_MIC;
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_VOIP_HEADSET_MIC;
                }
            } else if (adev->active_input->enable_aec &&
                    adev->active_input->enable_ns) {
                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                    if (my_data->fluence_type & FLUENCE_DUAL_MIC &&
+6 −0
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ enum {
    SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET,
    SND_DEVICE_OUT_ANC_HANDSET,
    SND_DEVICE_OUT_SPEAKER_PROTECTED,
    SND_DEVICE_OUT_VOIP_HANDSET,
    SND_DEVICE_OUT_VOIP_SPEAKER,
    SND_DEVICE_OUT_VOIP_HEADPHONES,
    SND_DEVICE_OUT_END,

    /*
@@ -122,6 +125,9 @@ enum {
    SND_DEVICE_IN_HANDSET_STEREO_DMIC,
    SND_DEVICE_IN_SPEAKER_STEREO_DMIC,
    SND_DEVICE_IN_CAPTURE_VI_FEEDBACK,
    SND_DEVICE_IN_VOIP_HANDSET_MIC,
    SND_DEVICE_IN_VOIP_SPEAKER_MIC,
    SND_DEVICE_IN_VOIP_HEADSET_MIC,
    SND_DEVICE_IN_END,

    SND_DEVICE_MAX = SND_DEVICE_IN_END,
+14 −0
Original line number Diff line number Diff line
@@ -756,6 +756,20 @@ bool voice_extn_compress_voip_pcm_prop_check()
        return false;
}

bool voice_extn_dedicated_voip_device_prop_check()
{
    char prop_value[PROPERTY_VALUE_MAX] = {0};

    property_get("use.dedicated.device.for.voip", prop_value, "0");
    if (!strncmp("true", prop_value, sizeof("true")))
    {
        ALOGD("%s: Using dedicated path for VoIP", __func__);
        return true;
    }
    else
        return false;
}

bool voice_extn_compress_voip_is_active(struct audio_device *adev)
{
    struct audio_usecase *voip_usecase = NULL;
+7 −0
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@ void voice_extn_compress_voip_in_get_parameters(struct stream_in *in,
                                                struct str_parms *query,
                                                struct str_parms *reply);
bool voice_extn_compress_voip_pcm_prop_check();
bool voice_extn_dedicated_voip_device_prop_check();
bool voice_extn_compress_voip_is_active(struct audio_device *adev);
bool voice_extn_compress_voip_is_format_supported(audio_format_t format);
bool voice_extn_compress_voip_is_config_supported(struct audio_config *config);
@@ -255,6 +256,12 @@ static bool voice_extn_compress_voip_pcm_prop_check()
    return false;
}

static bool voice_extn_dedicated_voip_device_prop_check()
{
    ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
    return false;
}

static bool voice_extn_compress_voip_is_active(struct audio_device *adev __unused)
{
    ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);