msm7kv2-dai.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* sound/soc/msm/msm-dai.c
  2. *
  3. * Copyright (C) 2008 Google, Inc.
  4. * Copyright (C) 2008 HTC Corporation
  5. * Copyright (c) 2008-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 <linux/slab.h>
  33. #include "msm7kv2-pcm.h"
  34. static struct snd_soc_dai_driver msm_pcm_codec_dais[] = {
  35. {
  36. .name = "msm-codec-dai",
  37. .playback = {
  38. .channels_max = USE_CHANNELS_MAX,
  39. .rate_min = USE_RATE_MIN,
  40. .rate_max = USE_RATE_MAX,
  41. .rates = SNDRV_PCM_RATE_8000_48000,
  42. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  43. },
  44. .capture = {
  45. .channels_max = USE_CHANNELS_MAX,
  46. .rate_min = USE_RATE_MIN,
  47. .rate_max = USE_RATE_MAX,
  48. .rates = SNDRV_PCM_RATE_8000_48000,
  49. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  50. },
  51. },
  52. };
  53. static struct snd_soc_dai_driver msm_pcm_cpu_dais[] = {
  54. {
  55. .name = "msm-cpu-dai",
  56. .playback = {
  57. .channels_max = USE_CHANNELS_MAX,
  58. .rate_min = USE_RATE_MIN,
  59. .rate_max = USE_RATE_MAX,
  60. .rates = SNDRV_PCM_RATE_8000_48000,
  61. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  62. },
  63. .capture = {
  64. .channels_max = USE_CHANNELS_MAX,
  65. .rate_min = USE_RATE_MIN,
  66. .rate_max = USE_RATE_MAX,
  67. .rates = SNDRV_PCM_RATE_8000_48000,
  68. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  69. },
  70. },
  71. };
  72. static struct snd_soc_codec_driver soc_codec_dev_msm = {
  73. .compress_type = SND_SOC_FLAT_COMPRESSION,
  74. };
  75. static __devinit int asoc_msm_codec_probe(struct platform_device *pdev)
  76. {
  77. dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev));
  78. return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_msm,
  79. msm_pcm_codec_dais, ARRAY_SIZE(msm_pcm_codec_dais));
  80. }
  81. static int __devexit asoc_msm_codec_remove(struct platform_device *pdev)
  82. {
  83. snd_soc_unregister_dai(&pdev->dev);
  84. return 0;
  85. }
  86. static __devinit int asoc_msm_cpu_probe(struct platform_device *pdev)
  87. {
  88. dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev));
  89. return snd_soc_register_dai(&pdev->dev, msm_pcm_cpu_dais);
  90. }
  91. static int __devexit asoc_msm_cpu_remove(struct platform_device *pdev)
  92. {
  93. snd_soc_unregister_dai(&pdev->dev);
  94. return 0;
  95. }
  96. static struct platform_driver asoc_msm_codec_driver = {
  97. .probe = asoc_msm_codec_probe,
  98. .remove = __devexit_p(asoc_msm_codec_remove),
  99. .driver = {
  100. .name = "msm-codec-dai",
  101. .owner = THIS_MODULE,
  102. },
  103. };
  104. static struct platform_driver asoc_msm_cpu_driver = {
  105. .probe = asoc_msm_cpu_probe,
  106. .remove = __devexit_p(asoc_msm_cpu_remove),
  107. .driver = {
  108. .name = "msm-cpu-dai",
  109. .owner = THIS_MODULE,
  110. },
  111. };
  112. static int __init msm_codec_dai_init(void)
  113. {
  114. return platform_driver_register(&asoc_msm_codec_driver);
  115. }
  116. static void __exit msm_codec_dai_exit(void)
  117. {
  118. platform_driver_unregister(&asoc_msm_codec_driver);
  119. }
  120. static int __init msm_cpu_dai_init(void)
  121. {
  122. return platform_driver_register(&asoc_msm_cpu_driver);
  123. }
  124. static void __exit msm_cpu_dai_exit(void)
  125. {
  126. platform_driver_unregister(&asoc_msm_cpu_driver);
  127. }
  128. module_init(msm_codec_dai_init);
  129. module_exit(msm_codec_dai_exit);
  130. module_init(msm_cpu_dai_init);
  131. module_exit(msm_cpu_dai_exit);
  132. /* Module information */
  133. MODULE_DESCRIPTION("MSM Codec/Cpu Dai driver");
  134. MODULE_LICENSE("GPL v2");