kirkwood-openrd.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 <mach/kirkwood.h>
  19. #include <plat/audio.h>
  20. #include <asm/mach-types.h>
  21. #include "../codecs/cs42l51.h"
  22. static int openrd_client_hw_params(struct snd_pcm_substream *substream,
  23. struct snd_pcm_hw_params *params)
  24. {
  25. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  26. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  27. unsigned int freq;
  28. switch (params_rate(params)) {
  29. default:
  30. case 44100:
  31. freq = 11289600;
  32. break;
  33. case 48000:
  34. freq = 12288000;
  35. break;
  36. case 96000:
  37. freq = 24576000;
  38. break;
  39. }
  40. return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN);
  41. }
  42. static struct snd_soc_ops openrd_client_ops = {
  43. .hw_params = openrd_client_hw_params,
  44. };
  45. static struct snd_soc_dai_link openrd_client_dai[] = {
  46. {
  47. .name = "CS42L51",
  48. .stream_name = "CS42L51 HiFi",
  49. .cpu_dai_name = "kirkwood-i2s",
  50. .platform_name = "kirkwood-pcm-audio",
  51. .codec_dai_name = "cs42l51-hifi",
  52. .codec_name = "cs42l51-codec.0-004a",
  53. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
  54. .ops = &openrd_client_ops,
  55. },
  56. };
  57. static struct snd_soc_card openrd_client = {
  58. .name = "OpenRD Client",
  59. .owner = THIS_MODULE,
  60. .dai_link = openrd_client_dai,
  61. .num_links = ARRAY_SIZE(openrd_client_dai),
  62. };
  63. static int __devinit openrd_probe(struct platform_device *pdev)
  64. {
  65. struct snd_soc_card *card = &openrd_client;
  66. int ret;
  67. card->dev = &pdev->dev;
  68. ret = snd_soc_register_card(card);
  69. if (ret)
  70. dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
  71. ret);
  72. return ret;
  73. }
  74. static int __devexit openrd_remove(struct platform_device *pdev)
  75. {
  76. struct snd_soc_card *card = platform_get_drvdata(pdev);
  77. snd_soc_unregister_card(card);
  78. return 0;
  79. }
  80. static struct platform_driver openrd_driver = {
  81. .driver = {
  82. .name = "openrd-client-audio",
  83. .owner = THIS_MODULE,
  84. },
  85. .probe = openrd_probe,
  86. .remove = __devexit_p(openrd_remove),
  87. };
  88. module_platform_driver(openrd_driver);
  89. /* Module information */
  90. MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
  91. MODULE_DESCRIPTION("ALSA SoC OpenRD Client");
  92. MODULE_LICENSE("GPL");
  93. MODULE_ALIAS("platform:openrd-client-audio");