3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 DBG_DEFAULT_CHANNEL(HWDETECT
);
30 UCHAR Signature
[4]; // (ret) signature ("VESA")
31 // (call) VESA 2.0 request signature ("VBE2"), required to receive
33 USHORT VesaVersion
; // VESA version number (one-digit minor version -- 0102h = v1.2)
34 ULONG OemNamePtr
; // pointer to OEM name
35 // "761295520" for ATI
36 ULONG Capabilities
; // capabilities flags (see #00078)
37 ULONG SupportedModeListPtr
; // pointer to list of supported VESA and OEM video modes
38 // (list of words terminated with FFFFh)
39 USHORT TotalVideoMemory
; // total amount of video memory in 64K blocks
42 //UCHAR Reserved[236];
45 USHORT OemSoftwareVersion
; // OEM software version (BCD, high byte = major, low byte = minor)
46 ULONG VendorNamePtr
; // pointer to vendor name
47 ULONG ProductNamePtr
; // pointer to product name
48 ULONG ProductRevisionStringPtr
; // pointer to product revision string
49 USHORT VBE_AF_Version
; // (if capabilities bit 3 set) VBE/AF version (BCD)
51 ULONG AcceleratedModeListPtr
; // (if capabilities bit 3 set) pointer to list of supported
52 // accelerated video modes (list of words terminated with FFFFh)
53 UCHAR Reserved
[216]; // reserved for VBE implementation
54 UCHAR ScratchPad
[256]; // OEM scratchpad (for OEM strings, etc.)
55 } VESA_SVGA_INFO
, *PVESA_SVGA_INFO
;
58 // Bitfields for VESA capabilities:
60 // Bit(s) Description (Table 00078)
61 // 0 DAC can be switched into 8-bit mode
62 // 1 non-VGA controller
63 // 2 programmed DAC with blank bit (i.e. only during blanking interval)
64 // 3 (VBE v3.0) controller supports hardware stereoscopic signalling
65 // 3 controller supports VBE/AF v1.0P extensions
66 // 4 (VBE v3.0) if bit 3 set:
67 // =0 stereo signalling via external VESA stereo connector
68 // =1 stereo signalling via VESA EVC connector
69 // 4 (VBE/AF v1.0P) must call EnableDirectAccess to access framebuffer
70 // 5 (VBE/AF v1.0P) controller supports hardware mouse cursor
71 // 6 (VBE/AF v1.0P) controller supports hardware clipping
72 // 7 (VBE/AF v1.0P) controller supports transparent BitBLT
75 // Notes: The list of supported video modes is stored in the reserved
76 // portion of the SuperVGA information record by some implementations,
77 // and it may thus be necessary to either copy the mode list or use a
78 // different buffer for all subsequent VESA calls. Not all of the video
79 // modes in the list of mode numbers may be supported, e.g. if they require
80 // more memory than currently installed or are not supported by the
81 // attached monitor. Check any mode you intend to use through AX=4F01h first..
82 // The 1.1 VESA document specifies 242 reserved bytes at the end, so the
83 // buffer should be 262 bytes to ensure that it is not overrun; for v2.0,
84 // the buffer should be 512 bytes. The S3 specific video modes will most
85 // likely follow the FFFFh terminator at the end of the standard modes.
86 // A search must then be made to find them, FFFFh will also terminate this
87 // second list. In some cases, only a "stub" VBE may be present, supporting
88 // only AX=4F00h; this case may be assumed if the list of supported video modes
89 // is empty (consisting of a single word of FFFFh)
91 static VOID
BiosSetVideoFont8x16(VOID
)
96 // VIDEO - TEXT-MODE CHARGEN - LOAD ROM 8x16 CHARACTER SET (VGA)
104 Int386(0x10, &Regs
, &Regs
);
107 static VOID
VideoSetTextCursorPosition(ULONG X
, ULONG Y
)
111 static ULONG
VideoGetTextCursorPositionX(VOID
)
116 // VIDEO - GET CURSOR POSITION AND SIZE
122 // 0 in graphics modes
124 // AX = 0000h (Phoenix BIOS)
125 // CH = start scan line
126 // CL = end scan line
127 // DH = row (00h is top)
128 // DL = column (00h is left)
131 Int386(0x10, &Regs
, &Regs
);
136 static ULONG
VideoGetTextCursorPositionY(VOID
)
141 // VIDEO - GET CURSOR POSITION AND SIZE
147 // 0 in graphics modes
149 // AX = 0000h (Phoenix BIOS)
150 // CH = start scan line
151 // CL = end scan line
152 // DH = row (00h is top)
153 // DL = column (00h is left)
156 Int386(0x10, &Regs
, &Regs
);
162 USHORT
BiosIsVesaSupported(VOID
)
165 PVESA_SVGA_INFO SvgaInfo
= (PVESA_SVGA_INFO
)BIOSCALLBUFFER
;
166 //USHORT* VideoModes;
169 TRACE("BiosIsVesaSupported()\n");
171 RtlZeroMemory(SvgaInfo
, sizeof(VESA_SVGA_INFO
));
173 // Make sure we receive version 2.0 info
174 SvgaInfo
->Signature
[0] = 'V';
175 SvgaInfo
->Signature
[1] = 'B';
176 SvgaInfo
->Signature
[2] = 'E';
177 SvgaInfo
->Signature
[3] = '2';
180 // VESA SuperVGA BIOS (VBE) - GET SuperVGA INFORMATION
183 // ES:DI -> buffer for SuperVGA information (see #00077)
185 // AL = 4Fh if function supported
188 // ES:DI buffer filled
191 // 02h function not supported by current hardware configuration
192 // 03h function invalid in current video mode
194 // Determine whether VESA BIOS extensions are present and the
195 // capabilities supported by the display adapter
197 // Installation check;VESA SuperVGA
199 Regs
.w
.es
= BIOSCALLBUFSEGMENT
;
200 Regs
.w
.di
= BIOSCALLBUFOFFSET
;
201 Int386(0x10, &Regs
, &Regs
);
203 TRACE("AL = 0x%x\n", Regs
.b
.al
);
204 TRACE("AH = 0x%x\n", Regs
.b
.ah
);
206 if (Regs
.w
.ax
!= 0x004F)
208 ERR("VESA BIOS call failed\n");
212 TRACE("Supported.\n");
213 TRACE("SvgaInfo->Signature[4] = %c%c%c%c\n", SvgaInfo
->Signature
[0], SvgaInfo
->Signature
[1], SvgaInfo
->Signature
[2], SvgaInfo
->Signature
[3]);
214 TRACE("SvgaInfo->VesaVersion = v%d.%d\n", ((SvgaInfo
->VesaVersion
>> 8) & 0xFF), (SvgaInfo
->VesaVersion
& 0xFF));
215 TRACE("SvgaInfo->OemNamePtr = 0x%x\n", SvgaInfo
->OemNamePtr
);
216 TRACE("SvgaInfo->Capabilities = 0x%x\n", SvgaInfo
->Capabilities
);
217 TRACE("SvgaInfo->VideoMemory = %dK\n", SvgaInfo
->TotalVideoMemory
* 64);
218 TRACE("---VBE v2.0 ---\n");
219 TRACE("SvgaInfo->OemSoftwareVersion = v%d.%d\n", ((SvgaInfo
->OemSoftwareVersion
>> 8) & 0x0F) + (((SvgaInfo
->OemSoftwareVersion
>> 12) & 0x0F) * 10), (SvgaInfo
->OemSoftwareVersion
& 0x0F) + (((SvgaInfo
->OemSoftwareVersion
>> 4) & 0x0F) * 10));
220 TRACE("SvgaInfo->VendorNamePtr = 0x%x\n", SvgaInfo
->VendorNamePtr
);
221 TRACE("SvgaInfo->ProductNamePtr = 0x%x\n", SvgaInfo
->ProductNamePtr
);
222 TRACE("SvgaInfo->ProductRevisionStringPtr = 0x%x\n", SvgaInfo
->ProductRevisionStringPtr
);
223 TRACE("SvgaInfo->VBE/AF Version = 0x%x (BCD WORD)\n", SvgaInfo
->VBE_AF_Version
);
225 if (SvgaInfo
->Signature
[0] != 'V' ||
226 SvgaInfo
->Signature
[1] != 'E' ||
227 SvgaInfo
->Signature
[2] != 'S' ||
228 SvgaInfo
->Signature
[3] != 'A')
230 ERR("Bad signature in VESA information (%c%c%c%c)\n",
231 SvgaInfo
->Signature
[0],
232 SvgaInfo
->Signature
[1],
233 SvgaInfo
->Signature
[2],
234 SvgaInfo
->Signature
[3]);
238 return SvgaInfo
->VesaVersion
;
243 BiosIsVesaDdcSupported(VOID
)
247 TRACE("BiosIsVesaDdcSupported()\n");
254 Int386(0x10, &Regs
, &Regs
);
256 TRACE("AL = 0x%x\n", Regs
.b
.al
);
257 TRACE("AH = 0x%x\n", Regs
.b
.ah
);
259 TRACE("BL = 0x%x\n", Regs
.b
.bl
);
261 if (Regs
.w
.ax
!= 0x004F)
263 ERR("VESA/DDC installation check failed\n");
267 return (Regs
.b
.ah
== 0);
272 BiosVesaReadEdid(VOID
)
276 TRACE("BiosVesaReadEdid()\n");
278 RtlZeroMemory((PVOID
)BIOSCALLBUFFER
, 128);
284 Regs
.w
.es
= BIOSCALLBUFSEGMENT
;
285 Regs
.w
.di
= BIOSCALLBUFOFFSET
;
286 Int386(0x10, &Regs
, &Regs
);
288 TRACE("AL = 0x%x\n", Regs
.b
.al
);
289 TRACE("AH = 0x%x\n", Regs
.b
.ah
);
291 if (Regs
.w
.ax
!= 0x004F)
293 ERR("Read EDID function not supported!\n");
297 return (Regs
.b
.ah
== 0);