diff options
author | Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org> | 2010-10-21 13:40:03 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-10-21 16:51:43 -0400 |
commit | d906401114861585c990ff0290c002b5d22fc71a (patch) | |
tree | 51ed437624891911522f375d5567dce675ffecdb /sound/soc/kirkwood | |
parent | 6f4bc952c60b26ecfcb013fb9a7e9474023e046e (diff) |
ASoC: kirkwood: Add audio support to hp t5325 thin clients
This patch is adding support for hp t5325 thin clients.
There's a alc5623 codec connected to the i2s interface.
Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/kirkwood')
-rw-r--r-- | sound/soc/kirkwood/Kconfig | 9 | ||||
-rw-r--r-- | sound/soc/kirkwood/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/kirkwood/kirkwood-t5325.c | 141 |
3 files changed, 152 insertions, 0 deletions
diff --git a/sound/soc/kirkwood/Kconfig b/sound/soc/kirkwood/Kconfig index 16ec2a2dba4d..54258fd9797f 100644 --- a/sound/soc/kirkwood/Kconfig +++ b/sound/soc/kirkwood/Kconfig | |||
@@ -18,3 +18,12 @@ config SND_KIRKWOOD_SOC_OPENRD | |||
18 | Say Y if you want to add support for SoC audio on | 18 | Say Y if you want to add support for SoC audio on |
19 | Openrd Client. | 19 | Openrd Client. |
20 | 20 | ||
21 | config SND_KIRKWOOD_SOC_T5325 | ||
22 | tristate "SoC Audio support for HP t5325" | ||
23 | depends on SND_KIRKWOOD_SOC && MACH_T5325 | ||
24 | select SND_KIRKWOOD_SOC_I2S | ||
25 | select SND_SOC_ALC5623 | ||
26 | help | ||
27 | Say Y if you want to add support for SoC audio on | ||
28 | the HP t5325 thin client. | ||
29 | |||
diff --git a/sound/soc/kirkwood/Makefile b/sound/soc/kirkwood/Makefile index 33a16dcab5b5..3e62ae9e7bbe 100644 --- a/sound/soc/kirkwood/Makefile +++ b/sound/soc/kirkwood/Makefile | |||
@@ -5,5 +5,7 @@ obj-$(CONFIG_SND_KIRKWOOD_SOC) += snd-soc-kirkwood.o | |||
5 | obj-$(CONFIG_SND_KIRKWOOD_SOC_I2S) += snd-soc-kirkwood-i2s.o | 5 | obj-$(CONFIG_SND_KIRKWOOD_SOC_I2S) += snd-soc-kirkwood-i2s.o |
6 | 6 | ||
7 | snd-soc-openrd-objs := kirkwood-openrd.o | 7 | snd-soc-openrd-objs := kirkwood-openrd.o |
8 | snd-soc-t5325-objs := kirkwood-t5325.o | ||
8 | 9 | ||
9 | obj-$(CONFIG_SND_KIRKWOOD_SOC_OPENRD) += snd-soc-openrd.o | 10 | obj-$(CONFIG_SND_KIRKWOOD_SOC_OPENRD) += snd-soc-openrd.o |
11 | obj-$(CONFIG_SND_KIRKWOOD_SOC_T5325) += snd-soc-t5325.o | ||
diff --git a/sound/soc/kirkwood/kirkwood-t5325.c b/sound/soc/kirkwood/kirkwood-t5325.c new file mode 100644 index 000000000000..51b52e31cb0b --- /dev/null +++ b/sound/soc/kirkwood/kirkwood-t5325.c | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | * kirkwood-t5325.c | ||
3 | * | ||
4 | * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/moduleparam.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <sound/soc.h> | ||
18 | #include <sound/soc-dapm.h> | ||
19 | #include <mach/kirkwood.h> | ||
20 | #include <plat/audio.h> | ||
21 | #include <asm/mach-types.h> | ||
22 | #include "../codecs/alc5623.h" | ||
23 | |||
24 | static int t5325_hw_params(struct snd_pcm_substream *substream, | ||
25 | struct snd_pcm_hw_params *params) | ||
26 | { | ||
27 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
28 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
29 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
30 | int ret; | ||
31 | unsigned int freq, fmt; | ||
32 | |||
33 | fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS; | ||
34 | ret = snd_soc_dai_set_fmt(cpu_dai, fmt); | ||
35 | if (ret < 0) | ||
36 | return ret; | ||
37 | |||
38 | ret = snd_soc_dai_set_fmt(codec_dai, fmt); | ||
39 | if (ret < 0) | ||
40 | return ret; | ||
41 | |||
42 | freq = params_rate(params) * 256; | ||
43 | |||
44 | return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN); | ||
45 | |||
46 | } | ||
47 | |||
48 | static struct snd_soc_ops t5325_ops = { | ||
49 | .hw_params = t5325_hw_params, | ||
50 | }; | ||
51 | |||
52 | static const struct snd_soc_dapm_widget t5325_dapm_widgets[] = { | ||
53 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | ||
54 | SND_SOC_DAPM_SPK("Speaker", NULL), | ||
55 | SND_SOC_DAPM_MIC("Mic Jack", NULL), | ||
56 | }; | ||
57 | |||
58 | static const struct snd_soc_dapm_route t5325_route[] = { | ||
59 | { "Headphone Jack", NULL, "HPL" }, | ||
60 | { "Headphone Jack", NULL, "HPR" }, | ||
61 | |||
62 | {"Speaker", NULL, "SPKOUT"}, | ||
63 | {"Speaker", NULL, "SPKOUTN"}, | ||
64 | |||
65 | { "MIC1", NULL, "Mic Jack" }, | ||
66 | { "MIC2", NULL, "Mic Jack" }, | ||
67 | }; | ||
68 | |||
69 | static int t5325_dai_init(struct snd_soc_pcm_runtime *rtd) | ||
70 | { | ||
71 | struct snd_soc_codec *codec = rtd->codec; | ||
72 | |||
73 | snd_soc_dapm_new_controls(codec, t5325_dapm_widgets, | ||
74 | ARRAY_SIZE(t5325_dapm_widgets)); | ||
75 | |||
76 | snd_soc_dapm_add_routes(codec, t5325_route, ARRAY_SIZE(t5325_route)); | ||
77 | |||
78 | snd_soc_dapm_enable_pin(codec, "Mic Jack"); | ||
79 | snd_soc_dapm_enable_pin(codec, "Headphone Jack"); | ||
80 | snd_soc_dapm_enable_pin(codec, "Speaker"); | ||
81 | |||
82 | snd_soc_dapm_sync(codec); | ||
83 | |||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | static struct snd_soc_dai_link t5325_dai[] = { | ||
88 | { | ||
89 | .name = "ALC5621", | ||
90 | .stream_name = "ALC5621 HiFi", | ||
91 | .cpu_dai_name = "kirkwood-i2s", | ||
92 | .platform_name = "kirkwood-pcm-audio", | ||
93 | .codec_dai_name = "alc5621-hifi", | ||
94 | .codec_name = "alc562x-codec.0-001a", | ||
95 | .ops = &t5325_ops, | ||
96 | .init = t5325_dai_init, | ||
97 | }, | ||
98 | }; | ||
99 | |||
100 | |||
101 | static struct snd_soc_card t5325 = { | ||
102 | .name = "t5325", | ||
103 | .dai_link = t5325_dai, | ||
104 | .num_links = ARRAY_SIZE(t5325_dai), | ||
105 | }; | ||
106 | |||
107 | static struct platform_device *t5325_snd_device; | ||
108 | |||
109 | static int __init t5325_init(void) | ||
110 | { | ||
111 | int ret; | ||
112 | |||
113 | if (!machine_is_t5325()) | ||
114 | return 0; | ||
115 | |||
116 | t5325_snd_device = platform_device_alloc("soc-audio", -1); | ||
117 | if (!t5325_snd_device) | ||
118 | return -ENOMEM; | ||
119 | |||
120 | platform_set_drvdata(t5325_snd_device, | ||
121 | &t5325); | ||
122 | |||
123 | ret = platform_device_add(t5325_snd_device); | ||
124 | if (ret) { | ||
125 | printk(KERN_ERR "%s: platform_device_add failed\n", __func__); | ||
126 | platform_device_put(t5325_snd_device); | ||
127 | } | ||
128 | |||
129 | return ret; | ||
130 | } | ||
131 | module_init(t5325_init); | ||
132 | |||
133 | static void __exit t5325_exit(void) | ||
134 | { | ||
135 | platform_device_unregister(t5325_snd_device); | ||
136 | } | ||
137 | module_exit(t5325_exit); | ||
138 | |||
139 | MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>"); | ||
140 | MODULE_DESCRIPTION("ALSA SoC t5325 audio client"); | ||
141 | MODULE_LICENSE("GPL"); | ||