summaryrefslogtreecommitdiffstats
path: root/sys/dev/fb/vesa.c
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2012-03-17 00:00:33 +0000
committerjkim <jkim@FreeBSD.org>2012-03-17 00:00:33 +0000
commit971b05384cd8b7e69c6e3d8bf78276a9a2a29f9f (patch)
treec666359fd63082bd2075c5a3e95da8154883c6d5 /sys/dev/fb/vesa.c
parent6cf86670c6993bb7fc2bb291080185e372a91f87 (diff)
downloadFreeBSD-src-971b05384cd8b7e69c6e3d8bf78276a9a2a29f9f.zip
FreeBSD-src-971b05384cd8b7e69c6e3d8bf78276a9a2a29f9f.tar.gz
Save and restore linear frame buffer between suspend and resume.
MFC after: 1 week
Diffstat (limited to 'sys/dev/fb/vesa.c')
-rw-r--r--sys/dev/fb/vesa.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/dev/fb/vesa.c b/sys/dev/fb/vesa.c
index 26f57b2..5d64852 100644
--- a/sys/dev/fb/vesa.c
+++ b/sys/dev/fb/vesa.c
@@ -88,6 +88,8 @@ static ssize_t vesa_state_buf_size;
static u_char *vesa_palette;
static uint32_t vesa_palette_offs;
+static void *vesa_vmem_buf;
+
static void *vesa_bios;
static uint32_t vesa_bios_offs;
static uint32_t vesa_bios_int10;
@@ -1459,6 +1461,8 @@ vesa_set_border(video_adapter_t *adp, int color)
static int
vesa_save_state(video_adapter_t *adp, void *p, size_t size)
{
+ vm_offset_t buf;
+ size_t bsize;
if (adp != vesa_adp || vesa_state_buf_size == 0)
return ((*prevvidsw->save_state)(adp, p, size));
@@ -1468,6 +1472,13 @@ vesa_save_state(video_adapter_t *adp, void *p, size_t size)
if (size < (offsetof(adp_state_t, regs) + vesa_state_buf_size))
return (EINVAL);
+ buf = adp->va_buffer;
+ if (buf != 0) {
+ bsize = adp->va_buffer_size;
+ vesa_vmem_buf = malloc(bsize, M_DEVBUF, M_NOWAIT);
+ if (vesa_vmem_buf != NULL)
+ bcopy((void *)buf, vesa_vmem_buf, bsize);
+ }
((adp_state_t *)p)->sig = V_STATE_SIG;
bzero(((adp_state_t *)p)->regs, vesa_state_buf_size);
return (vesa_bios_save_restore(STATE_SAVE, ((adp_state_t *)p)->regs));
@@ -1476,6 +1487,8 @@ vesa_save_state(video_adapter_t *adp, void *p, size_t size)
static int
vesa_load_state(video_adapter_t *adp, void *p)
{
+ vm_offset_t buf;
+ size_t bsize;
int mode;
if (adp != vesa_adp)
@@ -1483,6 +1496,8 @@ vesa_load_state(video_adapter_t *adp, void *p)
/* Try BIOS POST to restore a sane state. */
(void)vesa_bios_post();
+ buf = adp->va_buffer;
+ bsize = adp->va_buffer_size;
mode = adp->va_mode;
(void)vesa_set_mode(adp, adp->va_initial_mode);
if (mode != adp->va_initial_mode)
@@ -1490,6 +1505,10 @@ vesa_load_state(video_adapter_t *adp, void *p)
if (((adp_state_t *)p)->sig != V_STATE_SIG)
return ((*prevvidsw->load_state)(adp, p));
+ if (buf != 0 && vesa_vmem_buf != NULL) {
+ bcopy(vesa_vmem_buf, (void *)buf, bsize);
+ free(vesa_vmem_buf, M_DEVBUF);
+ }
return (vesa_bios_save_restore(STATE_LOAD, ((adp_state_t *)p)->regs));
}
OpenPOWER on IntegriCloud