Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

831 lines
27 KiB

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