예제 #1
0
파일: surface.c 프로젝트: damouse/PCC
BOOL MoveAllSurfacesToRam(PDev *pdev)
{
    UINT32 surface_id;
    SurfaceInfo *surface_info;
    SURFOBJ *surf_obj;
    UINT8 *copy;
    UINT8 *line0;
    int size;
    QXLPHYSICAL phys_mem;

    for (surface_id = 1 ; surface_id < pdev->n_surfaces ; ++surface_id) {
        surface_info = GetSurfaceInfo(pdev, surface_id);
        if (!surface_info->draw_area.base_mem) {
            continue;
        }
        surf_obj = surface_info->draw_area.surf_obj;
        if (!surf_obj) {
            DEBUG_PRINT((pdev, 3, "%s: %d: no surfobj, not copying\n", __FUNCTION__, surface_id));
            continue;
        }
        size = surf_obj->sizlBitmap.cy * abs(surf_obj->lDelta);
        copy = EngAllocMem(0, size, ALLOC_TAG);
        DEBUG_PRINT((pdev, 3, "%s: %d: copying #%d to %p (%d)\n", __FUNCTION__, surface_id, size,
            copy, surf_obj->lDelta));
        RtlCopyMemory(copy, surface_info->draw_area.base_mem, size);
        surface_info->copy = copy;
        line0 = surf_obj->lDelta > 0 ? copy : copy + abs(surf_obj->lDelta) *
                (surf_obj->sizlBitmap.cy - 1);
        if (!EngModifySurface((HSURF)surface_info->hbitmap,
                      pdev->eng,
                      0, /* from the example: used to monitor memory HOOK_COPYBITS | HOOK_BITBLT, */
                      0,                    /* It's system-memory */
                      (DHSURF)surface_info,
                      line0,
                      surf_obj->lDelta,
                      NULL)) {
            /* Send a create messsage for this surface - we previously did a destroy all. */
            EngFreeMem(surface_info->copy);
            surface_info->copy = NULL;
            DEBUG_PRINT((pdev, 0, "%s: %d: EngModifySurface failed, sending create for %d-%d\n",
                         __FUNCTION__, surface_id, surface_id, pdev->n_surfaces - 1));
            SendSurfaceRangeCreateCommand(pdev, surface_id, pdev->n_surfaces);
            return FALSE;
        }
        QXLDelSurface(pdev, surface_info->draw_area.base_mem, DEVICE_BITMAP_ALLOCATION_TYPE_VRAM);
        surface_info->draw_area.base_mem = copy;
        FreeDrawArea(&surface_info->draw_area);
    }
    return TRUE;
}
예제 #2
0
파일: surface.c 프로젝트: damouse/PCC
BOOL MoveSurfaceToVideoRam(PDev *pdev, UINT32 surface_id)
{
    QXLSurfaceCmd *surface;
    UINT32 surface_format;
    UINT32 depth;
    int count_used = 0;
    int size;
    INT32 stride = 0;
    QXLPHYSICAL phys_mem;
    SurfaceInfo *surface_info = GetSurfaceInfo(pdev, surface_id);
    UINT32 cx = surface_info->size.cx;
    UINT32 cy = surface_info->size.cy;
    UINT8 *base_mem;

    DEBUG_PRINT((pdev, 3, "%s: %d\n", __FUNCTION__, surface_id));
    if ((base_mem = CreateSurfaceHelper(pdev, surface_id, cx, cy, surface_info->bitmap_format,
                                        DEVICE_BITMAP_ALLOCATION_TYPE_VRAM,
                                        &stride, &surface_format, &phys_mem)) == NULL) {
        DEBUG_PRINT((pdev, 0, "%s: %p: %d: failed\n", __FUNCTION__, pdev, surface_id));
        return FALSE;
    }
    size = abs(stride) * cy;
    if (!EngModifySurface((HSURF)surface_info->hbitmap, pdev->eng, QXL_SURFACE_HOOKS,
        MS_NOTSYSTEMMEMORY, (DHSURF)surface_info, NULL, 0, NULL)) {
        DEBUG_PRINT((pdev, 0, "%s: %p: %d: EngModifySurface failed\n",
            __FUNCTION__, pdev, surface_id));
        CleanupSurfaceInfo(pdev, surface_id, DEVICE_BITMAP_ALLOCATION_TYPE_VRAM);
        return FALSE;
    }
    DEBUG_PRINT((pdev, 3, "%s: stride = %d, phys_mem = %0lX, base_mem = %p\n",
        __FUNCTION__, -stride, (uint64_t)phys_mem, base_mem));
    DEBUG_PRINT((pdev, 3, "%s: copy %d bytes to %d\n", __FUNCTION__, size, surface_id));
    // Everything allocated, nothing can fail (API wise) from this point
    RtlCopyMemory(base_mem, surface_info->copy, size);
    EngFreeMem(surface_info->copy);
    surface_info->copy = NULL;
    SendSurfaceCreateCommand(pdev, surface_id, surface_info->size, surface_format,
                             -stride, phys_mem, 1);
    return TRUE;
}
예제 #3
0
파일: enable.c 프로젝트: GYGit/reactos
BOOL DrvAssertMode(
DHPDEV dhpdev,
BOOL bEnable)
{
    PPDEV   ppdev = (PPDEV) dhpdev;
    ULONG   ulReturn;
    PBYTE   pjScreen;

    if (bEnable)
    {
        //
        // The screen must be reenabled, reinitialize the device to clean state.
        //
// eVb: 1.6 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping
        pjScreen = ppdev->pjScreen;

        if (!bInitSURF(ppdev, FALSE))
        {
            DISPDBG((0, "DISP DrvAssertMode failed bInitSURF\n"));
            return (FALSE);
        }

        if (pjScreen != ppdev->pjScreen) {

            if ( !EngModifySurface(ppdev->hsurfEng,
                                   ppdev->hdevEng,
                                   ppdev->flHooks | HOOK_SYNCHRONIZE,
                                   MS_NOTSYSTEMMEMORY,
                                   (DHSURF)ppdev,
                                   ppdev->pjScreen,
                                   ppdev->lDeltaScreen,
                                   NULL))
            {
                DISPDBG((0, "DISP DrvAssertMode failed EngModifySurface\n"));
                return (FALSE);
            }
        }
// eVb: 1.6 [END]
        return (TRUE);
    }
    else
    {
        //
        // We must give up the display.
        // Call the kernel driver to reset the device to a known state.
        //

        if (EngDeviceIoControl(ppdev->hDriver,
                               IOCTL_VIDEO_RESET_DEVICE,
                               NULL,
                               0,
                               NULL,
                               0,
                               &ulReturn))
        {
            RIP("DISP DrvAssertMode failed IOCTL");
            return FALSE;
        }
        else
        {
            return TRUE;
        }
    }
}
예제 #4
0
파일: enable.c 프로젝트: GYGit/reactos
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);
}
예제 #5
0
파일: enable.c 프로젝트: Moteesh/reactos
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);
}