1
2
3
4
5
6
7
8
9
10
11#include <linux/module.h>
12#include <linux/device.h>
13#include <sound/core.h>
14#include <sound/pcm.h>
15#include <sound/soc.h>
16#include <sound/pcm_params.h>
17
18#include "../codecs/adau1701.h"
19
20static const struct snd_soc_dapm_widget bfin_eval_adau1701_dapm_widgets[] = {
21 SND_SOC_DAPM_SPK("Speaker", NULL),
22 SND_SOC_DAPM_LINE("Line Out", NULL),
23 SND_SOC_DAPM_LINE("Line In", NULL),
24};
25
26static const struct snd_soc_dapm_route bfin_eval_adau1701_dapm_routes[] = {
27 { "Speaker", NULL, "OUT0" },
28 { "Speaker", NULL, "OUT1" },
29 { "Line Out", NULL, "OUT2" },
30 { "Line Out", NULL, "OUT3" },
31
32 { "IN0", NULL, "Line In" },
33 { "IN1", NULL, "Line In" },
34};
35
36static int bfin_eval_adau1701_hw_params(struct snd_pcm_substream *substream,
37 struct snd_pcm_hw_params *params)
38{
39 struct snd_soc_pcm_runtime *rtd = substream->private_data;
40 struct snd_soc_dai *codec_dai = rtd->codec_dai;
41 int ret;
42
43 ret = snd_soc_dai_set_sysclk(codec_dai, ADAU1701_CLK_SRC_OSC, 12288000,
44 SND_SOC_CLOCK_IN);
45
46 return ret;
47}
48
49static struct snd_soc_ops bfin_eval_adau1701_ops = {
50 .hw_params = bfin_eval_adau1701_hw_params,
51};
52
53#define BFIN_EVAL_ADAU1701_DAI_FMT (SND_SOC_DAIFMT_I2S | \
54 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM)
55
56static struct snd_soc_dai_link bfin_eval_adau1701_dai[] = {
57 {
58 .name = "adau1701",
59 .stream_name = "adau1701",
60 .cpu_dai_name = "bfin-i2s.0",
61 .codec_dai_name = "adau1701",
62 .platform_name = "bfin-i2s-pcm-audio",
63 .codec_name = "adau1701.0-0034",
64 .ops = &bfin_eval_adau1701_ops,
65 .dai_fmt = BFIN_EVAL_ADAU1701_DAI_FMT,
66 },
67 {
68 .name = "adau1701",
69 .stream_name = "adau1701",
70 .cpu_dai_name = "bfin-i2s.1",
71 .codec_dai_name = "adau1701",
72 .platform_name = "bfin-i2s-pcm-audio",
73 .codec_name = "adau1701.0-0034",
74 .ops = &bfin_eval_adau1701_ops,
75 .dai_fmt = BFIN_EVAL_ADAU1701_DAI_FMT,
76 },
77};
78
79static struct snd_soc_card bfin_eval_adau1701 = {
80 .name = "bfin-eval-adau1701",
81 .owner = THIS_MODULE,
82 .dai_link = &bfin_eval_adau1701_dai[CONFIG_SND_BF5XX_SPORT_NUM],
83 .num_links = 1,
84
85 .dapm_widgets = bfin_eval_adau1701_dapm_widgets,
86 .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1701_dapm_widgets),
87 .dapm_routes = bfin_eval_adau1701_dapm_routes,
88 .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1701_dapm_routes),
89};
90
91static int bfin_eval_adau1701_probe(struct platform_device *pdev)
92{
93 struct snd_soc_card *card = &bfin_eval_adau1701;
94
95 card->dev = &pdev->dev;
96
97 return snd_soc_register_card(&bfin_eval_adau1701);
98}
99
100static int bfin_eval_adau1701_remove(struct platform_device *pdev)
101{
102 struct snd_soc_card *card = platform_get_drvdata(pdev);
103
104 snd_soc_unregister_card(card);
105
106 return 0;
107}
108
109static struct platform_driver bfin_eval_adau1701_driver = {
110 .driver = {
111 .name = "bfin-eval-adau1701",
112 .pm = &snd_soc_pm_ops,
113 },
114 .probe = bfin_eval_adau1701_probe,
115 .remove = bfin_eval_adau1701_remove,
116};
117
118module_platform_driver(bfin_eval_adau1701_driver);
119
120MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
121MODULE_DESCRIPTION("ALSA SoC bfin ADAU1701 driver");
122MODULE_LICENSE("GPL");
123MODULE_ALIAS("platform:bfin-eval-adau1701");
124