VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.3.0.0/edid.h@ 78406

Last change on this file since 78406 was 25078, checked in by vboxsync, 15 years ago

Additions/x11/x11include: exported and set eol-style on new headers

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette