From f981c5f62fe342f9e1c95765c032b8ffd63d09f2 Mon Sep 17 00:00:00 2001 From: Arun Shamanna Lakshmi Date: Tue, 10 Mar 2015 13:44:34 -0700 Subject: [PATCH] ASoC: tegra-alt: Set driver params iff clock is ON Enable the module clock before the setting of any parameters. Fix I2S Loopback, MVC volume & mute, Mixer Gain parameters. Bug 200075850 Change-Id: Ieaa532be286de09a47d02db6dbe25db039cccaf3 Signed-off-by: Arun Shamanna Lakshmi Reviewed-on: http://git-master/r/715943 Reviewed-by: Uday Gupta Reviewed-by: Viraj Karandikar --- sound/soc/tegra-alt/tegra210_i2s_alt.c | 32 +++++++++++++++++++++++- sound/soc/tegra-alt/tegra210_mixer_alt.c | 2 ++ sound/soc/tegra-alt/tegra210_mvc_alt.c | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/sound/soc/tegra-alt/tegra210_i2s_alt.c b/sound/soc/tegra-alt/tegra210_i2s_alt.c index 1a0a55ad..9ed718ed 100644 --- a/sound/soc/tegra-alt/tegra210_i2s_alt.c +++ b/sound/soc/tegra-alt/tegra210_i2s_alt.c @@ -621,8 +621,37 @@ static struct snd_soc_dai_driver tegra210_i2s_dais[] = { } }; +static int tegra210_i2s_loopback_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct tegra210_i2s *i2s = snd_soc_codec_get_drvdata(codec); + + ucontrol->value.integer.value[0] = i2s->loopback; + + return 0; +} + +static int tegra210_i2s_loopback_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct tegra210_i2s *i2s = snd_soc_codec_get_drvdata(codec); + + i2s->loopback = ucontrol->value.integer.value[0]; + + pm_runtime_get_sync(codec->dev); + regmap_update_bits(i2s->regmap, TEGRA210_I2S_CTRL, + TEGRA210_I2S_CTRL_LPBK_MASK, + i2s->loopback << TEGRA210_I2S_CTRL_LPBK_SHIFT); + pm_runtime_put(codec->dev); + + return 0; +} + static const struct snd_kcontrol_new tegra210_i2s_controls[] = { - SOC_SINGLE("Loopback", TEGRA210_I2S_CTRL, 8, 1, 0), + SOC_SINGLE_EXT("Loopback", SND_SOC_NOPM, 0, 1, 0, + tegra210_i2s_loopback_get, tegra210_i2s_loopback_put), }; static const struct snd_soc_dapm_widget tegra210_i2s_widgets[] = { @@ -804,6 +833,7 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev) i2s->tx_mask = i2s->rx_mask = 0xFFFF; i2s->bclk_ratio = 2; i2s->enable_cya = false; + i2s->loopback = 0; i2s->clk_i2s = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(i2s->clk_i2s)) { diff --git a/sound/soc/tegra-alt/tegra210_mixer_alt.c b/sound/soc/tegra-alt/tegra210_mixer_alt.c index b0d8f7d4..a66eccd0 100644 --- a/sound/soc/tegra-alt/tegra210_mixer_alt.c +++ b/sound/soc/tegra-alt/tegra210_mixer_alt.c @@ -159,6 +159,7 @@ static int tegra210_mixer_put_gain(struct snd_kcontrol *kcontrol, unsigned int reg = mc->reg; unsigned int ret, i; + pm_runtime_get_sync(codec->dev); /* write default gain config poly coefficients */ for (i = 0; i < 14; i++) tegra210_mixer_write_ram(mixer, reg + i, mixer->gain_coeff[i]); @@ -168,6 +169,7 @@ static int tegra210_mixer_put_gain(struct snd_kcontrol *kcontrol, ucontrol->value.integer.value[0]); ret |= tegra210_mixer_write_ram(mixer, reg + 0x0f, ucontrol->value.integer.value[0]); + pm_runtime_put(codec->dev); /* save gain */ i = (reg - TEGRA210_MIXER_AHUBRAMCTL_GAIN_CONFIG_RAM_ADDR_0) / diff --git a/sound/soc/tegra-alt/tegra210_mvc_alt.c b/sound/soc/tegra-alt/tegra210_mvc_alt.c index 76f7b90e..0e7454e6 100644 --- a/sound/soc/tegra-alt/tegra210_mvc_alt.c +++ b/sound/soc/tegra-alt/tegra210_mvc_alt.c @@ -137,6 +137,7 @@ static int tegra210_mvc_put_vol(struct snd_kcontrol *kcontrol, unsigned int reg = mc->reg; unsigned int ret, value, wait = 0xffff; + pm_runtime_get_sync(codec->dev); /* check if VOLUME_SWITCH is triggered*/ do { regmap_read(mvc->regmap, @@ -157,6 +158,7 @@ static int tegra210_mvc_put_vol(struct snd_kcontrol *kcontrol, ret |= regmap_update_bits(mvc->regmap, TEGRA210_MVC_SWITCH, TEGRA210_MVC_VOLUME_SWITCH_MASK, TEGRA210_MVC_VOLUME_SWITCH_TRIGGER); + pm_runtime_put(codec->dev); return ret; }