speyside.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. #include <sound/soc.h>
  12. #include <sound/soc-dapm.h>
  13. #include "../codecs/wm8915.h"
  14. static int speyside_hw_params(struct snd_pcm_substream *substream,
  15. struct snd_pcm_hw_params *params)
  16. {
  17. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  18. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  19. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  20. int ret;
  21. ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S
  22. | SND_SOC_DAIFMT_NB_NF
  23. | SND_SOC_DAIFMT_CBM_CFM);
  24. if (ret < 0)
  25. return ret;
  26. ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S
  27. | SND_SOC_DAIFMT_NB_NF
  28. | SND_SOC_DAIFMT_CBM_CFM);
  29. if (ret < 0)
  30. return ret;
  31. ret = snd_soc_dai_set_pll(codec_dai, 0, WM8915_FLL_MCLK1,
  32. 32768, 256 * 48000);
  33. if (ret < 0)
  34. return ret;
  35. ret = snd_soc_dai_set_sysclk(codec_dai, WM8915_SYSCLK_FLL,
  36. 256 * 48000, SND_SOC_CLOCK_IN);
  37. if (ret < 0)
  38. return ret;
  39. return 0;
  40. }
  41. static struct snd_soc_ops speyside_ops = {
  42. .hw_params = speyside_hw_params,
  43. };
  44. static struct snd_soc_dai_link speyside_dai[] = {
  45. {
  46. .name = "CPU",
  47. .stream_name = "CPU",
  48. .cpu_dai_name = "samsung-i2s.0",
  49. .codec_dai_name = "wm8915-aif1",
  50. .platform_name = "samsung-audio",
  51. .codec_name = "wm8915.1-001a",
  52. .ops = &speyside_ops,
  53. },
  54. };
  55. static struct snd_soc_dapm_widget widgets[] = {
  56. SND_SOC_DAPM_HP("Headphone", NULL),
  57. SND_SOC_DAPM_SPK("Main Speaker", NULL),
  58. SND_SOC_DAPM_MIC("Main AMIC", NULL),
  59. SND_SOC_DAPM_MIC("Main DMIC", NULL),
  60. };
  61. static struct snd_soc_dapm_route audio_paths[] = {
  62. { "IN1LP", NULL, "MICB2" },
  63. { "MICB2", NULL, "Main AMIC" },
  64. { "DMIC1DAT", NULL, "MICB1" },
  65. { "DMIC2DAT", NULL, "MICB1" },
  66. { "MICB1", NULL, "Main DMIC" },
  67. { "Headphone", NULL, "HPOUT1L" },
  68. { "Headphone", NULL, "HPOUT1R" },
  69. { "Main Speaker", NULL, "SPKDAT" },
  70. };
  71. static struct snd_soc_card speyside = {
  72. .name = "Speyside",
  73. .dai_link = speyside_dai,
  74. .num_links = ARRAY_SIZE(speyside_dai),
  75. .dapm_widgets = widgets,
  76. .num_dapm_widgets = ARRAY_SIZE(widgets),
  77. .dapm_routes = audio_paths,
  78. .num_dapm_routes = ARRAY_SIZE(audio_paths),
  79. };
  80. static __devinit int speyside_probe(struct platform_device *pdev)
  81. {
  82. struct snd_soc_card *card = &speyside;
  83. int ret;
  84. card->dev = &pdev->dev;
  85. ret = snd_soc_register_card(card);
  86. if (ret) {
  87. dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
  88. ret);
  89. return ret;
  90. }
  91. return 0;
  92. }
  93. static int __devexit speyside_remove(struct platform_device *pdev)
  94. {
  95. struct snd_soc_card *card = platform_get_drvdata(pdev);
  96. snd_soc_unregister_card(card);
  97. return 0;
  98. }
  99. static struct platform_driver speyside_driver = {
  100. .driver = {
  101. .name = "speyside",
  102. .owner = THIS_MODULE,
  103. .pm = &snd_soc_pm_ops,
  104. },
  105. .probe = speyside_probe,
  106. .remove = __devexit_p(speyside_remove),
  107. };
  108. static int __init speyside_audio_init(void)
  109. {
  110. return platform_driver_register(&speyside_driver);
  111. }
  112. module_init(speyside_audio_init);
  113. static void __exit speyside_audio_exit(void)
  114. {
  115. platform_driver_unregister(&speyside_driver);
  116. }
  117. module_exit(speyside_audio_exit);
  118. MODULE_DESCRIPTION("Speyside audio support");
  119. MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
  120. MODULE_LICENSE("GPL");
  121. MODULE_ALIAS("platform:speyside");