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

Commit 71530c58 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "audio: limit sampling rates to 192Khz for WCD9380 varient."

parents eeec053f 9d0d8e47
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -859,6 +859,7 @@ int b64decode(char *inp, int ilen, uint8_t* outp);
int b64encode(uint8_t *inp, int ilen, char* outp);
int read_line_from_file(const char *path, char *buf, size_t count);
int audio_extn_utils_get_codec_version(const char *snd_card_name, int card_num, char *codec_version);
int audio_extn_utils_get_codec_variant(int card_num, char *codec_variant);
audio_format_t alsa_format_to_hal(uint32_t alsa_format);
uint32_t hal_format_to_alsa(audio_format_t hal_format);
audio_format_t pcm_format_to_hal(uint32_t pcm_format);
+21 −0
Original line number Diff line number Diff line
@@ -1860,6 +1860,27 @@ int audio_extn_utils_get_codec_version(const char *snd_card_name,
    return 0;
}

int audio_extn_utils_get_codec_variant(int card_num,
                            char *codec_variant)
{
    char procfs_path[50];
    FILE *fp;
    snprintf(procfs_path, sizeof(procfs_path),
             "/proc/asound/card%d/codecs/wcd938x/variant", card_num);
    if ((fp = fopen(procfs_path, "r")) == NULL) {
        snprintf(procfs_path, sizeof(procfs_path),
                 "/proc/asound/card%d/codecs/wcd937x/variant", card_num);
        if ((fp = fopen(procfs_path, "r")) == NULL) {
            ALOGE("%s: ERROR. cannot open %s", __func__, procfs_path);
            return -ENOENT;
        }
    }
    fgets(codec_variant, CODEC_VARIANT_MAX_LENGTH, fp);
    fclose(fp);
    ALOGD("%s: codec variant is %s", __func__, codec_variant);
    return 0;
}


#ifdef AUDIO_EXTERNAL_HDMI_ENABLED

+18 −0
Original line number Diff line number Diff line
@@ -335,6 +335,7 @@ struct platform_data {
    char ec_ref_mixer_path[MIXER_PATH_MAX_LENGTH];
    codec_backend_cfg_t current_backend_cfg[MAX_CODEC_BACKENDS];
    char codec_version[CODEC_VERSION_MAX_LENGTH];
    char codec_variant[CODEC_VARIANT_MAX_LENGTH];
    int hw_dep_fd;
    char cvd_version[MAX_CVD_VERSION_STRING_SIZE];
    char snd_card_name[MAX_SND_CARD_STRING_SIZE];
@@ -3663,6 +3664,8 @@ acdb_init_fail:
        }
    }

    ret = audio_extn_utils_get_codec_variant(my_data->adev->snd_card,
                                             my_data->codec_variant);
    ret = audio_extn_utils_get_codec_version(snd_card_name,
                                             my_data->adev->snd_card,
                                             my_data->codec_version);
@@ -8637,6 +8640,21 @@ static bool platform_check_codec_backend_cfg(struct audio_device* adev,
                        sample_rate = curr_out->sample_rate;
                    }
                }

                /* WCD9380 support SR upto 192Khz only, hence reset
                 * SR > 192Khz to 192Khz.
                 */
                if (strstr(my_data->codec_variant, "WCD9380")) {
                    switch (sample_rate) {
                        case 352800:
                        case 384000:
                            sample_rate = 192000;
                            ALOGD("%s:Reset Sampling rate to %d",  __func__, sample_rate);
                            break;
                        default:
                            break;
                    }
                }
            }
        } else if (na_mode != NATIVE_AUDIO_MODE_MULTIPLE_MIX_IN_CODEC) {
            /*
+1 −0
Original line number Diff line number Diff line
@@ -372,6 +372,7 @@ enum {
#define DEFAULT_VOLUME_RAMP_DURATION_MS 20
#define MIXER_PATH_MAX_LENGTH 100
#define CODEC_VERSION_MAX_LENGTH 100
#define CODEC_VARIANT_MAX_LENGTH 100

#define MAX_VOL_INDEX 5
#define MIN_VOL_INDEX 0