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