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