OLD | NEW |
1 /* | 1 /* |
2 * seaboard.c - Seaboard machine ASoC driver | 2 * seaboard.c - Seaboard machine ASoC driver |
3 * | 3 * |
4 * Author: Stephen Warren <swarren@nvidia.com> | 4 * Author: Stephen Warren <swarren@nvidia.com> |
5 * Copyright (C) 2010-2011 - NVIDIA, Inc. | 5 * Copyright (C) 2010-2011 - NVIDIA, Inc. |
6 * | 6 * |
7 * Based on code copyright/by: | 7 * Based on code copyright/by: |
8 * | 8 * |
9 * (c) 2009, 2010 Nvidia Graphics Pvt. Ltd. | 9 * (c) 2009, 2010 Nvidia Graphics Pvt. Ltd. |
10 * | 10 * |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 return 0; | 124 return 0; |
125 } | 125 } |
126 | 126 |
127 static struct snd_soc_ops seaboard_asoc_ops = { | 127 static struct snd_soc_ops seaboard_asoc_ops = { |
128 .hw_params = seaboard_asoc_hw_params, | 128 .hw_params = seaboard_asoc_hw_params, |
129 }; | 129 }; |
130 | 130 |
| 131 static int seaboard_spdif_hw_params(struct snd_pcm_substream *substream, |
| 132 struct snd_pcm_hw_params *params) |
| 133 { |
| 134 struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 135 struct snd_soc_codec *codec = rtd->codec; |
| 136 struct snd_soc_card *card = codec->card; |
| 137 struct tegra_seaboard *seaboard = snd_soc_card_get_drvdata(card); |
| 138 int srate, mclk, mclk_change; |
| 139 int err; |
| 140 |
| 141 /* |
| 142 * FIXME: Refactor mclk into PCM-specific function; SPDIF doesn't |
| 143 * need it |
| 144 */ |
| 145 srate = params_rate(params); |
| 146 switch (srate) { |
| 147 case 64000: |
| 148 case 88200: |
| 149 case 96000: |
| 150 mclk = 128 * srate; |
| 151 break; |
| 152 default: |
| 153 mclk = 256 * srate; |
| 154 break; |
| 155 } |
| 156 /* FIXME: Codec only requires >= 3MHz if OSR==0 */ |
| 157 while (mclk < 6000000) |
| 158 mclk *= 2; |
| 159 |
| 160 err = tegra_asoc_utils_set_rate(&seaboard->util_data, srate, mclk, |
| 161 &mclk_change); |
| 162 if (err < 0) { |
| 163 dev_err(card->dev, "Can't configure clocks\n"); |
| 164 return err; |
| 165 } |
| 166 |
| 167 return 0; |
| 168 } |
| 169 |
| 170 static struct snd_soc_ops seaboard_spdif_ops = { |
| 171 .hw_params = seaboard_spdif_hw_params, |
| 172 }; |
| 173 |
131 static struct snd_soc_jack seaboard_hp_jack; | 174 static struct snd_soc_jack seaboard_hp_jack; |
132 | 175 |
133 static struct snd_soc_jack_pin seaboard_hp_jack_pins[] = { | 176 static struct snd_soc_jack_pin seaboard_hp_jack_pins[] = { |
134 { | 177 { |
135 .pin = "Headphone Jack", | 178 .pin = "Headphone Jack", |
136 .mask = SND_JACK_HEADPHONE, | 179 .mask = SND_JACK_HEADPHONE, |
137 }, | 180 }, |
138 }; | 181 }; |
139 | 182 |
140 static struct snd_soc_jack_gpio seaboard_hp_jack_gpios[] = { | 183 static struct snd_soc_jack_gpio seaboard_hp_jack_gpios[] = { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 snd_soc_dapm_nc_pin(dapm, "IN3L"); | 284 snd_soc_dapm_nc_pin(dapm, "IN3L"); |
242 snd_soc_dapm_nc_pin(dapm, "IN3R"); | 285 snd_soc_dapm_nc_pin(dapm, "IN3R"); |
243 snd_soc_dapm_nc_pin(dapm, "LINEOUTL"); | 286 snd_soc_dapm_nc_pin(dapm, "LINEOUTL"); |
244 snd_soc_dapm_nc_pin(dapm, "LINEOUTR"); | 287 snd_soc_dapm_nc_pin(dapm, "LINEOUTR"); |
245 | 288 |
246 snd_soc_dapm_sync(dapm); | 289 snd_soc_dapm_sync(dapm); |
247 | 290 |
248 return 0; | 291 return 0; |
249 } | 292 } |
250 | 293 |
251 static struct snd_soc_dai_link seaboard_wm8903_dai = { | 294 static struct snd_soc_dai_link seaboard_links[] = { |
252 » .name = "WM8903", | 295 » { |
253 » .stream_name = "WM8903 PCM", | 296 » » .name = "WM8903", |
254 » .codec_name = "wm8903.0-001a", | 297 » » .stream_name = "WM8903 PCM", |
255 » .platform_name = "tegra-pcm-audio", | 298 » » .codec_name = "wm8903.0-001a", |
256 » .cpu_dai_name = "tegra-i2s.0", | 299 » » .platform_name = "tegra-pcm-audio", |
257 » .codec_dai_name = "wm8903-hifi", | 300 » » .cpu_dai_name = "tegra-i2s.0", |
258 » .init = seaboard_asoc_init, | 301 » » .codec_dai_name = "wm8903-hifi", |
259 » .ops = &seaboard_asoc_ops, | 302 » » .init = seaboard_asoc_init, |
| 303 » » .ops = &seaboard_asoc_ops, |
| 304 » }, |
| 305 » { |
| 306 » » .name = "SPDIF", |
| 307 » » .stream_name = "spdif", |
| 308 » » .codec_name = "spdif-dit", |
| 309 » » .platform_name = "tegra-pcm-audio", |
| 310 » » .cpu_dai_name = "tegra-spdif", |
| 311 » » .codec_dai_name = "dit-hifi", |
| 312 » » .ops = &seaboard_spdif_ops, |
| 313 » }, |
260 }; | 314 }; |
261 | 315 |
262 static struct snd_soc_card snd_soc_seaboard = { | 316 static struct snd_soc_card snd_soc_seaboard = { |
263 .name = "tegra-seaboard", | 317 .name = "tegra-seaboard", |
264 » .dai_link = &seaboard_wm8903_dai, | 318 » .dai_link = seaboard_links, |
265 » .num_links = 1, | 319 » .num_links = ARRAY_SIZE(seaboard_links), |
266 }; | 320 }; |
267 | 321 |
268 static __devinit int tegra_snd_seaboard_probe(struct platform_device *pdev) | 322 static __devinit int tegra_snd_seaboard_probe(struct platform_device *pdev) |
269 { | 323 { |
270 struct snd_soc_card *card = &snd_soc_seaboard; | 324 struct snd_soc_card *card = &snd_soc_seaboard; |
271 struct tegra_seaboard *seaboard; | 325 struct tegra_seaboard *seaboard; |
272 struct seaboard_audio_platform_data *pdata; | 326 struct seaboard_audio_platform_data *pdata; |
273 int ret; | 327 int ret; |
274 | 328 |
275 if (!machine_is_seaboard()) { | 329 if (!machine_is_seaboard()) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 static void __exit snd_tegra_seaboard_exit(void) | 412 static void __exit snd_tegra_seaboard_exit(void) |
359 { | 413 { |
360 platform_driver_unregister(&tegra_snd_seaboard_driver); | 414 platform_driver_unregister(&tegra_snd_seaboard_driver); |
361 } | 415 } |
362 module_exit(snd_tegra_seaboard_exit); | 416 module_exit(snd_tegra_seaboard_exit); |
363 | 417 |
364 MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); | 418 MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); |
365 MODULE_DESCRIPTION("Seaboard machine ASoC driver"); | 419 MODULE_DESCRIPTION("Seaboard machine ASoC driver"); |
366 MODULE_LICENSE("GPL"); | 420 MODULE_LICENSE("GPL"); |
367 MODULE_ALIAS("platform:" DRV_NAME); | 421 MODULE_ALIAS("platform:" DRV_NAME); |
OLD | NEW |