diff options
author | Alon Levy <alevy@redhat.com> | 2011-06-05 16:39:11 +0300 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2011-07-31 12:34:29 +0300 |
commit | 6f7262628021333748e823a3b2219a7722fd405e (patch) | |
tree | 52a8f1cbd5b06cee8aee581874ece07e7e17aa4b /display/res.c | |
parent | bc99aa0d84aea859d54404c3ccf085e3ef65901f (diff) |
display/surface: add DEVICE_BITMAP_ALLOCATION_TYPE_RAM, cleanup surface alloc/free code paths
This adds a third surface allocation type, allocation from guest memory using
the windows ddk allocator.
Not all code paths are used later - the creation is not done since
copy-surfaces-to-ram allocates memory itself, and at the end we never allocate
any surfaces when the device is disabled, we just punt the allocation to the
gdi, but the code is still left in GetSurfaceMemory.
Cc: Yonit Halperin <yhalperi@redhat.com>
Diffstat (limited to 'display/res.c')
-rw-r--r-- | display/res.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/display/res.c b/display/res.c index fb308ea..eda6663 100644 --- a/display/res.c +++ b/display/res.c @@ -790,13 +790,21 @@ _inline void GetSurfaceMemory(PDev *pdev, UINT32 x, UINT32 y, UINT32 depth, UINT *base_mem = AllocMem(pdev, MSPACE_TYPE_DEVRAM, (*stride) * y); *phys_mem = PA(pdev, *base_mem, pdev->main_mem_slot); break; - case DEVICE_BITMAP_ALLOCATION_TYPE_VRAM: { + case DEVICE_BITMAP_ALLOCATION_TYPE_VRAM: *stride = x * depth / 8; *stride = ALIGN(*stride, 4); *base_mem = __AllocMem(pdev, MSPACE_TYPE_VRAM, (*stride) * y, FALSE); *phys_mem = PA(pdev, (PVOID)((UINT64)*base_mem), pdev->vram_mem_slot); break; - } + case DEVICE_BITMAP_ALLOCATION_TYPE_RAM: + /* used only before suspend to sleep (DrvAssertMode(FALSE)) and then released + * and copied back to VRAM */ + *stride = x * depth / 8; + *stride = ALIGN(*stride, 4); + *base_mem = EngAllocMem(0 /* don't zero memory, will be copied over in a bit */, + (*stride) * y, ALLOC_TAG); + *phys_mem = (QXLPHYSICAL)NULL; /* make sure no one uses it */ + break; default: PANIC(pdev, "No allocation type"); } @@ -810,10 +818,18 @@ void QXLGetSurface(PDev *pdev, QXLPHYSICAL *surface_phys, UINT32 x, UINT32 y, UI void QXLDelSurface(PDev *pdev, UINT8 *base_mem, UINT8 allocation_type) { - if (allocation_type == DEVICE_BITMAP_ALLOCATION_TYPE_DEVRAM) { + switch (allocation_type) { + case DEVICE_BITMAP_ALLOCATION_TYPE_DEVRAM: FreeMem(pdev, MSPACE_TYPE_DEVRAM, base_mem); - } else if (allocation_type == DEVICE_BITMAP_ALLOCATION_TYPE_VRAM) { // this wasn't there in the original code - FreeMem(pdev, MSPACE_TYPE_VRAM, base_mem); + break; + case DEVICE_BITMAP_ALLOCATION_TYPE_VRAM: + FreeMem(pdev, MSPACE_TYPE_VRAM, base_mem); + break; + case DEVICE_BITMAP_ALLOCATION_TYPE_RAM: + EngFreeMem(base_mem); + break; + default: + PANIC(pdev, "bad allocation type"); } } @@ -829,18 +845,8 @@ static void FreeDelSurface(PDev *pdev, Resource *res) DEBUG_PRINT((pdev, 12, "%s\n", __FUNCTION__)); internal = (InternalDelSurface *)res->res; - switch (internal->allocation_type) { - case DEVICE_BITMAP_ALLOCATION_TYPE_DEVRAM: - FreeMem(pdev, MSPACE_TYPE_DEVRAM, - GetSurfaceInfo(pdev, internal->surface_id)->draw_area.base_mem); - break; - case DEVICE_BITMAP_ALLOCATION_TYPE_VRAM: - FreeMem(pdev, MSPACE_TYPE_VRAM, - GetSurfaceInfo(pdev, internal->surface_id)->draw_area.base_mem); - break; - default: - PANIC(pdev, "bad allocation type"); - } + QXLDelSurface(pdev, GetSurfaceInfo(pdev, internal->surface_id)->draw_area.base_mem, + internal->allocation_type); FreeSurfaceInfo(pdev, internal->surface_id); FreeMem(pdev, MSPACE_TYPE_DEVRAM, res); |