dw_hdmi.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (C) 2011 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. */
  9. #ifndef __DW_HDMI__
  10. #define __DW_HDMI__
  11. #include <drm/drmP.h>
  12. struct dw_hdmi;
  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. struct drm_display_mode *mode);
  108. void (*disable)(struct dw_hdmi *hdmi, void *data);
  109. enum drm_connector_status (*read_hpd)(struct dw_hdmi *hdmi, void *data);
  110. void (*update_hpd)(struct dw_hdmi *hdmi, void *data,
  111. bool force, bool disabled, bool rxsense);
  112. void (*setup_hpd)(struct dw_hdmi *hdmi, void *data);
  113. };
  114. struct dw_hdmi_plat_data {
  115. struct regmap *regm;
  116. enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
  117. const struct drm_display_mode *mode);
  118. unsigned long input_bus_format;
  119. unsigned long input_bus_encoding;
  120. /* Vendor PHY support */
  121. const struct dw_hdmi_phy_ops *phy_ops;
  122. const char *phy_name;
  123. void *phy_data;
  124. /* Synopsys PHY support */
  125. const struct dw_hdmi_mpll_config *mpll_cfg;
  126. const struct dw_hdmi_curr_ctrl *cur_ctr;
  127. const struct dw_hdmi_phy_config *phy_config;
  128. int (*configure_phy)(struct dw_hdmi *hdmi,
  129. const struct dw_hdmi_plat_data *pdata,
  130. unsigned long mpixelclock);
  131. };
  132. struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
  133. const struct dw_hdmi_plat_data *plat_data);
  134. void dw_hdmi_remove(struct dw_hdmi *hdmi);
  135. void dw_hdmi_unbind(struct dw_hdmi *hdmi);
  136. struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev,
  137. struct drm_encoder *encoder,
  138. const struct dw_hdmi_plat_data *plat_data);
  139. void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense);
  140. void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate);
  141. void dw_hdmi_audio_enable(struct dw_hdmi *hdmi);
  142. void dw_hdmi_audio_disable(struct dw_hdmi *hdmi);
  143. /* PHY configuration */
  144. void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address);
  145. void dw_hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data,
  146. unsigned char addr);
  147. void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable);
  148. void dw_hdmi_phy_gen2_txpwron(struct dw_hdmi *hdmi, u8 enable);
  149. void dw_hdmi_phy_reset(struct dw_hdmi *hdmi);
  150. enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi,
  151. void *data);
  152. void dw_hdmi_phy_update_hpd(struct dw_hdmi *hdmi, void *data,
  153. bool force, bool disabled, bool rxsense);
  154. void dw_hdmi_phy_setup_hpd(struct dw_hdmi *hdmi, void *data);
  155. #endif /* __IMX_HDMI_H__ */