dw_hdmi.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2011 Freescale Semiconductor, Inc.
  4. */
  5. #ifndef __DW_HDMI__
  6. #define __DW_HDMI__
  7. #include <sound/hdmi-codec.h>
  8. struct drm_display_info;
  9. struct drm_display_mode;
  10. struct drm_encoder;
  11. struct dw_hdmi;
  12. struct platform_device;
  13. /**
  14. * DOC: Supported input formats and encodings
  15. *
  16. * Depending on the Hardware configuration of the Controller IP, it supports
  17. * a subset of the following input formats and encodings on its internal
  18. * 48bit bus.
  19. *
  20. * +----------------------+----------------------------------+------------------------------+
  21. * | Format Name | Format Code | Encodings |
  22. * +----------------------+----------------------------------+------------------------------+
  23. * | RGB 4:4:4 8bit | ``MEDIA_BUS_FMT_RGB888_1X24`` | ``V4L2_YCBCR_ENC_DEFAULT`` |
  24. * +----------------------+----------------------------------+------------------------------+
  25. * | RGB 4:4:4 10bits | ``MEDIA_BUS_FMT_RGB101010_1X30`` | ``V4L2_YCBCR_ENC_DEFAULT`` |
  26. * +----------------------+----------------------------------+------------------------------+
  27. * | RGB 4:4:4 12bits | ``MEDIA_BUS_FMT_RGB121212_1X36`` | ``V4L2_YCBCR_ENC_DEFAULT`` |
  28. * +----------------------+----------------------------------+------------------------------+
  29. * | RGB 4:4:4 16bits | ``MEDIA_BUS_FMT_RGB161616_1X48`` | ``V4L2_YCBCR_ENC_DEFAULT`` |
  30. * +----------------------+----------------------------------+------------------------------+
  31. * | YCbCr 4:4:4 8bit | ``MEDIA_BUS_FMT_YUV8_1X24`` | ``V4L2_YCBCR_ENC_601`` |
  32. * | | | or ``V4L2_YCBCR_ENC_709`` |
  33. * | | | or ``V4L2_YCBCR_ENC_XV601`` |
  34. * | | | or ``V4L2_YCBCR_ENC_XV709`` |
  35. * +----------------------+----------------------------------+------------------------------+
  36. * | YCbCr 4:4:4 10bits | ``MEDIA_BUS_FMT_YUV10_1X30`` | ``V4L2_YCBCR_ENC_601`` |
  37. * | | | or ``V4L2_YCBCR_ENC_709`` |
  38. * | | | or ``V4L2_YCBCR_ENC_XV601`` |
  39. * | | | or ``V4L2_YCBCR_ENC_XV709`` |
  40. * +----------------------+----------------------------------+------------------------------+
  41. * | YCbCr 4:4:4 12bits | ``MEDIA_BUS_FMT_YUV12_1X36`` | ``V4L2_YCBCR_ENC_601`` |
  42. * | | | or ``V4L2_YCBCR_ENC_709`` |
  43. * | | | or ``V4L2_YCBCR_ENC_XV601`` |
  44. * | | | or ``V4L2_YCBCR_ENC_XV709`` |
  45. * +----------------------+----------------------------------+------------------------------+
  46. * | YCbCr 4:4:4 16bits | ``MEDIA_BUS_FMT_YUV16_1X48`` | ``V4L2_YCBCR_ENC_601`` |
  47. * | | | or ``V4L2_YCBCR_ENC_709`` |
  48. * | | | or ``V4L2_YCBCR_ENC_XV601`` |
  49. * | | | or ``V4L2_YCBCR_ENC_XV709`` |
  50. * +----------------------+----------------------------------+------------------------------+
  51. * | YCbCr 4:2:2 8bit | ``MEDIA_BUS_FMT_UYVY8_1X16`` | ``V4L2_YCBCR_ENC_601`` |
  52. * | | | or ``V4L2_YCBCR_ENC_709`` |
  53. * +----------------------+----------------------------------+------------------------------+
  54. * | YCbCr 4:2:2 10bits | ``MEDIA_BUS_FMT_UYVY10_1X20`` | ``V4L2_YCBCR_ENC_601`` |
  55. * | | | or ``V4L2_YCBCR_ENC_709`` |
  56. * +----------------------+----------------------------------+------------------------------+
  57. * | YCbCr 4:2:2 12bits | ``MEDIA_BUS_FMT_UYVY12_1X24`` | ``V4L2_YCBCR_ENC_601`` |
  58. * | | | or ``V4L2_YCBCR_ENC_709`` |
  59. * +----------------------+----------------------------------+------------------------------+
  60. * | YCbCr 4:2:0 8bit | ``MEDIA_BUS_FMT_UYYVYY8_0_5X24`` | ``V4L2_YCBCR_ENC_601`` |
  61. * | | | or ``V4L2_YCBCR_ENC_709`` |
  62. * +----------------------+----------------------------------+------------------------------+
  63. * | YCbCr 4:2:0 10bits | ``MEDIA_BUS_FMT_UYYVYY10_0_5X30``| ``V4L2_YCBCR_ENC_601`` |
  64. * | | | or ``V4L2_YCBCR_ENC_709`` |
  65. * +----------------------+----------------------------------+------------------------------+
  66. * | YCbCr 4:2:0 12bits | ``MEDIA_BUS_FMT_UYYVYY12_0_5X36``| ``V4L2_YCBCR_ENC_601`` |
  67. * | | | or ``V4L2_YCBCR_ENC_709`` |
  68. * +----------------------+----------------------------------+------------------------------+
  69. * | YCbCr 4:2:0 16bits | ``MEDIA_BUS_FMT_UYYVYY16_0_5X48``| ``V4L2_YCBCR_ENC_601`` |
  70. * | | | or ``V4L2_YCBCR_ENC_709`` |
  71. * +----------------------+----------------------------------+------------------------------+
  72. */
  73. enum {
  74. DW_HDMI_RES_8,
  75. DW_HDMI_RES_10,
  76. DW_HDMI_RES_12,
  77. DW_HDMI_RES_MAX,
  78. };
  79. enum dw_hdmi_phy_type {
  80. DW_HDMI_PHY_DWC_HDMI_TX_PHY = 0x00,
  81. DW_HDMI_PHY_DWC_MHL_PHY_HEAC = 0xb2,
  82. DW_HDMI_PHY_DWC_MHL_PHY = 0xc2,
  83. DW_HDMI_PHY_DWC_HDMI_3D_TX_PHY_HEAC = 0xe2,
  84. DW_HDMI_PHY_DWC_HDMI_3D_TX_PHY = 0xf2,
  85. DW_HDMI_PHY_DWC_HDMI20_TX_PHY = 0xf3,
  86. DW_HDMI_PHY_VENDOR_PHY = 0xfe,
  87. };
  88. struct dw_hdmi_mpll_config {
  89. unsigned long mpixelclock;
  90. struct {
  91. u16 cpce;
  92. u16 gmp;
  93. } res[DW_HDMI_RES_MAX];
  94. };
  95. struct dw_hdmi_curr_ctrl {
  96. unsigned long mpixelclock;
  97. u16 curr[DW_HDMI_RES_MAX];
  98. };
  99. struct dw_hdmi_phy_config {
  100. unsigned long mpixelclock;
  101. u16 sym_ctr; /*clock symbol and transmitter control*/
  102. u16 term; /*transmission termination value*/
  103. u16 vlev_ctr; /* voltage level control */
  104. };
  105. struct dw_hdmi_phy_ops {
  106. int (*init)(struct dw_hdmi *hdmi, void *data,
  107. const struct drm_display_info *display,
  108. const struct drm_display_mode *mode);
  109. void (*disable)(struct dw_hdmi *hdmi, void *data);
  110. enum drm_connector_status (*read_hpd)(struct dw_hdmi *hdmi, void *data);
  111. void (*update_hpd)(struct dw_hdmi *hdmi, void *data,
  112. bool force, bool disabled, bool rxsense);
  113. void (*setup_hpd)(struct dw_hdmi *hdmi, void *data);
  114. };
  115. struct dw_hdmi_plat_data {
  116. struct regmap *regm;
  117. unsigned int output_port;
  118. unsigned long input_bus_encoding;
  119. bool use_drm_infoframe;
  120. bool ycbcr_420_allowed;
  121. /*
  122. * Private data passed to all the .mode_valid() and .configure_phy()
  123. * callback functions.
  124. */
  125. void *priv_data;
  126. /* Platform-specific mode validation (optional). */
  127. enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,
  128. const struct drm_display_info *info,
  129. const struct drm_display_mode *mode);
  130. /*
  131. * priv_audio is specially used for additional audio device to get
  132. * driver data through this dw_hdmi_plat_data.
  133. */
  134. void *priv_audio;
  135. /* Platform-specific audio enable/disable (optional) */
  136. void (*enable_audio)(struct dw_hdmi *hdmi, int channel,
  137. int width, int rate, int non_pcm, int iec958);
  138. void (*disable_audio)(struct dw_hdmi *hdmi);
  139. /* Vendor PHY support */
  140. const struct dw_hdmi_phy_ops *phy_ops;
  141. const char *phy_name;
  142. void *phy_data;
  143. unsigned int phy_force_vendor;
  144. /* Synopsys PHY support */
  145. const struct dw_hdmi_mpll_config *mpll_cfg;
  146. const struct dw_hdmi_curr_ctrl *cur_ctr;
  147. const struct dw_hdmi_phy_config *phy_config;
  148. int (*configure_phy)(struct dw_hdmi *hdmi, void *data,
  149. unsigned long mpixelclock);
  150. unsigned int disable_cec : 1;
  151. };
  152. struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
  153. const struct dw_hdmi_plat_data *plat_data);
  154. void dw_hdmi_remove(struct dw_hdmi *hdmi);
  155. void dw_hdmi_unbind(struct dw_hdmi *hdmi);
  156. struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev,
  157. struct drm_encoder *encoder,
  158. const struct dw_hdmi_plat_data *plat_data);
  159. void dw_hdmi_resume(struct dw_hdmi *hdmi);
  160. void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense);
  161. int dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn,
  162. struct device *codec_dev);
  163. void dw_hdmi_set_sample_non_pcm(struct dw_hdmi *hdmi, unsigned int non_pcm);
  164. void dw_hdmi_set_sample_iec958(struct dw_hdmi *hdmi, unsigned int iec958);
  165. void dw_hdmi_set_sample_width(struct dw_hdmi *hdmi, unsigned int width);
  166. void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate);
  167. void dw_hdmi_set_channel_count(struct dw_hdmi *hdmi, unsigned int cnt);
  168. void dw_hdmi_set_channel_status(struct dw_hdmi *hdmi, u8 *channel_status);
  169. void dw_hdmi_set_channel_allocation(struct dw_hdmi *hdmi, unsigned int ca);
  170. void dw_hdmi_audio_enable(struct dw_hdmi *hdmi);
  171. void dw_hdmi_audio_disable(struct dw_hdmi *hdmi);
  172. void dw_hdmi_set_high_tmds_clock_ratio(struct dw_hdmi *hdmi,
  173. const struct drm_display_info *display);
  174. /* PHY configuration */
  175. void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address);
  176. void dw_hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data,
  177. unsigned char addr);
  178. void dw_hdmi_phy_gen1_reset(struct dw_hdmi *hdmi);
  179. void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable);
  180. void dw_hdmi_phy_gen2_txpwron(struct dw_hdmi *hdmi, u8 enable);
  181. void dw_hdmi_phy_gen2_reset(struct dw_hdmi *hdmi);
  182. enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi,
  183. void *data);
  184. void dw_hdmi_phy_update_hpd(struct dw_hdmi *hdmi, void *data,
  185. bool force, bool disabled, bool rxsense);
  186. void dw_hdmi_phy_setup_hpd(struct dw_hdmi *hdmi, void *data);
  187. bool dw_hdmi_bus_fmt_is_420(struct dw_hdmi *hdmi);
  188. const struct dw_hdmi_plat_data *dw_hdmi_to_plat_data(struct dw_hdmi *hdmi);
  189. #endif /* __IMX_HDMI_H__ */