ReactOS 0.4.15-dev-5669-g09dde2c
driver.h File Reference
#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"framebuf"
 
#define STANDARD_DEBUG_PREFIX   "FRAMEBUF: "
 
#define ALLOC_TAG   'bfDD'
 

Typedefs

typedef struct _PDEV PDEV
 
typedef struct _PDEVPPDEV
 

Functions

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

Macro Definition Documentation

◆ ALLOC_TAG

#define ALLOC_TAG   'bfDD'

Definition at line 75 of file driver.h.

◆ DLL_NAME

#define DLL_NAME   L"framebuf"

Definition at line 73 of file driver.h.

◆ DRIVER_EXTRA_SIZE

#define DRIVER_EXTRA_SIZE   0

Definition at line 71 of file driver.h.

◆ MAX_CLUT_SIZE

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

Definition at line 64 of file driver.h.

◆ STANDARD_DEBUG_PREFIX

#define STANDARD_DEBUG_PREFIX   "FRAMEBUF: "

Definition at line 74 of file driver.h.

Typedef Documentation

◆ PDEV

typedef struct _PDEV PDEV

◆ PPDEV

typedef struct _PDEV * PPDEV

Function Documentation

◆ bInit256ColorPalette()

BOOL NTAPI bInit256ColorPalette ( PPDEV  ppdev)

Definition at line 193 of file palette.c.

194{
195 BYTE ajClutSpace[MAX_CLUT_SIZE];
196 PVIDEO_CLUT pScreenClut;
197 ULONG ulReturnedDataLength;
198 ULONG cColors;
199 PVIDEO_CLUTDATA pScreenClutData;
200
201 if (ppdev->ulBitCount == 8)
202 {
203 //
204 // Fill in pScreenClut header info:
205 //
206
207 pScreenClut = (PVIDEO_CLUT) ajClutSpace;
208 pScreenClut->NumEntries = 256;
209 pScreenClut->FirstEntry = 0;
210
211 //
212 // Copy colours in:
213 //
214
215 cColors = 256;
216 pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0]));
217
218 while(cColors--)
219 {
220 pScreenClutData[cColors].Red = ppdev->pPal[cColors].peRed >>
221 ppdev->cPaletteShift;
222 pScreenClutData[cColors].Green = ppdev->pPal[cColors].peGreen >>
223 ppdev->cPaletteShift;
224 pScreenClutData[cColors].Blue = ppdev->pPal[cColors].peBlue >>
225 ppdev->cPaletteShift;
226 pScreenClutData[cColors].Unused = 0;
227 }
228
229 //
230 // Set palette registers:
231 //
232
233 if (EngDeviceIoControl(ppdev->hDriver,
235 pScreenClut,
237 NULL,
238 0,
239 &ulReturnedDataLength))
240 {
241 DISPDBG((0, "Failed bEnablePalette"));
242 return(FALSE);
243 }
244 }
245
246 DISPDBG((5, "Passed bEnablePalette"));
247
248 return(TRUE);
249}
#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:149
struct VIDEO_CLUT * PVIDEO_CLUT
struct _VIDEO_CLUTDATA * PVIDEO_CLUTDATA
union VIDEO_CLUT::@3144 LookupTable[1]
USHORT FirstEntry
Definition: ntddvdeo.h:521
USHORT NumEntries
Definition: ntddvdeo.h:520
ULONG cPaletteShift
Definition: driver.h:39
PALETTEENTRY * pPal
Definition: driver.h:48
ULONG ulBitCount
Definition: driver.h:42
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:64
unsigned char BYTE
Definition: xxhash.c:193

Referenced by DrvEnableSurface().

◆ bInitPaletteInfo()

BOOL NTAPI bInitPaletteInfo ( PPDEV  ppdev,
DEVINFO pDevInfo 
)

Definition at line 50 of file palette.c.

51{
52 if (!bInitDefaultPalette(ppdev, pDevInfo))
53 return(FALSE);
54
55 return(TRUE);
56}
BOOL NTAPI bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo)
Definition: palette.c:86

Referenced by DrvEnablePDEV().

◆ bInitPDEV()

BOOL NTAPI bInitPDEV ( PPDEV  ,
PDEVMODEW  ,
GDIINFO ,
DEVINFO  
)

Referenced by DrvEnablePDEV().

◆ bInitPointer()

BOOL NTAPI bInitPointer ( PPDEV  ppdev,
DEVINFO pdevinfo 
)

Definition at line 400 of file pointer.c.

401{
402 DWORD returnedDataLength;
403
404 ppdev->pPointerAttributes = NULL;
405 ppdev->cjPointerAttributes = 0; // initialized in screen.c
406
407 //
408 // Ask the miniport whether it provides pointer support.
409 //
410
411 if (EngDeviceIoControl(ppdev->hDriver,
413 NULL,
414 0,
415 &ppdev->PointerCapabilities,
416 sizeof(ppdev->PointerCapabilities),
417 &returnedDataLength))
418 {
419 return(FALSE);
420 }
421
422 //
423 // If neither mono nor color hardware pointer is supported, there's no
424 // hardware pointer support and we're done.
425 //
426
429 {
430 return(TRUE);
431 }
432
433 //
434 // Note: The buffer itself is allocated after we set the
435 // mode. At that time we know the pixel depth and we can
436 // allocate the correct size for the color pointer if supported.
437 //
438
439 //
440 // Set the asynchronous support status (async means miniport is capable of
441 // drawing the Pointer at any time, with no interference with any ongoing
442 // drawing operation)
443 //
444
446 {
447 pdevinfo->flGraphicsCaps |= GCAPS_ASYNCMOVE;
448 }
449 else
450 {
451 pdevinfo->flGraphicsCaps &= ~GCAPS_ASYNCMOVE;
452 }
453
454 return(TRUE);
455}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define VIDEO_MODE_MONO_POINTER
Definition: ntddvdeo.h:455
#define IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES
Definition: ntddvdeo.h:128
#define VIDEO_MODE_ASYNC_POINTER
Definition: ntddvdeo.h:454
#define VIDEO_MODE_COLOR_POINTER
Definition: ntddvdeo.h:456
FLONG flGraphicsCaps
Definition: winddi.h:390
VIDEO_POINTER_CAPABILITIES PointerCapabilities
Definition: driver.h:44
DWORD cjPointerAttributes
Definition: driver.h:46
PVIDEO_POINTER_ATTRIBUTES pPointerAttributes
Definition: driver.h:45
#define GCAPS_ASYNCMOVE
Definition: winddi.h:335

Referenced by DrvEnablePDEV().

◆ bInitSURF()

BOOL NTAPI bInitSURF ( PPDEV  ppdev,
BOOL  bFirst 
)

Definition at line 43 of file screen.c.

44{
45 DWORD returnedDataLength;
46 DWORD MaxWidth, MaxHeight;
47 VIDEO_MEMORY videoMemory;
48 VIDEO_MEMORY_INFORMATION videoMemoryInformation;
49// eVb: 2.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping
50 ULONG RemappingNeeded = 0;
51// eVb: 2.1 [END]
52 //
53 // Set the current mode into the hardware.
54 //
55
56 if (EngDeviceIoControl(ppdev->hDriver,
58 &(ppdev->ulMode),
59 sizeof(ULONG),
60// eVb: 2.2 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping
61 &RemappingNeeded,
62 sizeof(ULONG),
63// eVb: 2.2 [END]
64 &returnedDataLength))
65 {
66 RIP("DISP bInitSURF failed IOCTL_SET_MODE\n");
67 return(FALSE);
68 }
69
70 //
71 // If this is the first time we enable the surface we need to map in the
72 // memory also.
73 //
74// eVb: 2.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping
75 if (bFirst || RemappingNeeded)
76 {
77// eVb: 2.3 [END]
78 videoMemory.RequestedVirtualAddress = NULL;
79
80 if (EngDeviceIoControl(ppdev->hDriver,
82 &videoMemory,
83 sizeof(VIDEO_MEMORY),
84 &videoMemoryInformation,
86 &returnedDataLength))
87 {
88 RIP("DISP bInitSURF failed IOCTL_VIDEO_MAP\n");
89 return(FALSE);
90 }
91
92 ppdev->pjScreen = (PBYTE)(videoMemoryInformation.FrameBufferBase);
93
94 if (videoMemoryInformation.FrameBufferBase !=
95 videoMemoryInformation.VideoRamBase)
96 {
97 RIP("VideoRamBase does not correspond to FrameBufferBase\n");
98 }
99// eVb: 2.4 [DDK Change] - Make sure frame buffer mapping worked
100 //
101 // Make sure we can access this video memory
102 //
103
104 *(PULONG)(ppdev->pjScreen) = 0xaa55aa55;
105
106 if (*(PULONG)(ppdev->pjScreen) != 0xaa55aa55) {
107
108 DISPDBG((1, "Frame buffer memory is not accessible.\n"));
109 return(FALSE);
110 }
111// eVb: 2.4 [END]
112 ppdev->cScreenSize = videoMemoryInformation.VideoRamLength;
113
114 //
115 // Initialize the head of the offscreen list to NULL.
116 //
117
118 ppdev->pOffscreenList = NULL;
119
120 // It's a hardware pointer; set up pointer attributes.
121
122 MaxHeight = ppdev->PointerCapabilities.MaxHeight;
123
124 // Allocate space for two DIBs (data/mask) for the pointer. If this
125 // device supports a color Pointer, we will allocate a larger bitmap.
126 // If this is a color bitmap we allocate for the largest possible
127 // bitmap because we have no idea of what the pixel depth might be.
128
129 // Width rounded up to nearest byte multiple
130
132 {
133 MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8;
134 }
135 else
136 {
137 MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD);
138 }
139
140 ppdev->cjPointerAttributes =
142 ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2);
143
146
147 if (ppdev->pPointerAttributes == NULL) {
148
149 DISPDBG((0, "bInitPointer EngAllocMem failed\n"));
150 return(FALSE);
151 }
152
154 ppdev->pPointerAttributes->WidthInBytes = MaxWidth;
156 ppdev->pPointerAttributes->Height = MaxHeight;
157 ppdev->pPointerAttributes->Column = 0;
158 ppdev->pPointerAttributes->Row = 0;
159 ppdev->pPointerAttributes->Enable = 0;
160 }
161
162 return(TRUE);
163}
#define ALLOC_TAG
Definition: btrfs_drv.h:87
#define DWORD
Definition: nt_native.h:44
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:104
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:152
struct _VIDEO_POINTER_ATTRIBUTES VIDEO_POINTER_ATTRIBUTES
struct _VIDEO_POINTER_ATTRIBUTES * PVIDEO_POINTER_ATTRIBUTES
BYTE * PBYTE
Definition: pedump.c:66
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
PBYTE pjScreen
Definition: driver.h:28
ULONG cScreenSize
Definition: driver.h:33
PVOID pOffscreenList
Definition: driver.h:35
ULONG ulMode
Definition: driver.h:31
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:275
uint32_t * PULONG
Definition: typedefs.h:59
#define RIP(x)
Definition: debug.h:24
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DrvAssertMode(), and DrvEnableSurface().

◆ getAvailableModes()

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

Definition at line 507 of file screen.c.

511{
512 ULONG ulTemp;
513 VIDEO_NUM_MODES modes;
514 PVIDEO_MODE_INFORMATION pVideoTemp;
515
516 //
517 // Get the number of modes supported by the mini-port
518 //
519
520 if (EngDeviceIoControl(hDriver,
522 NULL,
523 0,
524 &modes,
525 sizeof(VIDEO_NUM_MODES),
526 &ulTemp))
527 {
528 DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_NUM_AVAIL_MODES\n"));
529 return 0;
530 }
531
532 *cbModeSize = modes.ModeInformationLength;
533
534 //
535 // Allocate the buffer for the mini-port to write the modes in.
536 //
537
538 *modeInformation = (PVIDEO_MODE_INFORMATION)
539 EngAllocMem(0, modes.NumModes *
541
542 if (*modeInformation == NULL)
543 {
544 DISPDBG((0, "getAvailableModes failed EngAllocMem\n"));
545
546 return 0;
547 }
548
549 //
550 // Ask the mini-port to fill in the available modes.
551 //
552
553 if (EngDeviceIoControl(hDriver,
555 NULL,
556 0,
557 *modeInformation,
558 modes.NumModes * modes.ModeInformationLength,
559 &ulTemp))
560 {
561
562 DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_AVAIL_MODES\n"));
563
564 EngFreeMem(*modeInformation);
565 *modeInformation = NULL;
566
567 return 0;
568 }
569
570 //
571 // Now see which of these modes are supported by the display driver.
572 // As an internal mechanism, set the length to 0 for the modes we
573 // DO NOT support.
574 //
575
576 ulTemp = modes.NumModes;
577 pVideoTemp = *modeInformation;
578
579 //
580 // Mode is rejected if it is not one plane, or not graphics, or is not
581 // one of 8, 16 or 32 bits per pel.
582 //
583
584 while (ulTemp--)
585 {
586 if ((pVideoTemp->NumberOfPlanes != 1 ) ||
587 !(pVideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) ||
588// eVb: 2.6 [DDK CHANGE] - Do not process banked video modes
589 (pVideoTemp->AttributeFlags & VIDEO_MODE_BANKED) ||
590// eVb: 2.6 [END]
591 ((pVideoTemp->BitsPerPlane != 8) &&
592 (pVideoTemp->BitsPerPlane != 16) &&
593 (pVideoTemp->BitsPerPlane != 24) &&
594 (pVideoTemp->BitsPerPlane != 32)))
595 {
596 pVideoTemp->Length = 0;
597 }
598
599 pVideoTemp = (PVIDEO_MODE_INFORMATION)
600 (((PUCHAR)pVideoTemp) + modes.ModeInformationLength);
601 }
602
603 return modes.NumModes;
604
605}
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:295
struct _VIDEO_MODE_INFORMATION * PVIDEO_MODE_INFORMATION
#define VIDEO_MODE_BANKED
Definition: ntddvdeo.h:301
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:107
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:122
#define EngFreeMem
Definition: polytest.cpp:56
ULONG ModeInformationLength
Definition: ntddvdeo.h:329
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

Referenced by DrvGetModes().

◆ vDisablePalette()

VOID NTAPI vDisablePalette ( PPDEV  ppdev)

Definition at line 65 of file palette.c.

66{
67// Delete the default palette if we created one.
68
69 if (ppdev->hpalDefault)
70 {
72 ppdev->hpalDefault = NULL;
73 }
74
75 if (ppdev->pPal != NULL)
76 EngFreeMem((PVOID)ppdev->pPal);
77}
HPALETTE hpalDefault
Definition: driver.h:27
ENGAPI BOOL APIENTRY EngDeletePalette(_In_ _Post_ptr_invalid_ HPALETTE hpal)

Referenced by DrvDisablePDEV().

◆ vDisableSURF()

VOID NTAPI vDisableSURF ( PPDEV  ppdev)

Definition at line 172 of file screen.c.

173{
174 DWORD returnedDataLength;
175 VIDEO_MEMORY videoMemory;
176
177 videoMemory.RequestedVirtualAddress = (PVOID) ppdev->pjScreen;
178
179 if (EngDeviceIoControl(ppdev->hDriver,
181 &videoMemory,
182 sizeof(VIDEO_MEMORY),
183 NULL,
184 0,
185 &returnedDataLength))
186 {
187 RIP("DISP vDisableSURF failed IOCTL_VIDEO_UNMAP\n");
188 }
189}
if(dx< 0)
Definition: linetemp.h:194
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:179
void * PVOID
Definition: typedefs.h:50

Referenced by DrvDisableSurface().