dmic.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 <linux/module.h>
  24. #include <sound/core.h>
  25. #include <sound/pcm.h>
  26. #include <sound/soc.h>
  27. #include <sound/soc-dapm.h>
  28. static struct snd_soc_dai_driver dmic_dai = {
  29. .name = "dmic-hifi",
  30. .capture = {
  31. .stream_name = "Capture",
  32. .channels_min = 1,
  33. .channels_max = 8,
  34. .rates = SNDRV_PCM_RATE_CONTINUOUS,
  35. .formats = SNDRV_PCM_FMTBIT_S32_LE
  36. | SNDRV_PCM_FMTBIT_S24_LE
  37. | SNDRV_PCM_FMTBIT_S16_LE,
  38. },
  39. };
  40. static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = {
  41. SND_SOC_DAPM_AIF_OUT("DMIC AIF", "Capture", 0,
  42. SND_SOC_NOPM, 0, 0),
  43. SND_SOC_DAPM_INPUT("DMic"),
  44. };
  45. static const struct snd_soc_dapm_route intercon[] = {
  46. {"DMIC AIF", NULL, "DMic"},
  47. };
  48. static int dmic_probe(struct snd_soc_codec *codec)
  49. {
  50. struct snd_soc_dapm_context *dapm = &codec->dapm;
  51. snd_soc_dapm_new_controls(dapm, dmic_dapm_widgets,
  52. ARRAY_SIZE(dmic_dapm_widgets));
  53. snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
  54. snd_soc_dapm_new_widgets(dapm);
  55. return 0;
  56. }
  57. static struct snd_soc_codec_driver soc_dmic = {
  58. .probe = dmic_probe,
  59. };
  60. static int __devinit dmic_dev_probe(struct platform_device *pdev)
  61. {
  62. return snd_soc_register_codec(&pdev->dev,
  63. &soc_dmic, &dmic_dai, 1);
  64. }
  65. static int __devexit dmic_dev_remove(struct platform_device *pdev)
  66. {
  67. snd_soc_unregister_codec(&pdev->dev);
  68. return 0;
  69. }
  70. MODULE_ALIAS("platform:dmic-codec");
  71. static struct platform_driver dmic_driver = {
  72. .driver = {
  73. .name = "dmic-codec",
  74. .owner = THIS_MODULE,
  75. },
  76. .probe = dmic_dev_probe,
  77. .remove = __devexit_p(dmic_dev_remove),
  78. };
  79. module_platform_driver(dmic_driver);
  80. MODULE_DESCRIPTION("Generic DMIC driver");
  81. MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
  82. MODULE_LICENSE("GPL");