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