VirtualBox

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

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

DdMapMemory must map the offscreen heap as well. Report DdLock updates only for the primary surface.

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