Web lists-archives.com

[Spca50x-devs] PATCH: gspca-mercurial OV7630 fixes




Hi!

This patches make the initialization of the OV7630 shorter and fixes some initialization values to make the sensor work better in both resolution modes.

Regards,

Andoni
diff -r ed92c6358ca1 linux/drivers/media/video/gspca/sonixb.c
--- a/linux/drivers/media/video/gspca/sonixb.c	Thu Jul 17 12:34:28 2008 +0200
+++ b/linux/drivers/media/video/gspca/sonixb.c	Thu Jul 17 18:56:15 2008 -0300
@@ -358,7 +358,7 @@
 	{0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10},
 	{0xb0, 0x21, 0x01, 0x77, 0x3a, 0x00, 0x00, 0x10},
 /*	{0xd0, 0x21, 0x12, 0x7c, 0x01, 0x80, 0x34, 0x10},	   jfm */
-	{0xd0, 0x21, 0x12, 0x1c, 0x00, 0x80, 0x34, 0x10},	/* jfm */
+	{0xd0, 0x21, 0x12, 0x1c, 0x80, 0x80, 0x14, 0x10},
 	{0xa0, 0x21, 0x1b, 0x04, 0x00, 0x80, 0x34, 0x10},
 	{0xa0, 0x21, 0x20, 0x44, 0x00, 0x80, 0x34, 0x10},
 	{0xa0, 0x21, 0x23, 0xee, 0x00, 0x80, 0x34, 0x10},
@@ -381,10 +381,6 @@
 	{0xa0, 0x21, 0x10, 0x57, 0xbd, 0x06, 0xf6, 0x16},
 	{0xa0, 0x21, 0x76, 0x02, 0xbd, 0x06, 0xf6, 0x16},
 	{0xa0, 0x21, 0x00, 0x10, 0xbd, 0x06, 0xf6, 0x15},	/* gain */
-};
-static const __u8 ov7630_sensor_init_3[][8] = {
-	{0xa0, 0x21, 0x2a, 0xa0, 0x00, 0x00, 0x00, 0x10},
-	{0xa0, 0x21, 0x2a, 0x80, 0x00, 0x00, 0x00, 0x10},
 };
 
 static const __u8 initPas106[] = {
@@ -747,7 +743,7 @@
 		   found experimentally for the ov6650 is exactly half that of
 		   the ov6645. The ov7630 datasheet says the max is 0x41. */
 		const int reg10_max = (sd->sensor == SENSOR_OV6650)
-				? 0x4d : 0x41;
+				? 0x4d : 0xff;
 
 		reg11 = (60 * sd->exposure + 999) / 1000;
 		if (reg11 < 1)
@@ -767,6 +763,12 @@
 			reg10 = 10;
 		else if (reg10 > reg10_max)
 			reg10 = reg10_max;
+
+		/* In 640x480, if the reg11 has less than 2, the image is 
+		   unstable. */
+		if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv == 0
+		    && reg11 < 3)
+			reg11 = 3;
 
 		/* Write reg 10 and reg11 low nibble */
 		i2c[1] = sd->sensor_addr;
@@ -808,7 +810,7 @@
 			break;
 		case 1:			/* 50 hz */
 			i2c[3] = (sd->sensor == SENSOR_OV6650)
-					? 0x4f : 0x8a;
+					? 0x4f : 0x9e;
 			break;
 		}
 		i2c[1] = sd->sensor_addr;
@@ -1134,12 +1136,22 @@
 		i2c_w_vector(gspca_dev, ov7630_sensor_init,
 				sizeof ov7630_sensor_init);
 		break;
-	case SENSOR_OV7630_3:
+	case SENSOR_OV7630_3: {
+		__u8 i2c_r13[] = {0xa0, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10};
+		__u8 i2c_r2a[] = {0xa0, 0x21, 0x2a, 0x80, 0x00, 0x00, 0x00, 0x10};
+
+		if (mode == 0) {
+			i2c_r2a[3] |= 0x20;
+			i2c_r13[3] &= ~0x80;
+		}
 		i2c_w_vector(gspca_dev, ov7630_sensor_init_com,
 				sizeof ov7630_sensor_init_com);
 		msleep(200);
-		i2c_w(gspca_dev, ov7630_sensor_init_3[mode]);
+
+		i2c_w(gspca_dev, i2c_r13);
+		i2c_w(gspca_dev, i2c_r2a);
 		break;
+	    }
 	case SENSOR_PAS106:
 		pas106_i2cinit(gspca_dev);
 		break;
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Spca50x-devs mailing list
Spca50x-devs@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/spca50x-devs