spdif_transmitter.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * ALSA SoC SPDIF DIT driver
  4. *
  5. * This driver is used by controllers which can operate in DIT (SPDI/F) where
  6. * no codec is needed. This file provides stub codec that can be used
  7. * in these configurations. TI DaVinci Audio controller uses this driver.
  8. *
  9. * Author: Steve Chen, <schen@mvista.com>
  10. * Copyright: (C) 2009 MontaVista Software, Inc., <source@mvista.com>
  11. * Copyright: (C) 2009 Texas Instruments, India
  12. */
  13. #include <linux/module.h>
  14. #include <linux/moduleparam.h>
  15. #include <linux/slab.h>
  16. #include <sound/soc.h>
  17. #include <sound/pcm.h>
  18. #include <sound/initval.h>
  19. #include <linux/of.h>
  20. #define DRV_NAME "spdif-dit"
  21. #define STUB_RATES SNDRV_PCM_RATE_8000_192000
  22. #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
  23. SNDRV_PCM_FMTBIT_S20_3LE | \
  24. SNDRV_PCM_FMTBIT_S24_LE | \
  25. SNDRV_PCM_FMTBIT_S32_LE)
  26. static const struct snd_soc_dapm_widget dit_widgets[] = {
  27. SND_SOC_DAPM_OUTPUT("spdif-out"),
  28. };
  29. static const struct snd_soc_dapm_route dit_routes[] = {
  30. { "spdif-out", NULL, "Playback" },
  31. };
  32. static struct snd_soc_component_driver soc_codec_spdif_dit = {
  33. .dapm_widgets = dit_widgets,
  34. .num_dapm_widgets = ARRAY_SIZE(dit_widgets),
  35. .dapm_routes = dit_routes,
  36. .num_dapm_routes = ARRAY_SIZE(dit_routes),
  37. .idle_bias_on = 1,
  38. .use_pmdown_time = 1,
  39. .endianness = 1,
  40. .non_legacy_dai_naming = 1,
  41. };
  42. static struct snd_soc_dai_driver dit_stub_dai = {
  43. .name = "dit-hifi",
  44. .playback = {
  45. .stream_name = "Playback",
  46. .channels_min = 1,
  47. .channels_max = 384,
  48. .rates = STUB_RATES,
  49. .formats = STUB_FORMATS,
  50. },
  51. };
  52. static int spdif_dit_probe(struct platform_device *pdev)
  53. {
  54. return devm_snd_soc_register_component(&pdev->dev,
  55. &soc_codec_spdif_dit,
  56. &dit_stub_dai, 1);
  57. }
  58. #ifdef CONFIG_OF
  59. static const struct of_device_id spdif_dit_dt_ids[] = {
  60. { .compatible = "linux,spdif-dit", },
  61. { }
  62. };
  63. MODULE_DEVICE_TABLE(of, spdif_dit_dt_ids);
  64. #endif
  65. static struct platform_driver spdif_dit_driver = {
  66. .probe = spdif_dit_probe,
  67. .driver = {
  68. .name = DRV_NAME,
  69. .of_match_table = of_match_ptr(spdif_dit_dt_ids),
  70. },
  71. };
  72. module_platform_driver(spdif_dit_driver);
  73. MODULE_AUTHOR("Steve Chen <schen@mvista.com>");
  74. MODULE_DESCRIPTION("SPDIF dummy codec driver");
  75. MODULE_LICENSE("GPL");
  76. MODULE_ALIAS("platform:" DRV_NAME);