display.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
  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 (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. *
  23. * Authors:
  24. * Ke Yu
  25. * Zhiyuan Lv <zhiyuan.lv@intel.com>
  26. *
  27. * Contributors:
  28. * Terrence Xu <terrence.xu@intel.com>
  29. * Changbin Du <changbin.du@intel.com>
  30. * Bing Niu <bing.niu@intel.com>
  31. * Zhi Wang <zhi.a.wang@intel.com>
  32. *
  33. */
  34. #ifndef _GVT_DISPLAY_H_
  35. #define _GVT_DISPLAY_H_
  36. #define SBI_REG_MAX 20
  37. #define DPCD_SIZE 0x700
  38. #define intel_vgpu_port(vgpu, port) \
  39. (&(vgpu->display.ports[port]))
  40. #define intel_vgpu_has_monitor_on_port(vgpu, port) \
  41. (intel_vgpu_port(vgpu, port)->edid && \
  42. intel_vgpu_port(vgpu, port)->edid->data_valid)
  43. #define intel_vgpu_port_is_dp(vgpu, port) \
  44. ((intel_vgpu_port(vgpu, port)->type == GVT_DP_A) || \
  45. (intel_vgpu_port(vgpu, port)->type == GVT_DP_B) || \
  46. (intel_vgpu_port(vgpu, port)->type == GVT_DP_C) || \
  47. (intel_vgpu_port(vgpu, port)->type == GVT_DP_D))
  48. #define INTEL_GVT_MAX_UEVENT_VARS 3
  49. /* DPCD start */
  50. #define DPCD_SIZE 0x700
  51. /* DPCD */
  52. #define DP_SET_POWER 0x600
  53. #define DP_SET_POWER_D0 0x1
  54. #define AUX_NATIVE_WRITE 0x8
  55. #define AUX_NATIVE_READ 0x9
  56. #define AUX_NATIVE_REPLY_MASK (0x3 << 4)
  57. #define AUX_NATIVE_REPLY_ACK (0x0 << 4)
  58. #define AUX_NATIVE_REPLY_NAK (0x1 << 4)
  59. #define AUX_NATIVE_REPLY_DEFER (0x2 << 4)
  60. #define AUX_BURST_SIZE 16
  61. /* DPCD addresses */
  62. #define DPCD_REV 0x000
  63. #define DPCD_MAX_LINK_RATE 0x001
  64. #define DPCD_MAX_LANE_COUNT 0x002
  65. #define DPCD_TRAINING_PATTERN_SET 0x102
  66. #define DPCD_SINK_COUNT 0x200
  67. #define DPCD_LANE0_1_STATUS 0x202
  68. #define DPCD_LANE2_3_STATUS 0x203
  69. #define DPCD_LANE_ALIGN_STATUS_UPDATED 0x204
  70. #define DPCD_SINK_STATUS 0x205
  71. /* link training */
  72. #define DPCD_TRAINING_PATTERN_SET_MASK 0x03
  73. #define DPCD_LINK_TRAINING_DISABLED 0x00
  74. #define DPCD_TRAINING_PATTERN_1 0x01
  75. #define DPCD_TRAINING_PATTERN_2 0x02
  76. #define DPCD_CP_READY_MASK (1 << 6)
  77. /* lane status */
  78. #define DPCD_LANES_CR_DONE 0x11
  79. #define DPCD_LANES_EQ_DONE 0x22
  80. #define DPCD_SYMBOL_LOCKED 0x44
  81. #define DPCD_INTERLANE_ALIGN_DONE 0x01
  82. #define DPCD_SINK_IN_SYNC 0x03
  83. /* DPCD end */
  84. #define SBI_RESPONSE_MASK 0x3
  85. #define SBI_RESPONSE_SHIFT 0x1
  86. #define SBI_STAT_MASK 0x1
  87. #define SBI_STAT_SHIFT 0x0
  88. #define SBI_OPCODE_SHIFT 8
  89. #define SBI_OPCODE_MASK (0xff << SBI_OPCODE_SHIFT)
  90. #define SBI_CMD_IORD 2
  91. #define SBI_CMD_IOWR 3
  92. #define SBI_CMD_CRRD 6
  93. #define SBI_CMD_CRWR 7
  94. #define SBI_ADDR_OFFSET_SHIFT 16
  95. #define SBI_ADDR_OFFSET_MASK (0xffff << SBI_ADDR_OFFSET_SHIFT)
  96. struct intel_vgpu_sbi_register {
  97. unsigned int offset;
  98. u32 value;
  99. };
  100. struct intel_vgpu_sbi {
  101. int number;
  102. struct intel_vgpu_sbi_register registers[SBI_REG_MAX];
  103. };
  104. enum intel_gvt_plane_type {
  105. PRIMARY_PLANE = 0,
  106. CURSOR_PLANE,
  107. SPRITE_PLANE,
  108. MAX_PLANE
  109. };
  110. struct intel_vgpu_dpcd_data {
  111. bool data_valid;
  112. u8 data[DPCD_SIZE];
  113. };
  114. enum intel_vgpu_port_type {
  115. GVT_CRT = 0,
  116. GVT_DP_A,
  117. GVT_DP_B,
  118. GVT_DP_C,
  119. GVT_DP_D,
  120. GVT_HDMI_B,
  121. GVT_HDMI_C,
  122. GVT_HDMI_D,
  123. GVT_PORT_MAX
  124. };
  125. struct intel_vgpu_port {
  126. /* per display EDID information */
  127. struct intel_vgpu_edid_data *edid;
  128. /* per display DPCD information */
  129. struct intel_vgpu_dpcd_data *dpcd;
  130. int type;
  131. };
  132. void intel_gvt_emulate_vblank(struct intel_gvt *gvt);
  133. void intel_gvt_check_vblank_emulation(struct intel_gvt *gvt);
  134. int intel_vgpu_init_display(struct intel_vgpu *vgpu);
  135. void intel_vgpu_clean_display(struct intel_vgpu *vgpu);
  136. #endif