drm_edid.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. struct est_timings {
  29. u8 t1;
  30. u8 t2;
  31. u8 mfg_rsvd;
  32. } __attribute__((packed));
  33. /* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
  34. #define EDID_TIMING_ASPECT_SHIFT 6
  35. #define EDID_TIMING_ASPECT_MASK (0x3 << EDID_TIMING_ASPECT_SHIFT)
  36. /* need to add 60 */
  37. #define EDID_TIMING_VFREQ_SHIFT 0
  38. #define EDID_TIMING_VFREQ_MASK (0x3f << EDID_TIMING_VFREQ_SHIFT)
  39. struct std_timing {
  40. u8 hsize; /* need to multiply by 8 then add 248 */
  41. u8 vfreq_aspect;
  42. } __attribute__((packed));
  43. #define DRM_EDID_PT_HSYNC_POSITIVE (1 << 1)
  44. #define DRM_EDID_PT_VSYNC_POSITIVE (1 << 2)
  45. #define DRM_EDID_PT_SEPARATE_SYNC (3 << 3)
  46. #define DRM_EDID_PT_STEREO (1 << 5)
  47. #define DRM_EDID_PT_INTERLACED (1 << 7)
  48. /* If detailed data is pixel timing */
  49. struct detailed_pixel_timing {
  50. u8 hactive_lo;
  51. u8 hblank_lo;
  52. u8 hactive_hblank_hi;
  53. u8 vactive_lo;
  54. u8 vblank_lo;
  55. u8 vactive_vblank_hi;
  56. u8 hsync_offset_lo;
  57. u8 hsync_pulse_width_lo;
  58. u8 vsync_offset_pulse_width_lo;
  59. u8 hsync_vsync_offset_pulse_width_hi;
  60. u8 width_mm_lo;
  61. u8 height_mm_lo;
  62. u8 width_height_mm_hi;
  63. u8 hborder;
  64. u8 vborder;
  65. u8 misc;
  66. } __attribute__((packed));
  67. /* If it's not pixel timing, it'll be one of the below */
  68. struct detailed_data_string {
  69. u8 str[13];
  70. } __attribute__((packed));
  71. struct detailed_data_monitor_range {
  72. u8 min_vfreq;
  73. u8 max_vfreq;
  74. u8 min_hfreq_khz;
  75. u8 max_hfreq_khz;
  76. u8 pixel_clock_mhz; /* need to multiply by 10 */
  77. __le16 sec_gtf_toggle; /* A000=use above, 20=use below */
  78. u8 hfreq_start_khz; /* need to multiply by 2 */
  79. u8 c; /* need to divide by 2 */
  80. __le16 m;
  81. u8 k;
  82. u8 j; /* need to divide by 2 */
  83. } __attribute__((packed));
  84. struct detailed_data_wpindex {
  85. u8 white_yx_lo; /* Lower 2 bits each */
  86. u8 white_x_hi;
  87. u8 white_y_hi;
  88. u8 gamma; /* need to divide by 100 then add 1 */
  89. } __attribute__((packed));
  90. struct detailed_data_color_point {
  91. u8 windex1;
  92. u8 wpindex1[3];
  93. u8 windex2;
  94. u8 wpindex2[3];
  95. } __attribute__((packed));
  96. struct detailed_non_pixel {
  97. u8 pad1;
  98. u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name
  99. fb=color point data, fa=standard timing data,
  100. f9=undefined, f8=mfg. reserved */
  101. u8 pad2;
  102. union {
  103. struct detailed_data_string str;
  104. struct detailed_data_monitor_range range;
  105. struct detailed_data_wpindex color;
  106. struct std_timing timings[5];
  107. } data;
  108. } __attribute__((packed));
  109. #define EDID_DETAIL_STD_MODES 0xfa
  110. #define EDID_DETAIL_MONITOR_CPDATA 0xfb
  111. #define EDID_DETAIL_MONITOR_NAME 0xfc
  112. #define EDID_DETAIL_MONITOR_RANGE 0xfd
  113. #define EDID_DETAIL_MONITOR_STRING 0xfe
  114. #define EDID_DETAIL_MONITOR_SERIAL 0xff
  115. struct detailed_timing {
  116. __le16 pixel_clock; /* need to multiply by 10 KHz */
  117. union {
  118. struct detailed_pixel_timing pixel_data;
  119. struct detailed_non_pixel other_data;
  120. } data;
  121. } __attribute__((packed));
  122. #define DRM_EDID_INPUT_SERRATION_VSYNC (1 << 0)
  123. #define DRM_EDID_INPUT_SYNC_ON_GREEN (1 << 1)
  124. #define DRM_EDID_INPUT_COMPOSITE_SYNC (1 << 2)
  125. #define DRM_EDID_INPUT_SEPARATE_SYNCS (1 << 3)
  126. #define DRM_EDID_INPUT_BLANK_TO_BLACK (1 << 4)
  127. #define DRM_EDID_INPUT_VIDEO_LEVEL (3 << 5)
  128. #define DRM_EDID_INPUT_DIGITAL (1 << 7) /* bits below must be zero if set */
  129. #define DRM_EDID_FEATURE_DEFAULT_GTF (1 << 0)
  130. #define DRM_EDID_FEATURE_PREFERRED_TIMING (1 << 1)
  131. #define DRM_EDID_FEATURE_STANDARD_COLOR (1 << 2)
  132. #define DRM_EDID_FEATURE_DISPLAY_TYPE (3 << 3) /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */
  133. #define DRM_EDID_FEATURE_PM_ACTIVE_OFF (1 << 5)
  134. #define DRM_EDID_FEATURE_PM_SUSPEND (1 << 6)
  135. #define DRM_EDID_FEATURE_PM_STANDBY (1 << 7)
  136. struct edid {
  137. u8 header[8];
  138. /* Vendor & product info */
  139. u8 mfg_id[2];
  140. u8 prod_code[2];
  141. u32 serial; /* FIXME: byte order */
  142. u8 mfg_week;
  143. u8 mfg_year;
  144. /* EDID version */
  145. u8 version;
  146. u8 revision;
  147. /* Display info: */
  148. u8 input;
  149. u8 width_cm;
  150. u8 height_cm;
  151. u8 gamma;
  152. u8 features;
  153. /* Color characteristics */
  154. u8 red_green_lo;
  155. u8 black_white_lo;
  156. u8 red_x;
  157. u8 red_y;
  158. u8 green_x;
  159. u8 green_y;
  160. u8 blue_x;
  161. u8 blue_y;
  162. u8 white_x;
  163. u8 white_y;
  164. /* Est. timings and mfg rsvd timings*/
  165. struct est_timings established_timings;
  166. /* Standard timings 1-8*/
  167. struct std_timing standard_timings[8];
  168. /* Detailing timings 1-4 */
  169. struct detailed_timing detailed_timings[4];
  170. /* Number of 128 byte ext. blocks */
  171. u8 extensions;
  172. /* Checksum */
  173. u8 checksum;
  174. } __attribute__((packed));
  175. #define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8))
  176. #endif /* __DRM_EDID_H__ */