edid.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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_EDID_H_
  35. #define _GVT_EDID_H_
  36. #define EDID_SIZE 128
  37. #define EDID_ADDR 0x50 /* Linux hvm EDID addr */
  38. #define GVT_AUX_NATIVE_WRITE 0x8
  39. #define GVT_AUX_NATIVE_READ 0x9
  40. #define GVT_AUX_I2C_WRITE 0x0
  41. #define GVT_AUX_I2C_READ 0x1
  42. #define GVT_AUX_I2C_STATUS 0x2
  43. #define GVT_AUX_I2C_MOT 0x4
  44. #define GVT_AUX_I2C_REPLY_ACK 0x0
  45. struct intel_vgpu_edid_data {
  46. bool data_valid;
  47. unsigned char edid_block[EDID_SIZE];
  48. };
  49. enum gmbus_cycle_type {
  50. GMBUS_NOCYCLE = 0x0,
  51. NIDX_NS_W = 0x1,
  52. IDX_NS_W = 0x3,
  53. GMBUS_STOP = 0x4,
  54. NIDX_STOP = 0x5,
  55. IDX_STOP = 0x7
  56. };
  57. /*
  58. * States of GMBUS
  59. *
  60. * GMBUS0-3 could be related to the EDID virtualization. Another two GMBUS
  61. * registers, GMBUS4 (interrupt mask) and GMBUS5 (2 byte indes register), are
  62. * not considered here. Below describes the usage of GMBUS registers that are
  63. * cared by the EDID virtualization
  64. *
  65. * GMBUS0:
  66. * R/W
  67. * port selection. value of bit0 - bit2 corresponds to the GPIO registers.
  68. *
  69. * GMBUS1:
  70. * R/W Protect
  71. * Command and Status.
  72. * bit0 is the direction bit: 1 is read; 0 is write.
  73. * bit1 - bit7 is slave 7-bit address.
  74. * bit16 - bit24 total byte count (ignore?)
  75. *
  76. * GMBUS2:
  77. * Most of bits are read only except bit 15 (IN_USE)
  78. * Status register
  79. * bit0 - bit8 current byte count
  80. * bit 11: hardware ready;
  81. *
  82. * GMBUS3:
  83. * Read/Write
  84. * Data for transfer
  85. */
  86. /* From hw specs, Other phases like START, ADDRESS, INDEX
  87. * are invisible to GMBUS MMIO interface. So no definitions
  88. * in below enum types
  89. */
  90. enum gvt_gmbus_phase {
  91. GMBUS_IDLE_PHASE = 0,
  92. GMBUS_DATA_PHASE,
  93. GMBUS_WAIT_PHASE,
  94. //GMBUS_STOP_PHASE,
  95. GMBUS_MAX_PHASE
  96. };
  97. struct intel_vgpu_i2c_gmbus {
  98. unsigned int total_byte_count; /* from GMBUS1 */
  99. enum gmbus_cycle_type cycle_type;
  100. enum gvt_gmbus_phase phase;
  101. };
  102. struct intel_vgpu_i2c_aux_ch {
  103. bool i2c_over_aux_ch;
  104. bool aux_ch_mot;
  105. };
  106. enum i2c_state {
  107. I2C_NOT_SPECIFIED = 0,
  108. I2C_GMBUS = 1,
  109. I2C_AUX_CH = 2
  110. };
  111. /* I2C sequences cannot interleave.
  112. * GMBUS and AUX_CH sequences cannot interleave.
  113. */
  114. struct intel_vgpu_i2c_edid {
  115. enum i2c_state state;
  116. unsigned int port;
  117. bool slave_selected;
  118. bool edid_available;
  119. unsigned int current_edid_read;
  120. struct intel_vgpu_i2c_gmbus gmbus;
  121. struct intel_vgpu_i2c_aux_ch aux_ch;
  122. };
  123. void intel_vgpu_init_i2c_edid(struct intel_vgpu *vgpu);
  124. int intel_gvt_i2c_handle_gmbus_read(struct intel_vgpu *vgpu,
  125. unsigned int offset, void *p_data, unsigned int bytes);
  126. int intel_gvt_i2c_handle_gmbus_write(struct intel_vgpu *vgpu,
  127. unsigned int offset, void *p_data, unsigned int bytes);
  128. void intel_gvt_i2c_handle_aux_ch_write(struct intel_vgpu *vgpu,
  129. int port_idx,
  130. unsigned int offset,
  131. void *p_data);
  132. #endif /*_GVT_EDID_H_*/