hdmi-codec.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * hdmi-codec.h - HDMI Codec driver API
  3. *
  4. * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
  5. *
  6. * Author: Jyri Sarha <jsarha@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #ifndef __HDMI_CODEC_H__
  18. #define __HDMI_CODEC_H__
  19. #include <linux/of_graph.h>
  20. #include <linux/hdmi.h>
  21. #include <drm/drm_edid.h>
  22. #include <sound/asoundef.h>
  23. #include <sound/soc.h>
  24. #include <uapi/sound/asound.h>
  25. /*
  26. * Protocol between ASoC cpu-dai and HDMI-encoder
  27. */
  28. struct hdmi_codec_daifmt {
  29. enum {
  30. HDMI_I2S,
  31. HDMI_RIGHT_J,
  32. HDMI_LEFT_J,
  33. HDMI_DSP_A,
  34. HDMI_DSP_B,
  35. HDMI_AC97,
  36. HDMI_SPDIF,
  37. } fmt;
  38. unsigned int bit_clk_inv:1;
  39. unsigned int frame_clk_inv:1;
  40. unsigned int bit_clk_master:1;
  41. unsigned int frame_clk_master:1;
  42. };
  43. /*
  44. * HDMI audio parameters
  45. */
  46. struct hdmi_codec_params {
  47. struct hdmi_audio_infoframe cea;
  48. struct snd_aes_iec958 iec;
  49. int sample_rate;
  50. int sample_width;
  51. int channels;
  52. };
  53. struct hdmi_codec_pdata;
  54. struct hdmi_codec_ops {
  55. /*
  56. * Called when ASoC starts an audio stream setup.
  57. * Optional
  58. */
  59. int (*audio_startup)(struct device *dev, void *data);
  60. /*
  61. * Configures HDMI-encoder for audio stream.
  62. * Mandatory
  63. */
  64. int (*hw_params)(struct device *dev, void *data,
  65. struct hdmi_codec_daifmt *fmt,
  66. struct hdmi_codec_params *hparms);
  67. /*
  68. * Shuts down the audio stream.
  69. * Mandatory
  70. */
  71. void (*audio_shutdown)(struct device *dev, void *data);
  72. /*
  73. * Mute/unmute HDMI audio stream.
  74. * Optional
  75. */
  76. int (*digital_mute)(struct device *dev, void *data, bool enable);
  77. /*
  78. * Provides EDID-Like-Data from connected HDMI device.
  79. * Optional
  80. */
  81. int (*get_eld)(struct device *dev, void *data,
  82. uint8_t *buf, size_t len);
  83. /*
  84. * Getting DAI ID
  85. * Optional
  86. */
  87. int (*get_dai_id)(struct snd_soc_component *comment,
  88. struct device_node *endpoint);
  89. };
  90. /* HDMI codec initalization data */
  91. struct hdmi_codec_pdata {
  92. const struct hdmi_codec_ops *ops;
  93. uint i2s:1;
  94. uint spdif:1;
  95. int max_i2s_channels;
  96. void *data;
  97. };
  98. #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec"
  99. #endif /* __HDMI_CODEC_H__ */