aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/tegra
diff options
context:
space:
mode:
authorLeon Romanovsky <leon@leon.nu>2011-12-19 14:51:52 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-19 19:41:29 -0500
commit58783faf281559379871d85faf2ef53e97d075e0 (patch)
treeaaaadf2467ffa96088b8ebfda3158a2799f63a91 /sound/soc/tegra
parent58fa8e456c8e8329fe829994202b43286eb0de3f (diff)
ASoC: Tegra machine ASoC driver for boards using ALC5332 codec
At this stage only Toshiba AC100/Dynabook supported. Signed-off-by: Leon Romanovsky <leon@leon.nu> Signed-off-by: Andrey Danin <danindrey@mail.ru> Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/tegra')
-rw-r--r--sound/soc/tegra/Kconfig9
-rw-r--r--sound/soc/tegra/Makefile2
-rw-r--r--sound/soc/tegra/tegra_alc5632.c213
3 files changed, 224 insertions, 0 deletions
diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig
index c6af1fd707f5..ce1b773c351f 100644
--- a/sound/soc/tegra/Kconfig
+++ b/sound/soc/tegra/Kconfig
@@ -47,3 +47,12 @@ config SND_SOC_TEGRA_TRIMSLICE
47 help 47 help
48 Say Y or M here if you want to add support for SoC audio on the 48 Say Y or M here if you want to add support for SoC audio on the
49 TrimSlice platform. 49 TrimSlice platform.
50
51config SND_SOC_TEGRA_ALC5632
52 tristate "SoC Audio support for Tegra boards using an ALC5632 codec"
53 depends on SND_SOC_TEGRA && I2C
54 select SND_SOC_TEGRA_I2S
55 select SND_SOC_ALC5632
56 help
57 Say Y or M here if you want to add support for SoC audio on the
58 Toshiba AC100 netbook.
diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile
index 4d943b3fe150..8e584b8fcfba 100644
--- a/sound/soc/tegra/Makefile
+++ b/sound/soc/tegra/Makefile
@@ -14,6 +14,8 @@ obj-$(CONFIG_SND_SOC_TEGRA_SPDIF) += snd-soc-tegra-spdif.o
14# Tegra machine Support 14# Tegra machine Support
15snd-soc-tegra-wm8903-objs := tegra_wm8903.o 15snd-soc-tegra-wm8903-objs := tegra_wm8903.o
16snd-soc-tegra-trimslice-objs := trimslice.o 16snd-soc-tegra-trimslice-objs := trimslice.o
17snd-soc-tegra-alc5632-objs := tegra_alc5632.o
17 18
18obj-$(CONFIG_SND_SOC_TEGRA_WM8903) += snd-soc-tegra-wm8903.o 19obj-$(CONFIG_SND_SOC_TEGRA_WM8903) += snd-soc-tegra-wm8903.o
19obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += snd-soc-tegra-trimslice.o 20obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += snd-soc-tegra-trimslice.o
21obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
new file mode 100644
index 000000000000..9287eb8028fd
--- /dev/null
+++ b/sound/soc/tegra/tegra_alc5632.c
@@ -0,0 +1,213 @@
1/*
2* tegra_alc5632.c -- Toshiba AC100(PAZ00) machine ASoC driver
3*
4* Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.lauchpad.net>
5*
6* Authors: Leon Romanovsky <leon@leon.nu>
7* Andrey Danin <danindrey@mail.ru>
8* Marc Dietrich <marvin24@gmx.de>
9*
10* This program is free software; you can redistribute it and/or modify
11* it under the terms of the GNU General Public License version 2 as
12* published by the Free Software Foundation.
13*/
14
15#include <asm/mach-types.h>
16
17#include <linux/module.h>
18#include <linux/platform_device.h>
19#include <linux/slab.h>
20#include <linux/gpio.h>
21
22#include <sound/core.h>
23#include <sound/jack.h>
24#include <sound/pcm.h>
25#include <sound/pcm_params.h>
26#include <sound/soc.h>
27
28#include "../codecs/alc5632.h"
29
30#include "tegra_das.h"
31#include "tegra_i2s.h"
32#include "tegra_pcm.h"
33#include "tegra_asoc_utils.h"
34
35#define DRV_NAME "tegra-alc5632"
36
37struct tegra_alc5632 {
38 struct tegra_asoc_utils_data util_data;
39};
40
41static int tegra_alc5632_asoc_hw_params(struct snd_pcm_substream *substream,
42 struct snd_pcm_hw_params *params)
43{
44 struct snd_soc_pcm_runtime *rtd = substream->private_data;
45 struct snd_soc_dai *codec_dai = rtd->codec_dai;
46 struct snd_soc_codec *codec = rtd->codec;
47 struct snd_soc_card *card = codec->card;
48 struct tegra_alc5632 *alc5632 = snd_soc_card_get_drvdata(card);
49 int srate, mclk;
50 int err;
51
52 srate = params_rate(params);
53 mclk = 512 * srate;
54
55 err = tegra_asoc_utils_set_rate(&alc5632->util_data, srate, mclk);
56 if (err < 0) {
57 dev_err(card->dev, "Can't configure clocks\n");
58 return err;
59 }
60
61 err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
62 SND_SOC_CLOCK_IN);
63 if (err < 0) {
64 dev_err(card->dev, "codec_dai clock not set\n");
65 return err;
66 }
67
68 return 0;
69}
70
71static struct snd_soc_ops tegra_alc5632_asoc_ops = {
72 .hw_params = tegra_alc5632_asoc_hw_params,
73};
74
75static struct snd_soc_jack tegra_alc5632_hs_jack;
76
77static struct snd_soc_jack_pin tegra_alc5632_hs_jack_pins[] = {
78 {
79 .pin = "Headset Mic",
80 .mask = SND_JACK_MICROPHONE,
81 },
82 {
83 .pin = "Headset Stereophone",
84 .mask = SND_JACK_HEADPHONE,
85 },
86};
87
88static const struct snd_soc_dapm_widget tegra_alc5632_dapm_widgets[] = {
89 SND_SOC_DAPM_SPK("Int Spk", NULL),
90 SND_SOC_DAPM_HP("Headset Stereophone", NULL),
91 SND_SOC_DAPM_MIC("Headset Mic", NULL),
92};
93
94static const struct snd_soc_dapm_route tegra_alc5632_audio_map[] = {
95 /* Internal Speaker */
96 {"Int Spk", NULL, "SPKOUT"},
97 {"Int Spk", NULL, "SPKOUTN"},
98
99 /* Headset Mic */
100 {"MIC1", NULL, "MICBIAS1"},
101 {"MICBIAS1", NULL, "Headset Mic"},
102
103 /* Headset Stereophone */
104 {"Headset Stereophone", NULL, "HPR"},
105 {"Headset Stereophone", NULL, "HPL"},
106};
107
108static const struct snd_kcontrol_new tegra_alc5632_controls[] = {
109 SOC_DAPM_PIN_SWITCH("Int Spk"),
110};
111
112static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd)
113{
114 struct snd_soc_codec *codec = rtd->codec;
115 struct snd_soc_dapm_context *dapm = &codec->dapm;
116
117 snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET,
118 &tegra_alc5632_hs_jack);
119 snd_soc_jack_add_pins(&tegra_alc5632_hs_jack,
120 ARRAY_SIZE(tegra_alc5632_hs_jack_pins),
121 tegra_alc5632_hs_jack_pins);
122
123 snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
124
125 return 0;
126}
127
128static struct snd_soc_dai_link tegra_alc5632_dai = {
129 .name = "ALC5632",
130 .stream_name = "ALC5632 PCM",
131 .codec_name = "alc5632.0-001e",
132 .platform_name = "tegra-pcm-audio",
133 .cpu_dai_name = "tegra-i2s.0",
134 .codec_dai_name = "alc5632-hifi",
135 .init = tegra_alc5632_asoc_init,
136 .ops = &tegra_alc5632_asoc_ops,
137 .dai_fmt = SND_SOC_DAIFMT_I2S
138 | SND_SOC_DAIFMT_NB_NF
139 | SND_SOC_DAIFMT_CBS_CFS,
140};
141
142static struct snd_soc_card snd_soc_tegra_alc5632 = {
143 .name = "tegra-alc5632",
144 .dai_link = &tegra_alc5632_dai,
145 .num_links = 1,
146 .controls = tegra_alc5632_controls,
147 .num_controls = ARRAY_SIZE(tegra_alc5632_controls),
148 .dapm_widgets = tegra_alc5632_dapm_widgets,
149 .num_dapm_widgets = ARRAY_SIZE(tegra_alc5632_dapm_widgets),
150 .dapm_routes = tegra_alc5632_audio_map,
151 .num_dapm_routes = ARRAY_SIZE(tegra_alc5632_audio_map),
152 .fully_routed = true,
153};
154
155static __devinit int tegra_alc5632_probe(struct platform_device *pdev)
156{
157 struct snd_soc_card *card = &snd_soc_tegra_alc5632;
158 struct tegra_alc5632 *alc5632;
159 int ret;
160
161 alc5632 = devm_kzalloc(&pdev->dev,
162 sizeof(struct tegra_alc5632), GFP_KERNEL);
163 if (!alc5632) {
164 dev_err(&pdev->dev, "Can't allocate tegra_alc5632\n");
165 return -ENOMEM;
166 }
167
168 ret = tegra_asoc_utils_init(&alc5632->util_data, &pdev->dev);
169 if (ret)
170 return ret;
171
172 card->dev = &pdev->dev;
173 platform_set_drvdata(pdev, card);
174 snd_soc_card_set_drvdata(card, alc5632);
175
176 ret = snd_soc_register_card(card);
177 if (ret) {
178 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
179 ret);
180 tegra_asoc_utils_fini(&alc5632->util_data);
181 return ret;
182 }
183
184 return 0;
185}
186
187static int __devexit tegra_alc5632_remove(struct platform_device *pdev)
188{
189 struct snd_soc_card *card = platform_get_drvdata(pdev);
190 struct tegra_alc5632 *alc5632 = snd_soc_card_get_drvdata(card);
191
192 snd_soc_unregister_card(card);
193
194 tegra_asoc_utils_fini(&alc5632->util_data);
195
196 return 0;
197}
198
199static struct platform_driver tegra_alc5632_driver = {
200 .driver = {
201 .name = DRV_NAME,
202 .owner = THIS_MODULE,
203 .pm = &snd_soc_pm_ops,
204 },
205 .probe = tegra_alc5632_probe,
206 .remove = __devexit_p(tegra_alc5632_remove),
207};
208module_platform_driver(tegra_alc5632_driver);
209
210MODULE_AUTHOR("Leon Romanovsky <leon@leon.nu>");
211MODULE_DESCRIPTION("Tegra+ALC5632 machine ASoC driver");
212MODULE_LICENSE("GPL");
213MODULE_ALIAS("platform:" DRV_NAME);