patch-2.1.81 linux/drivers/char/bttv.c

Next file: linux/drivers/char/busmouse.c
Previous file: linux/drivers/cdrom/cdu31a.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.80/linux/drivers/char/bttv.c linux/drivers/char/bttv.c
@@ -129,16 +129,22 @@
 	btwrite(BT848_INT_I2CDONE, BT848_INT_STAT);
   
 	btwrite(((addr & 0xff) << 24) | I2C_COMMAND, BT848_I2C);
-  
-	for (i=0x7fffffff; i; i--)
+
+	/*
+	 * Timeout for I2CRead is 1 second (this should be enough, really!)
+	 */
+	for (i=1000; i; i--)
 	{
 		stat=btread(BT848_INT_STAT);
 		if (stat & BT848_INT_I2CDONE)
 			break;
+		udelay(1000); /* 1ms, as I2C is 1kHz (?) */
 	}
   
-	if (!i)
+	if (!i) {
+		printk(KERN_DEBUG "bttv: I2CRead timeout\n");
 		return -1;
+	}
 	if (!(stat & BT848_INT_RACK))
 		return -2;
   
@@ -167,15 +173,18 @@
   
 	btwrite(data, BT848_I2C);
 
-	for (i=0x7fffffff; i; i--)
+	for (i=1000; i; i--)
 	{
 		stat=btread(BT848_INT_STAT);
 		if (stat & BT848_INT_I2CDONE)
 			break;
+		udelay(1000);
 	}
   
-	if (!i)
+	if (!i) {
+		printk(KERN_DEBUG "bttv: I2CWrite timeout\n");
 		return -1;
+	}
 	if (!(stat & BT848_INT_RACK))
 		return -2;
   
@@ -772,7 +781,7 @@
 	/*
 	 *	32bit depth frame buffers need extra flags setting
 	 */
-	 
+
 	if (depth==4)
 		mask=BT848_RISC_BYTE3;
 	else
@@ -1093,13 +1102,13 @@
 		case VIDIOCGPICT:
 		{
 			struct video_picture p=btv->picture;
-			if(btv->win.bpp==8)
+			if(btv->win.bpp==1)
 				p.palette=VIDEO_PALETTE_HI240;
-			if(btv->win.bpp==16)
+			if(btv->win.bpp==2)
 				p.palette=VIDEO_PALETTE_RGB565;
-			if(btv->win.bpp==24)
+			if(btv->win.bpp==3)
 				p.palette=VIDEO_PALETTE_RGB24;
-			if(btv->win.bpp==32)
+			if(btv->win.bpp==4)
 				p.palette=VIDEO_PALETTE_RGB32;
 			if(copy_to_user(arg, &p, sizeof(p)))
 				return -EFAULT;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov