kirkwood-openrd.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * kirkwood-openrd.c
  3. *
  4. * (c) 2010 Arnaud Patard <apatard@mandriva.com>
  5. * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/moduleparam.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/slab.h>
  17. #include <sound/soc.h>
  18. #include <linux/platform_data/asoc-kirkwood.h>
  19. #include "../codecs/cs42l51.h"
  20. static int openrd_client_hw_params(struct snd_pcm_substream *substream,
  21. struct snd_pcm_hw_params *params)
  22. {
  23. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  24. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  25. unsigned int freq;
  26. switch (params_rate(params)) {
  27. default:
  28. case 44100:
  29. freq = 11289600;
  30. break;
  31. case 48000:
  32. freq = 12288000;
  33. break;
  34. case 96000:
  35. freq = 24576000;
  36. break;
  37. }
  38. return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN);
  39. }
  40. static struct snd_soc_ops openrd_client_ops = {
  41. .hw_params = openrd_client_hw_params,
  42. };
  43. static struct snd_soc_dai_link openrd_client_dai[] = {
  44. {
  45. .name = "CS42L51",
  46. .stream_name = "CS42L51 HiFi",
  47. .cpu_dai_name = "i2s",
  48. .platform_name = "mvebu-audio",
  49. .codec_dai_name = "cs42l51-hifi",
  50. .codec_name = "cs42l51-codec.0-004a",
  51. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
  52. .ops = &openrd_client_ops,
  53. },
  54. };
  55. static struct snd_soc_card openrd_client = {
  56. .name = "OpenRD Client",
  57. .owner = THIS_MODULE,
  58. .dai_link = openrd_client_dai,
  59. .num_links = ARRAY_SIZE(openrd_client_dai),
  60. };
  61. static int openrd_probe(struct platform_device *pdev)
  62. {
  63. struct snd_soc_card *card = &openrd_client;
  64. int ret;
  65. card->dev = &pdev->dev;
  66. ret = snd_soc_register_card(card);
  67. if (ret)
  68. dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
  69. ret);
  70. return ret;
  71. }
  72. static int openrd_remove(struct platform_device *pdev)
  73. {
  74. struct snd_soc_card *card = platform_get_drvdata(pdev);
  75. snd_soc_unregister_card(card);
  76. return 0;
  77. }
  78. static struct platform_driver openrd_driver = {
  79. .driver = {
  80. .name = "openrd-client-audio",
  81. .owner = THIS_MODULE,
  82. },
  83. .probe = openrd_probe,
  84. .remove = openrd_remove,
  85. };
  86. module_platform_driver(openrd_driver);
  87. /* Module information */
  88. MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
  89. MODULE_DESCRIPTION("ALSA SoC OpenRD Client");
  90. MODULE_LICENSE("GPL");
  91. MODULE_ALIAS("platform:openrd-client-audio");