ReactOS 0.4.16-dev-297-gc569aee
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");
129 return FALSE;
130 }
131 return TRUE;
132}
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
if(dx< 0)
Definition: linetemp.h:194
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:248
PBYTE fbScreen
Definition: vgaddi.h:137
HANDLE KMDriver
Definition: vgaddi.h:108
PVOID RequestedVirtualAddress
Definition: ntddvdeo.h:344
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG
Definition: typedefs.h:59
_Analysis_noreturn_ ENGAPI VOID APIENTRY EngDebugBreak(VOID)

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;
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 == 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 = 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}
#define ALLOC_TAG
Definition: btrfs_drv.h:87
#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
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
ULONG ModeInformationLength
Definition: ntddvdeo.h:398
unsigned char * PUCHAR
Definition: typedefs.h:53
#define BROKEN_RASTERS(stride, cy)
Definition: vgaddi.h:72
_Must_inspect_result_ _In_ WDFDRIVER Driver
Definition: wdfcontrol.h:83

Referenced by bInitPDEV(), and DrvGetModes().

◆ 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 = 2;
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,
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}
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:173
#define IOCTL_VIDEO_SET_PALETTE_REGISTERS
Definition: ntddvdeo.h:230
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:221
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:218
SIZEL sizeSurf
Definition: vgaddi.h:136
ULONG ModeNum
Definition: vgaddi.h:134
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
PBYTE vidmem
Definition: vgavideo.c:18
static WORD PaletteBuffer[]
Definition: screen.c:11
static BYTE ColorBuffer[]
Definition: screen.c:16
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

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().