aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/pxa
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-05-20 12:41:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-20 12:41:44 -0400
commit7f06a8b26aba1dc03b42272dc0089a800372c575 (patch)
tree7c67198f83d069eb13fd417e022d111b7e4c82a1 /sound/soc/pxa
parentc3ad33c9bcb6616999953af76f16318120fe3691 (diff)
parentd71f4cece4bd97d05592836202fc04ff2e7817e3 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6: (250 commits) ALSA: hda: Storage class should be before const qualifier ASoC: tpa6130a2: Remove CPVSS and HPVdd supplies ASoC: tpa6130a2: Define output pins with SND_SOC_DAPM_OUTPUT ASoC: sdp4430 - add sdp4430 pcm ops to DAI. ASoC: TWL6040: Enable earphone path in codec ASoC: SDP4430: Add support for Earphone speaker ASoC: SDP4430: Add sdp4430 machine driver ASoC: tlv320dac33: Avoid powering off while in BIAS_OFF ASoC: tlv320dac33: Use dev_dbg in dac33_hard_power function ALSA: sound/pci/asihpi: Use kzalloc ALSA: hdmi - dont fail on extra nodes ALSA: intelhdmi - add id for the CougarPoint chipset ALSA: intelhdmi - user friendly codec name ALSA: intelhdmi - add dependency on SND_DYNAMIC_MINORS ALSA: asihpi: incorrect range check ALSA: asihpi: testing the wrong variable ALSA: es1688: add pedantic range checks ARM: McBSP: Add support for omap4 in McBSP driver ARM: McBSP: Fix request for irq in OMAP4 OMAP: McBSP: Add 32-bit mode support ...
Diffstat (limited to 'sound/soc/pxa')
-rw-r--r--sound/soc/pxa/Kconfig8
-rw-r--r--sound/soc/pxa/Makefile2
-rw-r--r--sound/soc/pxa/spitz.c43
-rw-r--r--sound/soc/pxa/z2.c246
4 files changed, 292 insertions, 7 deletions
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index 78e612100782..e30c8325f35e 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -43,6 +43,14 @@ config SND_PXA2XX_SOC_SPITZ
43 Say Y if you want to add support for SoC audio on Sharp 43 Say Y if you want to add support for SoC audio on Sharp
44 Zaurus SL-Cxx00 models (Spitz, Borzoi and Akita). 44 Zaurus SL-Cxx00 models (Spitz, Borzoi and Akita).
45 45
46config SND_PXA2XX_SOC_Z2
47 tristate "SoC Audio support for Zipit Z2"
48 depends on SND_PXA2XX_SOC && MACH_ZIPIT2
49 select SND_PXA2XX_SOC_I2S
50 select SND_SOC_WM8750
51 help
52 Say Y if you want to add support for SoC audio on Zipit Z2.
53
46config SND_PXA2XX_SOC_POODLE 54config SND_PXA2XX_SOC_POODLE
47 tristate "SoC Audio support for Poodle" 55 tristate "SoC Audio support for Poodle"
48 depends on SND_PXA2XX_SOC && MACH_POODLE 56 depends on SND_PXA2XX_SOC && MACH_POODLE
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile
index f3e08fd40ca2..caa03d8f4789 100644
--- a/sound/soc/pxa/Makefile
+++ b/sound/soc/pxa/Makefile
@@ -22,6 +22,7 @@ snd-soc-palm27x-objs := palm27x.o
22snd-soc-zylonite-objs := zylonite.o 22snd-soc-zylonite-objs := zylonite.o
23snd-soc-magician-objs := magician.o 23snd-soc-magician-objs := magician.o
24snd-soc-mioa701-objs := mioa701_wm9713.o 24snd-soc-mioa701-objs := mioa701_wm9713.o
25snd-soc-z2-objs := z2.o
25snd-soc-imote2-objs := imote2.o 26snd-soc-imote2-objs := imote2.o
26snd-soc-raumfeld-objs := raumfeld.o 27snd-soc-raumfeld-objs := raumfeld.o
27 28
@@ -36,6 +37,7 @@ obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o
36obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o 37obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o
37obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o 38obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o
38obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o 39obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o
40obj-$(CONFIG_SND_PXA2XX_SOC_Z2) += snd-soc-z2.o
39obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o 41obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o
40obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o 42obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o
41obj-$(CONFIG_SND_SOC_RAUMFELD) += snd-soc-raumfeld.o 43obj-$(CONFIG_SND_SOC_RAUMFELD) += snd-soc-raumfeld.o
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index c4cd2acaacb4..1941a357e8c4 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -322,19 +322,44 @@ static struct snd_soc_card snd_soc_spitz = {
322 .num_links = 1, 322 .num_links = 1,
323}; 323};
324 324
325/* spitz audio private data */
326static struct wm8750_setup_data spitz_wm8750_setup = {
327 .i2c_bus = 0,
328 .i2c_address = 0x1b,
329};
330
331/* spitz audio subsystem */ 325/* spitz audio subsystem */
332static struct snd_soc_device spitz_snd_devdata = { 326static struct snd_soc_device spitz_snd_devdata = {
333 .card = &snd_soc_spitz, 327 .card = &snd_soc_spitz,
334 .codec_dev = &soc_codec_dev_wm8750, 328 .codec_dev = &soc_codec_dev_wm8750,
335 .codec_data = &spitz_wm8750_setup,
336}; 329};
337 330
331/*
332 * FIXME: This is a temporary bodge to avoid cross-tree merge issues.
333 * New drivers should register the wm8750 I2C device in the machine
334 * setup code (under arch/arm for ARM systems).
335 */
336static int wm8750_i2c_register(void)
337{
338 struct i2c_board_info info;
339 struct i2c_adapter *adapter;
340 struct i2c_client *client;
341
342 memset(&info, 0, sizeof(struct i2c_board_info));
343 info.addr = 0x1b;
344 strlcpy(info.type, "wm8750", I2C_NAME_SIZE);
345
346 adapter = i2c_get_adapter(0);
347 if (!adapter) {
348 printk(KERN_ERR "can't get i2c adapter 0\n");
349 return -ENODEV;
350 }
351
352 client = i2c_new_device(adapter, &info);
353 i2c_put_adapter(adapter);
354 if (!client) {
355 printk(KERN_ERR "can't add i2c device at 0x%x\n",
356 (unsigned int)info.addr);
357 return -ENODEV;
358 }
359
360 return 0;
361}
362
338static struct platform_device *spitz_snd_device; 363static struct platform_device *spitz_snd_device;
339 364
340static int __init spitz_init(void) 365static int __init spitz_init(void)
@@ -344,6 +369,10 @@ static int __init spitz_init(void)
344 if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita())) 369 if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita()))
345 return -ENODEV; 370 return -ENODEV;
346 371
372 ret = wm8750_i2c_setup();
373 if (ret != 0)
374 return ret;
375
347 spitz_snd_device = platform_device_alloc("soc-audio", -1); 376 spitz_snd_device = platform_device_alloc("soc-audio", -1);
348 if (!spitz_snd_device) 377 if (!spitz_snd_device)
349 return -ENOMEM; 378 return -ENOMEM;
diff --git a/sound/soc/pxa/z2.c b/sound/soc/pxa/z2.c
new file mode 100644
index 000000000000..4e4d2fa8ddc5
--- /dev/null
+++ b/sound/soc/pxa/z2.c
@@ -0,0 +1,246 @@
1/*
2 * linux/sound/soc/pxa/z2.c
3 *
4 * SoC Audio driver for Aeronix Zipit Z2
5 *
6 * Copyright (C) 2009 Ken McGuire <kenm@desertweyr.com>
7 * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/timer.h>
17#include <linux/interrupt.h>
18#include <linux/platform_device.h>
19#include <linux/gpio.h>
20
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/soc.h>
24#include <sound/soc-dapm.h>
25#include <sound/jack.h>
26
27#include <asm/mach-types.h>
28#include <mach/hardware.h>
29#include <mach/audio.h>
30#include <mach/z2.h>
31
32#include "../codecs/wm8750.h"
33#include "pxa2xx-pcm.h"
34#include "pxa2xx-i2s.h"
35
36static struct snd_soc_card snd_soc_z2;
37
38static int z2_hw_params(struct snd_pcm_substream *substream,
39 struct snd_pcm_hw_params *params)
40{
41 struct snd_soc_pcm_runtime *rtd = substream->private_data;
42 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
43 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
44 unsigned int clk = 0;
45 int ret = 0;
46
47 switch (params_rate(params)) {
48 case 8000:
49 case 16000:
50 case 48000:
51 case 96000:
52 clk = 12288000;
53 break;
54 case 11025:
55 case 22050:
56 case 44100:
57 clk = 11289600;
58 break;
59 }
60
61 /* set codec DAI configuration */
62 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
63 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
64 if (ret < 0)
65 return ret;
66
67 /* set cpu DAI configuration */
68 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
69 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
70 if (ret < 0)
71 return ret;
72
73 /* set the codec system clock for DAC and ADC */
74 ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk,
75 SND_SOC_CLOCK_IN);
76 if (ret < 0)
77 return ret;
78
79 /* set the I2S system clock as input (unused) */
80 ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0,
81 SND_SOC_CLOCK_IN);
82 if (ret < 0)
83 return ret;
84
85 return 0;
86}
87
88static struct snd_soc_jack hs_jack;
89
90/* Headset jack detection DAPM pins */
91static struct snd_soc_jack_pin hs_jack_pins[] = {
92 {
93 .pin = "Mic Jack",
94 .mask = SND_JACK_MICROPHONE,
95 },
96 {
97 .pin = "Headphone Jack",
98 .mask = SND_JACK_HEADPHONE,
99 },
100};
101
102/* Headset jack detection gpios */
103static struct snd_soc_jack_gpio hs_jack_gpios[] = {
104 {
105 .gpio = GPIO37_ZIPITZ2_HEADSET_DETECT,
106 .name = "hsdet-gpio",
107 .report = SND_JACK_HEADSET,
108 .debounce_time = 200,
109 },
110};
111
112/* z2 machine dapm widgets */
113static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
114 SND_SOC_DAPM_HP("Headphone Jack", NULL),
115 SND_SOC_DAPM_MIC("Mic Jack", NULL),
116 SND_SOC_DAPM_SPK("Ext Spk", NULL),
117
118 /* headset is a mic and mono headphone */
119 SND_SOC_DAPM_HP("Headset Jack", NULL),
120};
121
122/* Z2 machine audio_map */
123static const struct snd_soc_dapm_route audio_map[] = {
124
125 /* headphone connected to LOUT1, ROUT1 */
126 {"Headphone Jack", NULL, "LOUT1"},
127 {"Headphone Jack", NULL, "ROUT1"},
128
129 /* ext speaker connected to LOUT2, ROUT2 */
130 {"Ext Spk", NULL , "ROUT2"},
131 {"Ext Spk", NULL , "LOUT2"},
132
133 /* mic is connected to R input 2 - with bias */
134 {"RINPUT2", NULL, "Mic Bias"},
135 {"Mic Bias", NULL, "Mic Jack"},
136};
137
138/*
139 * Logic for a wm8750 as connected on a Z2 Device
140 */
141static int z2_wm8750_init(struct snd_soc_codec *codec)
142{
143 int ret;
144
145 /* NC codec pins */
146 snd_soc_dapm_disable_pin(codec, "LINPUT3");
147 snd_soc_dapm_disable_pin(codec, "RINPUT3");
148 snd_soc_dapm_disable_pin(codec, "OUT3");
149 snd_soc_dapm_disable_pin(codec, "MONO");
150
151 /* Add z2 specific widgets */
152 snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets,
153 ARRAY_SIZE(wm8750_dapm_widgets));
154
155 /* Set up z2 specific audio paths */
156 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
157
158 ret = snd_soc_dapm_sync(codec);
159 if (ret)
160 goto err;
161
162 /* Jack detection API stuff */
163 ret = snd_soc_jack_new(&snd_soc_z2, "Headset Jack", SND_JACK_HEADSET,
164 &hs_jack);
165 if (ret)
166 goto err;
167
168 ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
169 hs_jack_pins);
170 if (ret)
171 goto err;
172
173 ret = snd_soc_jack_add_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios),
174 hs_jack_gpios);
175 if (ret)
176 goto err;
177
178 return 0;
179
180err:
181 return ret;
182}
183
184static struct snd_soc_ops z2_ops = {
185 .hw_params = z2_hw_params,
186};
187
188/* z2 digital audio interface glue - connects codec <--> CPU */
189static struct snd_soc_dai_link z2_dai = {
190 .name = "wm8750",
191 .stream_name = "WM8750",
192 .cpu_dai = &pxa_i2s_dai,
193 .codec_dai = &wm8750_dai,
194 .init = z2_wm8750_init,
195 .ops = &z2_ops,
196};
197
198/* z2 audio machine driver */
199static struct snd_soc_card snd_soc_z2 = {
200 .name = "Z2",
201 .platform = &pxa2xx_soc_platform,
202 .dai_link = &z2_dai,
203 .num_links = 1,
204};
205
206/* z2 audio subsystem */
207static struct snd_soc_device z2_snd_devdata = {
208 .card = &snd_soc_z2,
209 .codec_dev = &soc_codec_dev_wm8750,
210};
211
212static struct platform_device *z2_snd_device;
213
214static int __init z2_init(void)
215{
216 int ret;
217
218 if (!machine_is_zipit2())
219 return -ENODEV;
220
221 z2_snd_device = platform_device_alloc("soc-audio", -1);
222 if (!z2_snd_device)
223 return -ENOMEM;
224
225 platform_set_drvdata(z2_snd_device, &z2_snd_devdata);
226 z2_snd_devdata.dev = &z2_snd_device->dev;
227 ret = platform_device_add(z2_snd_device);
228
229 if (ret)
230 platform_device_put(z2_snd_device);
231
232 return ret;
233}
234
235static void __exit z2_exit(void)
236{
237 platform_device_unregister(z2_snd_device);
238}
239
240module_init(z2_init);
241module_exit(z2_exit);
242
243MODULE_AUTHOR("Ken McGuire <kenm@desertweyr.com>, "
244 "Marek Vasut <marek.vasut@gmail.com>");
245MODULE_DESCRIPTION("ALSA SoC ZipitZ2");
246MODULE_LICENSE("GPL");