1
/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/edid.h,v 1.6 2000/04/17 16:29:55 eich Exp $ */
3
/* edid.h: defines to parse an EDID block
5
* This file contains all information to interpret a standard EDIC block
6
* transmitted by a display device via DDC (Display Data Channel). So far
7
* there is no information to deal with optional EDID blocks.
8
* DDC is a Trademark of VESA (Video Electronics Standard Association).
10
* Copyright 1998 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE>
18
/* read complete EDID record */
20
#define BITS_PER_BYTE 9
21
#define NUM BITS_PER_BYTE*EDID1_LEN
29
/* header: 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x00 */
30
#define HEADER_SECTION 0
31
#define HEADER_LENGTH 8
34
#define VENDOR_SECTION (HEADER_SECTION + HEADER_LENGTH)
35
#define V_MANUFACTURER 0
36
#define V_PROD_ID (V_MANUFACTURER + 2)
37
#define V_SERIAL (V_PROD_ID + 2)
38
#define V_WEEK (V_SERIAL + 4)
39
#define V_YEAR (V_WEEK + 1)
40
#define VENDOR_LENGTH (V_YEAR + 1)
43
#define VERSION_SECTION (VENDOR_SECTION + VENDOR_LENGTH)
45
#define V_REVISION (V_VERSION + 1)
46
#define VERSION_LENGTH (V_REVISION + 1)
48
/* display information */
49
#define DISPLAY_SECTION (VERSION_SECTION + VERSION_LENGTH)
51
#define D_HSIZE (D_INPUT + 1)
52
#define D_VSIZE (D_HSIZE + 1)
53
#define D_GAMMA (D_VSIZE + 1)
54
#define FEAT_S (D_GAMMA + 1)
55
#define D_RG_LOW (FEAT_S + 1)
56
#define D_BW_LOW (D_RG_LOW + 1)
57
#define D_REDX (D_BW_LOW + 1)
58
#define D_REDY (D_REDX + 1)
59
#define D_GREENX (D_REDY + 1)
60
#define D_GREENY (D_GREENX + 1)
61
#define D_BLUEX (D_GREENY + 1)
62
#define D_BLUEY (D_BLUEX + 1)
63
#define D_WHITEX (D_BLUEY + 1)
64
#define D_WHITEY (D_WHITEX + 1)
65
#define DISPLAY_LENGTH (D_WHITEY + 1)
67
/* supported VESA and other standard timings */
68
#define ESTABLISHED_TIMING_SECTION (DISPLAY_SECTION + DISPLAY_LENGTH)
70
#define E_T2 (E_T1 + 1)
71
#define E_TMANU (E_T2 + 1)
72
#define E_TIMING_LENGTH (E_TMANU + 1)
74
/* non predefined standard timings supported by display */
75
#define STD_TIMING_SECTION (ESTABLISHED_TIMING_SECTION + E_TIMING_LENGTH)
76
#define STD_TIMING_INFO_LEN 2
77
#define STD_TIMING_INFO_NUM STD_TIMINGS
78
#define STD_TIMING_LENGTH (STD_TIMING_INFO_LEN * STD_TIMING_INFO_NUM)
80
/* detailed timing info of non standard timings */
81
#define DET_TIMING_SECTION (STD_TIMING_SECTION + STD_TIMING_LENGTH)
82
#define DET_TIMING_INFO_LEN 18
83
#define MONITOR_DESC_LEN DET_TIMING_INFO_LEN
84
#define DET_TIMING_INFO_NUM DET_TIMINGS
85
#define DET_TIMING_LENGTH (DET_TIMING_INFO_LEN * DET_TIMING_INFO_NUM)
87
/* number of EDID sections to follow */
88
#define NO_EDID (DET_TIMING_SECTION + DET_TIMING_LENGTH)
89
/* one byte checksum */
90
#define CHECKSUM (NO_EDID + 1)
92
#if (CHECKSUM != (EDID1_LEN - 1))
93
# error "EDID1 length != 128!"
97
#define SECTION(x,y) (Uchar *)(x + y)
98
#define GET_ARRAY(y) ((Uchar *)(c + y))
99
#define GET(y) *(Uchar *)(c + y)
101
/* extract information from vendor section */
102
#define _PROD_ID(x) x[0] + (x[1] << 8);
103
#define PROD_ID _PROD_ID(GET_ARRAY(V_PROD_ID))
104
#define _SERIAL_NO(x) x[0] + (x[1] << 8) + (x[2] << 16) + (x[3] << 24)
105
#define SERIAL_NO _SERIAL_NO(GET_ARRAY(V_SERIAL))
106
#define _YEAR(x) (x & 0xFF) + 1990
107
#define YEAR _YEAR(GET(V_YEAR))
108
#define WEEK GET(V_WEEK) & 0xFF
109
#define _L1(x) ((x[0] & 0x7C) >> 2) + '@'
110
#define _L2(x) ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'
111
#define _L3(x) (x[1] & 0x1F) + '@';
112
#define L1 _L1(GET_ARRAY(V_MANUFACTURER))
113
#define L2 _L2(GET_ARRAY(V_MANUFACTURER))
114
#define L3 _L3(GET_ARRAY(V_MANUFACTURER))
116
/* extract information from version section */
117
#define VERSION GET(V_VERSION)
118
#define REVISION GET(V_REVISION)
120
/* extract information from display section */
121
#define _INPUT_TYPE(x) ((x & 0x80) >> 7)
122
#define INPUT_TYPE _INPUT_TYPE(GET(D_INPUT))
123
#define _INPUT_VOLTAGE(x) ((x & 0x60) >> 5)
124
#define INPUT_VOLTAGE _INPUT_VOLTAGE(GET(D_INPUT))
125
#define _SETUP(x) ((x & 0x10) >> 4)
126
#define SETUP _SETUP(GET(D_INPUT))
127
#define _SYNC(x) (x & 0x0F)
128
#define SYNC _SYNC(GET(D_INPUT))
129
#define _DFP(x) (x & 0x01)
130
#define DFP _DFP(GET(D_INPUT))
131
#define _GAMMA(x) (x == 0xff ? 1.0 : ((x + 100.0)/100.0))
132
#define GAMMA _GAMMA(GET(D_GAMMA))
133
#define HSIZE_MAX GET(D_HSIZE)
134
#define VSIZE_MAX GET(D_VSIZE)
135
#define _DPMS(x) ((x & 0xE0) >> 5)
136
#define DPMS _DPMS(GET(FEAT_S))
137
#define _DISPLAY_TYPE(x) ((x & 0x18) >> 3)
138
#define DISPLAY_TYPE _DISPLAY_TYPE(GET(FEAT_S))
139
#define _MSC(x) (x & 0x7)
140
#define MSC _MSC(GET(FEAT_S))
143
/* color characteristics */
144
#define CC_L(x,y) ((x & (0x03 << y)) >> y)
145
#define CC_H(x) (x << 2)
146
#define I_CC(x,y,z) CC_H(y) | CC_L(x,z)
147
#define F_CC(x) ((x)/1024.0)
148
#define REDX F_CC(I_CC((GET(D_RG_LOW)),(GET(D_REDX)),6))
149
#define REDY F_CC(I_CC((GET(D_RG_LOW)),(GET(D_REDY)),4))
150
#define GREENX F_CC(I_CC((GET(D_RG_LOW)),(GET(D_GREENX)),2))
151
#define GREENY F_CC(I_CC((GET(D_RG_LOW)),(GET(D_GREENY)),0))
152
#define BLUEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_BLUEX)),6))
153
#define BLUEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_BLUEY)),4))
154
#define WHITEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEX)),2))
155
#define WHITEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEY)),0))
157
/* extract information from standard timing section */
160
#define T_MANU GET(E_TMANU)
162
/* extract information from estabished timing section */
163
#define _VALID_TIMING(x) !(((x[0] == 0x01) && (x[1] == 0x01)) \
164
|| ((x[0] == 0x00) && (x[1] == 0x00)) \
165
|| ((x[0] == 0x20) && (x[1] == 0x20)) )
166
#define VALID_TIMING _VALID_TIMING(c)
167
#define _HSIZE1(x) ((x[0] + 31) * 8)
168
#define HSIZE1 _HSIZE1(c)
169
#define RATIO(x) ((x[1] & 0xC0) >> 6)
171
/* EDID Ver. 1.3 redefined this */
172
#define RATIO16_10 RATIO1_1
176
#define _VSIZE1(x,y,r) switch(RATIO(x)){ \
177
case RATIO1_1: y = ((v->version > 1 || v->revision > 2) \
178
? (_HSIZE1(x) * 10) / 16 : _HSIZE1(x)); break; \
179
case RATIO4_3: y = _HSIZE1(x) * 3 / 4; break; \
180
case RATIO5_4: y = _HSIZE1(x) * 4 / 5; break; \
181
case RATIO16_9: y = _HSIZE1(x) * 9 / 16; break; \
183
#define VSIZE1(x) _VSIZE1(c,x,v)
184
#define _REFRESH_R(x) (x[1] & 0x3F) + 60
185
#define REFRESH_R _REFRESH_R(c)
186
#define _ID_LOW(x) x[0]
187
#define ID_LOW _ID_LOW(c)
188
#define _ID_HIGH(x) (x[1] << 8)
189
#define ID_HIGH _ID_HIGH(c)
190
#define STD_TIMING_ID (ID_LOW | ID_HIGH)
191
#define _NEXT_STD_TIMING(x) (x = (x + STD_TIMING_INFO_LEN))
192
#define NEXT_STD_TIMING _NEXT_STD_TIMING(c)
195
/* EDID Ver. >= 1.2 */
196
#define _IS_MONITOR_DESC(x) (x[0] == 0 && x[1] == 0 && x[2] == 0 && x[4] == 0)
197
#define IS_MONITOR_DESC _IS_MONITOR_DESC(c)
198
#define _PIXEL_CLOCK(x) (x[0] + (x[1] << 8)) * 10000
199
#define PIXEL_CLOCK _PIXEL_CLOCK(c)
200
#define _H_ACTIVE(x) (x[2] + ((x[4] & 0xF0) << 4))
201
#define H_ACTIVE _H_ACTIVE(c)
202
#define _H_BLANK(x) (x[3] + ((x[4] & 0x0F) << 8))
203
#define H_BLANK _H_BLANK(c)
204
#define _V_ACTIVE(x) (x[5] + ((x[7] & 0xF0) << 4))
205
#define V_ACTIVE _V_ACTIVE(c)
206
#define _V_BLANK(x) (x[6] + ((x[7] & 0x0F) << 8))
207
#define V_BLANK _V_BLANK(c)
208
#define _H_SYNC_OFF(x) (x[8] + ((x[11] & 0xC0) << 2))
209
#define H_SYNC_OFF _H_SYNC_OFF(c)
210
#define _H_SYNC_WIDTH(x) (x[9] + ((x[11] & 0x30) << 4))
211
#define H_SYNC_WIDTH _H_SYNC_WIDTH(c)
212
#define _V_SYNC_OFF(x) ((x[10] >> 4) + ((x[11] & 0x0C) << 2))
213
#define V_SYNC_OFF _V_SYNC_OFF(c)
214
#define _V_SYNC_WIDTH(x) ((x[10] & 0x0F) + ((x[11] & 0x03) << 4))
215
#define V_SYNC_WIDTH _V_SYNC_WIDTH(c)
216
#define _H_SIZE(x) (x[12] + ((x[14] & 0xF0) << 4))
217
#define H_SIZE _H_SIZE(c)
218
#define _V_SIZE(x) (x[13] + ((x[14] & 0x0F) << 8))
219
#define V_SIZE _V_SIZE(c)
220
#define _H_BORDER(x) (x[15])
221
#define H_BORDER _H_BORDER(c)
222
#define _V_BORDER(x) (x[16])
223
#define V_BORDER _V_BORDER(c)
224
#define _INTERLACED(x) ((x[17] & 0x80) >> 7)
225
#define INTERLACED _INTERLACED(c)
226
#define _STEREO(x) ((x[17] & 0x60) >> 5)
227
#define STEREO _STEREO(c)
228
#define _STEREO1(x) (x[17] & 0x1)
229
#define STEREO1 _STEREO(c)
230
#define _SYNC_T(x) ((x[17] & 0x18) >> 4)
231
#define SYNC_T _SYNC_T(c)
232
#define _MISC(x) ((x[17] & 0x06) >> 2)
233
#define MISC _MISC(c)
235
#define _MONITOR_DESC_TYPE(x) x[3]
236
#define MONITOR_DESC_TYPE _MONITOR_DESC_TYPE(c)
237
#define SERIAL_NUMBER 0xFF
238
#define ASCII_STR 0xFE
239
#define MONITOR_RANGES 0xFD
240
#define _MIN_V(x) x[5]
241
#define MIN_V _MIN_V(c)
242
#define _MAX_V(x) x[6]
243
#define MAX_V _MAX_V(c)
244
#define _MIN_H(x) x[7]
245
#define MIN_H _MIN_H(c)
246
#define _MAX_H(x) x[8]
247
#define MAX_H _MAX_H(c)
248
#define _MAX_CLOCK(x) x[9]
249
#define MAX_CLOCK _MAX_CLOCK(c)
250
#define _HAVE_2ND_GTF(x) (x[10] == 0x02)
251
#define HAVE_2ND_GTF _HAVE_2ND_GTF(c)
252
#define _F_2ND_GTF(x) (x[12] * 2)
253
#define F_2ND_GTF _F_2ND_GTF(c)
254
#define _C_2ND_GTF(x) (x[13] / 2)
255
#define C_2ND_GTF _C_2ND_GTF(c)
256
#define _M_2ND_GTF(x) (x[14] + (x[15] << 8))
257
#define M_2ND_GTF _M_2ND_GTF(c)
258
#define _K_2ND_GTF(x) (x[16])
259
#define K_2ND_GTF _K_2ND_GTF(c)
260
#define _J_2ND_GTF(x) (x[17] / 2)
261
#define J_2ND_GTF _J_2ND_GTF(c)
262
#define MONITOR_NAME 0xFC
263
#define ADD_COLOR_POINT 0xFB
264
#define WHITEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEX)),2))
265
#define WHITEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEY)),0))
266
#define _WHITEX_ADD(x,y) F_CC(I_CC(((*(x + y))),(*(x + y + 1)),2))
267
#define _WHITEY_ADD(x,y) F_CC(I_CC(((*(x + y))),(*(x + y + 2)),0))
268
#define _WHITE_INDEX1(x) x[5]
269
#define WHITE_INDEX1 _WHITE_INDEX1(c)
270
#define _WHITE_INDEX2(x) x[10]
271
#define WHITE_INDEX2 _WHITE_INDEX2(c)
272
#define WHITEX1 _WHITEX_ADD(c,6)
273
#define WHITEY1 _WHITEY_ADD(c,6)
274
#define WHITEX2 _WHITEX_ADD(c,12)
275
#define WHITEY2 _WHITEY_ADD(c,12)
276
#define _WHITE_GAMMA1(x) _GAMMA(x[9])
277
#define WHITE_GAMMA1 _WHITE_GAMMA1(c)
278
#define _WHITE_GAMMA2(x) _GAMMA(x[14])
279
#define WHITE_GAMMA2 _WHITE_GAMMA2(c)
280
#define ADD_STD_TIMINGS 0xFA
281
#define ADD_DUMMY 0x10
283
#define _NEXT_DT_MD_SECTION(x) (x = (x + DET_TIMING_INFO_LEN))
284
#define NEXT_DT_MD_SECTION _NEXT_DT_MD_SECTION(c)
286
#endif /* _PARSE_EDID_ */
294
/* input voltage level */
295
#define V070 0 /* 0.700V/0.300V */
296
#define V071 1 /* 0.714V/0.286V */
297
#define V100 2 /* 1.000V/0.400V */
298
#define V007 3 /* 0.700V/0.000V */
300
/* Signal level setup */
301
#define SIG_SETUP(x) (x)
303
/* sync characteristics */
304
#define SEP_SYNC(x) (x & 0x08)
305
#define COMP_SYNC(x) (x & 0x04)
306
#define SYNC_O_GREEN(x) (x & 0x02)
307
#define SYNC_SERR(x) (x & 0x01)
310
#define DPMS_STANDBY(x) (x & 0x04)
311
#define DPMS_SUSPEND(x) (x & 0x02)
312
#define DPMS_OFF(x) (x & 0x01)
317
#define DISP_MULTCOLOR 2
319
/* Msc stuff EDID Ver > 1.1 */
320
#define STD_COLOR_SPACE(x) (x & 0x4)
321
#define PREFERRED_TIMING_MODE(x) (x & 0x2)
322
#define GFT_SUPPORTED(x) (x & 0x1)
324
/* detailed timing misc */
325
#define IS_INTERLACED(x) (x)
326
#define IS_STEREO(x) (x)
327
#define IS_RIGHT_STEREO(x) (x & 0x01)
328
#define IS_LEFT_STEREO(x) (x & 0x02)
329
#define IS_4WAY_STEREO(x) (x & 0x03)
330
#define IS_RIGHT_ON_SYNC(x) IS_RIGHT_STEREO(x)
331
#define IS_LEFT_ON_SYNC(x) IS_LEFT_STEREO(x)
334
typedef unsigned int Uint;
335
typedef unsigned char Uchar;
345
struct edid_version {
350
struct disp_features {
351
unsigned int input_type:1;
352
unsigned int input_voltage:2;
353
unsigned int input_setup:1;
354
unsigned int input_sync:5;
355
unsigned int input_dfp:1;
360
unsigned int display_type:2;
372
struct established_timings {
385
struct detailed_timings {
399
unsigned int interlaced:1;
400
unsigned int stereo:2;
403
unsigned int stereo_1:1;
407
#define DS_SERIAL 0xFF
408
#define DS_ASCII_STR 0xFE
410
#define DS_RANGES 0xFD
411
#define DS_WHITE_P 0xFB
412
#define DS_STD_TIMINGS 0xFA
413
#define DS_DUMMY 0x10
415
struct monitor_ranges {
435
struct detailed_monitor_section {
438
struct detailed_timings d_timings;
440
Uchar ascii_data[13];
442
struct monitor_ranges ranges;
443
struct std_timings std_t[5];
444
struct whitePoints wp[2];
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];
459
} xf86Monitor, *xf86MonPtr;
461
extern xf86MonPtr ConfiguredMonitor;
463
#endif /* _EDID_H_ */