spdif_receiver.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * ALSA SoC SPDIF DIR (Digital Interface Reciever) driver
  4. *
  5. * Based on ALSA SoC SPDIF DIT driver
  6. *
  7. * This driver is used by controllers which can operate in DIR (SPDI/F) where
  8. * no codec is needed. This file provides stub codec that can be used
  9. * in these configurations. SPEAr SPDIF IN Audio controller uses this driver.
  10. *
  11. * Author: Vipin Kumar, <vipin.kumar@st.com>
  12. * Copyright: (C) 2012 ST Microelectronics
  13. */
  14. #include <linux/module.h>
  15. #include <linux/moduleparam.h>
  16. #include <linux/slab.h>
  17. #include <sound/soc.h>
  18. #include <sound/pcm.h>
  19. #include <sound/initval.h>
  20. #include <linux/of.h>
  21. static const struct snd_soc_dapm_widget dir_widgets[] = {
  22. SND_SOC_DAPM_INPUT("spdif-in"),
  23. };
  24. static const struct snd_soc_dapm_route dir_routes[] = {
  25. { "Capture", NULL, "spdif-in" },
  26. };
  27. #define STUB_RATES SNDRV_PCM_RATE_8000_192000
  28. #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
  29. SNDRV_PCM_FMTBIT_S20_3LE | \
  30. SNDRV_PCM_FMTBIT_S24_LE | \
  31. SNDRV_PCM_FMTBIT_S32_LE | \
  32. SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
  33. static struct snd_soc_component_driver soc_codec_spdif_dir = {
  34. .dapm_widgets = dir_widgets,
  35. .num_dapm_widgets = ARRAY_SIZE(dir_widgets),
  36. .dapm_routes = dir_routes,
  37. .num_dapm_routes = ARRAY_SIZE(dir_routes),
  38. .idle_bias_on = 1,
  39. .use_pmdown_time = 1,
  40. .endianness = 1,
  41. .non_legacy_dai_naming = 1,
  42. };
  43. static struct snd_soc_dai_driver dir_stub_dai = {
  44. .name = "dir-hifi",
  45. .capture = {
  46. .stream_name = "Capture",
  47. .channels_min = 1,
  48. .channels_max = 384,
  49. .rates = STUB_RATES,
  50. .formats = STUB_FORMATS,
  51. },
  52. };
  53. static int spdif_dir_probe(struct platform_device *pdev)
  54. {
  55. return devm_snd_soc_register_component(&pdev->dev,
  56. &soc_codec_spdif_dir,
  57. &dir_stub_dai, 1);
  58. }
  59. #ifdef CONFIG_OF
  60. static const struct of_device_id spdif_dir_dt_ids[] = {
  61. { .compatible = "linux,spdif-dir", },
  62. { }
  63. };
  64. MODULE_DEVICE_TABLE(of, spdif_dir_dt_ids);
  65. #endif
  66. static struct platform_driver spdif_dir_driver = {
  67. .probe = spdif_dir_probe,
  68. .driver = {
  69. .name = "spdif-dir",
  70. .of_match_table = of_match_ptr(spdif_dir_dt_ids),
  71. },
  72. };
  73. module_platform_driver(spdif_dir_driver);
  74. MODULE_DESCRIPTION("ASoC SPDIF DIR driver");
  75. MODULE_AUTHOR("Vipin Kumar <vipin.kumar@st.com>");
  76. MODULE_LICENSE("GPL");