ReactOS  0.4.15-dev-509-g96a357b
screen.c File Reference
#include <vgaddi.h>
Include dependency graph for screen.c:

Go to the source code of this file.

Functions

DWORD getAvailableModes (IN HANDLE Driver, OUT PVIDEO_MODE_INFORMATION *modeInformation, OUT DWORD *ModeSize)
 
BOOL DeinitVGA (PPDEV ppdev)
 
BOOL InitVGA (PPDEV ppdev, BOOL bFirst)
 

Variables

static WORD PaletteBuffer []
 
static BYTE ColorBuffer []
 

Function Documentation

◆ DeinitVGA()

BOOL DeinitVGA ( PPDEV  ppdev)

Definition at line 112 of file screen.c.

113 {
114  VIDEO_MEMORY VideoMemory;
115  ULONG ReturnedDataLength;
116 
117  VideoMemory.RequestedVirtualAddress = (PVOID)ppdev->fbScreen;
118 
119  if (EngDeviceIoControl(ppdev->KMDriver,
121  (PVOID)&VideoMemory,
122  sizeof(VIDEO_MEMORY),
123  NULL,
124  0,
125  &ReturnedDataLength))
126  {
127  DPRINT1("Failed to unmap video memory.\n");
128  EngDebugBreak();
129  return FALSE;
130  }
131  return TRUE;
132 }
#define TRUE
Definition: types.h:120
_Analysis_noreturn_ ENGAPI VOID APIENTRY EngDebugBreak(VOID)
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:274
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
PBYTE fbScreen
Definition: vgaddi.h:137
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:179
HANDLE KMDriver
Definition: vgaddi.h:108
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1

Referenced by DrvDisableSurface().

◆ getAvailableModes()

DWORD getAvailableModes ( IN HANDLE  Driver,
OUT PVIDEO_MODE_INFORMATION modeInformation,
OUT DWORD ModeSize 
)

Definition at line 38 of file screen.c.

42 {
43  ULONG Temp;
44  VIDEO_NUM_MODES modes;
45  PVIDEO_MODE_INFORMATION VideoTemp;
46 
47  /* get number of modes supported */
48  if (EngDeviceIoControl(Driver,
50  NULL,
51  0,
52  &modes,
53  sizeof(VIDEO_NUM_MODES),
54  &Temp))
55  {
56  /* get modes failed */
57  return 0;
58  }
59 
60  *ModeSize = modes.ModeInformationLength;
61 
62  /* allocate buffer for the mini-port to write the modes in */
63  *modeInformation = (PVIDEO_MODE_INFORMATION)
64  EngAllocMem(0, modes.NumModes *
66 
67  if (*modeInformation == (PVIDEO_MODE_INFORMATION) NULL)
68  {
69  /* couldn't allocate buffer */
70  return 0;
71  }
72 
73  /* Ask the mini-port to fill in the available modes. */
74  if (EngDeviceIoControl(Driver,
76  NULL,
77  0,
78  *modeInformation,
79  modes.NumModes * modes.ModeInformationLength,
80  &Temp))
81  {
82  /* failed to query modes */
83  EngFreeMem(*modeInformation);
84  *modeInformation = (PVIDEO_MODE_INFORMATION) NULL;
85 
86  return 0;
87  }
88 
89  /* Which modes supported by miniport driver are also suppoted by us, the
90  * display driver */
91 
92  Temp = modes.NumModes;
93  VideoTemp = *modeInformation;
94 
95  /* Reject mode if it's not 4 planes or not graphic or not 1 bits per pel */
96  while (Temp--)
97  {
98  if ((VideoTemp->NumberOfPlanes != 4 ) ||
99  !(VideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) ||
100  (VideoTemp->BitsPerPlane != 1) ||
101  BROKEN_RASTERS(VideoTemp->ScreenStride, VideoTemp->VisScreenHeight))
102  {
103  VideoTemp->Length = 0;
104  }
105 
106  VideoTemp = (PVIDEO_MODE_INFORMATION)(((PUCHAR)VideoTemp) + modes.ModeInformationLength);
107  }
108 
109  return modes.NumModes;
110 }
ULONG ModeInformationLength
Definition: ntddvdeo.h:328
#define EngFreeMem
Definition: polytest.cpp:56
unsigned char * PUCHAR
Definition: retypes.h:3
#define ALLOC_TAG
Definition: btrfs_drv.h:91
struct _VIDEO_MODE_INFORMATION * PVIDEO_MODE_INFORMATION
smooth NULL
Definition: ftsmooth.c:416
_In_ PCUNICODE_STRING _In_ PVOID Driver
Definition: cmfuncs.h:32
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
#define BROKEN_RASTERS(stride, cy)
Definition: vgaddi.h:72
unsigned int ULONG
Definition: retypes.h:1
#define VIDEO_MODE_GRAPHICS
Definition: ntddvdeo.h:294

◆ InitVGA()

BOOL InitVGA ( PPDEV  ppdev,
BOOL  bFirst 
)

Definition at line 134 of file screen.c.

135 {
136  ULONG ReturnedDataLength;
137  VIDEO_MEMORY VideoMemory;
138  VIDEO_MEMORY_INFORMATION VideoMemoryInfo;
139 
140  ppdev->sizeSurf.cx = 640;
141  ppdev->sizeSurf.cy = 480;
142  ppdev->ModeNum = 12;
143 
144  /* Set the mode that was requested */
145  if (EngDeviceIoControl(ppdev->KMDriver,
147  &ppdev->ModeNum,
148  sizeof(VIDEO_MODE),
149  NULL,
150  0,
151  &ReturnedDataLength))
152  {
153  return FALSE;
154  }
155 
156  /* set up internal palette */
157  if (EngDeviceIoControl(ppdev->KMDriver,
161  NULL,
162  0,
163  &ReturnedDataLength))
164  {
165  return FALSE;
166  }
167 
168  /* set up the DAC */
169  if (EngDeviceIoControl(ppdev->KMDriver,
171  (PVOID) ColorBuffer,
173  NULL,
174  0,
175  &ReturnedDataLength))
176  {
177  return FALSE;
178  }
179 
180  if (bFirst)
181  {
182  /* map video memory into virtual memory */
183  VideoMemory.RequestedVirtualAddress = NULL;
184 
185  if (EngDeviceIoControl(ppdev->KMDriver,
187  (PVOID) &VideoMemory,
189  (PVOID) &VideoMemoryInfo,
190  sizeof (VideoMemoryInfo),
191  &ReturnedDataLength))
192  {
193  /* Failed to map to virtual memory */
194  return FALSE;
195  }
196 
197  ppdev->fbScreen = VideoMemoryInfo.FrameBufferBase;
198  vidmem = (PUCHAR)ppdev->fbScreen;
199  }
200 
201  return TRUE;
202 }
PBYTE vidmem
Definition: vgavideo.c:18
#define TRUE
Definition: types.h:120
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
unsigned char * PUCHAR
Definition: retypes.h:3
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:104
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:274
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:152
#define IOCTL_VIDEO_SET_PALETTE_REGISTERS
Definition: ntddvdeo.h:161
SIZEL sizeSurf
Definition: vgaddi.h:136
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
PBYTE fbScreen
Definition: vgaddi.h:137
HANDLE KMDriver
Definition: vgaddi.h:108
static BYTE ColorBuffer[]
Definition: screen.c:16
static WORD PaletteBuffer[]
Definition: screen.c:11
ULONG ModeNum
Definition: vgaddi.h:134
unsigned int ULONG
Definition: retypes.h:1
LONG cy
Definition: windef.h:335
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:149

Referenced by DrvAssertMode(), and DrvEnableSurface().

Variable Documentation

◆ ColorBuffer

BYTE ColorBuffer[]
static
Initial value:
= {
16,
0, 0,
0,
0x00, 0x00, 0x00, 0x00,
0x2A, 0x00, 0x15, 0x00,
0x00, 0x2A, 0x15, 0x00,
0x2A, 0x2A, 0x15, 0x00,
0x00, 0x00, 0x2A, 0x00,
0x2A, 0x15, 0x2A, 0x00,
0x15, 0x2A, 0x2A, 0x00,
0x21, 0x22, 0x23, 0x00,
0x30, 0x31, 0x32, 0x00,
0x3F, 0x00, 0x00, 0x00,
0x00, 0x3F, 0x00, 0x00,
0x3F, 0x3F, 0x00, 0x00,
0x00, 0x00, 0x3F, 0x00,
0x3F, 0x00, 0x3F, 0x00,
0x00, 0x3F, 0x3F, 0x00,
0x3F, 0x3F, 0x3F, 0x00
}

Definition at line 16 of file screen.c.

Referenced by InitVGA().

◆ PaletteBuffer

WORD PaletteBuffer[]
static
Initial value:
= {
16, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
}

Definition at line 11 of file screen.c.

Referenced by InitVGA(), and VgaSetPaletteReg().