7 #include <ddk/winddi.h>
9 #include <ddk/ntddvdeo.h>
11 /* FIXME - what a headers mess.... */
13 #define DDKAPI __stdcall
14 #define DDKFASTAPI __fastcall
15 #define FASTCALL __fastcall
16 #define DDKCDECLAPI __cdecl
18 ULONG
DbgPrint(PCH Format
,...);
19 VOID DDKAPI
DbgBreakPoint(VOID
);
20 VOID DDKAPI
WRITE_PORT_UCHAR(IN PUCHAR Port
, IN UCHAR Value
);
21 VOID DDKAPI
WRITE_REGISTER_UCHAR(IN PUCHAR Register
, IN UCHAR Value
);
22 UCHAR DDKAPI
READ_REGISTER_UCHAR(IN PUCHAR Register
);
24 static __inline BOOLEAN
31 OldFlink
= Entry
->Flink
;
32 OldBlink
= Entry
->Blink
;
33 OldFlink
->Blink
= OldBlink
;
34 OldBlink
->Flink
= OldFlink
;
35 return (OldFlink
== OldBlink
);
40 IN PLIST_ENTRY ListHead
,
44 OldFlink
= ListHead
->Flink
;
45 Entry
->Flink
= OldFlink
;
46 Entry
->Blink
= ListHead
;
47 OldFlink
->Blink
= Entry
;
48 ListHead
->Flink
= Entry
;
53 IN PLIST_ENTRY ListHead
)
55 ListHead
->Flink
= ListHead
->Blink
= ListHead
;
58 /***********************************************************/
60 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
62 #define DS_SOLIDBRUSH 0x00000001
63 #define DS_GREYBRUSH 0x00000002
64 #define DS_BRUSH 0x00000004
65 #define DS_DIB 0x00000008
67 #define POW2(stride) (!((stride) & ((stride)-1))) // TRUE if stride is power of 2
68 #define BROKEN_RASTERS(stride,cy) ((!(POW2(stride))) && ((stride*cy) > 0x10000))
70 #define ENUM_RECT_LIMIT 50
72 typedef struct _RECT_ENUM
75 RECTL arcl
[ENUM_RECT_LIMIT
];
79 typedef struct _XYPAIR
85 typedef struct _SAVED_SCREEN_BITS
91 } SAVED_SCREEN_BITS
, *PSAVED_SCREEN_BITS
;
94 #define CURSOR_COLOR 0x00000004
95 #define CURSOR_HW 0x00000010
96 #define CURSOR_HW_ACTIVE 0x00000020
97 #define CURSOR_ANIMATE 0x00000040
101 ULONG fl
; // driver flags
105 HDEV GDIDevHandle
; // engine's handle to PDEV
106 HSURF SurfHandle
; // engine's handle to surface
107 PVOID AssociatedSurf
; // associated surface
110 XYPAIR xyHotSpot
; // cursor hotspot
113 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes
; // HW Pointer Attributes
114 PSAVED_SCREEN_BITS ImageBehindCursor
;
115 ULONG XorMaskStartOffset
; // Start offset of hardware pointer
116 // XOR mask relative to AND mask for
117 // passing to HW pointer
118 DWORD PointerAttributes
; // Size of buffer allocated
119 DWORD flPreallocSSBBufferInUse
; // True if preallocated saved screen
120 // bits buffer is in use
121 PUCHAR pjPreallocSSBBuffer
; // Pointer to preallocated saved screen
122 // bits buffer, if there is one
123 ULONG ulPreallocSSBSize
; // Size of preallocated saved screen
125 VIDEO_POINTER_CAPABILITIES PointerCapabilities
; // HW pointer abilities
126 PUCHAR pucDIB4ToVGAConvBuffer
; // DIB4->VGA conversion table buffer
127 PUCHAR pucDIB4ToVGAConvTables
; // Pointer to DIB4->VGA conversion
130 ULONG ModeNum
; // mode index for current VGA mode
132 SIZEL sizeSurf
; // displayed size of the surface
133 PBYTE fbScreen
; // pointer to the frame buffer
134 RECTL SavedBitsRight
; // invisible part right of screen
135 RECTL SavedBitsBottom
; // invisible part at the bottom of the screen
136 BOOL BitsSaved
; // TRUE if bits are currently saved
137 SIZEL sizeMem
; // actual size (in pixels) of video memory
138 LONG NumScansUsedByPointer
; // # scans of offscreen memory used by
143 RECTL BankBounds
; // Pixels addressable in this bank
144 ULONG BankOffset
; // Offset of bank start from bitmap start if linearly addressable
145 } BANK_INFO
, *PBANK_INFO
;
152 // bank control function vector
153 //typedef VOID (*PFN_BankControl)(PDEVSURF, ULONG, BANK_JUST);
154 typedef VOID (*PFN_BankControl
)(PVOID
, ULONG
, BANK_JUST
);
156 // DEVSURF -- definition of a surface as seen and used by the various VGA
159 typedef struct _DEVSURF
161 IDENT ident
; // Identifier for debugging ease
162 ULONG flSurf
; // DS_ flags as defined below
163 BYTE Color
; // Solid color surface if DS_SOLIDBRUSH
165 // If DS_SOLIDBRUSH, the following fields are undefined and not guaranteed to
166 // have been allocated!
168 BYTE Format
; // BMF_*, BMF_PHYSDEVICE
169 BYTE jReserved1
; // Reserved
170 BYTE jReserved2
; // Reserved
171 PPDEV ppdev
; // Pointer to associated PDEV
172 SIZEL sizeSurf
; // Size of the surface
173 ULONG NextScan
; // Offset from scan "n" to "n+1"
174 ULONG NextPlane
; // Offset from plane "n" to "n+1"
175 PVOID Scan0
; // Pointer to scan 0 of bitmap
176 // (actual address of start of bank, for banked VGA surface)
177 PVOID StartBmp
; // Pointer to start of bitmap
178 PVOID Conv
; // Pointer to DIB/Planer conversion buffer
180 // Banking variables; used only for banked VGA surfaces
182 PVIDEO_BANK_SELECT BankSelectInfo
;
183 ULONG Bank2RWSkip
; // Offset from one bank index to next to make two 32K banks appear to be
184 // one seamless 64K bank
185 PFN pfnBankSwitchCode
;
186 VIDEO_BANK_TYPE BankingType
;
187 ULONG BitmapSize
; // Length of bitmap if there were no banking, in CPU addressable bytes
188 ULONG PtrBankScan
; // Last scan line in pointer work bank
189 RECTL WindowClip1
; // Single-window banking clip rect
190 RECTL WindowClip2
[2]; // Double-window banking clip rects for
192 ULONG WindowBank
[2]; // Current banks mapped into windows
193 // 0 & 1 (used in 2 window mode only)
194 PBANK_INFO BankInfo
; // Pointer to array of bank clip info
195 ULONG BankInfoLength
; // Length of pbiBankInfo, in entries
196 PBANK_INFO BankInfo2RW
; // Same as above, but for 2RW window
197 ULONG BankInfo2RWLength
; // case
198 PFN_BankControl pfnBankControl
; // Pointer to bank control function
199 PFN_BankControl pfnBankControl2Window
; // Pointer to double-window bank
201 PVOID BitmapStart
; // Single-window bitmap start pointer (adjusted as
202 // necessary to make window map in at proper offset)
203 PVOID BitmapStart2Window
[2]; // Double-window window 0 and 1 bitmap start
204 PVOID BankBufferPlane0
; // Pointer to temp buffer capable of
205 // storing one full bank for plane 0 for 1
206 // R/W case; capable of storing one full
207 // bank height of edge bytes for all four
208 // planes for the 1R/1W case. Also used to
209 // point to text building buffer in all
210 // cases. This is the pointer used to
211 // dealloc bank working storage for all
214 // The following 3 pointers used by 1 R/W banked devices
215 PVOID BankBufferPlane1
; // Like above, but for plane 1
216 PVOID BankBufferPlane2
; // Like above, but for plane 2
217 PVOID BankBufferPlane3
; // Like above, but for plane 3
218 ULONG TempBufferSize
; // Full size of temp buffer pointed to
219 // by pvBankBufferPlane0
221 ULONG ajBits
[1]; // Bits will start here for device bitmaps
222 PSAVED_SCREEN_BITS ssbList
; // Pointer to start of linked list of
223 // saved screen bit blocks
224 } DEVSURF
, *PDEVSURF
;
226 typedef VOID (*PFN_ScreenToScreenBlt
)(PDEVSURF
, PRECTL
, PPOINTL
, INT
);
228 // BMF_PHYSDEVICE format type
230 #define BMF_PHYSDEVICE 0xFF
233 // Identifiers used in debugging (DEVSURF.ident)
235 #define PDEV_IDENT ('V' + ('P' << 8) + ('D' << 16) + ('V' << 24))
236 #define DEVSURF_IDENT ('V' + ('S' << 8) + ('R' << 16) + ('F' << 24))
238 BOOL
InitVGA(PPDEV ppdev
, BOOL bFirst
); // screen.c: initialize VGA mode
239 BOOL
DeinitVGA(PPDEV ppdev
); // screen.c: Free resources allocated in InitVGA
241 #define DRIVER_EXTRA_SIZE 0
242 #define ALLOC_TAG TAG('D', 'v', 'g', 'a') // Dvga tag
243 #define DLL_NAME L"vga" // DLL name in Unicode
245 #define MAX_SCAN_WIDTH 2048 // pixels
246 #define DRIVER_OFFSCREEN_REFRESHED 0x04L // if not set, don't use offscreen memory
247 #define PLANAR_PELS_PER_CPU_ADDRESS 8
248 #define PACKED_PELS_PER_CPU_ADDRESS 2
251 SURFOBJ
*Dest
, SURFOBJ
*Source
, SURFOBJ
*Mask
, XLATEOBJ
*ColorTranslation
,
252 RECTL
*DestRect
, POINTL
*SourcePoint
);
255 VGADDI_BltFromSavedScreenBits(ULONG DestX
,
257 PSAVED_SCREEN_BITS Src
,
261 VGADDI_BltToSavedScreenBits(PSAVED_SCREEN_BITS Dest
,
267 VGADDI_FreeSavedScreenBits(PSAVED_SCREEN_BITS SavedBits
);
269 VGADDI_AllocSavedScreenBits(ULONG Size
);
271 VGADDI_InitializeOffScreenMem(ULONG Start
, ULONG Length
);
273 BOOL
InitPointer(PPDEV ppdev
);
274 DWORD
getAvailableModes(HANDLE Driver
,
275 PVIDEO_MODE_INFORMATION
*modeInformation
,
279 vgaReadScan ( int x
, int y
, int w
, void *b
);
282 vgaWriteScan ( int x
, int y
, int w
, void *b
);