staging: xgifb: vb_setmode: make XGI_SetXG27FPBits() static
[linux/fpc-iii.git] / sound / soc / blackfin / bfin-eval-adav80x.c
blob897cfa68a2a668789b8844c00167b51eb1a12887
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 <linux/module.h>
14 #include <sound/core.h>
15 #include <sound/pcm.h>
16 #include <sound/soc.h>
18 #include "../codecs/adav80x.h"
20 static const struct snd_soc_dapm_widget bfin_eval_adav80x_dapm_widgets[] = {
21 SND_SOC_DAPM_LINE("Line Out", NULL),
22 SND_SOC_DAPM_LINE("Line In", NULL),
25 static const struct snd_soc_dapm_route bfin_eval_adav80x_dapm_routes[] = {
26 { "Line Out", NULL, "VOUTL" },
27 { "Line Out", NULL, "VOUTR" },
29 { "VINL", NULL, "Line In" },
30 { "VINR", NULL, "Line In" },
33 static int bfin_eval_adav80x_hw_params(struct snd_pcm_substream *substream,
34 struct snd_pcm_hw_params *params)
36 struct snd_soc_pcm_runtime *rtd = substream->private_data;
37 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
38 struct snd_soc_dai *codec_dai = rtd->codec_dai;
39 int ret;
41 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
42 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
43 if (ret)
44 return ret;
46 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
47 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
48 if (ret)
49 return ret;
51 ret = snd_soc_dai_set_pll(codec_dai, ADAV80X_PLL1, ADAV80X_PLL_SRC_XTAL,
52 27000000, params_rate(params) * 256);
53 if (ret)
54 return ret;
56 ret = snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_PLL1,
57 params_rate(params) * 256, SND_SOC_CLOCK_IN);
59 return ret;
62 static int bfin_eval_adav80x_codec_init(struct snd_soc_pcm_runtime *rtd)
64 struct snd_soc_dai *codec_dai = rtd->codec_dai;
66 snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_SYSCLK1, 0,
67 SND_SOC_CLOCK_OUT);
68 snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_SYSCLK2, 0,
69 SND_SOC_CLOCK_OUT);
70 snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_SYSCLK3, 0,
71 SND_SOC_CLOCK_OUT);
73 snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_XTAL, 2700000, 0);
75 return 0;
78 static struct snd_soc_ops bfin_eval_adav80x_ops = {
79 .hw_params = bfin_eval_adav80x_hw_params,
82 static struct snd_soc_dai_link bfin_eval_adav80x_dais[] = {
84 .name = "adav80x",
85 .stream_name = "ADAV80x HiFi",
86 .cpu_dai_name = "bfin-i2s.0",
87 .codec_dai_name = "adav80x-hifi",
88 .platform_name = "bfin-i2s-pcm-audio",
89 .init = bfin_eval_adav80x_codec_init,
90 .ops = &bfin_eval_adav80x_ops,
94 static struct snd_soc_card bfin_eval_adav80x = {
95 .name = "bfin-eval-adav80x",
96 .dai_link = bfin_eval_adav80x_dais,
97 .num_links = ARRAY_SIZE(bfin_eval_adav80x_dais),
99 .dapm_widgets = bfin_eval_adav80x_dapm_widgets,
100 .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adav80x_dapm_widgets),
101 .dapm_routes = bfin_eval_adav80x_dapm_routes,
102 .num_dapm_routes = ARRAY_SIZE(bfin_eval_adav80x_dapm_routes),
105 enum bfin_eval_adav80x_type {
106 BFIN_EVAL_ADAV801,
107 BFIN_EVAL_ADAV803,
110 static int bfin_eval_adav80x_probe(struct platform_device *pdev)
112 struct snd_soc_card *card = &bfin_eval_adav80x;
113 const char *codec_name;
115 switch (platform_get_device_id(pdev)->driver_data) {
116 case BFIN_EVAL_ADAV801:
117 codec_name = "spi0.1";
118 break;
119 case BFIN_EVAL_ADAV803:
120 codec_name = "adav803.0-0034";
121 break;
122 default:
123 return -EINVAL;
126 bfin_eval_adav80x_dais[0].codec_name = codec_name;
128 card->dev = &pdev->dev;
130 return snd_soc_register_card(&bfin_eval_adav80x);
133 static int __devexit bfin_eval_adav80x_remove(struct platform_device *pdev)
135 struct snd_soc_card *card = platform_get_drvdata(pdev);
137 snd_soc_unregister_card(card);
139 return 0;
142 static const struct platform_device_id bfin_eval_adav80x_ids[] = {
143 { "bfin-eval-adav801", BFIN_EVAL_ADAV801 },
144 { "bfin-eval-adav803", BFIN_EVAL_ADAV803 },
145 { },
147 MODULE_DEVICE_TABLE(platform, bfin_eval_adav80x_ids);
149 static struct platform_driver bfin_eval_adav80x_driver = {
150 .driver = {
151 .name = "bfin-eval-adav80x",
152 .owner = THIS_MODULE,
153 .pm = &snd_soc_pm_ops,
155 .probe = bfin_eval_adav80x_probe,
156 .remove = __devexit_p(bfin_eval_adav80x_remove),
157 .id_table = bfin_eval_adav80x_ids,
160 static int __init bfin_eval_adav80x_init(void)
162 return platform_driver_register(&bfin_eval_adav80x_driver);
164 module_init(bfin_eval_adav80x_init);
166 static void __exit bfin_eval_adav80x_exit(void)
168 platform_driver_unregister(&bfin_eval_adav80x_driver);
170 module_exit(bfin_eval_adav80x_exit);
172 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
173 MODULE_DESCRIPTION("ALSA SoC bfin adav80x driver");
174 MODULE_LICENSE("GPL");