drm_edid.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Copyright © 2007-2008 Intel Corporation
  3. * Jesse Barnes <jesse.barnes@intel.com>
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  19. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  20. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. * OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #ifndef __DRM_EDID_H__
  24. #define __DRM_EDID_H__
  25. #include <linux/types.h>
  26. #define EDID_LENGTH 128
  27. #define DDC_ADDR 0x50
  28. #ifdef BIG_ENDIAN
  29. #error "EDID structure is little endian, need big endian versions"
  30. #else
  31. struct est_timings {
  32. u8 t1;
  33. u8 t2;
  34. u8 mfg_rsvd;
  35. } __attribute__((packed));
  36. struct std_timing {
  37. u8 hsize; /* need to multiply by 8 then add 248 */
  38. u8 vfreq:6; /* need to add 60 */
  39. u8 aspect_ratio:2; /* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
  40. } __attribute__((packed));
  41. /* If detailed data is pixel timing */
  42. struct detailed_pixel_timing {
  43. u8 hactive_lo;
  44. u8 hblank_lo;
  45. u8 hblank_hi:4;
  46. u8 hactive_hi:4;
  47. u8 vactive_lo;
  48. u8 vblank_lo;
  49. u8 vblank_hi:4;
  50. u8 vactive_hi:4;
  51. u8 hsync_offset_lo;
  52. u8 hsync_pulse_width_lo;
  53. u8 vsync_pulse_width_lo:4;
  54. u8 vsync_offset_lo:4;
  55. u8 vsync_pulse_width_hi:2;
  56. u8 vsync_offset_hi:2;
  57. u8 hsync_pulse_width_hi:2;
  58. u8 hsync_offset_hi:2;
  59. u8 width_mm_lo;
  60. u8 height_mm_lo;
  61. u8 height_mm_hi:4;
  62. u8 width_mm_hi:4;
  63. u8 hborder;
  64. u8 vborder;
  65. u8 unknown0:1;
  66. u8 hsync_positive:1;
  67. u8 vsync_positive:1;
  68. u8 separate_sync:2;
  69. u8 stereo:1;
  70. u8 unknown6:1;
  71. u8 interlaced:1;
  72. } __attribute__((packed));
  73. /* If it's not pixel timing, it'll be one of the below */
  74. struct detailed_data_string {
  75. u8 str[13];
  76. } __attribute__((packed));
  77. struct detailed_data_monitor_range {
  78. u8 min_vfreq;
  79. u8 max_vfreq;
  80. u8 min_hfreq_khz;
  81. u8 max_hfreq_khz;
  82. u8 pixel_clock_mhz; /* need to multiply by 10 */
  83. u16 sec_gtf_toggle; /* A000=use above, 20=use below */ /* FIXME: byte order */
  84. u8 hfreq_start_khz; /* need to multiply by 2 */
  85. u8 c; /* need to divide by 2 */
  86. u16 m; /* FIXME: byte order */
  87. u8 k;
  88. u8 j; /* need to divide by 2 */
  89. } __attribute__((packed));
  90. struct detailed_data_wpindex {
  91. u8 white_y_lo:2;
  92. u8 white_x_lo:2;
  93. u8 pad:4;
  94. u8 white_x_hi;
  95. u8 white_y_hi;
  96. u8 gamma; /* need to divide by 100 then add 1 */
  97. } __attribute__((packed));
  98. struct detailed_data_color_point {
  99. u8 windex1;
  100. u8 wpindex1[3];
  101. u8 windex2;
  102. u8 wpindex2[3];
  103. } __attribute__((packed));
  104. struct detailed_non_pixel {
  105. u8 pad1;
  106. u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name
  107. fb=color point data, fa=standard timing data,
  108. f9=undefined, f8=mfg. reserved */
  109. u8 pad2;
  110. union {
  111. struct detailed_data_string str;
  112. struct detailed_data_monitor_range range;
  113. struct detailed_data_wpindex color;
  114. struct std_timing timings[5];
  115. } data;
  116. } __attribute__((packed));
  117. #define EDID_DETAIL_STD_MODES 0xfa
  118. #define EDID_DETAIL_MONITOR_CPDATA 0xfb
  119. #define EDID_DETAIL_MONITOR_NAME 0xfc
  120. #define EDID_DETAIL_MONITOR_RANGE 0xfd
  121. #define EDID_DETAIL_MONITOR_STRING 0xfe
  122. #define EDID_DETAIL_MONITOR_SERIAL 0xff
  123. struct detailed_timing {
  124. u16 pixel_clock; /* need to multiply by 10 KHz */ /* FIXME: byte order */
  125. union {
  126. struct detailed_pixel_timing pixel_data;
  127. struct detailed_non_pixel other_data;
  128. } data;
  129. } __attribute__((packed));
  130. struct edid {
  131. u8 header[8];
  132. /* Vendor & product info */
  133. u8 mfg_id[2];
  134. u8 prod_code[2];
  135. u32 serial; /* FIXME: byte order */
  136. u8 mfg_week;
  137. u8 mfg_year;
  138. /* EDID version */
  139. u8 version;
  140. u8 revision;
  141. /* Display info: */
  142. /* input definition */
  143. u8 serration_vsync:1;
  144. u8 sync_on_green:1;
  145. u8 composite_sync:1;
  146. u8 separate_syncs:1;
  147. u8 blank_to_black:1;
  148. u8 video_level:2;
  149. u8 digital:1; /* bits below must be zero if set */
  150. u8 width_cm;
  151. u8 height_cm;
  152. u8 gamma;
  153. /* feature support */
  154. u8 default_gtf:1;
  155. u8 preferred_timing:1;
  156. u8 standard_color:1;
  157. u8 display_type:2; /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */
  158. u8 pm_active_off:1;
  159. u8 pm_suspend:1;
  160. u8 pm_standby:1;
  161. /* Color characteristics */
  162. u8 red_green_lo;
  163. u8 black_white_lo;
  164. u8 red_x;
  165. u8 red_y;
  166. u8 green_x;
  167. u8 green_y;
  168. u8 blue_x;
  169. u8 blue_y;
  170. u8 white_x;
  171. u8 white_y;
  172. /* Est. timings and mfg rsvd timings*/
  173. struct est_timings established_timings;
  174. /* Standard timings 1-8*/
  175. struct std_timing standard_timings[8];
  176. /* Detailing timings 1-4 */
  177. struct detailed_timing detailed_timings[4];
  178. /* Number of 128 byte ext. blocks */
  179. u8 extensions;
  180. /* Checksum */
  181. u8 checksum;
  182. } __attribute__((packed));
  183. #endif /* little endian structs */
  184. #define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8))
  185. #endif /* __DRM_EDID_H__ */