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

Commit f69e9ef0 authored by Samyak Jain's avatar Samyak Jain
Browse files

hal: add a single mixer control MIXER_SAMPLE_RATE_DEFAULT for a2dp

Audio not heard on a2dp playback in older devices
where different sampling rates for rx and tx is not supported

Add a single mixer control to update the sample rate irrespective of tx or rx,
update this when the tx and rx specific controls are not available

Change-Id: I9d365c9ab464a26ba6bef52ab2a1f6b4e10fe3dd
parent 0d1a5592
Loading
Loading
Loading
Loading
+64 −37
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@
#define MIXER_SCRAMBLER_MODE       "AFE Scrambler Mode"
#define MIXER_SAMPLE_RATE_RX       "BT SampleRate RX"
#define MIXER_SAMPLE_RATE_TX       "BT SampleRate TX"
#define MIXER_SAMPLE_RATE_DEFAULT  "BT SampleRate"
#define MIXER_AFE_IN_CHANNELS      "AFE Input Channels"
#define MIXER_ABR_TX_FEEDBACK_PATH "A2DP_SLIM7_UL_HL Switch"
#define MIXER_SET_FEEDBACK_CHANNEL "BT set feedback channel"
@@ -787,16 +788,14 @@ static int a2dp_set_backend_cfg()
    ALOGD("%s: set backend rx sample rate = %s", __func__, rate_str);
    ctl_sample_rate = mixer_get_ctl_by_name(a2dp.adev->mixer,
                                        MIXER_SAMPLE_RATE_RX);
    if (!ctl_sample_rate) {
        ALOGE("%s: ERROR backend sample rate mixer control not identifed", __func__);
        return -ENOSYS;
    }
    if (ctl_sample_rate) {

        if (mixer_ctl_set_enum_by_string(ctl_sample_rate, rate_str) != 0) {
            ALOGE("%s: Failed to set backend sample rate = %s", __func__, rate_str);
            return -ENOSYS;
        }

    // Set Tx backend sample rate
        /* Set Tx backend sample rate */
        if (a2dp.abr_config.is_abr_enabled)
        rate_str = ABR_TX_SAMPLE_RATE;

@@ -807,11 +806,26 @@ static int a2dp_set_backend_cfg()
                ALOGE("%s: ERROR backend sample rate mixer control not identifed", __func__);
                return -ENOSYS;
        }

        if (mixer_ctl_set_enum_by_string(ctl_sample_rate, rate_str) != 0) {
            ALOGE("%s: Failed to set backend sample rate = %s", __func__, rate_str);
            return -ENOSYS;
        }
    } else {
        /* Fallback to legacy approch if MIXER_SAMPLE_RATE_RX and
        MIXER_SAMPLE_RATE_TX is not supported */
        ctl_sample_rate = mixer_get_ctl_by_name(a2dp.adev->mixer,
                                        MIXER_SAMPLE_RATE_DEFAULT);
        if (!ctl_sample_rate) {
            ALOGE("%s: ERROR backend sample rate mixer control not identifed", __func__);
            return -ENOSYS;
        }

        if (mixer_ctl_set_enum_by_string(ctl_sample_rate, rate_str) != 0) {
        ALOGE("%s: Failed to set backend sample rate = %s",
                                    __func__, rate_str);
            ALOGE("%s: Failed to set backend sample rate = %s", __func__, rate_str);
            return -ENOSYS;
        }
    }

    //Configure AFE input channels
    switch (a2dp.enc_channels) {
@@ -849,10 +863,8 @@ static int a2dp_reset_backend_cfg()
    ALOGD("%s: reset backend sample rate = %s", __func__, rate_str);
    ctl_sample_rate_rx = mixer_get_ctl_by_name(a2dp.adev->mixer,
                                        MIXER_SAMPLE_RATE_RX);
    if (!ctl_sample_rate_rx) {
        ALOGE("%s: ERROR Rx backend sample rate mixer control not identifed", __func__);
        return -ENOSYS;
    }
    if (ctl_sample_rate_rx) {

        if (mixer_ctl_set_enum_by_string(ctl_sample_rate_rx, rate_str) != 0) {
            ALOGE("%s: Failed to reset Rx backend sample rate = %s", __func__, rate_str);
            return -ENOSYS;
@@ -864,10 +876,25 @@ static int a2dp_reset_backend_cfg()
                ALOGE("%s: ERROR Tx backend sample rate mixer control not identifed", __func__);
                return -ENOSYS;
        }

        if (mixer_ctl_set_enum_by_string(ctl_sample_rate_tx, rate_str) != 0) {
            ALOGE("%s: Failed to reset Tx backend sample rate = %s", __func__, rate_str);
            return -ENOSYS;
        }
    } else {

        ctl_sample_rate_rx = mixer_get_ctl_by_name(a2dp.adev->mixer,
                                        MIXER_SAMPLE_RATE_DEFAULT);
        if (!ctl_sample_rate_rx) {
            ALOGE("%s: ERROR backend sample rate mixer control not identifed", __func__);
            return -ENOSYS;
        }

        if (mixer_ctl_set_enum_by_string(ctl_sample_rate_rx, rate_str) != 0) {
            ALOGE("%s: Failed to reset backend sample rate = %s", __func__, rate_str);
            return -ENOSYS;
        }
    }

    // Reset AFE input channels
    ALOGD("%s: reset AFE input channels = %s", __func__, in_channels);