hdmi.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #define DRV_NAME "hdmi-audio-codec"
  24. static const struct snd_soc_dapm_widget hdmi_widgets[] = {
  25. SND_SOC_DAPM_INPUT("RX"),
  26. SND_SOC_DAPM_OUTPUT("TX"),
  27. };
  28. static const struct snd_soc_dapm_route hdmi_routes[] = {
  29. { "Capture", NULL, "RX" },
  30. { "TX", NULL, "Playback" },
  31. };
  32. static struct snd_soc_dai_driver hdmi_codec_dai = {
  33. .name = "hdmi-hifi",
  34. .playback = {
  35. .stream_name = "Playback",
  36. .channels_min = 2,
  37. .channels_max = 8,
  38. .rates = SNDRV_PCM_RATE_32000 |
  39. SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
  40. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
  41. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,
  42. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  43. SNDRV_PCM_FMTBIT_S24_LE,
  44. },
  45. .capture = {
  46. .stream_name = "Capture",
  47. .channels_min = 2,
  48. .channels_max = 2,
  49. .rates = SNDRV_PCM_RATE_32000 |
  50. SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
  51. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
  52. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,
  53. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  54. SNDRV_PCM_FMTBIT_S24_LE,
  55. },
  56. };
  57. static struct snd_soc_codec_driver hdmi_codec = {
  58. .dapm_widgets = hdmi_widgets,
  59. .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets),
  60. .dapm_routes = hdmi_routes,
  61. .num_dapm_routes = ARRAY_SIZE(hdmi_routes),
  62. };
  63. static int hdmi_codec_probe(struct platform_device *pdev)
  64. {
  65. return snd_soc_register_codec(&pdev->dev, &hdmi_codec,
  66. &hdmi_codec_dai, 1);
  67. }
  68. static int hdmi_codec_remove(struct platform_device *pdev)
  69. {
  70. snd_soc_unregister_codec(&pdev->dev);
  71. return 0;
  72. }
  73. static struct platform_driver hdmi_codec_driver = {
  74. .driver = {
  75. .name = DRV_NAME,
  76. .owner = THIS_MODULE,
  77. },
  78. .probe = hdmi_codec_probe,
  79. .remove = hdmi_codec_remove,
  80. };
  81. module_platform_driver(hdmi_codec_driver);
  82. MODULE_AUTHOR("Ricardo Neri <ricardo.neri@ti.com>");
  83. MODULE_DESCRIPTION("ASoC generic HDMI codec driver");
  84. MODULE_LICENSE("GPL");
  85. MODULE_ALIAS("platform:" DRV_NAME);