[PATCH 5/6] [media] gspca/sonixj: Fix support for sn9c105+0v7660

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This bug were very tricky to discover. Basically, replying the webcam
initialization sequence, after the capture is running make it works.
After several researches, I discovered that the sensor were in powerdown
mode, when the init sequence was sent. As result, the sensor were never
initialized.

The right fix would be to map the cases where the powerdown logic is
inverted, and add it at some per-device init table. While we don't have
it at sonixj, just add a variable to the bridge_init (where the sensor is
also initialized), properly handling the case where the logic is not inverted
for this specific device.

The patch were tested with a 0c45:60fb Microdia Composite Device.

Signed-off-by: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>

diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 2229847..681f64b 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -1766,6 +1766,7 @@ static void bridge_init(struct gspca_dev *gspca_dev,
 	static const u8 reg9a_spec[] =
 		{0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
 	static const u8 regd4[] = {0x60, 0x00, 0x00};
+	u8 reg1_inv_powerdown = 0x02;
 
 	/* sensor clock already enabled in sd_init */
 	/* reg_w1(gspca_dev, 0xf1, 0x00); */
@@ -1779,6 +1780,14 @@ static void bridge_init(struct gspca_dev *gspca_dev,
 	reg_w(gspca_dev, 0x01, reg0102, 2);
 	reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
 	reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
+
+	/*
+	 * This combination doesn't use an inverted powerdown
+	 * Tested with USB ID = 0c45:60fb
+	 */
+	if (sd->sensor == SENSOR_OV7660 && sd->bridge == BRIDGE_SN9C105)
+		reg1_inv_powerdown = 0;
+
 	switch (sd->sensor) {
 	case SENSOR_GC0307:
 	case SENSOR_OV7660:
@@ -1798,6 +1807,11 @@ static void bridge_init(struct gspca_dev *gspca_dev,
 
 	reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
 
+	/*
+	 * FIXME: most of the info on this table is due to inverse
+	 * powerdown. The better is to add this information on a per-type
+	 * config, and remove this ugly hack
+	 */
 	switch (sd->sensor) {
 	case SENSOR_ADCM1700:
 		reg_w1(gspca_dev, 0x01, 0x43);
@@ -1864,10 +1878,10 @@ static void bridge_init(struct gspca_dev *gspca_dev,
 		break;
 	case SENSOR_PO2030N:
 	case SENSOR_OV7660:
-		reg_w1(gspca_dev, 0x01, 0x63);
+		reg_w1(gspca_dev, 0x01, 0x61 | reg1_inv_powerdown);
 		reg_w1(gspca_dev, 0x17, 0x20);
-		reg_w1(gspca_dev, 0x01, 0x62);
-		reg_w1(gspca_dev, 0x01, 0x42);
+		reg_w1(gspca_dev, 0x01, 0x60 | reg1_inv_powerdown);
+		reg_w1(gspca_dev, 0x01, 0x40 | reg1_inv_powerdown);
 		break;
 	case SENSOR_SP80708:
 		reg_w1(gspca_dev, 0x01, 0x63);
@@ -2606,6 +2620,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
 				reg17 = 0xa2;
 				reg1 = 0x44;	/* 48 Mhz, video trf eneble */
 			}
+		} else if (sd->bridge == BRIDGE_SN9C105) {
+			reg17 = 0xa2;
+			reg1 = 0x44;	/* 48 Mhz, video trf eneble */
 		} else {
 			reg17 = 0x22;
 			reg1 = 0x06;	/* 24 Mhz, video trf eneble
-- 
1.7.1


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux