OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / prebuilt / linux-x86 / toolchain / i686-unknown-linux-gnu-4.2.1 / lib / gcc / i686-unknown-linux-gnu / 4.2.1 / include / xorg / edid.h
1 /*  DO NOT EDIT THIS FILE.
2
3     It has been auto-edited by fixincludes from:
4
5         "/usr/include/xorg/edid.h"
6
7     This had to be done to correct non-standard usages in the
8     original, manufacturer supplied header file.  */
9
10 /* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/edid.h,v 1.6 2000/04/17 16:29:55 eich Exp $ */
11
12 /* edid.h: defines to parse an EDID block 
13  *
14  * This file contains all information to interpret a standard EDIC block 
15  * transmitted by a display device via DDC (Display Data Channel). So far 
16  * there is no information to deal with optional EDID blocks.  
17  * DDC is a Trademark of VESA (Video Electronics Standard Association).
18  *
19  * Copyright 1998 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE>
20  */
21
22 #ifndef _EDID_H_
23 #define _EDID_H_ 
24
25 #include "vdif.h"
26
27 /* read complete EDID record */
28 #define EDID1_LEN 128
29 #define BITS_PER_BYTE 9
30 #define NUM BITS_PER_BYTE*EDID1_LEN
31 #define HEADER 6
32
33 #define STD_TIMINGS 8
34 #define DET_TIMINGS 4
35
36 #ifdef _PARSE_EDID_
37
38 /* header: 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x00  */
39 #define HEADER_SECTION 0
40 #define HEADER_LENGTH 8
41
42 /* vendor section */
43 #define VENDOR_SECTION (HEADER_SECTION + HEADER_LENGTH)
44 #define V_MANUFACTURER 0
45 #define V_PROD_ID (V_MANUFACTURER + 2)
46 #define V_SERIAL (V_PROD_ID + 2)
47 #define V_WEEK (V_SERIAL + 4)
48 #define V_YEAR (V_WEEK + 1)
49 #define VENDOR_LENGTH (V_YEAR + 1)
50
51 /* EDID version */
52 #define VERSION_SECTION (VENDOR_SECTION + VENDOR_LENGTH)
53 #define V_VERSION 0
54 #define V_REVISION (V_VERSION + 1)
55 #define VERSION_LENGTH (V_REVISION + 1)
56
57 /* display information */
58 #define DISPLAY_SECTION (VERSION_SECTION + VERSION_LENGTH)
59 #define D_INPUT 0
60 #define D_HSIZE (D_INPUT + 1)
61 #define D_VSIZE (D_HSIZE + 1)
62 #define D_GAMMA (D_VSIZE + 1)
63 #define FEAT_S (D_GAMMA + 1)
64 #define D_RG_LOW (FEAT_S + 1)
65 #define D_BW_LOW (D_RG_LOW + 1)
66 #define D_REDX (D_BW_LOW + 1)
67 #define D_REDY (D_REDX + 1)
68 #define D_GREENX (D_REDY + 1)
69 #define D_GREENY (D_GREENX + 1)
70 #define D_BLUEX (D_GREENY + 1)
71 #define D_BLUEY (D_BLUEX + 1)
72 #define D_WHITEX (D_BLUEY + 1)
73 #define D_WHITEY (D_WHITEX + 1)
74 #define DISPLAY_LENGTH (D_WHITEY + 1)
75
76 /* supported VESA and other standard timings */
77 #define ESTABLISHED_TIMING_SECTION (DISPLAY_SECTION + DISPLAY_LENGTH)
78 #define E_T1 0
79 #define E_T2 (E_T1 + 1)
80 #define E_TMANU (E_T2 + 1)
81 #define E_TIMING_LENGTH (E_TMANU + 1) 
82
83 /* non predefined standard timings supported by display */
84 #define STD_TIMING_SECTION (ESTABLISHED_TIMING_SECTION + E_TIMING_LENGTH)
85 #define STD_TIMING_INFO_LEN 2
86 #define STD_TIMING_INFO_NUM STD_TIMINGS
87 #define STD_TIMING_LENGTH (STD_TIMING_INFO_LEN * STD_TIMING_INFO_NUM)
88
89 /* detailed timing info of non standard timings */
90 #define DET_TIMING_SECTION (STD_TIMING_SECTION + STD_TIMING_LENGTH)
91 #define DET_TIMING_INFO_LEN 18
92 #define MONITOR_DESC_LEN DET_TIMING_INFO_LEN
93 #define DET_TIMING_INFO_NUM DET_TIMINGS
94 #define DET_TIMING_LENGTH (DET_TIMING_INFO_LEN * DET_TIMING_INFO_NUM)
95
96 /* number of EDID sections to follow */
97 #define NO_EDID (DET_TIMING_SECTION + DET_TIMING_LENGTH)
98 /* one byte checksum */
99 #define CHECKSUM (NO_EDID + 1)  
100
101 #if (CHECKSUM != (EDID1_LEN - 1))
102 # error "EDID1 length != 128!" 
103 #endif
104
105
106 #define SECTION(x,y) (Uchar *)(x + y)
107 #define GET_ARRAY(y) ((Uchar *)(c + y))
108 #define GET(y) *(Uchar *)(c + y)
109
110 /* extract information from vendor section */
111 #define _PROD_ID(x) x[0] + (x[1] << 8);
112 #define PROD_ID _PROD_ID(GET_ARRAY(V_PROD_ID))
113 #define _SERIAL_NO(x) x[0] + (x[1] << 8) + (x[2] << 16) + (x[3] << 24)
114 #define SERIAL_NO _SERIAL_NO(GET_ARRAY(V_SERIAL))
115 #define _YEAR(x) (x & 0xFF) + 1990
116 #define YEAR _YEAR(GET(V_YEAR))
117 #define WEEK GET(V_WEEK) & 0xFF
118 #define _L1(x) ((x[0] & 0x7C) >> 2) + '@'
119 #define _L2(x) ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'
120 #define _L3(x) (x[1] & 0x1F) + '@';
121 #define L1 _L1(GET_ARRAY(V_MANUFACTURER))
122 #define L2 _L2(GET_ARRAY(V_MANUFACTURER))
123 #define L3 _L3(GET_ARRAY(V_MANUFACTURER))
124
125 /* extract information from version section */
126 #define VERSION GET(V_VERSION)
127 #define REVISION GET(V_REVISION)
128
129 /* extract information from display section */
130 #define _INPUT_TYPE(x) ((x & 0x80) >> 7)
131 #define INPUT_TYPE _INPUT_TYPE(GET(D_INPUT))
132 #define _INPUT_VOLTAGE(x) ((x & 0x60) >> 5)
133 #define INPUT_VOLTAGE _INPUT_VOLTAGE(GET(D_INPUT))
134 #define _SETUP(x) ((x & 0x10) >> 4)
135 #define SETUP _SETUP(GET(D_INPUT))
136 #define _SYNC(x) (x  & 0x0F)
137 #define SYNC _SYNC(GET(D_INPUT))
138 #define _DFP(x) (x & 0x01)
139 #define DFP _DFP(GET(D_INPUT))
140 #define _GAMMA(x) (x == 0xff ? 1.0 : ((x + 100.0)/100.0))
141 #define GAMMA _GAMMA(GET(D_GAMMA))
142 #define HSIZE_MAX GET(D_HSIZE)
143 #define VSIZE_MAX GET(D_VSIZE)
144 #define _DPMS(x) ((x & 0xE0) >> 5)
145 #define DPMS _DPMS(GET(FEAT_S))
146 #define _DISPLAY_TYPE(x) ((x & 0x18) >> 3)
147 #define DISPLAY_TYPE _DISPLAY_TYPE(GET(FEAT_S))
148 #define _MSC(x) (x & 0x7)
149 #define MSC _MSC(GET(FEAT_S))
150
151
152 /* color characteristics */
153 #define CC_L(x,y) ((x & (0x03 << y)) >> y)
154 #define CC_H(x) (x << 2)
155 #define I_CC(x,y,z) CC_H(y) | CC_L(x,z)
156 #define F_CC(x) ((x)/1024.0)
157 #define REDX F_CC(I_CC((GET(D_RG_LOW)),(GET(D_REDX)),6))
158 #define REDY F_CC(I_CC((GET(D_RG_LOW)),(GET(D_REDY)),4))
159 #define GREENX F_CC(I_CC((GET(D_RG_LOW)),(GET(D_GREENX)),2))
160 #define GREENY F_CC(I_CC((GET(D_RG_LOW)),(GET(D_GREENY)),0))
161 #define BLUEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_BLUEX)),6))
162 #define BLUEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_BLUEY)),4))
163 #define WHITEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEX)),2))
164 #define WHITEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEY)),0))
165
166 /* extract information from standard timing section */
167 #define T1 GET(E_T1)
168 #define T2 GET(E_T2)
169 #define T_MANU GET(E_TMANU)
170
171 /* extract information from estabished timing section */
172 #define _VALID_TIMING(x) !(((x[0] == 0x01) && (x[1] == 0x01)) \
173                         || ((x[0] == 0x00) && (x[1] == 0x00)) \
174                         || ((x[0] == 0x20) && (x[1] == 0x20)) )
175 #define VALID_TIMING _VALID_TIMING(c)
176 #define _HSIZE1(x) ((x[0] + 31) * 8)
177 #define HSIZE1 _HSIZE1(c)
178 #define RATIO(x) ((x[1] & 0xC0) >> 6)
179 #define RATIO1_1 0
180 /* EDID Ver. 1.3 redefined this */
181 #define RATIO16_10 RATIO1_1
182 #define RATIO4_3 1
183 #define RATIO5_4 2
184 #define RATIO16_9 3
185 #define _VSIZE1(x,y,r) switch(RATIO(x)){ \
186   case RATIO1_1: y =  ((v->version > 1 || v->revision > 2) \
187                        ? (_HSIZE1(x) * 10) / 16 : _HSIZE1(x)); break; \
188   case RATIO4_3: y = _HSIZE1(x) * 3 / 4; break; \
189   case RATIO5_4: y = _HSIZE1(x) * 4 / 5; break; \
190   case RATIO16_9: y = _HSIZE1(x) * 9 / 16; break; \
191   }
192 #define VSIZE1(x) _VSIZE1(c,x,v)
193 #define _REFRESH_R(x) (x[1] & 0x3F) + 60
194 #define REFRESH_R  _REFRESH_R(c)
195 #define _ID_LOW(x) x[0]
196 #define ID_LOW _ID_LOW(c)
197 #define _ID_HIGH(x) (x[1] << 8)
198 #define ID_HIGH _ID_HIGH(c)
199 #define STD_TIMING_ID (ID_LOW | ID_HIGH)
200 #define _NEXT_STD_TIMING(x)  (x = (x + STD_TIMING_INFO_LEN))
201 #define NEXT_STD_TIMING _NEXT_STD_TIMING(c)
202
203
204 /* EDID Ver. >= 1.2 */
205 #define _IS_MONITOR_DESC(x) (x[0] == 0 && x[1] == 0 && x[2] == 0 && x[4] == 0)
206 #define IS_MONITOR_DESC _IS_MONITOR_DESC(c)
207 #define _PIXEL_CLOCK(x) (x[0] + (x[1] << 8)) * 10000
208 #define PIXEL_CLOCK _PIXEL_CLOCK(c)
209 #define _H_ACTIVE(x) (x[2] + ((x[4] & 0xF0) << 4))
210 #define H_ACTIVE _H_ACTIVE(c)
211 #define _H_BLANK(x) (x[3] + ((x[4] & 0x0F) << 8))
212 #define H_BLANK _H_BLANK(c)
213 #define _V_ACTIVE(x) (x[5] + ((x[7] & 0xF0) << 4))
214 #define V_ACTIVE _V_ACTIVE(c)
215 #define _V_BLANK(x) (x[6] + ((x[7] & 0x0F) << 8))
216 #define V_BLANK _V_BLANK(c)
217 #define _H_SYNC_OFF(x) (x[8] + ((x[11] & 0xC0) << 2))
218 #define H_SYNC_OFF _H_SYNC_OFF(c)
219 #define _H_SYNC_WIDTH(x) (x[9] + ((x[11] & 0x30) << 4))
220 #define H_SYNC_WIDTH _H_SYNC_WIDTH(c)
221 #define _V_SYNC_OFF(x) ((x[10] >> 4) + ((x[11] & 0x0C) << 2))
222 #define V_SYNC_OFF _V_SYNC_OFF(c)
223 #define _V_SYNC_WIDTH(x) ((x[10] & 0x0F) + ((x[11] & 0x03) << 4))
224 #define V_SYNC_WIDTH _V_SYNC_WIDTH(c)
225 #define _H_SIZE(x) (x[12] + ((x[14] & 0xF0) << 4))
226 #define H_SIZE _H_SIZE(c)
227 #define _V_SIZE(x) (x[13] + ((x[14] & 0x0F) << 8))
228 #define V_SIZE _V_SIZE(c)
229 #define _H_BORDER(x) (x[15])
230 #define H_BORDER _H_BORDER(c)
231 #define _V_BORDER(x) (x[16])
232 #define V_BORDER _V_BORDER(c)
233 #define _INTERLACED(x) ((x[17] & 0x80) >> 7)
234 #define INTERLACED _INTERLACED(c)
235 #define _STEREO(x) ((x[17] & 0x60) >> 5)
236 #define STEREO _STEREO(c)
237 #define _STEREO1(x) (x[17] & 0x1)
238 #define STEREO1 _STEREO(c)
239 #define _SYNC_T(x) ((x[17] & 0x18) >> 4)
240 #define SYNC_T _SYNC_T(c)
241 #define _MISC(x) ((x[17] & 0x06) >> 2)
242 #define MISC _MISC(c)
243
244 #define _MONITOR_DESC_TYPE(x) x[3]
245 #define MONITOR_DESC_TYPE _MONITOR_DESC_TYPE(c)
246 #define SERIAL_NUMBER 0xFF
247 #define ASCII_STR 0xFE
248 #define MONITOR_RANGES 0xFD
249 #define _MIN_V(x) x[5]
250 #define MIN_V _MIN_V(c) 
251 #define _MAX_V(x) x[6]
252 #define MAX_V _MAX_V(c) 
253 #define _MIN_H(x) x[7]
254 #define MIN_H _MIN_H(c) 
255 #define _MAX_H(x) x[8]
256 #define MAX_H _MAX_H(c) 
257 #define _MAX_CLOCK(x) x[9]
258 #define MAX_CLOCK _MAX_CLOCK(c) 
259 #define _HAVE_2ND_GTF(x) (x[10] == 0x02)
260 #define HAVE_2ND_GTF _HAVE_2ND_GTF(c)
261 #define _F_2ND_GTF(x) (x[12] * 2)
262 #define F_2ND_GTF _F_2ND_GTF(c)
263 #define _C_2ND_GTF(x) (x[13] / 2)
264 #define C_2ND_GTF _C_2ND_GTF(c)
265 #define _M_2ND_GTF(x) (x[14] + (x[15] << 8))
266 #define M_2ND_GTF _M_2ND_GTF(c)
267 #define _K_2ND_GTF(x) (x[16])
268 #define K_2ND_GTF _K_2ND_GTF(c)
269 #define _J_2ND_GTF(x) (x[17] / 2)
270 #define J_2ND_GTF _J_2ND_GTF(c)
271 #define MONITOR_NAME 0xFC
272 #define ADD_COLOR_POINT 0xFB
273 #define WHITEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEX)),2))
274 #define WHITEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEY)),0))
275 #define _WHITEX_ADD(x,y) F_CC(I_CC(((*(x + y))),(*(x + y + 1)),2))
276 #define _WHITEY_ADD(x,y) F_CC(I_CC(((*(x + y))),(*(x + y + 2)),0))
277 #define _WHITE_INDEX1(x) x[5]
278 #define WHITE_INDEX1 _WHITE_INDEX1(c)
279 #define _WHITE_INDEX2(x) x[10]
280 #define WHITE_INDEX2 _WHITE_INDEX2(c)
281 #define WHITEX1 _WHITEX_ADD(c,6)
282 #define WHITEY1 _WHITEY_ADD(c,6)
283 #define WHITEX2 _WHITEX_ADD(c,12)
284 #define WHITEY2 _WHITEY_ADD(c,12)
285 #define _WHITE_GAMMA1(x) _GAMMA(x[9])
286 #define WHITE_GAMMA1 _WHITE_GAMMA1(c) 
287 #define _WHITE_GAMMA2(x) _GAMMA(x[14])
288 #define WHITE_GAMMA2 _WHITE_GAMMA2(c)
289 #define ADD_STD_TIMINGS 0xFA
290 #define ADD_DUMMY 0x10
291
292 #define _NEXT_DT_MD_SECTION(x) (x = (x + DET_TIMING_INFO_LEN))
293 #define NEXT_DT_MD_SECTION _NEXT_DT_MD_SECTION('c')
294
295 #endif /* _PARSE_EDID_ */
296
297 /* input type */
298 #define DIGITAL(x) x
299
300 /* DFP */
301 #define DFP1(x) x
302
303 /* input voltage level */
304 #define V070 0  /* 0.700V/0.300V */
305 #define V071 1  /* 0.714V/0.286V */
306 #define V100 2  /* 1.000V/0.400V */
307 #define V007 3 /* 0.700V/0.000V */
308
309 /* Signal level setup */
310 #define SIG_SETUP(x) (x)
311
312 /* sync characteristics */
313 #define SEP_SYNC(x) (x & 0x08)
314 #define COMP_SYNC(x) (x & 0x04)
315 #define SYNC_O_GREEN(x) (x & 0x02)
316 #define SYNC_SERR(x) (x & 0x01)
317
318 /* DPMS features */
319 #define DPMS_STANDBY(x) (x & 0x04)
320 #define DPMS_SUSPEND(x) (x & 0x02)
321 #define DPMS_OFF(x) (x & 0x01)
322
323 /* display type */
324 #define DISP_MONO 0
325 #define DISP_RGB 1
326 #define DISP_MULTCOLOR 2
327
328 /* Msc stuff EDID Ver > 1.1 */
329 #define STD_COLOR_SPACE(x) (x & 0x4)
330 #define PREFERRED_TIMING_MODE(x) (x & 0x2)
331 #define GFT_SUPPORTED(x) (x & 0x1)
332
333 /* detailed timing misc */
334 #define IS_INTERLACED(x)  (x) 
335 #define IS_STEREO(x)  (x) 
336 #define IS_RIGHT_STEREO(x) (x & 0x01)
337 #define IS_LEFT_STEREO(x) (x & 0x02)
338 #define IS_4WAY_STEREO(x) (x & 0x03)
339 #define IS_RIGHT_ON_SYNC(x) IS_RIGHT_STEREO(x)
340 #define IS_LEFT_ON_SYNC(x) IS_LEFT_STEREO(x)
341
342
343 typedef unsigned int Uint;
344 typedef unsigned char Uchar;
345
346 struct vendor {
347   char name[4];
348   int prod_id;
349   Uint serial;
350   int week;
351   int year;
352 };
353
354 struct edid_version {
355   int version;
356   int revision;
357 };
358
359 struct disp_features {
360   unsigned int input_type:1;
361   unsigned int input_voltage:2;
362   unsigned int input_setup:1;
363   unsigned int input_sync:5;
364   unsigned int input_dfp:1;
365   int hsize;
366   int vsize;
367   float gamma;
368   unsigned int dpms:3;
369   unsigned int display_type:2;
370   unsigned int msc:3;
371   float redx;
372   float redy;
373   float greenx;
374   float greeny;
375   float bluex;
376   float bluey;
377   float whitex;
378   float whitey;
379 };
380
381 struct established_timings {
382   Uchar t1;
383   Uchar t2;
384   Uchar t_manu;
385 };
386
387 struct std_timings {
388   int hsize;
389   int vsize;
390   int refresh;
391   CARD16 id;
392 };
393
394 struct detailed_timings {
395   int clock;
396   int h_active;
397   int h_blanking;
398   int v_active;
399   int v_blanking;
400   int h_sync_off;
401   int h_sync_width;
402   int v_sync_off;
403   int v_sync_width;
404   int h_size;
405   int v_size;
406   int h_border;
407   int v_border;
408   unsigned int interlaced:1;
409   unsigned int stereo:2;
410   unsigned int sync:2;
411   unsigned int misc:2;
412   unsigned int stereo_1:1;
413 };
414
415 #define DT 0
416 #define DS_SERIAL 0xFF
417 #define DS_ASCII_STR 0xFE
418 #define DS_NAME 0xFC
419 #define DS_RANGES 0xFD
420 #define DS_WHITE_P 0xFB
421 #define DS_STD_TIMINGS 0xFA
422 #define DS_DUMMY 0x10
423
424 struct monitor_ranges {
425   int min_v;
426   int max_v;
427   int min_h;
428   int max_h;
429   int max_clock;
430   int gtf_2nd_f;
431   int gtf_2nd_c;
432   int gtf_2nd_m;
433   int gtf_2nd_k;
434   int gtf_2nd_j;
435 };
436
437 struct whitePoints{
438   int   index;
439   float white_x;
440   float white_y;
441   float white_gamma;
442 };
443
444 struct detailed_monitor_section {
445   int type;
446   union {
447     struct detailed_timings d_timings;
448     Uchar serial[13];
449     Uchar ascii_data[13];
450     Uchar name[13];
451     struct monitor_ranges ranges;
452     struct std_timings std_t[5];
453     struct whitePoints wp[2];
454   } section;
455 };
456
457 typedef struct {
458   int scrnIndex;
459   struct vendor vendor;
460   struct edid_version ver;
461   struct disp_features features;
462   struct established_timings timings1;
463   struct std_timings timings2[8];
464   struct detailed_monitor_section det_mon[4];
465   xf86vdifPtr vdif;
466   int no_sections;
467   Uchar *rawData;
468 } xf86Monitor, *xf86MonPtr;
469
470 extern xf86MonPtr ConfiguredMonitor;
471
472 #endif /* _EDID_H_ */