]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - sound/soc/blackfin/bfin-eval-adau1x81.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi...
[mirror_ubuntu-bionic-kernel.git] / sound / soc / blackfin / bfin-eval-adau1x81.c
1 /*
2 * Machine driver for EVAL-ADAU1x81 on Analog Devices bfin
3 * evaluation boards.
4 *
5 * Copyright 2011-2014 Analog Devices Inc.
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
7 *
8 * Licensed under the GPL-2 or later.
9 */
10
11 #include <linux/module.h>
12 #include <linux/device.h>
13 #include <linux/slab.h>
14 #include <sound/core.h>
15 #include <sound/pcm.h>
16 #include <sound/soc.h>
17 #include <sound/pcm_params.h>
18
19 #include "../codecs/adau17x1.h"
20
21 static const struct snd_soc_dapm_widget bfin_eval_adau1x81_dapm_widgets[] = {
22 SND_SOC_DAPM_LINE("Stereo In", NULL),
23 SND_SOC_DAPM_LINE("Beep", NULL),
24
25 SND_SOC_DAPM_SPK("Speaker", NULL),
26 SND_SOC_DAPM_HP("Headphone", NULL),
27 };
28
29 static const struct snd_soc_dapm_route bfin_eval_adau1x81_dapm_routes[] = {
30 { "BEEP", NULL, "Beep" },
31 { "LMIC", NULL, "Stereo In" },
32 { "LMIC", NULL, "Stereo In" },
33
34 { "Headphone", NULL, "AOUTL" },
35 { "Headphone", NULL, "AOUTR" },
36 { "Speaker", NULL, "SP" },
37 };
38
39 static int bfin_eval_adau1x81_hw_params(struct snd_pcm_substream *substream,
40 struct snd_pcm_hw_params *params)
41 {
42 struct snd_soc_pcm_runtime *rtd = substream->private_data;
43 struct snd_soc_dai *codec_dai = rtd->codec_dai;
44 int pll_rate;
45 int ret;
46
47 switch (params_rate(params)) {
48 case 48000:
49 case 8000:
50 case 12000:
51 case 16000:
52 case 24000:
53 case 32000:
54 case 96000:
55 pll_rate = 48000 * 1024;
56 break;
57 case 44100:
58 case 7350:
59 case 11025:
60 case 14700:
61 case 22050:
62 case 29400:
63 case 88200:
64 pll_rate = 44100 * 1024;
65 break;
66 default:
67 return -EINVAL;
68 }
69
70 ret = snd_soc_dai_set_pll(codec_dai, ADAU17X1_PLL,
71 ADAU17X1_PLL_SRC_MCLK, 12288000, pll_rate);
72 if (ret)
73 return ret;
74
75 ret = snd_soc_dai_set_sysclk(codec_dai, ADAU17X1_CLK_SRC_PLL, pll_rate,
76 SND_SOC_CLOCK_IN);
77
78 return ret;
79 }
80
81 static const struct snd_soc_ops bfin_eval_adau1x81_ops = {
82 .hw_params = bfin_eval_adau1x81_hw_params,
83 };
84
85 static struct snd_soc_dai_link bfin_eval_adau1x81_dai = {
86 .name = "adau1x81",
87 .stream_name = "adau1x81",
88 .cpu_dai_name = "bfin-i2s.0",
89 .codec_dai_name = "adau-hifi",
90 .platform_name = "bfin-i2s-pcm-audio",
91 .codec_name = "adau1781.0-0038",
92 .ops = &bfin_eval_adau1x81_ops,
93 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
94 SND_SOC_DAIFMT_CBM_CFM,
95 };
96
97 static struct snd_soc_card bfin_eval_adau1x81 = {
98 .name = "bfin-eval-adau1x81",
99 .driver_name = "eval-adau1x81",
100 .dai_link = &bfin_eval_adau1x81_dai,
101 .num_links = 1,
102
103 .dapm_widgets = bfin_eval_adau1x81_dapm_widgets,
104 .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1x81_dapm_widgets),
105 .dapm_routes = bfin_eval_adau1x81_dapm_routes,
106 .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1x81_dapm_routes),
107 .fully_routed = true,
108 };
109
110 static int bfin_eval_adau1x81_probe(struct platform_device *pdev)
111 {
112 bfin_eval_adau1x81.dev = &pdev->dev;
113
114 return devm_snd_soc_register_card(&pdev->dev, &bfin_eval_adau1x81);
115 }
116
117 static struct platform_driver bfin_eval_adau1x81_driver = {
118 .driver = {
119 .name = "bfin-eval-adau1x81",
120 .pm = &snd_soc_pm_ops,
121 },
122 .probe = bfin_eval_adau1x81_probe,
123 };
124 module_platform_driver(bfin_eval_adau1x81_driver);
125
126 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
127 MODULE_DESCRIPTION("ALSA SoC bfin adau1x81 driver");
128 MODULE_LICENSE("GPL");
129 MODULE_ALIAS("platform:bfin-eval-adau1x81");