ReactOS 0.4.16-dev-122-g325d74c
enable.c File Reference
#include "driver.h"
Include dependency graph for enable.c:

Go to the source code of this file.

Macros

#define HOOKS_BMF8BPP   0
 
#define HOOKS_BMF16BPP   0
 
#define HOOKS_BMF24BPP   0
 
#define HOOKS_BMF32BPP   0
 

Functions

BOOL APIENTRY DrvEnableDriver (ULONG iEngineVersion, ULONG cj, PDRVENABLEDATA pded)
 
DHPDEV APIENTRY DrvEnablePDEV (DEVMODEW *pDevmode, PWSTR pwszLogAddress, ULONG cPatterns, HSURF *ahsurfPatterns, ULONG cjGdiInfo, ULONG *pGdiInfo, ULONG cjDevInfo, DEVINFO *pDevInfo, HDEV hdev, PWSTR pwszDeviceName, HANDLE hDriver)
 
VOID APIENTRY DrvCompletePDEV (DHPDEV dhpdev, HDEV hdev)
 
VOID APIENTRY DrvDisablePDEV (DHPDEV dhpdev)
 
HSURF APIENTRY DrvEnableSurface (DHPDEV dhpdev)
 
VOID APIENTRY DrvDisableSurface (DHPDEV dhpdev)
 
BOOL APIENTRY DrvAssertMode (DHPDEV dhpdev, BOOL bEnable)
 
ULONG APIENTRY DrvGetModes (HANDLE hDriver, ULONG cjSize, DEVMODEW *pdm)
 

Variables

static DRVFN gadrvfn []
 

Macro Definition Documentation

◆ HOOKS_BMF16BPP

#define HOOKS_BMF16BPP   0

Definition at line 38 of file enable.c.

◆ HOOKS_BMF24BPP

#define HOOKS_BMF24BPP   0

Definition at line 40 of file enable.c.

◆ HOOKS_BMF32BPP

#define HOOKS_BMF32BPP   0

Definition at line 42 of file enable.c.

◆ HOOKS_BMF8BPP

#define HOOKS_BMF8BPP   0

Definition at line 36 of file enable.c.

Function Documentation

◆ DrvAssertMode()

BOOL APIENTRY DrvAssertMode ( DHPDEV  dhpdev,
BOOL  bEnable 
)

Definition at line 348 of file enable.c.

351{
352 PPDEV ppdev = (PPDEV) dhpdev;
353 ULONG ulReturn;
354 PBYTE pjScreen;
355
356 if (bEnable)
357 {
358 //
359 // The screen must be reenabled, reinitialize the device to clean state.
360 //
361// eVb: 1.6 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping
362 pjScreen = ppdev->pjScreen;
363
364 if (!bInitSURF(ppdev, FALSE))
365 {
366 DISPDBG((0, "DISP DrvAssertMode failed bInitSURF\n"));
367 return (FALSE);
368 }
369
370 if (pjScreen != ppdev->pjScreen) {
371
372 if ( !EngModifySurface(ppdev->hsurfEng,
373 ppdev->hdevEng,
374 ppdev->flHooks | HOOK_SYNCHRONIZE,
376 (DHSURF)ppdev,
377 ppdev->pjScreen,
378 ppdev->lDeltaScreen,
379 NULL))
380 {
381 DISPDBG((0, "DISP DrvAssertMode failed EngModifySurface\n"));
382 return (FALSE);
383 }
384 }
385// eVb: 1.6 [END]
386 return (TRUE);
387 }
388 else
389 {
390 //
391 // We must give up the display.
392 // Call the kernel driver to reset the device to a known state.
393 //
394
395 if (EngDeviceIoControl(ppdev->hDriver,
397 NULL,
398 0,
399 NULL,
400 0,
401 &ulReturn))
402 {
403 RIP("DISP DrvAssertMode failed IOCTL");
404 return FALSE;
405 }
406 else
407 {
408 return TRUE;
409 }
410 }
411}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
struct _PDEV * PPDEV
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:206
BYTE * PBYTE
Definition: pedump.c:66
Definition: framebuf.h:34
LONG flHooks
Definition: driver.h:49
HSURF hsurfEng
Definition: driver.h:24
PBYTE pjScreen
Definition: driver.h:26
HDEV hdevEng
Definition: driver.h:23
uint32_t ULONG
Definition: typedefs.h:59
#define RIP(x)
Definition: debug.h:24
#define DISPDBG(arg)
Definition: debug.h:23
BOOL bInitSURF(PPDEV, BOOL)
Definition: screen.c:168
ENGAPI BOOL APIENTRY EngModifySurface(_In_ HSURF hsurf, _In_ HDEV hdev, _In_ FLONG flHooks, _In_ FLONG flSurface, _In_ DHSURF dhsurf, _In_ PVOID pvScan0, _In_ LONG lDelta, _Reserved_ PVOID pvReserved)
Definition: surface.c:471
#define MS_NOTSYSTEMMEMORY
Definition: winddi.h:2129
_In_ BOOL bEnable
Definition: winddi.h:3426
#define HOOK_SYNCHRONIZE
Definition: winddi.h:1431

◆ DrvCompletePDEV()

VOID APIENTRY DrvCompletePDEV ( DHPDEV  dhpdev,
HDEV  hdev 
)

Definition at line 179 of file enable.c.

182{
183 ((PPDEV) dhpdev)->hdevEng = hdev;
184}
_In_ HDEV hdev
Definition: winddi.h:3449

◆ DrvDisablePDEV()

VOID APIENTRY DrvDisablePDEV ( DHPDEV  dhpdev)

Definition at line 194 of file enable.c.

196{
197 vDisablePalette((PPDEV) dhpdev);
198 EngFreeMem(dhpdev);
199}
#define EngFreeMem
Definition: polytest.cpp:56
VOID vDisablePalette(PPDEV)
Definition: palette.c:82

◆ DrvDisableSurface()

VOID APIENTRY DrvDisableSurface ( DHPDEV  dhpdev)

Definition at line 333 of file enable.c.

335{
336 EngDeleteSurface(((PPDEV) dhpdev)->hsurfEng);
337 vDisableSURF((PPDEV) dhpdev);
338 ((PPDEV) dhpdev)->hsurfEng = NULL;
339}
VOID vDisableSURF(PPDEV)
Definition: screen.c:297
ENGAPI BOOL APIENTRY EngDeleteSurface(_In_ _Post_ptr_invalid_ HSURF hsurf)
Definition: surface.c:567

◆ DrvEnableDriver()

BOOL APIENTRY DrvEnableDriver ( ULONG  iEngineVersion,
ULONG  cj,
PDRVENABLEDATA  pded 
)

Definition at line 51 of file enable.c.

55{
56// Engine Version is passed down so future drivers can support previous
57// engine versions. A next generation driver can support both the old
58// and new engine conventions if told what version of engine it is
59// working with. For the first version the driver does nothing with it.
60// eVb: 1.1 [DDK Change] - Remove bogus statement
61 //iEngineVersion;
62// eVb: 1.1 [END]
63// Fill in as much as we can.
64
65 if (cj >= sizeof(DRVENABLEDATA))
66 pded->pdrvfn = gadrvfn;
67
68 if (cj >= (sizeof(ULONG) * 2))
69 pded->c = sizeof(gadrvfn) / sizeof(DRVFN);
70
71// DDI version this driver was targeted for is passed back to engine.
72// Future graphic's engine may break calls down to old driver format.
73
74 if (cj >= sizeof(ULONG))
75// eVb: 1.2 [DDK Change] - Use DDI_DRIVER_VERSION_NT4 instead of DDI_DRIVER_VERSION
77// eVb: 1.2 [END]
78
79 return TRUE;
80}
Definition: winddi.h:529
ULONG iDriverVersion
Definition: winddi.h:542
DRVFN * pdrvfn
Definition: winddi.h:544
static DRVFN gadrvfn[]
Definition: enable.c:14
#define DDI_DRIVER_VERSION_NT4
Definition: winddi.h:535
_In_ ULONG cj
Definition: winddi.h:3540

◆ DrvEnablePDEV()

DHPDEV APIENTRY DrvEnablePDEV ( DEVMODEW pDevmode,
PWSTR  pwszLogAddress,
ULONG  cPatterns,
HSURF ahsurfPatterns,
ULONG  cjGdiInfo,
ULONG pGdiInfo,
ULONG  cjDevInfo,
DEVINFO pDevInfo,
HDEV  hdev,
PWSTR  pwszDeviceName,
HANDLE  hDriver 
)

Definition at line 91 of file enable.c.

103{
104 GDIINFO GdiInfo;
105 DEVINFO DevInfo;
106 PPDEV ppdev = NULL;
107
110
111 // Allocate a physical device structure.
112
113 ppdev = (PPDEV) EngAllocMem(0, sizeof(PDEV), ALLOC_TAG);
114
115 if (ppdev == NULL)
116 {
117 RIP("DISP DrvEnablePDEV failed EngAllocMem\n");
118 return NULL;
119 }
120
121 memset(ppdev, 0, sizeof(PDEV));
122
123 // Save the screen handle in the PDEV.
124
125 ppdev->hDriver = hDriver;
126
127 // Get the current screen mode information. Set up device caps and devinfo.
128
129 if (!bInitPDEV(ppdev, pDevmode, &GdiInfo, &DevInfo))
130 {
131 DISPDBG((0,"DISP DrvEnablePDEV failed\n"));
132 goto error_free;
133 }
134
135// eVb: 1.2 [VGARISC Change] - Disable hardware pointer support
136#if 0
137 // Initialize the cursor information.
138
139 if (!bInitPointer(ppdev, &DevInfo))
140 {
141 // Not a fatal error...
142 DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n"));
143 }
144
145#endif
146// eVb: 1.2 [END]
147 // Initialize palette information.
148
149 if (!bInitPaletteInfo(ppdev, &DevInfo))
150 {
151 RIP("DrvEnablePDEV failed bInitPalette\n");
152 goto error_free;
153 }
154
155 // Copy the devinfo into the engine buffer.
156
157 memcpy(pDevInfo, &DevInfo, min(sizeof(DEVINFO), cjDevInfo));
158
159 // Set the pdevCaps with GdiInfo we have prepared to the list of caps for this
160 // pdev.
161
162 memcpy(pGdiInfo, &GdiInfo, min(cjGdiInfo, sizeof(GDIINFO)));
163
164 return (DHPDEV)ppdev;
165
166 // Error case for failure.
167error_free:
168 EngFreeMem(ppdev);
169 return NULL;
170}
#define ALLOC_TAG
Definition: btrfs_drv.h:87
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define memset(x, y, z)
Definition: compat.h:39
HANDLE hDriver
Definition: framebuf.h:35
BOOL bInitPointer(PPDEV, DEVINFO *)
BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *)
BOOL bInitPaletteInfo(PPDEV, DEVINFO *)
Definition: palette.c:67
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG cjDevInfo
Definition: winddi.h:3553
typedef DHPDEV(APIENTRY FN_DrvEnablePDEV)(_In_ DEVMODEW *pdm
_In_ LPWSTR pwszLogAddress
Definition: winddi.h:3548
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR pwszDeviceName
Definition: winddi.h:3556
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3557

◆ DrvEnableSurface()

HSURF APIENTRY DrvEnableSurface ( DHPDEV  dhpdev)

Definition at line 210 of file enable.c.

212{
213 PPDEV ppdev;
214 HSURF hsurf;
215 SIZEL sizl;
216 ULONG ulBitmapType;
217#if 0
218 FLONG flHooks;
219#endif
220 HSURF hSurfBitmap;
221
222 // Create engine bitmap around frame buffer.
223
224 ppdev = (PPDEV) dhpdev;
225
226 if (!bInitSURF(ppdev, TRUE))
227 {
228 RIP("DISP DrvEnableSurface failed bInitSURF\n");
229 return NULL;
230 }
231
232 sizl.cx = ppdev->cxScreen;
233 sizl.cy = ppdev->cyScreen;
234
235// eVb: 1.3 [VGARISC Change] - Disable dynamic palette and > 4BPP support
236#if 0
237 if (ppdev->ulBitCount == 8)
238 {
239 if (!bInit256ColorPalette(ppdev)) {
240 RIP("DISP DrvEnableSurface failed to init the 8bpp palette\n");
241 return NULL;
242 }
243 ulBitmapType = BMF_8BPP;
244 flHooks = HOOKS_BMF8BPP;
245 }
246 else if (ppdev->ulBitCount == 16)
247 {
248 ulBitmapType = BMF_16BPP;
249 flHooks = HOOKS_BMF16BPP;
250 }
251 else if (ppdev->ulBitCount == 24)
252 {
253 ulBitmapType = BMF_24BPP;
254 flHooks = HOOKS_BMF24BPP;
255 }
256 else
257 {
258 ulBitmapType = BMF_32BPP;
259 flHooks = HOOKS_BMF32BPP;
260 }
261// eVb: 1.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping
262 ppdev->flHooks = flHooks;
263// eVb: 1.3 [END]
264#else
265 ulBitmapType = BMF_4BPP;
266#endif
267// eVb: 1.3 [END]
268// eVb: 1.4 [DDK Change] - Use EngCreateDeviceSurface instead of EngCreateBitmap
269 hsurf = (HSURF)EngCreateDeviceSurface((DHSURF)ppdev,
270 sizl,
271 ulBitmapType);
272
273 if (hsurf == NULL)
274 {
275 RIP("DISP DrvEnableSurface failed EngCreateDeviceSurface\n");
276 return NULL;
277 }
278// eVb: 1.4 [END]
279
280// eVb: 1.5 [DDK Change] - Use EngModifySurface instead of EngAssociateSurface
281 if ( !EngModifySurface(hsurf,
282 ppdev->hdevEng,
283 ppdev->flHooks | HOOK_SYNCHRONIZE,
285 (DHSURF)ppdev,
286 ppdev->pjScreen,
287 ppdev->lDeltaScreen,
288 NULL))
289 {
290 RIP("DISP DrvEnableSurface failed EngModifySurface\n");
291 return NULL;
292 }
293// eVb: 1.5 [END]
294 ppdev->hsurfEng = hsurf;
295// eVb: 1.4 [VGARISC Change] - Allocate 4BPP DIB that will store GDI drawing
296 hSurfBitmap = (HSURF)EngCreateBitmap(sizl, 0, ulBitmapType, 0, NULL);
297 if (hSurfBitmap == NULL)
298 {
299 RIP("DISP DrvEnableSurface failed EngCreateBitmap\n");
300 return NULL;
301 }
302
303 if ( !EngModifySurface(hSurfBitmap,
304 ppdev->hdevEng,
305 ppdev->flHooks | HOOK_SYNCHRONIZE,
307 (DHSURF)ppdev,
308 ppdev->pjScreen,
309 ppdev->lDeltaScreen,
310 NULL))
311 {
312 RIP("DISP DrvEnableSurface failed second EngModifySurface\n");
313 return NULL;
314 }
315
316 ppdev->pso = EngLockSurface(hSurfBitmap);
317 if (ppdev->pso == NULL)
318 {
319 RIP("DISP DrvEnableSurface failed EngLockSurface\n");
320 return NULL;
321 }
322// eVb: 1.4 [END]
323 return hsurf;
324}
unsigned long FLONG
Definition: ntbasedef.h:366
ULONG ulBitCount
Definition: driver.h:40
ULONG cyScreen
Definition: driver.h:28
ULONG cxScreen
Definition: driver.h:27
BOOL bInit256ColorPalette(PPDEV)
Definition: palette.c:226
#define HOOKS_BMF32BPP
Definition: enable.c:42
#define HOOKS_BMF8BPP
Definition: enable.c:36
#define HOOKS_BMF16BPP
Definition: enable.c:38
#define HOOKS_BMF24BPP
Definition: enable.c:40
#define BMF_16BPP
Definition: winddi.h:358
#define BMF_8BPP
Definition: winddi.h:357
ENGAPI SURFOBJ *APIENTRY EngLockSurface(_In_ HSURF hsurf)
Definition: surface.c:607
ENGAPI HBITMAP APIENTRY EngCreateBitmap(_In_ SIZEL sizl, _In_ LONG lWidth, _In_ ULONG iFormat, _In_ FLONG fl, _In_opt_ PVOID pvBits)
_Must_inspect_result_ ENGAPI HSURF APIENTRY EngCreateDeviceSurface(_In_ DHSURF dhsurf, _In_ SIZEL sizl, _In_ ULONG iFormatCompat)
Definition: surface.c:391
#define BMF_24BPP
Definition: winddi.h:359
#define BMF_32BPP
Definition: winddi.h:360
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)
#define BMF_4BPP
Definition: winddi.h:356
_In_ SIZEL sizl
Definition: winddi.h:3467

◆ DrvGetModes()

ULONG APIENTRY DrvGetModes ( HANDLE  hDriver,
ULONG  cjSize,
DEVMODEW pdm 
)

Definition at line 420 of file enable.c.

425{
426
427 DWORD cModes;
428 DWORD cbOutputSize;
429 PVIDEO_MODE_INFORMATION pVideoModeInformation, pVideoTemp;
430 DWORD cOutputModes = cjSize / (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
431 DWORD cbModeSize;
432
433 DISPDBG((3, "DrvGetModes\n"));
434
435 cModes = getAvailableModes(hDriver,
436 (PVIDEO_MODE_INFORMATION *) &pVideoModeInformation,
437 &cbModeSize);
438
439 if (cModes == 0)
440 {
441 DISPDBG((0, "DrvGetModes failed to get mode information"));
442 return 0;
443 }
444
445 if (pdm == NULL)
446 {
447 cbOutputSize = cModes * (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
448 }
449 else
450 {
451 //
452 // Now copy the information for the supported modes back into the output
453 // buffer
454 //
455
456 cbOutputSize = 0;
457
458 pVideoTemp = pVideoModeInformation;
459
460 do
461 {
462 if (pVideoTemp->Length != 0)
463 {
464 if (cOutputModes == 0)
465 {
466 break;
467 }
468
469 //
470 // Zero the entire structure to start off with.
471 //
472
473 memset(pdm, 0, sizeof(DEVMODEW));
474
475 //
476 // Set the name of the device to the name of the DLL.
477 //
478
479 memcpy(pdm->dmDeviceName, DLL_NAME, sizeof(DLL_NAME));
480
483 pdm->dmSize = sizeof(DEVMODEW);
485
486 pdm->dmBitsPerPel = pVideoTemp->NumberOfPlanes *
487 pVideoTemp->BitsPerPlane;
488 pdm->dmPelsWidth = pVideoTemp->VisScreenWidth;
489 pdm->dmPelsHeight = pVideoTemp->VisScreenHeight;
490 pdm->dmDisplayFrequency = pVideoTemp->Frequency;
491 pdm->dmDisplayFlags = 0;
492
493 pdm->dmFields = DM_BITSPERPEL |
498
499 //
500 // Go to the next DEVMODE entry in the buffer.
501 //
502
503 cOutputModes--;
504
505 pdm = (LPDEVMODEW) ( ((ULONG)pdm) + sizeof(DEVMODEW) +
507
508 cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
509
510 }
511
512 pVideoTemp = (PVIDEO_MODE_INFORMATION)
513 (((PUCHAR)pVideoTemp) + cbModeSize);
514
515 } while (--cModes);
516 }
517
518 EngFreeMem(pVideoModeInformation);
519
520 return cbOutputSize;
521
522}
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _VIDEO_MODE_INFORMATION * PVIDEO_MODE_INFORMATION
DWORD dmBitsPerPel
Definition: wingdi.h:1647
WCHAR dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1617
DWORD dmFields
Definition: wingdi.h:1622
DWORD dmPelsWidth
Definition: wingdi.h:1648
WORD dmDriverExtra
Definition: wingdi.h:1621
WORD dmSpecVersion
Definition: wingdi.h:1618
DWORD dmDisplayFlags
Definition: wingdi.h:1651
DWORD dmPelsHeight
Definition: wingdi.h:1649
DWORD dmDisplayFrequency
Definition: wingdi.h:1654
WORD dmSize
Definition: wingdi.h:1620
WORD dmDriverVersion
Definition: wingdi.h:1619
unsigned char * PUCHAR
Definition: typedefs.h:53
#define DLL_NAME
Definition: vgaddi.h:247
#define DRIVER_EXTRA_SIZE
Definition: vgaddi.h:245
DWORD getAvailableModes(IN HANDLE Driver, OUT PVIDEO_MODE_INFORMATION *modeInformation, OUT DWORD *ModeSize)
Definition: screen.c:38
_In_ ULONG cjSize
Definition: winddi.h:3634
#define DM_DISPLAYFREQUENCY
Definition: wingdi.h:1272
#define DM_PELSWIDTH
Definition: wingdi.h:1269
struct _devicemodeW * LPDEVMODEW
struct _devicemodeW DEVMODEW
#define DM_BITSPERPEL
Definition: wingdi.h:1268
#define DM_SPECVERSION
Definition: wingdi.h:1243
#define DM_PELSHEIGHT
Definition: wingdi.h:1270
#define DM_DISPLAYFLAGS
Definition: wingdi.h:1271

Variable Documentation

◆ gadrvfn

DRVFN gadrvfn[]
static
Initial value:
=
{
}
LONG_PTR(APIENTRY * PFN)()
Definition: winddi.h:133
FN_DrvSetPalette DrvSetPalette
#define INDEX_DrvDisableSurface
Definition: winddi.h:420
FN_DrvGetModes DrvGetModes
#define INDEX_DrvCompletePDEV
Definition: winddi.h:417
#define INDEX_DrvSetPalette
Definition: winddi.h:438
FN_DrvEnableSurface DrvEnableSurface
#define INDEX_DrvEnablePDEV
Definition: winddi.h:416
FN_DrvCompletePDEV DrvCompletePDEV
#define INDEX_DrvAssertMode
Definition: winddi.h:421
FN_DrvEnablePDEV DrvEnablePDEV
FN_DrvAssertMode DrvAssertMode
FN_DrvDisableSurface DrvDisableSurface
FN_DrvDisablePDEV DrvDisablePDEV
#define INDEX_DrvEnableSurface
Definition: winddi.h:419
#define INDEX_DrvDisablePDEV
Definition: winddi.h:418
#define INDEX_DrvGetModes
Definition: winddi.h:457

Definition at line 14 of file enable.c.

Referenced by BmfdEnableDriver(), DrvEnableDriver(), and FtfdEnableDriver().