[PATCH] vesafb: Add blanking support
authorAntonino A. Daplas <adaplas@gmail.com>
Fri, 9 Sep 2005 20:04:31 +0000 (13:04 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 9 Sep 2005 20:57:58 +0000 (13:57 -0700)
Add rudimentary support by manipulating the VGA registers.  However, not
all vesa modes are VGA compatible, so VGA compatiblity is checked first.
Only 2 levels are supported, powerup and powerdown.

Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/i386/boot/video.S
drivers/video/vesafb.c
include/linux/tty.h

index 0587477c99f2f32afa73a4dc10cf48e4ecb757d7..02bf625a681b041af67a6fb0de21df98da61a662 100644 (file)
@@ -97,6 +97,7 @@
 #define PARAM_VESAPM_OFF       0x30
 #define PARAM_LFB_PAGES                0x32
 #define PARAM_VESA_ATTRIB      0x34
+#define PARAM_CAPABILITIES      0x36
 
 /* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
 #ifdef CONFIG_VIDEO_RETAIN
@@ -233,6 +234,10 @@ mopar_gr:
        movw    18(%di), %ax
        movl    %eax, %fs:(PARAM_LFB_SIZE)
 
+# store mode capabilities
+       movl    10(%di), %eax
+       movl    %eax, %fs:(PARAM_CAPABILITIES)
+
 # switching the DAC to 8-bit is for <= 8 bpp only
        movw    %fs:(PARAM_LFB_DEPTH), %ax
        cmpw    $8, %ax
index a272592b037391858ab28d31ad93171fc15be1bb..1ca80264c7b00a13036f887e4438ab052ca68fd5 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/fb.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
+#include <video/vga.h>
 #include <asm/io.h>
 #include <asm/mtrr.h>
 
@@ -54,6 +55,7 @@ static unsigned short  *pmi_base  = NULL;
 static void            (*pmi_start)(void);
 static void            (*pmi_pal)(void);
 static int             depth;
+static int             vga_compat;
 
 /* --------------------------------------------------------------------- */
 
@@ -86,6 +88,37 @@ static int vesafb_pan_display(struct fb_var_screeninfo *var,
        return 0;
 }
 
+static int vesafb_blank(int blank, struct fb_info *info)
+{
+       int err = 1;
+
+       if (vga_compat) {
+               int loop = 10000;
+               u8 seq = 0, crtc17 = 0;
+
+               err = 0;
+
+               if (blank) {
+                       seq = 0x20;
+                       crtc17 = 0x00;
+               } else {
+                       seq = 0x00;
+                       crtc17 = 0x80;
+               }
+
+               vga_wseq(NULL, 0x00, 0x01);
+               seq |= vga_rseq(NULL, 0x01) & ~0x20;
+               vga_wseq(NULL, 0x00, seq);
+
+               crtc17 |= vga_rcrt(NULL, 0x17) & ~0x80;
+               while (loop--);
+               vga_wcrt(NULL, 0x17, crtc17);
+               vga_wseq(NULL, 0x00, 0x03);
+       }
+
+       return err;
+}
+
 static void vesa_setpalette(int regno, unsigned red, unsigned green,
                            unsigned blue)
 {
@@ -176,6 +209,7 @@ static struct fb_ops vesafb_ops = {
        .owner          = THIS_MODULE,
        .fb_setcolreg   = vesafb_setcolreg,
        .fb_pan_display = vesafb_pan_display,
+       .fb_blank       = vesafb_blank,
        .fb_fillrect    = cfb_fillrect,
        .fb_copyarea    = cfb_copyarea,
        .fb_imageblit   = cfb_imageblit,
@@ -429,6 +463,10 @@ static int __init vesafb_probe(struct device *device)
        info->flags = FBINFO_FLAG_DEFAULT |
                (ypan) ? FBINFO_HWACCEL_YPAN : 0;
 
+       vga_compat = (screen_info.capabilities & 2) ? 0 : 1;
+       printk("vesafb: Mode is %sVGA compatible\n",
+              (vga_compat) ? "" : "not ");
+
        if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
                err = -ENOMEM;
                goto err;
index 59ff42c629ece02d39f81b12959e164a5918965e..1267f88ece6eae9616453c1128859cbf49754000 100644 (file)
@@ -74,7 +74,8 @@ struct screen_info {
        u16 vesapm_off;         /* 0x30 */
        u16 pages;              /* 0x32 */
        u16 vesa_attributes;    /* 0x34 */
-                               /* 0x36 -- 0x3f reserved for future expansion */
+       u32  capabilities;      /* 0x36 */
+                               /* 0x3a -- 0x3f reserved for future expansion */
 };
 
 extern struct screen_info screen_info;