edid.h 4.1 KB

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