msm8x60-dai.c 3.8 KB

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