ad73311.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * ad73311.c -- ALSA Soc AD73311 codec support
  3. *
  4. * Copyright: Analog Device Inc.
  5. * Author: Cliff Cai <cliff.cai@analog.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/slab.h>
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/device.h>
  17. #include <sound/core.h>
  18. #include <sound/pcm.h>
  19. #include <sound/ac97_codec.h>
  20. #include <sound/initval.h>
  21. #include <sound/soc.h>
  22. #include "ad73311.h"
  23. static const struct snd_soc_dapm_widget ad73311_dapm_widgets[] = {
  24. SND_SOC_DAPM_INPUT("VINP"),
  25. SND_SOC_DAPM_INPUT("VINN"),
  26. SND_SOC_DAPM_OUTPUT("VOUTN"),
  27. SND_SOC_DAPM_OUTPUT("VOUTP"),
  28. };
  29. static const struct snd_soc_dapm_route ad73311_dapm_routes[] = {
  30. { "Capture", NULL, "VINP" },
  31. { "Capture", NULL, "VINN" },
  32. { "VOUTN", NULL, "Playback" },
  33. { "VOUTP", NULL, "Playback" },
  34. };
  35. static struct snd_soc_dai_driver ad73311_dai = {
  36. .name = "ad73311-hifi",
  37. .playback = {
  38. .stream_name = "Playback",
  39. .channels_min = 1,
  40. .channels_max = 1,
  41. .rates = SNDRV_PCM_RATE_8000,
  42. .formats = SNDRV_PCM_FMTBIT_S16_LE, },
  43. .capture = {
  44. .stream_name = "Capture",
  45. .channels_min = 1,
  46. .channels_max = 1,
  47. .rates = SNDRV_PCM_RATE_8000,
  48. .formats = SNDRV_PCM_FMTBIT_S16_LE, },
  49. };
  50. static struct snd_soc_codec_driver soc_codec_dev_ad73311 = {
  51. .component_driver = {
  52. .dapm_widgets = ad73311_dapm_widgets,
  53. .num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets),
  54. .dapm_routes = ad73311_dapm_routes,
  55. .num_dapm_routes = ARRAY_SIZE(ad73311_dapm_routes),
  56. },
  57. };
  58. static int ad73311_probe(struct platform_device *pdev)
  59. {
  60. return snd_soc_register_codec(&pdev->dev,
  61. &soc_codec_dev_ad73311, &ad73311_dai, 1);
  62. }
  63. static int ad73311_remove(struct platform_device *pdev)
  64. {
  65. snd_soc_unregister_codec(&pdev->dev);
  66. return 0;
  67. }
  68. static struct platform_driver ad73311_codec_driver = {
  69. .driver = {
  70. .name = "ad73311",
  71. },
  72. .probe = ad73311_probe,
  73. .remove = ad73311_remove,
  74. };
  75. module_platform_driver(ad73311_codec_driver);
  76. MODULE_DESCRIPTION("ASoC ad73311 driver");
  77. MODULE_AUTHOR("Cliff Cai ");
  78. MODULE_LICENSE("GPL");