[ar71xx] create firmware image for the Ubiquiti LS-SR71 board
[openwrt.git] / target / linux / s3c24xx / patches-2.6.26 / 1030-gta02-sound.patch.patch
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
5
6 ---
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
14
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);
22
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,
27 + char *pin);
28 +int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec);
29 +
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
39 with the WM8753.
40
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
46 + help
47 + Say Y if you want to add support for SoC audio on neo1973 gta02
48 + with the WM8753 codec
49 +
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
62
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
67 +
68 diff --git a/sound/soc/s3c24xx/neo1973_gta02_wm8753.c b/sound/soc/s3c24xx/neo1973_gta02_wm8753.c
69 new file mode 100644
70 index 0000000..f32cba3
71 --- /dev/null
72 +++ b/sound/soc/s3c24xx/neo1973_gta02_wm8753.c
73 @@ -0,0 +1,667 @@
74 +/*
75 + * neo1973_gta02_wm8753.c -- SoC audio for Neo1973
76 + *
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>
81 + *
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.
86 + *
87 + * Revision history
88 + * 06th Nov 2007 Changed from GTA01 to GTA02
89 + * 20th Jan 2007 Initial version.
90 + * 05th Feb 2007 Rename all to Neo1973
91 + *
92 + */
93 +
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>
105 +
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>
113 +#include <asm/io.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"
120 +
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
132 +
133 +static struct snd_soc_machine neo1973_gta02;
134 +
135 +static int neo1973_gta02_hifi_hw_params(struct snd_pcm_substream *substream,
136 + struct snd_pcm_hw_params *params)
137 +{
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;
142 + int ret = 0;
143 + unsigned long iis_clkrate;
144 +
145 + iis_clkrate = s3c24xx_i2s_get_clockrate();
146 +
147 + switch (params_rate(params)) {
148 + case 8000:
149 + case 16000:
150 + pll_out = 12288000;
151 + break;
152 + case 48000:
153 + bclk = WM8753_BCLK_DIV_4;
154 + pll_out = 12288000;
155 + break;
156 + case 96000:
157 + bclk = WM8753_BCLK_DIV_2;
158 + pll_out = 12288000;
159 + break;
160 + case 11025:
161 + bclk = WM8753_BCLK_DIV_16;
162 + pll_out = 11289600;
163 + break;
164 + case 22050:
165 + bclk = WM8753_BCLK_DIV_8;
166 + pll_out = 11289600;
167 + break;
168 + case 44100:
169 + bclk = WM8753_BCLK_DIV_4;
170 + pll_out = 11289600;
171 + break;
172 + case 88200:
173 + bclk = WM8753_BCLK_DIV_2;
174 + pll_out = 11289600;
175 + break;
176 + }
177 +
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);
182 + if (ret < 0)
183 + return ret;
184 +
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);
189 + if (ret < 0)
190 + return ret;
191 +
192 + /* set the codec system clock for DAC and ADC */
193 + ret = codec_dai->dai_ops.set_sysclk(codec_dai, WM8753_MCLK, pll_out,
194 + SND_SOC_CLOCK_IN);
195 + if (ret < 0)
196 + return ret;
197 +
198 + /* set MCLK division for sample rate */
199 + ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
200 + S3C2410_IISMOD_32FS );
201 + if (ret < 0)
202 + return ret;
203 +
204 + /* set codec BCLK division for sample rate */
205 + ret = codec_dai->dai_ops.set_clkdiv(codec_dai,
206 + WM8753_BCLKDIV, bclk);
207 + if (ret < 0)
208 + return ret;
209 +
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));
213 + if (ret < 0)
214 + return ret;
215 +
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);
219 + if (ret < 0)
220 + return ret;
221 +
222 + return 0;
223 +}
224 +
225 +static int neo1973_gta02_hifi_hw_free(struct snd_pcm_substream *substream)
226 +{
227 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
228 + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
229 +
230 + /* disable the PLL */
231 + return codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL1, 0, 0);
232 +}
233 +
234 +/*
235 + * Neo1973 WM8753 HiFi DAI opserations.
236 + */
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,
240 +};
241 +
242 +static int neo1973_gta02_voice_hw_params(
243 + struct snd_pcm_substream *substream,
244 + struct snd_pcm_hw_params *params)
245 +{
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;
249 + int ret = 0;
250 + unsigned long iis_clkrate;
251 +
252 + iis_clkrate = s3c24xx_i2s_get_clockrate();
253 +
254 + if (params_rate(params) != 8000)
255 + return -EINVAL;
256 + if (params_channels(params) != 1)
257 + return -EINVAL;
258 +
259 + pcmdiv = WM8753_PCM_DIV_6; /* 2.048 MHz */
260 +
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);
265 + if (ret < 0)
266 + return ret;
267 +
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);
271 + if (ret < 0)
272 + return ret;
273 +
274 + /* set codec PCM division for sample rate */
275 + ret = codec_dai->dai_ops.set_clkdiv(codec_dai, WM8753_PCMDIV,
276 + pcmdiv);
277 + if (ret < 0)
278 + return ret;
279 +
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);
283 + if (ret < 0)
284 + return ret;
285 +
286 + return 0;
287 +}
288 +
289 +static int neo1973_gta02_voice_hw_free(struct snd_pcm_substream *substream)
290 +{
291 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
292 + struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai;
293 +
294 + /* disable the PLL */
295 + return codec_dai->dai_ops.set_pll(codec_dai, WM8753_PLL2, 0, 0);
296 +}
297 +
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,
301 +};
302 +
303 +#define LM4853_AMP 1
304 +#define LM4853_SPK 2
305 +
306 +static u8 lm4853_state=0;
307 +
308 +static int lm4853_set_state(struct snd_kcontrol *kcontrol,
309 + struct snd_ctl_elem_value *ucontrol)
310 +{
311 + int val = ucontrol->value.integer.value[0];
312 +
313 + if(val) {
314 + lm4853_state |= LM4853_AMP;
315 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT,0);
316 + } else {
317 + lm4853_state &= ~LM4853_AMP;
318 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT,1);
319 + }
320 +
321 + return 0;
322 +}
323 +
324 +static int lm4853_get_state(struct snd_kcontrol *kcontrol,
325 + struct snd_ctl_elem_value *ucontrol)
326 +{
327 + ucontrol->value.integer.value[0] = lm4853_state & LM4853_AMP;
328 +
329 + return 0;
330 +}
331 +
332 +static int lm4853_set_spk(struct snd_kcontrol *kcontrol,
333 + struct snd_ctl_elem_value *ucontrol)
334 +{
335 + int val = ucontrol->value.integer.value[0];
336 +
337 + if(val) {
338 + lm4853_state |= LM4853_SPK;
339 + s3c2410_gpio_setpin(GTA02_GPIO_HP_IN,0);
340 + } else {
341 + lm4853_state &= ~LM4853_SPK;
342 + s3c2410_gpio_setpin(GTA02_GPIO_HP_IN,1);
343 + }
344 +
345 + return 0;
346 +}
347 +
348 +static int lm4853_get_spk(struct snd_kcontrol *kcontrol,
349 + struct snd_ctl_elem_value *ucontrol)
350 +{
351 + ucontrol->value.integer.value[0] = (lm4853_state & LM4853_SPK) >> 1;
352 +
353 + return 0;
354 +}
355 +
356 +static int neo1973_gta02_set_stereo_out(struct snd_kcontrol *kcontrol,
357 + struct snd_ctl_elem_value *ucontrol)
358 +{
359 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
360 + int val = ucontrol->value.integer.value[0];
361 +
362 + snd_soc_dapm_set_endpoint(codec, "Stereo Out", val);
363 +
364 + snd_soc_dapm_sync_endpoints(codec);
365 +
366 + return 0;
367 +}
368 +
369 +static int neo1973_gta02_get_stereo_out(struct snd_kcontrol *kcontrol,
370 + struct snd_ctl_elem_value *ucontrol)
371 +{
372 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
373 +
374 + ucontrol->value.integer.value[0] =
375 + snd_soc_dapm_get_endpoint(codec, "Stereo Out");
376 +
377 + return 0;
378 +}
379 +
380 +
381 +static int neo1973_gta02_set_gsm_out(struct snd_kcontrol *kcontrol,
382 + struct snd_ctl_elem_value *ucontrol)
383 +{
384 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
385 + int val = ucontrol->value.integer.value[0];
386 +
387 + snd_soc_dapm_set_endpoint(codec, "GSM Line Out", val);
388 +
389 + snd_soc_dapm_sync_endpoints(codec);
390 +
391 + return 0;
392 +}
393 +
394 +static int neo1973_gta02_get_gsm_out(struct snd_kcontrol *kcontrol,
395 + struct snd_ctl_elem_value *ucontrol)
396 +{
397 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
398 +
399 + ucontrol->value.integer.value[0] =
400 + snd_soc_dapm_get_endpoint(codec, "GSM Line Out");
401 +
402 + return 0;
403 +}
404 +
405 +static int neo1973_gta02_set_gsm_in(struct snd_kcontrol *kcontrol,
406 + struct snd_ctl_elem_value *ucontrol)
407 +{
408 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
409 + int val = ucontrol->value.integer.value[0];
410 +
411 + snd_soc_dapm_set_endpoint(codec, "GSM Line In", val);
412 +
413 + snd_soc_dapm_sync_endpoints(codec);
414 +
415 + return 0;
416 +}
417 +
418 +static int neo1973_gta02_get_gsm_in(struct snd_kcontrol *kcontrol,
419 + struct snd_ctl_elem_value *ucontrol)
420 +{
421 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
422 +
423 + ucontrol->value.integer.value[0] =
424 + snd_soc_dapm_get_endpoint(codec, "GSM Line In");
425 +
426 + return 0;
427 +}
428 +
429 +static int neo1973_gta02_set_headset_mic(struct snd_kcontrol *kcontrol,
430 + struct snd_ctl_elem_value *ucontrol)
431 +{
432 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
433 + int val = ucontrol->value.integer.value[0];
434 +
435 + snd_soc_dapm_set_endpoint(codec, "Headset Mic", val);
436 +
437 + snd_soc_dapm_sync_endpoints(codec);
438 +
439 + return 0;
440 +}
441 +
442 +static int neo1973_gta02_get_headset_mic(struct snd_kcontrol *kcontrol,
443 + struct snd_ctl_elem_value *ucontrol)
444 +{
445 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
446 +
447 + ucontrol->value.integer.value[0] =
448 + snd_soc_dapm_get_endpoint(codec, "Headset Mic");
449 +
450 + return 0;
451 +}
452 +
453 +static int neo1973_gta02_set_handset_mic(struct snd_kcontrol *kcontrol,
454 + struct snd_ctl_elem_value *ucontrol)
455 +{
456 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
457 + int val = ucontrol->value.integer.value[0];
458 +
459 + snd_soc_dapm_set_endpoint(codec, "Handset Mic", val);
460 +
461 + snd_soc_dapm_sync_endpoints(codec);
462 +
463 + return 0;
464 +}
465 +
466 +static int neo1973_gta02_get_handset_mic(struct snd_kcontrol *kcontrol,
467 + struct snd_ctl_elem_value *ucontrol)
468 +{
469 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
470 +
471 + ucontrol->value.integer.value[0] =
472 + snd_soc_dapm_get_endpoint(codec, "Handset Mic");
473 +
474 + return 0;
475 +}
476 +
477 +static int neo1973_gta02_set_handset_spk(struct snd_kcontrol *kcontrol,
478 + struct snd_ctl_elem_value *ucontrol)
479 +{
480 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
481 + int val = ucontrol->value.integer.value[0];
482 +
483 + snd_soc_dapm_set_endpoint(codec, "Handset Spk", val);
484 +
485 + snd_soc_dapm_sync_endpoints(codec);
486 +
487 + return 0;
488 +}
489 +
490 +static int neo1973_gta02_get_handset_spk(struct snd_kcontrol *kcontrol,
491 + struct snd_ctl_elem_value *ucontrol)
492 +{
493 + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
494 +
495 + ucontrol->value.integer.value[0] =
496 + snd_soc_dapm_get_endpoint(codec, "Handset Spk");
497 +
498 + return 0;
499 +}
500 +
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),
508 +};
509 +
510 +
511 +/* example machine audio_mapnections */
512 +static const char* audio_map[][3] = {
513 +
514 + /* Connections to the lm4853 amp */
515 + {"Stereo Out", NULL, "LOUT1"},
516 + {"Stereo Out", NULL, "ROUT1"},
517 +
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"},
523 +
524 + /* Connections to Headset */
525 + {"MIC1", NULL, "Mic Bias"},
526 + {"Mic Bias", NULL, "Headset Mic"},
527 +
528 + /* Call Mic */
529 + {"MIC2", NULL, "Mic Bias"},
530 + {"MIC2N", NULL, "Mic Bias"},
531 + {"Mic Bias", NULL, "Handset Mic"},
532 +
533 + /* Call Speaker */
534 + {"Handset Spk", NULL, "LOUT2"},
535 + {"Handset Spk", NULL, "ROUT2"},
536 +
537 + /* Connect the ALC pins */
538 + {"ACIN", NULL, "ACOP"},
539 +
540 + {NULL, NULL, NULL},
541 +};
542 +
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,
563 + lm4853_get_state,
564 + lm4853_set_state),
565 + SOC_SINGLE_EXT("Amp Spk Switch", 7, 0, 1, 0,
566 + lm4853_get_spk,
567 + lm4853_set_spk),
568 +};
569 +
570 +/*
571 + * This is an example machine initialisation for a wm8753 connected to a
572 + * neo1973 GTA02.
573 + */
574 +static int neo1973_gta02_wm8753_init(struct snd_soc_codec *codec)
575 +{
576 + int i, err;
577 +
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);
583 +
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]);
587 +
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],
592 + codec, NULL));
593 + if (err < 0)
594 + return err;
595 + }
596 +
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]);
601 + }
602 +
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);
610 +
611 + snd_soc_dapm_sync_endpoints(codec);
612 + return 0;
613 +}
614 +
615 +/*
616 + * BT Codec DAI
617 + */
618 +static struct snd_soc_cpu_dai bt_dai =
619 +{ .name = "Bluetooth",
620 + .id = 0,
621 + .type = SND_SOC_DAI_PCM,
622 + .playback = {
623 + .channels_min = 1,
624 + .channels_max = 1,
625 + .rates = SNDRV_PCM_RATE_8000,
626 + .formats = SNDRV_PCM_FMTBIT_S16_LE,},
627 + .capture = {
628 + .channels_min = 1,
629 + .channels_max = 1,
630 + .rates = SNDRV_PCM_RATE_8000,
631 + .formats = SNDRV_PCM_FMTBIT_S16_LE,},
632 +};
633 +
634 +static struct snd_soc_dai_link neo1973_gta02_dai[] = {
635 +{ /* Hifi Playback - for similatious use with voice below */
636 + .name = "WM8753",
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,
642 +},
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,
649 +},
650 +};
651 +
652 +#ifdef CONFIG_PM
653 +int neo1973_gta02_suspend(struct platform_device *pdev, pm_message_t state)
654 +{
655 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT, 1);
656 +
657 + return 0;
658 +}
659 +
660 +int neo1973_gta02_resume(struct platform_device *pdev)
661 +{
662 + if(lm4853_state & LM4853_AMP)
663 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT, 0);
664 +
665 + return 0;
666 +}
667 +#else
668 +#define neo1973_gta02_suspend NULL
669 +#define neo1973_gta02_resume NULL
670 +#endif
671 +
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),
678 +};
679 +
680 +static struct wm8753_setup_data neo1973_gta02_wm8753_setup = {
681 + .i2c_address = 0x1a,
682 +};
683 +
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,
689 +};
690 +
691 +static struct platform_device *neo1973_gta02_snd_device;
692 +
693 +static int __init neo1973_gta02_init(void)
694 +{
695 + int ret;
696 +
697 + if (!machine_is_neo1973_gta02()) {
698 + printk(KERN_INFO
699 + "Only GTA02 hardware supported by ASoc driver\n");
700 + return -ENODEV;
701 + }
702 +
703 + neo1973_gta02_snd_device = platform_device_alloc("soc-audio", -1);
704 + if (!neo1973_gta02_snd_device)
705 + return -ENOMEM;
706 +
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);
711 +
712 + if (ret)
713 + platform_device_put(neo1973_gta02_snd_device);
714 +
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);
718 +
719 + /* Amp off by default */
720 + s3c2410_gpio_setpin(GTA02_GPIO_AMP_SHUT, 1);
721 +
722 + /* Speaker off by default */
723 + s3c2410_gpio_setpin(GTA02_GPIO_HP_IN, 1);
724 +
725 + return ret;
726 +}
727 +
728 +static void __exit neo1973_gta02_exit(void)
729 +{
730 + platform_device_unregister(neo1973_gta02_snd_device);
731 +}
732 +
733 +module_init(neo1973_gta02_init);
734 +module_exit(neo1973_gta02_exit);
735 +
736 +/* Module information */
737 +MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org");
738 +MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973 GTA02");
739 +MODULE_LICENSE("GPL");
740 +
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);
747
748 /**
749 + * snd_soc_dapm_get_endpoint - get audio endpoint status
750 + * @codec: audio codec
751 + * @endpoint: audio signal endpoint (or start point)
752 + *
753 + * Get audio endpoint status - connected or disconnected.
754 + *
755 + * Returns status
756 + */
757 +int snd_soc_dapm_get_endpoint(struct snd_soc_codec *codec,
758 + char *endpoint)
759 +{
760 + struct snd_soc_dapm_widget *w;
761 +
762 + list_for_each_entry(w, &codec->dapm_widgets, list) {
763 + if (!strcmp(w->name, endpoint)) {
764 + return w->connected;
765 + }
766 + }
767 +
768 + return 0;
769 +}
770 +EXPORT_SYMBOL_GPL(snd_soc_dapm_get_endpoint);
771 +
772 +/**
773 * snd_soc_dapm_free - free dapm resources
774 * @socdev: SoC device
775 *
776 --
777 1.5.6.3
778
This page took 0.072615 seconds and 5 git commands to generate.