asoc: codecs: Add support for setting ear gain ctl
Add support for setting EAR PA gain directly using mixer control. Change-Id: Ifd9e31ed45d10b5ea0f9cf546806ef78ece9e181 Signed-off-by: Vatsal Bucha <vbucha@codeaurora.org>
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

parent
5141b172ce
commit
2e838e52fe
@@ -910,6 +910,9 @@ static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD937X_DIGITAL_PDM_WD_CTL0,
|
||||
0x17, 0x13);
|
||||
if (!wcd937x->comp1_enable)
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD937X_ANA_EAR_COMPANDER_CTL, 0x80, 0x80);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
usleep_range(6000, 6010);
|
||||
@@ -929,6 +932,9 @@ static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
||||
(WCD_RX1 << 0x10 | 0x1));
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
if (!wcd937x->comp1_enable)
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD937X_ANA_EAR_COMPANDER_CTL, 0x80, 0x00);
|
||||
usleep_range(7000, 7010);
|
||||
wcd_cls_h_fsm(component, &wcd937x->clsh_info,
|
||||
WCD_CLSH_EVENT_POST_PA,
|
||||
@@ -1595,6 +1601,48 @@ static int wcd937x_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wcd937x_ear_pa_gain_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
u8 ear_pa_gain = 0;
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
|
||||
ear_pa_gain = snd_soc_component_read32(component,
|
||||
WCD937X_ANA_EAR_COMPANDER_CTL);
|
||||
|
||||
ear_pa_gain = (ear_pa_gain & 0x7C) >> 2;
|
||||
|
||||
ucontrol->value.integer.value[0] = ear_pa_gain;
|
||||
|
||||
dev_dbg(component->dev, "%s: ear_pa_gain = 0x%x\n", __func__,
|
||||
ear_pa_gain);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wcd937x_ear_pa_gain_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
u8 ear_pa_gain = 0;
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
|
||||
__func__, ucontrol->value.integer.value[0]);
|
||||
|
||||
ear_pa_gain = ucontrol->value.integer.value[0] << 2;
|
||||
|
||||
if (!wcd937x->comp1_enable) {
|
||||
snd_soc_component_update_bits(component,
|
||||
WCD937X_ANA_EAR_COMPANDER_CTL,
|
||||
0x7C, ear_pa_gain);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wcd937x_get_compander(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
@@ -1690,11 +1738,24 @@ static const char * const rx_hph_mode_mux_text[] = {
|
||||
"CLS_H_ULP", "CLS_AB_HIFI",
|
||||
};
|
||||
|
||||
static const char * const wcd937x_ear_pa_gain_text[] = {
|
||||
"G_6_DB", "G_4P5_DB", "G_3_DB", "G_1P5_DB", "G_0_DB",
|
||||
"G_M1P5_DB", "G_M3_DB", "G_M4P5_DB",
|
||||
"G_M6_DB", "G_7P5_DB", "G_M9_DB",
|
||||
"G_M10P5_DB", "G_M12_DB", "G_M13P5_DB",
|
||||
"G_M15_DB", "G_M16P5_DB", "G_M18_DB",
|
||||
};
|
||||
|
||||
static const struct soc_enum rx_hph_mode_mux_enum =
|
||||
SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
|
||||
rx_hph_mode_mux_text);
|
||||
|
||||
static SOC_ENUM_SINGLE_EXT_DECL(wcd937x_ear_pa_gain_enum,
|
||||
wcd937x_ear_pa_gain_text);
|
||||
|
||||
static const struct snd_kcontrol_new wcd937x_snd_controls[] = {
|
||||
SOC_ENUM_EXT("EAR PA GAIN", wcd937x_ear_pa_gain_enum,
|
||||
wcd937x_ear_pa_gain_get, wcd937x_ear_pa_gain_put),
|
||||
SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
|
||||
wcd937x_rx_hph_mode_get, wcd937x_rx_hph_mode_put),
|
||||
SOC_SINGLE_EXT("HPHL_COMP Switch", SND_SOC_NOPM, 0, 1, 0,
|
||||
|
Reference in New Issue
Block a user