nfsd4: typo logical vs bitwise negate for want_mask
[linux-btrfs-devel.git] / sound / soc / blackfin / bfin-eval-adav80x.c
blob8d014d01626e85c367700e2baa3a54844dc2d742
1 /*
2 * Machine driver for EVAL-ADAV801 and EVAL-ADAV803 on Analog Devices bfin
3 * evaluation boards.
5 * Copyright 2011 Analog Devices Inc.
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
8 * Licensed under the GPL-2 or later.
9 */
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <sound/core.h>
14 #include <sound/pcm.h>
15 #include <sound/soc.h>
17 #include "../codecs/adav80x.h"
19 static const struct snd_soc_dapm_widget bfin_eval_adav80x_dapm_widgets[] = {
20 SND_SOC_DAPM_LINE("Line Out", NULL),
21 SND_SOC_DAPM_LINE("Line In", NULL),
24 static const struct snd_soc_dapm_route bfin_eval_adav80x_dapm_routes[] = {
25 { "Line Out", NULL, "VOUTL" },
26 { "Line Out", NULL, "VOUTR" },
28 { "VINL", NULL, "Line In" },
29 { "VINR", NULL, "Line In" },
32 static int bfin_eval_adav80x_hw_params(struct snd_pcm_substream *substream,
33 struct snd_pcm_hw_params *params)
35 struct snd_soc_pcm_runtime *rtd = substream->private_data;
36 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
37 struct snd_soc_dai *codec_dai = rtd->codec_dai;
38 int ret;
40 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
41 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
42 if (ret)
43 return ret;
45 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
46 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
47 if (ret)
48 return ret;
50 ret = snd_soc_dai_set_pll(codec_dai, ADAV80X_PLL1, ADAV80X_PLL_SRC_XTAL,
51 27000000, params_rate(params) * 256);
52 if (ret)
53 return ret;
55 ret = snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_PLL1,
56 params_rate(params) * 256, SND_SOC_CLOCK_IN);
58 return ret;
61 static int bfin_eval_adav80x_codec_init(struct snd_soc_pcm_runtime *rtd)
63 struct snd_soc_dai *codec_dai = rtd->codec_dai;
65 snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_SYSCLK1, 0,
66 SND_SOC_CLOCK_OUT);
67 snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_SYSCLK2, 0,
68 SND_SOC_CLOCK_OUT);
69 snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_SYSCLK3, 0,
70 SND_SOC_CLOCK_OUT);
72 snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_XTAL, 2700000, 0);
74 return 0;
77 static struct snd_soc_ops bfin_eval_adav80x_ops = {
78 .hw_params = bfin_eval_adav80x_hw_params,
81 static struct snd_soc_dai_link bfin_eval_adav80x_dais[] = {
83 .name = "adav80x",
84 .stream_name = "ADAV80x HiFi",
85 .cpu_dai_name = "bfin-i2s.0",
86 .codec_dai_name = "adav80x-hifi",
87 .platform_name = "bfin-i2s-pcm-audio",
88 .init = bfin_eval_adav80x_codec_init,
89 .ops = &bfin_eval_adav80x_ops,
93 static struct snd_soc_card bfin_eval_adav80x = {
94 .name = "bfin-eval-adav80x",
95 .dai_link = bfin_eval_adav80x_dais,
96 .num_links = ARRAY_SIZE(bfin_eval_adav80x_dais),
98 .dapm_widgets = bfin_eval_adav80x_dapm_widgets,
99 .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adav80x_dapm_widgets),
100 .dapm_routes = bfin_eval_adav80x_dapm_routes,
101 .num_dapm_routes = ARRAY_SIZE(bfin_eval_adav80x_dapm_routes),
104 enum bfin_eval_adav80x_type {
105 BFIN_EVAL_ADAV801,
106 BFIN_EVAL_ADAV803,
109 static int bfin_eval_adav80x_probe(struct platform_device *pdev)
111 struct snd_soc_card *card = &bfin_eval_adav80x;
112 const char *codec_name;
114 switch (platform_get_device_id(pdev)->driver_data) {
115 case BFIN_EVAL_ADAV801:
116 codec_name = "spi0.1";
117 break;
118 case BFIN_EVAL_ADAV803:
119 codec_name = "adav803.0-0034";
120 break;
121 default:
122 return -EINVAL;
125 bfin_eval_adav80x_dais[0].codec_name = codec_name;
127 card->dev = &pdev->dev;
129 return snd_soc_register_card(&bfin_eval_adav80x);
132 static int __devexit bfin_eval_adav80x_remove(struct platform_device *pdev)
134 struct snd_soc_card *card = platform_get_drvdata(pdev);
136 snd_soc_unregister_card(card);
138 return 0;
141 static const struct platform_device_id bfin_eval_adav80x_ids[] = {
142 { "bfin-eval-adav801", BFIN_EVAL_ADAV801 },
143 { "bfin-eval-adav803", BFIN_EVAL_ADAV803 },
144 { },
146 MODULE_DEVICE_TABLE(platform, bfin_eval_adav80x_ids);
148 static struct platform_driver bfin_eval_adav80x_driver = {
149 .driver = {
150 .name = "bfin-eval-adav80x",
151 .owner = THIS_MODULE,
152 .pm = &snd_soc_pm_ops,
154 .probe = bfin_eval_adav80x_probe,
155 .remove = __devexit_p(bfin_eval_adav80x_remove),
156 .id_table = bfin_eval_adav80x_ids,
159 static int __init bfin_eval_adav80x_init(void)
161 return platform_driver_register(&bfin_eval_adav80x_driver);
163 module_init(bfin_eval_adav80x_init);
165 static void __exit bfin_eval_adav80x_exit(void)
167 platform_driver_unregister(&bfin_eval_adav80x_driver);
169 module_exit(bfin_eval_adav80x_exit);
171 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
172 MODULE_DESCRIPTION("ALSA SoC bfin adav80x driver");
173 MODULE_LICENSE("GPL");