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