2 #include <ddk/winddi.h>
3 #include <ddk/ntddvid.h>
5 #define DS_SOLIDBRUSH 0x00000001
6 #define DS_GREYBRUSH 0x00000002
7 #define DS_BRUSH 0x00000004
8 #define DS_DIB 0x00000008
10 #define POW2(stride) (!((stride) & ((stride)-1))) // TRUE if stride is power of 2
11 #define BROKEN_RASTERS(stride,cy) ((!(POW2(stride))) && ((stride*cy) > 0x10000))
13 #define DM_SPECVERSION 1 // FIXME: What is this really?
14 #define ENUM_RECT_LIMIT 50
16 typedef struct _RECT_ENUM
19 RECTL arcl[ENUM_RECT_LIMIT];
23 typedef struct _XYPAIR
30 #define CURSOR_DOWN 0x00000001
31 #define CURSOR_COLOR 0x00000004
32 #define CURSOR_HW 0x00000010
33 #define CURSOR_HW_ACTIVE 0x00000020
34 #define CURSOR_ANIMATE 0x00000040
38 ULONG fl; // driver flags
42 HDEV GDIDevHandle; // engine's handle to PDEV
43 HSURF SurfHandle; // engine's handle to surface
44 PVOID AssociatedSurf; // associated surface
47 XYPAIR xyCursor; // cursor position
48 POINTL ptlExtent; // cursor extent
49 ULONG cExtent; // effective cursor extent
50 ULONG flCursor; // cursor status
53 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // HW Pointer Attributes
54 ULONG XorMaskStartOffset; // Start offset of hardware pointer
55 // XOR mask relative to AND mask for
56 // passing to HW pointer
57 DWORD PointerAttributes; // Size of buffer allocated
58 DWORD flPreallocSSBBufferInUse; // True if preallocated saved screen
59 // bits buffer is in use
60 PUCHAR pjPreallocSSBBuffer; // Pointer to preallocated saved screen
61 // bits buffer, if there is one
62 ULONG ulPreallocSSBSize; // Size of preallocated saved screen
64 VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
65 PUCHAR pucDIB4ToVGAConvBuffer; // DIB4->VGA conversion table buffer
66 PUCHAR pucDIB4ToVGAConvTables; // Pointer to DIB4->VGA conversion
69 ULONG ModeNum; // mode index for current VGA mode
71 SIZEL sizeSurf; // displayed size of the surface
72 PBYTE fbScreen; // pointer to the frame buffer
73 RECTL SavedBitsRight; // invisible part right of screen
74 RECTL SavedBitsBottom; // invisible part at the bottom of the screen
75 BOOL BitsSaved; // TRUE if bits are currently saved
76 SIZEL sizeMem; // actual size (in pixels) of video memory
77 LONG NumScansUsedByPointer; // # scans of offscreen memory used by
82 RECTL BankBounds; // Pixels addressable in this bank
83 ULONG BankOffset; // Offset of bank start from bitmap start if linearly addressable
84 } BANK_INFO, *PBANK_INFO;
91 // bank control function vector
92 //typedef VOID (*PFN_BankControl)(PDEVSURF, ULONG, BANK_JUST);
93 typedef VOID (*PFN_BankControl)(PVOID, ULONG, BANK_JUST);
96 // descriptor for a saved screen bits block
98 typedef struct _SAVED_SCREEN_BITS
101 PBYTE pjBuffer; // pointer to save buffer start
102 ULONG ulSize; // size of save buffer (per plane; display memory only)
103 ULONG ulSaveWidthInBytes; // # of bytes across save area (including
104 // partial edge bytes, if any)
105 ULONG ulDelta; // # of bytes from end of one saved scan's saved bits to
106 // start of next (system memory only)
107 PVOID pvNextSSB; // pointer to next saved screen bits block
108 // for system memory blocks, saved bits start immediately
109 // after this structure
110 } SAVED_SCREEN_BITS, *PSAVED_SCREEN_BITS;
112 typedef struct _SAVED_SCREEN_BITS
117 LIST_ENTRY ListEntry;
118 } SAVED_SCREEN_BITS, *PSAVED_SCREEN_BITS;
121 // DEVSURF -- definition of a surface as seen and used by the various VGA
124 typedef struct _DEVSURF
126 IDENT ident; // Identifier for debugging ease
127 ULONG flSurf; // DS_ flags as defined below
128 BYTE Color; // Solid color surface if DS_SOLIDBRUSH
130 // If DS_SOLIDBRUSH, the following fields are undefined and not guaranteed to
131 // have been allocated!
133 BYTE Format; // BMF_*, BMF_PHYSDEVICE
134 BYTE jReserved1; // Reserved
135 BYTE jReserved2; // Reserved
136 PPDEV ppdev; // Pointer to associated PDEV
137 SIZEL sizeSurf; // Size of the surface
138 ULONG NextScan; // Offset from scan "n" to "n+1"
139 ULONG NextPlane; // Offset from plane "n" to "n+1"
140 PVOID Scan0; // Pointer to scan 0 of bitmap
141 // (actual address of start of bank, for banked VGA surface)
142 PVOID StartBmp; // Pointer to start of bitmap
143 PVOID Conv; // Pointer to DIB/Planer conversion buffer
145 // Banking variables; used only for banked VGA surfaces
147 PVIDEO_BANK_SELECT BankSelectInfo;
148 ULONG Bank2RWSkip; // Offset from one bank index to next to make two 32K banks appear to be
149 // one seamless 64K bank
150 PFN pfnBankSwitchCode;
151 VIDEO_BANK_TYPE BankingType;
152 ULONG BitmapSize; // Length of bitmap if there were no banking, in CPU addressable bytes
153 ULONG PtrBankScan; // Last scan line in pointer work bank
154 RECTL WindowClip1; // Single-window banking clip rect
155 RECTL WindowClip2[2]; // Double-window banking clip rects for
157 ULONG WindowBank[2]; // Current banks mapped into windows
158 // 0 & 1 (used in 2 window mode only)
159 PBANK_INFO BankInfo; // Pointer to array of bank clip info
160 ULONG BankInfoLength; // Length of pbiBankInfo, in entries
161 PBANK_INFO BankInfo2RW; // Same as above, but for 2RW window
162 ULONG BankInfo2RWLength; // case
163 PFN_BankControl pfnBankControl; // Pointer to bank control function
164 PFN_BankControl pfnBankControl2Window; // Pointer to double-window bank
166 PVOID BitmapStart; // Single-window bitmap start pointer (adjusted as
167 // necessary to make window map in at proper offset)
168 PVOID BitmapStart2Window[2]; // Double-window window 0 and 1 bitmap start
169 PVOID BankBufferPlane0; // Pointer to temp buffer capable of
170 // storing one full bank for plane 0 for 1
171 // R/W case; capable of storing one full
172 // bank height of edge bytes for all four
173 // planes for the 1R/1W case. Also used to
174 // point to text building buffer in all
175 // cases. This is the pointer used to
176 // dealloc bank working storage for all
179 // The following 3 pointers used by 1 R/W banked devices
180 PVOID BankBufferPlane1; // Like above, but for plane 1
181 PVOID BankBufferPlane2; // Like above, but for plane 2
182 PVOID BankBufferPlane3; // Like above, but for plane 3
183 ULONG TempBufferSize; // Full size of temp buffer pointed to
184 // by pvBankBufferPlane0
186 ULONG ajBits[1]; // Bits will start here for device bitmaps
187 PSAVED_SCREEN_BITS ssbList; // Pointer to start of linked list of
188 // saved screen bit blocks
189 } DEVSURF, *PDEVSURF;
191 typedef VOID (*PFN_ScreenToScreenBlt)(PDEVSURF, PRECTL, PPOINTL, INT);
193 // BMF_PHYSDEVICE format type
195 #define BMF_PHYSDEVICE 0xFF
198 // Identifiers used in debugging (DEVSURF.ident)
200 #define PDEV_IDENT ('V' + ('P' << 8) + ('D' << 16) + ('V' << 24))
201 #define DEVSURF_IDENT ('V' + ('S' << 8) + ('R' << 16) + ('F' << 24))
203 BOOL InitVGA(PPDEV ppdev, BOOL bFirst); // screen.c: initialize VGA mode
205 #define DRIVER_EXTRA_SIZE 0
206 #define ALLOC_TAG TAG('D', 'v', 'g', 'a') // Dvga tag
207 #define DLL_NAME L"vga" // DLL name in Unicode
209 #define MAX_SCAN_WIDTH 2048 // pixels
210 #define DRIVER_OFFSCREEN_REFRESHED 0x04L // if not set, don't use offscreen memory
211 #define PLANAR_PELS_PER_CPU_ADDRESS 8
212 #define PACKED_PELS_PER_CPU_ADDRESS 2
215 SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask, XLATEOBJ *ColorTranslation,
216 RECTL *DestRect, POINTL *SourcePoint);
219 VGADDI_BltFromSavedScreenBits(ULONG DestX,
221 PSAVED_SCREEN_BITS Src,
225 VGADDI_BltToSavedScreenBits(PSAVED_SCREEN_BITS Dest,
231 VGADDI_FreeSavedScreenBits(PSAVED_SCREEN_BITS SavedBits);
233 VGADDI_AllocSavedScreenBits(ULONG Size);
235 VGADDI_InitializeOffScreenMem(ULONG Start, ULONG Length);