1 From db8f1eba9154789c45c6a92413bbbd94f5d9c7f5 Mon Sep 17 00:00:00 2001
2 From: Tim Yamin <plasm@roo.me.uk>
3 Date: Wed, 29 Apr 2009 17:30:25 -0700
4 Subject: [PATCH] Touch Book: turn on/off the class D amplifier depending on whether the headphones are plugged into the jack or not.
6 Signed-off-by: Tim Yamin <plasm@roo.me.uk>
8 sound/soc/omap/omap3beagle.c | 33 +++++++++++++++++++++++++++++++++
9 1 files changed, 33 insertions(+), 0 deletions(-)
11 diff --git a/sound/soc/omap/omap3beagle.c b/sound/soc/omap/omap3beagle.c
12 index fd24a4a..1236638 100644
13 --- a/sound/soc/omap/omap3beagle.c
14 +++ b/sound/soc/omap/omap3beagle.c
18 #include <linux/clk.h>
19 +#include <linux/irq.h>
20 +#include <linux/interrupt.h>
21 #include <linux/platform_device.h>
23 #include <sound/core.h>
24 #include <sound/pcm.h>
25 #include <sound/soc.h>
28 #include "../codecs/twl4030.h"
30 +#define TB_HEADPHONE_GPIO 56
31 +#define TB_HEADPHONE_IRQ OMAP_GPIO_IRQ(TB_HEADPHONE_GPIO)
33 static int omap3beagle_hw_params(struct snd_pcm_substream *substream,
34 struct snd_pcm_hw_params *params)
36 @@ -103,6 +109,34 @@ static struct snd_soc_device omap3beagle_snd_devdata = {
38 static struct platform_device *omap3beagle_snd_device;
40 +static void jack_work_func(struct work_struct *wq)
42 + int status = gpio_get_value(TB_HEADPHONE_GPIO);
44 + struct snd_soc_device *socdev = platform_get_drvdata(omap3beagle_snd_device);
45 + struct snd_soc_codec *codec = socdev->card->codec;
48 + snd_soc_dapm_disable_pin(codec, "HFL");
49 + snd_soc_dapm_disable_pin(codec, "HFR");
51 + snd_soc_dapm_enable_pin(codec, "HFL");
52 + snd_soc_dapm_enable_pin(codec, "HFR");
55 + enable_irq(TB_HEADPHONE_IRQ);
57 + //snd_soc_dapm_sync(codec);
59 +DECLARE_WORK(jack_work, jack_work_func);
61 +static irqreturn_t touchbook_headphone_event(int irq, void *snd)
63 + disable_irq_nosync(irq);
64 + schedule_work(&jack_work);
68 static int __init omap3beagle_soc_init(void)
71 @@ -123,10 +156,19 @@ static int __init omap3beagle_soc_init(void)
72 omap3beagle_snd_devdata.dev = &omap3beagle_snd_device->dev;
73 *(unsigned int *)omap3beagle_dai.cpu_dai->private_data = 1; /* McBSP2 */
75 + /* Touch Book -- headphone jack sensor */
76 + ret = request_irq(TB_HEADPHONE_IRQ, touchbook_headphone_event, IRQF_TRIGGER_RISING |
77 + IRQF_TRIGGER_FALLING, "touchbook_headphone", omap3beagle_snd_device);
81 ret = platform_device_add(omap3beagle_snd_device);
85 + /* Detect headphone status */
86 + touchbook_headphone_event(0, omap3beagle_snd_device);