diff options
author | Ravindra Lokhande <rlokhande@nvidia.com> | 2011-05-03 21:36:47 +0530 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2011-05-05 14:19:24 -0700 |
commit | 2e3dcf0106af3015cdf2077b450a50b765a29559 (patch) | |
tree | f20eda64e33f84b1b940f26cbcba4e8f22449799 /sound | |
parent | 23a6f13e880dec15804509ee2c79bbca317885e6 (diff) |
tegra: alsa: enable speaker
fixes bug 822278
Change-Id: I4444e3786660ab1402469543c0bc04020d4c5021
Reviewed-on: http://git-master/r/30234
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Tested-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: Scott Peterson <speterson@nvidia.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/tegra/tegra_soc.h | 1 | ||||
-rw-r--r-- | sound/soc/tegra/tegra_soc_wm8903.c | 65 |
2 files changed, 65 insertions, 1 deletions
diff --git a/sound/soc/tegra/tegra_soc.h b/sound/soc/tegra/tegra_soc.h index 495f5c2b53cc..53366d33b090 100644 --- a/sound/soc/tegra/tegra_soc.h +++ b/sound/soc/tegra/tegra_soc.h @@ -120,6 +120,7 @@ int tegra_jack_init(struct snd_soc_codec *codec); void tegra_jack_exit(void); void tegra_jack_resume(void); void tegra_switch_set_state(int state); +void speaker_settings(struct snd_soc_codec *codec, int value); void setup_i2s_dma_request(struct snd_pcm_substream *substream, struct tegra_dma_req *req, diff --git a/sound/soc/tegra/tegra_soc_wm8903.c b/sound/soc/tegra/tegra_soc_wm8903.c index 8498120cfceb..691c09d91fdf 100644 --- a/sound/soc/tegra/tegra_soc_wm8903.c +++ b/sound/soc/tegra/tegra_soc_wm8903.c @@ -328,6 +328,62 @@ static struct snd_soc_ops tegra_spdif_ops = { .hw_params = tegra_spdif_hw_params, }; +void speaker_settings(struct snd_soc_codec *codec, int value) +{ + int CtrlReg = 0; + + /* Set Spkr */ + CtrlReg = snd_soc_read(codec, WM8903_ANALOGUE_SPK_MIX_LEFT_0); + CtrlReg &= ~WM8903_DACL_TO_MIXSPKL_MASK; + CtrlReg |= (value << WM8903_DACL_TO_MIXSPKL_SHIFT); + + snd_soc_write(codec, WM8903_ANALOGUE_SPK_MIX_LEFT_0, CtrlReg); + + + CtrlReg = snd_soc_read(codec, WM8903_ANALOGUE_SPK_MIX_RIGHT_0); + CtrlReg &= ~WM8903_DACR_TO_MIXSPKR_MASK; + CtrlReg |= (value << WM8903_DACR_TO_MIXSPKR_SHIFT); + + snd_soc_write(codec, WM8903_ANALOGUE_SPK_MIX_RIGHT_0, CtrlReg); + + CtrlReg = snd_soc_read(codec, WM8903_POWER_MANAGEMENT_4); + CtrlReg = SET_REG_VAL(CtrlReg, + WM8903_MIXSPKL_ENA_WIDTH, + WM8903_MIXSPKL_ENA_SHIFT, value); + CtrlReg = SET_REG_VAL(CtrlReg, + WM8903_MIXSPKR_ENA_WIDTH, + WM8903_MIXSPKR_ENA_SHIFT, value); + + snd_soc_write(codec, WM8903_POWER_MANAGEMENT_4, CtrlReg); + + CtrlReg = snd_soc_read(codec, WM8903_ANALOGUE_OUT3_LEFT); + CtrlReg = SET_REG_VAL(CtrlReg, 1, 8, ~value); + snd_soc_write(codec, WM8903_ANALOGUE_OUT3_LEFT, CtrlReg); + + CtrlReg = snd_soc_read(codec, WM8903_ANALOGUE_OUT3_RIGHT); + CtrlReg = SET_REG_VAL(CtrlReg, 1, 8, ~value); + snd_soc_write(codec, WM8903_ANALOGUE_OUT3_RIGHT, CtrlReg); + + CtrlReg = snd_soc_read(codec, WM8903_POWER_MANAGEMENT_5); + CtrlReg &= ~WM8903_SPKL_ENA_MASK; + CtrlReg |= (value << WM8903_SPKL_ENA_SHIFT); + CtrlReg &= ~WM8903_SPKR_ENA_MASK; + CtrlReg |= (value << WM8903_SPKR_ENA_SHIFT); + + + snd_soc_write(codec, WM8903_POWER_MANAGEMENT_5, CtrlReg); + + + CtrlReg = snd_soc_read(codec, WM8903_GPIO_CONTROL_3); + + if (value) + CtrlReg = 0x33; + else + CtrlReg = 0; + + snd_soc_write(codec, WM8903_GPIO_CONTROL_3, CtrlReg); +} + void tegra_ext_control(struct snd_soc_codec *codec, int new_con) { struct tegra_audio_data* audio_data = codec->socdev->codec_data; @@ -368,9 +424,16 @@ void tegra_ext_control(struct snd_soc_codec *codec, int new_con) else snd_soc_dapm_disable_pin(codec, "Headset"); + audio_data->codec_con = new_con; + + /* using this function until pin/widget works*/ + if (new_con & TEGRA_SPK) + speaker_settings(codec, 1); + else + speaker_settings(codec, 0); /* signal a DAPM event */ snd_soc_dapm_sync(codec); - audio_data->codec_con = new_con; + } static int tegra_dapm_event_int_spk(struct snd_soc_dapm_widget* w, |