1 /* 2 * ReactOS VBE miniport video driver 3 * 4 * Copyright (C) 2004 Filip Navara 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License along 17 * with this program; if not, write to the Free Software Foundation, Inc., 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 */ 20 21 #ifndef _VBEMP_PCH_ 22 #define _VBEMP_PCH_ 23 24 /* INCLUDES *******************************************************************/ 25 26 #include <ntdef.h> 27 #include <dderror.h> 28 #include <miniport.h> 29 #include <video.h> 30 31 #define TAG_VBE ' EBV' 32 33 /* 34 * Compile-time define to get VBE 1.2 support. The implementation 35 * is far from complete now and so it's left undefined. 36 */ 37 38 /* #define VBE12_SUPPORT */ 39 40 #include <pshpack1.h> 41 42 /* 43 * VBE Command Definitions 44 */ 45 46 #define VBE_GET_CONTROLLER_INFORMATION 0x4F00 47 #define VBE_GET_MODE_INFORMATION 0x4F01 48 #define VBE_SET_VBE_MODE 0x4F02 49 #define VBE_GET_CURRENT_VBE_MODE 0x4F03 50 #define VBE_SAVE_RESTORE_STATE 0x4F04 51 #define VBE_DISPLAY_WINDOW_CONTROL 0x4F05 52 #define VBE_SET_GET_LOGICAL_SCAN_LINE_LENGTH 0x4F06 53 #define VBE_SET_GET_DISPLAY_START 0x4F07 54 #define VBE_SET_GET_DAC_PALETTE_FORMAT 0x4F08 55 #define VBE_SET_GET_PALETTE_DATA 0x4F09 56 57 /* VBE 2.0+ */ 58 #define VBE_RETURN_PROTECTED_MODE_INTERFACE 0x4F0A 59 #define VBE_GET_SET_PIXEL_CLOCK 0x4F0B 60 61 /* Extensions */ 62 #define VBE_POWER_MANAGEMENT_EXTENSIONS 0x4F10 63 #define VBE_FLAT_PANEL_INTERFACE_EXTENSIONS 0x4F11 64 #define VBE_AUDIO_INTERFACE_EXTENSIONS 0x4F12 65 #define VBE_OEM_EXTENSIONS 0x4F13 66 #define VBE_DISPLAY_DATA_CHANNEL 0x4F14 67 #define VBE_DDC 0x4F15 68 69 /* 70 * VBE DDC Sub-Functions 71 */ 72 73 #define VBE_DDC_READ_EDID 0x01 74 #define VBE_DDC_REPORT_CAPABILITIES 0x10 75 #define VBE_DDC_BEGIN_SCL_SDA_CONTROL 0x11 76 #define VBE_DDC_END_SCL_SDA_CONTROL 0x12 77 #define VBE_DDC_WRITE_SCL_CLOCK_LINE 0x13 78 #define VBE_DDC_WRITE_SDA_DATA_LINE 0x14 79 #define VBE_DDC_READ_SCL_CLOCK_LINE 0x15 80 #define VBE_DDC_READ_SDA_DATA_LINE 0x16 81 82 /* 83 * VBE Video Mode Information Definitions 84 */ 85 86 #define VBE_MODEATTR_LINEAR 0x80 87 88 #define VBE_MEMORYMODEL_PACKEDPIXEL 0x04 89 #define VBE_MEMORYMODEL_DIRECTCOLOR 0x06 90 91 /* 92 * VBE Return Codes 93 */ 94 95 #define VBE_SUCCESS 0x4F 96 #define VBE_UNSUCCESSFUL 0x14F 97 #define VBE_NOT_SUPPORTED 0x24F 98 #define VBE_FUNCTION_INVALID 0x34F 99 100 #define VBE_GETRETURNCODE(x) (x & 0xFFFF) 101 102 /* 103 * VBE specification defined structure for general adapter info 104 * returned by function VBE_GET_CONTROLLER_INFORMATION command. 105 */ 106 107 typedef struct 108 { 109 CHAR Signature[4]; 110 USHORT Version; 111 ULONG OemStringPtr; 112 LONG Capabilities; 113 ULONG VideoModePtr; 114 USHORT TotalMemory; 115 USHORT OemSoftwareRevision; 116 ULONG OemVendorNamePtr; 117 ULONG OemProductNamePtr; 118 ULONG OemProductRevPtr; 119 CHAR Reserved[222]; 120 CHAR OemData[256]; 121 } VBE_INFO, *PVBE_INFO; 122 123 /* 124 * VBE specification defined structure for specific video mode 125 * info returned by function VBE_GET_MODE_INFORMATION command. 126 */ 127 128 typedef struct 129 { 130 /* Mandatory information for all VBE revisions */ 131 USHORT ModeAttributes; 132 UCHAR WinAAttributes; 133 UCHAR WinBAttributes; 134 USHORT WinGranularity; 135 USHORT WinSize; 136 USHORT WinASegment; 137 USHORT WinBSegment; 138 ULONG WinFuncPtr; 139 USHORT BytesPerScanLine; 140 141 /* Mandatory information for VBE 1.2 and above */ 142 USHORT XResolution; 143 USHORT YResolution; 144 UCHAR XCharSize; 145 UCHAR YCharSize; 146 UCHAR NumberOfPlanes; 147 UCHAR BitsPerPixel; 148 UCHAR NumberOfBanks; 149 UCHAR MemoryModel; 150 UCHAR BankSize; 151 UCHAR NumberOfImagePages; 152 UCHAR Reserved1; 153 154 /* Direct Color fields (required for Direct/6 and YUV/7 memory models) */ 155 UCHAR RedMaskSize; 156 UCHAR RedFieldPosition; 157 UCHAR GreenMaskSize; 158 UCHAR GreenFieldPosition; 159 UCHAR BlueMaskSize; 160 UCHAR BlueFieldPosition; 161 UCHAR ReservedMaskSize; 162 UCHAR ReservedFieldPosition; 163 UCHAR DirectColorModeInfo; 164 165 /* Mandatory information for VBE 2.0 and above */ 166 ULONG PhysBasePtr; 167 ULONG Reserved2; 168 USHORT Reserved3; 169 170 /* Mandatory information for VBE 3.0 and above */ 171 USHORT LinBytesPerScanLine; 172 UCHAR BnkNumberOfImagePages; 173 UCHAR LinNumberOfImagePages; 174 UCHAR LinRedMaskSize; 175 UCHAR LinRedFieldPosition; 176 UCHAR LinGreenMaskSize; 177 UCHAR LinGreenFieldPosition; 178 UCHAR LinBlueMaskSize; 179 UCHAR LinBlueFieldPosition; 180 UCHAR LinReservedMaskSize; 181 UCHAR LinReservedFieldPosition; 182 ULONG MaxPixelClock; 183 184 CHAR Reserved4[189]; 185 } VBE_MODEINFO, *PVBE_MODEINFO; 186 187 #define MAX_SIZE_OF_EDID 256 188 189 #include <poppack.h> 190 191 typedef struct 192 { 193 /* Interface to Int10 calls */ 194 VIDEO_PORT_INT10_INTERFACE Int10Interface; 195 196 /* Trampoline memory for communication with VBE real-mode interface */ 197 USHORT TrampolineMemorySegment; 198 USHORT TrampolineMemoryOffset; 199 200 /* General controller/BIOS information */ 201 VBE_INFO VbeInfo; 202 203 /* Saved information about video modes */ 204 ULONG ModeCount; 205 USHORT *ModeNumbers; 206 PVBE_MODEINFO ModeInfo; 207 USHORT CurrentMode; 208 209 /* Current child been enumerated */ 210 ULONG CurrentChildIndex; 211 } VBE_DEVICE_EXTENSION, *PVBE_DEVICE_EXTENSION; 212 213 /* edid.c */ 214 215 VP_STATUS NTAPI 216 VBEGetVideoChildDescriptor( 217 IN PVOID HwDeviceExtension, 218 IN PVIDEO_CHILD_ENUM_INFO ChildEnumInfo, 219 OUT PVIDEO_CHILD_TYPE VideoChildType, 220 OUT PUCHAR pChildDescriptor, 221 OUT PULONG UId, 222 OUT PULONG pUnused); 223 224 /* vbemp.c */ 225 VP_STATUS NTAPI 226 VBEFindAdapter( 227 IN PVOID HwDeviceExtension, 228 IN PVOID HwContext, 229 IN PWSTR ArgumentString, 230 IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, 231 OUT PUCHAR Again); 232 233 BOOLEAN NTAPI 234 VBEInitialize(PVOID HwDeviceExtension); 235 236 BOOLEAN NTAPI 237 VBEStartIO( 238 PVOID HwDeviceExtension, 239 PVIDEO_REQUEST_PACKET RequestPacket); 240 241 BOOLEAN NTAPI 242 VBEResetHw( 243 PVOID DeviceExtension, 244 ULONG Columns, 245 ULONG Rows); 246 247 VP_STATUS NTAPI 248 VBEGetPowerState( 249 PVOID HwDeviceExtension, 250 ULONG HwId, 251 PVIDEO_POWER_MANAGEMENT VideoPowerControl); 252 253 VP_STATUS NTAPI 254 VBESetPowerState( 255 PVOID HwDeviceExtension, 256 ULONG HwId, 257 PVIDEO_POWER_MANAGEMENT VideoPowerControl); 258 259 BOOLEAN FASTCALL 260 VBESetCurrentMode( 261 PVBE_DEVICE_EXTENSION DeviceExtension, 262 PVIDEO_MODE RequestedMode, 263 PSTATUS_BLOCK StatusBlock); 264 265 BOOLEAN FASTCALL 266 VBEResetDevice( 267 PVBE_DEVICE_EXTENSION DeviceExtension, 268 PSTATUS_BLOCK StatusBlock); 269 270 BOOLEAN FASTCALL 271 VBEMapVideoMemory( 272 PVBE_DEVICE_EXTENSION DeviceExtension, 273 PVIDEO_MEMORY RequestedAddress, 274 PVIDEO_MEMORY_INFORMATION MapInformation, 275 PSTATUS_BLOCK StatusBlock); 276 277 BOOLEAN FASTCALL 278 VBEUnmapVideoMemory( 279 PVBE_DEVICE_EXTENSION DeviceExtension, 280 PVIDEO_MEMORY VideoMemory, 281 PSTATUS_BLOCK StatusBlock); 282 283 BOOLEAN FASTCALL 284 VBEQueryNumAvailModes( 285 PVBE_DEVICE_EXTENSION DeviceExtension, 286 PVIDEO_NUM_MODES Modes, 287 PSTATUS_BLOCK StatusBlock); 288 289 BOOLEAN FASTCALL 290 VBEQueryAvailModes( 291 PVBE_DEVICE_EXTENSION DeviceExtension, 292 PVIDEO_MODE_INFORMATION ReturnedModes, 293 PSTATUS_BLOCK StatusBlock); 294 295 BOOLEAN FASTCALL 296 VBEQueryCurrentMode( 297 PVBE_DEVICE_EXTENSION DeviceExtension, 298 PVIDEO_MODE_INFORMATION VideoModeInfo, 299 PSTATUS_BLOCK StatusBlock); 300 301 BOOLEAN FASTCALL 302 VBESetColorRegisters( 303 PVBE_DEVICE_EXTENSION DeviceExtension, 304 PVIDEO_CLUT ColorLookUpTable, 305 PSTATUS_BLOCK StatusBlock); 306 307 #endif /* _VBEMP_PCH_ */ 308