• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/sound/soc/pxa/
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"
9#include "pxa2xx-pcm.h"
10
11static int imote2_asoc_hw_params(struct snd_pcm_substream *substream,
12				 struct snd_pcm_hw_params *params)
13{
14	struct snd_soc_pcm_runtime *rtd = substream->private_data;
15	struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
16	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
17	unsigned int clk = 0;
18	int ret;
19
20	switch (params_rate(params)) {
21	case 8000:
22	case 16000:
23	case 48000:
24	case 96000:
25		clk = 12288000;
26		break;
27	case 11025:
28	case 22050:
29	case 44100:
30		clk = 11289600;
31		break;
32	}
33
34	/* set codec DAI configuration */
35	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S
36				  | SND_SOC_DAIFMT_NB_NF
37				  | SND_SOC_DAIFMT_CBS_CFS);
38	if (ret < 0)
39		return ret;
40
41	/* CPU should be clock master */
42	ret = snd_soc_dai_set_fmt(cpu_dai,  SND_SOC_DAIFMT_I2S
43				  | SND_SOC_DAIFMT_NB_NF
44				  | SND_SOC_DAIFMT_CBS_CFS);
45	if (ret < 0)
46		return ret;
47
48	ret = snd_soc_dai_set_sysclk(codec_dai, 0, clk,
49				     SND_SOC_CLOCK_IN);
50	if (ret < 0)
51		return ret;
52
53	/* set the I2S system clock as input (unused) */
54	ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, clk,
55		SND_SOC_CLOCK_OUT);
56
57	return ret;
58}
59
60static struct snd_soc_ops imote2_asoc_ops = {
61	.hw_params = imote2_asoc_hw_params,
62};
63
64static struct snd_soc_dai_link imote2_dai = {
65	.name = "WM8940",
66	.stream_name = "WM8940",
67	.cpu_dai = &pxa_i2s_dai,
68	.codec_dai = &wm8940_dai,
69	.ops = &imote2_asoc_ops,
70};
71
72static struct snd_soc_card snd_soc_imote2 = {
73	.name = "Imote2",
74	.platform = &pxa2xx_soc_platform,
75	.dai_link = &imote2_dai,
76	.num_links = 1,
77};
78
79static struct snd_soc_device imote2_snd_devdata = {
80	.card = &snd_soc_imote2,
81	.codec_dev = &soc_codec_dev_wm8940,
82};
83
84static struct platform_device *imote2_snd_device;
85
86static int __init imote2_asoc_init(void)
87{
88	int ret;
89
90	if (!machine_is_intelmote2())
91		return -ENODEV;
92	imote2_snd_device = platform_device_alloc("soc-audio", -1);
93	if (!imote2_snd_device)
94		return -ENOMEM;
95
96	platform_set_drvdata(imote2_snd_device, &imote2_snd_devdata);
97	imote2_snd_devdata.dev = &imote2_snd_device->dev;
98	ret = platform_device_add(imote2_snd_device);
99	if (ret)
100		platform_device_put(imote2_snd_device);
101
102	return ret;
103}
104module_init(imote2_asoc_init);
105
106static void __exit imote2_asoc_exit(void)
107{
108	platform_device_unregister(imote2_snd_device);
109}
110module_exit(imote2_asoc_exit);
111
112MODULE_AUTHOR("Jonathan Cameron");
113MODULE_DESCRIPTION("ALSA SoC Imote 2");
114MODULE_LICENSE("GPL");
115