Author: jkim
Date: Sat Mar 17 00:00:33 2012
New Revision: 233056
URL: http://svn.freebsd.org/changeset/base/233056

Log:
  Save and restore linear frame buffer between suspend and resume.
  
  MFC after:    1 week

Modified:
  head/sys/dev/fb/vesa.c

Modified: head/sys/dev/fb/vesa.c
==============================================================================
--- head/sys/dev/fb/vesa.c      Fri Mar 16 23:58:35 2012        (r233055)
+++ head/sys/dev/fb/vesa.c      Sat Mar 17 00:00:33 2012        (r233056)
@@ -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, in
 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, vo
        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, vo
 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, vo
 
        /* 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, vo
 
        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));
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to