drm_dp_dual_mode_helper.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright © 2016 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #ifndef DRM_DP_DUAL_MODE_HELPER_H
  23. #define DRM_DP_DUAL_MODE_HELPER_H
  24. #include <linux/types.h>
  25. /*
  26. * Optional for type 1 DVI adaptors
  27. * Mandatory for type 1 HDMI and type 2 adaptors
  28. */
  29. #define DP_DUAL_MODE_HDMI_ID 0x00 /* 00-0f */
  30. #define DP_DUAL_MODE_HDMI_ID_LEN 16
  31. /*
  32. * Optional for type 1 adaptors
  33. * Mandatory for type 2 adaptors
  34. */
  35. #define DP_DUAL_MODE_ADAPTOR_ID 0x10
  36. #define DP_DUAL_MODE_REV_MASK 0x07
  37. #define DP_DUAL_MODE_REV_TYPE2 0x00
  38. #define DP_DUAL_MODE_TYPE_MASK 0xf0
  39. #define DP_DUAL_MODE_TYPE_TYPE2 0xa0
  40. /* This field is marked reserved in dual mode spec, used in LSPCON */
  41. #define DP_DUAL_MODE_TYPE_HAS_DPCD 0x08
  42. #define DP_DUAL_MODE_IEEE_OUI 0x11 /* 11-13*/
  43. #define DP_DUAL_IEEE_OUI_LEN 3
  44. #define DP_DUAL_DEVICE_ID 0x14 /* 14-19 */
  45. #define DP_DUAL_DEVICE_ID_LEN 6
  46. #define DP_DUAL_MODE_HARDWARE_REV 0x1a
  47. #define DP_DUAL_MODE_FIRMWARE_MAJOR_REV 0x1b
  48. #define DP_DUAL_MODE_FIRMWARE_MINOR_REV 0x1c
  49. #define DP_DUAL_MODE_MAX_TMDS_CLOCK 0x1d
  50. #define DP_DUAL_MODE_I2C_SPEED_CAP 0x1e
  51. #define DP_DUAL_MODE_TMDS_OEN 0x20
  52. #define DP_DUAL_MODE_TMDS_DISABLE 0x01
  53. #define DP_DUAL_MODE_HDMI_PIN_CTRL 0x21
  54. #define DP_DUAL_MODE_CEC_ENABLE 0x01
  55. #define DP_DUAL_MODE_I2C_SPEED_CTRL 0x22
  56. /* LSPCON specific registers, defined by MCA */
  57. #define DP_DUAL_MODE_LSPCON_MODE_CHANGE 0x40
  58. #define DP_DUAL_MODE_LSPCON_CURRENT_MODE 0x41
  59. #define DP_DUAL_MODE_LSPCON_MODE_PCON 0x1
  60. struct i2c_adapter;
  61. ssize_t drm_dp_dual_mode_read(struct i2c_adapter *adapter,
  62. u8 offset, void *buffer, size_t size);
  63. ssize_t drm_dp_dual_mode_write(struct i2c_adapter *adapter,
  64. u8 offset, const void *buffer, size_t size);
  65. /**
  66. * enum drm_lspcon_mode
  67. * @DRM_LSPCON_MODE_INVALID: No LSPCON.
  68. * @DRM_LSPCON_MODE_LS: Level shifter mode of LSPCON
  69. * which drives DP++ to HDMI 1.4 conversion.
  70. * @DRM_LSPCON_MODE_PCON: Protocol converter mode of LSPCON
  71. * which drives DP++ to HDMI 2.0 active conversion.
  72. */
  73. enum drm_lspcon_mode {
  74. DRM_LSPCON_MODE_INVALID,
  75. DRM_LSPCON_MODE_LS,
  76. DRM_LSPCON_MODE_PCON,
  77. };
  78. /**
  79. * enum drm_dp_dual_mode_type - Type of the DP dual mode adaptor
  80. * @DRM_DP_DUAL_MODE_NONE: No DP dual mode adaptor
  81. * @DRM_DP_DUAL_MODE_UNKNOWN: Could be either none or type 1 DVI adaptor
  82. * @DRM_DP_DUAL_MODE_TYPE1_DVI: Type 1 DVI adaptor
  83. * @DRM_DP_DUAL_MODE_TYPE1_HDMI: Type 1 HDMI adaptor
  84. * @DRM_DP_DUAL_MODE_TYPE2_DVI: Type 2 DVI adaptor
  85. * @DRM_DP_DUAL_MODE_TYPE2_HDMI: Type 2 HDMI adaptor
  86. * @DRM_DP_DUAL_MODE_LSPCON: Level shifter / protocol converter
  87. */
  88. enum drm_dp_dual_mode_type {
  89. DRM_DP_DUAL_MODE_NONE,
  90. DRM_DP_DUAL_MODE_UNKNOWN,
  91. DRM_DP_DUAL_MODE_TYPE1_DVI,
  92. DRM_DP_DUAL_MODE_TYPE1_HDMI,
  93. DRM_DP_DUAL_MODE_TYPE2_DVI,
  94. DRM_DP_DUAL_MODE_TYPE2_HDMI,
  95. DRM_DP_DUAL_MODE_LSPCON,
  96. };
  97. enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(struct i2c_adapter *adapter);
  98. int drm_dp_dual_mode_max_tmds_clock(enum drm_dp_dual_mode_type type,
  99. struct i2c_adapter *adapter);
  100. int drm_dp_dual_mode_get_tmds_output(enum drm_dp_dual_mode_type type,
  101. struct i2c_adapter *adapter, bool *enabled);
  102. int drm_dp_dual_mode_set_tmds_output(enum drm_dp_dual_mode_type type,
  103. struct i2c_adapter *adapter, bool enable);
  104. const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type);
  105. int drm_lspcon_get_mode(struct i2c_adapter *adapter,
  106. enum drm_lspcon_mode *current_mode);
  107. int drm_lspcon_set_mode(struct i2c_adapter *adapter,
  108. enum drm_lspcon_mode reqd_mode);
  109. #endif