hdmi.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * ALSA SoC codec driver for HDMI audio codecs.
  3. * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
  4. * Author: Ricardo Neri <ricardo.neri@ti.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  18. * 02110-1301 USA
  19. *
  20. */
  21. #include <linux/module.h>
  22. #include <sound/soc.h>
  23. #include <linux/of.h>
  24. #include <linux/of_device.h>
  25. #define DRV_NAME "hdmi-audio-codec"
  26. static const struct snd_soc_dapm_widget hdmi_widgets[] = {
  27. SND_SOC_DAPM_INPUT("RX"),
  28. SND_SOC_DAPM_OUTPUT("TX"),
  29. };
  30. static const struct snd_soc_dapm_route hdmi_routes[] = {
  31. { "Capture", NULL, "RX" },
  32. { "TX", NULL, "Playback" },
  33. };
  34. static struct snd_soc_dai_driver hdmi_codec_dai = {
  35. .name = "hdmi-hifi",
  36. .playback = {
  37. .stream_name = "Playback",
  38. .channels_min = 2,
  39. .channels_max = 8,
  40. .rates = SNDRV_PCM_RATE_32000 |
  41. SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
  42. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
  43. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,
  44. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  45. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
  46. },
  47. .capture = {
  48. .stream_name = "Capture",
  49. .channels_min = 2,
  50. .channels_max = 2,
  51. .rates = SNDRV_PCM_RATE_32000 |
  52. SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
  53. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
  54. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,
  55. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  56. SNDRV_PCM_FMTBIT_S24_LE,
  57. },
  58. };
  59. #ifdef CONFIG_OF
  60. static const struct of_device_id hdmi_audio_codec_ids[] = {
  61. { .compatible = "linux,hdmi-audio", },
  62. { }
  63. };
  64. MODULE_DEVICE_TABLE(of, hdmi_audio_codec_ids);
  65. #endif
  66. static struct snd_soc_codec_driver hdmi_codec = {
  67. .dapm_widgets = hdmi_widgets,
  68. .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets),
  69. .dapm_routes = hdmi_routes,
  70. .num_dapm_routes = ARRAY_SIZE(hdmi_routes),
  71. };
  72. static int hdmi_codec_probe(struct platform_device *pdev)
  73. {
  74. return snd_soc_register_codec(&pdev->dev, &hdmi_codec,
  75. &hdmi_codec_dai, 1);
  76. }
  77. static int hdmi_codec_remove(struct platform_device *pdev)
  78. {
  79. snd_soc_unregister_codec(&pdev->dev);
  80. return 0;
  81. }
  82. static struct platform_driver hdmi_codec_driver = {
  83. .driver = {
  84. .name = DRV_NAME,
  85. .owner = THIS_MODULE,
  86. .of_match_table = of_match_ptr(hdmi_audio_codec_ids),
  87. },
  88. .probe = hdmi_codec_probe,
  89. .remove = hdmi_codec_remove,
  90. };
  91. module_platform_driver(hdmi_codec_driver);
  92. MODULE_AUTHOR("Ricardo Neri <ricardo.neri@ti.com>");
  93. MODULE_DESCRIPTION("ASoC generic HDMI codec driver");
  94. MODULE_LICENSE("GPL");
  95. MODULE_ALIAS("platform:" DRV_NAME);