Annotation of ntddk/src/video/displays/framebuf/screen.c, revision 1.1.1.1

1.1       root        1: /******************************Module*Header*******************************\
                      2: * Module Name: screen.c
                      3: *
                      4: * Initializes the GDIINFO and DEVINFO structures for DrvEnablePDEV.
                      5: *
                      6: * Copyright (c) 1992 Microsoft Corporation
                      7: \**************************************************************************/
                      8: 
                      9: #include "driver.h"
                     10: 
                     11: #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"}
                     12: #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"}
                     13: #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"}
                     14: 
                     15: // This is the basic devinfo for a default driver.  This is used as a base and customized based
                     16: // on information passed back from the miniport driver.
                     17: 
                     18: const DEVINFO gDevInfoFrameBuffer = {
                     19:     (GCAPS_OPAQUERECT | GCAPS_MONO_DITHER), /* Graphics capabilities         */
                     20:     SYSTM_LOGFONT,    /* Default font description */
                     21:     HELVE_LOGFONT,    /* ANSI variable font description   */
                     22:     COURI_LOGFONT,    /* ANSI fixed font description          */
                     23:     0,                /* Count of device fonts          */
                     24:     0,                /* Preferred DIB format          */
                     25:     8,                /* Width of color dither          */
                     26:     8,                /* Height of color dither   */
                     27:     0                 /* Default palette to use for this device */
                     28: };
                     29: 
                     30: /******************************Public*Routine******************************\
                     31: * bInitSURF
                     32: *
                     33: * Enables the surface.        Maps the frame buffer into memory.
                     34: *
                     35: \**************************************************************************/
                     36: 
                     37: BOOL bInitSURF(PPDEV ppdev, BOOL bFirst)
                     38: {
                     39:     DWORD returnedDataLength;
                     40:     DWORD MaxWidth, MaxHeight;
                     41:     VIDEO_MEMORY videoMemory;
                     42:     VIDEO_MEMORY_INFORMATION videoMemoryInformation;
                     43: 
                     44:     // Set the current mode into the hardware.
                     45:     if (!DeviceIoControl(ppdev->hDriver,
                     46:             IOCTL_VIDEO_SET_CURRENT_MODE,
                     47:             &(ppdev->ulMode),
                     48:             sizeof(ULONG),
                     49:             NULL,
                     50:             0,
                     51:             &returnedDataLength,
                     52:             NULL))
                     53:     {
                     54:         RIP("DISP bInitSURF failed IOCTL_SET_MODE\n");
                     55:         return(FALSE);
                     56:     }
                     57: 
                     58:     // If this is the first time we enable the surface we need to map in the
                     59:     // memory also.
                     60: 
                     61:     if (bFirst)
                     62:     {
                     63:         videoMemory.RequestedVirtualAddress = NULL;
                     64: 
                     65:         if (!DeviceIoControl(ppdev->hDriver,
                     66:                             IOCTL_VIDEO_MAP_VIDEO_MEMORY,
                     67:                             &videoMemory,
                     68:                             sizeof(VIDEO_MEMORY),
                     69:                             &videoMemoryInformation,
                     70:                             sizeof(VIDEO_MEMORY_INFORMATION),
                     71:                             &returnedDataLength,
                     72:                             NULL))
                     73:         {
                     74:             RIP("DISP bInitSURF failed IOCTL_VIDEO_MAP\n");
                     75:             return(FALSE);
                     76:         }
                     77: 
                     78:         ppdev->pjScreen = (PBYTE)(videoMemoryInformation.FrameBufferBase);
                     79: 
                     80:         // It's a hardware pointer; set up pointer attributes.
                     81: 
                     82:         MaxHeight = ppdev->PointerCapabilities.MaxHeight;
                     83: 
                     84:         // Allocate space for two DIBs (data/mask) for the pointer. If this
                     85:         // device supports a color Pointer, we will allocate a larger bitmap.
                     86:         // If this is a color bitmap we allocate for the largest possible
                     87:         // bitmap because we have no idea of what the pixel depth might be.
                     88: 
                     89:         // Width rounded up to nearest byte multiple
                     90: 
                     91:         if (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER)) {
                     92:             MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8;
                     93:         } else {
                     94:             MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD);
                     95:         }
                     96: 
                     97:         ppdev->cjPointerAttributes =
                     98:                 sizeof(VIDEO_POINTER_ATTRIBUTES) +
                     99:                 ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2);
                    100: 
                    101:         ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES)
                    102:                 LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT,
                    103:                 ppdev->cjPointerAttributes);
                    104: 
                    105:         if (ppdev->pPointerAttributes == NULL) {
                    106: 
                    107:             DISPDBG((0, "FRAMEBUF: bInitPointer LocalAlloc failed\n"));
                    108:             return(FALSE);
                    109:         }
                    110: 
                    111:         ppdev->pPointerAttributes->WidthInBytes = MaxWidth;
                    112:         ppdev->pPointerAttributes->Width = ppdev->PointerCapabilities.MaxWidth;
                    113:         ppdev->pPointerAttributes->Height = MaxHeight;
                    114:         ppdev->pPointerAttributes->Column = 0;
                    115:         ppdev->pPointerAttributes->Row = 0;
                    116:         ppdev->pPointerAttributes->Enable = 0;
                    117:     }
                    118: 
                    119:     return(TRUE);
                    120: }
                    121: 
                    122: /******************************Public*Routine******************************\
                    123: * vDisableSURF
                    124: *
                    125: * Disable the surface. Un-Maps the frame in memory.
                    126: *
                    127: \**************************************************************************/
                    128: 
                    129: VOID vDisableSURF(PPDEV ppdev)
                    130: {
                    131:     DWORD returnedDataLength;
                    132:     VIDEO_MEMORY videoMemory;
                    133: 
                    134:     videoMemory.RequestedVirtualAddress = (PVOID) ppdev->pjScreen;
                    135: 
                    136:     if (!DeviceIoControl(ppdev->hDriver,
                    137:                         IOCTL_VIDEO_UNMAP_VIDEO_MEMORY,
                    138:                         &videoMemory,
                    139:                         sizeof(VIDEO_MEMORY),
                    140:                         NULL,
                    141:                         0,
                    142:                         &returnedDataLength,
                    143:                         NULL))
                    144:     {
                    145:         RIP("DISP vDisableSURF failed IOCTL_VIDEO_UNMAP\n");
                    146:     }
                    147: 
                    148:     // We must give up the display.
                    149:     // Call the kernel driver to reset the device to a known state.
                    150: 
                    151:     if (!DeviceIoControl(ppdev->hDriver,
                    152:                          IOCTL_VIDEO_RESET_DEVICE,
                    153:                          NULL,
                    154:                          0,
                    155:                          NULL,
                    156:                          0,
                    157:                          &returnedDataLength,
                    158:                          NULL))
                    159:     {
                    160:         RIP("DISP vDisableSurf failed IOCTL_VIDEO_RESET_DEVICE");
                    161:     }
                    162: 
                    163: }
                    164: 
                    165: 
                    166: /******************************Public*Routine******************************\
                    167: * bInitPDEV
                    168: *
                    169: * Determine the mode we should be in based on the DEVMODE passed in.
                    170: * Query mini-port to get information needed to fill in the DevInfo and the
                    171: * GdiInfo .
                    172: *
                    173: \**************************************************************************/
                    174: 
                    175: BOOL bInitPDEV(
                    176: PPDEV ppdev,
                    177: DEVMODEW *pDevMode,
                    178: GDIINFO *pGdiInfo,
                    179: DEVINFO *pDevInfo)
                    180: {
                    181:     ULONG cModes;
                    182:     PVIDEO_MODE_INFORMATION pVideoBuffer, pVideoModeSelected, pVideoTemp;
                    183:     VIDEO_COLOR_CAPABILITIES colorCapabilities;
                    184:     ULONG ulTemp;
                    185:     BOOL bSelectDefault;
                    186:     ULONG cbModeSize;
                    187: 
                    188:     //
                    189:     // calls the miniport to get mode information.
                    190:     //
                    191: 
                    192:     cModes = getAvailableModes(ppdev->hDriver, &pVideoBuffer, &cbModeSize);
                    193: 
                    194:     if (cModes == 0)
                    195:     {
                    196:         return(FALSE);
                    197:     }
                    198: 
                    199:     //
                    200:     // Determine if we are looking for a default mode.
                    201:     //
                    202: 
                    203:     if ( ((pDevMode->dmPelsWidth) ||
                    204:           (pDevMode->dmPelsHeight) ||
                    205:           (pDevMode->dmBitsPerPel) ||
                    206:           (pDevMode->dmDisplayFlags) ||
                    207:           (pDevMode->dmDisplayFrequency)) == 0)
                    208:     {
                    209:         bSelectDefault = TRUE;
                    210:     }
                    211:     else
                    212:     {
                    213:         bSelectDefault = FALSE;
                    214:     }
                    215: 
                    216:     //
                    217:     // Now see if the requested mode has a match in that table.
                    218:     //
                    219: 
                    220:     pVideoModeSelected = NULL;
                    221:     pVideoTemp = pVideoBuffer;
                    222: 
                    223:     while (cModes--)
                    224:     {
                    225:         if (pVideoTemp->Length != 0)
                    226:         {
                    227:             if (bSelectDefault ||
                    228:                 ((pVideoTemp->VisScreenWidth  == pDevMode->dmPelsWidth) &&
                    229:                  (pVideoTemp->VisScreenHeight == pDevMode->dmPelsHeight) &&
                    230:                  (pVideoTemp->BitsPerPlane *
                    231:                   pVideoTemp->NumberOfPlanes  == pDevMode->dmBitsPerPel)) )
                    232:             {
                    233:                 pVideoModeSelected = pVideoTemp;
                    234:                 DISPDBG((3, "framebuf: Found a match\n")) ;
                    235:                 break;
                    236:             }
                    237:         }
                    238: 
                    239:         pVideoTemp = (PVIDEO_MODE_INFORMATION)
                    240:             (((PUCHAR)pVideoTemp) + cbModeSize);
                    241:     }
                    242: 
                    243:     //
                    244:     // If no mode has been found, return an error
                    245:     //
                    246: 
                    247:     if (pVideoModeSelected == NULL)
                    248:     {
                    249:         LocalFree(pVideoBuffer);
                    250:         return(FALSE);
                    251:     }
                    252: 
                    253:     //
                    254:     // Fill in the GDIINFO data structure with the information returned from
                    255:     // the kernel driver.
                    256:     //
                    257: 
                    258:     ppdev->ulMode = pVideoModeSelected->ModeIndex;
                    259:     ppdev->cxScreen = pVideoModeSelected->VisScreenWidth;
                    260:     ppdev->cyScreen = pVideoModeSelected->VisScreenHeight;
                    261:     ppdev->ulBitCount = pVideoModeSelected->BitsPerPlane *
                    262:                         pVideoModeSelected->NumberOfPlanes;
                    263:     ppdev->lDeltaScreen = pVideoModeSelected->ScreenStride;
                    264: 
                    265:     ppdev->flRed = pVideoModeSelected->RedMask;
                    266:     ppdev->flGreen = pVideoModeSelected->GreenMask;
                    267:     ppdev->flBlue = pVideoModeSelected->BlueMask;
                    268: 
                    269: 
                    270:     pGdiInfo->ulVersion    = 0x1000;    // Our driver is verion 1.000
                    271:     pGdiInfo->ulTechnology = DT_RASDISPLAY;
                    272:     pGdiInfo->ulHorzSize   = pVideoModeSelected->XMillimeter;
                    273:     pGdiInfo->ulVertSize   = pVideoModeSelected->YMillimeter;
                    274: 
                    275:     pGdiInfo->ulHorzRes   = ppdev->cxScreen;
                    276:     pGdiInfo->ulVertRes   = ppdev->cyScreen;
                    277:     pGdiInfo->cBitsPixel  = pVideoModeSelected->BitsPerPlane;
                    278:     pGdiInfo->cPlanes     = pVideoModeSelected->NumberOfPlanes;
                    279: 
                    280:     pGdiInfo->ulLogPixelsX = 96;
                    281:     pGdiInfo->ulLogPixelsY = 96;
                    282: 
                    283: #ifdef MIPS
                    284:     if (ppdev->ulBitCount == 8)
                    285:         pGdiInfo->flTextCaps = (TC_RA_ABLE | TC_SCROLLBLT);
                    286:     else
                    287: #endif
                    288:     pGdiInfo->flTextCaps = TC_RA_ABLE;
                    289: 
                    290:     pGdiInfo->flRaster = 0;           // flRaster is reserved by DDI
                    291: 
                    292:     pGdiInfo->ulDACRed   = pVideoModeSelected->NumberRedBits;
                    293:     pGdiInfo->ulDACGreen = pVideoModeSelected->NumberGreenBits;
                    294:     pGdiInfo->ulDACBlue  = pVideoModeSelected->NumberBlueBits;
                    295: 
                    296:     pGdiInfo->ulAspectX    = 0x24;    // One-to-one aspect ratio
                    297:     pGdiInfo->ulAspectY    = 0x24;
                    298:     pGdiInfo->ulAspectXY   = 0x33;
                    299: 
                    300:     pGdiInfo->xStyleStep   = 1;       // A style unit is 3 pels
                    301:     pGdiInfo->yStyleStep   = 1;
                    302:     pGdiInfo->denStyleStep = 3;
                    303: 
                    304:     pGdiInfo->ptlPhysOffset.x = 0;
                    305:     pGdiInfo->ptlPhysOffset.y = 0;
                    306:     pGdiInfo->szlPhysSize.cx  = 0;
                    307:     pGdiInfo->szlPhysSize.cy  = 0;
                    308: 
                    309:     // RGB and CMY color info.
                    310: 
                    311:     // try to get it from the miniport.
                    312:     // if the miniport doesn ot support this feature, use defaults.
                    313: 
                    314:     if (!DeviceIoControl(ppdev->hDriver,
                    315:                          IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES,
                    316:                          NULL,
                    317:                          0,
                    318:                          &colorCapabilities,
                    319:                          sizeof(VIDEO_COLOR_CAPABILITIES),
                    320:                          &ulTemp,
                    321:                          NULL))
                    322:     {
                    323: 
                    324:         DISPDBG((2, "FRAMEBUF getcolorCapabilities failed \n"));
                    325: 
                    326:         pGdiInfo->ciDevice.Red.x = 6700;
                    327:         pGdiInfo->ciDevice.Red.y = 3300;
                    328:         pGdiInfo->ciDevice.Red.Y = 0;
                    329:         pGdiInfo->ciDevice.Green.x = 2100;
                    330:         pGdiInfo->ciDevice.Green.y = 7100;
                    331:         pGdiInfo->ciDevice.Green.Y = 0;
                    332:         pGdiInfo->ciDevice.Blue.x = 1400;
                    333:         pGdiInfo->ciDevice.Blue.y = 800;
                    334:         pGdiInfo->ciDevice.Blue.Y = 0;
                    335:         pGdiInfo->ciDevice.AlignmentWhite.x = 3127;
                    336:         pGdiInfo->ciDevice.AlignmentWhite.y = 3290;
                    337:         pGdiInfo->ciDevice.AlignmentWhite.Y = 0;
                    338: 
                    339:         pGdiInfo->ciDevice.RedGamma = 20000;
                    340:         pGdiInfo->ciDevice.GreenGamma = 20000;
                    341:         pGdiInfo->ciDevice.BlueGamma = 20000;
                    342: 
                    343:     }
                    344:     else
                    345:     {
                    346:         pGdiInfo->ciDevice.Red.x = colorCapabilities.RedChromaticity_x;
                    347:         pGdiInfo->ciDevice.Red.y = colorCapabilities.RedChromaticity_y;
                    348:         pGdiInfo->ciDevice.Red.Y = 0;
                    349:         pGdiInfo->ciDevice.Green.x = colorCapabilities.GreenChromaticity_x;
                    350:         pGdiInfo->ciDevice.Green.y = colorCapabilities.GreenChromaticity_y;
                    351:         pGdiInfo->ciDevice.Green.Y = 0;
                    352:         pGdiInfo->ciDevice.Blue.x = colorCapabilities.BlueChromaticity_x;
                    353:         pGdiInfo->ciDevice.Blue.y = colorCapabilities.BlueChromaticity_y;
                    354:         pGdiInfo->ciDevice.Blue.Y = 0;
                    355:         pGdiInfo->ciDevice.AlignmentWhite.x = colorCapabilities.WhiteChromaticity_x;
                    356:         pGdiInfo->ciDevice.AlignmentWhite.y = colorCapabilities.WhiteChromaticity_y;
                    357:         pGdiInfo->ciDevice.AlignmentWhite.Y = colorCapabilities.WhiteChromaticity_Y;
                    358: 
                    359:         // if we have a color device store the three color gamma values,
                    360:         // otherwise store the unique gamma value in all three.
                    361: 
                    362:         if (colorCapabilities.AttributeFlags & VIDEO_DEVICE_COLOR)
                    363:         {
                    364:             pGdiInfo->ciDevice.RedGamma = colorCapabilities.RedGamma;
                    365:             pGdiInfo->ciDevice.GreenGamma = colorCapabilities.GreenGamma;
                    366:             pGdiInfo->ciDevice.BlueGamma = colorCapabilities.BlueGamma;
                    367:         }
                    368:         else
                    369:         {
                    370:             pGdiInfo->ciDevice.RedGamma = colorCapabilities.WhiteGamma;
                    371:             pGdiInfo->ciDevice.GreenGamma = colorCapabilities.WhiteGamma;
                    372:             pGdiInfo->ciDevice.BlueGamma = colorCapabilities.WhiteGamma;
                    373:         }
                    374: 
                    375:     };
                    376: 
                    377:     pGdiInfo->ciDevice.Cyan.x = 0;
                    378:     pGdiInfo->ciDevice.Cyan.y = 0;
                    379:     pGdiInfo->ciDevice.Cyan.Y = 0;
                    380:     pGdiInfo->ciDevice.Magenta.x = 0;
                    381:     pGdiInfo->ciDevice.Magenta.y = 0;
                    382:     pGdiInfo->ciDevice.Magenta.Y = 0;
                    383:     pGdiInfo->ciDevice.Yellow.x = 0;
                    384:     pGdiInfo->ciDevice.Yellow.y = 0;
                    385:     pGdiInfo->ciDevice.Yellow.Y = 0;
                    386: 
                    387:     // No dye correction for raster displays.
                    388: 
                    389:     pGdiInfo->ciDevice.MagentaInCyanDye = 0;
                    390:     pGdiInfo->ciDevice.YellowInCyanDye = 0;
                    391:     pGdiInfo->ciDevice.CyanInMagentaDye = 0;
                    392:     pGdiInfo->ciDevice.YellowInMagentaDye = 0;
                    393:     pGdiInfo->ciDevice.CyanInYellowDye = 0;
                    394:     pGdiInfo->ciDevice.MagentaInYellowDye = 0;
                    395: 
                    396:     pGdiInfo->ulDevicePelsDPI = 0;   // For printers only
                    397:     pGdiInfo->ulPrimaryOrder = PRIMARY_ORDER_CBA;
                    398: 
                    399:     // BUGBUG this should be modified to take into account the size
                    400:     // of the display and the resolution.
                    401: 
                    402:     pGdiInfo->ulHTPatternSize = HT_PATSIZE_4x4_M;
                    403: 
                    404:     pGdiInfo->flHTFlags = HT_FLAG_ADDITIVE_PRIMS;
                    405: 
                    406:     // Fill in the basic devinfo structure
                    407: 
                    408:     *pDevInfo = gDevInfoFrameBuffer;
                    409: 
                    410:     // Fill in the rest of the devinfo and GdiInfo structures.
                    411: 
                    412:     if (ppdev->ulBitCount == 8)
                    413:     {
                    414:         // It is Palette Managed.
                    415: 
                    416:         pGdiInfo->ulNumColors = 20;
                    417:         pGdiInfo->ulNumPalReg = 1 << ppdev->ulBitCount;
                    418: 
                    419:         pDevInfo->flGraphicsCaps |= (GCAPS_PALMANAGED | GCAPS_COLOR_DITHER);
                    420: 
                    421:         pGdiInfo->ulHTOutputFormat = HT_FORMAT_8BPP;
                    422:         pDevInfo->iDitherFormat = BMF_8BPP;
                    423:     }
                    424:     else
                    425:     {
                    426:         pGdiInfo->ulNumColors = 2048;
                    427:         pGdiInfo->ulNumPalReg = 0;
                    428: 
                    429:         if (ppdev->ulBitCount == 16)
                    430:         {
                    431:             pGdiInfo->ulHTOutputFormat = HT_FORMAT_16BPP;
                    432:             pDevInfo->iDitherFormat = BMF_16BPP;
                    433:         }
                    434:         else if (ppdev->ulBitCount == 24)
                    435:         {
                    436:             pGdiInfo->ulHTOutputFormat = HT_FORMAT_24BPP;
                    437:             pDevInfo->iDitherFormat = BMF_24BPP;
                    438:         }
                    439:         else
                    440:         {
                    441:             pGdiInfo->ulHTOutputFormat = HT_FORMAT_32BPP;
                    442:             pDevInfo->iDitherFormat = BMF_32BPP;
                    443:         }
                    444:     }
                    445: 
                    446:     LocalFree(pVideoBuffer);
                    447: 
                    448:     return(TRUE);
                    449: }
                    450: 
                    451: 
                    452: /******************************Public*Routine******************************\
                    453: * getAvailableModes
                    454: *
                    455: * Calls the miniport to get the list of modes supported by the kernel driver,
                    456: * and returns the list of modes supported by the diplay driver among those
                    457: *
                    458: * returns the number of entries in the videomode buffer.
                    459: * 0 means no modes are supported by the miniport or that an error occured.
                    460: *
                    461: * NOTE: the buffer must be freed up by the caller.
                    462: *
                    463: \**************************************************************************/
                    464: 
                    465: DWORD getAvailableModes(
                    466: HANDLE hDriver,
                    467: PVIDEO_MODE_INFORMATION *modeInformation,
                    468: DWORD *cbModeSize)
                    469: {
                    470:     ULONG ulTemp;
                    471:     VIDEO_NUM_MODES modes;
                    472:     PVIDEO_MODE_INFORMATION pVideoTemp;
                    473: 
                    474:     //
                    475:     // Get the number of modes supported by the mini-port
                    476:     //
                    477: 
                    478:     if (!DeviceIoControl(hDriver,
                    479:             IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES,
                    480:             NULL,
                    481:             0,
                    482:             &modes,
                    483:             sizeof(VIDEO_NUM_MODES),
                    484:             &ulTemp,
                    485:             NULL))
                    486:     {
                    487:         DISPDBG((0, "framebuf.dll getAvailableModes failed VIDEO_QUERY_NUM_AVAIL_MODES\n"));
                    488:         return(0);
                    489:     }
                    490: 
                    491:     *cbModeSize = modes.ModeInformationLength;
                    492: 
                    493:     //
                    494:     // Allocate the buffer for the mini-port to write the modes in.
                    495:     //
                    496: 
                    497:     *modeInformation = (PVIDEO_MODE_INFORMATION)
                    498:                         LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT,
                    499:                                    modes.NumModes *
                    500:                                    modes.ModeInformationLength);
                    501: 
                    502:     if (*modeInformation == (PVIDEO_MODE_INFORMATION) NULL)
                    503:     {
                    504:         DISPDBG((0, "framebuf.dll getAvailableModes failed LocalAlloc\n"));
                    505: 
                    506:         return 0;
                    507:     }
                    508: 
                    509:     //
                    510:     // Ask the mini-port to fill in the available modes.
                    511:     //
                    512: 
                    513:     if (!DeviceIoControl(hDriver,
                    514:             IOCTL_VIDEO_QUERY_AVAIL_MODES,
                    515:             NULL,
                    516:             0,
                    517:             *modeInformation,
                    518:             modes.NumModes * modes.ModeInformationLength,
                    519:             &ulTemp,
                    520:             NULL))
                    521:     {
                    522: 
                    523:         DISPDBG((0, "framebuf.dll getAvailableModes failed VIDEO_QUERY_AVAIL_MODES\n"));
                    524: 
                    525:         LocalFree(*modeInformation);
                    526:         *modeInformation = (PVIDEO_MODE_INFORMATION) NULL;
                    527: 
                    528:         return(0);
                    529:     }
                    530: 
                    531:     //
                    532:     // Now see which of these modes are supported by the display driver.
                    533:     // As an internal mechanism, set the length to 0 for the modes we
                    534:     // DO NOT support.
                    535:     //
                    536: 
                    537:     ulTemp = modes.NumModes;
                    538:     pVideoTemp = *modeInformation;
                    539: 
                    540:     //
                    541:     // Mode is rejected if it is not one plane, or not graphics, or is not
                    542:     // one of 8, 16 or 32 bits per pel.
                    543:     //
                    544: 
                    545:     while (ulTemp--)
                    546:     {
                    547:         if ((pVideoTemp->NumberOfPlanes != 1 ) ||
                    548:             !(pVideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) ||
                    549:             ((pVideoTemp->BitsPerPlane != 8) &&
                    550:              (pVideoTemp->BitsPerPlane != 16) &&
                    551:              (pVideoTemp->BitsPerPlane != 24) &&
                    552:              (pVideoTemp->BitsPerPlane != 32)))
                    553:         {
                    554:             pVideoTemp->Length = 0;
                    555:         }
                    556: 
                    557:         pVideoTemp = (PVIDEO_MODE_INFORMATION)
                    558:             (((PUCHAR)pVideoTemp) + modes.ModeInformationLength);
                    559:     }
                    560: 
                    561:     return modes.NumModes;
                    562: 
                    563: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.