wm8782.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * sound/soc/codecs/wm8782.c
  3. * simple, strap-pin configured 24bit 2ch ADC
  4. *
  5. * Copyright: 2011 Raumfeld GmbH
  6. * Author: Johannes Stezenbach <js@sig21.net>
  7. *
  8. * based on ad73311.c
  9. * Copyright: Analog Device Inc.
  10. * Author: Cliff Cai <cliff.cai@analog.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. */
  17. #include <linux/init.h>
  18. #include <linux/slab.h>
  19. #include <linux/module.h>
  20. #include <linux/kernel.h>
  21. #include <linux/device.h>
  22. #include <sound/core.h>
  23. #include <sound/pcm.h>
  24. #include <sound/ac97_codec.h>
  25. #include <sound/initval.h>
  26. #include <sound/soc.h>
  27. static const struct snd_soc_dapm_widget wm8782_dapm_widgets[] = {
  28. SND_SOC_DAPM_INPUT("AINL"),
  29. SND_SOC_DAPM_INPUT("AINR"),
  30. };
  31. static const struct snd_soc_dapm_route wm8782_dapm_routes[] = {
  32. { "Capture", NULL, "AINL" },
  33. { "Capture", NULL, "AINR" },
  34. };
  35. static struct snd_soc_dai_driver wm8782_dai = {
  36. .name = "wm8782",
  37. .capture = {
  38. .stream_name = "Capture",
  39. .channels_min = 2,
  40. .channels_max = 2,
  41. /* For configurations with FSAMPEN=0 */
  42. .rates = SNDRV_PCM_RATE_8000_48000,
  43. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  44. SNDRV_PCM_FMTBIT_S20_3LE |
  45. SNDRV_PCM_FMTBIT_S24_LE,
  46. },
  47. };
  48. static struct snd_soc_codec_driver soc_codec_dev_wm8782 = {
  49. .dapm_widgets = wm8782_dapm_widgets,
  50. .num_dapm_widgets = ARRAY_SIZE(wm8782_dapm_widgets),
  51. .dapm_routes = wm8782_dapm_routes,
  52. .num_dapm_routes = ARRAY_SIZE(wm8782_dapm_routes),
  53. };
  54. static int wm8782_probe(struct platform_device *pdev)
  55. {
  56. return snd_soc_register_codec(&pdev->dev,
  57. &soc_codec_dev_wm8782, &wm8782_dai, 1);
  58. }
  59. static int wm8782_remove(struct platform_device *pdev)
  60. {
  61. snd_soc_unregister_codec(&pdev->dev);
  62. return 0;
  63. }
  64. static struct platform_driver wm8782_codec_driver = {
  65. .driver = {
  66. .name = "wm8782",
  67. .owner = THIS_MODULE,
  68. },
  69. .probe = wm8782_probe,
  70. .remove = wm8782_remove,
  71. };
  72. module_platform_driver(wm8782_codec_driver);
  73. MODULE_DESCRIPTION("ASoC WM8782 driver");
  74. MODULE_AUTHOR("Johannes Stezenbach <js@sig21.net>");
  75. MODULE_LICENSE("GPL");