2 #include <linux/module.h>
5 #include <asm/mach-types.h>
7 #include "../codecs/wm8940.h"
8 #include "pxa2xx-i2s.h"
10 static int imote2_asoc_hw_params(struct snd_pcm_substream
*substream
,
11 struct snd_pcm_hw_params
*params
)
13 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
14 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
15 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
19 switch (params_rate(params
)) {
33 /* set codec DAI configuration */
34 ret
= snd_soc_dai_set_fmt(codec_dai
, SND_SOC_DAIFMT_I2S
35 | SND_SOC_DAIFMT_NB_NF
36 | SND_SOC_DAIFMT_CBS_CFS
);
40 /* CPU should be clock master */
41 ret
= snd_soc_dai_set_fmt(cpu_dai
, SND_SOC_DAIFMT_I2S
42 | SND_SOC_DAIFMT_NB_NF
43 | SND_SOC_DAIFMT_CBS_CFS
);
47 ret
= snd_soc_dai_set_sysclk(codec_dai
, 0, clk
,
52 /* set the I2S system clock as input (unused) */
53 ret
= snd_soc_dai_set_sysclk(cpu_dai
, PXA2XX_I2S_SYSCLK
, clk
,
59 static struct snd_soc_ops imote2_asoc_ops
= {
60 .hw_params
= imote2_asoc_hw_params
,
63 static struct snd_soc_dai_link imote2_dai
= {
65 .stream_name
= "WM8940",
66 .cpu_dai_name
= "pxa2xx-i2s",
67 .codec_dai_name
= "wm8940-hifi",
68 .platform_name
= "pxa-pcm-audio",
69 .codec_name
= "wm8940-codec.0-0034",
70 .ops
= &imote2_asoc_ops
,
73 static struct snd_soc_card imote2
= {
75 .dai_link
= &imote2_dai
,
79 static int __devinit
imote2_probe(struct platform_device
*pdev
)
81 struct snd_soc_card
*card
= &imote2
;
84 card
->dev
= &pdev
->dev
;
86 ret
= snd_soc_register_card(card
);
88 dev_err(&pdev
->dev
, "snd_soc_register_card() failed: %d\n",
93 static int __devexit
imote2_remove(struct platform_device
*pdev
)
95 struct snd_soc_card
*card
= platform_get_drvdata(pdev
);
97 snd_soc_unregister_card(card
);
101 static struct platform_driver imote2_driver
= {
103 .name
= "imote2-audio",
104 .owner
= THIS_MODULE
,
106 .probe
= imote2_probe
,
107 .remove
= __devexit_p(imote2_remove
),
110 module_platform_driver(imote2_driver
);
112 MODULE_AUTHOR("Jonathan Cameron");
113 MODULE_DESCRIPTION("ALSA SoC Imote 2");
114 MODULE_LICENSE("GPL");
115 MODULE_ALIAS("platform:imote2-audio");