]>
Commit | Line | Data |
---|---|---|
a195b51b JC |
1 | |
2 | #include <linux/module.h> | |
3 | #include <sound/soc.h> | |
4 | ||
5 | #include <asm/mach-types.h> | |
6 | ||
7 | #include "../codecs/wm8940.h" | |
8 | #include "pxa2xx-i2s.h" | |
a195b51b JC |
9 | |
10 | static int imote2_asoc_hw_params(struct snd_pcm_substream *substream, | |
11 | struct snd_pcm_hw_params *params) | |
12 | { | |
13 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
f0fba2ad LG |
14 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
15 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | |
a195b51b JC |
16 | unsigned int clk = 0; |
17 | int ret; | |
18 | ||
19 | switch (params_rate(params)) { | |
20 | case 8000: | |
21 | case 16000: | |
22 | case 48000: | |
23 | case 96000: | |
24 | clk = 12288000; | |
25 | break; | |
26 | case 11025: | |
27 | case 22050: | |
28 | case 44100: | |
29 | clk = 11289600; | |
30 | break; | |
31 | } | |
32 | ||
a195b51b JC |
33 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, clk, |
34 | SND_SOC_CLOCK_IN); | |
35 | if (ret < 0) | |
36 | return ret; | |
37 | ||
38 | /* set the I2S system clock as input (unused) */ | |
39 | ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, clk, | |
40 | SND_SOC_CLOCK_OUT); | |
41 | ||
42 | return ret; | |
43 | } | |
44 | ||
45 | static struct snd_soc_ops imote2_asoc_ops = { | |
46 | .hw_params = imote2_asoc_hw_params, | |
47 | }; | |
48 | ||
49 | static struct snd_soc_dai_link imote2_dai = { | |
50 | .name = "WM8940", | |
51 | .stream_name = "WM8940", | |
a2a0086d | 52 | .cpu_dai_name = "pxa2xx-i2s", |
f0fba2ad LG |
53 | .codec_dai_name = "wm8940-hifi", |
54 | .platform_name = "pxa-pcm-audio", | |
55 | .codec_name = "wm8940-codec.0-0034", | |
52ec35f6 AL |
56 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
57 | SND_SOC_DAIFMT_CBS_CFS, | |
a195b51b JC |
58 | .ops = &imote2_asoc_ops, |
59 | }; | |
60 | ||
ac1e8986 | 61 | static struct snd_soc_card imote2 = { |
a195b51b | 62 | .name = "Imote2", |
561c6a17 | 63 | .owner = THIS_MODULE, |
a195b51b JC |
64 | .dai_link = &imote2_dai, |
65 | .num_links = 1, | |
66 | }; | |
67 | ||
570f6fe1 | 68 | static int imote2_probe(struct platform_device *pdev) |
a195b51b | 69 | { |
ac1e8986 | 70 | struct snd_soc_card *card = &imote2; |
a195b51b JC |
71 | int ret; |
72 | ||
ac1e8986 | 73 | card->dev = &pdev->dev; |
a195b51b | 74 | |
2fd7076a | 75 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
a195b51b | 76 | if (ret) |
ac1e8986 AL |
77 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", |
78 | ret); | |
a195b51b JC |
79 | return ret; |
80 | } | |
a195b51b | 81 | |
ac1e8986 AL |
82 | static struct platform_driver imote2_driver = { |
83 | .driver = { | |
84 | .name = "imote2-audio", | |
7db1698f | 85 | .pm = &snd_soc_pm_ops, |
ac1e8986 AL |
86 | }, |
87 | .probe = imote2_probe, | |
ac1e8986 AL |
88 | }; |
89 | ||
90 | module_platform_driver(imote2_driver); | |
a195b51b JC |
91 | |
92 | MODULE_AUTHOR("Jonathan Cameron"); | |
93 | MODULE_DESCRIPTION("ALSA SoC Imote 2"); | |
94 | MODULE_LICENSE("GPL"); | |
ac1e8986 | 95 | MODULE_ALIAS("platform:imote2-audio"); |