summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMisael Lopez Cruz <misael.lopez@ti.com>2012-03-28 13:58:01 +0800
committerAndy Green <andy.green@linaro.org>2012-03-28 13:58:01 +0800
commit4dc1647dabdaa66dbd10ee5142f71d1a729a1f39 (patch)
tree19f1d1d25dfb511abc485526cedf20aeddbf9b10
parente52cd6311743398a352e5a87b0f326d200f58e4c (diff)
ASoC: sdp4430: Add vaux2 regulator for AV Switchtilt-linux-linaro-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.c31
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);