patch-2.4.21 linux-2.4.21/drivers/video/sstfb.c

Next file: linux-2.4.21/drivers/video/sti/sticore.c
Previous file: linux-2.4.21/drivers/video/sis/vstruct.h
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/drivers/video/sstfb.c linux-2.4.21/drivers/video/sstfb.c
@@ -333,7 +333,7 @@
 
 #if (SST_DEBUG_REG > 0)
 static void sst_dbg_print_read_reg (u32 reg, u32 val) {
-	char * regname =NULL;
+	char * regname = NULL;
 	switch (reg) {
 	case FBIINIT0: regname="FbiInit0"; break;
 	case FBIINIT1: regname="FbiInit1"; break;
@@ -367,8 +367,8 @@
 		r_dprintk(" sst_write(%s, %#x)\n", regname, val);
 }
 #else /*  (SST_DEBUG_REG > 0) */
-#  define sst_dbg_print_read_reg(reg, val)	do {}while(0)
-#  define sst_dbg_print_write_reg(reg, val)	do {}while(0)
+#  define sst_dbg_print_read_reg(reg, val)	do {} while(0)
+#  define sst_dbg_print_write_reg(reg, val)	do {} while(0)
 #endif /*  (SST_DEBUG_REG > 0) */
 
 /* register access */
@@ -531,20 +531,15 @@
 		break;
 #endif
 #ifdef EN_24_32_BPP
-#ifdef FBCON_HAS_CFB24
+#if defined(FBCON_HAS_CFB24) || defined(FBCON_HAS_CFB32)
 	case 24:
-		sst_info->fbcon_cmap.cfb32[regno]=col;
-		break;
-#endif
-#ifdef FBCON_HAS_CFB32
 	case 32:
 		sst_info->fbcon_cmap.cfb32[regno]=col;
 		break;
 #endif
 #endif
 	default:
-		eprintk("bug line %d: bad depth '%u'\n",__LINE__,
-			disp->var.bits_per_pixel);
+		BUG();
 		break;
 	}
 	f_dddprintk("bpp: %d . encoded color: %#x\n",
@@ -736,6 +731,7 @@
 #ifdef EN_24_32_BPP
 	case 24:	/* RGB 888 LfbMode 4 */
 	case 32:	/* ARGB 8888 LfbMode 5 */
+	       	/* in 24bpp we fake a 32 bpp mode */
 		var->red.length    = 8;
 		var->green.length  = 8;
 		var->blue.length   = 8;
@@ -744,11 +740,11 @@
 		var->red.offset    = 16;
 		var->green.offset  = 8;
 		var->blue.offset   = 0;
-		var->transp.offset = 0; /* in 24bpp we fake a 32 bpp mode */
+		var->transp.offset = 0;
 		break;
 #endif
 	default:
-		eprintk ("bug line %d: bad depth '%u'\n", __LINE__, par->bpp);
+		eprintk("bug line %d: bad depth '%u'\n", __LINE__, par->bpp);
 		break;
 	}
 	return 0;
@@ -775,18 +771,16 @@
 {
 #define sst_info	((struct sstfb_info *) info)
 
-  	struct fb_var_screeninfo *var;
- 	struct fb_var_screeninfo var2;
+	struct fb_var_screeninfo *var;
+	struct fb_var_screeninfo var2;
 
 	f_dprintk("sstfb_get_fix(con: %d)\n",con);
 	memset(fix, 0, sizeof(struct fb_fix_screeninfo));
 	
-	if (con == -1)
-	{
+	if (con == -1) {
 		sstfb_encode_var(&var2, &sst_info->current_par, sst_info);
 		var = &var2;
-	}
-	else
+	} else
 		var = &fb_display[con].var;
 
 	strcpy(fix->id, sst_info->info.modename);
@@ -974,27 +968,27 @@
                        struct fb_info *info)
 {
 #define sst_info	((struct sstfb_info *) info)
-#if (SST_DEBUG_IOCTL >0)
 	int i;
 	u_long p;
 	u32 tmp, val;
 	u32 fbiinit0;
 	struct pci_dev * sst_dev = sst_info->dev;
-#endif
 
 	f_dprintk("sstfb_ioctl(%x)\n", cmd);
-#if (SST_DEBUG_IOCTL >0)
+	
 	switch (cmd) {
-#  if (SST_DEBUG_VAR >0)
-/* tmp ioctl : dumps fb_display[0-5] */
+		
+#if (SST_DEBUG_VAR >0)
+	/* tmp ioctl : dumps fb_display[0-5] */
 	case _IO('F', 0xdb):		/* 0x46db */
 		f_dprintk("dumping fb_display[0-5].var\n");
 		for (i = 0 ; i< 6 ; i++) {
 			print_var(&fb_display[i].var, "var(%d)", i);
 		}
 		return 0;
-#  endif /* (SST_DEBUG_VAR >0) */
-/* fills the lfb up to *(u32*)arg */
+#endif /* (SST_DEBUG_VAR >0) */
+
+	/* fills the lfb up to given count of pixels */
 	case _IOW('F', 0xdc, u32):	/* 0x46dc */
 		if (copy_from_user(&val, (void *) arg, sizeof(val)))
 			return -EFAULT;
@@ -1004,7 +998,8 @@
 		for (p = 0 ; p < val; p+=2)
 			writew( p >> 6 , sst_info->video.vbase + p);
 		return 0;
-/* change VGA pass_through */
+		
+	/* enable/disable VGA pass_through */
 	case _IOW('F', 0xdd, u32):	/* 0x46dd */
 		if (copy_from_user(&val, (void *) arg, sizeof(val)))
 			return -EFAULT;
@@ -1022,28 +1017,29 @@
 		}
 		pci_write_config_dword(sst_dev, PCI_INIT_ENABLE, tmp);
 		return 0;
+
+	/* display test pattern */
 	case _IO('F', 0xde):		/* 0x46de */
 		f_dprintk("test color display\n");
 		f_ddprintk("currcon: %d, bpp %d\n", sst_info->currcon,
 			  sst_info->current_par.bpp);
 		memset_io(sst_info->video.vbase, 0, sst_info->video.len);
-	switch (sst_info->current_par.bpp) {
+		switch (sst_info->current_par.bpp) {
 	       	case 16:
 			sstfb_test16(sst_info);
 			break;
-#  ifdef EN_24_32_BPP
+#ifdef EN_24_32_BPP
 		case 24:
 		case 32:
 			sstfb_test32(sst_info);
 			break;
-#  endif
+#endif
 		default:
-			dprintk("bug line %d: bad depth '%u'\n", __LINE__,
-			        sst_info->current_par.bpp);
-			}
+			return -EFAULT;
+		}
 		return 0;
 	}
-#endif /* (SST_DEBUG_IOCTL >0) */
+	
 	return -EINVAL;
 #undef sst_info
 }
@@ -1506,7 +1502,7 @@
 	pci_write_config_dword(sst_dev, PCI_INIT_ENABLE, PCI_EN_FIFO_WR);
 
 	/* set lfbmode : set mode + front buffer for reads/writes
-	   + disable pipeline */
+	   + disable pipeline  */
 	switch(par->bpp) {
 	case 16:
 		lfbmode = LFB_565;
@@ -1520,18 +1516,16 @@
 		break;
 #endif
 	default:
-		dprintk("bug line %d: bad depth '%u'\n", __LINE__,
-			par->bpp );
+		BUG();
 		return 0;
-		break;
 	}
 
 #if defined(__BIG_ENDIAN)
 	/* enable byte-swizzle functionality in hardware */
-	lfbmode |= ( LFB_WORD_SWIZZLE_WR | LFB_BYTE_SWIZZLE_WR |
+	lfbmode |= ( LFB_WORD_SWIZZLE_WR | LFB_BYTE_SWIZZLE_WR | 
 		     LFB_WORD_SWIZZLE_RD | LFB_BYTE_SWIZZLE_RD );
 #endif
-	
+
 	if (clipping) {
 		sst_write(LFBMODE, lfbmode | EN_PXL_PIPELINE);
 	/*
@@ -1539,7 +1533,7 @@
 	 * writes to offscreen areas of the framebuffer are performed,
 	 * the "behaviour is undefined" (_very_ undefined) - Urs
 	 */
-	/* btw, it requires enabling pixel pipeline in LFBMODE .
+	/* btw, it requires enabling pixel pipeline in LFBMODE.
 	   off screen read/writes will just wrap and read/print pixels
 	   on screen. Ugly but not that dangerous */
 
@@ -1554,7 +1548,7 @@
 		sst_write(LFBMODE, lfbmode );
 	}
 
-	sst_info->current_par = *par ;
+	sst_info->current_par = *par;
 	return 1;
 }
 
@@ -1589,8 +1583,7 @@
 		break;
 #endif
 	default:
-		dprintk("bug line %d: bad depth '%u'\n", __LINE__, bpp);
-		break;
+		BUG();
 	}
 }
 
@@ -1608,8 +1601,7 @@
 		break;
 #endif
 	default:
-		dprintk("bug line %d: bad depth '%u'\n", __LINE__, bpp);
-		break;
+		BUG();
 	}
 }
 
@@ -2005,34 +1997,34 @@
 	u_long fbbase_virt = sst_info->video.vbase;
 
 	f_dprintk("sstfb_test16\n");
-	/* rect blanc 20x100+200+0 */
+	/* white rectangle 20x100+200+0 */
 	for (i=0 ; i< 100; i++) {
 	  p = fbbase_virt + 2048 *i+400;
-	  for (j=0 ; j < 10 ; j++) {
-	    writel( 0xffffffff, p);
+	  for (j=0; j < 10; j++) {
+	    writel(0xffffffff, p);
 	    p+=4;
 	  }
 	}
-	/* rect bleu 180x200+0+0 */
+	/* blue rectangle 180x200+0+0 */
 	for (i=0 ; i< 200; i++) {
 	  p = fbbase_virt + 2048 *i;
-	  for (j=0 ; j < 90 ; j++) {
-	    writel(0x001f001f,p);
+	  for (j=0; j < 90; j++) {
+	    writel(0x001f001f, p);
 	    p+=4;
 	  }
 	}
-	/* carre vert 40x40+100+0 */
+	/* green rectangle 40x40+100+0 */
 	for (i=0 ; i< 40 ; i++) {
 	  p = fbbase_virt + 2048 *i + 200;
-	  for (j=0; j <20;j++) {
+	  for (j=0; j <20; j++) {
 	    writel(0x07e007e0, p);
 	    p+=4;
 	  }
 	}
-	/*carre rouge 40x40+100+40 */
+	/* red rectangle 40x40+100+40 */
 	for (i=0; i<40; i++) {
 	  p = fbbase_virt + 2048 * (i+40) + 200;
-	  for (j=0; j <20;j++) {
+	  for (j=0; j <20; j++) {
 	    writel( 0xf800f800, p);
 	    p+=4;
 	  }
@@ -2052,22 +2044,22 @@
 	for (i=0 ; i< 100; i++) {
 	  p = fbbase_virt + 4096*i + 800;
 	  for (j=0 ; j < 20 ; j++) {
-	    writel( 0x00ffffff, p);
+	    writel(0x00ffffff, p);
 	    p+=4;
 	  }
 	}
 	/* rect bleu 180x200+0+0 */
 	for (i=0 ; i< 200; i++) {
 	  p = fbbase_virt + 4096 * i;
-	  for (j=0 ; j < 180 ; j++) {
-	    writel(0x000000ff,p);
+	  for (j=0 ; j < 180; j++) {
+	    writel(0x000000ff, p);
 	    p+=4;
 	  }
 	}
 	/* carre vert 40x40+100+0 */
 	for (i=0 ; i< 40 ; i++) {
 	  p = fbbase_virt + 4096 *i + 400;
-	  for (j=0; j <40;j++) {
+	  for (j=0; j <40; j++) {
 	    writel(0x0000ff00, p);
 	    p+=4;
 	  }
@@ -2075,8 +2067,8 @@
 	/*carre rouge 40x40+100+10 */
 	for (i=0; i<40; i++) {
 	  p = fbbase_virt + 4096 * (i+40) + 400;
-	  for (j=0; j <40;j++) {
-	    writel( 0x00ff0000, p);
+	  for (j=0; j <40; j++) {
+	    writel(0x00ff0000, p);
 	    p+=4;
 	  }
 	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)