VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/enable.c@ 2558

Last change on this file since 2558 was 2558, checked in by vboxsync, 18 years ago

Undid incorrect commit.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 25.9 KB
Line 
1/******************************Module*Header*******************************\
2*
3* *******************
4* * GDI SAMPLE CODE *
5* *******************
6*
7* Module Name: enable.c
8*
9* This module contains the functions that enable and disable the
10* driver, the pdev, and the surface.
11*
12* Copyright (c) 1992-1998 Microsoft Corporation
13\**************************************************************************/
14
15#include "driver.h"
16
17// The driver function table with all function index/address pairs
18
19// Hook functions to track dirty rectangles and generate RDP orders.
20// NT4 functions
21DRVFN gadrvfn_nt4[] = {
22 { INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV }, // 0
23 { INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV }, // 1
24 { INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV }, // 2
25 { INDEX_DrvEnableSurface, (PFN) DrvEnableSurface }, // 3
26 { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, // 4
27 { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, // 5
28 { INDEX_DrvOffset, (PFN) DrvOffset }, // 6
29 { INDEX_DrvDisableDriver, (PFN) DrvDisableDriver }, // 8
30 { INDEX_DrvRealizeBrush, (PFN) DrvRealizeBrush }, // 12
31 { INDEX_DrvDitherColor, (PFN) DrvDitherColor }, // 13
32 { INDEX_DrvStrokePath, (PFN) DrvStrokePath }, // 14
33 { INDEX_DrvFillPath, (PFN) DrvFillPath }, // 15
34 { INDEX_DrvPaint, (PFN) DrvPaint }, // 17
35 { INDEX_DrvBitBlt, (PFN) DrvBitBlt }, // 18
36 { INDEX_DrvCopyBits, (PFN) DrvCopyBits }, // 19
37 { INDEX_DrvStretchBlt, (PFN) DrvStretchBlt, }, // 20
38 { INDEX_DrvSetPalette, (PFN) DrvSetPalette }, // 22
39 { INDEX_DrvTextOut, (PFN) DrvTextOut }, // 23
40 { INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape }, // 29
41 { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, // 30
42 { INDEX_DrvLineTo, (PFN) DrvLineTo }, // 31
43 { INDEX_DrvSynchronize, (PFN) DrvSynchronize }, // 38
44 { INDEX_DrvSaveScreenBits, (PFN) DrvSaveScreenBits }, // 40
45 { INDEX_DrvGetModes, (PFN) DrvGetModes }, // 41
46};
47/* Experimental begin */
48BOOL APIENTRY DrvResetPDEV(
49 DHPDEV dhpdevOld,
50 DHPDEV dhpdevNew
51 )
52{
53 DISPDBG((0, "Experimental %s: %p, %p\n", __FUNCTION__, dhpdevOld, dhpdevNew));
54 return TRUE;
55}
56
57BOOL DrvNineGrid (PVOID x1, PVOID x2, PVOID x3, PVOID x4, PVOID x5, PVOID x6, PVOID x7, PVOID x8, PVOID x9)
58{
59 DISPDBG((0, "Experimental %s: %p, %p, %p, %p, %p, %p, %p, %p, %p\n", __FUNCTION__, x1, x2, x3, x4, x5, x6, x7, x8, x9));
60 return FALSE;
61}
62
63VOID APIENTRY DrvDestroyFont(
64 FONTOBJ *pfo)
65{
66 DISPDBG((0, "Experimental %s: %p\n", __FUNCTION__, pfo));
67}
68
69ULONG APIENTRY DrvEscape(
70 SURFOBJ *pso,
71 ULONG iEsc,
72 ULONG cjIn,
73 PVOID pvIn,
74 ULONG cjOut,
75 PVOID pvOut
76 )
77{
78 DISPDBG((0, "Experimental %s: %p, %p, %p, %p, %p, %p\n", __FUNCTION__, pso, iEsc, cjIn, pvIn, cjOut, pvOut));
79 return 0;
80}
81
82BOOL DrvConnect (PVOID x1, PVOID x2, PVOID x3, PVOID x4)
83{
84 DISPDBG((0, "Experimental %s: %p, %p, %p, %p\n", __FUNCTION__, x1, x2, x3, x4));
85 return TRUE;
86}
87
88BOOL DrvDisconnect (PVOID x1, PVOID x2)
89{
90 DISPDBG((0, "Experimental %s: %p, %p\n", __FUNCTION__, x1, x2));
91 return FALSE;
92}
93
94BOOL DrvReconnect (PVOID x1, PVOID x2)
95{
96 DISPDBG((0, "Experimental %s: %p, %p\n", __FUNCTION__, x1, x2));
97 return FALSE;
98}
99
100BOOL DrvShadowConnect (PVOID x1, PVOID x2)
101{
102 DISPDBG((0, "Experimental %s: %p, %p\n", __FUNCTION__, x1, x2));
103 return FALSE;
104}
105
106BOOL DrvShadowDisconnect (PVOID x1, PVOID x2)
107{
108 DISPDBG((0, "Experimental %s: %p, %p\n", __FUNCTION__, x1, x2));
109 return FALSE;
110}
111
112BOOL DrvDDInit (PVOID x1)
113{
114 DISPDBG((0, "Experimental %s: %p\n", __FUNCTION__, x1));
115 return FALSE;
116}
117
118BOOL APIENTRY DrvGetDirectDrawInfo(
119 DHPDEV dhpdev,
120 DD_HALINFO *pHalInfo,
121 DWORD *pdwNumHeaps,
122 VIDEOMEMORY *pvmList,
123 DWORD *pdwNumFourCCCodes,
124 DWORD *pdwFourCC
125 )
126{
127 DISPDBG((0, "Experimental %s: %p, %p, %p, %p, %p. %p\n", __FUNCTION__, dhpdev, pHalInfo, pdwNumHeaps, pvmList, pdwNumFourCCCodes, pdwFourCC));
128 return FALSE;
129}
130
131BOOL APIENTRY DrvEnableDirectDraw(
132 DHPDEV dhpdev,
133 DD_CALLBACKS *pCallBacks,
134 DD_SURFACECALLBACKS *pSurfaceCallBacks,
135 DD_PALETTECALLBACKS *pPaletteCallBacks
136 )
137{
138 DISPDBG((0, "Experimental %s: %p, %p, %p, %p\n", __FUNCTION__, dhpdev, pCallBacks, pSurfaceCallBacks, pPaletteCallBacks));
139 return FALSE;
140}
141
142/* Experimental end */
143
144// W2K,XP functions
145DRVFN gadrvfn_nt5[] = {
146 { INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV }, // 0 0x0
147 { INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV }, // 1 0x1
148 { INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV }, // 2 0x2
149 { INDEX_DrvEnableSurface, (PFN) DrvEnableSurface }, // 3 0x3
150 { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, // 4 0x4
151 { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, // 5 0x5
152 { INDEX_DrvDisableDriver, (PFN) DrvDisableDriver }, // 8 0x8
153 { INDEX_DrvRealizeBrush, (PFN) DrvRealizeBrush }, // 12 0xc
154 { INDEX_DrvDitherColor, (PFN) DrvDitherColor }, // 13 0xd
155 { INDEX_DrvStrokePath, (PFN) DrvStrokePath }, // 14 0xe
156 { INDEX_DrvFillPath, (PFN) DrvFillPath }, // 15 0xf
157 { INDEX_DrvPaint, (PFN) DrvPaint }, // 17 0x11
158 { INDEX_DrvBitBlt, (PFN) DrvBitBlt }, // 18 0x12
159 { INDEX_DrvCopyBits, (PFN) DrvCopyBits }, // 19 0x13
160 { INDEX_DrvStretchBlt, (PFN) DrvStretchBlt, }, // 20 0x14
161 { INDEX_DrvSetPalette, (PFN) DrvSetPalette }, // 22 0x16
162 { INDEX_DrvTextOut, (PFN) DrvTextOut }, // 23 0x17
163 { INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape }, // 29 0x1d
164 { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, // 30 0x1e
165 { INDEX_DrvLineTo, (PFN) DrvLineTo }, // 31 0x1f
166 { INDEX_DrvSynchronize, (PFN) DrvSynchronize }, // 38 0x26
167 { INDEX_DrvSaveScreenBits, (PFN) DrvSaveScreenBits }, // 40 0x28
168 { INDEX_DrvGetModes, (PFN) DrvGetModes }, // 41 0x29
169// /* Experimental. */
170// { 0x7, (PFN) DrvResetPDEV }, // 0x7
171// { 0x5b, (PFN) DrvNineGrid }, // 0x5b
172// { 0x2b, (PFN) DrvDestroyFont }, // 0x2b
173// { 0x18, (PFN) DrvEscape }, // 0x18
174// { 0x4d, (PFN) DrvConnect }, // 0x4d
175// { 0x4e, (PFN) DrvDisconnect }, // 0x4e
176// { 0x4f, (PFN) DrvReconnect }, // 0x4f
177// { 0x50, (PFN) DrvShadowConnect }, // 0x50
178// { 0x51, (PFN) DrvShadowDisconnect }, // 0x51
179// { 0x3d, (PFN) DrvDDInit }, // 0x3d
180// { 0x3b, (PFN) DrvGetDirectDrawInfo }, // 0x3b
181// { 0x3c, (PFN) DrvEnableDirectDraw }, // 0x3c
182
183};
184
185// Required hook bits will be set up according to DDI version
186static ULONG gflHooks = 0;
187
188#define HOOKS_BMF8BPP gflHooks
189#define HOOKS_BMF16BPP gflHooks
190#define HOOKS_BMF24BPP gflHooks
191#define HOOKS_BMF32BPP gflHooks
192
193/******************************Public*Routine******************************\
194* DrvEnableDriver
195*
196* Enables the driver by retrieving the drivers function table and version.
197*
198\**************************************************************************/
199
200BOOL DrvEnableDriver(
201ULONG iEngineVersion,
202ULONG cj,
203PDRVENABLEDATA pded)
204{
205// Engine Version is passed down so future drivers can support previous
206// engine versions. A next generation driver can support both the old
207// and new engine conventions if told what version of engine it is
208// working with. For the first version the driver does nothing with it.
209
210 iEngineVersion;
211
212 DISPDBG((0, "VBoxDisp::DrvEnableDriver called. iEngine version = %08X\n", iEngineVersion));
213
214 // Set up hook flags to intercept all functions which can generate VRDP orders
215 gflHooks = HOOK_BITBLT | HOOK_TEXTOUT | HOOK_FILLPATH |
216 HOOK_COPYBITS | HOOK_STROKEPATH | HOOK_LINETO |
217 HOOK_PAINT | HOOK_STRETCHBLT | HOOK_SYNCHRONIZEACCESS;
218
219// Fill in as much as we can.
220
221 if (cj >= sizeof(DRVENABLEDATA))
222 pded->pdrvfn = (iEngineVersion >= DDI_DRIVER_VERSION_NT5)?
223 gadrvfn_nt5:
224 gadrvfn_nt4;
225
226
227 if (cj >= (sizeof(ULONG) * 2))
228 pded->c = (iEngineVersion >= DDI_DRIVER_VERSION_NT5)?
229 sizeof(gadrvfn_nt5) / sizeof(DRVFN):
230 sizeof(gadrvfn_nt4) / sizeof(DRVFN);
231
232// DDI version this driver was targeted for is passed back to engine.
233// Future graphic's engine may break calls down to old driver format.
234
235 if (cj >= sizeof(ULONG))
236 pded->iDriverVersion = (iEngineVersion >= DDI_DRIVER_VERSION_NT5)?
237 DDI_DRIVER_VERSION_NT5:
238 DDI_DRIVER_VERSION_NT4;
239
240 return(TRUE);
241}
242
243/******************************Public*Routine******************************\
244* DrvDisableDriver
245*
246* Tells the driver it is being disabled. Release any resources allocated in
247* DrvEnableDriver.
248*
249\**************************************************************************/
250
251VOID DrvDisableDriver(VOID)
252{
253 DISPDBG((0, "VBoxDisp::DrvDisableDriver called.\n"));
254 return;
255}
256
257/******************************Public*Routine******************************\
258* DrvEnablePDEV
259*
260* DDI function, Enables the Physical Device.
261*
262* Return Value: device handle to pdev.
263*
264\**************************************************************************/
265
266DHPDEV DrvEnablePDEV(
267DEVMODEW *pDevmode, // Pointer to DEVMODE
268PWSTR pwszLogAddress, // Logical address
269ULONG cPatterns, // number of patterns
270HSURF *ahsurfPatterns, // return standard patterns
271ULONG cjGdiInfo, // Length of memory pointed to by pGdiInfo
272ULONG *pGdiInfo, // Pointer to GdiInfo structure
273ULONG cjDevInfo, // Length of following PDEVINFO structure
274DEVINFO *pDevInfo, // physical device information structure
275HDEV hdev, // HDEV, used for callbacks
276PWSTR pwszDeviceName, // DeviceName - not used
277HANDLE hDriver) // Handle to base driver
278{
279 GDIINFO GdiInfo;
280 DEVINFO DevInfo;
281 PPDEV ppdev = (PPDEV) NULL;
282
283 DISPDBG((0, "VBoxDisp::DrvEnablePDEV called\n"));
284
285 UNREFERENCED_PARAMETER(pwszLogAddress);
286 UNREFERENCED_PARAMETER(pwszDeviceName);
287
288 RtlZeroMemory(&DevInfo, sizeof (DEVINFO));
289 RtlZeroMemory(&GdiInfo, sizeof (GDIINFO));
290
291 // Allocate a physical device structure.
292
293 ppdev = (PPDEV) EngAllocMem(0, sizeof(PDEV), ALLOC_TAG);
294
295 if (ppdev == (PPDEV) NULL)
296 {
297 DISPDBG((0, "DISP DrvEnablePDEV failed EngAllocMem\n"));
298 return((DHPDEV) 0);
299 }
300
301 memset(ppdev, 0, sizeof(PDEV));
302
303 // Save the screen handle in the PDEV.
304
305 ppdev->hDriver = hDriver;
306
307 // Get the current screen mode information. Set up device caps and devinfo.
308
309 if (!bInitPDEV(ppdev, pDevmode, &GdiInfo, &DevInfo))
310 {
311 DISPDBG((0,"DISP DrvEnablePDEV failed\n"));
312 goto error_free;
313 }
314
315 // Initialize the cursor information.
316
317 if (!bInitPointer(ppdev, &DevInfo))
318 {
319 // Not a fatal error...
320 DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n"));
321 }
322
323 // Initialize palette information.
324
325 if (!bInitPaletteInfo(ppdev, &DevInfo))
326 {
327 DISPDBG((0, "DrvEnablePDEV failed bInitPalette\n"));
328 goto error_free;
329 }
330
331// // Start a thread that will process notifications from VMMDev
332// if (!bInitNotificationThread(ppdev))
333// {
334// DISPDBG((0, "DrvEnablePDEV failed bInitNotificationThread\n"));
335// goto error_free;
336// }
337
338 // Copy the devinfo into the engine buffer.
339
340 DISPDBG((0, "VBoxDisp::DrvEnablePDEV: sizeof(DEVINFO) = %d, cjDevInfo = %d, alpha = %d\n", sizeof(DEVINFO), cjDevInfo, DevInfo.flGraphicsCaps2 & GCAPS2_ALPHACURSOR));
341
342// @todo seems to be not necessary. these bits are initialized in screen.c DevInfo.flGraphicsCaps |= GCAPS_OPAQUERECT |
343// GCAPS_DITHERONREALIZE |
344// GCAPS_PALMANAGED |
345// GCAPS_ALTERNATEFILL |
346// GCAPS_WINDINGFILL |
347// GCAPS_MONO_DITHER |
348// GCAPS_COLOR_DITHER |
349// GCAPS_ASYNCMOVE;
350//
351// DevInfo.flGraphicsCaps |= GCAPS_DITHERONREALIZE;
352
353 DevInfo.flGraphicsCaps2 |= GCAPS2_RESERVED1; /* @todo figure out what is this. */
354
355 memcpy(pDevInfo, &DevInfo, min(sizeof(DEVINFO), cjDevInfo));
356
357 // Set the pdevCaps with GdiInfo we have prepared to the list of caps for this
358 // pdev.
359
360 memcpy(pGdiInfo, &GdiInfo, min(cjGdiInfo, sizeof(GDIINFO)));
361
362 DISPDBG((0, "VBoxDisp::DrvEnablePDEV completed\n"));
363
364 return((DHPDEV) ppdev);
365
366 // Error case for failure.
367error_free:
368 EngFreeMem(ppdev);
369 return((DHPDEV) 0);
370}
371
372/******************************Public*Routine******************************\
373* DrvCompletePDEV
374*
375* Store the HPDEV, the engines handle for this PDEV, in the DHPDEV.
376*
377\**************************************************************************/
378
379VOID DrvCompletePDEV(
380DHPDEV dhpdev,
381HDEV hdev)
382{
383 DISPDBG((0, "VBoxDisp::DrvCompletePDEV called\n"));
384 ((PPDEV) dhpdev)->hdevEng = hdev;
385}
386
387/******************************Public*Routine******************************\
388* DrvDisablePDEV
389*
390* Release the resources allocated in DrvEnablePDEV. If a surface has been
391* enabled DrvDisableSurface will have already been called.
392*
393\**************************************************************************/
394
395VOID DrvDisablePDEV(
396DHPDEV dhpdev)
397{
398 DISPDBG((0, "VBoxDisp::DrvDisablePDEV called\n"));
399// vStopNotificationThread ((PPDEV) dhpdev);
400 vDisablePalette((PPDEV) dhpdev);
401
402 /* Free the driver's VBVA resources. */
403 vboxVbvaDisable ((PPDEV) dhpdev);
404
405 EngFreeMem(dhpdev);
406}
407
408/******************************Public*Routine******************************\
409* VOID DrvOffset
410*
411* DescriptionText
412*
413\**************************************************************************/
414
415BOOL DrvOffset(
416SURFOBJ* pso,
417LONG x,
418LONG y,
419FLONG flReserved)
420{
421 PDEV* ppdev = (PDEV*) pso->dhpdev;
422
423 // Add back last offset that we subtracted. I could combine the next
424 // two statements, but I thought this was more clear. It's not
425 // performance critical anyway.
426
427 ppdev->pjScreen += ((ppdev->ptlOrg.y * ppdev->lDeltaScreen) +
428 (ppdev->ptlOrg.x * ((ppdev->ulBitCount+1) >> 3)));
429
430 // Subtract out new offset
431
432 ppdev->pjScreen -= ((y * ppdev->lDeltaScreen) +
433 (x * ((ppdev->ulBitCount+1) >> 3)));
434
435 ppdev->ptlOrg.x = x;
436 ppdev->ptlOrg.y = y;
437
438 return(TRUE);
439}
440
441/******************************Public*Routine******************************\
442* DrvEnableSurface
443*
444* Enable the surface for the device. Hook the calls this driver supports.
445*
446* Return: Handle to the surface if successful, 0 for failure.
447*
448\**************************************************************************/
449
450HSURF DrvEnableSurface(
451DHPDEV dhpdev)
452{
453 PPDEV ppdev;
454 HSURF hsurf;
455 SIZEL sizl;
456 ULONG ulBitmapType;
457 FLONG flHooks;
458
459 DISPDBG((0, "DISP DrvEnableSurface called\n"));
460
461 // Create engine bitmap around frame buffer.
462
463 ppdev = (PPDEV) dhpdev;
464
465 ppdev->ptlOrg.x = 0;
466 ppdev->ptlOrg.y = 0;
467
468 if (!bInitSURF(ppdev, TRUE))
469 {
470 DISPDBG((0, "DISP DrvEnableSurface failed bInitSURF\n"));
471 return(FALSE);
472 }
473
474 DISPDBG((0, "DISP DrvEnableSurface bInitSURF success\n"));
475
476 sizl.cx = ppdev->cxScreen;
477 sizl.cy = ppdev->cyScreen;
478
479 if (ppdev->ulBitCount == 8)
480 {
481 if (!bInit256ColorPalette(ppdev)) {
482 DISPDBG((0, "DISP DrvEnableSurface failed to init the 8bpp palette\n"));
483 return(FALSE);
484 }
485 ulBitmapType = BMF_8BPP;
486 flHooks = HOOKS_BMF8BPP;
487 }
488 else if (ppdev->ulBitCount == 16)
489 {
490 ulBitmapType = BMF_16BPP;
491 flHooks = HOOKS_BMF16BPP;
492 }
493 else if (ppdev->ulBitCount == 24)
494 {
495 ulBitmapType = BMF_24BPP;
496 flHooks = HOOKS_BMF24BPP;
497 }
498 else
499 {
500 ulBitmapType = BMF_32BPP;
501 flHooks = HOOKS_BMF32BPP;
502 }
503
504 hsurf = (HSURF) EngCreateBitmap(sizl,
505 ppdev->lDeltaScreen,
506 ulBitmapType,
507 (ppdev->lDeltaScreen > 0) ? BMF_TOPDOWN : 0,
508 (PVOID) (ppdev->pjScreen));
509
510 if (hsurf == (HSURF) 0)
511 {
512 DISPDBG((0, "DISP DrvEnableSurface failed EngCreateBitmap\n"));
513 goto l_Failure;
514 }
515 else
516 {
517 ppdev->hsurfScreenBitmap = hsurf;
518
519 if (!EngAssociateSurface(hsurf, ppdev->hdevEng, 0))
520 {
521 DISPDBG((0, "DISP DrvEnableSurface failed EngAssociateSurface for ScreenBitmap.\n"));
522 goto l_Failure;
523 }
524 else
525 {
526 SURFOBJ *pso = EngLockSurface(hsurf);
527
528 ppdev->psoScreenBitmap = pso;
529
530 hsurf = (HSURF) EngCreateDeviceSurface((DHSURF)pso,
531 sizl,
532 ulBitmapType);
533
534 if (hsurf == (HSURF) 0)
535 {
536 DISPDBG((0, "DISP DrvEnableSurface failed EngCreateDeviceSurface\n"));
537 goto l_Failure;
538 }
539 else
540 {
541 ppdev->hsurfScreen = hsurf;
542
543 if (!EngAssociateSurface(hsurf, ppdev->hdevEng, flHooks))
544 {
545 DISPDBG((0, "DISP DrvEnableSurface failed EngAssociateSurface for Screen.\n"));
546 goto l_Failure;
547 }
548 else
549 {
550 ppdev->flHooks = flHooks;
551 ppdev->ulBitmapType = ulBitmapType;
552 }
553 }
554 }
555 }
556
557 return ppdev->hsurfScreen;
558
559l_Failure:
560
561 DrvDisableSurface(dhpdev);
562
563 return((HSURF)0);
564}
565
566/******************************Public*Routine******************************\
567* DrvDisableSurface
568*
569* Free resources allocated by DrvEnableSurface. Release the surface.
570*
571\**************************************************************************/
572
573VOID DrvDisableSurface(
574DHPDEV dhpdev)
575{
576 PPDEV ppdev = (PPDEV)dhpdev;
577
578 DISPDBG((0, "VBoxDisp::DrvDisableSurface called\n"));
579 if (ppdev->psoScreenBitmap)
580 {
581 EngUnlockSurface (ppdev->psoScreenBitmap);
582 ppdev->psoScreenBitmap = NULL;
583 }
584
585 if (ppdev->hsurfScreen)
586 {
587 EngDeleteSurface(ppdev->hsurfScreen);
588 ppdev->hsurfScreen = (HSURF)0;
589 }
590
591 if (ppdev->hsurfScreenBitmap)
592 {
593 EngDeleteSurface(ppdev->hsurfScreenBitmap);
594 ppdev->hsurfScreenBitmap = (HSURF)0;
595 }
596
597 vDisableSURF(ppdev);
598}
599
600/******************************Public*Routine******************************\
601* DrvAssertMode
602*
603* This asks the device to reset itself to the mode of the pdev passed in.
604*
605\**************************************************************************/
606
607BOOL DrvAssertMode(
608DHPDEV dhpdev,
609BOOL bEnable)
610{
611 PPDEV ppdev = (PPDEV) dhpdev;
612 ULONG ulReturn;
613 PBYTE pjScreen;
614
615 DISPDBG((0, "DISP DrvAssertMode called bEnable = %d\n", bEnable));
616
617 if (bEnable)
618 {
619 pjScreen = ppdev->pjScreen;
620
621 if (!bInitSURF(ppdev, FALSE))
622 {
623 DISPDBG((0, "DISP DrvAssertMode failed bInitSURF\n"));
624 return (FALSE);
625 }
626
627 if (pjScreen != ppdev->pjScreen)
628 {
629 HSURF hsurf;
630 SIZEL sizl;
631 SURFOBJ *pso;
632
633 DISPDBG((0, "DISP DrvAssertMode Screen pointer has changed!!!\n"));
634
635 sizl.cx = ppdev->cxScreen;
636 sizl.cy = ppdev->cyScreen;
637
638 hsurf = (HSURF) EngCreateBitmap(sizl,
639 ppdev->lDeltaScreen,
640 ppdev->ulBitmapType,
641 (ppdev->lDeltaScreen > 0) ? BMF_TOPDOWN : 0,
642 (PVOID) (ppdev->pjScreen));
643
644 if (hsurf == (HSURF) 0)
645 {
646 DISPDBG((0, "DISP DrvAssertMode failed EngCreateBitmap\n"));
647 return FALSE;
648 }
649
650 pso = EngLockSurface(hsurf);
651
652 if (ppdev->psoScreenBitmap)
653 {
654 EngUnlockSurface (ppdev->psoScreenBitmap);
655 ppdev->psoScreenBitmap = NULL;
656 }
657
658 if (ppdev->hsurfScreenBitmap)
659 {
660 EngDeleteSurface(ppdev->hsurfScreenBitmap);
661 ppdev->hsurfScreenBitmap = (HSURF)0;
662 }
663
664 ppdev->hsurfScreenBitmap = hsurf;
665 ppdev->psoScreenBitmap = pso;
666 }
667
668 if (!EngAssociateSurface(ppdev->hsurfScreenBitmap, ppdev->hdevEng, 0))
669 {
670 DISPDBG((0, "DISP DrvAssertMode failed EngAssociateSurface for ScreenBitmap.\n"));
671 return FALSE;
672 }
673
674 if (!EngAssociateSurface(ppdev->hsurfScreen, ppdev->hdevEng, ppdev->flHooks))
675 {
676 DISPDBG((0, "DISP DrvAssertMode failed EngAssociateSurface for Screen.\n"));
677 return FALSE;
678 }
679
680 return TRUE;
681 }
682 else
683 {
684 //
685 // We must give up the display.
686 // Call the kernel driver to reset the device to a known state.
687 //
688
689 if (EngDeviceIoControl(ppdev->hDriver,
690 IOCTL_VIDEO_RESET_DEVICE,
691 NULL,
692 0,
693 NULL,
694 0,
695 &ulReturn))
696 {
697 DISPDBG((0, "DISP DrvAssertMode failed IOCTL\n"));
698 return FALSE;
699 }
700 else
701 {
702 return TRUE;
703 }
704 }
705}
706
707/******************************Public*Routine******************************\
708* DrvGetModes
709*
710* Returns the list of available modes for the device.
711*
712\**************************************************************************/
713
714ULONG DrvGetModes(
715HANDLE hDriver,
716ULONG cjSize,
717DEVMODEW *pdm)
718
719{
720
721 DWORD cModes;
722 DWORD cbOutputSize;
723 PVIDEO_MODE_INFORMATION pVideoModeInformation, pVideoTemp;
724 DWORD cOutputModes = cjSize / (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
725 DWORD cbModeSize;
726
727 DISPDBG((3, "DrvGetModes\n"));
728
729 cModes = getAvailableModes(hDriver,
730 (PVIDEO_MODE_INFORMATION *) &pVideoModeInformation,
731 &cbModeSize);
732
733 if (cModes == 0)
734 {
735 DISPDBG((0, "DrvGetModes failed to get mode information"));
736 return 0;
737 }
738
739 if (pdm == NULL)
740 {
741 cbOutputSize = cModes * (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
742 }
743 else
744 {
745 //
746 // Now copy the information for the supported modes back into the output
747 // buffer
748 //
749
750 cbOutputSize = 0;
751
752 pVideoTemp = pVideoModeInformation;
753
754 do
755 {
756 if (pVideoTemp->Length != 0)
757 {
758 if (cOutputModes == 0)
759 {
760 break;
761 }
762
763 //
764 // Zero the entire structure to start off with.
765 //
766
767 memset(pdm, 0, sizeof(DEVMODEW));
768
769 //
770 // Set the name of the device to the name of the DLL.
771 //
772
773 memcpy(pdm->dmDeviceName, DLL_NAME, sizeof(DLL_NAME));
774
775 pdm->dmSpecVersion = DM_SPECVERSION;
776 pdm->dmDriverVersion = DM_SPECVERSION;
777 pdm->dmSize = sizeof(DEVMODEW);
778 pdm->dmDriverExtra = DRIVER_EXTRA_SIZE;
779
780 pdm->dmBitsPerPel = pVideoTemp->NumberOfPlanes *
781 pVideoTemp->BitsPerPlane;
782 pdm->dmPelsWidth = pVideoTemp->VisScreenWidth;
783 pdm->dmPelsHeight = pVideoTemp->VisScreenHeight;
784 pdm->dmDisplayFrequency = pVideoTemp->Frequency;
785 pdm->dmDisplayFlags = 0;
786
787 pdm->dmFields = DM_BITSPERPEL |
788 DM_PELSWIDTH |
789 DM_PELSHEIGHT |
790 DM_DISPLAYFREQUENCY |
791 DM_DISPLAYFLAGS ;
792
793 //
794 // Go to the next DEVMODE entry in the buffer.
795 //
796
797 cOutputModes--;
798
799 pdm = (LPDEVMODEW) ( ((ULONG_PTR)pdm) + sizeof(DEVMODEW)
800 + DRIVER_EXTRA_SIZE);
801
802 cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
803
804 }
805
806 pVideoTemp = (PVIDEO_MODE_INFORMATION)
807 (((PUCHAR)pVideoTemp) + cbModeSize);
808
809 } while (--cModes);
810 }
811
812 EngFreeMem(pVideoModeInformation);
813
814 return cbOutputSize;
815
816}
817
818VOID DrvSynchronize(
819IN DHPDEV dhpdev,
820IN RECTL *prcl)
821{
822}
823
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette