aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2009-01-08 07:38:45 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:30 -0400
commit3ab67baf36c1f5356afb6424aca77866d91a6b5b (patch)
treeb36dc93d52cab1fbf9fac6610f55ac2ba27dc17c /drivers
parent36e819db435a61819d50c57c424a5ab2b9634e59 (diff)
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: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/zc3xx.c125
1 files changed, 59 insertions, 66 deletions
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 226aafc9688d..74eabce7b4ae 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -6237,7 +6237,7 @@ static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = {
6237 {} 6237 {}
6238}; 6238};
6239 6239
6240static int reg_r_i(struct gspca_dev *gspca_dev, 6240static u8 reg_r_i(struct gspca_dev *gspca_dev,
6241 __u16 index) 6241 __u16 index)
6242{ 6242{
6243 usb_control_msg(gspca_dev->dev, 6243 usb_control_msg(gspca_dev->dev,
@@ -6250,10 +6250,10 @@ static int reg_r_i(struct gspca_dev *gspca_dev,
6250 return gspca_dev->usb_buf[0]; 6250 return gspca_dev->usb_buf[0];
6251} 6251}
6252 6252
6253static int reg_r(struct gspca_dev *gspca_dev, 6253static u8 reg_r(struct gspca_dev *gspca_dev,
6254 __u16 index) 6254 __u16 index)
6255{ 6255{
6256 int ret; 6256 u8 ret;
6257 6257
6258 ret = reg_r_i(gspca_dev, index); 6258 ret = reg_r_i(gspca_dev, index);
6259 PDEBUG(D_USBI, "reg r [%04x] -> %02x", index, ret); 6259 PDEBUG(D_USBI, "reg r [%04x] -> %02x", index, ret);
@@ -6734,26 +6734,25 @@ static int sif_probe(struct gspca_dev *gspca_dev)
6734static int vga_2wr_probe(struct gspca_dev *gspca_dev) 6734static int vga_2wr_probe(struct gspca_dev *gspca_dev)
6735{ 6735{
6736 struct usb_device *dev = gspca_dev->dev; 6736 struct usb_device *dev = gspca_dev->dev;
6737 __u8 retbyte; 6737 u16 retword;
6738 __u16 checkword;
6739 6738
6740 start_2wr_probe(dev, 0x00); /* HV7131B */ 6739 start_2wr_probe(dev, 0x00); /* HV7131B */
6741 i2c_write(gspca_dev, 0x01, 0xaa, 0x00); 6740 i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
6742 retbyte = i2c_read(gspca_dev, 0x01); 6741 retword = i2c_read(gspca_dev, 0x01);
6743 if (retbyte != 0) 6742 if (retword != 0)
6744 return 0x00; /* HV7131B */ 6743 return 0x00; /* HV7131B */
6745 6744
6746 start_2wr_probe(dev, 0x04); /* CS2102 */ 6745 start_2wr_probe(dev, 0x04); /* CS2102 */
6747 i2c_write(gspca_dev, 0x01, 0xaa, 0x00); 6746 i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
6748 retbyte = i2c_read(gspca_dev, 0x01); 6747 retword = i2c_read(gspca_dev, 0x01);
6749 if (retbyte != 0) 6748 if (retword != 0)
6750 return 0x04; /* CS2102 */ 6749 return 0x04; /* CS2102 */
6751 6750
6752 start_2wr_probe(dev, 0x06); /* OmniVision */ 6751 start_2wr_probe(dev, 0x06); /* OmniVision */
6753 reg_w(dev, 0x08, 0x008d); 6752 reg_w(dev, 0x08, 0x008d);
6754 i2c_write(gspca_dev, 0x11, 0xaa, 0x00); 6753 i2c_write(gspca_dev, 0x11, 0xaa, 0x00);
6755 retbyte = i2c_read(gspca_dev, 0x11); 6754 retword = i2c_read(gspca_dev, 0x11);
6756 if (retbyte != 0) { 6755 if (retword != 0) {
6757 /* (should have returned 0xaa) --> Omnivision? */ 6756 /* (should have returned 0xaa) --> Omnivision? */
6758 /* reg_r 0x10 -> 0x06 --> */ 6757 /* reg_r 0x10 -> 0x06 --> */
6759 goto ov_check; 6758 goto ov_check;
@@ -6761,40 +6760,40 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
6761 6760
6762 start_2wr_probe(dev, 0x08); /* HDCS2020 */ 6761 start_2wr_probe(dev, 0x08); /* HDCS2020 */
6763 i2c_write(gspca_dev, 0x15, 0xaa, 0x00); 6762 i2c_write(gspca_dev, 0x15, 0xaa, 0x00);
6764 retbyte = i2c_read(gspca_dev, 0x15); 6763 retword = i2c_read(gspca_dev, 0x15);
6765 if (retbyte != 0) 6764 if (retword != 0)
6766 return 0x08; /* HDCS2020 */ 6765 return 0x08; /* HDCS2020 */
6767 6766
6768 start_2wr_probe(dev, 0x0a); /* PB0330 */ 6767 start_2wr_probe(dev, 0x0a); /* PB0330 */
6769 i2c_write(gspca_dev, 0x07, 0xaa, 0xaa); 6768 i2c_write(gspca_dev, 0x07, 0xaa, 0xaa);
6770 retbyte = i2c_read(gspca_dev, 0x07); 6769 retword = i2c_read(gspca_dev, 0x07);
6771 if (retbyte != 0) 6770 if (retword != 0)
6772 return 0x0a; /* PB0330 */ 6771 return 0x0a; /* PB0330 */
6773 retbyte = i2c_read(gspca_dev, 0x03); 6772 retword = i2c_read(gspca_dev, 0x03);
6774 if (retbyte != 0) 6773 if (retword != 0)
6775 return 0x0a; /* PB0330 ?? */ 6774 return 0x0a; /* PB0330 ?? */
6776 retbyte = i2c_read(gspca_dev, 0x04); 6775 retword = i2c_read(gspca_dev, 0x04);
6777 if (retbyte != 0) 6776 if (retword != 0)
6778 return 0x0a; /* PB0330 ?? */ 6777 return 0x0a; /* PB0330 ?? */
6779 6778
6780 start_2wr_probe(dev, 0x0c); /* ICM105A */ 6779 start_2wr_probe(dev, 0x0c); /* ICM105A */
6781 i2c_write(gspca_dev, 0x01, 0x11, 0x00); 6780 i2c_write(gspca_dev, 0x01, 0x11, 0x00);
6782 retbyte = i2c_read(gspca_dev, 0x01); 6781 retword = i2c_read(gspca_dev, 0x01);
6783 if (retbyte != 0) 6782 if (retword != 0)
6784 return 0x0c; /* ICM105A */ 6783 return 0x0c; /* ICM105A */
6785 6784
6786 start_2wr_probe(dev, 0x0e); /* PAS202BCB */ 6785 start_2wr_probe(dev, 0x0e); /* PAS202BCB */
6787 reg_w(dev, 0x08, 0x008d); 6786 reg_w(dev, 0x08, 0x008d);
6788 i2c_write(gspca_dev, 0x03, 0xaa, 0x00); 6787 i2c_write(gspca_dev, 0x03, 0xaa, 0x00);
6789 msleep(500); 6788 msleep(500);
6790 retbyte = i2c_read(gspca_dev, 0x03); 6789 retword = i2c_read(gspca_dev, 0x03);
6791 if (retbyte != 0) 6790 if (retword != 0)
6792 return 0x0e; /* PAS202BCB */ 6791 return 0x0e; /* PAS202BCB */
6793 6792
6794 start_2wr_probe(dev, 0x02); /* ?? */ 6793 start_2wr_probe(dev, 0x02); /* ?? */
6795 i2c_write(gspca_dev, 0x01, 0xaa, 0x00); 6794 i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
6796 retbyte = i2c_read(gspca_dev, 0x01); 6795 retword = i2c_read(gspca_dev, 0x01);
6797 if (retbyte != 0) 6796 if (retword != 0)
6798 return 0x02; /* ?? */ 6797 return 0x02; /* ?? */
6799ov_check: 6798ov_check:
6800 reg_r(gspca_dev, 0x0010); /* ?? */ 6799 reg_r(gspca_dev, 0x0010); /* ?? */
@@ -6808,12 +6807,10 @@ ov_check:
6808 msleep(500); 6807 msleep(500);
6809 reg_w(dev, 0x01, 0x0012); 6808 reg_w(dev, 0x01, 0x0012);
6810 i2c_write(gspca_dev, 0x12, 0x80, 0x00); /* sensor reset */ 6809 i2c_write(gspca_dev, 0x12, 0x80, 0x00); /* sensor reset */
6811 retbyte = i2c_read(gspca_dev, 0x0a); 6810 retword = i2c_read(gspca_dev, 0x0a) << 8;
6812 checkword = retbyte << 8; 6811 retword |= i2c_read(gspca_dev, 0x0b);
6813 retbyte = i2c_read(gspca_dev, 0x0b); 6812 PDEBUG(D_PROBE, "probe 2wr ov vga 0x%04x", retword);
6814 checkword |= retbyte; 6813 switch (retword) {
6815 PDEBUG(D_PROBE, "probe 2wr ov vga 0x%04x", checkword);
6816 switch (checkword) {
6817 case 0x7631: /* OV7630C */ 6814 case 0x7631: /* OV7630C */
6818 reg_w(dev, 0x06, 0x0010); 6815 reg_w(dev, 0x06, 0x0010);
6819 break; 6816 break;
@@ -6823,7 +6820,7 @@ ov_check:
6823 default: 6820 default:
6824 return -1; /* not OmniVision */ 6821 return -1; /* not OmniVision */
6825 } 6822 }
6826 return checkword; 6823 return retword;
6827} 6824}
6828 6825
6829struct sensor_by_chipset_revision { 6826struct sensor_by_chipset_revision {
@@ -6844,7 +6841,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6844 struct usb_device *dev = gspca_dev->dev; 6841 struct usb_device *dev = gspca_dev->dev;
6845 int i; 6842 int i;
6846 __u8 retbyte; 6843 __u8 retbyte;
6847 __u16 checkword; 6844 u16 retword;
6848 6845
6849/*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/ 6846/*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/
6850 reg_w(dev, 0x02, 0x0010); 6847 reg_w(dev, 0x02, 0x0010);
@@ -6856,27 +6853,25 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6856 reg_w(dev, 0x03, 0x0012); 6853 reg_w(dev, 0x03, 0x0012);
6857 reg_w(dev, 0x01, 0x0012); 6854 reg_w(dev, 0x01, 0x0012);
6858 reg_w(dev, 0x05, 0x0012); 6855 reg_w(dev, 0x05, 0x0012);
6859 retbyte = i2c_read(gspca_dev, 0x14); 6856 retword = i2c_read(gspca_dev, 0x14);
6860 if (retbyte != 0) 6857 if (retword != 0)
6861 return 0x11; /* HV7131R */ 6858 return 0x11; /* HV7131R */
6862 retbyte = i2c_read(gspca_dev, 0x15); 6859 retword = i2c_read(gspca_dev, 0x15);
6863 if (retbyte != 0) 6860 if (retword != 0)
6864 return 0x11; /* HV7131R */ 6861 return 0x11; /* HV7131R */
6865 retbyte = i2c_read(gspca_dev, 0x16); 6862 retword = i2c_read(gspca_dev, 0x16);
6866 if (retbyte != 0) 6863 if (retword != 0)
6867 return 0x11; /* HV7131R */ 6864 return 0x11; /* HV7131R */
6868 6865
6869 reg_w(dev, 0x02, 0x0010); 6866 reg_w(dev, 0x02, 0x0010);
6870 retbyte = reg_r(gspca_dev, 0x000b); 6867 retword = reg_r(gspca_dev, 0x000b) << 8;
6871 checkword = retbyte << 8; 6868 retword |= reg_r(gspca_dev, 0x000a);
6872 retbyte = reg_r(gspca_dev, 0x000a); 6869 PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", retword);
6873 checkword |= retbyte;
6874 PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", checkword);
6875 reg_r(gspca_dev, 0x0010); 6870 reg_r(gspca_dev, 0x0010);
6876 /* this is tested only once anyway */ 6871 /* this is tested only once anyway */
6877 for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) { 6872 for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) {
6878 if (chipset_revision_sensor[i].revision == checkword) { 6873 if (chipset_revision_sensor[i].revision == retword) {
6879 sd->chip_revision = checkword; 6874 sd->chip_revision = retword;
6880 send_unknown(dev, SENSOR_PB0330); 6875 send_unknown(dev, SENSOR_PB0330);
6881 return chipset_revision_sensor[i].internal_sensor_id; 6876 return chipset_revision_sensor[i].internal_sensor_id;
6882 } 6877 }
@@ -6888,8 +6883,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6888 reg_w(dev, 0x0a, 0x0010); 6883 reg_w(dev, 0x0a, 0x0010);
6889 reg_w(dev, 0x03, 0x0012); 6884 reg_w(dev, 0x03, 0x0012);
6890 reg_w(dev, 0x01, 0x0012); 6885 reg_w(dev, 0x01, 0x0012);
6891 retbyte = i2c_read(gspca_dev, 0x00); 6886 retword = i2c_read(gspca_dev, 0x00);
6892 if (retbyte != 0) { 6887 if (retword != 0) {
6893 PDEBUG(D_PROBE, "probe 3wr vga type 0a ?"); 6888 PDEBUG(D_PROBE, "probe 3wr vga type 0a ?");
6894 return 0x0a; /* ?? */ 6889 return 0x0a; /* ?? */
6895 } 6890 }
@@ -6901,14 +6896,14 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6901 reg_w(dev, 0x03, 0x0012); 6896 reg_w(dev, 0x03, 0x0012);
6902 msleep(2); 6897 msleep(2);
6903 reg_w(dev, 0x01, 0x0012); 6898 reg_w(dev, 0x01, 0x0012);
6904 retbyte = i2c_read(gspca_dev, 0x00); 6899 retword = i2c_read(gspca_dev, 0x00);
6905 if (retbyte != 0) { 6900 if (retword != 0) {
6906 PDEBUG(D_PROBE, "probe 3wr vga type %02x", retbyte); 6901 PDEBUG(D_PROBE, "probe 3wr vga type %02x", retword);
6907 if (retbyte == 0x11) /* VF0250 */ 6902 if (retword == 0x0011) /* VF0250 */
6908 return 0x0250; 6903 return 0x0250;
6909 if (retbyte == 0x29) /* gc0305 */ 6904 if (retword == 0x0029) /* gc0305 */
6910 send_unknown(dev, SENSOR_GC0305); 6905 send_unknown(dev, SENSOR_GC0305);
6911 return retbyte; 6906 return retword;
6912 } 6907 }
6913 6908
6914 reg_w(dev, 0x01, 0x0000); /* check OmniVision */ 6909 reg_w(dev, 0x01, 0x0000); /* check OmniVision */
@@ -6918,8 +6913,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6918 reg_w(dev, 0x06, 0x0010); 6913 reg_w(dev, 0x06, 0x0010);
6919 reg_w(dev, 0x01, 0x0012); 6914 reg_w(dev, 0x01, 0x0012);
6920 reg_w(dev, 0x05, 0x0012); 6915 reg_w(dev, 0x05, 0x0012);
6921 if (i2c_read(gspca_dev, 0x1c) == 0x7f /* OV7610 - manufacturer ID */ 6916 if (i2c_read(gspca_dev, 0x1c) == 0x007f /* OV7610 - manufacturer ID */
6922 && i2c_read(gspca_dev, 0x1d) == 0xa2) { 6917 && i2c_read(gspca_dev, 0x1d) == 0x00a2) {
6923 send_unknown(dev, SENSOR_OV7620); 6918 send_unknown(dev, SENSOR_OV7620);
6924 return 0x06; /* OmniVision confirm ? */ 6919 return 0x06; /* OmniVision confirm ? */
6925 } 6920 }
@@ -6933,16 +6928,14 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6933/* msleep(150); */ 6928/* msleep(150); */
6934 reg_w(dev, 0x01, 0x0012); 6929 reg_w(dev, 0x01, 0x0012);
6935 reg_w(dev, 0x05, 0x0012); 6930 reg_w(dev, 0x05, 0x0012);
6936 retbyte = i2c_read(gspca_dev, 0x0000); /* ID 0 */ 6931 retword = i2c_read(gspca_dev, 0x00) << 8; /* ID 0 */
6937 checkword = retbyte << 8; 6932 retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */
6938 retbyte = i2c_read(gspca_dev, 0x0001); /* ID 1 */ 6933 PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword);
6939 checkword |= retbyte; 6934 if (retword == 0x2030) {
6940 PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", checkword);
6941 if (checkword == 0x2030) {
6942 retbyte = i2c_read(gspca_dev, 0x02); /* revision number */ 6935 retbyte = i2c_read(gspca_dev, 0x02); /* revision number */
6943 PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte); 6936 PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte);
6944 send_unknown(dev, SENSOR_PO2030); 6937 send_unknown(dev, SENSOR_PO2030);
6945 return checkword; 6938 return retword;
6946 } 6939 }
6947 6940
6948 reg_w(dev, 0x01, 0x0000); 6941 reg_w(dev, 0x01, 0x0000);
@@ -6953,9 +6946,9 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6953 reg_w(dev, 0x01, 0x0012); 6946 reg_w(dev, 0x01, 0x0012);
6954 reg_w(dev, 0x05, 0x0001); 6947 reg_w(dev, 0x05, 0x0001);
6955 reg_w(dev, 0xd3, 0x008b); 6948 reg_w(dev, 0xd3, 0x008b);
6956 retbyte = i2c_read(gspca_dev, 0x01); 6949 retword = i2c_read(gspca_dev, 0x01);
6957 if (retbyte != 0) { 6950 if (retword != 0) {
6958 PDEBUG(D_PROBE, "probe 3wr vga type 0a ?"); 6951 PDEBUG(D_PROBE, "probe 3wr vga type 0a ? ret: %04x", retword);
6959 return 0x0a; /* ?? */ 6952 return 0x0a; /* ?? */
6960 } 6953 }
6961 return -1; 6954 return -1;