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

Commit 545dbd34 authored by Vidyakumar Athota's avatar Vidyakumar Athota
Browse files

hal: Add new CSD API to reduce in call device switch delay

New CSD api is added to reduce device switch delay during voice call.
This api is called before enabling the devices so that csd voice call
sequence on MDM can run in parallel with device enable configuration
on APQ.

Change-Id: I9239ff21e1c07370516d0ed668e1e94af12f9eb2
parent 2133453a
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -729,6 +729,15 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
        disable_snd_device(adev, usecase->in_snd_device, false);
    }

    /* Applicable only on the targets that has external modem.
     * New device information should be sent to modem before enabling
     * the devices to reduce in-call device switch time.
     */
    if (usecase->type == VOICE_CALL)
        status = platform_switch_voice_call_enable_device_config(adev->platform,
                                                                 out_snd_device,
                                                                 in_snd_device);

    /* Enable new sound devices */
    if (out_snd_device != SND_DEVICE_NONE) {
        if (usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND)
+33 −0
Original line number Diff line number Diff line
@@ -416,6 +416,13 @@ static struct csd_data *open_csd_client()
                  __func__, dlerror());
            goto error;
        }
        csd->enable_device_config = (enable_device_config_t)dlsym(csd->csd_client,
                                               "csd_client_enable_device_config");
        if (csd->enable_device_config == NULL) {
            ALOGE("%s: dlsym error %s for csd_client_enable_device_config",
                  __func__, dlerror());
            goto error;
        }
        csd->enable_device = (enable_device_t)dlsym(csd->csd_client,
                                             "csd_client_enable_device");
        if (csd->enable_device == NULL) {
@@ -831,6 +838,32 @@ int platform_switch_voice_call_device_pre(void *platform)
    return ret;
}

int platform_switch_voice_call_enable_device_config(void *platform,
                                                    snd_device_t out_snd_device,
                                                    snd_device_t in_snd_device)
{
    struct platform_data *my_data = (struct platform_data *)platform;
    int acdb_rx_id, acdb_tx_id;
    int ret = 0;

    acdb_rx_id = acdb_device_table[out_snd_device];
    acdb_tx_id = acdb_device_table[in_snd_device];

    if (my_data->csd != NULL) {
        if (acdb_rx_id > 0 && acdb_tx_id > 0) {
            ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id);
            if (ret < 0) {
                ALOGE("%s: csd_enable_device_config, failed, error %d",
                      __func__, ret);
            }
        } else {
            ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
                  acdb_rx_id, acdb_tx_id);
        }
    }
    return ret;
}

int platform_switch_voice_call_device_post(void *platform,
                                           snd_device_t out_snd_device,
                                           snd_device_t in_snd_device)
+2 −0
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ enum {
typedef int (*init_t)();
typedef int (*deinit_t)();
typedef int (*disable_device_t)();
typedef int (*enable_device_config_t)(int, int);
typedef int (*enable_device_t)(int, int, uint32_t);
typedef int (*volume_t)(uint32_t, int);
typedef int (*mic_mute_t)(uint32_t, int);
@@ -234,6 +235,7 @@ struct csd_data {
    init_t init;
    deinit_t deinit;
    disable_device_t disable_device;
    enable_device_config_t enable_device_config;
    enable_device_t enable_device;
    volume_t volume;
    mic_mute_t mic_mute;
+3 −0
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@ int platform_get_snd_device_index(char *snd_device_index_name);
int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id);
int platform_send_audio_calibration(void *platform, snd_device_t snd_device);
int platform_switch_voice_call_device_pre(void *platform);
int platform_switch_voice_call_enable_device_config(void *platform,
                                                    snd_device_t out_snd_device,
                                                    snd_device_t in_snd_device);
int platform_switch_voice_call_device_post(void *platform,
                                           snd_device_t out_snd_device,
                                           snd_device_t in_snd_device);