initialize the url field for packages
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1037-gta02-sound.patch.patch
1 From c7b72aecf04a0a51e04f7d9346757c7068e0a74d Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Fri, 4 Apr 2008 11:35:32 +0100
4 Subject: [PATCH] gta02-sound.patch
5
6 ---
7 include/sound/soc-dapm.h | 2 +
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, 705 insertions(+), 0 deletions(-)
13 create mode 100644 sound/soc/s3c24xx/neo1973_gta02_wm8753.c
14
15 diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
16 index 2b1ae8e..204be0b 100644
17 --- a/include/sound/soc-dapm.h
18 +++ b/include/sound/soc-dapm.h
19 @@ -206,6 +206,8 @@ int snd_soc_dapm_sys_add(struct device *dev);
20 /* dapm audio endpoint control */
21 int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
22 char *pin, int status);
23 +int snd_soc_dapm_get_endpoint(struct snd_soc_codec *codec,
24 + char *pin);
25 int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec);
26
27 /* dapm widget types */
28 diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
29 index 5632a2e..4146ac4 100644
30 --- a/sound/soc/s3c24xx/Kconfig
31 +++ b/sound/soc/s3c24xx/Kconfig
32 @@ -25,6 +25,15 @@ config SND_S3C24XX_SOC_NEO1973_WM8753
33 Say Y if you want to add support for SoC audio on smdk2440
34 with the WM8753.
35
36 +config SND_S3C24XX_SOC_NEO1973_GTA02_WM8753
37 + tristate "SoC I2S Audio support for NEO1973 GTA02 - WM8753"
38 + depends on SND_S3C24XX_SOC && MACH_NEO1973_GTA02
39 + select SND_S3C24XX_SOC_I2S
40 + select SND_SOC_WM8753
41 + help
42 + Say Y if you want to add support for SoC audio on neo1973 gta02
43 + with the WM8753 codec
44 +
45 config SND_S3C24XX_SOC_SMDK2443_WM9710
46 tristate "SoC AC97 Audio support for SMDK2443 - WM9710"
47 depends on SND_S3C24XX_SOC && MACH_SMDK2443
48 diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
49 index 13c92f0..e356071 100644
50 --- a/sound/soc/s3c24xx/Makefile
51 +++ b/sound/soc/s3c24xx/Makefile
52 @@ -10,6 +10,9 @@ obj-$(CONFIG_SND_S3C2443_SOC_AC97) += snd-soc-s3c2443-ac97.o
53 # S3C24XX Machine Support
54 snd-soc-neo1973-wm8753-objs := neo1973_wm8753.o
55 snd-soc-smdk2443-wm9710-objs := smdk2443_wm9710.o
56 +snd-soc-neo1973-gta02-wm8753-objs := neo1973_gta02_wm8753.o
57
58 obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o
59 obj-$(CONFIG_SND_S3C24XX_SOC_SMDK2443_WM9710) += snd-soc-smdk2443-wm9710.o
60 +obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_GTA02_WM8753) += snd-soc-neo1973-gta02-wm8753.o
61 +
62 diff --git a/sound/soc/s3c24xx/neo1973_gta02_wm8753.c b/sound/soc/s3c24xx/neo1973_gta02_wm8753.c
63 new file mode 100644
64 index 0000000..f32cba3
65 --- /dev/null
66 +++ b/sound/soc/s3c24xx/neo1973_gta02_wm8753.c
67 @@ -0,0 +1,667 @@
68 +/*
69 + * neo1973_gta02_wm8753.c -- SoC audio for Neo1973
70 + *
71 + * Copyright 2007 OpenMoko Inc
72 + * Author: Graeme Gregory <graeme@openmoko.org>
73 + * Copyright 2007 Wolfson Microelectronics PLC.
74 + * Author: Graeme Gregory <linux@wolfsonmicro.com>
75 + *
76 + * This program is free software; you can redistribute it and/or modify it
77 + * under the terms of the GNU General Public License as published by the
78 + * Free Software Foundation; either version 2 of the License, or (at your
79 + * option) any later version.
80 + *
81 + * Revision history
82 + * 06th Nov 2007 Changed from GTA01 to GTA02
83 + * 20th Jan 2007 Initial version.
84 + * 05th Feb 2007 Rename all to Neo1973
85 + *
86 + */
87 +
88 +#include <linux/module.h>
89 +#include <linux/moduleparam.h>
90 +#include <linux/timer.h>
91 +#include <linux/interrupt.h>
92 +#include <linux/platform_device.h>
93 +#include <linux/i2c.h>
94 +#include <sound/driver.h>
95 +#include <sound/core.h>
96 +#include <sound/pcm.h>
97 +#include <sound/soc.h>
98 +#include <sound/soc-dapm.h>
99 +
100 +#include <asm/mach-types.h>
101 +#include <asm/hardware/scoop.h>
102 +#include <asm/plat-s3c24xx/regs-iis.h>
103 +#include <asm/arch/regs-clock.h>
104 +#include <asm/arch/regs-gpio.h>
105 +#include <asm/hardware.h>
106 +#include <asm/arch/audio.h>
107 +#include <asm/io.h>
108 +#include <asm/arch/spi-gpio.h>
109 +#include <asm/arch/regs-gpioj.h>
110 +#include <asm/arch/gta02.h>
111 +#include "../codecs/wm8753.h"
112 +#include "s3c24xx-pcm.h"
113 +#include "s3c24xx-i2s.h"
114 +
115 +/* define the scenarios */
116 +#define NEO_AUDIO_OFF 0
117 +#define NEO_GSM_CALL_AUDIO_HANDSET 1
118 +#define NEO_GSM_CALL_AUDIO_HEADSET 2
119 +#define NEO_GSM_CALL_AUDIO_BLUETOOTH 3
120 +#define NEO_STEREO_TO_SPEAKERS 4
121 +#define NEO_STEREO_TO_HEADPHONES 5
122 +#define NEO_CAPTURE_HANDSET 6
123 +#define NEO_CAPTURE_HEADSET 7
124 +#define NEO_CAPTURE_BLUETOOTH 8
125 +#define NEO_STEREO_TO_HANDSET_SPK 9
126 +
127 +static struct snd_soc_machine neo1973_gta02;
128 +
129 +static int neo1973_gta02_hifi_hw_params(struct snd_pcm_substream *substream,
130 + struct snd_pcm_hw_params *params)
131 +{
132 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
133 + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
134 + struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
135 + unsigned int pll_out = 0, bclk = 0;
136 + int ret = 0;
137 + unsigned long iis_clkrate;
138 +
139 + iis_clkrate = s3c24xx_i2s_get_clockrate();
140 +
141 + switch (params_rate(params)) {
142 + case 8000:
143 + case 16000:
144 + pll_out = 12288000;
145 + break;
146 + case 48000:
147 + bclk = WM8753_BCLK_DIV_4;
148 + pll_out = 12288000;
149 + break;
150 + case 96000:
151 + bclk = WM8753_BCLK_DIV_2;
152 + pll_out = 12288000;
153 + break;
154 + case 11025:
155 + bclk = WM8753_BCLK_DIV_16;
156 + pll_out = 11289600;
157 + break;
158 + case 22050:
159 + bclk = WM8753_BCLK_DIV_8;
160 + pll_out = 11289600;
161 + break;
162 + case 44100:
163 + bclk = WM8753_BCLK_DIV_4;
164 + pll_out = 11289600;
165 + break;
166 + case 88200:
167 + bclk = WM8753_BCLK_DIV_2;
168 + pll_out = 11289600;
169 + break;
170 + }
171 +
172 + /* set codec DAI configuration */
173 + ret = codec_dai->dai_ops.set_fmt(codec_dai,
174 + SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
175 + SND_SOC_DAIFMT_CBM_CFM);
176 + if (ret < 0)
177 + return ret;
178 +
179 + /* set cpu DAI configuration */
180 + ret = cpu_dai->dai_ops.set_fmt(cpu_dai,
181 + SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
182 + SND_SOC_DAIFMT_CBM_CFM);
183 + if (ret < 0)
184 + return ret;
185 +
186 + /* set the codec system clock for DAC and ADC */
187 + ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8753_MCLK, pll_out,
188 + SND_SOC_CLOCK_IN);
189 + if (ret < 0)
190 + return ret;
191 +
192 + /* set MCLK division for sample rate */
193 + ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
194 + S3C2410_IISMOD_32FS );
195 + if (ret < 0)
196 + return ret;
197 +
198 + /* set codec BCLK division for sample rate */
199 + ret = codec_dai->dai_ops.set_clkdiv(codec_dai,
200 + WM8753_BCLKDIV, bclk);
201 + if (ret < 0)
202 + return ret;
203 +
204 + /* set prescaler division for sample rate */
205 + ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER,
206 + S3C24XX_PRESCALE(4,4));
207 + if (ret < 0)
208 + return ret;
209 +
210 + /* codec PLL input is PCLK/4 */
211 + ret = codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL1,
212 + iis_clkrate / 4, pll_out);
213 + if (ret < 0)
214 + return ret;
215 +
216 + return 0;
217 +}
218 +
219 +static int neo1973_gta02_hifi_hw_free(struct snd_pcm_substream *substream)
220 +{
221 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
222 + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
223 +
224 + /* disable the PLL */
225 + return codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL1, 0, 0);
226 +}
227 +
228 +/*
229 + * Neo1973 WM8753 HiFi DAI opserations.
230 + */
231 +static struct snd_soc_ops neo1973_gta02_hifi_ops = {
232 + .hw_params = neo1973_gta02_hifi_hw_params,
233 + .hw_free = neo1973_gta02_hifi_hw_free,
234 +};
235 +
236 +static int neo1973_gta02_voice_hw_params(
237 + struct snd_pcm_substream *substream,
238 + struct snd_pcm_hw_params *params)
239 +{
240 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
241 + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
242 + unsigned int pcmdiv = 0;
243 + int ret = 0;
244 + unsigned long iis_clkrate;
245 +
246 + iis_clkrate = s3c24xx_i2s_get_clockrate();
247 +
248 + if (params_rate(params) != 8000)
249 + return -EINVAL;
250 + if (params_channels(params) != 1)
251 + return -EINVAL;
252 +
253 + pcmdiv = WM8753_PCM_DIV_6; /* 2.048 MHz */
254 +
255 + /* todo: gg check mode (DSP_B) against CSR datasheet */
256 + /* set codec DAI configuration */
257 + ret = codec_dai->dai_ops.set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B |
258 + SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
259 + if (ret < 0)
260 + return ret;
261 +
262 + /* set the codec system clock for DAC and ADC */
263 + ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8753_PCMCLK,
264 + 12288000, SND_SOC_CLOCK_IN);
265 + if (ret < 0)
266 + return ret;
267 +
268 + /* set codec PCM division for sample rate */
269 + ret = codec_dai->dai_ops.set_clkdiv(codec_dai, WM8753_PCMDIV,
270 + pcmdiv);
271 + if (ret < 0)
272 + return ret;
273 +
274 + /* configue and enable PLL for 12.288MHz output */
275 + ret = codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL2,
276 + iis_clkrate / 4, 12288000);
277 + if (ret < 0)
278 + return ret;
279 +
280 + return 0;
281 +}
282 +
283 +static int neo1973_gta02_voice_hw_free(struct snd_pcm_substream *substream)
284 +{
285 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
286 + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
287 +
288 + /* disable the PLL */
289 + return codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL2, 0, 0);
290 +}
291 +
292 +static struct snd_soc_ops neo1973_gta02_voice_ops = {
293 + .hw_params = neo1973_gta02_voice_hw_params,
294 + .hw_free = neo1973_gta02_voice_hw_free,
295 +};
296 +
297 +#define LM4853_AMP 1
298 +#define LM4853_SPK 2
299 +
300 +static u8 lm4853_state=0;
301 +
302 +static int lm4853_set_state(struct snd_kcontrol *kcontrol,
303 + struct snd_ctl_elem_value *ucontrol)
304 +{
305 + int val = ucontrol->value.integer.value[0];
306 +
307 + if(val) {
308 + lm4853_state |= LM4853_AMP;
309 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT,0);
310 + } else {
311 + lm4853_state &= ~LM4853_AMP;
312 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT,1);
313 + }
314 +
315 + return 0;
316 +}
317 +
318 +static int lm4853_get_state(struct snd_kcontrol *kcontrol,
319 + struct snd_ctl_elem_value *ucontrol)
320 +{
321 + ucontrol->value.integer.value[0] = lm4853_state & LM4853_AMP;
322 +
323 + return 0;
324 +}
325 +
326 +static int lm4853_set_spk(struct snd_kcontrol *kcontrol,
327 + struct snd_ctl_elem_value *ucontrol)
328 +{
329 + int val = ucontrol->value.integer.value[0];
330 +
331 + if(val) {
332 + lm4853_state |= LM4853_SPK;
333 + s3c2410_gpio_setpin(GTA02_GPIO_HP_IN,0);
334 + } else {
335 + lm4853_state &= ~LM4853_SPK;
336 + s3c2410_gpio_setpin(GTA02_GPIO_HP_IN,1);
337 + }
338 +
339 + return 0;
340 +}
341 +
342 +static int lm4853_get_spk(struct snd_kcontrol *kcontrol,
343 + struct snd_ctl_elem_value *ucontrol)
344 +{
345 + ucontrol->value.integer.value[0] = (lm4853_state & LM4853_SPK) >> 1;
346 +
347 + return 0;
348 +}
349 +
350 +static int neo1973_gta02_set_stereo_out(struct snd_kcontrol *kcontrol,
351 + struct snd_ctl_elem_value *ucontrol)
352 +{
353 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
354 + int val = ucontrol->value.integer.value[0];
355 +
356 + snd_soc_dapm_set_endpoint(codec, "Stereo Out", val);
357 +
358 + snd_soc_dapm_sync_endpoints(codec);
359 +
360 + return 0;
361 +}
362 +
363 +static int neo1973_gta02_get_stereo_out(struct snd_kcontrol *kcontrol,
364 + struct snd_ctl_elem_value *ucontrol)
365 +{
366 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
367 +
368 + ucontrol->value.integer.value[0] =
369 + snd_soc_dapm_get_endpoint(codec, "Stereo Out");
370 +
371 + return 0;
372 +}
373 +
374 +
375 +static int neo1973_gta02_set_gsm_out(struct snd_kcontrol *kcontrol,
376 + struct snd_ctl_elem_value *ucontrol)
377 +{
378 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
379 + int val = ucontrol->value.integer.value[0];
380 +
381 + snd_soc_dapm_set_endpoint(codec, "GSM Line Out", val);
382 +
383 + snd_soc_dapm_sync_endpoints(codec);
384 +
385 + return 0;
386 +}
387 +
388 +static int neo1973_gta02_get_gsm_out(struct snd_kcontrol *kcontrol,
389 + struct snd_ctl_elem_value *ucontrol)
390 +{
391 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
392 +
393 + ucontrol->value.integer.value[0] =
394 + snd_soc_dapm_get_endpoint(codec, "GSM Line Out");
395 +
396 + return 0;
397 +}
398 +
399 +static int neo1973_gta02_set_gsm_in(struct snd_kcontrol *kcontrol,
400 + struct snd_ctl_elem_value *ucontrol)
401 +{
402 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
403 + int val = ucontrol->value.integer.value[0];
404 +
405 + snd_soc_dapm_set_endpoint(codec, "GSM Line In", val);
406 +
407 + snd_soc_dapm_sync_endpoints(codec);
408 +
409 + return 0;
410 +}
411 +
412 +static int neo1973_gta02_get_gsm_in(struct snd_kcontrol *kcontrol,
413 + struct snd_ctl_elem_value *ucontrol)
414 +{
415 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
416 +
417 + ucontrol->value.integer.value[0] =
418 + snd_soc_dapm_get_endpoint(codec, "GSM Line In");
419 +
420 + return 0;
421 +}
422 +
423 +static int neo1973_gta02_set_headset_mic(struct snd_kcontrol *kcontrol,
424 + struct snd_ctl_elem_value *ucontrol)
425 +{
426 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
427 + int val = ucontrol->value.integer.value[0];
428 +
429 + snd_soc_dapm_set_endpoint(codec, "Headset Mic", val);
430 +
431 + snd_soc_dapm_sync_endpoints(codec);
432 +
433 + return 0;
434 +}
435 +
436 +static int neo1973_gta02_get_headset_mic(struct snd_kcontrol *kcontrol,
437 + struct snd_ctl_elem_value *ucontrol)
438 +{
439 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
440 +
441 + ucontrol->value.integer.value[0] =
442 + snd_soc_dapm_get_endpoint(codec, "Headset Mic");
443 +
444 + return 0;
445 +}
446 +
447 +static int neo1973_gta02_set_handset_mic(struct snd_kcontrol *kcontrol,
448 + struct snd_ctl_elem_value *ucontrol)
449 +{
450 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
451 + int val = ucontrol->value.integer.value[0];
452 +
453 + snd_soc_dapm_set_endpoint(codec, "Handset Mic", val);
454 +
455 + snd_soc_dapm_sync_endpoints(codec);
456 +
457 + return 0;
458 +}
459 +
460 +static int neo1973_gta02_get_handset_mic(struct snd_kcontrol *kcontrol,
461 + struct snd_ctl_elem_value *ucontrol)
462 +{
463 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
464 +
465 + ucontrol->value.integer.value[0] =
466 + snd_soc_dapm_get_endpoint(codec, "Handset Mic");
467 +
468 + return 0;
469 +}
470 +
471 +static int neo1973_gta02_set_handset_spk(struct snd_kcontrol *kcontrol,
472 + struct snd_ctl_elem_value *ucontrol)
473 +{
474 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
475 + int val = ucontrol->value.integer.value[0];
476 +
477 + snd_soc_dapm_set_endpoint(codec, "Handset Spk", val);
478 +
479 + snd_soc_dapm_sync_endpoints(codec);
480 +
481 + return 0;
482 +}
483 +
484 +static int neo1973_gta02_get_handset_spk(struct snd_kcontrol *kcontrol,
485 + struct snd_ctl_elem_value *ucontrol)
486 +{
487 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
488 +
489 + ucontrol->value.integer.value[0] =
490 + snd_soc_dapm_get_endpoint(codec, "Handset Spk");
491 +
492 + return 0;
493 +}
494 +
495 +static const struct snd_soc_dapm_widget wm8753_dapm_widgets[] = {
496 + SND_SOC_DAPM_LINE("Stereo Out", NULL),
497 + SND_SOC_DAPM_LINE("GSM Line Out", NULL),
498 + SND_SOC_DAPM_LINE("GSM Line In", NULL),
499 + SND_SOC_DAPM_MIC("Headset Mic", NULL),
500 + SND_SOC_DAPM_MIC("Handset Mic", NULL),
501 + SND_SOC_DAPM_SPK("Handset Spk", NULL),
502 +};
503 +
504 +
505 +/* example machine audio_mapnections */
506 +static const char* audio_map[][3] = {
507 +
508 + /* Connections to the lm4853 amp */
509 + {"Stereo Out", NULL, "LOUT1"},
510 + {"Stereo Out", NULL, "ROUT1"},
511 +
512 + /* Connections to the GSM Module */
513 + {"GSM Line Out", NULL, "MONO1"},
514 + {"GSM Line Out", NULL, "MONO2"},
515 + {"RXP", NULL, "GSM Line In"},
516 + {"RXN", NULL, "GSM Line In"},
517 +
518 + /* Connections to Headset */
519 + {"MIC1", NULL, "Mic Bias"},
520 + {"Mic Bias", NULL, "Headset Mic"},
521 +
522 + /* Call Mic */
523 + {"MIC2", NULL, "Mic Bias"},
524 + {"MIC2N", NULL, "Mic Bias"},
525 + {"Mic Bias", NULL, "Handset Mic"},
526 +
527 + /* Call Speaker */
528 + {"Handset Spk", NULL, "LOUT2"},
529 + {"Handset Spk", NULL, "ROUT2"},
530 +
531 + /* Connect the ALC pins */
532 + {"ACIN", NULL, "ACOP"},
533 +
534 + {NULL, NULL, NULL},
535 +};
536 +
537 +static const struct snd_kcontrol_new wm8753_neo1973_gta02_controls[] = {
538 + SOC_SINGLE_EXT("DAPM Stereo Out Switch", 0, 0, 1, 0,
539 + neo1973_gta02_get_stereo_out,
540 + neo1973_gta02_set_stereo_out),
541 + SOC_SINGLE_EXT("DAPM GSM Line Out Switch", 1, 0, 1, 0,
542 + neo1973_gta02_get_gsm_out,
543 + neo1973_gta02_set_gsm_out),
544 + SOC_SINGLE_EXT("DAPM GSM Line In Switch", 2, 0, 1, 0,
545 + neo1973_gta02_get_gsm_in,
546 + neo1973_gta02_set_gsm_in),
547 + SOC_SINGLE_EXT("DAPM Headset Mic Switch", 3, 0, 1, 0,
548 + neo1973_gta02_get_headset_mic,
549 + neo1973_gta02_set_headset_mic),
550 + SOC_SINGLE_EXT("DAPM Handset Mic Switch", 4, 0, 1, 0,
551 + neo1973_gta02_get_handset_mic,
552 + neo1973_gta02_set_handset_mic),
553 + SOC_SINGLE_EXT("DAPM Handset Spk Switch", 5, 0, 1, 0,
554 + neo1973_gta02_get_handset_spk,
555 + neo1973_gta02_set_handset_spk),
556 + SOC_SINGLE_EXT("Amp State Switch", 6, 0, 1, 0,
557 + lm4853_get_state,
558 + lm4853_set_state),
559 + SOC_SINGLE_EXT("Amp Spk Switch", 7, 0, 1, 0,
560 + lm4853_get_spk,
561 + lm4853_set_spk),
562 +};
563 +
564 +/*
565 + * This is an example machine initialisation for a wm8753 connected to a
566 + * neo1973 GTA02.
567 + */
568 +static int neo1973_gta02_wm8753_init(struct snd_soc_codec *codec)
569 +{
570 + int i, err;
571 +
572 + /* set up NC codec pins */
573 + snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
574 + snd_soc_dapm_set_endpoint(codec, "OUT4", 0);
575 + snd_soc_dapm_set_endpoint(codec, "LINE1", 0);
576 + snd_soc_dapm_set_endpoint(codec, "LINE2", 0);
577 +
578 + /* Add neo1973 gta02 specific widgets */
579 + for (i = 0; i < ARRAY_SIZE(wm8753_dapm_widgets); i++)
580 + snd_soc_dapm_new_control(codec, &wm8753_dapm_widgets[i]);
581 +
582 + /* add neo1973 gta02 specific controls */
583 + for (i = 0; i < ARRAY_SIZE(wm8753_neo1973_gta02_controls); i++) {
584 + err = snd_ctl_add(codec->card,
585 + snd_soc_cnew(&wm8753_neo1973_gta02_controls[i],
586 + codec, NULL));
587 + if (err < 0)
588 + return err;
589 + }
590 +
591 + /* set up neo1973 gta02 specific audio path audio_mapnects */
592 + for (i = 0; audio_map[i][0] != NULL; i++) {
593 + snd_soc_dapm_connect_input(codec, audio_map[i][0],
594 + audio_map[i][1], audio_map[i][2]);
595 + }
596 +
597 + /* set endpoints to default off mode */
598 + snd_soc_dapm_set_endpoint(codec, "Stereo Out", 0);
599 + snd_soc_dapm_set_endpoint(codec, "GSM Line Out",0);
600 + snd_soc_dapm_set_endpoint(codec, "GSM Line In", 0);
601 + snd_soc_dapm_set_endpoint(codec, "Headset Mic", 0);
602 + snd_soc_dapm_set_endpoint(codec, "Handset Mic", 0);
603 + snd_soc_dapm_set_endpoint(codec, "Handset Spk", 0);
604 +
605 + snd_soc_dapm_sync_endpoints(codec);
606 + return 0;
607 +}
608 +
609 +/*
610 + * BT Codec DAI
611 + */
612 +static struct snd_soc_cpu_dai bt_dai =
613 +{ .name = "Bluetooth",
614 + .id = 0,
615 + .type = SND_SOC_DAI_PCM,
616 + .playback = {
617 + .channels_min = 1,
618 + .channels_max = 1,
619 + .rates = SNDRV_PCM_RATE_8000,
620 + .formats = SNDRV_PCM_FMTBIT_S16_LE,},
621 + .capture = {
622 + .channels_min = 1,
623 + .channels_max = 1,
624 + .rates = SNDRV_PCM_RATE_8000,
625 + .formats = SNDRV_PCM_FMTBIT_S16_LE,},
626 +};
627 +
628 +static struct snd_soc_dai_link neo1973_gta02_dai[] = {
629 +{ /* Hifi Playback - for similatious use with voice below */
630 + .name = "WM8753",
631 + .stream_name = "WM8753 HiFi",
632 + .cpu_dai = &s3c24xx_i2s_dai,
633 + .codec_dai = &wm8753_dai[WM8753_DAI_HIFI],
634 + .init = neo1973_gta02_wm8753_init,
635 + .ops = &neo1973_gta02_hifi_ops,
636 +},
637 +{ /* Voice via BT */
638 + .name = "Bluetooth",
639 + .stream_name = "Voice",
640 + .cpu_dai = &bt_dai,
641 + .codec_dai = &wm8753_dai[WM8753_DAI_VOICE],
642 + .ops = &neo1973_gta02_voice_ops,
643 +},
644 +};
645 +
646 +#ifdef CONFIG_PM
647 +int neo1973_gta02_suspend(struct platform_device *pdev, pm_message_t state)
648 +{
649 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT, 1);
650 +
651 + return 0;
652 +}
653 +
654 +int neo1973_gta02_resume(struct platform_device *pdev)
655 +{
656 + if(lm4853_state & LM4853_AMP)
657 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT, 0);
658 +
659 + return 0;
660 +}
661 +#else
662 +#define neo1973_gta02_suspend NULL
663 +#define neo1973_gta02_resume NULL
664 +#endif
665 +
666 +static struct snd_soc_machine neo1973_gta02 = {
667 + .name = "neo1973-gta02",
668 + .suspend_pre = neo1973_gta02_suspend,
669 + .resume_post = neo1973_gta02_resume,
670 + .dai_link = neo1973_gta02_dai,
671 + .num_links = ARRAY_SIZE(neo1973_gta02_dai),
672 +};
673 +
674 +static struct wm8753_setup_data neo1973_gta02_wm8753_setup = {
675 + .i2c_address = 0x1a,
676 +};
677 +
678 +static struct snd_soc_device neo1973_gta02_snd_devdata = {
679 + .machine = &neo1973_gta02,
680 + .platform = &s3c24xx_soc_platform,
681 + .codec_dev = &soc_codec_dev_wm8753,
682 + .codec_data = &neo1973_gta02_wm8753_setup,
683 +};
684 +
685 +static struct platform_device *neo1973_gta02_snd_device;
686 +
687 +static int __init neo1973_gta02_init(void)
688 +{
689 + int ret;
690 +
691 + if (!machine_is_neo1973_gta02()) {
692 + printk(KERN_INFO
693 + "Only GTA02 hardware supported by ASoc driver\n");
694 + return -ENODEV;
695 + }
696 +
697 + neo1973_gta02_snd_device = platform_device_alloc("soc-audio", -1);
698 + if (!neo1973_gta02_snd_device)
699 + return -ENOMEM;
700 +
701 + platform_set_drvdata(neo1973_gta02_snd_device,
702 + &neo1973_gta02_snd_devdata);
703 + neo1973_gta02_snd_devdata.dev = &neo1973_gta02_snd_device->dev;
704 + ret = platform_device_add(neo1973_gta02_snd_device);
705 +
706 + if (ret)
707 + platform_device_put(neo1973_gta02_snd_device);
708 +
709 + /* Initialise GPIOs used by amp */
710 + s3c2410_gpio_cfgpin(GTA02_GPIO_HP_IN, S3C2410_GPIO_OUTPUT);
711 + s3c2410_gpio_cfgpin(GTA02_GPIO_AMP_SHUT, S3C2410_GPIO_OUTPUT);
712 +
713 + /* Amp off by default */
714 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT, 1);
715 +
716 + /* Speaker off by default */
717 + s3c2410_gpio_setpin(GTA02_GPIO_HP_IN, 1);
718 +
719 + return ret;
720 +}
721 +
722 +static void __exit neo1973_gta02_exit(void)
723 +{
724 + platform_device_unregister(neo1973_gta02_snd_device);
725 +}
726 +
727 +module_init(neo1973_gta02_init);
728 +module_exit(neo1973_gta02_exit);
729 +
730 +/* Module information */
731 +MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org");
732 +MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973 GTA02");
733 +MODULE_LICENSE("GPL");
734 +
735 diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
736 index 29a546f..84fa860 100644
737 --- a/sound/soc/soc-dapm.c
738 +++ b/sound/soc/soc-dapm.c
739 @@ -1305,6 +1305,30 @@ int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
740 EXPORT_SYMBOL_GPL(snd_soc_dapm_set_endpoint);
741
742 /**
743 + * snd_soc_dapm_get_endpoint - get audio endpoint status
744 + * @codec: audio codec
745 + * @endpoint: audio signal endpoint (or start point)
746 + *
747 + * Get audio endpoint status - connected or disconnected.
748 + *
749 + * Returns status
750 + */
751 +int snd_soc_dapm_get_endpoint(struct snd_soc_codec *codec,
752 + char *endpoint)
753 +{
754 + struct snd_soc_dapm_widget *w;
755 +
756 + list_for_each_entry(w, &codec->dapm_widgets, list) {
757 + if (!strcmp(w->name, endpoint)) {
758 + return w->connected;
759 + }
760 + }
761 +
762 + return 0;
763 +}
764 +EXPORT_SYMBOL_GPL(snd_soc_dapm_get_endpoint);
765 +
766 +/**
767 * snd_soc_dapm_free - free dapm resources
768 * @socdev: SoC device
769 *
770 --
771 1.5.6.5
772
This page took 0.090567 seconds and 5 git commands to generate.