diff options
author | Misael Lopez Cruz <misael.lopez@ti.com> | 2012-03-28 13:30:00 +0800 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2012-03-28 13:30:00 +0800 |
commit | 47a806621775298e2c83bd87d6f387c1c5609f2e (patch) | |
tree | 9b79cdbfa10db1e05d3533551e8eb5a93c6a24f4 | |
parent | c989312d074e2003cc4f330ae78cf1fe1fc80b94 (diff) |
ASoC: sdp4430: Add vaux2 regulator for AV Switchtilt-3.1
An AV switch is used in Blaze/SDP4430 to switch headset jack pin 3
between headset microphone and video output. AV switch is then a
consumer of VAUX2 supply. The corresponding consumer-supply is added
to have VAUX2 supply when headset microphone is in use.
This is considered non-essential, so if the driver is unable to
acquire the VAUX2 supply, it will gracefully continue.
On the 2.6.35 branch, this is the similar to:
commit: 2b3c5945463fe470b240eee8643cad4db48dae66
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
[s-jan@ti.com: fixed conflicts in sound/soc/omap/sdp4430.c]
Signed-off-by: Sebastien Jan <s-jan@ti.com>
-rw-r--r-- | sound/soc/omap/sdp4430.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c index 43b90d29fd6..64634951445 100644 --- a/sound/soc/omap/sdp4430.c +++ b/sound/soc/omap/sdp4430.c @@ -24,6 +24,7 @@ #include <linux/platform_device.h> #include <linux/mfd/twl6040.h> #include <linux/i2c.h> +#include <linux/regulator/consumer.h> #include <sound/core.h> #include <sound/pcm.h> @@ -46,6 +47,7 @@ #include "omap-dmic.h" #include "../codecs/twl6040.h" +static struct regulator *av_switch_reg; static int twl6040_power_mode; static int mcbsp_cfg; static struct snd_soc_codec *twl6040_codec; @@ -307,6 +309,19 @@ static struct snd_soc_jack_pin hs_jack_pins[] = { }, }; +static int sdp4430_av_switch_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + int ret; + + if (SND_SOC_DAPM_EVENT_ON(event)) + ret = regulator_enable(av_switch_reg); + else + ret = regulator_disable(av_switch_reg); + + return ret; +} + static int sdp4430_get_power_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -344,6 +359,9 @@ static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = { SND_SOC_DAPM_HP("Headset Stereophone", NULL), SND_SOC_DAPM_SPK("Earphone Spk", NULL), SND_SOC_DAPM_INPUT("FM Stereo In"), + SND_SOC_DAPM_SUPPLY("AV Switch Supply", + SND_SOC_NOPM, 0, 0, sdp4430_av_switch_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_MIC("Digital Mic 0", NULL), SND_SOC_DAPM_MIC("Digital Mic 1", NULL), @@ -363,6 +381,7 @@ static const struct snd_soc_dapm_route audio_map[] = { /* Headset Mic: HSMIC with bias */ {"HSMIC", NULL, "Headset Mic Bias"}, {"Headset Mic Bias", NULL, "Headset Mic"}, + {"Headset Mic", NULL, "AV Switch Supply"}, /* Headset Stereophone (Headphone): HSOL, HSOR */ {"Headset Stereophone", NULL, "HSOL"}, @@ -1040,7 +1059,16 @@ static int __init sdp4430_soc_init(void) if (ret) goto err_dev; + av_switch_reg = regulator_get(&sdp4430_snd_device->dev, "av-switch"); + if (IS_ERR(av_switch_reg)) { + ret = PTR_ERR(av_switch_reg); + printk(KERN_ERR "couldn't get AV Switch regulator %d\n", + ret); + goto err_reg; + } + adapter = i2c_get_adapter(1); + if (!adapter) { printk(KERN_ERR "can't get i2c adapter\n"); ret = -ENODEV; @@ -1066,6 +1094,8 @@ static int __init sdp4430_soc_init(void) err_i2c: i2c_put_adapter(adapter); err_adap: + regulator_put(av_switch_reg); +err_reg: platform_device_del(sdp4430_snd_device); err_dev: snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai)); @@ -1077,6 +1107,7 @@ module_init(sdp4430_soc_init); static void __exit sdp4430_soc_exit(void) { + regulator_put(av_switch_reg); platform_device_unregister(sdp4430_snd_device); snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai)); i2c_unregister_device(tps6130x_client); |