mvs-dai.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* Copyright (c) 2010, The Linux Foundation. All rights reserved.
  2. *
  3. * This software is licensed under the terms of the GNU General Public
  4. * License version 2, as published by the Free Software Foundation, and
  5. * may be copied, distributed, and modified under those terms.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. *
  11. * See the GNU General Public License for more details.
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, you can find it at http://www.fsf.org.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/module.h>
  17. #include <linux/device.h>
  18. #include <linux/delay.h>
  19. #include <linux/clk.h>
  20. #include <linux/platform_device.h>
  21. #include <sound/core.h>
  22. #include <sound/pcm.h>
  23. #include <sound/initval.h>
  24. #include <sound/soc.h>
  25. #include "msm_audio_mvs.h"
  26. static struct snd_soc_dai_driver msm_mvs_codec_dais[] = {
  27. {
  28. .name = "mvs-codec-dai",
  29. .playback = {
  30. .channels_max = 2,
  31. .rates = (SNDRV_PCM_RATE_8000),
  32. .rate_min = 8000,
  33. .rate_max = 8000,
  34. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  35. },
  36. .capture = {
  37. .channels_max = 2,
  38. .rates = (SNDRV_PCM_RATE_8000),
  39. .rate_min = 8000,
  40. .rate_max = 8000,
  41. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  42. },
  43. },
  44. };
  45. static struct snd_soc_dai_driver msm_mvs_cpu_dais[] = {
  46. {
  47. .name = "mvs-cpu-dai",
  48. .playback = {
  49. .channels_max = 2,
  50. .rates = (SNDRV_PCM_RATE_8000),
  51. .rate_min = 8000,
  52. .rate_max = 8000,
  53. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  54. },
  55. .capture = {
  56. .channels_max = 2,
  57. .rates = (SNDRV_PCM_RATE_8000),
  58. .rate_min = 8000,
  59. .rate_max = 8000,
  60. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  61. },
  62. },
  63. };
  64. static struct snd_soc_codec_driver soc_codec_dev_msm = {
  65. .compress_type = SND_SOC_FLAT_COMPRESSION,
  66. };
  67. static __devinit int asoc_mvs_codec_probe(struct platform_device *pdev)
  68. {
  69. dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev));
  70. return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_msm,
  71. msm_mvs_codec_dais, ARRAY_SIZE(msm_mvs_codec_dais));
  72. }
  73. static int __devexit asoc_mvs_codec_remove(struct platform_device *pdev)
  74. {
  75. snd_soc_unregister_dai(&pdev->dev);
  76. return 0;
  77. }
  78. static __devinit int asoc_mvs_cpu_probe(struct platform_device *pdev)
  79. {
  80. dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev));
  81. return snd_soc_register_dai(&pdev->dev, msm_mvs_cpu_dais);
  82. }
  83. static int __devexit asoc_mvs_cpu_remove(struct platform_device *pdev)
  84. {
  85. snd_soc_unregister_dai(&pdev->dev);
  86. return 0;
  87. }
  88. static struct platform_driver asoc_mvs_codec_driver = {
  89. .probe = asoc_mvs_codec_probe,
  90. .remove = __devexit_p(asoc_mvs_codec_remove),
  91. .driver = {
  92. .name = "mvs-codec-dai",
  93. .owner = THIS_MODULE,
  94. },
  95. };
  96. static struct platform_driver asoc_mvs_cpu_driver = {
  97. .probe = asoc_mvs_cpu_probe,
  98. .remove = __devexit_p(asoc_mvs_cpu_remove),
  99. .driver = {
  100. .name = "mvs-cpu-dai",
  101. .owner = THIS_MODULE,
  102. },
  103. };
  104. static int __init mvs_codec_dai_init(void)
  105. {
  106. return platform_driver_register(&asoc_mvs_codec_driver);
  107. }
  108. static void __exit mvs_codec_dai_exit(void)
  109. {
  110. platform_driver_unregister(&asoc_mvs_codec_driver);
  111. }
  112. static int __init mvs_cpu_dai_init(void)
  113. {
  114. return platform_driver_register(&asoc_mvs_cpu_driver);
  115. }
  116. static void __exit mvs_cpu_dai_exit(void)
  117. {
  118. platform_driver_unregister(&asoc_mvs_cpu_driver);
  119. }
  120. module_init(mvs_codec_dai_init);
  121. module_exit(mvs_codec_dai_exit);
  122. module_init(mvs_cpu_dai_init);
  123. module_exit(mvs_cpu_dai_exit);
  124. /* Module information */
  125. MODULE_DESCRIPTION("MSM Codec/Cpu Dai driver");
  126. MODULE_LICENSE("GPL v2");