kirkwood-t5325.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * kirkwood-t5325.c
  3. *
  4. * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
  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 <linux/module.h>
  12. #include <linux/moduleparam.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/slab.h>
  16. #include <sound/soc.h>
  17. #include <linux/platform_data/asoc-kirkwood.h>
  18. #include "../codecs/alc5623.h"
  19. static int t5325_hw_params(struct snd_pcm_substream *substream,
  20. struct snd_pcm_hw_params *params)
  21. {
  22. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  23. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  24. unsigned int freq;
  25. freq = params_rate(params) * 256;
  26. return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN);
  27. }
  28. static struct snd_soc_ops t5325_ops = {
  29. .hw_params = t5325_hw_params,
  30. };
  31. static const struct snd_soc_dapm_widget t5325_dapm_widgets[] = {
  32. SND_SOC_DAPM_HP("Headphone Jack", NULL),
  33. SND_SOC_DAPM_SPK("Speaker", NULL),
  34. SND_SOC_DAPM_MIC("Mic Jack", NULL),
  35. };
  36. static const struct snd_soc_dapm_route t5325_route[] = {
  37. { "Headphone Jack", NULL, "HPL" },
  38. { "Headphone Jack", NULL, "HPR" },
  39. {"Speaker", NULL, "SPKOUT"},
  40. {"Speaker", NULL, "SPKOUTN"},
  41. { "MIC1", NULL, "Mic Jack" },
  42. { "MIC2", NULL, "Mic Jack" },
  43. };
  44. static int t5325_dai_init(struct snd_soc_pcm_runtime *rtd)
  45. {
  46. struct snd_soc_codec *codec = rtd->codec;
  47. struct snd_soc_dapm_context *dapm = &codec->dapm;
  48. snd_soc_dapm_enable_pin(dapm, "Mic Jack");
  49. snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
  50. snd_soc_dapm_enable_pin(dapm, "Speaker");
  51. return 0;
  52. }
  53. static struct snd_soc_dai_link t5325_dai[] = {
  54. {
  55. .name = "ALC5621",
  56. .stream_name = "ALC5621 HiFi",
  57. .cpu_dai_name = "mvebu-audio",
  58. .platform_name = "mvebu-audio",
  59. .codec_dai_name = "alc5621-hifi",
  60. .codec_name = "alc562x-codec.0-001a",
  61. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
  62. .ops = &t5325_ops,
  63. .init = t5325_dai_init,
  64. },
  65. };
  66. static struct snd_soc_card t5325 = {
  67. .name = "t5325",
  68. .owner = THIS_MODULE,
  69. .dai_link = t5325_dai,
  70. .num_links = ARRAY_SIZE(t5325_dai),
  71. .dapm_widgets = t5325_dapm_widgets,
  72. .num_dapm_widgets = ARRAY_SIZE(t5325_dapm_widgets),
  73. .dapm_routes = t5325_route,
  74. .num_dapm_routes = ARRAY_SIZE(t5325_route),
  75. };
  76. static int t5325_probe(struct platform_device *pdev)
  77. {
  78. struct snd_soc_card *card = &t5325;
  79. int ret;
  80. card->dev = &pdev->dev;
  81. ret = snd_soc_register_card(card);
  82. if (ret)
  83. dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
  84. ret);
  85. return ret;
  86. }
  87. static int t5325_remove(struct platform_device *pdev)
  88. {
  89. struct snd_soc_card *card = platform_get_drvdata(pdev);
  90. snd_soc_unregister_card(card);
  91. return 0;
  92. }
  93. static struct platform_driver t5325_driver = {
  94. .driver = {
  95. .name = "t5325-audio",
  96. .owner = THIS_MODULE,
  97. },
  98. .probe = t5325_probe,
  99. .remove = t5325_remove,
  100. };
  101. module_platform_driver(t5325_driver);
  102. MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
  103. MODULE_DESCRIPTION("ALSA SoC t5325 audio client");
  104. MODULE_LICENSE("GPL");
  105. MODULE_ALIAS("platform:t5325-audio");