
From: "Antonino A. Daplas" <adaplas@hotpop.com>

This patch fixes some of the drivers' fb_blank() implementation which got
the usage of the VESA_* constants incorrectly and converts them to use the
new FB_BLANK-* constants.

I'm not sure if what I did is correct for all drivers, so maintainers,
please review.

(Note: For most of the drivers, FB_BLANK_NORMAL is treated as
FB_BLANK_UNBLANK, but returns a nonzero so fbcon will do a soft_blank).

Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/video/aty/radeon_base.c |   22 +++++++++++++---------
 25-akpm/drivers/video/cirrusfb.c        |   18 +++++++++++-------
 25-akpm/drivers/video/epson1355fb.c     |   13 ++++++++-----
 25-akpm/drivers/video/i810/i810_main.c  |   17 ++++++++++++-----
 25-akpm/drivers/video/radeonfb.c        |   12 +++++++-----
 5 files changed, 51 insertions(+), 31 deletions(-)

diff -puN drivers/video/aty/radeon_base.c~fbdev-fix-broken-fb_blank-implementation drivers/video/aty/radeon_base.c
--- 25/drivers/video/aty/radeon_base.c~fbdev-fix-broken-fb_blank-implementation	2004-11-07 16:32:51.629990784 -0800
+++ 25-akpm/drivers/video/aty/radeon_base.c	2004-11-07 16:32:51.642988808 -0800
@@ -947,15 +947,16 @@ static int radeon_screen_blank (struct r
         val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS |
                  CRTC_VSYNC_DIS);
         switch (blank) {
-	case VESA_NO_BLANKING:
+	case FB_BLANK_UNBLANK:
+	case FB_BLANK_NORMAL:
 		break;
-	case VESA_VSYNC_SUSPEND:
+	case FB_BLANK_VSYNC_SUSPEND:
 		val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS);
 		break;
-	case VESA_HSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
 		val |= (CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS);
 		break;
-	case VESA_POWERDOWN:
+	case FB_BLANK_POWERDOWN:
 		val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS |
 			CRTC_HSYNC_DIS);
 		break;
@@ -967,7 +968,8 @@ static int radeon_screen_blank (struct r
 	case MT_DFP:
 		if (mode_switch)
 			break;
-		if (blank == VESA_NO_BLANKING)
+		if (blank == FB_BLANK_UNBLANK ||
+		    blank == FB_BLANK_NORMAL)
 			OUTREGP(FP_GEN_CNTL, (FP_FPON | FP_TMDS_EN),
 				~(FP_FPON | FP_TMDS_EN));
 		else
@@ -975,7 +977,8 @@ static int radeon_screen_blank (struct r
 		break;
 	case MT_LCD:
 		val = INREG(LVDS_GEN_CNTL);
-		if (blank == VESA_NO_BLANKING) {
+		if (blank == FB_BLANK_UNBLANK ||
+		    blank == FB_BLANK_NORMAL) {
 			u32 target_val = (val & ~LVDS_DISPLAY_DIS) | LVDS_BLON | LVDS_ON
 				| LVDS_ON | (rinfo->init_state.lvds_gen_cntl & LVDS_DIGON);
 			if ((val ^ target_val) == LVDS_DISPLAY_DIS)
@@ -1023,7 +1026,8 @@ static int radeon_screen_blank (struct r
 		break;
 	}
 
-	return 0;
+	/* let fbcon do a soft blank for us */
+	return (blank == FB_BLANK_NORMAL) ? -EINVAL : 0;
 }
 
 int radeonfb_blank (int blank, struct fb_info *info)
@@ -1265,7 +1269,7 @@ static void radeon_write_mode (struct ra
 
 	del_timer_sync(&rinfo->lvds_timer);
 
-	radeon_screen_blank(rinfo, VESA_POWERDOWN, 1);
+	radeon_screen_blank(rinfo, FB_BLANK_POWERDOWN, 1);
 	msleep(100);
 
 	radeon_fifo_wait(31);
@@ -1308,7 +1312,7 @@ static void radeon_write_mode (struct ra
 		OUTREG(TMDS_TRANSMITTER_CNTL, mode->tmds_transmitter_cntl);
 	}
 
-	radeon_screen_blank(rinfo, VESA_NO_BLANKING, 1);
+	radeon_screen_blank(rinfo, FB_BLANK_UNBLANK, 1);
 
 	radeon_fifo_wait(2);
 	OUTPLL(VCLK_ECP_CNTL, mode->vclk_ecp_cntl);
diff -puN drivers/video/cirrusfb.c~fbdev-fix-broken-fb_blank-implementation drivers/video/cirrusfb.c
--- 25/drivers/video/cirrusfb.c~fbdev-fix-broken-fb_blank-implementation	2004-11-07 16:32:51.631990480 -0800
+++ 25-akpm/drivers/video/cirrusfb.c	2004-11-07 16:32:51.644988504 -0800
@@ -1727,7 +1727,8 @@ int cirrusfb_blank (int blank_mode, stru
 	}
 
 	/* Undo current */
-	if (current_mode != VESA_NO_BLANKING) {
+	if (current_mode == FB_BLANK_NORMAL ||
+	    current_mode == FB_BLANK_UNBLANK) {
 		/* unblank the screen */
 		val = vga_rseq (cinfo->regbase, VGA_SEQ_CLOCK_MODE);
 		vga_wseq (cinfo->regbase, VGA_SEQ_CLOCK_MODE, val & 0xdf);	/* clear "FullBandwidth" bit */
@@ -1736,22 +1737,23 @@ int cirrusfb_blank (int blank_mode, stru
 	}
 
 	/* set new */
-	if(blank_mode != VESA_NO_BLANKING) {
+	if(blank_mode > FB_BLANK_NORMAL) {
 		/* blank the screen */
 		val = vga_rseq (cinfo->regbase, VGA_SEQ_CLOCK_MODE);
 		vga_wseq (cinfo->regbase, VGA_SEQ_CLOCK_MODE, val | 0x20);	/* set "FullBandwidth" bit */
 	}
 
 	switch (blank_mode) {
-	case VESA_NO_BLANKING:
+	case FB_BLANK_UNBLANK:
+	case FB_BLANK_NORMAL:
 		break;
-	case VESA_VSYNC_SUSPEND:
+	case FB_BLANK_VSYNC_SUSPEND:
 		vga_wgfx (cinfo->regbase, CL_GRE, 0x04);
 		break;
-	case VESA_HSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
 		vga_wgfx (cinfo->regbase, CL_GRE, 0x02);
 		break;
-	case VESA_POWERDOWN:
+	case FB_BLANK_POWERDOWN:
 		vga_wgfx (cinfo->regbase, CL_GRE, 0x06);
 		break;
 	default:
@@ -1761,7 +1763,9 @@ int cirrusfb_blank (int blank_mode, stru
 
 	cinfo->blank_mode = blank_mode;
 	DPRINTK ("EXIT, returning 0\n");
-	return 0;
+
+	/* Let fbcon do a soft blank for us */
+	return (blank_mode == FB_BLANK_NORMAL) ? 1 : 0;
 }
 /**** END   Hardware specific Routines **************************************/
 /****************************************************************************/
diff -puN drivers/video/epson1355fb.c~fbdev-fix-broken-fb_blank-implementation drivers/video/epson1355fb.c
--- 25/drivers/video/epson1355fb.c~fbdev-fix-broken-fb_blank-implementation	2004-11-07 16:32:51.633990176 -0800
+++ 25-akpm/drivers/video/epson1355fb.c	2004-11-07 16:32:51.645988352 -0800
@@ -288,22 +288,25 @@ static int epson1355fb_blank(int blank_m
 	struct epson1355_par *par = info->par;
 
 	switch (blank_mode) {
-	case VESA_NO_BLANKING:
+	case FB_BLANK_UNBLANKING:
+	case FB_BLANK_NORMAL:
 		lcd_enable(par, 1);
 		backlight_enable(1);
 		break;
-	case VESA_VSYNC_SUSPEND:
-	case VESA_HSYNC_SUSPEND:
+	case FB_BLANK_VSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
 		backlight_enable(0);
 		break;
-	case VESA_POWERDOWN:
+	case FB_BLANK_POWERDOWN:
 		backlight_enable(0);
 		lcd_enable(par, 0);
 		break;
 	default:
 		return -EINVAL;
 	}
-	return 0;
+
+	/* let fbcon do a soft blank for us */
+	return (blank_mode == FB_BLANK_NORMAL) ? 1 : 0;
 }
 
 /* ------------------------------------------------------------------------- */
diff -puN drivers/video/i810/i810_main.c~fbdev-fix-broken-fb_blank-implementation drivers/video/i810/i810_main.c
--- 25/drivers/video/i810/i810_main.c~fbdev-fix-broken-fb_blank-implementation	2004-11-07 16:32:51.635989872 -0800
+++ 25-akpm/drivers/video/i810/i810_main.c	2004-11-07 16:32:51.647988048 -0800
@@ -1323,23 +1323,28 @@ static int i810fb_blank (int blank_mode,
 	
 	pwr = i810_readl(PWR_CLKC, mmio);
 
-	switch(blank_mode) {
-	case VESA_NO_BLANKING:
+	switch (blank_mode) {
+	case FB_BLANK_UNBLANK:
 		mode = POWERON;
 		pwr |= 1;
 		scr_off = ON;
 		break;
-	case VESA_VSYNC_SUSPEND:
+	case FB_BLANK_NORMAL:
+		mode = POWERON;
+		pwr |= 1;
+		scr_off = OFF;
+		break;
+	case FB_BLANK_VSYNC_SUSPEND:
 		mode = STANDBY;
 		pwr |= 1;
 		scr_off = OFF;
 		break;
-	case VESA_HSYNC_SUSPEND:
+	case FB_BLANK_HSYNC_SUSPEND:
 		mode = SUSPEND;
 		pwr |= 1;
 		scr_off = OFF;
 		break;
-	case VESA_POWERDOWN:
+	case FB_BLANK_POWERDOWN:
 		mode = POWERDOWN;
 		pwr &= ~1;
 		scr_off = OFF;
@@ -1347,9 +1352,11 @@ static int i810fb_blank (int blank_mode,
 	default:
 		return -EINVAL; 
 	}
+
 	i810_screen_off(mmio, scr_off);
 	i810_writel(HVSYNC, mmio, mode);
 	i810_writel(PWR_CLKC, mmio, pwr);
+
 	return 0;
 }
 
diff -puN drivers/video/radeonfb.c~fbdev-fix-broken-fb_blank-implementation drivers/video/radeonfb.c
--- 25/drivers/video/radeonfb.c~fbdev-fix-broken-fb_blank-implementation	2004-11-07 16:32:51.637989568 -0800
+++ 25-akpm/drivers/video/radeonfb.c	2004-11-07 16:32:51.649987744 -0800
@@ -1629,15 +1629,16 @@ static int radeonfb_blank (int blank, st
 	val2 &= ~(LVDS_DISPLAY_DIS);
 
         switch (blank) {
-                case VESA_NO_BLANKING:
+	        case FB_BLANK_UNBLANK:
+	        case FB_BLANK_NORMAL:
                         break;
-                case VESA_VSYNC_SUSPEND:
+                case FB_BLANK_VSYNC_SUSPEND:
                         val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS);
                         break;
-                case VESA_HSYNC_SUSPEND:
+                case FB_BLANK_HSYNC_SUSPEND:
                         val |= (CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS);
                         break;
-                case VESA_POWERDOWN:
+                case FB_BLANK_POWERDOWN:
                         val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS | 
                                 CRTC_HSYNC_DIS);
 			val2 |= (LVDS_DISPLAY_DIS);
@@ -1654,7 +1655,8 @@ static int radeonfb_blank (int blank, st
 			break;
 	}
 
-	return 0;
+	/* let fbcon do a soft blank for us */
+	return (blank == FB_BLANK_NORMAL) ? 1 : 0;
 }
 
 
_
