summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-04-14 17:03:34 +0300
committerAlon Levy <alevy@redhat.com>2011-04-14 17:03:34 +0300
commit59805b0faba1c5497adf169b9e08e1df72ee622d (patch)
tree2f2807d080be8af745be51c648f058aeb41c811c
parentf420462cec6778fe77ee266b9da24a74ea92bfbc (diff)
add ResendSurfaceCreateCommands
-rw-r--r--display/surface.c61
-rw-r--r--display/surface.h2
2 files changed, 63 insertions, 0 deletions
diff --git a/display/surface.c b/display/surface.c
index 7cc8f8d..347b70a 100644
--- a/display/surface.c
+++ b/display/surface.c
@@ -170,6 +170,67 @@ out_error1:
return 0;
}
+/* TODO: move to h file */
+static _inline QXLPHYSICAL PA(PDev *pdev, PVOID virt, UINT8 slot_id)
+{
+ PMemSlot *p_slot = &pdev->mem_slots[slot_id];
+
+ return p_slot->high_bits | ((UINT64)virt - p_slot->slot.start_virt_addr);
+}
+
+/* when we return from S3 we need to resend all the surface creation commands.
+ * Actually moving the memory vram<->guest is not strictly neccessary since vram
+ * is not reset during the suspend, so contents are not lost */
+VOID ResendSurfaceCreateCommands(PDev *pdev)
+{
+ QXLSurfaceCmd *surface;
+ UINT32 surface_id;
+ SurfaceInfo *surface_info;
+ QXLPHYSICAL phys_mem;
+ UINT32 surface_format;
+ UINT32 depth;
+ //HBITMAP surf;
+ UINT32 stride;
+ SURFOBJ *surf_obj;
+ int count_used = 0;
+ UINT32 cx, cy;
+
+ /* brute force implementation - alternative is to keep an updated used_surfaces list */
+ DEBUG_PRINT((pdev, 0, "%s\n", __FUNCTION__));
+
+ 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 = surface_info->draw_area.bitmap;
+ surf_obj = surface_info->draw_area.surf_obj;
+ if (!surf_obj) {
+ DEBUG_PRINT((pdev, 0, "%s: surface_id = %d, marked as used, but no surf_obj\n", __FUNCTION__,
+ surface_id));
+ continue;
+ }
+ cx = surf_obj->sizlBitmap.cx;
+ cy = surf_obj->sizlBitmap.cy;
+ phys_mem = (QXLPHYSICAL)surf_obj->pvBits;
+ BitmapFormatToDepthAndSurfaceFormat(surf_obj->iBitmapFormat, &depth, &surface_format);
+ stride = surf_obj->lDelta;
+ DEBUG_PRINT((pdev, 0,
+ "%s: surface_id = %d, format = %d, depth = %d, size = (%d, %d), stride = %d\n",
+ __FUNCTION__, surface_id, surface_format, depth, cx, cy, stride));
+ phys_mem = PA(pdev, (PVOID)((UINT64)surface_info->draw_area.base_mem), pdev->vram_mem_slot);
+ DEBUG_PRINT((pdev, 0, "%s: data = %p\n", __FUNCTION__, stride, phys_mem));
+ surface = SurfaceCmd(pdev, QXL_SURFACE_CMD_CREATE, surface_id);
+ surface->u.surface_create.format = surface_format;
+ surface->u.surface_create.width = cx;
+ surface->u.surface_create.height = cy;
+ surface->u.surface_create.stride = stride;
+ surface->u.surface_create.data = phys_mem;
+ PushSurfaceCmd(pdev, surface);
+ }
+ //EngFreeMem(used);
+}
+
VOID DeleteDeviceBitmap(PDev *pdev, UINT32 surface_id, UINT8 allocation_type)
{
DrawArea *drawarea;
diff --git a/display/surface.h b/display/surface.h
index e212c46..30e9cea 100644
--- a/display/surface.h
+++ b/display/surface.h
@@ -87,4 +87,6 @@ HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *ph
UINT8 **base_mem, UINT32 surface_id, UINT8 allocation_type);
VOID DeleteDeviceBitmap(PDev *pdev, UINT32 surface_id, UINT8 allocation_type);
+VOID ResendSurfaceCreateCommands(PDev *pdev);
+
#endif