VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/screen.c@ 4027

Last change on this file since 4027 was 4027, checked in by vboxsync, 17 years ago

Direct draw heap and miniport heap memory reservation for Windows guest additions.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.0 KB
Line 
1/******************************Module*Header*******************************\
2*
3* *******************
4* * GDI SAMPLE CODE *
5* *******************
6*
7* Module Name: screen.c
8*
9* Initializes the GDIINFO and DEVINFO structures for DrvEnablePDEV.
10*
11* Copyright (c) 1992-1998 Microsoft Corporation
12\**************************************************************************/
13
14#include "driver.h"
15
16#define SYSTM_LOGFONT {16,7,0,0,700,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"System"}
17#define HELVE_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"MS Sans Serif"}
18#define COURI_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,FIXED_PITCH | FF_DONTCARE, L"Courier"}
19
20// This is the basic devinfo for a default driver. This is used as a base and customized based
21// on information passed back from the miniport driver.
22
23const DEVINFO gDevInfoFrameBuffer = {
24 ( GCAPS_OPAQUERECT
25#ifdef VBOX_WITH_DDRAW
26 | GCAPS_DIRECTDRAW
27#endif
28 | GCAPS_MONO_DITHER
29 ), /* Graphics capabilities */
30 SYSTM_LOGFONT, /* Default font description */
31 HELVE_LOGFONT, /* ANSI variable font description */
32 COURI_LOGFONT, /* ANSI fixed font description */
33 0, /* Count of device fonts */
34 0, /* Preferred DIB format */
35 8, /* Width of color dither */
36 8, /* Height of color dither */
37 0 /* Default palette to use for this device */
38};
39
40/* Setup display information after remapping. */
41static void vboxSetupDisplayInfo (PPDEV ppdev, VIDEO_MEMORY_INFORMATION *pMemoryInformation)
42{
43 VBOXDISPLAYINFO *pInfo;
44 uint8_t *pu8;
45
46 DWORD returnedDataLength;
47 QUERYDISPLAYINFORESULT DispInfo;
48 RtlZeroMemory(&DispInfo, sizeof (DispInfo));
49 if (EngDeviceIoControl(ppdev->hDriver,
50 IOCTL_VIDEO_QUERY_DISPLAY_INFO,
51 NULL,
52 0,
53 &DispInfo,
54 sizeof(DispInfo),
55 &returnedDataLength))
56 {
57 DISPDBG((1, "DISP bInitSURF failed IOCTL_VIDEO_QUERY_DISPLAY_INFO\n"));
58 ppdev->pInfo = NULL;
59 return;
60 }
61
62 if (returnedDataLength != sizeof (QUERYDISPLAYINFORESULT)
63 || DispInfo.u32DisplayInfoSize >= pMemoryInformation->VideoRamLength)
64 {
65 DISPDBG((1, "DISP bInitSURF failed DispInfo.u32DisplayInfoSize 0x%x >= pMemoryInformation->VideoRamLength 0x%x\n",
66 DispInfo.u32DisplayInfoSize, pMemoryInformation->VideoRamLength));
67 ppdev->pInfo = NULL;
68 ppdev->cbDisplayInformation = 0;
69 return;
70 }
71
72 ppdev->iDevice = DispInfo.iDevice;
73 ppdev->cbDisplayInformation = DispInfo.u32DisplayInfoSize;
74
75 pu8 = (uint8_t *)pMemoryInformation->VideoRamBase;
76 pu8 += pMemoryInformation->VideoRamLength - DispInfo.u32DisplayInfoSize;
77
78 pInfo = (VBOXDISPLAYINFO *)pu8;
79 pu8 += sizeof (VBOXDISPLAYINFO);
80
81 pInfo->hdrLink.u8Type = VBOX_VIDEO_INFO_TYPE_LINK;
82 pInfo->hdrLink.u8Reserved = 0;
83 pInfo->hdrLink.u16Length = sizeof (VBOXVIDEOINFOLINK);
84 pInfo->link.i32Offset = 0;
85
86 pInfo->hdrScreen.u8Type = VBOX_VIDEO_INFO_TYPE_SCREEN;
87 pInfo->hdrScreen.u8Reserved = 0;
88 pInfo->hdrScreen.u16Length = sizeof (VBOXVIDEOINFOSCREEN);
89 DISPDBG((1, "Setup: %d,%d\n", ppdev->ptlDevOrg.x, ppdev->ptlDevOrg.y));
90 pInfo->screen.xOrigin = ppdev->ptlDevOrg.x;
91 pInfo->screen.yOrigin = ppdev->ptlDevOrg.y;
92 pInfo->screen.u32LineSize = 0;
93 pInfo->screen.u16Width = 0;
94 pInfo->screen.u16Height = 0;
95 pInfo->screen.bitsPerPixel = 0;
96 pInfo->screen.u8Flags = VBOX_VIDEO_INFO_SCREEN_F_NONE;
97
98 pInfo->hdrHostEvents.u8Type = VBOX_VIDEO_INFO_TYPE_HOST_EVENTS;
99 pInfo->hdrHostEvents.u8Reserved = 0;
100 pInfo->hdrHostEvents.u16Length = sizeof (VBOXVIDEOINFOHOSTEVENTS);
101 pInfo->hostEvents.fu32Events = VBOX_VIDEO_INFO_HOST_EVENTS_F_NONE;
102
103 pInfo->hdrEnd.u8Type = VBOX_VIDEO_INFO_TYPE_END;
104 pInfo->hdrEnd.u8Reserved = 0;
105 pInfo->hdrEnd.u16Length = 0;
106
107 ppdev->pInfo = pInfo;
108}
109
110
111static void vboxUpdateDisplayInfo (PPDEV ppdev)
112{
113 if (ppdev->pInfo)
114 {
115 ppdev->pInfo->screen.u32LineSize = ppdev->lDeltaScreen;
116 ppdev->pInfo->screen.u16Width = (uint16_t)ppdev->cxScreen;
117 ppdev->pInfo->screen.u16Height = (uint16_t)ppdev->cyScreen;
118 ppdev->pInfo->screen.bitsPerPixel = (uint8_t)ppdev->ulBitCount;
119 ppdev->pInfo->screen.u8Flags = VBOX_VIDEO_INFO_SCREEN_F_ACTIVE;
120
121 DISPDBG((1, "Update: %d,%d\n", ppdev->ptlDevOrg.x, ppdev->ptlDevOrg.y));
122 VBoxProcessDisplayInfo(ppdev);
123 }
124}
125
126
127/******************************Public*Routine******************************\
128* bInitSURF
129*
130* Enables the surface. Maps the frame buffer into memory.
131*
132\**************************************************************************/
133
134BOOL bInitSURF(PPDEV ppdev, BOOL bFirst)
135{
136 DWORD returnedDataLength;
137 DWORD MaxWidth, MaxHeight;
138 VIDEO_MEMORY videoMemory;
139 VIDEO_MEMORY_INFORMATION videoMemoryInformation;
140 ULONG RemappingNeeded = 0;
141
142 //
143 // Set the current mode into the hardware.
144 //
145
146 if (EngDeviceIoControl(ppdev->hDriver,
147 IOCTL_VIDEO_SET_CURRENT_MODE,
148 &(ppdev->ulMode),
149 sizeof(ULONG),
150 &RemappingNeeded,
151 sizeof(ULONG),
152 &returnedDataLength))
153 {
154 DISPDBG((1, "DISP bInitSURF failed IOCTL_SET_MODE\n"));
155 return(FALSE);
156 }
157
158 //
159 // If this is the first time we enable the surface we need to map in the
160 // memory also.
161 //
162
163 if (bFirst || RemappingNeeded)
164 {
165 videoMemory.RequestedVirtualAddress = NULL;
166
167 if (EngDeviceIoControl(ppdev->hDriver,
168 IOCTL_VIDEO_MAP_VIDEO_MEMORY,
169 &videoMemory,
170 sizeof(VIDEO_MEMORY),
171 &videoMemoryInformation,
172 sizeof(VIDEO_MEMORY_INFORMATION),
173 &returnedDataLength))
174 {
175 DISPDBG((1, "DISP bInitSURF failed IOCTL_VIDEO_MAP\n"));
176 return(FALSE);
177 }
178
179 ppdev->pjScreen = (PBYTE)(videoMemoryInformation.FrameBufferBase);
180
181 if (videoMemoryInformation.FrameBufferBase !=
182 videoMemoryInformation.VideoRamBase)
183 {
184 DISPDBG((0, "VideoRamBase does not correspond to FrameBufferBase\n"));
185 }
186
187 //
188 // Make sure we can access this video memory
189 //
190
191 *(PULONG)(ppdev->pjScreen) = 0xaa55aa55;
192
193 if (*(PULONG)(ppdev->pjScreen) != 0xaa55aa55) {
194
195 DISPDBG((1, "Frame buffer memory is not accessible.\n"));
196 return(FALSE);
197 }
198
199 //
200 // Initialize the head of the offscreen list to NULL.
201 //
202
203 ppdev->pOffscreenList = NULL;
204
205 // It's a hardware pointer; set up pointer attributes.
206
207 MaxHeight = ppdev->PointerCapabilities.MaxHeight;
208
209 // Allocate space for two DIBs (data/mask) for the pointer. If this
210 // device supports a color Pointer, we will allocate a larger bitmap.
211 // If this is a color bitmap we allocate for the largest possible
212 // bitmap because we have no idea of what the pixel depth might be.
213
214 // Width rounded up to nearest byte multiple
215
216 if (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER))
217 {
218 MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8;
219 }
220 else
221 {
222 MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD);
223 }
224
225 ppdev->cjPointerAttributes =
226 sizeof(VIDEO_POINTER_ATTRIBUTES) +
227 ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2);
228
229 ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES)
230 EngAllocMem(0, ppdev->cjPointerAttributes, ALLOC_TAG);
231
232 if (ppdev->pPointerAttributes == NULL) {
233
234 DISPDBG((0, "bInitPointer EngAllocMem failed\n"));
235 return(FALSE);
236 }
237
238 ppdev->pPointerAttributes->Flags = ppdev->PointerCapabilities.Flags;
239 ppdev->pPointerAttributes->WidthInBytes = MaxWidth;
240 ppdev->pPointerAttributes->Width = ppdev->PointerCapabilities.MaxWidth;
241 ppdev->pPointerAttributes->Height = MaxHeight;
242 ppdev->pPointerAttributes->Column = 0;
243 ppdev->pPointerAttributes->Row = 0;
244 ppdev->pPointerAttributes->Enable = 0;
245
246 /* Setup the display information. */
247 vboxSetupDisplayInfo (ppdev, &videoMemoryInformation);
248
249 ppdev->cScreenSize = videoMemoryInformation.VideoRamLength - ppdev->cbDisplayInformation;
250 ppdev->cFrameBufferSize = videoMemoryInformation.FrameBufferLength;
251 }
252
253
254 DISPDBG((1, "DISP bInitSURF: ppdev->ulBitCount %d\n", ppdev->ulBitCount));
255
256 if ( ppdev->ulBitCount == 16
257 || ppdev->ulBitCount == 24
258 || ppdev->ulBitCount == 32)
259 {
260 if (ppdev->pInfo) /* Do not use VBVA on old hosts. */
261 {
262 /* Enable VBVA for this video mode. */
263 vboxVbvaEnable (ppdev);
264 }
265 }
266
267 DISPDBG((1, "DISP bInitSURF success\n"));
268
269 /* Update the display information. */
270 vboxUpdateDisplayInfo (ppdev);
271
272 return(TRUE);
273}
274
275/******************************Public*Routine******************************\
276* vDisableSURF
277*
278* Disable the surface. Un-Maps the frame in memory.
279*
280\**************************************************************************/
281
282VOID vDisableSURF(PPDEV ppdev)
283{
284 DWORD returnedDataLength;
285 VIDEO_MEMORY videoMemory;
286
287 videoMemory.RequestedVirtualAddress = (PVOID) ppdev->pjScreen;
288
289 if (EngDeviceIoControl(ppdev->hDriver,
290 IOCTL_VIDEO_UNMAP_VIDEO_MEMORY,
291 &videoMemory,
292 sizeof(VIDEO_MEMORY),
293 NULL,
294 0,
295 &returnedDataLength))
296 {
297 DISPDBG((0, "DISP vDisableSURF failed IOCTL_VIDEO_UNMAP\n"));
298 }
299}
300
301
302/******************************Public*Routine******************************\
303* bInitPDEV
304*
305* Determine the mode we should be in based on the DEVMODE passed in.
306* Query mini-port to get information needed to fill in the DevInfo and the
307* GdiInfo .
308*
309\**************************************************************************/
310
311BOOL bInitPDEV(
312PPDEV ppdev,
313DEVMODEW *pDevMode,
314GDIINFO *pGdiInfo,
315DEVINFO *pDevInfo)
316{
317 ULONG cModes;
318 PVIDEO_MODE_INFORMATION pVideoBuffer, pVideoModeSelected, pVideoTemp;
319 VIDEO_COLOR_CAPABILITIES colorCapabilities;
320 ULONG ulTemp;
321 BOOL bSelectDefault;
322 ULONG cbModeSize;
323
324 //
325 // calls the miniport to get mode information.
326 //
327
328 cModes = getAvailableModes(ppdev->hDriver, &pVideoBuffer, &cbModeSize);
329
330 if (cModes == 0)
331 {
332 return(FALSE);
333 }
334
335 //
336 // Now see if the requested mode has a match in that table.
337 //
338
339 pVideoModeSelected = NULL;
340 pVideoTemp = pVideoBuffer;
341
342 if ((pDevMode->dmPelsWidth == 0) &&
343 (pDevMode->dmPelsHeight == 0) &&
344 (pDevMode->dmBitsPerPel == 0) &&
345 (pDevMode->dmDisplayFrequency == 0))
346 {
347 DISPDBG((2, "Default mode requested"));
348 bSelectDefault = TRUE;
349 }
350 else
351 {
352 DISPDBG((2, "Requested mode...\n"));
353 DISPDBG((2, " Screen width -- %li\n", pDevMode->dmPelsWidth));
354 DISPDBG((2, " Screen height -- %li\n", pDevMode->dmPelsHeight));
355 DISPDBG((2, " Bits per pel -- %li\n", pDevMode->dmBitsPerPel));
356 DISPDBG((2, " Frequency -- %li\n", pDevMode->dmDisplayFrequency));
357
358 bSelectDefault = FALSE;
359 }
360
361 while (cModes--)
362 {
363 if (pVideoTemp->Length != 0)
364 {
365 if (bSelectDefault ||
366 ((pVideoTemp->VisScreenWidth == pDevMode->dmPelsWidth) &&
367 (pVideoTemp->VisScreenHeight == pDevMode->dmPelsHeight) &&
368 (pVideoTemp->BitsPerPlane *
369 pVideoTemp->NumberOfPlanes == pDevMode->dmBitsPerPel) &&
370 (pVideoTemp->Frequency == pDevMode->dmDisplayFrequency)))
371 {
372 pVideoModeSelected = pVideoTemp;
373 DISPDBG((3, "Found a match\n")) ;
374 break;
375 }
376 }
377
378 pVideoTemp = (PVIDEO_MODE_INFORMATION)
379 (((PUCHAR)pVideoTemp) + cbModeSize);
380 }
381
382 //
383 // If no mode has been found, return an error
384 //
385
386 if (pVideoModeSelected == NULL)
387 {
388 EngFreeMem(pVideoBuffer);
389 DISPDBG((0,"DISP bInitPDEV failed - no valid modes\n"));
390 return(FALSE);
391 }
392
393 //
394 // Fill in the GDIINFO data structure with the information returned from
395 // the kernel driver.
396 //
397
398 ppdev->ulMode = pVideoModeSelected->ModeIndex;
399 ppdev->cxScreen = pVideoModeSelected->VisScreenWidth;
400 ppdev->cyScreen = pVideoModeSelected->VisScreenHeight;
401 ppdev->ulBitCount = pVideoModeSelected->BitsPerPlane *
402 pVideoModeSelected->NumberOfPlanes;
403 ppdev->lDeltaScreen = pVideoModeSelected->ScreenStride;
404
405 ppdev->flRed = pVideoModeSelected->RedMask;
406 ppdev->flGreen = pVideoModeSelected->GreenMask;
407 ppdev->flBlue = pVideoModeSelected->BlueMask;
408
409
410 pGdiInfo->ulVersion = GDI_DRIVER_VERSION;
411 pGdiInfo->ulTechnology = DT_RASDISPLAY;
412 pGdiInfo->ulHorzSize = pVideoModeSelected->XMillimeter;
413 pGdiInfo->ulVertSize = pVideoModeSelected->YMillimeter;
414
415 pGdiInfo->ulHorzRes = ppdev->cxScreen;
416 pGdiInfo->ulVertRes = ppdev->cyScreen;
417 pGdiInfo->ulPanningHorzRes = ppdev->cxScreen;
418 pGdiInfo->ulPanningVertRes = ppdev->cyScreen;
419 pGdiInfo->cBitsPixel = pVideoModeSelected->BitsPerPlane;
420 pGdiInfo->cPlanes = pVideoModeSelected->NumberOfPlanes;
421 pGdiInfo->ulVRefresh = pVideoModeSelected->Frequency;
422 /* bit block transfers are accelerated */
423 pGdiInfo->ulBltAlignment = 0;
424
425 pGdiInfo->ulLogPixelsX = pDevMode->dmLogPixels;
426 pGdiInfo->ulLogPixelsY = pDevMode->dmLogPixels;
427
428#ifdef MIPS
429 if (ppdev->ulBitCount == 8)
430 pGdiInfo->flTextCaps = (TC_RA_ABLE | TC_SCROLLBLT);
431 else
432#endif
433 pGdiInfo->flTextCaps = TC_RA_ABLE;
434
435 pGdiInfo->flRaster = 0; // flRaster is reserved by DDI
436
437 pGdiInfo->ulDACRed = pVideoModeSelected->NumberRedBits;
438 pGdiInfo->ulDACGreen = pVideoModeSelected->NumberGreenBits;
439 pGdiInfo->ulDACBlue = pVideoModeSelected->NumberBlueBits;
440
441 pGdiInfo->ulAspectX = 0x24; // One-to-one aspect ratio
442 pGdiInfo->ulAspectY = 0x24;
443 pGdiInfo->ulAspectXY = 0x33;
444
445 pGdiInfo->xStyleStep = 1; // A style unit is 3 pels
446 pGdiInfo->yStyleStep = 1;
447 pGdiInfo->denStyleStep = 3;
448
449 pGdiInfo->ptlPhysOffset.x = 0;
450 pGdiInfo->ptlPhysOffset.y = 0;
451 pGdiInfo->szlPhysSize.cx = 0;
452 pGdiInfo->szlPhysSize.cy = 0;
453
454 // RGB and CMY color info.
455
456 //
457 // try to get it from the miniport.
458 // if the miniport doesn ot support this feature, use defaults.
459 //
460
461 if (EngDeviceIoControl(ppdev->hDriver,
462 IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES,
463 NULL,
464 0,
465 &colorCapabilities,
466 sizeof(VIDEO_COLOR_CAPABILITIES),
467 &ulTemp))
468 {
469
470 DISPDBG((2, "getcolorCapabilities failed \n"));
471
472 pGdiInfo->ciDevice.Red.x = 6700;
473 pGdiInfo->ciDevice.Red.y = 3300;
474 pGdiInfo->ciDevice.Red.Y = 0;
475 pGdiInfo->ciDevice.Green.x = 2100;
476 pGdiInfo->ciDevice.Green.y = 7100;
477 pGdiInfo->ciDevice.Green.Y = 0;
478 pGdiInfo->ciDevice.Blue.x = 1400;
479 pGdiInfo->ciDevice.Blue.y = 800;
480 pGdiInfo->ciDevice.Blue.Y = 0;
481 pGdiInfo->ciDevice.AlignmentWhite.x = 3127;
482 pGdiInfo->ciDevice.AlignmentWhite.y = 3290;
483 pGdiInfo->ciDevice.AlignmentWhite.Y = 0;
484
485 pGdiInfo->ciDevice.RedGamma = 20000;
486 pGdiInfo->ciDevice.GreenGamma = 20000;
487 pGdiInfo->ciDevice.BlueGamma = 20000;
488
489 }
490 else
491 {
492 pGdiInfo->ciDevice.Red.x = colorCapabilities.RedChromaticity_x;
493 pGdiInfo->ciDevice.Red.y = colorCapabilities.RedChromaticity_y;
494 pGdiInfo->ciDevice.Red.Y = 0;
495 pGdiInfo->ciDevice.Green.x = colorCapabilities.GreenChromaticity_x;
496 pGdiInfo->ciDevice.Green.y = colorCapabilities.GreenChromaticity_y;
497 pGdiInfo->ciDevice.Green.Y = 0;
498 pGdiInfo->ciDevice.Blue.x = colorCapabilities.BlueChromaticity_x;
499 pGdiInfo->ciDevice.Blue.y = colorCapabilities.BlueChromaticity_y;
500 pGdiInfo->ciDevice.Blue.Y = 0;
501 pGdiInfo->ciDevice.AlignmentWhite.x = colorCapabilities.WhiteChromaticity_x;
502 pGdiInfo->ciDevice.AlignmentWhite.y = colorCapabilities.WhiteChromaticity_y;
503 pGdiInfo->ciDevice.AlignmentWhite.Y = colorCapabilities.WhiteChromaticity_Y;
504
505 // if we have a color device store the three color gamma values,
506 // otherwise store the unique gamma value in all three.
507
508 if (colorCapabilities.AttributeFlags & VIDEO_DEVICE_COLOR)
509 {
510 pGdiInfo->ciDevice.RedGamma = colorCapabilities.RedGamma;
511 pGdiInfo->ciDevice.GreenGamma = colorCapabilities.GreenGamma;
512 pGdiInfo->ciDevice.BlueGamma = colorCapabilities.BlueGamma;
513 }
514 else
515 {
516 pGdiInfo->ciDevice.RedGamma = colorCapabilities.WhiteGamma;
517 pGdiInfo->ciDevice.GreenGamma = colorCapabilities.WhiteGamma;
518 pGdiInfo->ciDevice.BlueGamma = colorCapabilities.WhiteGamma;
519 }
520
521 };
522
523 pGdiInfo->ciDevice.Cyan.x = 0;
524 pGdiInfo->ciDevice.Cyan.y = 0;
525 pGdiInfo->ciDevice.Cyan.Y = 0;
526 pGdiInfo->ciDevice.Magenta.x = 0;
527 pGdiInfo->ciDevice.Magenta.y = 0;
528 pGdiInfo->ciDevice.Magenta.Y = 0;
529 pGdiInfo->ciDevice.Yellow.x = 0;
530 pGdiInfo->ciDevice.Yellow.y = 0;
531 pGdiInfo->ciDevice.Yellow.Y = 0;
532
533 // No dye correction for raster displays.
534
535 pGdiInfo->ciDevice.MagentaInCyanDye = 0;
536 pGdiInfo->ciDevice.YellowInCyanDye = 0;
537 pGdiInfo->ciDevice.CyanInMagentaDye = 0;
538 pGdiInfo->ciDevice.YellowInMagentaDye = 0;
539 pGdiInfo->ciDevice.CyanInYellowDye = 0;
540 pGdiInfo->ciDevice.MagentaInYellowDye = 0;
541
542 pGdiInfo->ulDevicePelsDPI = 0; // For printers only
543 pGdiInfo->ulPrimaryOrder = PRIMARY_ORDER_CBA;
544
545 // Note: this should be modified later to take into account the size
546 // of the display and the resolution.
547
548 pGdiInfo->ulHTPatternSize = HT_PATSIZE_4x4_M;
549
550 pGdiInfo->flHTFlags = HT_FLAG_ADDITIVE_PRIMS;
551
552 // Fill in the basic devinfo structure
553
554 *pDevInfo = gDevInfoFrameBuffer;
555
556 // Fill in the rest of the devinfo and GdiInfo structures.
557
558 if (ppdev->ulBitCount == 8)
559 {
560 // It is Palette Managed.
561
562 pGdiInfo->ulNumColors = 20;
563 pGdiInfo->ulNumPalReg = 1 << ppdev->ulBitCount;
564
565 pDevInfo->flGraphicsCaps |= (GCAPS_PALMANAGED | GCAPS_COLOR_DITHER);
566
567 pGdiInfo->ulHTOutputFormat = HT_FORMAT_8BPP;
568 pDevInfo->iDitherFormat = BMF_8BPP;
569
570 // Assuming palette is orthogonal - all colors are same size.
571
572 ppdev->cPaletteShift = 8 - pGdiInfo->ulDACRed;
573 }
574 else
575 {
576 pGdiInfo->ulNumColors = (ULONG) (-1);
577 pGdiInfo->ulNumPalReg = 0;
578
579 if (ppdev->ulBitCount == 16)
580 {
581 pGdiInfo->ulHTOutputFormat = HT_FORMAT_16BPP;
582 pDevInfo->iDitherFormat = BMF_16BPP;
583 }
584 else if (ppdev->ulBitCount == 24)
585 {
586 pGdiInfo->ulHTOutputFormat = HT_FORMAT_24BPP;
587 pDevInfo->iDitherFormat = BMF_24BPP;
588 }
589 else
590 {
591 pGdiInfo->ulHTOutputFormat = HT_FORMAT_32BPP;
592 pDevInfo->iDitherFormat = BMF_32BPP;
593 }
594 }
595
596 EngFreeMem(pVideoBuffer);
597
598 return(TRUE);
599}
600
601
602/******************************Public*Routine******************************\
603* getAvailableModes
604*
605* Calls the miniport to get the list of modes supported by the kernel driver,
606* and returns the list of modes supported by the diplay driver among those
607*
608* returns the number of entries in the videomode buffer.
609* 0 means no modes are supported by the miniport or that an error occured.
610*
611* NOTE: the buffer must be freed up by the caller.
612*
613\**************************************************************************/
614
615DWORD getAvailableModes(
616HANDLE hDriver,
617PVIDEO_MODE_INFORMATION *modeInformation,
618DWORD *cbModeSize)
619{
620 ULONG ulTemp;
621 VIDEO_NUM_MODES modes;
622 PVIDEO_MODE_INFORMATION pVideoTemp;
623
624 //
625 // Get the number of modes supported by the mini-port
626 //
627
628 if (EngDeviceIoControl(hDriver,
629 IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES,
630 NULL,
631 0,
632 &modes,
633 sizeof(VIDEO_NUM_MODES),
634 &ulTemp))
635 {
636 DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_NUM_AVAIL_MODES\n"));
637 return(0);
638 }
639
640 *cbModeSize = modes.ModeInformationLength;
641
642 //
643 // Allocate the buffer for the mini-port to write the modes in.
644 //
645
646 *modeInformation = (PVIDEO_MODE_INFORMATION)
647 EngAllocMem(0, modes.NumModes *
648 modes.ModeInformationLength, ALLOC_TAG);
649
650 if (*modeInformation == (PVIDEO_MODE_INFORMATION) NULL)
651 {
652 DISPDBG((0, "getAvailableModes failed EngAllocMem\n"));
653
654 return 0;
655 }
656
657 //
658 // Ask the mini-port to fill in the available modes.
659 //
660
661 if (EngDeviceIoControl(hDriver,
662 IOCTL_VIDEO_QUERY_AVAIL_MODES,
663 NULL,
664 0,
665 *modeInformation,
666 modes.NumModes * modes.ModeInformationLength,
667 &ulTemp))
668 {
669
670 DISPDBG((0, "getAvailableModes failed VIDEO_QUERY_AVAIL_MODES\n"));
671
672 EngFreeMem(*modeInformation);
673 *modeInformation = (PVIDEO_MODE_INFORMATION) NULL;
674
675 return(0);
676 }
677
678 //
679 // Now see which of these modes are supported by the display driver.
680 // As an internal mechanism, set the length to 0 for the modes we
681 // DO NOT support.
682 //
683
684 ulTemp = modes.NumModes;
685 pVideoTemp = *modeInformation;
686
687 //
688 // Mode is rejected if it is not one plane, or not graphics, or is not
689 // one of 8, 16 or 32 bits per pel.
690 //
691
692 while (ulTemp--)
693 {
694 if ((pVideoTemp->NumberOfPlanes != 1 ) ||
695 !(pVideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) ||
696 (pVideoTemp->AttributeFlags & VIDEO_MODE_BANKED) ||
697 ((pVideoTemp->BitsPerPlane != 8) &&
698 (pVideoTemp->BitsPerPlane != 16) &&
699 (pVideoTemp->BitsPerPlane != 24) &&
700 (pVideoTemp->BitsPerPlane != 32)))
701 {
702 pVideoTemp->Length = 0;
703 }
704
705 pVideoTemp = (PVIDEO_MODE_INFORMATION)
706 (((PUCHAR)pVideoTemp) + modes.ModeInformationLength);
707 }
708
709 return modes.NumModes;
710
711}
712
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