ad73311.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * ad73311.c -- ALSA Soc AD73311 codec support
  4. *
  5. * Copyright: Analog Devices Inc.
  6. * Author: Cliff Cai <cliff.cai@analog.com>
  7. */
  8. #include <linux/init.h>
  9. #include <linux/slab.h>
  10. #include <linux/module.h>
  11. #include <linux/kernel.h>
  12. #include <linux/device.h>
  13. #include <sound/core.h>
  14. #include <sound/pcm.h>
  15. #include <sound/ac97_codec.h>
  16. #include <sound/initval.h>
  17. #include <sound/soc.h>
  18. #include "ad73311.h"
  19. static const struct snd_soc_dapm_widget ad73311_dapm_widgets[] = {
  20. SND_SOC_DAPM_INPUT("VINP"),
  21. SND_SOC_DAPM_INPUT("VINN"),
  22. SND_SOC_DAPM_OUTPUT("VOUTN"),
  23. SND_SOC_DAPM_OUTPUT("VOUTP"),
  24. };
  25. static const struct snd_soc_dapm_route ad73311_dapm_routes[] = {
  26. { "Capture", NULL, "VINP" },
  27. { "Capture", NULL, "VINN" },
  28. { "VOUTN", NULL, "Playback" },
  29. { "VOUTP", NULL, "Playback" },
  30. };
  31. static struct snd_soc_dai_driver ad73311_dai = {
  32. .name = "ad73311-hifi",
  33. .playback = {
  34. .stream_name = "Playback",
  35. .channels_min = 1,
  36. .channels_max = 1,
  37. .rates = SNDRV_PCM_RATE_8000,
  38. .formats = SNDRV_PCM_FMTBIT_S16_LE, },
  39. .capture = {
  40. .stream_name = "Capture",
  41. .channels_min = 1,
  42. .channels_max = 1,
  43. .rates = SNDRV_PCM_RATE_8000,
  44. .formats = SNDRV_PCM_FMTBIT_S16_LE, },
  45. };
  46. static const struct snd_soc_component_driver soc_component_dev_ad73311 = {
  47. .dapm_widgets = ad73311_dapm_widgets,
  48. .num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets),
  49. .dapm_routes = ad73311_dapm_routes,
  50. .num_dapm_routes = ARRAY_SIZE(ad73311_dapm_routes),
  51. .idle_bias_on = 1,
  52. .use_pmdown_time = 1,
  53. .endianness = 1,
  54. .non_legacy_dai_naming = 1,
  55. };
  56. static int ad73311_probe(struct platform_device *pdev)
  57. {
  58. return devm_snd_soc_register_component(&pdev->dev,
  59. &soc_component_dev_ad73311, &ad73311_dai, 1);
  60. }
  61. static struct platform_driver ad73311_codec_driver = {
  62. .driver = {
  63. .name = "ad73311",
  64. },
  65. .probe = ad73311_probe,
  66. };
  67. module_platform_driver(ad73311_codec_driver);
  68. MODULE_DESCRIPTION("ASoC ad73311 driver");
  69. MODULE_AUTHOR("Cliff Cai ");
  70. MODULE_LICENSE("GPL");