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

Commit 4980fa1f authored by Anish Kumar's avatar Anish Kumar Committed by Gerrit - the friendly Code Review server
Browse files

hal: Set echo reference from mixer file

Set echo reference from mixer file.
Change-Id: I8b9d1209002ead0f82eb6052d41ab00ba41ce6a2
parent 8471e805
Loading
Loading
Loading
Loading
+8 −14
Original line number Original line Diff line number Diff line
@@ -193,20 +193,14 @@ static const int acdb_device_table[SND_DEVICE_MAX] = {
#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)


static int set_echo_reference(struct mixer *mixer, const char* ec_ref)
static void set_echo_reference(struct audio_device *adev, bool enable)
{
{
    struct mixer_ctl *ctl;
    if (enable)
    const char *mixer_ctl_name = "EC_REF_RX";
        audio_route_apply_and_update_path(adev->audio_route, "echo-reference");
    else
        audio_route_reset_and_update_path(adev->audio_route, "echo-reference");


    ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name);
    ALOGV("Setting EC Reference: %d", enable);
    if (!ctl) {
        ALOGE("%s: Could not get ctl for mixer cmd - %s",
              __func__, mixer_ctl_name);
        return -EINVAL;
    }
    ALOGV("Setting EC Reference: %s", ec_ref);
    mixer_ctl_set_enum_by_string(ctl, ec_ref);
    return 0;
}
}


void *platform_init(struct audio_device *adev)
void *platform_init(struct audio_device *adev)
@@ -748,9 +742,9 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC;
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC;
                }
                }
                set_echo_reference(adev->mixer, "SLIM_RX");
                set_echo_reference(adev, true);
            } else
            } else
                set_echo_reference(adev->mixer, "NONE");
                set_echo_reference(adev, false);
        }
        }
    } else if (source == AUDIO_SOURCE_DEFAULT) {
    } else if (source == AUDIO_SOURCE_DEFAULT) {
        goto exit;
        goto exit;
+12 −18
Original line number Original line Diff line number Diff line
@@ -436,20 +436,14 @@ struct snd_device_index snd_device_name_index[SND_DEVICE_MAX] = {
#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)


static int set_echo_reference(struct mixer *mixer, const char* ec_ref)
static void set_echo_reference(struct audio_device *adev, bool enable)
{
{
    struct mixer_ctl *ctl;
    if (enable)
    const char *mixer_ctl_name = "EC_REF_RX";
        audio_route_apply_and_update_path(adev->audio_route, "echo-reference");
    else
        audio_route_reset_and_update_path(adev->audio_route, "echo-reference");


    ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name);
    ALOGV("Setting EC Reference: %d", enable);
    if (!ctl) {
        ALOGE("%s: Could not get ctl for mixer cmd - %s",
              __func__, mixer_ctl_name);
        return -EINVAL;
    }
    ALOGV("Setting EC Reference: %s", ec_ref);
    mixer_ctl_set_enum_by_string(ctl, ec_ref);
    return 0;
}
}


static struct csd_data *open_csd_client(bool i2s_ext_modem)
static struct csd_data *open_csd_client(bool i2s_ext_modem)
@@ -1444,7 +1438,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
            } else if (my_data->fluence_type == FLUENCE_NONE ||
            } else if (my_data->fluence_type == FLUENCE_NONE ||
                my_data->fluence_in_voice_call == false) {
                my_data->fluence_in_voice_call == false) {
                snd_device = SND_DEVICE_IN_HANDSET_MIC;
                snd_device = SND_DEVICE_IN_HANDSET_MIC;
                set_echo_reference(adev->mixer, EC_REF_RX);
                set_echo_reference(adev, true);
            } else {
            } else {
                snd_device = SND_DEVICE_IN_VOICE_DMIC;
                snd_device = SND_DEVICE_IN_VOICE_DMIC;
                adev->acdb_settings |= DMIC_FLAG;
                adev->acdb_settings |= DMIC_FLAG;
@@ -1521,7 +1515,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                }
                }
                set_echo_reference(adev->mixer, EC_REF_RX);
                set_echo_reference(adev, true);
            } else if (adev->active_input->enable_aec) {
            } else if (adev->active_input->enable_aec) {
                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                    if (my_data->fluence_type & FLUENCE_DUAL_MIC &&
                    if (my_data->fluence_type & FLUENCE_DUAL_MIC &&
@@ -1542,7 +1536,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                }
                }
                set_echo_reference(adev->mixer, EC_REF_RX);
                set_echo_reference(adev, true);
            } else if (adev->active_input->enable_ns) {
            } else if (adev->active_input->enable_ns) {
                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                    if (my_data->fluence_type & FLUENCE_DUAL_MIC &&
                    if (my_data->fluence_type & FLUENCE_DUAL_MIC &&
@@ -1563,9 +1557,9 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                    snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
                }
                }
                set_echo_reference(adev->mixer, "NONE");
                set_echo_reference(adev, false);
            } else
            } else
                set_echo_reference(adev->mixer, "NONE");
                set_echo_reference(adev, false);
        }
        }
    } else if (source == AUDIO_SOURCE_MIC) {
    } else if (source == AUDIO_SOURCE_MIC) {
        if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC &&
        if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC &&
@@ -1573,7 +1567,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
            if(my_data->fluence_type & FLUENCE_DUAL_MIC &&
            if(my_data->fluence_type & FLUENCE_DUAL_MIC &&
                    my_data->fluence_in_audio_rec) {
                    my_data->fluence_in_audio_rec) {
                snd_device = SND_DEVICE_IN_HANDSET_DMIC;
                snd_device = SND_DEVICE_IN_HANDSET_DMIC;
                set_echo_reference(adev->mixer, EC_REF_RX);
                set_echo_reference(adev, true);
            }
            }
        }
        }
    } else if (source == AUDIO_SOURCE_FM_RX ||
    } else if (source == AUDIO_SOURCE_FM_RX ||