HSURF DrvEnableSurface( DHPDEV dhpdev) { PPDEV ppdev; HSURF hsurf; SIZEL sizl; ULONG ulBitmapType; FLONG flHooks; // Create engine bitmap around frame buffer. ppdev = (PPDEV) dhpdev; if (!bInitSURF(ppdev, TRUE)) { RIP("DISP DrvEnableSurface failed bInitSURF\n"); return(FALSE); } sizl.cx = ppdev->cxScreen; sizl.cy = ppdev->cyScreen; // eVb: 1.3 [VGARISC Change] - Disable dynamic palette and > 4BPP support #if 0 if (ppdev->ulBitCount == 8) { if (!bInit256ColorPalette(ppdev)) { RIP("DISP DrvEnableSurface failed to init the 8bpp palette\n"); return(FALSE); } ulBitmapType = BMF_8BPP; flHooks = HOOKS_BMF8BPP; } else if (ppdev->ulBitCount == 16) { ulBitmapType = BMF_16BPP; flHooks = HOOKS_BMF16BPP; } else if (ppdev->ulBitCount == 24) { ulBitmapType = BMF_24BPP; flHooks = HOOKS_BMF24BPP; } else { ulBitmapType = BMF_32BPP; flHooks = HOOKS_BMF32BPP; } // eVb: 1.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping ppdev->flHooks = flHooks; // eVb: 1.3 [END] #else ulBitmapType = BMF_4BPP; #endif // eVb: 1.3 [END] // eVb: 1.4 [DDK Change] - Use EngCreateDeviceSurface instead of EngCreateBitmap hsurf = (HSURF)EngCreateDeviceSurface((DHSURF)ppdev, sizl, ulBitmapType); if (hsurf == (HSURF) 0) { RIP("DISP DrvEnableSurface failed EngCreateDeviceSurface\n"); return(FALSE); } // eVb: 1.4 [END] // eVb: 1.5 [DDK Change] - Use EngModifySurface instead of EngAssociateSurface if ( !EngModifySurface(hsurf, ppdev->hdevEng, ppdev->flHooks | HOOK_SYNCHRONIZE, MS_NOTSYSTEMMEMORY, (DHSURF)ppdev, ppdev->pjScreen, ppdev->lDeltaScreen, NULL)) { RIP("DISP DrvEnableSurface failed EngModifySurface\n"); return(FALSE); } // eVb: 1.5 [END] ppdev->hsurfEng = hsurf; // eVb: 1.4 [VGARISC Change] - Allocate 4BPP DIB that will store GDI drawing HSURF hSurfBitmap; hSurfBitmap = (HSURF)EngCreateBitmap(sizl, 0, ulBitmapType, 0, NULL); if (hSurfBitmap == (HSURF) 0) { RIP("DISP DrvEnableSurface failed EngCreateBitmap\n"); return(FALSE); } if ( !EngModifySurface(hSurfBitmap, ppdev->hdevEng, ppdev->flHooks | HOOK_SYNCHRONIZE, MS_NOTSYSTEMMEMORY, (DHSURF)ppdev, ppdev->pjScreen, ppdev->lDeltaScreen, NULL)) { RIP("DISP DrvEnableSurface failed second EngModifySurface\n"); return(FALSE); } ppdev->pso = EngLockSurface(hSurfBitmap); if (ppdev->pso == NULL) { RIP("DISP DrvEnableSurface failed EngLockSurface\n"); return(FALSE); } // eVb: 1.4 [END] return(hsurf); }
/* Called to create and associate surface with device */ HSURF APIENTRY VBoxDispDrvEnableSurface(DHPDEV dhpdev) { int rc; PVBOXDISPDEV pDev = (PVBOXDISPDEV)dhpdev; LOGF_ENTER(); /* Switch device to mode requested in VBoxDispDrvEnablePDEV */ rc = VBoxDispMPSetCurrentMode(pDev->hDriver, pDev->mode.ulIndex); VBOX_WARNRC_RETV(rc, NULL); /* Map fb and vram */ rc = VBoxDispMPMapMemory(pDev, &pDev->memInfo); VBOX_WARNRC_RETV(rc, NULL); /* Clear mapped memory, to avoid garbage while video mode is switching */ /* @todo: VIDEO_MODE_NO_ZERO_MEMORY does nothing in miniport's IOCTL_VIDEO_SET_CURRENT_MODE*/ memset(pDev->memInfo.FrameBufferBase, 0, pDev->mode.ulHeight * abs(pDev->mode.lScanlineStride)); /* Allocate memory for pointer attrs */ rc = VBoxDispInitPointerAttrs(pDev); VBOX_WARNRC_RETV(rc, NULL); /* Init VBVA */ rc = VBoxDispVBVAInit(pDev); VBOX_WARNRC_RETV(rc, NULL); /* Enable VBVA */ if (pDev->hgsmi.bSupported) { if (pDev->mode.ulBitsPerPel==16 || pDev->mode.ulBitsPerPel==24 || pDev->mode.ulBitsPerPel==32) { VBVABUFFER *pVBVA = (VBVABUFFER *)((uint8_t *)pDev->memInfo.VideoRamBase+pDev->layout.offVBVABuffer); pDev->hgsmi.bSupported = VBoxVBVAEnable(&pDev->vbvaCtx, &pDev->hgsmi.ctx, pVBVA, -1); LogRel(("VBoxDisp[%d]: VBVA %senabled\n", pDev->iDevice, pDev->hgsmi.bSupported? "":"not ")); } } /* Inform host */ if (pDev->hgsmi.bSupported) { VBoxHGSMIProcessDisplayInfo(&pDev->hgsmi.ctx, pDev->iDevice, pDev->orgDev.x, pDev->orgDev.y, 0, abs(pDev->mode.lScanlineStride), pDev->mode.ulWidth, pDev->mode.ulHeight, (uint16_t)pDev->mode.ulBitsPerPel, VBVA_SCREEN_F_ACTIVE); } #ifdef VBOX_WITH_VIDEOHWACCEL VBoxDispVHWAEnable(pDev); #endif /* Set device palette if needed */ if (pDev->mode.ulBitsPerPel == 8) { rc = VBoxDispSetPalette8BPP(pDev); VBOX_WARNRC_RETV(rc, NULL); } pDev->orgDisp.x = 0; pDev->orgDisp.y = 0; /* Create GDI managed bitmap, which resides in our framebuffer memory */ ULONG iFormat; SIZEL size; switch (pDev->mode.ulBitsPerPel) { case 8: { iFormat = BMF_8BPP; break; } case 16: { iFormat = BMF_16BPP; break; } case 24: { iFormat = BMF_24BPP; break; } case 32: { iFormat = BMF_32BPP; break; } } size.cx = pDev->mode.ulWidth; size.cy = pDev->mode.ulHeight; pDev->surface.hBitmap = EngCreateBitmap(size, pDev->mode.lScanlineStride, iFormat, pDev->mode.lScanlineStride>0 ? BMF_TOPDOWN:0, pDev->memInfo.FrameBufferBase); if (!pDev->surface.hBitmap) { WARN(("EngCreateBitmap failed!")); return NULL; } pDev->surface.psoBitmap = EngLockSurface((HSURF)pDev->surface.hBitmap); /* Create device-managed surface */ pDev->surface.hSurface = EngCreateDeviceSurface((DHSURF)pDev, size, iFormat); if (!pDev->surface.hSurface) { WARN(("EngCreateDeviceSurface failed!")); VBoxDispDrvDisableSurface(dhpdev); return NULL; } FLONG flHooks = HOOK_BITBLT|HOOK_TEXTOUT|HOOK_FILLPATH|HOOK_COPYBITS|HOOK_STROKEPATH|HOOK_LINETO| HOOK_PAINT|HOOK_STRETCHBLT; /* Associate created surface with our device */ if (!EngAssociateSurface(pDev->surface.hSurface, pDev->hDevGDI, flHooks)) { WARN(("EngAssociateSurface failed!")); VBoxDispDrvDisableSurface(dhpdev); return NULL; } pDev->surface.ulFormat = iFormat; pDev->flDrawingHooks = flHooks; LOG(("Created surface %p for physical device %p", pDev->surface.hSurface, pDev)); LOGF_LEAVE(); return pDev->surface.hSurface; }
HSURF DrvEnableSurface( DHPDEV dhpdev) { PDEV* ppdev; HSURF hsurfShadow; HSURF hsurfDevice; SIZEL sizl; ppdev = (PDEV*) dhpdev; ///////////////////////////////////////////////////////////////////// // Have GDI create the actual SURFOBJ. // // Our drawing surface is going to be 'device-managed', meaning that // GDI cannot draw on the framebuffer bits directly, and as such we // create the surface via EngCreateSurface. By doing this, we ensure // that GDI will only ever access the bitmaps bits via the Drv calls // that we've HOOKed. sizl.cx = ppdev->cxScreen; sizl.cy = ppdev->cyScreen; hsurfDevice = EngCreateDeviceSurface(NULL, sizl, ppdev->iBitmapFormat); if (hsurfDevice == 0) { DISPDBG((0, "DrvEnableSurface - Failed EngCreateSurface")); goto ReturnFailure; } ppdev->hsurfScreen = hsurfDevice; // Remember it for clean-up ///////////////////////////////////////////////////////////////////// // Now associate the surface and the PDEV. // // We have to associate the surface we just created with our physical // device so that GDI can get information related to the PDEV when // it's drawing to the surface (such as, for example, the length of // styles on the device when simulating styled lines). // if (!EngAssociateSurface(hsurfDevice, ppdev->hdevEng, ppdev->flHooks)) { DISPDBG((0, "DrvEnableSurface - Failed EngAssociateSurface")); goto ReturnFailure; } // Create the 4bpp DIB on which we'll have GDI do all the drawing. // We'll merely occasionally blt portions to the screen to update. sizl.cx = ppdev->cxScreen; sizl.cy = ppdev->cyScreen; hsurfShadow = (HSURF) EngCreateBitmap(sizl, 0, ppdev->iBitmapFormat, 0, NULL); if (hsurfShadow == 0) goto ReturnFailure; if (!EngAssociateSurface(hsurfShadow, ppdev->hdevEng, ppdev->flHooks)) { DISPDBG((0, "DrvEnableSurface - Failed second EngAssociateSurface")); goto ReturnFailure; } ppdev->pso = EngLockSurface(hsurfShadow); if (ppdev->pso == NULL) goto ReturnFailure; ///////////////////////////////////////////////////////////////////// // Now enable all the subcomponents. // // Note that the order in which these 'Enable' functions are called // may be significant in low off-screen memory conditions, because // the off-screen heap manager may fail some of the later // allocations... if (!bEnableHardware(ppdev)) goto ReturnFailure; DISPDBG((5, "Passed DrvEnableSurface")); return(hsurfDevice); ReturnFailure: DrvDisableSurface((DHPDEV) ppdev); DISPDBG((0, "Failed DrvEnableSurface")); return(0); }
HSURF NTAPI DrvEnableSurface( DHPDEV dhpdev) { PPDEV ppdev; HSURF hsurf; SIZEL sizl; ULONG ulBitmapType; FLONG flHooks; // Create engine bitmap around frame buffer. ppdev = (PPDEV) dhpdev; if (!bInitSURF(ppdev, TRUE)) { RIP("DISP DrvEnableSurface failed bInitSURF\n"); return(FALSE); } sizl.cx = ppdev->cxScreen; sizl.cy = ppdev->cyScreen; if (ppdev->ulBitCount == 8) { if (!bInit256ColorPalette(ppdev)) { RIP("DISP DrvEnableSurface failed to init the 8bpp palette\n"); return(FALSE); } ulBitmapType = BMF_8BPP; flHooks = HOOKS_BMF8BPP; } else if (ppdev->ulBitCount == 16) { ulBitmapType = BMF_16BPP; flHooks = HOOKS_BMF16BPP; } else if (ppdev->ulBitCount == 24) { ulBitmapType = BMF_24BPP; flHooks = HOOKS_BMF24BPP; } else { ulBitmapType = BMF_32BPP; flHooks = HOOKS_BMF32BPP; } // eVb: 1.3 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping ppdev->flHooks = flHooks; // eVb: 1.3 [END] // eVb: 1.4 [DDK Change] - Use EngCreateDeviceSurface instead of EngCreateBitmap hsurf = (HSURF)EngCreateDeviceSurface((DHSURF)ppdev, sizl, ulBitmapType); if (hsurf == (HSURF) 0) { RIP("DISP DrvEnableSurface failed EngCreateDeviceSurface\n"); return(FALSE); } // eVb: 1.4 [END] // eVb: 1.5 [DDK Change] - Use EngModifySurface instead of EngAssociateSurface if ( !EngModifySurface(hsurf, ppdev->hdevEng, ppdev->flHooks | HOOK_SYNCHRONIZE, MS_NOTSYSTEMMEMORY, (DHSURF)ppdev, ppdev->pjScreen, ppdev->lDeltaScreen, NULL)) { RIP("DISP DrvEnableSurface failed EngModifySurface\n"); return(FALSE); } // eVb: 1.5 [END] ppdev->hsurfEng = hsurf; return(hsurf); }
HSURF DrvEnableSurface(DHPDEV dhpdev) { PPDEV ppdev; PDEVSURF pdsurf; DHSURF dhsurf; HSURF hsurf; DISPDBG((2, "enabling Surface\n")); ppdev = (PPDEV) dhpdev; // // Initialize the VGA device into the selected mode which will also map // the video frame buffer // if (!bInitVGA(ppdev, TRUE)) { goto error_done; } dhsurf = (DHSURF) EngAllocMem(0, sizeof(DEVSURF), ALLOC_TAG); if (dhsurf == (DHSURF) 0) { goto error_done; } pdsurf = (PDEVSURF) dhsurf; pdsurf->ident = DEVSURF_IDENT; pdsurf->flSurf = 0; pdsurf->iFormat = BMF_PHYSDEVICE; pdsurf->jReserved1 = 0; pdsurf->jReserved2 = 0; pdsurf->ppdev = ppdev; pdsurf->sizlSurf.cx = ppdev->sizlSurf.cx; pdsurf->sizlSurf.cy = ppdev->sizlSurf.cy; pdsurf->lNextPlane = 0; pdsurf->pvScan0 = ppdev->pjScreen; pdsurf->pvBitmapStart = ppdev->pjScreen; pdsurf->pvStart = ppdev->pjScreen; pdsurf->pvConv = &ajConvertBuffer[0]; // Initialize pointer information. // // bInitPointer must be called before bInitSavedBits. // if (!bInitPointer(ppdev)) { DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n")); goto error_clean; } if (!SetUpBanking(pdsurf, ppdev)) { DISPDBG((0, "DrvEnablePDEV failed SetUpBanking\n")); goto error_clean; } if ((hsurf = EngCreateDeviceSurface(dhsurf, ppdev->sizlSurf, BMF_4BPP)) == (HSURF) 0) { DISPDBG((0, "DrvEnablePDEV failed EngCreateDeviceSurface\n")); goto error_clean; } // // vInitSavedBits must be called after bInitPointer. // vInitSavedBits(ppdev); if (EngAssociateSurface(hsurf, ppdev->hdevEng, HOOK_BITBLT | HOOK_TEXTOUT | HOOK_STROKEPATH | HOOK_COPYBITS | HOOK_PAINT | HOOK_FILLPATH )) { ppdev->hsurfEng = hsurf; ppdev->pdsurf = pdsurf; // Set up an empty saved screen block list pdsurf->ssbList = NULL; DISPDBG((2, "enabled surface\n")); return(hsurf); } DISPDBG((0, "DrvEnablePDEV failed EngDeleteSurface\n")); EngDeleteSurface(hsurf); error_clean: // We created the surface, so delete it EngFreeMem(dhsurf); error_done: return((HSURF) 0); }