audio: limit sampling rates to 192Khz for WCD9380 varient.
-WCD9380 supports sampling rates upto 192Khz, hence limit
SR > 192Khz to 192Khz.
Change-Id: I1435919320d784bedf4147a9e467867d777b594b
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index b7942ae..17e0720 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -854,6 +854,7 @@
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);
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index d66b368..0ea7d94 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -1772,6 +1772,27 @@
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
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 459c37c..aa32e38 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -333,6 +333,7 @@
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];
@@ -3643,6 +3644,8 @@
}
}
+ 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);
@@ -8534,6 +8537,21 @@
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) {
/*
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index 1d56a7e..0274b21 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -372,6 +372,7 @@
#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