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

Commit 0f68be7d authored by Roopesh Nataraja's avatar Roopesh Nataraja Committed by Gerrit - the friendly Code Review server
Browse files

hal: Enable support to dynamically load config files

QCV allows multiple chipsets to be supported on a single
vendor. Enable support to dynamically get configuration
file path in vendor and load audio configuration files.

If 'ro.boot.product.vendor.sku' is not set, audio config
files would be loaded from /vendor/etc/.
If the property is set, files would be loaded from
/vendor/etc/audio/sku_{ro.boot.product.vendor.sku}.

'ro.boot.product.vendor.sku' would be set to SoC/SKU
at boot up in vendor.

Change-Id: Id228d94735b239e7608dfe84dd5f1eec7b016d2b
parent f51ddecf
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -115,6 +115,9 @@ int audio_extn_parse_compress_metadata(struct stream_out *out,

#define AUDIO_PARAMETER_KEY_HIFI_AUDIO_FILTER "hifi_filter"

#define VENDOR_CONFIG_PATH_MAX_LENGTH 128
#define VENDOR_CONFIG_FILE_MAX_LENGTH 128

struct snd_card_split {
    char device[HW_INFO_ARRAY_MAX_SIZE];
    char snd_card[HW_INFO_ARRAY_MAX_SIZE];
@@ -1402,4 +1405,6 @@ void audio_extn_set_custom_mtmx_params_v1(struct audio_device *adev,
snd_device_t audio_extn_get_loopback_snd_device(struct audio_device *adev,
                                                struct audio_usecase *usecase,
                                                int channel_count);

void audio_get_vendor_config_path(char* config_file_path, int path_size);
#endif /* AUDIO_EXTN_H */
+45 −10
Original line number Diff line number Diff line
@@ -54,13 +54,8 @@
#include "audio_parsers.h"
#endif

#ifdef LINUX_ENABLED
#define AUDIO_OUTPUT_POLICY_VENDOR_CONFIG_FILE "/etc/audio_output_policy.conf"
#define AUDIO_IO_POLICY_VENDOR_CONFIG_FILE "/etc/audio_io_policy.conf"
#else
#define AUDIO_OUTPUT_POLICY_VENDOR_CONFIG_FILE "/vendor/etc/audio_output_policy.conf"
#define AUDIO_IO_POLICY_VENDOR_CONFIG_FILE "/vendor/etc/audio_io_policy.conf"
#endif
#define AUDIO_IO_POLICY_VENDOR_CONFIG_FILE_NAME "audio_io_policy.conf"
#define AUDIO_OUTPUT_POLICY_VENDOR_CONFIG_FILE_NAME "audio_output_policy.conf"

#define OUTPUTS_TAG "outputs"
#define INPUTS_TAG "inputs"
@@ -517,6 +512,25 @@ static void send_app_type_cfg(void *platform, struct mixer *mixer,
    }
}

/* Function to retrieve audio vendor configs path */
void audio_get_vendor_config_path (char* config_file_path, int path_size)
{
    char vendor_sku[PROPERTY_VALUE_MAX] = {'\0'};
    if (property_get("ro.boot.product.vendor.sku", vendor_sku, "") <= 0) {
#ifdef LINUX_ENABLED
        /* Audio configs are stored in /etc */
        snprintf(config_file_path, path_size, "%s", "/etc");
#else
        /* Audio configs are stored in /vendor/etc */
        snprintf(config_file_path, path_size, "%s", "/vendor/etc");
#endif
    } else {
        /* Audio configs are stored in /vendor/etc/audio/sku_${vendor_sku} */
        snprintf(config_file_path, path_size,
            "%s%s", "/vendor/etc/audio/sku_", vendor_sku);
    }
}

void audio_extn_utils_update_streams_cfg_lists(void *platform,
                                    struct mixer *mixer,
                                    struct listnode *streams_output_cfg_list,
@@ -524,6 +538,9 @@ void audio_extn_utils_update_streams_cfg_lists(void *platform,
{
    cnode *root;
    char *data = NULL;
    char vendor_config_path[VENDOR_CONFIG_PATH_MAX_LENGTH];
    char audio_io_policy_file[VENDOR_CONFIG_FILE_MAX_LENGTH];
    char audio_output_policy_file[VENDOR_CONFIG_FILE_MAX_LENGTH];

    ALOGV("%s", __func__);
    list_init(streams_output_cfg_list);
@@ -535,11 +552,29 @@ void audio_extn_utils_update_streams_cfg_lists(void *platform,
        return;
    }

    data = (char *)load_file(AUDIO_IO_POLICY_VENDOR_CONFIG_FILE, NULL);
    /* Get path for audio configuration files in vendor */
    audio_get_vendor_config_path(vendor_config_path,
        sizeof(vendor_config_path));

    /* Get path for audio_io_policy_file in vendor */
    snprintf(audio_io_policy_file, sizeof(audio_io_policy_file),
        "%s/%s", vendor_config_path, AUDIO_IO_POLICY_VENDOR_CONFIG_FILE_NAME);

    /* Load audio_io_policy_file from vendor */
    data = (char *)load_file(audio_io_policy_file, NULL);

    if (data == NULL) {
        ALOGD("%s: failed to open io config file(%s), trying older config file",
              __func__, AUDIO_IO_POLICY_VENDOR_CONFIG_FILE);
        data = (char *)load_file(AUDIO_OUTPUT_POLICY_VENDOR_CONFIG_FILE, NULL);
              __func__, audio_io_policy_file);

        /* Get path for audio_output_policy_file in vendor */
        snprintf(audio_output_policy_file, sizeof(audio_output_policy_file),
            "%s/%s", vendor_config_path,
                AUDIO_OUTPUT_POLICY_VENDOR_CONFIG_FILE_NAME);

        /* Load audio_output_policy_file from vendor */
        data = (char *)load_file(audio_output_policy_file, NULL);

        if (data == NULL) {
            send_app_type_cfg(platform, mixer,
                              streams_output_cfg_list,