2 #include <ddk/winddi.h>
3 #include <ddk/ntddvid.h>
7 #define DS_SOLIDBRUSH 0x00000001
8 #define DS_GREYBRUSH 0x00000002
9 #define DS_BRUSH 0x00000004
10 #define DS_DIB 0x00000008
12 #define POW2(stride) (!((stride) & ((stride)-1))) // TRUE if stride is power of 2
13 #define BROKEN_RASTERS(stride,cy) ((!(POW2(stride))) && ((stride*cy) > 0x10000))
15 #define DM_SPECVERSION 1 // FIXME: What is this really?
16 #define ENUM_RECT_LIMIT 50
18 typedef struct _RECT_ENUM
21 RECTL arcl
[ENUM_RECT_LIMIT
];
25 typedef struct _XYPAIR
32 #define CURSOR_DOWN 0x00000001
33 #define CURSOR_COLOR 0x00000004
34 #define CURSOR_HW 0x00000010
35 #define CURSOR_HW_ACTIVE 0x00000020
36 #define CURSOR_ANIMATE 0x00000040
40 ULONG fl
; // driver flags
44 HDEV GDIDevHandle
; // engine's handle to PDEV
45 HSURF SurfHandle
; // engine's handle to surface
46 PVOID AssociatedSurf
; // associated surface
49 XYPAIR xyCursor
; // cursor position
50 POINTL ptlExtent
; // cursor extent
51 ULONG cExtent
; // effective cursor extent
52 ULONG flCursor
; // cursor status
55 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes
; // HW Pointer Attributes
56 ULONG XorMaskStartOffset
; // Start offset of hardware pointer
57 // XOR mask relative to AND mask for
58 // passing to HW pointer
59 DWORD PointerAttributes
; // Size of buffer allocated
60 DWORD flPreallocSSBBufferInUse
; // True if preallocated saved screen
61 // bits buffer is in use
62 PUCHAR pjPreallocSSBBuffer
; // Pointer to preallocated saved screen
63 // bits buffer, if there is one
64 ULONG ulPreallocSSBSize
; // Size of preallocated saved screen
66 VIDEO_POINTER_CAPABILITIES PointerCapabilities
; // HW pointer abilities
67 PUCHAR pucDIB4ToVGAConvBuffer
; // DIB4->VGA conversion table buffer
68 PUCHAR pucDIB4ToVGAConvTables
; // Pointer to DIB4->VGA conversion
72 ULONG ModeNum
; // mode index for current VGA mode
74 SIZEL sizeSurf
; // displayed size of the surface
76 PBYTE fbScreen
; // pointer to the frame buffer
78 RECTL SavedBitsRight
; // invisible part right of screen
79 RECTL SavedBitsBottom
; // invisible part at the bottom of the screen
80 BOOL BitsSaved
; // TRUE if bits are currently saved
81 SIZEL sizeMem
; // actual size (in pixels) of video memory
82 LONG NumScansUsedByPointer
; // # scans of offscreen memory used by
87 RECTL BankBounds
; // Pixels addressable in this bank
88 ULONG BankOffset
; // Offset of bank start from bitmap start if linearly addressable
89 } BANK_INFO
, *PBANK_INFO
;
96 // bank control function vector
97 //typedef VOID (*PFN_BankControl)(PDEVSURF, ULONG, BANK_JUST);
98 typedef VOID (*PFN_BankControl
)(PVOID
, ULONG
, BANK_JUST
);
100 // descriptor for a saved screen bits block
102 typedef struct _SAVED_SCREEN_BITS
105 PBYTE pjBuffer
; // pointer to save buffer start
106 ULONG ulSize
; // size of save buffer (per plane; display memory only)
107 ULONG ulSaveWidthInBytes
; // # of bytes across save area (including
108 // partial edge bytes, if any)
109 ULONG ulDelta
; // # of bytes from end of one saved scan's saved bits to
110 // start of next (system memory only)
111 PVOID pvNextSSB
; // pointer to next saved screen bits block
112 // for system memory blocks, saved bits start immediately
113 // after this structure
114 } SAVED_SCREEN_BITS
, *PSAVED_SCREEN_BITS
;
116 // DEVSURF -- definition of a surface as seen and used by the various VGA
119 typedef struct _DEVSURF
121 IDENT ident
; // Identifier for debugging ease
122 ULONG flSurf
; // DS_ flags as defined below
123 BYTE Color
; // Solid color surface if DS_SOLIDBRUSH
125 // If DS_SOLIDBRUSH, the following fields are undefined and not guaranteed to
126 // have been allocated!
128 BYTE Format
; // BMF_*, BMF_PHYSDEVICE
129 BYTE jReserved1
; // Reserved
130 BYTE jReserved2
; // Reserved
131 PPDEV ppdev
; // Pointer to associated PDEV
132 SIZEL sizeSurf
; // Size of the surface
133 ULONG NextScan
; // Offset from scan "n" to "n+1"
134 ULONG NextPlane
; // Offset from plane "n" to "n+1"
135 PVOID Scan0
; // Pointer to scan 0 of bitmap
136 // (actual address of start of bank, for banked VGA surface)
137 PVOID StartBmp
; // Pointer to start of bitmap
138 PVOID Conv
; // Pointer to DIB/Planer conversion buffer
140 // Banking variables; used only for banked VGA surfaces
142 PVIDEO_BANK_SELECT BankSelectInfo
;
143 ULONG Bank2RWSkip
; // Offset from one bank index to next to make two 32K banks appear to be
144 // one seamless 64K bank
145 PFN pfnBankSwitchCode
;
146 VIDEO_BANK_TYPE BankingType
;
147 ULONG BitmapSize
; // Length of bitmap if there were no banking, in CPU addressable bytes
148 ULONG PtrBankScan
; // Last scan line in pointer work bank
149 RECTL WindowClip1
; // Single-window banking clip rect
150 RECTL WindowClip2
[2]; // Double-window banking clip rects for
152 ULONG WindowBank
[2]; // Current banks mapped into windows
153 // 0 & 1 (used in 2 window mode only)
154 PBANK_INFO BankInfo
; // Pointer to array of bank clip info
155 ULONG BankInfoLength
; // Length of pbiBankInfo, in entries
156 PBANK_INFO BankInfo2RW
; // Same as above, but for 2RW window
157 ULONG BankInfo2RWLength
; // case
158 PFN_BankControl pfnBankControl
; // Pointer to bank control function
159 PFN_BankControl pfnBankControl2Window
; // Pointer to double-window bank
161 PVOID BitmapStart
; // Single-window bitmap start pointer (adjusted as
162 // necessary to make window map in at proper offset)
163 PVOID BitmapStart2Window
[2]; // Double-window window 0 and 1 bitmap start
164 PVOID BankBufferPlane0
; // Pointer to temp buffer capable of
165 // storing one full bank for plane 0 for 1
166 // R/W case; capable of storing one full
167 // bank height of edge bytes for all four
168 // planes for the 1R/1W case. Also used to
169 // point to text building buffer in all
170 // cases. This is the pointer used to
171 // dealloc bank working storage for all
174 // The following 3 pointers used by 1 R/W banked devices
176 PVOID BankBufferPlane1
; // Like above, but for plane 1
177 PVOID BankBufferPlane2
; // Like above, but for plane 2
178 PVOID BankBufferPlane3
; // Like above, but for plane 3
179 ULONG TempBufferSize
; // Full size of temp buffer pointed to
180 // by pvBankBufferPlane0
182 ULONG ajBits
[1]; // Bits will start here for device bitmaps
183 PSAVED_SCREEN_BITS ssbList
; // Pointer to start of linked list of
184 // saved screen bit blocks
185 } DEVSURF
, *PDEVSURF
;
187 typedef VOID (*PFN_ScreenToScreenBlt
)(PDEVSURF
, PRECTL
, PPOINTL
, INT
);
189 // BMF_PHYSDEVICE format type
191 #define BMF_PHYSDEVICE 0xFF
194 // Identifiers used in debugging (DEVSURF.ident)
196 #define PDEV_IDENT ('V' + ('P' << 8) + ('D' << 16) + ('V' << 24))
197 #define DEVSURF_IDENT ('V' + ('S' << 8) + ('R' << 16) + ('F' << 24))
199 BOOL
InitVGA(PPDEV ppdev
, BOOL bFirst
); // screen.c: initialize VGA mode
201 #define DRIVER_EXTRA_SIZE 0
202 #define ALLOC_TAG 'agvD' // Dvga reversed
203 #define DLL_NAME L"vga" // DLL name in Unicode
205 #define MAX_SCAN_WIDTH 2048 // pixels
206 #define DRIVER_OFFSCREEN_REFRESHED 0x04L // if not set, don't use offscreen memory
207 #define PLANAR_PELS_PER_CPU_ADDRESS 8
208 #define PACKED_PELS_PER_CPU_ADDRESS 2