root/morphix/trunk/ddcxinfo/vbe.h

Revision 2, 9.0 kB (checked in by nextime, 2 years ago)

Initial import, branching from morphix svn

Line 
1 #ifndef vbe_h
2 #define vbe_h
3 #ident "$Id: vbe.h 1815 2005-04-25 08:27:54Z alextreme $"
4 #include <sys/types.h>
5
6 /* Record returned by int 0x10, function 0x4f, subfunction 0x00. */
7 struct vbe_info {
8         unsigned char signature[4];
9         unsigned char version[2];
10         union {
11                 struct {
12                         u_int16_t ofs;
13                         u_int16_t seg;
14                 } addr;
15                 const char *string;
16         } oem_name;
17         u_int32_t capabilities;
18         union {
19                 struct {
20                         u_int16_t ofs;
21                         u_int16_t seg;
22                 } addr;
23                 u_int16_t *list;
24         } mode_list;
25         u_int16_t memory_size;
26         /* VESA 3.0+ */
27         u_int16_t vbe_revision;
28         union {
29                 struct {
30                         u_int16_t ofs;
31                         u_int16_t seg;
32                 } addr;
33                 const char *string;
34         } vendor_name;
35         union {
36                 struct {
37                         u_int16_t ofs;
38                         u_int16_t seg;
39                 } addr;
40                 const char *string;
41         } product_name;
42         union {
43                 struct {
44                         u_int16_t ofs;
45                         u_int16_t seg;
46                 } addr;
47                 const char *string;
48         } product_revision;
49         char reserved1[222];
50         char reserved2[256];
51 } __attribute__ ((packed));
52
53 /* Stuff returned by int 0x10, function 0x4f, subfunction 0x01. */
54 struct vbe_mode_info {
55         /* required for all VESA versions */
56         struct {
57                 /* VBE 1.0+ */
58                 u_int16_t supported: 1;
59                 u_int16_t optional_info_available: 1;
60                 u_int16_t bios_output_supported: 1;
61                 u_int16_t color: 1;
62                 u_int16_t graphics: 1;
63                 /* VBE 2.0+ */
64                 u_int16_t not_vga_compatible: 1;
65                 u_int16_t not_bank_switched: 1;
66                 u_int16_t lfb: 1;
67                 /* VBE 1.0+ */
68                 u_int16_t unknown: 1;
69                 u_int16_t must_enable_directaccess_in_10: 1;
70         } mode_attributes;
71         struct {
72                 unsigned char exists: 1;
73                 unsigned char readable: 1;
74                 unsigned char writeable: 1;
75                 unsigned char reserved: 5;
76         } windowa_attributes, windowb_attributes;
77         u_int16_t window_granularity;
78         u_int16_t window_size;
79         u_int16_t windowa_start_segment, windowb_start_segment;
80         u_int16_t window_positioning_seg, window_positioning_ofs;
81         u_int16_t bytes_per_scanline;
82         /* optional for VESA 1.0/1.1, required for OEM modes */
83         u_int16_t w, h;
84         unsigned char cell_width, cell_height;
85         unsigned char memory_planes;
86         unsigned char bpp;
87         unsigned char banks;
88         enum {
89                 memory_model_text = 0,
90                 memory_model_cga = 1,
91                 memory_model_hgc = 2,
92                 memory_model_ega16 = 3,
93                 memory_model_packed_pixel = 4,
94                 memory_model_sequ256 = 5,
95                 memory_model_direct_color = 6,
96                 memory_model_yuv = 7,
97         } memory_model: 8;
98         unsigned char bank_size;
99         unsigned char image_pages;
100         unsigned char reserved1;
101         /* required for VESA 1.2+ */
102         unsigned char red_mask, red_field;
103         unsigned char green_mask, green_field;
104         unsigned char blue_mask, blue_field;
105         unsigned char reserved_mask, reserved_field;
106         unsigned char direct_color_mode_info;
107         /* VESA 2.0+ */
108         u_int32_t linear_buffer_address;
109         u_int32_t offscreen_memory_address;
110         u_int16_t offscreen_memory_size;
111         unsigned char reserved2[206];
112 } __attribute__ ((packed));
113
114 /* Modeline information used by XFree86. */
115 struct vbe_modeline {
116         u_int16_t width, height;
117         unsigned char interlaced;
118         float refresh;
119         char *modeline;
120         float hfreq, vfreq, pixel_clock;
121 };
122
123 /* Aspect ratios used in EDID info. */
124 enum vbe_edid_aspect {
125         aspect_unknown = 0,
126         aspect_75,
127         aspect_8,
128         aspect_5625,
129 };
130
131 /* Detailed timing information used in EDID v1.x */
132 struct vbe_edid_detailed_timing {
133         u_int16_t pixel_clock;
134 #define VBE_EDID_DETAILED_TIMING_PIXEL_CLOCK(_x) \
135         ((_x).pixel_clock * 10000)
136         unsigned char horizontal_active;
137         unsigned char horizontal_blanking;
138         unsigned char horizontal_active_hi: 4;
139         unsigned char horizontal_blanking_hi: 4;
140 #define VBE_EDID_DETAILED_TIMING_HORIZONTAL_ACTIVE(_x) \
141         (((_x).horizontal_active_hi << 8) + (_x).horizontal_active)
142 #define VBE_EDID_DETAILED_TIMING_HORIZONTAL_BLANKING(_x) \
143         (((_x).horizontal_blanking_hi << 8) + (_x).horizontal_blanking)
144         unsigned char vertical_active;
145         unsigned char vertical_blanking;
146         unsigned char vertical_active_hi: 4;
147         unsigned char vertical_blanking_hi: 4;
148 #define VBE_EDID_DETAILED_TIMING_VERTICAL_ACTIVE(_x) \
149         (((_x).vertical_active_hi << 8) + (_x).vertical_active)
150 #define VBE_EDID_DETAILED_TIMING_VERTICAL_BLANKING(_x) \
151         (((_x).vertical_blanking_hi << 8) + (_x).vertical_blanking)
152         unsigned char hsync_offset;
153         unsigned char hsync_pulse_width;
154         unsigned char vsync_offset: 4;
155         unsigned char vsync_pulse_width: 4;
156         unsigned char hsync_offset_hi: 2;
157         unsigned char hsync_pulse_width_hi: 2;
158         unsigned char vsync_offset_hi: 2;
159         unsigned char vsync_pulse_width_hi: 2;
160 #define VBE_EDID_DETAILED_TIMING_HSYNC_OFFSET(_x) \
161         (((_x).hsync_offset_hi << 8) + (_x).hsync_offset)
162 #define VBE_EDID_DETAILED_TIMING_HSYNC_PULSE_WIDTH(_x) \
163         (((_x).hsync_pulse_width_hi << 8) + (_x).hsync_pulse_width)
164 #define VBE_EDID_DETAILED_TIMING_VSYNC_OFFSET(_x) \
165         (((_x).vsync_offset_hi << 4) + (_x).vsync_offset)
166 #define VBE_EDID_DETAILED_TIMING_VSYNC_PULSE_WIDTH(_x) \
167         (((_x).vsync_pulse_width_hi << 4) + (_x).vsync_pulse_width)
168         unsigned char himage_size;
169         unsigned char vimage_size;
170         unsigned char himage_size_hi: 4;
171         unsigned char vimage_size_hi: 4;
172 #define VBE_EDID_DETAILED_TIMING_HIMAGE_SIZE(_x) \
173         (((_x).himage_size_hi << 8) + (_x).himage_size)
174 #define VBE_EDID_DETAILED_TIMING_VIMAGE_SIZE(_x) \
175         (((_x).vimage_size_hi << 8) + (_x).vimage_size)
176         unsigned char hborder;
177         unsigned char vborder;
178         struct {
179                 unsigned char interlaced: 1;
180                 unsigned char stereo: 2;
181                 unsigned char digital_composite: 2;
182                 unsigned char variant: 2;
183                 unsigned char zero: 1;
184         } flags __attribute__ ((packed));
185 } __attribute__ ((packed));
186
187 enum {
188         vbe_edid_monitor_descriptor_serial = 0xff,
189         vbe_edid_monitor_descriptor_ascii = 0xfe,
190         vbe_edid_monitor_descriptor_range = 0xfd,
191         vbe_edid_monitor_descriptor_name = 0xfc,
192 } vbe_edid_monitor_descriptor_types;
193
194 struct vbe_edid_monitor_descriptor {
195         u_int16_t zero_flag_1;
196         unsigned char zero_flag_2;
197         unsigned char type;
198         unsigned char zero_flag_3;
199         union {
200                 char string[13];
201                 struct {
202                         unsigned char vertical_min;
203                         unsigned char vertical_max;
204                         unsigned char horizontal_min;
205                         unsigned char horizontal_max;
206                         unsigned char pixel_clock_max;
207                         unsigned char gtf_data[8];
208                 } range_data;
209         } data;
210 } __attribute__ ((packed));
211
212 struct vbe_edid1_info {
213         unsigned char header[8];
214         struct {
215                 u_int16_t char3: 5;
216                 u_int16_t char2: 5;
217                 u_int16_t char1: 5;
218                 u_int16_t zero: 1;
219         } manufacturer_name __attribute__ ((packed));
220         u_int16_t product_code;
221         u_int32_t serial_number;
222         unsigned char week;
223         unsigned char year;
224         unsigned char version;
225         unsigned char revision;
226         struct {
227                 unsigned char separate_sync: 1;
228                 unsigned char composite_sync: 1;
229                 unsigned char sync_on_green: 1;
230                 unsigned char unused: 2;
231                 unsigned char voltage_level: 2;
232                 unsigned char digital: 1;
233         } video_input_definition __attribute__ ((packed));
234         unsigned char max_size_horizontal;
235         unsigned char max_size_vertical;
236         unsigned char gamma;
237         struct {
238                 unsigned char unused1: 3;
239                 unsigned char rgb: 1;
240                 unsigned char unused2: 1;
241                 unsigned char active_off: 1;
242                 unsigned char suspend: 1;
243                 unsigned char standby: 1;
244         } feature_support __attribute__ ((packed));
245         unsigned char color_characteristics[10];
246         struct {
247                 unsigned char timing_720x400_70: 1;
248                 unsigned char timing_720x400_88: 1;
249                 unsigned char timing_640x480_60: 1;
250                 unsigned char timing_640x480_67: 1;
251                 unsigned char timing_640x480_72: 1;
252                 unsigned char timing_640x480_75: 1;
253                 unsigned char timing_800x600_56: 1;
254                 unsigned char timing_800x600_60: 1;
255                 unsigned char timing_800x600_72: 1;
256                 unsigned char timing_800x600_75: 1;
257                 unsigned char timing_832x624_75: 1;
258                 unsigned char timing_1024x768_87i: 1;
259                 unsigned char timing_1024x768_60: 1;
260                 unsigned char timing_1024x768_70: 1;
261                 unsigned char timing_1024x768_75: 1;
262                 unsigned char timing_1280x1024_75: 1;
263         } established_timings __attribute__ ((packed));
264         struct {
265                 unsigned char timing_1152x870_75: 1;
266                 unsigned char reserved: 7;
267         } manufacturer_timings __attribute__ ((packed));
268         struct {
269                 u_int16_t xresolution: 8;
270                 u_int16_t vfreq: 6;
271                 u_int16_t aspect: 2;
272         } standard_timing[8] __attribute__ ((packed));
273         union {
274                 struct vbe_edid_detailed_timing detailed_timing[4];
275                 struct vbe_edid_monitor_descriptor monitor_descriptor[4];
276         } monitor_details __attribute__ ((packed));
277         unsigned char extension_flag;
278         unsigned char checksum;
279         unsigned char padding[128];
280 } __attribute__ ((packed));
281
282 #define VBE_LINEAR_FRAMEBUFFER 0x4000
283
284 /* Get VESA information. */
285 struct vbe_info *vbe_get_vbe_info();
286
287 /* Get information about a particular video mode, bitwise or with
288    VBE_LINEAR_FRAMEBUFFER to check if LFB version is supported. */
289 struct vbe_mode_info *vbe_get_mode_info(u_int16_t mode);
290
291 /* Check if EDID reads are supported, and do them. */
292 int vbe_get_edid_supported();
293 struct vbe_edid1_info *vbe_get_edid_info();
294
295 /* Get the current video mode, -1 on error. */
296 int32_t vbe_get_mode();
297 /* Set a new video mode, bitwise or with VBE_LINEAR_FRAMEBUFFER. */
298 void vbe_set_mode(u_int16_t mode);
299
300 /* Save/restore the SVGA state.  Call free() on the state record when done. */
301 const void *vbe_save_svga_state();
302 void vbe_restore_svga_state(const void *state);
303
304 /* Get the ranges of values suitable for the attached monitor. */
305 void vbe_get_edid_ranges(unsigned char *hmin, unsigned char *hmax,
306                          unsigned char *vmin, unsigned char *vmax);
307
308 /* Get a list of modelines that will work with this monitor. */
309 struct vbe_modeline *vbe_get_edid_modelines();
310
311 #endif
312
Note: See TracBrowser for help on using the browser.