spdif_receiver.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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, <[email protected]>
  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. };
  42. static struct snd_soc_dai_driver dir_stub_dai = {
  43. .name = "dir-hifi",
  44. .capture = {
  45. .stream_name = "Capture",
  46. .channels_min = 1,
  47. .channels_max = 384,
  48. .rates = STUB_RATES,
  49. .formats = STUB_FORMATS,
  50. },
  51. };
  52. static int spdif_dir_probe(struct platform_device *pdev)
  53. {
  54. return devm_snd_soc_register_component(&pdev->dev,
  55. &soc_codec_spdif_dir,
  56. &dir_stub_dai, 1);
  57. }
  58. #ifdef CONFIG_OF
  59. static const struct of_device_id spdif_dir_dt_ids[] = {
  60. { .compatible = "linux,spdif-dir", },
  61. { }
  62. };
  63. MODULE_DEVICE_TABLE(of, spdif_dir_dt_ids);
  64. #endif
  65. static struct platform_driver spdif_dir_driver = {
  66. .probe = spdif_dir_probe,
  67. .driver = {
  68. .name = "spdif-dir",
  69. .of_match_table = of_match_ptr(spdif_dir_dt_ids),
  70. },
  71. };
  72. module_platform_driver(spdif_dir_driver);
  73. MODULE_DESCRIPTION("ASoC SPDIF DIR driver");
  74. MODULE_AUTHOR("Vipin Kumar <[email protected]>");
  75. MODULE_LICENSE("GPL");