diff options
author | Jarkko Nikula <jhnikula@gmail.com> | 2010-06-21 07:15:00 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-06-23 06:29:14 -0400 |
commit | 8c523115ae170840896ce6593a404ef0ffd3c7da (patch) | |
tree | 87807f4bbbb7a34030f0d90a1986e5a4dfd86da0 /sound/soc/omap | |
parent | 4eb5470326ca09c0eeae4502f52375d657a585c2 (diff) |
ASoC: RX-51: Add basic jack detection
This patch adds GPIO jack detection to Nokia N900/RX-51. At the moment only
SND_JACK_VIDEOOUT type is reported. More types could be reported after
getting more audio features supported and necessary drivers integrated for
implementing automated accessory detection.
Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/omap')
-rw-r--r-- | sound/soc/omap/rx51.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 1a2de34eecf5..88052d29617f 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/gpio.h> | 27 | #include <linux/gpio.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <sound/core.h> | 29 | #include <sound/core.h> |
30 | #include <sound/jack.h> | ||
30 | #include <sound/pcm.h> | 31 | #include <sound/pcm.h> |
31 | #include <sound/soc.h> | 32 | #include <sound/soc.h> |
32 | #include <sound/soc-dapm.h> | 33 | #include <sound/soc-dapm.h> |
@@ -38,6 +39,7 @@ | |||
38 | #include "../codecs/tlv320aic3x.h" | 39 | #include "../codecs/tlv320aic3x.h" |
39 | 40 | ||
40 | #define RX51_TVOUT_SEL_GPIO 40 | 41 | #define RX51_TVOUT_SEL_GPIO 40 |
42 | #define RX51_JACK_DETECT_GPIO 177 | ||
41 | /* | 43 | /* |
42 | * REVISIT: TWL4030 GPIO base in RX-51. Now statically defined to 192. This | 44 | * REVISIT: TWL4030 GPIO base in RX-51. Now statically defined to 192. This |
43 | * gpio is reserved in arch/arm/mach-omap2/board-rx51-peripherals.c | 45 | * gpio is reserved in arch/arm/mach-omap2/board-rx51-peripherals.c |
@@ -194,6 +196,18 @@ static int rx51_set_jack(struct snd_kcontrol *kcontrol, | |||
194 | return 1; | 196 | return 1; |
195 | } | 197 | } |
196 | 198 | ||
199 | static struct snd_soc_jack rx51_av_jack; | ||
200 | |||
201 | static struct snd_soc_jack_gpio rx51_av_jack_gpios[] = { | ||
202 | { | ||
203 | .gpio = RX51_JACK_DETECT_GPIO, | ||
204 | .name = "avdet-gpio", | ||
205 | .report = SND_JACK_VIDEOOUT, | ||
206 | .invert = 1, | ||
207 | .debounce_time = 200, | ||
208 | }, | ||
209 | }; | ||
210 | |||
197 | static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = { | 211 | static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = { |
198 | SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event), | 212 | SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event), |
199 | SND_SOC_DAPM_MIC("DMic", NULL), | 213 | SND_SOC_DAPM_MIC("DMic", NULL), |
@@ -228,6 +242,7 @@ static const struct snd_kcontrol_new aic34_rx51_controls[] = { | |||
228 | 242 | ||
229 | static int rx51_aic34_init(struct snd_soc_codec *codec) | 243 | static int rx51_aic34_init(struct snd_soc_codec *codec) |
230 | { | 244 | { |
245 | struct snd_soc_card *card = codec->socdev->card; | ||
231 | int err; | 246 | int err; |
232 | 247 | ||
233 | /* Set up NC codec pins */ | 248 | /* Set up NC codec pins */ |
@@ -250,7 +265,16 @@ static int rx51_aic34_init(struct snd_soc_codec *codec) | |||
250 | 265 | ||
251 | snd_soc_dapm_sync(codec); | 266 | snd_soc_dapm_sync(codec); |
252 | 267 | ||
253 | return 0; | 268 | /* AV jack detection */ |
269 | err = snd_soc_jack_new(card, "AV Jack", | ||
270 | SND_JACK_VIDEOOUT, &rx51_av_jack); | ||
271 | if (err) | ||
272 | return err; | ||
273 | err = snd_soc_jack_add_gpios(&rx51_av_jack, | ||
274 | ARRAY_SIZE(rx51_av_jack_gpios), | ||
275 | rx51_av_jack_gpios); | ||
276 | |||
277 | return err; | ||
254 | } | 278 | } |
255 | 279 | ||
256 | /* Digital audio interface glue - connects codec <--> CPU */ | 280 | /* Digital audio interface glue - connects codec <--> CPU */ |
@@ -326,6 +350,9 @@ err_gpio_tvout_sel: | |||
326 | 350 | ||
327 | static void __exit rx51_soc_exit(void) | 351 | static void __exit rx51_soc_exit(void) |
328 | { | 352 | { |
353 | snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios), | ||
354 | rx51_av_jack_gpios); | ||
355 | |||
329 | platform_device_unregister(rx51_snd_device); | 356 | platform_device_unregister(rx51_snd_device); |
330 | gpio_free(RX51_TVOUT_SEL_GPIO); | 357 | gpio_free(RX51_TVOUT_SEL_GPIO); |
331 | } | 358 | } |