display.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. #include <linux/hrtimer.h>
  37. #include <linux/types.h>
  38. struct intel_gvt;
  39. struct intel_vgpu;
  40. #define SBI_REG_MAX 20
  41. #define DPCD_SIZE 0x700
  42. #define intel_vgpu_port(vgpu, port) \
  43. (&(vgpu->display.ports[port]))
  44. #define intel_vgpu_has_monitor_on_port(vgpu, port) \
  45. (intel_vgpu_port(vgpu, port)->edid && \
  46. intel_vgpu_port(vgpu, port)->edid->data_valid)
  47. #define intel_vgpu_port_is_dp(vgpu, port) \
  48. ((intel_vgpu_port(vgpu, port)->type == GVT_DP_A) || \
  49. (intel_vgpu_port(vgpu, port)->type == GVT_DP_B) || \
  50. (intel_vgpu_port(vgpu, port)->type == GVT_DP_C) || \
  51. (intel_vgpu_port(vgpu, port)->type == GVT_DP_D))
  52. #define INTEL_GVT_MAX_UEVENT_VARS 3
  53. #define AUX_NATIVE_REPLY_NAK (0x1 << 4)
  54. #define AUX_BURST_SIZE 20
  55. struct intel_vgpu_sbi_register {
  56. unsigned int offset;
  57. u32 value;
  58. };
  59. struct intel_vgpu_sbi {
  60. int number;
  61. struct intel_vgpu_sbi_register registers[SBI_REG_MAX];
  62. };
  63. enum intel_gvt_plane_type {
  64. PRIMARY_PLANE = 0,
  65. CURSOR_PLANE,
  66. SPRITE_PLANE,
  67. MAX_PLANE
  68. };
  69. struct intel_vgpu_dpcd_data {
  70. bool data_valid;
  71. u8 data[DPCD_SIZE];
  72. };
  73. enum intel_vgpu_port_type {
  74. GVT_CRT = 0,
  75. GVT_DP_A,
  76. GVT_DP_B,
  77. GVT_DP_C,
  78. GVT_DP_D,
  79. GVT_HDMI_B,
  80. GVT_HDMI_C,
  81. GVT_HDMI_D,
  82. GVT_PORT_MAX
  83. };
  84. enum intel_vgpu_edid {
  85. GVT_EDID_1024_768,
  86. GVT_EDID_1920_1200,
  87. GVT_EDID_NUM,
  88. };
  89. #define GVT_DEFAULT_REFRESH_RATE 60
  90. struct intel_vgpu_port {
  91. /* per display EDID information */
  92. struct intel_vgpu_edid_data *edid;
  93. /* per display DPCD information */
  94. struct intel_vgpu_dpcd_data *dpcd;
  95. int type;
  96. enum intel_vgpu_edid id;
  97. /* x1000 to get accurate 59.94, 24.976, 29.94, etc. in timing std. */
  98. u32 vrefresh_k;
  99. };
  100. struct intel_vgpu_vblank_timer {
  101. struct hrtimer timer;
  102. u32 vrefresh_k;
  103. u64 period;
  104. };
  105. static inline char *vgpu_edid_str(enum intel_vgpu_edid id)
  106. {
  107. switch (id) {
  108. case GVT_EDID_1024_768:
  109. return "1024x768";
  110. case GVT_EDID_1920_1200:
  111. return "1920x1200";
  112. default:
  113. return "";
  114. }
  115. }
  116. static inline unsigned int vgpu_edid_xres(enum intel_vgpu_edid id)
  117. {
  118. switch (id) {
  119. case GVT_EDID_1024_768:
  120. return 1024;
  121. case GVT_EDID_1920_1200:
  122. return 1920;
  123. default:
  124. return 0;
  125. }
  126. }
  127. static inline unsigned int vgpu_edid_yres(enum intel_vgpu_edid id)
  128. {
  129. switch (id) {
  130. case GVT_EDID_1024_768:
  131. return 768;
  132. case GVT_EDID_1920_1200:
  133. return 1200;
  134. default:
  135. return 0;
  136. }
  137. }
  138. void intel_vgpu_emulate_vblank(struct intel_vgpu *vgpu);
  139. void vgpu_update_vblank_emulation(struct intel_vgpu *vgpu, bool turnon);
  140. int intel_vgpu_init_display(struct intel_vgpu *vgpu, u64 resolution);
  141. void intel_vgpu_reset_display(struct intel_vgpu *vgpu);
  142. void intel_vgpu_clean_display(struct intel_vgpu *vgpu);
  143. int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe);
  144. #endif