From a901777ebfae8c737814fbd66348276ca2b1c021 Mon Sep 17 00:00:00 2001 From: Viraj Karandikar Date: Tue, 31 May 2011 17:39:31 +0530 Subject: ASOC: tegra: Enable/disable regulator vmic when recording with d-mic Support recording with d-mic in audio only use case Reviewed-on: http://git-master/r/34551 (cherry picked from commit 58ff88e8ef9b805381a1bef40be276224a43e175) Change-Id: Iea9b509b805542f5089fb3399d7796d23d9270e5 Reviewed-on: http://git-master/r/35376 Tested-by: Viraj Karandikar Reviewed-by: Scott Peterson --- sound/soc/tegra/tegra_soc_wm8903.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/sound/soc/tegra/tegra_soc_wm8903.c b/sound/soc/tegra/tegra_soc_wm8903.c index 1c3ed544ddd5..ac7f9bbc441c 100644 --- a/sound/soc/tegra/tegra_soc_wm8903.c +++ b/sound/soc/tegra/tegra_soc_wm8903.c @@ -24,6 +24,7 @@ static struct platform_device *tegra_snd_device; +static struct regulator *reg_vmic = NULL; extern int en_dmic; extern struct snd_soc_dai tegra_i2s_dai[]; @@ -294,12 +295,26 @@ int tegra_codec_startup(struct snd_pcm_substream *substream) { tegra_das_power_mode(true); + if ((SNDRV_PCM_STREAM_CAPTURE == substream->stream) && en_dmic) { + /* enable d-mic */ + if (reg_vmic) { + regulator_enable(reg_vmic); + } + } + return 0; } void tegra_codec_shutdown(struct snd_pcm_substream *substream) { tegra_das_power_mode(false); + + if ((SNDRV_PCM_STREAM_CAPTURE == substream->stream) && en_dmic) { + /* disable d-mic */ + if (reg_vmic) { + regulator_disable(reg_vmic); + } + } } int tegra_soc_suspend_pre(struct platform_device *pdev, pm_message_t state) @@ -619,7 +634,13 @@ static int __init tegra_init(void) dev_err(&tegra_snd_device->dev, "%s: could not create sysfs entry %s: %d\n", __func__, dev_attr_enable_digital_mic.attr.name, ret); - return ret; + goto fail; + } + + reg_vmic = regulator_get(&tegra_snd_device->dev, "vmic"); + if (IS_ERR_OR_NULL(reg_vmic)) { + pr_err("Couldn't get vmic regulator\n"); + reg_vmic = NULL; } return 0; @@ -636,6 +657,10 @@ fail: static void __exit tegra_exit(void) { tegra_jack_exit(); + if (reg_vmic) { + regulator_put(reg_vmic); + reg_vmic = NULL; + } platform_device_unregister(tegra_snd_device); } -- cgit v1.2.3