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