VirtualBox

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

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

changed nt4 detection

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