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

Commit 71c066dc authored by Avinash Vaish's avatar Avinash Vaish
Browse files

hal: Add suppprt for per vocoder calibration

Add an interface to support per vocoder calibration
by providing facility to query CVD version at the
time of platform initialization and send it to acdb
loader.

Change-Id: Ia0757e1e68d410607b3a75f032973c517a5387bb
parent 3707b707
Loading
Loading
Loading
Loading
+44 −3
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#define PLATFORM_INFO_XML_PATH      "/system/etc/audio_platform_info.xml"
#define LIB_ACDB_LOADER "libacdbloader.so"
#define AUDIO_DATA_BLOCK_MIXER_CTL "HDMI EDID"
#define CVD_VERSION_MIXER_CTL "CVD Version"

#define MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE (256 * 1024)
#define MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE (2 * 1024)
@@ -71,6 +72,7 @@
 */
#define MAX_SAD_BLOCKS      10
#define SAD_BLOCK_SIZE      3
#define MAX_CVD_VERSION_STRING_SIZE    100

/* EDID format ID for LPCM audio */
#define EDID_FORMAT_LPCM    1
@@ -103,7 +105,7 @@ struct audio_block_header

/* Audio calibration related functions */
typedef void (*acdb_deallocate_t)();
typedef int  (*acdb_init_t)(char *);
typedef int  (*acdb_init_t)(char *, char *);
typedef void (*acdb_send_audio_cal_t)(int, int, int, int);
typedef void (*acdb_send_voice_cal_t)(int, int);
typedef int (*acdb_reload_vocvoltable_t)(int);
@@ -611,6 +613,33 @@ void close_csd_client(struct csd_data *csd)
    }
}

void get_cvd_version(char *cvd_version, struct audio_device *adev)
{
    struct mixer_ctl *ctl;
    int count;
    int ret = 0;

    ctl = mixer_get_ctl_by_name(adev->mixer, CVD_VERSION_MIXER_CTL);
    if (!ctl) {
        ALOGE("%s: Could not get ctl for mixer cmd - %s",  __func__, CVD_VERSION_MIXER_CTL);
        goto done;
    }
    mixer_ctl_update(ctl);

    count = mixer_ctl_get_num_values(ctl);
    if (count > MAX_CVD_VERSION_STRING_SIZE)
        count = MAX_CVD_VERSION_STRING_SIZE;

    ret = mixer_ctl_get_array(ctl, cvd_version, count);
    if (ret != 0) {
        ALOGE("%s: ERROR! mixer_ctl_get_array() failed to get CVD Version", __func__);
        goto done;
    }

done:
    return;
}

void *platform_init(struct audio_device *adev)
{
    char platform[PROPERTY_VALUE_MAX];
@@ -620,6 +649,7 @@ void *platform_init(struct audio_device *adev)
    int retry_num = 0, snd_card_num = 0;
    const char *snd_card_name;
    char mixer_xml_path[100];
    char *cvd_version = NULL;

    my_data = calloc(1, sizeof(struct platform_data));

@@ -758,12 +788,23 @@ void *platform_init(struct audio_device *adev)

        my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle,
                                                    "acdb_loader_init_v2");
        if (my_data->acdb_init == NULL)
        if (my_data->acdb_init == NULL) {
            ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror());
            goto acdb_init_fail;
        }

        cvd_version = calloc(1, MAX_CVD_VERSION_STRING_SIZE);
        if (!cvd_version)
            ALOGE("Failed to allocate cvd version");
        else
            my_data->acdb_init(snd_card_name);
            get_cvd_version(cvd_version, adev);

        my_data->acdb_init(snd_card_name, cvd_version);
        if (cvd_version)
            free(cvd_version);
    }

acdb_init_fail:
    /* Initialize ACDB ID's */
    platform_info_init(PLATFORM_INFO_XML_PATH);