2 #include <linux/module.h>
5 #include <asm/mach-types.h>
7 #include "../codecs/wm8940.h"
8 #include "pxa2xx-i2s.h"
9 #include "pxa2xx-pcm.h"
11 static int imote2_asoc_hw_params(struct snd_pcm_substream
*substream
,
12 struct snd_pcm_hw_params
*params
)
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
;
20 switch (params_rate(params
)) {
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
);
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
);
48 ret
= snd_soc_dai_set_sysclk(codec_dai
, 0, clk
,
53 /* set the I2S system clock as input (unused) */
54 ret
= snd_soc_dai_set_sysclk(cpu_dai
, PXA2XX_I2S_SYSCLK
, clk
,
60 static struct snd_soc_ops imote2_asoc_ops
= {
61 .hw_params
= imote2_asoc_hw_params
,
64 static struct snd_soc_dai_link imote2_dai
= {
66 .stream_name
= "WM8940",
67 .cpu_dai
= &pxa_i2s_dai
,
68 .codec_dai
= &wm8940_dai
,
69 .ops
= &imote2_asoc_ops
,
72 static struct snd_soc_card snd_soc_imote2
= {
74 .platform
= &pxa2xx_soc_platform
,
75 .dai_link
= &imote2_dai
,
79 static struct snd_soc_device imote2_snd_devdata
= {
80 .card
= &snd_soc_imote2
,
81 .codec_dev
= &soc_codec_dev_wm8940
,
84 static struct platform_device
*imote2_snd_device
;
86 static int __init
imote2_asoc_init(void)
90 if (!machine_is_intelmote2())
92 imote2_snd_device
= platform_device_alloc("soc-audio", -1);
93 if (!imote2_snd_device
)
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
);
100 platform_device_put(imote2_snd_device
);
104 module_init(imote2_asoc_init
);
106 static void __exit
imote2_asoc_exit(void)
108 platform_device_unregister(imote2_snd_device
);
110 module_exit(imote2_asoc_exit
);
112 MODULE_AUTHOR("Jonathan Cameron");
113 MODULE_DESCRIPTION("ALSA SoC Imote 2");
114 MODULE_LICENSE("GPL");