Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bfin-eval-adau1701.c
Go to the documentation of this file.
1 /*
2  * Machine driver for EVAL-ADAU1701MINIZ on Analog Devices bfin
3  * evaluation boards.
4  *
5  * Copyright 2011 Analog Devices Inc.
6  * Author: Lars-Peter Clausen <[email protected]>
7  *
8  * Licensed under the GPL-2 or later.
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 
20 static 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 
26 static 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 
36 static 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,
45 
46  return ret;
47 }
48 
49 static 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 
56 static 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 
79 static 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 
91 static 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 
100 static int __devexit bfin_eval_adau1701_remove(struct platform_device *pdev)
101 {
102  struct snd_soc_card *card = platform_get_drvdata(pdev);
103 
105 
106  return 0;
107 }
108 
109 static struct platform_driver bfin_eval_adau1701_driver = {
110  .driver = {
111  .name = "bfin-eval-adau1701",
112  .owner = THIS_MODULE,
113  .pm = &snd_soc_pm_ops,
114  },
115  .probe = bfin_eval_adau1701_probe,
116  .remove = __devexit_p(bfin_eval_adau1701_remove),
117 };
118 
119 module_platform_driver(bfin_eval_adau1701_driver);
120 
121 MODULE_AUTHOR("Lars-Peter Clausen <[email protected]>");
122 MODULE_DESCRIPTION("ALSA SoC bfin ADAU1701 driver");
123 MODULE_LICENSE("GPL");
124 MODULE_ALIAS("platform:bfin-eval-adau1701");