ReactOS  0.4.14-dev-358-gbef841c
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  )

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 TRUE
Definition: types.h:120
USHORT FirstEntry
Definition: ntddvdeo.h:520
struct VIDEO_CLUT * PVIDEO_CLUT
smooth NULL
Definition: ftsmooth.c:416
USHORT NumEntries
Definition: ntddvdeo.h:519
#define DISPDBG(arg)
Definition: debug.h:23
unsigned char BYTE
Definition: mem.h:68
#define MAX_CLUT_SIZE
Definition: driver.h:64
unsigned int ULONG
Definition: retypes.h:1
struct _VIDEO_CLUTDATA * PVIDEO_CLUTDATA
union VIDEO_CLUT::@3066 LookupTable[1]
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:149

◆ bInitPaletteInfo()

BOOL bInitPaletteInfo ( PPDEV  ,
DEVINFO  
)

Definition at line 50 of file palette.c.

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

◆ bInitPDEV()

BOOL bInitPDEV ( PPDEV  ,
PDEVMODEW  ,
GDIINFO ,
DEVINFO  
)

◆ bInitPointer()

BOOL bInitPointer ( PPDEV  ,
DEVINFO  
)

Definition at line 400 of file pointer.c.

401 {
402  DWORD returnedDataLength;
403 
404  ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES) 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 
427  if ((!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER)) &&
428  (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER)))
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 
445  if (ppdev->PointerCapabilities.Flags & VIDEO_MODE_ASYNC_POINTER)
446  {
447  pdevinfo->flGraphicsCaps |= GCAPS_ASYNCMOVE;
448  }
449  else
450  {
451  pdevinfo->flGraphicsCaps &= ~GCAPS_ASYNCMOVE;
452  }
453 
454  return(TRUE);
455 }
#define TRUE
Definition: types.h:120
#define VIDEO_MODE_COLOR_POINTER
Definition: ntddvdeo.h:455
#define IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES
Definition: ntddvdeo.h:128
#define VIDEO_MODE_MONO_POINTER
Definition: ntddvdeo.h:454
#define GCAPS_ASYNCMOVE
Definition: winddi.h:335
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _VIDEO_POINTER_ATTRIBUTES * PVIDEO_POINTER_ATTRIBUTES
#define VIDEO_MODE_ASYNC_POINTER
Definition: ntddvdeo.h:453

◆ bInitSURF()

BOOL bInitSURF ( PPDEV  ,
BOOL   
)

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 
131  if (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER))
132  {
133  MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8;
134  }
135  else
136  {
137  MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD);
138  }
139 
140  ppdev->cjPointerAttributes =
141  sizeof(VIDEO_POINTER_ATTRIBUTES) +
142  ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2);
143 
144  ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES)
145  EngAllocMem(0, ppdev->cjPointerAttributes, ALLOC_TAG);
146 
147  if (ppdev->pPointerAttributes == NULL) {
148 
149  DISPDBG((0, "bInitPointer EngAllocMem failed\n"));
150  return(FALSE);
151  }
152 
153  ppdev->pPointerAttributes->Flags = ppdev->PointerCapabilities.Flags;
154  ppdev->pPointerAttributes->WidthInBytes = MaxWidth;
155  ppdev->pPointerAttributes->Width = ppdev->PointerCapabilities.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 }
struct _VIDEO_POINTER_ATTRIBUTES VIDEO_POINTER_ATTRIBUTES
#define TRUE
Definition: types.h:120
#define VIDEO_MODE_COLOR_POINTER
Definition: ntddvdeo.h:455
#define RIP(x)
Definition: debug.h:24
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:104
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:274
#define DWORD
Definition: nt_native.h:44
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:152
#define ALLOC_TAG
Definition: btrfs_drv.h:91
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DISPDBG(arg)
Definition: debug.h:23
struct _VIDEO_POINTER_ATTRIBUTES * PVIDEO_POINTER_ATTRIBUTES
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
BYTE * PBYTE
Definition: pedump.c:66

◆ getAvailableModes()

DWORD getAvailableModes ( HANDLE  ,
PVIDEO_MODE_INFORMATION ,
DWORD  
)

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 == (PVIDEO_MODE_INFORMATION) 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 = (PVIDEO_MODE_INFORMATION) 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 }
ULONG ModeInformationLength
Definition: ntddvdeo.h:328
#define EngFreeMem
Definition: polytest.cpp:56
unsigned char * PUCHAR
Definition: retypes.h:3
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3553
#define ALLOC_TAG
Definition: btrfs_drv.h:91
struct _VIDEO_MODE_INFORMATION * PVIDEO_MODE_INFORMATION
smooth NULL
Definition: ftsmooth.c:416
#define VIDEO_MODE_BANKED
Definition: ntddvdeo.h:300
#define DISPDBG(arg)
Definition: debug.h:23
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:122
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:107
unsigned int ULONG
Definition: retypes.h:1
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:294

Referenced by bInitPDEV().

◆ vDisablePalette()

VOID vDisablePalette ( 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  {
71  EngDeletePalette(ppdev->hpalDefault);
72  ppdev->hpalDefault = (HPALETTE) 0;
73  }
74 
75  if (ppdev->pPal != (PPALETTEENTRY)NULL)
76  EngFreeMem((PVOID)ppdev->pPal);
77 }
#define EngFreeMem
Definition: polytest.cpp:56
smooth NULL
Definition: ftsmooth.c:416
BOOL APIENTRY EngDeletePalette(IN HPALETTE hpal)
Definition: palette.c:406

◆ vDisableSURF()

VOID vDisableSURF ( 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 }
#define RIP(x)
Definition: debug.h:24
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:274
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:179
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned long DWORD
Definition: ntddk_ex.h:95