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