ReactOS 0.4.16-dev-297-gc569aee
driver.h File Reference
#include "stddef.h"
#include <stdarg.h>
#include "windef.h"
#include "wingdi.h"
#include "winddi.h"
#include "devioctl.h"
#include "ntddvdeo.h"
#include "debug.h"
Include dependency graph for driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PDEV
 

Macros

#define MAX_CLUT_SIZE   (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
 
#define DRIVER_EXTRA_SIZE   0
 
#define DLL_NAME   L"vga"
 
#define STANDARD_DEBUG_PREFIX   "Vga risc: "
 
#define ALLOC_TAG   'rgvD'
 
#define VAL(data, px, pl, pos)   ((data) >> (((px) * 4) + (pl)) & 1) << (pos)
 
#define SET_PLANE_DATA(x, y, a, b)    (x) |= VAL(y, (((-1 + ((((b) % 8) % 2) << 1) - (((b) % 8) + 1) + 8))), a, b)
 
#define ALIGN_DOWN_BY(size, align)    ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
 
#define ALIGN_UP_BY(size, align)    (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
 

Typedefs

typedef struct _PDEV PDEV
 
typedef struct _PDEVPPDEV
 

Functions

DWORD getAvailableModes (HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *)
 
BOOL bInitPDEV (PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *)
 
BOOL bInitSURF (PPDEV, BOOL)
 
BOOL bInitPaletteInfo (PPDEV, DEVINFO *)
 
BOOL bInitPointer (PPDEV, DEVINFO *)
 
BOOL bInit256ColorPalette (PPDEV)
 
VOID vDisablePalette (PPDEV)
 
VOID vDisableSURF (PPDEV)
 

Macro Definition Documentation

◆ ALIGN_DOWN_BY

#define ALIGN_DOWN_BY (   size,
  align 
)     ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))

Definition at line 101 of file driver.h.

◆ ALIGN_UP_BY

#define ALIGN_UP_BY (   size,
  align 
)     (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))

Definition at line 104 of file driver.h.

◆ ALLOC_TAG

#define ALLOC_TAG   'rgvD'

Definition at line 78 of file driver.h.

◆ DLL_NAME

#define DLL_NAME   L"vga"

Definition at line 76 of file driver.h.

◆ DRIVER_EXTRA_SIZE

#define DRIVER_EXTRA_SIZE   0

Definition at line 73 of file driver.h.

◆ MAX_CLUT_SIZE

#define MAX_CLUT_SIZE   (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))

Definition at line 66 of file driver.h.

◆ SET_PLANE_DATA

#define SET_PLANE_DATA (   x,
  y,
  a,
  b 
)     (x) |= VAL(y, (((-1 + ((((b) % 8) % 2) << 1) - (((b) % 8) + 1) + 8))), a, b)

Definition at line 97 of file driver.h.

◆ STANDARD_DEBUG_PREFIX

#define STANDARD_DEBUG_PREFIX   "Vga risc: "

Definition at line 77 of file driver.h.

◆ VAL

#define VAL (   data,
  px,
  pl,
  pos 
)    ((data) >> (((px) * 4) + (pl)) & 1) << (pos)

Definition at line 91 of file driver.h.

Typedef Documentation

◆ PDEV

typedef struct _PDEV PDEV

◆ PPDEV

typedef struct _PDEV * PPDEV

Function Documentation

◆ bInit256ColorPalette()

BOOL bInit256ColorPalette ( PPDEV  ppdev)

Definition at line 226 of file palette.c.

227{
228 BYTE ajClutSpace[MAX_CLUT_SIZE];
229 PVIDEO_CLUT pScreenClut;
230 ULONG ulReturnedDataLength;
231 ULONG cColors;
232 PVIDEO_CLUTDATA pScreenClutData;
233
234 if (ppdev->ulBitCount == 8)
235 {
236 //
237 // Fill in pScreenClut header info:
238 //
239
240 pScreenClut = (PVIDEO_CLUT) ajClutSpace;
241 pScreenClut->NumEntries = 256;
242 pScreenClut->FirstEntry = 0;
243
244 //
245 // Copy colours in:
246 //
247
248 cColors = 256;
249 pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0]));
250
251 while(cColors--)
252 {
253 pScreenClutData[cColors].Red = ppdev->pPal[cColors].peRed >>
254 ppdev->cPaletteShift;
255 pScreenClutData[cColors].Green = ppdev->pPal[cColors].peGreen >>
256 ppdev->cPaletteShift;
257 pScreenClutData[cColors].Blue = ppdev->pPal[cColors].peBlue >>
258 ppdev->cPaletteShift;
259 pScreenClutData[cColors].Unused = 0;
260 }
261
262 //
263 // Set palette registers:
264 //
265
266 if (EngDeviceIoControl(ppdev->hDriver,
268 pScreenClut,
270 NULL,
271 0,
272 &ulReturnedDataLength))
273 {
274 DISPDBG((0, "Failed bEnablePalette"));
275 return(FALSE);
276 }
277 }
278
279 DISPDBG((5, "Passed bEnablePalette"));
280
281 return(TRUE);
282}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:218
struct VIDEO_CLUT * PVIDEO_CLUT
struct _VIDEO_CLUTDATA * PVIDEO_CLUTDATA
union VIDEO_CLUT::@3174 LookupTable[1]
USHORT FirstEntry
Definition: ntddvdeo.h:590
USHORT NumEntries
Definition: ntddvdeo.h:589
ULONG cPaletteShift
Definition: driver.h:37
ULONG ulBitCount
Definition: driver.h:40
PALETTEENTRY * pPal
Definition: driver.h:46
HANDLE hDriver
Definition: framebuf.h:35
uint32_t ULONG
Definition: typedefs.h:59
#define DISPDBG(arg)
Definition: debug.h:23
#define MAX_CLUT_SIZE
Definition: driver.h:66
unsigned char BYTE
Definition: xxhash.c:193

Referenced by DrvEnableSurface().

◆ bInitPaletteInfo()

BOOL bInitPaletteInfo ( PPDEV  ppdev,
DEVINFO pDevInfo 
)

Definition at line 67 of file palette.c.

68{
69 if (!bInitDefaultPalette(ppdev, pDevInfo))
70 return(FALSE);
71
72 return(TRUE);
73}
BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo)
Definition: palette.c:107

Referenced by DrvEnablePDEV().

◆ bInitPDEV()

BOOL bInitPDEV ( PPDEV  ,
PDEVMODEW  ,
GDIINFO ,
DEVINFO  
)

Referenced by DrvEnablePDEV().

◆ bInitPointer()

BOOL bInitPointer ( PPDEV  ,
DEVINFO  
)

Referenced by DrvEnablePDEV().

◆ bInitSURF()

BOOL bInitSURF ( PPDEV  ppdev,
BOOL  bFirst 
)

Definition at line 168 of file screen.c.

169{
170 DWORD returnedDataLength;
171 DWORD MaxWidth, MaxHeight;
172 VIDEO_MEMORY videoMemory;
173 VIDEO_MEMORY_INFORMATION videoMemoryInformation;
174// eVb: 2.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping
175 ULONG RemappingNeeded = 0;
176// eVb: 2.1 [END]
177 //
178 // Set the current mode into the hardware.
179 //
180
181 if (EngDeviceIoControl(ppdev->hDriver,
183 &(ppdev->ulMode),
184 sizeof(ULONG),
185// eVb: 2.2 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping
186 &RemappingNeeded,
187 sizeof(ULONG),
188// eVb: 2.2 [END]
189 &returnedDataLength))
190 {
191 RIP("DISP bInitSURF failed IOCTL_SET_MODE\n");
192 return(FALSE);
193 }
194
195 //
196 // If this is the first time we enable the surface we need to map in the
197 // memory also.
198 //
199// eVb: 2.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping
200 if (bFirst || RemappingNeeded)
201 {
202// eVb: 2.3 [END]
203 videoMemory.RequestedVirtualAddress = NULL;
204
205 if (EngDeviceIoControl(ppdev->hDriver,
207 &videoMemory,
208 sizeof(VIDEO_MEMORY),
209 &videoMemoryInformation,
211 &returnedDataLength))
212 {
213 RIP("DISP bInitSURF failed IOCTL_VIDEO_MAP\n");
214 return(FALSE);
215 }
216
217 ppdev->pjScreen = (PBYTE)(videoMemoryInformation.FrameBufferBase);
218
219 if (videoMemoryInformation.FrameBufferBase !=
220 videoMemoryInformation.VideoRamBase)
221 {
222 RIP("VideoRamBase does not correspond to FrameBufferBase\n");
223 }
224// eVb: 2.4 [DDK Change] - Make sure frame buffer mapping worked
225 //
226 // Make sure we can access this video memory
227 //
228
229 *(PULONG)(ppdev->pjScreen) = 0xaa55aa55;
230
231 if (*(PULONG)(ppdev->pjScreen) != 0xaa55aa55) {
232
233 DISPDBG((1, "Frame buffer memory is not accessible.\n"));
234 return(FALSE);
235 }
236// eVb: 2.4 [END]
237 ppdev->cScreenSize = videoMemoryInformation.VideoRamLength;
238
239 //
240 // Initialize the head of the offscreen list to NULL.
241 //
242
243 ppdev->pOffscreenList = NULL;
244
245 // It's a hardware pointer; set up pointer attributes.
246
248
249 // Allocate space for two DIBs (data/mask) for the pointer. If this
250 // device supports a color Pointer, we will allocate a larger bitmap.
251 // If this is a color bitmap we allocate for the largest possible
252 // bitmap because we have no idea of what the pixel depth might be.
253
254 // Width rounded up to nearest byte multiple
255
257 {
258 MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8;
259 }
260 else
261 {
262 MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD);
263 }
264
265 ppdev->cjPointerAttributes =
267 ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2);
268
271
272 if (ppdev->pPointerAttributes == NULL) {
273
274 DISPDBG((0, "bInitPointer EngAllocMem failed\n"));
275 return(FALSE);
276 }
277
279 ppdev->pPointerAttributes->WidthInBytes = MaxWidth;
282 ppdev->pPointerAttributes->Column = 0;
283 ppdev->pPointerAttributes->Row = 0;
284 ppdev->pPointerAttributes->Enable = 0;
285 }
286
287 return(TRUE);
288}
#define ALLOC_TAG
Definition: btrfs_drv.h:87
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DWORD
Definition: nt_native.h:44
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:173
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:221
struct _VIDEO_POINTER_ATTRIBUTES VIDEO_POINTER_ATTRIBUTES
struct _VIDEO_POINTER_ATTRIBUTES * PVIDEO_POINTER_ATTRIBUTES
#define VIDEO_MODE_COLOR_POINTER
Definition: ntddvdeo.h:525
BYTE * PBYTE
Definition: pedump.c:66
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
VIDEO_POINTER_CAPABILITIES PointerCapabilities
Definition: vgaddi.h:129
DWORD cjPointerAttributes
Definition: driver.h:44
PBYTE pjScreen
Definition: driver.h:26
PVIDEO_POINTER_ATTRIBUTES pPointerAttributes
Definition: vgaddi.h:117
ULONG cScreenSize
Definition: driver.h:31
PVOID pOffscreenList
Definition: driver.h:33
ULONG ulMode
Definition: driver.h:29
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:344
uint32_t * PULONG
Definition: typedefs.h:59
#define RIP(x)
Definition: debug.h:24
#define MaxHeight
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DrvAssertMode(), and DrvEnableSurface().

◆ getAvailableModes()

DWORD getAvailableModes ( HANDLE  hDriver,
PVIDEO_MODE_INFORMATION modeInformation,
DWORD cbModeSize 
)

Definition at line 651 of file screen.c.

655{
656 ULONG ulTemp;
657 VIDEO_NUM_MODES modes;
658 PVIDEO_MODE_INFORMATION pVideoTemp;
659
660 //
661 // Get the number of modes supported by the mini-port
662 //
663
664 if (EngDeviceIoControl(hDriver,
666 NULL,
667 0,
668 &modes,
669 sizeof(VIDEO_NUM_MODES),
670 &ulTemp))
671 {
672 DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_NUM_AVAIL_MODES\n"));
673 return 0;
674 }
675
676 *cbModeSize = modes.ModeInformationLength;
677
678 //
679 // Allocate the buffer for the mini-port to write the modes in.
680 //
681
682 *modeInformation = (PVIDEO_MODE_INFORMATION)
683 EngAllocMem(0, modes.NumModes *
685
686 if (*modeInformation == NULL)
687 {
688 DISPDBG((0, "getAvailableModes failed EngAllocMem\n"));
689
690 return 0;
691 }
692
693 //
694 // Ask the mini-port to fill in the available modes.
695 //
696
697 if (EngDeviceIoControl(hDriver,
699 NULL,
700 0,
701 *modeInformation,
702 modes.NumModes * modes.ModeInformationLength,
703 &ulTemp))
704 {
705
706 DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_AVAIL_MODES\n"));
707
708 EngFreeMem(*modeInformation);
709 *modeInformation = NULL;
710
711 return 0;
712 }
713
714 //
715 // Now see which of these modes are supported by the display driver.
716 // As an internal mechanism, set the length to 0 for the modes we
717 // DO NOT support.
718 //
719
720 ulTemp = modes.NumModes;
721 pVideoTemp = *modeInformation;
722
723// eVb: 2.5 [VGARISC CHANGE] - Add correct mode checks for VGA
724 //
725 // Mode is rejected if it is not 4 planes, or not graphics, or is not
726 // one of 1 bits per pel.
727 //
728
729 while (ulTemp--)
730 {
731 if ((pVideoTemp->NumberOfPlanes != 4 ) ||
732 !(pVideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) ||
733 ((pVideoTemp->BitsPerPlane != 1) ||
734 (pVideoTemp->VisScreenWidth > 800)))
735// eVb: 2.5 [END]
736 {
737 pVideoTemp->Length = 0;
738 }
739
740 pVideoTemp = (PVIDEO_MODE_INFORMATION)
741 (((PUCHAR)pVideoTemp) + modes.ModeInformationLength);
742 }
743
744 return modes.NumModes;
745
746}
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:364
struct _VIDEO_MODE_INFORMATION * PVIDEO_MODE_INFORMATION
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:176
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:191
#define EngFreeMem
Definition: polytest.cpp:56
ULONG ModeInformationLength
Definition: ntddvdeo.h:398
unsigned char * PUCHAR
Definition: typedefs.h:53
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3557

◆ vDisablePalette()

VOID vDisablePalette ( PPDEV  ppdev)

Definition at line 82 of file palette.c.

83{
84// Delete the default palette if we created one.
85
86 if (ppdev->hpalDefault)
87 {
89 ppdev->hpalDefault = NULL;
90 }
91
92// eVb: 4.2 [VGARISC Change] - VGA Palette is static, no need to free
93#if 0
94 if (ppdev->pPal != NULL)
95 EngFreeMem((PVOID)ppdev->pPal);
96#endif
97// eVb: 4.2 [END]
98}
HPALETTE hpalDefault
Definition: driver.h:25
ENGAPI BOOL APIENTRY EngDeletePalette(_In_ _Post_ptr_invalid_ HPALETTE hpal)

Referenced by DrvDisablePDEV().

◆ vDisableSURF()

VOID vDisableSURF ( PPDEV  ppdev)

Definition at line 297 of file screen.c.

298{
299 DWORD returnedDataLength;
300 VIDEO_MEMORY videoMemory;
301
302 videoMemory.RequestedVirtualAddress = (PVOID) ppdev->pjScreen;
303
304 if (EngDeviceIoControl(ppdev->hDriver,
306 &videoMemory,
307 sizeof(VIDEO_MEMORY),
308 NULL,
309 0,
310 &returnedDataLength))
311 {
312 RIP("DISP vDisableSURF failed IOCTL_VIDEO_UNMAP\n");
313 }
314}
if(dx< 0)
Definition: linetemp.h:194
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:248
void * PVOID
Definition: typedefs.h:50

Referenced by DrvDisableSurface().