Merge "ASoC: wcd9xxx: Fix RX Ear register gain values"
diff --git a/sound/soc/codecs/wcd9306.c b/sound/soc/codecs/wcd9306.c
index 4912cf04a..27ea648 100644
--- a/sound/soc/codecs/wcd9306.c
+++ b/sound/soc/codecs/wcd9306.c
@@ -514,31 +514,41 @@
struct snd_ctl_elem_value *ucontrol)
{
u8 ear_pa_gain;
+ int rc = 0;
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
ear_pa_gain = snd_soc_read(codec, TAPAN_A_RX_EAR_GAIN);
-
ear_pa_gain = ear_pa_gain >> 5;
- if (ear_pa_gain == 0x00) {
- ucontrol->value.integer.value[0] = 0;
- } else if (ear_pa_gain == 0x04) {
- ucontrol->value.integer.value[0] = 1;
- } else {
+ switch (ear_pa_gain) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ ucontrol->value.integer.value[0] = ear_pa_gain;
+ break;
+ case 7:
+ ucontrol->value.integer.value[0] = (ear_pa_gain - 1);
+ break;
+ default:
+ rc = -EINVAL;
pr_err("%s: ERROR: Unsupported Ear Gain = 0x%x\n",
- __func__, ear_pa_gain);
- return -EINVAL;
+ __func__, ear_pa_gain);
+ break;
}
dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__, ear_pa_gain);
- return 0;
+ return rc;
}
static int tapan_pa_gain_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
u8 ear_pa_gain;
+ int rc = 0;
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
@@ -546,17 +556,24 @@
switch (ucontrol->value.integer.value[0]) {
case 0:
- ear_pa_gain = 0x00;
- break;
case 1:
- ear_pa_gain = 0x80;
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ ear_pa_gain = ucontrol->value.integer.value[0];
+ break;
+ case 6:
+ ear_pa_gain = 0x07;
break;
default:
- return -EINVAL;
+ rc = -EINVAL;
+ break;
}
-
- snd_soc_update_bits(codec, TAPAN_A_RX_EAR_GAIN, 0xE0, ear_pa_gain);
- return 0;
+ if (!rc)
+ snd_soc_update_bits(codec, TAPAN_A_RX_EAR_GAIN,
+ 0xE0, ear_pa_gain << 5);
+ return rc;
}
static int tapan_get_iir_enable_audio_mixer(
@@ -1017,9 +1034,13 @@
return 0;
}
-static const char * const tapan_ear_pa_gain_text[] = {"POS_6_DB", "POS_2_DB"};
+static const char * const tapan_ear_pa_gain_text[] = {"POS_6_DB", "POS_4P5_DB",
+ "POS_3_DB", "POS_1P5_DB",
+ "POS_0_DB", "NEG_2P5_DB",
+ "NEG_12_DB"};
static const struct soc_enum tapan_ear_pa_gain_enum[] = {
- SOC_ENUM_SINGLE_EXT(2, tapan_ear_pa_gain_text),
+ SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tapan_ear_pa_gain_text),
+ tapan_ear_pa_gain_text),
};
static const char *const tapan_anc_func_text[] = {"OFF", "ON"};