NV50: basic fbcon + misc fixes
[platform/upstream/libdrm.git] / linux-core / drm_edid.h
1 #ifndef __DRM_EDID_H__
2 #define __DRM_EDID_H__
3
4 #include <linux/types.h>
5
6 #define EDID_LENGTH 128
7 #define DDC_ADDR 0x50
8
9 #ifdef BIG_ENDIAN
10 #error "EDID structure is little endian, need big endian versions"
11 #endif
12
13 struct est_timings {
14         u8 t1;
15         u8 t2;
16         u8 mfg_rsvd;
17 } __attribute__((packed));
18
19 struct std_timing {
20         u8 hsize; /* need to multiply by 8 then add 248 */
21         u8 vfreq:6; /* need to add 60 */
22         u8 aspect_ratio:2; /* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
23 } __attribute__((packed));
24
25 /* If detailed data is pixel timing */
26 struct detailed_pixel_timing {
27         u8 hactive_lo;
28         u8 hblank_lo;
29         u8 hblank_hi:4;
30         u8 hactive_hi:4;
31         u8 vactive_lo;
32         u8 vblank_lo;
33         u8 vblank_hi:4;
34         u8 vactive_hi:4;
35         u8 hsync_offset_lo;
36         u8 hsync_pulse_width_lo;
37         u8 vsync_pulse_width_lo:4;
38         u8 vsync_offset_lo:4;
39         u8 hsync_pulse_width_hi:2;
40         u8 hsync_offset_hi:2;
41         u8 vsync_pulse_width_hi:2;
42         u8 vsync_offset_hi:2;
43         u8 width_mm_lo;
44         u8 height_mm_lo;
45         u8 height_mm_hi:4;
46         u8 width_mm_hi:4;
47         u8 hborder;
48         u8 vborder;
49         u8 unknown0:1;
50         u8 vsync_positive:1;
51         u8 hsync_positive:1;
52         u8 separate_sync:2;
53         u8 stereo:1;
54         u8 unknown6:1;
55         u8 interlaced:1;
56 } __attribute__((packed));
57
58 /* If it's not pixel timing, it'll be one of the below */
59 struct detailed_data_string {
60         u8 str[13];
61 } __attribute__((packed));
62
63 struct detailed_data_monitor_range {
64         u8 min_vfreq;
65         u8 max_vfreq;
66         u8 min_hfreq_khz;
67         u8 max_hfreq_khz;
68         u8 pixel_clock_mhz; /* need to multiply by 10 */
69         u16 sec_gtf_toggle; /* A000=use above, 20=use below */ /* FIXME: byte order */
70         u8 hfreq_start_khz; /* need to multiply by 2 */
71         u8 c; /* need to divide by 2 */
72         u16 m; /* FIXME: byte order */
73         u8 k;
74         u8 j; /* need to divide by 2 */
75 } __attribute__((packed));
76
77 struct detailed_data_wpindex {
78         u8 white_y_lo:2;
79         u8 white_x_lo:2;
80         u8 pad:4;
81         u8 white_x_hi;
82         u8 white_y_hi;
83         u8 gamma; /* need to divide by 100 then add 1 */
84 } __attribute__((packed));
85
86 struct detailed_data_color_point {
87         u8 windex1;
88         u8 wpindex1[3];
89         u8 windex2;
90         u8 wpindex2[3];
91 } __attribute__((packed));
92
93 struct detailed_non_pixel {
94         u8 pad1;
95         u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name
96                     fb=color point data, fa=standard timing data,
97                     f9=undefined, f8=mfg. reserved */
98         u8 pad2;
99         union {
100                 struct detailed_data_string str;
101                 struct detailed_data_monitor_range range;
102                 struct detailed_data_wpindex color;
103                 struct std_timing timings[5];
104         } data;
105 } __attribute__((packed));
106
107 #define EDID_DETAIL_STD_MODES 0xfa
108 #define EDID_DETAIL_MONITOR_CPDATA 0xfb
109 #define EDID_DETAIL_MONITOR_NAME 0xfc
110 #define EDID_DETAIL_MONITOR_RANGE 0xfd
111 #define EDID_DETAIL_MONITOR_STRING 0xfe
112 #define EDID_DETAIL_MONITOR_SERIAL 0xff
113
114 struct detailed_timing {
115         u16 pixel_clock; /* need to multiply by 10 KHz */ /* FIXME: byte order */
116         union {
117                 struct detailed_pixel_timing pixel_data;
118                 struct detailed_non_pixel other_data;
119         } data;
120 } __attribute__((packed));
121
122 struct edid {
123         u8 header[8];
124         /* Vendor & product info */
125         u8 mfg_id[2];
126         u8 prod_code[2];
127         u32 serial; /* FIXME: byte order */
128         u8 mfg_week;
129         u8 mfg_year;
130         /* EDID version */
131         u8 version;
132         u8 revision;
133         /* Display info: */
134         /*   input definition */
135         u8 serration_vsync:1;
136         u8 sync_on_green:1;
137         u8 composite_sync:1;
138         u8 separate_syncs:1;
139         u8 blank_to_black:1;
140         u8 video_level:2;
141         u8 digital:1; /* bits below must be zero if set */
142         u8 width_cm;
143         u8 height_cm;
144         u8 gamma;
145         /*   feature support */
146         u8 default_gtf:1;
147         u8 preferred_timing:1;
148         u8 standard_color:1;
149         u8 display_type:2; /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */
150         u8 pm_active_off:1;
151         u8 pm_suspend:1;
152         u8 pm_standby:1;
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
176 #define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8))
177
178 #endif /* __DRM_EDID_H__ */