Driven Development Six - A Simple Display Driven Four

DrvEnablePDEV

Once a display mode is selected, the API will be invoked, allowing the drive to enable "physical devices".The purpose of this API is to allow the display driver to create its own private context that will be passed to other display entry points.The reason for creating a private context is that a display driver can manage multiple display devices and use it to distinguish between display devices.The return value of this API is either a context pointer or an instance of a display device.

The selected display settings are passed to this API through the DEVMODE parameter, however this method is not used in the example driver, but rather the display mode with hard-coded settings of 800 * 600 * 32.

In addition to creating an instance structure, this API must initialize two data structures, GDIINFO and DEVINFO.These parameters are important if you fill in a feature that supports it but is not.The side effect is distorted graphics or even a blue screen.The other two parameters I'll mention later are hDev and hDriver, which are actually Display-driven DEVICE_OBJECT and can be used for APIs, such as EngDeviceIoControl, which uses it to communicate with miniport-driven devices.

HDev is the handle to GDI, but since hDev is in the process of being created, this parameter is actually useless.It is recommended that you wait until DrvCompletePDEV is called before saving and using this handle.The code below comes from an example-driven DrvEnablePDEV.
 

DHPDEV GdiExample_DrvEnablePDEV(DEVMODEW *pdm, PWSTR pwszLogAddr,

       ULONG cPat, HSURF *phsurfPatterns, ULONG cjCaps,

       GDIINFO *pGdiInfo, ULONG cjDevInfo, DEVINFO *pDevInfo,

       HDEV hdev, PWSTR pwszDeviceName, HANDLE hDriver)

{

    PDEVICE_DATA pDeviceData = NULL;

  

    ENGDEBUGPRINT(0, "GdiExample_DrvEnablePDEV Enter \r\n", NULL);

    pDeviceData = (PDEVICE_DATA) EngAllocMem(0,

                               sizeof(DEVICE_DATA), FAKE_GFX_TAG);

    if(pDeviceData)

    {

        memset(pDeviceData, 0, sizeof(DEVICE_DATA));

        memset(pGdiInfo, 0, cjCaps);

        memset(pDevInfo, 0, cjDevInfo);

        {

            pGdiInfo->ulVersion    = 0x5000;

            pGdiInfo->ulTechnology = DT_RASDISPLAY;

            pGdiInfo->ulHorzSize   = 0;

            pGdiInfo->ulVertSize   = 0;

            pGdiInfo->ulHorzRes        = RESOLUTION_X;

            pGdiInfo->ulVertRes        = RESOLUTION_Y;

            pGdiInfo->ulPanningHorzRes = 0;

            pGdiInfo->ulPanningVertRes = 0;

            pGdiInfo->cBitsPixel       = 8;

            pGdiInfo->cPlanes          = 4;

            pGdiInfo->ulNumColors      = 20;

            pGdiInfo->ulVRefresh       = 1;     

            pGdiInfo->ulBltAlignment   = 1;   

            pGdiInfo->ulLogPixelsX = 96;

            pGdiInfo->ulLogPixelsY = 96;

            pGdiInfo->flTextCaps   = TC_RA_ABLE;

            pGdiInfo->flRaster     = 0;

            pGdiInfo->ulDACRed     = 8;

            pGdiInfo->ulDACGreen   = 8;

            pGdiInfo->ulDACBlue    = 8;

            pGdiInfo->ulAspectX    = 0x24;

            pGdiInfo->ulNumPalReg = 256;

            pGdiInfo->ulAspectY    = 0x24;

            pGdiInfo->ulAspectXY   = 0x33;

            pGdiInfo->xStyleStep   = 1;     

            pGdiInfo->yStyleStep   = 1;

            pGdiInfo->denStyleStep = 3;

            pGdiInfo->ptlPhysOffset.x = 0;

            pGdiInfo->ptlPhysOffset.y = 0;

            pGdiInfo->szlPhysSize.cx = 0;

            pGdiInfo->szlPhysSize.cy = 0;

            pGdiInfo->ciDevice.Red.x = 6700;

            pGdiInfo->ciDevice.Red.y = 3300;

            pGdiInfo->ciDevice.Red.Y = 0;

            pGdiInfo->ciDevice.Green.x = 2100;

            pGdiInfo->ciDevice.Green.y = 7100;

            pGdiInfo->ciDevice.Green.Y = 0;

            pGdiInfo->ciDevice.Blue.x = 1400;

            pGdiInfo->ciDevice.Blue.y = 800;

            pGdiInfo->ciDevice.Blue.Y = 0;

            pGdiInfo->ciDevice.AlignmentWhite.x = 3127;

            pGdiInfo->ciDevice.AlignmentWhite.y = 3290;

            pGdiInfo->ciDevice.AlignmentWhite.Y = 0;

            pGdiInfo->ciDevice.RedGamma = 20000;

            pGdiInfo->ciDevice.GreenGamma = 20000;

            pGdiInfo->ciDevice.BlueGamma = 20000;

            pGdiInfo->ciDevice.Cyan.x = 1750;

            pGdiInfo->ciDevice.Cyan.y = 3950;

            pGdiInfo->ciDevice.Cyan.Y = 0;

            pGdiInfo->ciDevice.Magenta.x = 4050;

            pGdiInfo->ciDevice.Magenta.y = 2050;

            pGdiInfo->ciDevice.Magenta.Y = 0;

            pGdiInfo->ciDevice.Yellow.x = 4400;

            pGdiInfo->ciDevice.Yellow.y = 5200;

            pGdiInfo->ciDevice.Yellow.Y = 0;

            pGdiInfo->ciDevice.MagentaInCyanDye = 0;

            pGdiInfo->ciDevice.YellowInCyanDye = 0;

            pGdiInfo->ciDevice.CyanInMagentaDye = 0;

            pGdiInfo->ciDevice.YellowInMagentaDye = 0;

            pGdiInfo->ciDevice.CyanInYellowDye = 0;

            pGdiInfo->ciDevice.MagentaInYellowDye = 0;

            pGdiInfo->ulDevicePelsDPI = 0;

            pGdiInfo->ulPrimaryOrder = PRIMARY_ORDER_CBA;

            pGdiInfo->ulHTPatternSize = HT_PATSIZE_4x4_M;

            pGdiInfo->flHTFlags = HT_FLAG_ADDITIVE_PRIMS;

            pGdiInfo->ulHTOutputFormat = HT_FORMAT_32BPP;

          

            *pDevInfo = gDevInfoFrameBuffer;

            pDevInfo->iDitherFormat = BMF_32BPP;

        }

        pDeviceData->pVideoMemory = EngMapFile(L"\\??\\c:\\video.dat",

              RESOLUTION_X*RESOLUTION_Y*4, &pDeviceData->pMappedFile);

        pDeviceData->hDriver = hDriver;

        pDevInfo->hpalDefault = EngCreatePalette(PAL_BITFIELDS,

               0, NULL, 0xFF0000, 0xFF00, 0xFF);

    }

    ENGDEBUGPRINT(0, "GdiExample_DrvEnablePDEV Exit \r\n", NULL);

    return (DHPDEV)pDeviceData;

}


 

Posted by batterdmooie on Wed, 18 Sep 2019 20:10:45 -0700