dmic.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * dmic.c -- SoC audio for Generic Digital MICs
  3. *
  4. * Author: Liam Girdwood <lrg@slimlogic.co.uk>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  18. * 02110-1301 USA
  19. *
  20. */
  21. #include <linux/platform_device.h>
  22. #include <linux/slab.h>
  23. #include <sound/core.h>
  24. #include <sound/pcm.h>
  25. #include <sound/soc.h>
  26. #include <sound/soc-dapm.h>
  27. static struct snd_soc_dai_driver dmic_dai = {
  28. .name = "dmic-hifi",
  29. .capture = {
  30. .stream_name = "Capture",
  31. .channels_min = 1,
  32. .channels_max = 8,
  33. .rates = SNDRV_PCM_RATE_CONTINUOUS,
  34. .formats = SNDRV_PCM_FMTBIT_S32_LE
  35. | SNDRV_PCM_FMTBIT_S24_LE
  36. | SNDRV_PCM_FMTBIT_S16_LE,
  37. },
  38. };
  39. static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = {
  40. SND_SOC_DAPM_AIF_OUT("DMIC AIF", "Capture", 0,
  41. SND_SOC_NOPM, 0, 0),
  42. SND_SOC_DAPM_INPUT("DMic"),
  43. };
  44. static const struct snd_soc_dapm_route intercon[] = {
  45. {"DMIC AIF", NULL, "DMic"},
  46. };
  47. static int dmic_probe(struct snd_soc_codec *codec)
  48. {
  49. struct snd_soc_dapm_context *dapm = &codec->dapm;
  50. snd_soc_dapm_new_controls(dapm, dmic_dapm_widgets,
  51. ARRAY_SIZE(dmic_dapm_widgets));
  52. snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
  53. snd_soc_dapm_new_widgets(dapm);
  54. return 0;
  55. }
  56. static struct snd_soc_codec_driver soc_dmic = {
  57. .probe = dmic_probe,
  58. };
  59. static int __devinit dmic_dev_probe(struct platform_device *pdev)
  60. {
  61. return snd_soc_register_codec(&pdev->dev,
  62. &soc_dmic, &dmic_dai, 1);
  63. }
  64. static int __devexit dmic_dev_remove(struct platform_device *pdev)
  65. {
  66. snd_soc_unregister_codec(&pdev->dev);
  67. return 0;
  68. }
  69. MODULE_ALIAS("platform:dmic-codec");
  70. static struct platform_driver dmic_driver = {
  71. .driver = {
  72. .name = "dmic-codec",
  73. .owner = THIS_MODULE,
  74. },
  75. .probe = dmic_dev_probe,
  76. .remove = __devexit_p(dmic_dev_remove),
  77. };
  78. static int __init dmic_init(void)
  79. {
  80. return platform_driver_register(&dmic_driver);
  81. }
  82. module_init(dmic_init);
  83. static void __exit dmic_exit(void)
  84. {
  85. platform_driver_unregister(&dmic_driver);
  86. }
  87. module_exit(dmic_exit);
  88. MODULE_DESCRIPTION("Generic DMIC driver");
  89. MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
  90. MODULE_LICENSE("GPL");