1 From c03e9f46b9f15afc3e8980ae28666ff30907b173 Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Wed, 16 Jul 2008 14:46:56 +0100
4 Subject: [PATCH] gta02-sound.patch
7 include/sound/soc-dapm.h | 7 +
8 sound/soc/s3c24xx/Kconfig | 9 +
9 sound/soc/s3c24xx/Makefile | 3 +
10 sound/soc/s3c24xx/neo1973_gta02_wm8753.c | 667 ++++++++++++++++++++++++++++++
11 sound/soc/soc-dapm.c | 24 ++
12 5 files changed, 710 insertions(+), 0 deletions(-)
13 create mode 100644 sound/soc/s3c24xx/neo1973_gta02_wm8753.c
15 diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
16 index a105b01..e867447 100644
17 --- a/include/sound/soc-dapm.h
18 +++ b/include/sound/soc-dapm.h
19 @@ -225,6 +225,13 @@ int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
20 char *pin, int status);
21 int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec);
23 +/* dapm audio endpoint control */
24 +int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
25 + char *pin, int status);
26 +int snd_soc_dapm_get_endpoint(struct snd_soc_codec *codec,
28 +int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec);
30 /* dapm widget types */
31 enum snd_soc_dapm_type {
32 snd_soc_dapm_input = 0, /* input pin */
33 diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
34 index 1f6dbfc..3155c43 100644
35 --- a/sound/soc/s3c24xx/Kconfig
36 +++ b/sound/soc/s3c24xx/Kconfig
37 @@ -28,6 +28,15 @@ config SND_S3C24XX_SOC_NEO1973_WM8753
38 Say Y if you want to add support for SoC audio on smdk2440
41 +config SND_S3C24XX_SOC_NEO1973_GTA02_WM8753
42 + tristate "SoC I2S Audio support for NEO1973 GTA02 - WM8753"
43 + depends on SND_S3C24XX_SOC && MACH_NEO1973_GTA02
44 + select SND_S3C24XX_SOC_I2S
45 + select SND_SOC_WM8753
47 + Say Y if you want to add support for SoC audio on neo1973 gta02
48 + with the WM8753 codec
50 config SND_S3C24XX_SOC_SMDK2443_WM9710
51 tristate "SoC AC97 Audio support for SMDK2443 - WM9710"
52 depends on SND_S3C24XX_SOC && MACH_SMDK2443
53 diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
54 index 0aa5fb0..f154cb1 100644
55 --- a/sound/soc/s3c24xx/Makefile
56 +++ b/sound/soc/s3c24xx/Makefile
57 @@ -13,7 +13,10 @@ obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o
58 snd-soc-neo1973-wm8753-objs := neo1973_wm8753.o
59 snd-soc-smdk2443-wm9710-objs := smdk2443_wm9710.o
60 snd-soc-ln2440sbc-alc650-objs := ln2440sbc_alc650.o
61 +snd-soc-neo1973-gta02-wm8753-objs := neo1973_gta02_wm8753.o
63 obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o
64 obj-$(CONFIG_SND_S3C24XX_SOC_SMDK2443_WM9710) += snd-soc-smdk2443-wm9710.o
65 obj-$(CONFIG_SND_S3C24XX_SOC_LN2440SBC_ALC650) += snd-soc-ln2440sbc-alc650.o
66 +obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_GTA02_WM8753) += snd-soc-neo1973-gta02-wm8753.o
68 diff --git a/sound/soc/s3c24xx/neo1973_gta02_wm8753.c b/sound/soc/s3c24xx/neo1973_gta02_wm8753.c
70 index 0000000..f32cba3
72 +++ b/sound/soc/s3c24xx/neo1973_gta02_wm8753.c
75 + * neo1973_gta02_wm8753.c -- SoC audio for Neo1973
77 + * Copyright 2007 OpenMoko Inc
78 + * Author: Graeme Gregory <graeme@openmoko.org>
79 + * Copyright 2007 Wolfson Microelectronics PLC.
80 + * Author: Graeme Gregory <linux@wolfsonmicro.com>
82 + * This program is free software; you can redistribute it and/or modify it
83 + * under the terms of the GNU General Public License as published by the
84 + * Free Software Foundation; either version 2 of the License, or (at your
85 + * option) any later version.
88 + * 06th Nov 2007 Changed from GTA01 to GTA02
89 + * 20th Jan 2007 Initial version.
90 + * 05th Feb 2007 Rename all to Neo1973
94 +#include <linux/module.h>
95 +#include <linux/moduleparam.h>
96 +#include <linux/timer.h>
97 +#include <linux/interrupt.h>
98 +#include <linux/platform_device.h>
99 +#include <linux/i2c.h>
100 +#include <sound/driver.h>
101 +#include <sound/core.h>
102 +#include <sound/pcm.h>
103 +#include <sound/soc.h>
104 +#include <sound/soc-dapm.h>
106 +#include <asm/mach-types.h>
107 +#include <asm/hardware/scoop.h>
108 +#include <asm/plat-s3c24xx/regs-iis.h>
109 +#include <asm/arch/regs-clock.h>
110 +#include <asm/arch/regs-gpio.h>
111 +#include <asm/hardware.h>
112 +#include <asm/arch/audio.h>
114 +#include <asm/arch/spi-gpio.h>
115 +#include <asm/arch/regs-gpioj.h>
116 +#include <asm/arch/gta02.h>
117 +#include "../codecs/wm8753.h"
118 +#include "s3c24xx-pcm.h"
119 +#include "s3c24xx-i2s.h"
121 +/* define the scenarios */
122 +#define NEO_AUDIO_OFF 0
123 +#define NEO_GSM_CALL_AUDIO_HANDSET 1
124 +#define NEO_GSM_CALL_AUDIO_HEADSET 2
125 +#define NEO_GSM_CALL_AUDIO_BLUETOOTH 3
126 +#define NEO_STEREO_TO_SPEAKERS 4
127 +#define NEO_STEREO_TO_HEADPHONES 5
128 +#define NEO_CAPTURE_HANDSET 6
129 +#define NEO_CAPTURE_HEADSET 7
130 +#define NEO_CAPTURE_BLUETOOTH 8
131 +#define NEO_STEREO_TO_HANDSET_SPK 9
133 +static struct snd_soc_machine neo1973_gta02;
135 +static int neo1973_gta02_hifi_hw_params(struct snd_pcm_substream *substream,
136 + struct snd_pcm_hw_params *params)
138 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
139 + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
140 + struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
141 + unsigned int pll_out = 0, bclk = 0;
143 + unsigned long iis_clkrate;
145 + iis_clkrate = s3c24xx_i2s_get_clockrate();
147 + switch (params_rate(params)) {
150 + pll_out = 12288000;
153 + bclk = WM8753_BCLK_DIV_4;
154 + pll_out = 12288000;
157 + bclk = WM8753_BCLK_DIV_2;
158 + pll_out = 12288000;
161 + bclk = WM8753_BCLK_DIV_16;
162 + pll_out = 11289600;
165 + bclk = WM8753_BCLK_DIV_8;
166 + pll_out = 11289600;
169 + bclk = WM8753_BCLK_DIV_4;
170 + pll_out = 11289600;
173 + bclk = WM8753_BCLK_DIV_2;
174 + pll_out = 11289600;
178 + /* set codec DAI configuration */
179 + ret = codec_dai->dai_ops.set_fmt(codec_dai,
180 + SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
181 + SND_SOC_DAIFMT_CBM_CFM);
185 + /* set cpu DAI configuration */
186 + ret = cpu_dai->dai_ops.set_fmt(cpu_dai,
187 + SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
188 + SND_SOC_DAIFMT_CBM_CFM);
192 + /* set the codec system clock for DAC and ADC */
193 + ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8753_MCLK, pll_out,
198 + /* set MCLK division for sample rate */
199 + ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
200 + S3C2410_IISMOD_32FS );
204 + /* set codec BCLK division for sample rate */
205 + ret = codec_dai->dai_ops.set_clkdiv(codec_dai,
206 + WM8753_BCLKDIV, bclk);
210 + /* set prescaler division for sample rate */
211 + ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER,
212 + S3C24XX_PRESCALE(4,4));
216 + /* codec PLL input is PCLK/4 */
217 + ret = codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL1,
218 + iis_clkrate / 4, pll_out);
225 +static int neo1973_gta02_hifi_hw_free(struct snd_pcm_substream *substream)
227 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
228 + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
230 + /* disable the PLL */
231 + return codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL1, 0, 0);
235 + * Neo1973 WM8753 HiFi DAI opserations.
237 +static struct snd_soc_ops neo1973_gta02_hifi_ops = {
238 + .hw_params = neo1973_gta02_hifi_hw_params,
239 + .hw_free = neo1973_gta02_hifi_hw_free,
242 +static int neo1973_gta02_voice_hw_params(
243 + struct snd_pcm_substream *substream,
244 + struct snd_pcm_hw_params *params)
246 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
247 + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
248 + unsigned int pcmdiv = 0;
250 + unsigned long iis_clkrate;
252 + iis_clkrate = s3c24xx_i2s_get_clockrate();
254 + if (params_rate(params) != 8000)
256 + if (params_channels(params) != 1)
259 + pcmdiv = WM8753_PCM_DIV_6; /* 2.048 MHz */
261 + /* todo: gg check mode (DSP_B) against CSR datasheet */
262 + /* set codec DAI configuration */
263 + ret = codec_dai->dai_ops.set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B |
264 + SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
268 + /* set the codec system clock for DAC and ADC */
269 + ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8753_PCMCLK,
270 + 12288000, SND_SOC_CLOCK_IN);
274 + /* set codec PCM division for sample rate */
275 + ret = codec_dai->dai_ops.set_clkdiv(codec_dai, WM8753_PCMDIV,
280 + /* configue and enable PLL for 12.288MHz output */
281 + ret = codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL2,
282 + iis_clkrate / 4, 12288000);
289 +static int neo1973_gta02_voice_hw_free(struct snd_pcm_substream *substream)
291 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
292 + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
294 + /* disable the PLL */
295 + return codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL2, 0, 0);
298 +static struct snd_soc_ops neo1973_gta02_voice_ops = {
299 + .hw_params = neo1973_gta02_voice_hw_params,
300 + .hw_free = neo1973_gta02_voice_hw_free,
303 +#define LM4853_AMP 1
304 +#define LM4853_SPK 2
306 +static u8 lm4853_state=0;
308 +static int lm4853_set_state(struct snd_kcontrol *kcontrol,
309 + struct snd_ctl_elem_value *ucontrol)
311 + int val = ucontrol->value.integer.value[0];
314 + lm4853_state |= LM4853_AMP;
315 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT,0);
317 + lm4853_state &= ~LM4853_AMP;
318 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT,1);
324 +static int lm4853_get_state(struct snd_kcontrol *kcontrol,
325 + struct snd_ctl_elem_value *ucontrol)
327 + ucontrol->value.integer.value[0] = lm4853_state & LM4853_AMP;
332 +static int lm4853_set_spk(struct snd_kcontrol *kcontrol,
333 + struct snd_ctl_elem_value *ucontrol)
335 + int val = ucontrol->value.integer.value[0];
338 + lm4853_state |= LM4853_SPK;
339 + s3c2410_gpio_setpin(GTA02_GPIO_HP_IN,0);
341 + lm4853_state &= ~LM4853_SPK;
342 + s3c2410_gpio_setpin(GTA02_GPIO_HP_IN,1);
348 +static int lm4853_get_spk(struct snd_kcontrol *kcontrol,
349 + struct snd_ctl_elem_value *ucontrol)
351 + ucontrol->value.integer.value[0] = (lm4853_state & LM4853_SPK) >> 1;
356 +static int neo1973_gta02_set_stereo_out(struct snd_kcontrol *kcontrol,
357 + struct snd_ctl_elem_value *ucontrol)
359 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
360 + int val = ucontrol->value.integer.value[0];
362 + snd_soc_dapm_set_endpoint(codec, "Stereo Out", val);
364 + snd_soc_dapm_sync_endpoints(codec);
369 +static int neo1973_gta02_get_stereo_out(struct snd_kcontrol *kcontrol,
370 + struct snd_ctl_elem_value *ucontrol)
372 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
374 + ucontrol->value.integer.value[0] =
375 + snd_soc_dapm_get_endpoint(codec, "Stereo Out");
381 +static int neo1973_gta02_set_gsm_out(struct snd_kcontrol *kcontrol,
382 + struct snd_ctl_elem_value *ucontrol)
384 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
385 + int val = ucontrol->value.integer.value[0];
387 + snd_soc_dapm_set_endpoint(codec, "GSM Line Out", val);
389 + snd_soc_dapm_sync_endpoints(codec);
394 +static int neo1973_gta02_get_gsm_out(struct snd_kcontrol *kcontrol,
395 + struct snd_ctl_elem_value *ucontrol)
397 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
399 + ucontrol->value.integer.value[0] =
400 + snd_soc_dapm_get_endpoint(codec, "GSM Line Out");
405 +static int neo1973_gta02_set_gsm_in(struct snd_kcontrol *kcontrol,
406 + struct snd_ctl_elem_value *ucontrol)
408 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
409 + int val = ucontrol->value.integer.value[0];
411 + snd_soc_dapm_set_endpoint(codec, "GSM Line In", val);
413 + snd_soc_dapm_sync_endpoints(codec);
418 +static int neo1973_gta02_get_gsm_in(struct snd_kcontrol *kcontrol,
419 + struct snd_ctl_elem_value *ucontrol)
421 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
423 + ucontrol->value.integer.value[0] =
424 + snd_soc_dapm_get_endpoint(codec, "GSM Line In");
429 +static int neo1973_gta02_set_headset_mic(struct snd_kcontrol *kcontrol,
430 + struct snd_ctl_elem_value *ucontrol)
432 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
433 + int val = ucontrol->value.integer.value[0];
435 + snd_soc_dapm_set_endpoint(codec, "Headset Mic", val);
437 + snd_soc_dapm_sync_endpoints(codec);
442 +static int neo1973_gta02_get_headset_mic(struct snd_kcontrol *kcontrol,
443 + struct snd_ctl_elem_value *ucontrol)
445 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
447 + ucontrol->value.integer.value[0] =
448 + snd_soc_dapm_get_endpoint(codec, "Headset Mic");
453 +static int neo1973_gta02_set_handset_mic(struct snd_kcontrol *kcontrol,
454 + struct snd_ctl_elem_value *ucontrol)
456 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
457 + int val = ucontrol->value.integer.value[0];
459 + snd_soc_dapm_set_endpoint(codec, "Handset Mic", val);
461 + snd_soc_dapm_sync_endpoints(codec);
466 +static int neo1973_gta02_get_handset_mic(struct snd_kcontrol *kcontrol,
467 + struct snd_ctl_elem_value *ucontrol)
469 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
471 + ucontrol->value.integer.value[0] =
472 + snd_soc_dapm_get_endpoint(codec, "Handset Mic");
477 +static int neo1973_gta02_set_handset_spk(struct snd_kcontrol *kcontrol,
478 + struct snd_ctl_elem_value *ucontrol)
480 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
481 + int val = ucontrol->value.integer.value[0];
483 + snd_soc_dapm_set_endpoint(codec, "Handset Spk", val);
485 + snd_soc_dapm_sync_endpoints(codec);
490 +static int neo1973_gta02_get_handset_spk(struct snd_kcontrol *kcontrol,
491 + struct snd_ctl_elem_value *ucontrol)
493 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
495 + ucontrol->value.integer.value[0] =
496 + snd_soc_dapm_get_endpoint(codec, "Handset Spk");
501 +static const struct snd_soc_dapm_widget wm8753_dapm_widgets[] = {
502 + SND_SOC_DAPM_LINE("Stereo Out", NULL),
503 + SND_SOC_DAPM_LINE("GSM Line Out", NULL),
504 + SND_SOC_DAPM_LINE("GSM Line In", NULL),
505 + SND_SOC_DAPM_MIC("Headset Mic", NULL),
506 + SND_SOC_DAPM_MIC("Handset Mic", NULL),
507 + SND_SOC_DAPM_SPK("Handset Spk", NULL),
511 +/* example machine audio_mapnections */
512 +static const char* audio_map[][3] = {
514 + /* Connections to the lm4853 amp */
515 + {"Stereo Out", NULL, "LOUT1"},
516 + {"Stereo Out", NULL, "ROUT1"},
518 + /* Connections to the GSM Module */
519 + {"GSM Line Out", NULL, "MONO1"},
520 + {"GSM Line Out", NULL, "MONO2"},
521 + {"RXP", NULL, "GSM Line In"},
522 + {"RXN", NULL, "GSM Line In"},
524 + /* Connections to Headset */
525 + {"MIC1", NULL, "Mic Bias"},
526 + {"Mic Bias", NULL, "Headset Mic"},
529 + {"MIC2", NULL, "Mic Bias"},
530 + {"MIC2N", NULL, "Mic Bias"},
531 + {"Mic Bias", NULL, "Handset Mic"},
534 + {"Handset Spk", NULL, "LOUT2"},
535 + {"Handset Spk", NULL, "ROUT2"},
537 + /* Connect the ALC pins */
538 + {"ACIN", NULL, "ACOP"},
540 + {NULL, NULL, NULL},
543 +static const struct snd_kcontrol_new wm8753_neo1973_gta02_controls[] = {
544 + SOC_SINGLE_EXT("DAPM Stereo Out Switch", 0, 0, 1, 0,
545 + neo1973_gta02_get_stereo_out,
546 + neo1973_gta02_set_stereo_out),
547 + SOC_SINGLE_EXT("DAPM GSM Line Out Switch", 1, 0, 1, 0,
548 + neo1973_gta02_get_gsm_out,
549 + neo1973_gta02_set_gsm_out),
550 + SOC_SINGLE_EXT("DAPM GSM Line In Switch", 2, 0, 1, 0,
551 + neo1973_gta02_get_gsm_in,
552 + neo1973_gta02_set_gsm_in),
553 + SOC_SINGLE_EXT("DAPM Headset Mic Switch", 3, 0, 1, 0,
554 + neo1973_gta02_get_headset_mic,
555 + neo1973_gta02_set_headset_mic),
556 + SOC_SINGLE_EXT("DAPM Handset Mic Switch", 4, 0, 1, 0,
557 + neo1973_gta02_get_handset_mic,
558 + neo1973_gta02_set_handset_mic),
559 + SOC_SINGLE_EXT("DAPM Handset Spk Switch", 5, 0, 1, 0,
560 + neo1973_gta02_get_handset_spk,
561 + neo1973_gta02_set_handset_spk),
562 + SOC_SINGLE_EXT("Amp State Switch", 6, 0, 1, 0,
565 + SOC_SINGLE_EXT("Amp Spk Switch", 7, 0, 1, 0,
571 + * This is an example machine initialisation for a wm8753 connected to a
574 +static int neo1973_gta02_wm8753_init(struct snd_soc_codec *codec)
578 + /* set up NC codec pins */
579 + snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
580 + snd_soc_dapm_set_endpoint(codec, "OUT4", 0);
581 + snd_soc_dapm_set_endpoint(codec, "LINE1", 0);
582 + snd_soc_dapm_set_endpoint(codec, "LINE2", 0);
584 + /* Add neo1973 gta02 specific widgets */
585 + for (i = 0; i < ARRAY_SIZE(wm8753_dapm_widgets); i++)
586 + snd_soc_dapm_new_control(codec, &wm8753_dapm_widgets[i]);
588 + /* add neo1973 gta02 specific controls */
589 + for (i = 0; i < ARRAY_SIZE(wm8753_neo1973_gta02_controls); i++) {
590 + err = snd_ctl_add(codec->card,
591 + snd_soc_cnew(&wm8753_neo1973_gta02_controls[i],
597 + /* set up neo1973 gta02 specific audio path audio_mapnects */
598 + for (i = 0; audio_map[i][0] != NULL; i++) {
599 + snd_soc_dapm_connect_input(codec, audio_map[i][0],
600 + audio_map[i][1], audio_map[i][2]);
603 + /* set endpoints to default off mode */
604 + snd_soc_dapm_set_endpoint(codec, "Stereo Out", 0);
605 + snd_soc_dapm_set_endpoint(codec, "GSM Line Out",0);
606 + snd_soc_dapm_set_endpoint(codec, "GSM Line In", 0);
607 + snd_soc_dapm_set_endpoint(codec, "Headset Mic", 0);
608 + snd_soc_dapm_set_endpoint(codec, "Handset Mic", 0);
609 + snd_soc_dapm_set_endpoint(codec, "Handset Spk", 0);
611 + snd_soc_dapm_sync_endpoints(codec);
618 +static struct snd_soc_cpu_dai bt_dai =
619 +{ .name = "Bluetooth",
621 + .type = SND_SOC_DAI_PCM,
625 + .rates = SNDRV_PCM_RATE_8000,
626 + .formats = SNDRV_PCM_FMTBIT_S16_LE,},
630 + .rates = SNDRV_PCM_RATE_8000,
631 + .formats = SNDRV_PCM_FMTBIT_S16_LE,},
634 +static struct snd_soc_dai_link neo1973_gta02_dai[] = {
635 +{ /* Hifi Playback - for similatious use with voice below */
637 + .stream_name = "WM8753 HiFi",
638 + .cpu_dai = &s3c24xx_i2s_dai,
639 + .codec_dai = &wm8753_dai[WM8753_DAI_HIFI],
640 + .init = neo1973_gta02_wm8753_init,
641 + .ops = &neo1973_gta02_hifi_ops,
643 +{ /* Voice via BT */
644 + .name = "Bluetooth",
645 + .stream_name = "Voice",
646 + .cpu_dai = &bt_dai,
647 + .codec_dai = &wm8753_dai[WM8753_DAI_VOICE],
648 + .ops = &neo1973_gta02_voice_ops,
653 +int neo1973_gta02_suspend(struct platform_device *pdev, pm_message_t state)
655 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT, 1);
660 +int neo1973_gta02_resume(struct platform_device *pdev)
662 + if(lm4853_state & LM4853_AMP)
663 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT, 0);
668 +#define neo1973_gta02_suspend NULL
669 +#define neo1973_gta02_resume NULL
672 +static struct snd_soc_machine neo1973_gta02 = {
673 + .name = "neo1973-gta02",
674 + .suspend_pre = neo1973_gta02_suspend,
675 + .resume_post = neo1973_gta02_resume,
676 + .dai_link = neo1973_gta02_dai,
677 + .num_links = ARRAY_SIZE(neo1973_gta02_dai),
680 +static struct wm8753_setup_data neo1973_gta02_wm8753_setup = {
681 + .i2c_address = 0x1a,
684 +static struct snd_soc_device neo1973_gta02_snd_devdata = {
685 + .machine = &neo1973_gta02,
686 + .platform = &s3c24xx_soc_platform,
687 + .codec_dev = &soc_codec_dev_wm8753,
688 + .codec_data = &neo1973_gta02_wm8753_setup,
691 +static struct platform_device *neo1973_gta02_snd_device;
693 +static int __init neo1973_gta02_init(void)
697 + if (!machine_is_neo1973_gta02()) {
699 + "Only GTA02 hardware supported by ASoc driver\n");
703 + neo1973_gta02_snd_device = platform_device_alloc("soc-audio", -1);
704 + if (!neo1973_gta02_snd_device)
707 + platform_set_drvdata(neo1973_gta02_snd_device,
708 + &neo1973_gta02_snd_devdata);
709 + neo1973_gta02_snd_devdata.dev = &neo1973_gta02_snd_device->dev;
710 + ret = platform_device_add(neo1973_gta02_snd_device);
713 + platform_device_put(neo1973_gta02_snd_device);
715 + /* Initialise GPIOs used by amp */
716 + s3c2410_gpio_cfgpin(GTA02_GPIO_HP_IN, S3C2410_GPIO_OUTPUT);
717 + s3c2410_gpio_cfgpin(GTA02_GPIO_AMP_SHUT, S3C2410_GPIO_OUTPUT);
719 + /* Amp off by default */
720 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT, 1);
722 + /* Speaker off by default */
723 + s3c2410_gpio_setpin(GTA02_GPIO_HP_IN, 1);
728 +static void __exit neo1973_gta02_exit(void)
730 + platform_device_unregister(neo1973_gta02_snd_device);
733 +module_init(neo1973_gta02_init);
734 +module_exit(neo1973_gta02_exit);
736 +/* Module information */
737 +MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org");
738 +MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973 GTA02");
739 +MODULE_LICENSE("GPL");
741 diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
742 index af3326c..95df1ff 100644
743 --- a/sound/soc/soc-dapm.c
744 +++ b/sound/soc/soc-dapm.c
745 @@ -1343,6 +1343,30 @@ int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
746 EXPORT_SYMBOL_GPL(snd_soc_dapm_set_endpoint);
749 + * snd_soc_dapm_get_endpoint - get audio endpoint status
750 + * @codec: audio codec
751 + * @endpoint: audio signal endpoint (or start point)
753 + * Get audio endpoint status - connected or disconnected.
757 +int snd_soc_dapm_get_endpoint(struct snd_soc_codec *codec,
760 + struct snd_soc_dapm_widget *w;
762 + list_for_each_entry(w, &codec->dapm_widgets, list) {
763 + if (!strcmp(w->name, endpoint)) {
764 + return w->connected;
770 +EXPORT_SYMBOL_GPL(snd_soc_dapm_get_endpoint);
773 * snd_soc_dapm_free - free dapm resources
774 * @socdev: SoC device