Merge "ASoC: msm8x16-wcd: add mixer control to update loopback mode"

This commit is contained in:
Linux Build Service Account 2014-07-16 11:54:01 -07:00 committed by Gerrit - the friendly Code Review server
commit 8bc67f5005
3 changed files with 56 additions and 0 deletions

View file

@ -813,6 +813,43 @@ static int msm8x16_wcd_pa_gain_get(struct snd_kcontrol *kcontrol,
return 0;
}
static int msm8x16_wcd_loopback_mode_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct msm8916_asoc_mach_data *pdata = NULL;
pdata = snd_soc_card_get_drvdata(codec->card);
dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
__func__, ucontrol->value.integer.value[0]);
return pdata->lb_mode;
}
static int msm8x16_wcd_loopback_mode_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct msm8916_asoc_mach_data *pdata = NULL;
pdata = snd_soc_card_get_drvdata(codec->card);
dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
__func__, ucontrol->value.integer.value[0]);
switch (ucontrol->value.integer.value[0]) {
case 0:
pdata->lb_mode = false;
break;
case 1:
pdata->lb_mode = true;
break;
default:
return -EINVAL;
}
return 0;
}
static int msm8x16_wcd_pa_gain_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
@ -1080,6 +1117,12 @@ static int msm8x16_wcd_put_iir_band_audio_mixer(
return 0;
}
static const char * const msm8x16_wcd_loopback_mode_ctrl_text[] = {
"DISABLE", "ENABLE"};
static const struct soc_enum msm8x16_wcd_loopback_mode_ctl_enum[] = {
SOC_ENUM_SINGLE_EXT(2, msm8x16_wcd_loopback_mode_ctrl_text),
};
static const char * const msm8x16_wcd_ear_pa_boost_ctrl_text[] = {
"DISABLE", "ENABLE"};
static const struct soc_enum msm8x16_wcd_ear_pa_boost_ctl_enum[] = {
@ -1129,6 +1172,9 @@ static const struct snd_kcontrol_new msm8x16_wcd_snd_controls[] = {
SOC_ENUM_EXT("Speaker Boost", msm8x16_wcd_spk_boost_ctl_enum[0],
msm8x16_wcd_spk_boost_get, msm8x16_wcd_spk_boost_set),
SOC_ENUM_EXT("LOOPBACK Mode", msm8x16_wcd_loopback_mode_ctl_enum[0],
msm8x16_wcd_loopback_mode_get, msm8x16_wcd_loopback_mode_put),
SOC_SINGLE_TLV("ADC1 Volume", MSM8X16_WCD_A_ANALOG_TX_1_EN, 3,
8, 0, analog_gain),
SOC_SINGLE_TLV("ADC2 Volume", MSM8X16_WCD_A_ANALOG_TX_2_EN, 3,
@ -1889,6 +1935,7 @@ static int msm8x16_wcd_codec_enable_dec(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct msm8916_asoc_mach_data *pdata = NULL;
unsigned int decimator;
struct msm8x16_wcd_priv *msm8x16_wcd = snd_soc_codec_get_drvdata(codec);
char *dec_name = NULL;
@ -1899,6 +1946,7 @@ static int msm8x16_wcd_codec_enable_dec(struct snd_soc_dapm_widget *w,
u8 dec_hpf_cut_of_freq;
int offset;
pdata = snd_soc_card_get_drvdata(codec->card);
dev_dbg(codec->dev, "%s %d\n", __func__, event);
widget_name = kstrndup(w->name, 15, GFP_KERNEL);
@ -1982,6 +2030,11 @@ static int msm8x16_wcd_codec_enable_dec(struct snd_soc_dapm_widget *w,
snd_soc_read(codec,
tx_digital_gain_reg[w->shift + offset])
);
if (pdata->lb_mode) {
pr_debug("%s: loopback mode unmute the DEC\n",
__func__);
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x00);
}
break;
case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01);

View file

@ -151,6 +151,7 @@ struct msm8916_asoc_mach_data {
int ext_pa;
int us_euro_gpio;
int mclk_freq;
int lb_mode;
atomic_t mclk_rsc_ref;
atomic_t mclk_enabled;
struct mutex cdc_mclk_mutex;

View file

@ -2151,6 +2151,8 @@ static int msm8x16_asoc_machine_probe(struct platform_device *pdev)
pdata->digital_cdc_clk.clk_val = pdata->mclk_freq;
pdata->digital_cdc_clk.clk_root = 5;
pdata->digital_cdc_clk.reserved = 0;
/* Initialize loopback mode to false */
pdata->lb_mode = false;
msm8x16_setup_hs_jack(pdev, pdata);