Commit 3ab67baf authored by Jean-Francois Moine's avatar Jean-Francois Moine Committed by Mauro Carvalho Chehab

V4L/DVB (10346): gspca - zc3xx: Fix bad variable type with i2c read.

The returned value of i2c read is a 16 bits word. It was stored in
a 8 bits variable, preventing a sensor to be detected.
Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 36e819db
...@@ -6237,7 +6237,7 @@ static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = { ...@@ -6237,7 +6237,7 @@ static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = {
{} {}
}; };
static int reg_r_i(struct gspca_dev *gspca_dev, static u8 reg_r_i(struct gspca_dev *gspca_dev,
__u16 index) __u16 index)
{ {
usb_control_msg(gspca_dev->dev, usb_control_msg(gspca_dev->dev,
...@@ -6250,10 +6250,10 @@ static int reg_r_i(struct gspca_dev *gspca_dev, ...@@ -6250,10 +6250,10 @@ static int reg_r_i(struct gspca_dev *gspca_dev,
return gspca_dev->usb_buf[0]; return gspca_dev->usb_buf[0];
} }
static int reg_r(struct gspca_dev *gspca_dev, static u8 reg_r(struct gspca_dev *gspca_dev,
__u16 index) __u16 index)
{ {
int ret; u8 ret;
ret = reg_r_i(gspca_dev, index); ret = reg_r_i(gspca_dev, index);
PDEBUG(D_USBI, "reg r [%04x] -> %02x", index, ret); PDEBUG(D_USBI, "reg r [%04x] -> %02x", index, ret);
...@@ -6734,26 +6734,25 @@ static int sif_probe(struct gspca_dev *gspca_dev) ...@@ -6734,26 +6734,25 @@ static int sif_probe(struct gspca_dev *gspca_dev)
static int vga_2wr_probe(struct gspca_dev *gspca_dev) static int vga_2wr_probe(struct gspca_dev *gspca_dev)
{ {
struct usb_device *dev = gspca_dev->dev; struct usb_device *dev = gspca_dev->dev;
__u8 retbyte; u16 retword;
__u16 checkword;
start_2wr_probe(dev, 0x00); /* HV7131B */ start_2wr_probe(dev, 0x00); /* HV7131B */
i2c_write(gspca_dev, 0x01, 0xaa, 0x00); i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
retbyte = i2c_read(gspca_dev, 0x01); retword = i2c_read(gspca_dev, 0x01);
if (retbyte != 0) if (retword != 0)
return 0x00; /* HV7131B */ return 0x00; /* HV7131B */
start_2wr_probe(dev, 0x04); /* CS2102 */ start_2wr_probe(dev, 0x04); /* CS2102 */
i2c_write(gspca_dev, 0x01, 0xaa, 0x00); i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
retbyte = i2c_read(gspca_dev, 0x01); retword = i2c_read(gspca_dev, 0x01);
if (retbyte != 0) if (retword != 0)
return 0x04; /* CS2102 */ return 0x04; /* CS2102 */
start_2wr_probe(dev, 0x06); /* OmniVision */ start_2wr_probe(dev, 0x06); /* OmniVision */
reg_w(dev, 0x08, 0x008d); reg_w(dev, 0x08, 0x008d);
i2c_write(gspca_dev, 0x11, 0xaa, 0x00); i2c_write(gspca_dev, 0x11, 0xaa, 0x00);
retbyte = i2c_read(gspca_dev, 0x11); retword = i2c_read(gspca_dev, 0x11);
if (retbyte != 0) { if (retword != 0) {
/* (should have returned 0xaa) --> Omnivision? */ /* (should have returned 0xaa) --> Omnivision? */
/* reg_r 0x10 -> 0x06 --> */ /* reg_r 0x10 -> 0x06 --> */
goto ov_check; goto ov_check;
...@@ -6761,40 +6760,40 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev) ...@@ -6761,40 +6760,40 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
start_2wr_probe(dev, 0x08); /* HDCS2020 */ start_2wr_probe(dev, 0x08); /* HDCS2020 */
i2c_write(gspca_dev, 0x15, 0xaa, 0x00); i2c_write(gspca_dev, 0x15, 0xaa, 0x00);
retbyte = i2c_read(gspca_dev, 0x15); retword = i2c_read(gspca_dev, 0x15);
if (retbyte != 0) if (retword != 0)
return 0x08; /* HDCS2020 */ return 0x08; /* HDCS2020 */
start_2wr_probe(dev, 0x0a); /* PB0330 */ start_2wr_probe(dev, 0x0a); /* PB0330 */
i2c_write(gspca_dev, 0x07, 0xaa, 0xaa); i2c_write(gspca_dev, 0x07, 0xaa, 0xaa);
retbyte = i2c_read(gspca_dev, 0x07); retword = i2c_read(gspca_dev, 0x07);
if (retbyte != 0) if (retword != 0)
return 0x0a; /* PB0330 */ return 0x0a; /* PB0330 */
retbyte = i2c_read(gspca_dev, 0x03); retword = i2c_read(gspca_dev, 0x03);
if (retbyte != 0) if (retword != 0)
return 0x0a; /* PB0330 ?? */ return 0x0a; /* PB0330 ?? */
retbyte = i2c_read(gspca_dev, 0x04); retword = i2c_read(gspca_dev, 0x04);
if (retbyte != 0) if (retword != 0)
return 0x0a; /* PB0330 ?? */ return 0x0a; /* PB0330 ?? */
start_2wr_probe(dev, 0x0c); /* ICM105A */ start_2wr_probe(dev, 0x0c); /* ICM105A */
i2c_write(gspca_dev, 0x01, 0x11, 0x00); i2c_write(gspca_dev, 0x01, 0x11, 0x00);
retbyte = i2c_read(gspca_dev, 0x01); retword = i2c_read(gspca_dev, 0x01);
if (retbyte != 0) if (retword != 0)
return 0x0c; /* ICM105A */ return 0x0c; /* ICM105A */
start_2wr_probe(dev, 0x0e); /* PAS202BCB */ start_2wr_probe(dev, 0x0e); /* PAS202BCB */
reg_w(dev, 0x08, 0x008d); reg_w(dev, 0x08, 0x008d);
i2c_write(gspca_dev, 0x03, 0xaa, 0x00); i2c_write(gspca_dev, 0x03, 0xaa, 0x00);
msleep(500); msleep(500);
retbyte = i2c_read(gspca_dev, 0x03); retword = i2c_read(gspca_dev, 0x03);
if (retbyte != 0) if (retword != 0)
return 0x0e; /* PAS202BCB */ return 0x0e; /* PAS202BCB */
start_2wr_probe(dev, 0x02); /* ?? */ start_2wr_probe(dev, 0x02); /* ?? */
i2c_write(gspca_dev, 0x01, 0xaa, 0x00); i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
retbyte = i2c_read(gspca_dev, 0x01); retword = i2c_read(gspca_dev, 0x01);
if (retbyte != 0) if (retword != 0)
return 0x02; /* ?? */ return 0x02; /* ?? */
ov_check: ov_check:
reg_r(gspca_dev, 0x0010); /* ?? */ reg_r(gspca_dev, 0x0010); /* ?? */
...@@ -6808,12 +6807,10 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev) ...@@ -6808,12 +6807,10 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
msleep(500); msleep(500);
reg_w(dev, 0x01, 0x0012); reg_w(dev, 0x01, 0x0012);
i2c_write(gspca_dev, 0x12, 0x80, 0x00); /* sensor reset */ i2c_write(gspca_dev, 0x12, 0x80, 0x00); /* sensor reset */
retbyte = i2c_read(gspca_dev, 0x0a); retword = i2c_read(gspca_dev, 0x0a) << 8;
checkword = retbyte << 8; retword |= i2c_read(gspca_dev, 0x0b);
retbyte = i2c_read(gspca_dev, 0x0b); PDEBUG(D_PROBE, "probe 2wr ov vga 0x%04x", retword);
checkword |= retbyte; switch (retword) {
PDEBUG(D_PROBE, "probe 2wr ov vga 0x%04x", checkword);
switch (checkword) {
case 0x7631: /* OV7630C */ case 0x7631: /* OV7630C */
reg_w(dev, 0x06, 0x0010); reg_w(dev, 0x06, 0x0010);
break; break;
...@@ -6823,7 +6820,7 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev) ...@@ -6823,7 +6820,7 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
default: default:
return -1; /* not OmniVision */ return -1; /* not OmniVision */
} }
return checkword; return retword;
} }
struct sensor_by_chipset_revision { struct sensor_by_chipset_revision {
...@@ -6844,7 +6841,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) ...@@ -6844,7 +6841,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
struct usb_device *dev = gspca_dev->dev; struct usb_device *dev = gspca_dev->dev;
int i; int i;
__u8 retbyte; __u8 retbyte;
__u16 checkword; u16 retword;
/*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/ /*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/
reg_w(dev, 0x02, 0x0010); reg_w(dev, 0x02, 0x0010);
...@@ -6856,27 +6853,25 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) ...@@ -6856,27 +6853,25 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
reg_w(dev, 0x03, 0x0012); reg_w(dev, 0x03, 0x0012);
reg_w(dev, 0x01, 0x0012); reg_w(dev, 0x01, 0x0012);
reg_w(dev, 0x05, 0x0012); reg_w(dev, 0x05, 0x0012);
retbyte = i2c_read(gspca_dev, 0x14); retword = i2c_read(gspca_dev, 0x14);
if (retbyte != 0) if (retword != 0)
return 0x11; /* HV7131R */ return 0x11; /* HV7131R */
retbyte = i2c_read(gspca_dev, 0x15); retword = i2c_read(gspca_dev, 0x15);
if (retbyte != 0) if (retword != 0)
return 0x11; /* HV7131R */ return 0x11; /* HV7131R */
retbyte = i2c_read(gspca_dev, 0x16); retword = i2c_read(gspca_dev, 0x16);
if (retbyte != 0) if (retword != 0)
return 0x11; /* HV7131R */ return 0x11; /* HV7131R */
reg_w(dev, 0x02, 0x0010); reg_w(dev, 0x02, 0x0010);
retbyte = reg_r(gspca_dev, 0x000b); retword = reg_r(gspca_dev, 0x000b) << 8;
checkword = retbyte << 8; retword |= reg_r(gspca_dev, 0x000a);
retbyte = reg_r(gspca_dev, 0x000a); PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", retword);
checkword |= retbyte;
PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", checkword);
reg_r(gspca_dev, 0x0010); reg_r(gspca_dev, 0x0010);
/* this is tested only once anyway */ /* this is tested only once anyway */
for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) { for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) {
if (chipset_revision_sensor[i].revision == checkword) { if (chipset_revision_sensor[i].revision == retword) {
sd->chip_revision = checkword; sd->chip_revision = retword;
send_unknown(dev, SENSOR_PB0330); send_unknown(dev, SENSOR_PB0330);
return chipset_revision_sensor[i].internal_sensor_id; return chipset_revision_sensor[i].internal_sensor_id;
} }
...@@ -6888,8 +6883,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) ...@@ -6888,8 +6883,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
reg_w(dev, 0x0a, 0x0010); reg_w(dev, 0x0a, 0x0010);
reg_w(dev, 0x03, 0x0012); reg_w(dev, 0x03, 0x0012);
reg_w(dev, 0x01, 0x0012); reg_w(dev, 0x01, 0x0012);
retbyte = i2c_read(gspca_dev, 0x00); retword = i2c_read(gspca_dev, 0x00);
if (retbyte != 0) { if (retword != 0) {
PDEBUG(D_PROBE, "probe 3wr vga type 0a ?"); PDEBUG(D_PROBE, "probe 3wr vga type 0a ?");
return 0x0a; /* ?? */ return 0x0a; /* ?? */
} }
...@@ -6901,14 +6896,14 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) ...@@ -6901,14 +6896,14 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
reg_w(dev, 0x03, 0x0012); reg_w(dev, 0x03, 0x0012);
msleep(2); msleep(2);
reg_w(dev, 0x01, 0x0012); reg_w(dev, 0x01, 0x0012);
retbyte = i2c_read(gspca_dev, 0x00); retword = i2c_read(gspca_dev, 0x00);
if (retbyte != 0) { if (retword != 0) {
PDEBUG(D_PROBE, "probe 3wr vga type %02x", retbyte); PDEBUG(D_PROBE, "probe 3wr vga type %02x", retword);
if (retbyte == 0x11) /* VF0250 */ if (retword == 0x0011) /* VF0250 */
return 0x0250; return 0x0250;
if (retbyte == 0x29) /* gc0305 */ if (retword == 0x0029) /* gc0305 */
send_unknown(dev, SENSOR_GC0305); send_unknown(dev, SENSOR_GC0305);
return retbyte; return retword;
} }
reg_w(dev, 0x01, 0x0000); /* check OmniVision */ reg_w(dev, 0x01, 0x0000); /* check OmniVision */
...@@ -6918,8 +6913,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) ...@@ -6918,8 +6913,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
reg_w(dev, 0x06, 0x0010); reg_w(dev, 0x06, 0x0010);
reg_w(dev, 0x01, 0x0012); reg_w(dev, 0x01, 0x0012);
reg_w(dev, 0x05, 0x0012); reg_w(dev, 0x05, 0x0012);
if (i2c_read(gspca_dev, 0x1c) == 0x7f /* OV7610 - manufacturer ID */ if (i2c_read(gspca_dev, 0x1c) == 0x007f /* OV7610 - manufacturer ID */
&& i2c_read(gspca_dev, 0x1d) == 0xa2) { && i2c_read(gspca_dev, 0x1d) == 0x00a2) {
send_unknown(dev, SENSOR_OV7620); send_unknown(dev, SENSOR_OV7620);
return 0x06; /* OmniVision confirm ? */ return 0x06; /* OmniVision confirm ? */
} }
...@@ -6933,16 +6928,14 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) ...@@ -6933,16 +6928,14 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
/* msleep(150); */ /* msleep(150); */
reg_w(dev, 0x01, 0x0012); reg_w(dev, 0x01, 0x0012);
reg_w(dev, 0x05, 0x0012); reg_w(dev, 0x05, 0x0012);
retbyte = i2c_read(gspca_dev, 0x0000); /* ID 0 */ retword = i2c_read(gspca_dev, 0x00) << 8; /* ID 0 */
checkword = retbyte << 8; retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */
retbyte = i2c_read(gspca_dev, 0x0001); /* ID 1 */ PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword);
checkword |= retbyte; if (retword == 0x2030) {
PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", checkword);
if (checkword == 0x2030) {
retbyte = i2c_read(gspca_dev, 0x02); /* revision number */ retbyte = i2c_read(gspca_dev, 0x02); /* revision number */
PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte); PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte);
send_unknown(dev, SENSOR_PO2030); send_unknown(dev, SENSOR_PO2030);
return checkword; return retword;
} }
reg_w(dev, 0x01, 0x0000); reg_w(dev, 0x01, 0x0000);
...@@ -6953,9 +6946,9 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) ...@@ -6953,9 +6946,9 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
reg_w(dev, 0x01, 0x0012); reg_w(dev, 0x01, 0x0012);
reg_w(dev, 0x05, 0x0001); reg_w(dev, 0x05, 0x0001);
reg_w(dev, 0xd3, 0x008b); reg_w(dev, 0xd3, 0x008b);
retbyte = i2c_read(gspca_dev, 0x01); retword = i2c_read(gspca_dev, 0x01);
if (retbyte != 0) { if (retword != 0) {
PDEBUG(D_PROBE, "probe 3wr vga type 0a ?"); PDEBUG(D_PROBE, "probe 3wr vga type 0a ? ret: %04x", retword);
return 0x0a; /* ?? */ return 0x0a; /* ?? */
} }
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment