]>
Commit | Line | Data |
---|---|---|
9b8dc66f MB |
1 | /* |
2 | * Speyside audio support | |
3 | * | |
4 | * Copyright 2011 Wolfson Microelectronics | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2 of the License, or (at your | |
9 | * option) any later version. | |
10 | */ | |
11 | ||
12 | #include <sound/soc.h> | |
13 | #include <sound/soc-dapm.h> | |
14 | ||
15 | #include "../codecs/wm8915.h" | |
16 | ||
17 | static int speyside_hw_params(struct snd_pcm_substream *substream, | |
18 | struct snd_pcm_hw_params *params) | |
19 | { | |
20 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
21 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | |
22 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | |
23 | int ret; | |
24 | ||
25 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | |
26 | | SND_SOC_DAIFMT_NB_NF | |
27 | | SND_SOC_DAIFMT_CBM_CFM); | |
28 | if (ret < 0) | |
29 | return ret; | |
30 | ||
31 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | |
32 | | SND_SOC_DAIFMT_NB_NF | |
33 | | SND_SOC_DAIFMT_CBM_CFM); | |
34 | if (ret < 0) | |
35 | return ret; | |
36 | ||
37 | ret = snd_soc_dai_set_pll(codec_dai, 0, WM8915_FLL_MCLK1, | |
38 | 32768, 256 * 48000); | |
39 | if (ret < 0) | |
40 | return ret; | |
41 | ||
42 | ret = snd_soc_dai_set_sysclk(codec_dai, WM8915_SYSCLK_FLL, | |
43 | 256 * 48000, SND_SOC_CLOCK_IN); | |
44 | if (ret < 0) | |
45 | return ret; | |
46 | ||
47 | return 0; | |
48 | } | |
49 | ||
50 | static struct snd_soc_ops speyside_ops = { | |
51 | .hw_params = speyside_hw_params, | |
52 | }; | |
53 | ||
54 | static struct snd_soc_dai_link speyside_dai[] = { | |
55 | { | |
56 | .name = "CPU", | |
57 | .stream_name = "CPU", | |
58 | .cpu_dai_name = "samsung-i2s.0", | |
59 | .codec_dai_name = "wm8915-aif1", | |
60 | .platform_name = "samsung-audio", | |
61 | .codec_name = "wm8915.1-001a", | |
62 | .ops = &speyside_ops, | |
63 | }, | |
64 | }; | |
65 | ||
ecfb1adf MB |
66 | static struct snd_soc_dapm_widget widgets[] = { |
67 | SND_SOC_DAPM_HP("Headphone", NULL), | |
68 | ||
69 | SND_SOC_DAPM_SPK("Main Speaker", NULL), | |
70 | ||
71 | SND_SOC_DAPM_MIC("Main AMIC", NULL), | |
72 | SND_SOC_DAPM_MIC("Main DMIC", NULL), | |
73 | }; | |
74 | ||
75 | static struct snd_soc_dapm_route audio_paths[] = { | |
76 | { "IN1LP", NULL, "MICB2" }, | |
77 | { "MICB2", NULL, "Main AMIC" }, | |
78 | ||
79 | { "DMIC1DAT", NULL, "MICB1" }, | |
80 | { "DMIC2DAT", NULL, "MICB1" }, | |
81 | { "MICB1", NULL, "Main DMIC" }, | |
82 | ||
83 | { "Headphone", NULL, "HPOUT1L" }, | |
84 | { "Headphone", NULL, "HPOUT1R" }, | |
85 | ||
86 | { "Main Speaker", NULL, "SPKDAT" }, | |
87 | }; | |
88 | ||
9b8dc66f MB |
89 | static struct snd_soc_card speyside = { |
90 | .name = "Speyside", | |
91 | .dai_link = speyside_dai, | |
92 | .num_links = ARRAY_SIZE(speyside_dai), | |
ecfb1adf MB |
93 | |
94 | .dapm_widgets = widgets, | |
95 | .num_dapm_widgets = ARRAY_SIZE(widgets), | |
96 | .dapm_routes = audio_paths, | |
97 | .num_dapm_routes = ARRAY_SIZE(audio_paths), | |
9b8dc66f MB |
98 | }; |
99 | ||
100 | static __devinit int speyside_probe(struct platform_device *pdev) | |
101 | { | |
102 | struct snd_soc_card *card = &speyside; | |
103 | int ret; | |
104 | ||
105 | card->dev = &pdev->dev; | |
106 | ||
107 | ret = snd_soc_register_card(card); | |
108 | if (ret) { | |
109 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | |
110 | ret); | |
111 | return ret; | |
112 | } | |
113 | ||
114 | return 0; | |
115 | } | |
116 | ||
117 | static int __devexit speyside_remove(struct platform_device *pdev) | |
118 | { | |
119 | struct snd_soc_card *card = platform_get_drvdata(pdev); | |
120 | ||
121 | snd_soc_unregister_card(card); | |
122 | ||
123 | return 0; | |
124 | } | |
125 | ||
126 | static struct platform_driver speyside_driver = { | |
127 | .driver = { | |
128 | .name = "speyside", | |
129 | .owner = THIS_MODULE, | |
130 | .pm = &snd_soc_pm_ops, | |
131 | }, | |
132 | .probe = speyside_probe, | |
133 | .remove = __devexit_p(speyside_remove), | |
134 | }; | |
135 | ||
136 | static int __init speyside_audio_init(void) | |
137 | { | |
138 | return platform_driver_register(&speyside_driver); | |
139 | } | |
140 | module_init(speyside_audio_init); | |
141 | ||
142 | static void __exit speyside_audio_exit(void) | |
143 | { | |
144 | platform_driver_unregister(&speyside_driver); | |
145 | } | |
146 | module_exit(speyside_audio_exit); | |
147 | ||
148 | MODULE_DESCRIPTION("Speyside audio support"); | |
149 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | |
150 | MODULE_LICENSE("GPL"); | |
151 | MODULE_ALIAS("platform:speyside"); |