aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca
diff options
context:
space:
mode:
authorJean-François Moine <moinejf@free.fr>2010-08-04 04:44:13 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-08 22:43:01 -0400
commit6d31450544c75d99e1f4dbb21d5db6b2ca6ada4d (patch)
treebf045ae3ac0917b631c2b7c8476fee94f09bcc36 /drivers/media/video/gspca
parent83d1aa3d21ce50b9bc3b503ce2b1e7bb718709f1 (diff)
V4L/DVB: gspca - zc3xx: Check the USB exchanges
Signed-off-by: Jean-François Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r--drivers/media/video/gspca/zc3xx.c329
1 files changed, 171 insertions, 158 deletions
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index e184eb3b8c73..a9af568305ac 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -5841,13 +5841,22 @@ static const struct usb_action tas5130c_vf0250_NoFliker[] = {
5841static u8 reg_r_i(struct gspca_dev *gspca_dev, 5841static u8 reg_r_i(struct gspca_dev *gspca_dev,
5842 u16 index) 5842 u16 index)
5843{ 5843{
5844 usb_control_msg(gspca_dev->dev, 5844 int ret;
5845
5846 if (gspca_dev->usb_err < 0)
5847 return 0;
5848 ret = usb_control_msg(gspca_dev->dev,
5845 usb_rcvctrlpipe(gspca_dev->dev, 0), 5849 usb_rcvctrlpipe(gspca_dev->dev, 0),
5846 0xa1, 5850 0xa1,
5847 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 5851 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
5848 0x01, /* value */ 5852 0x01, /* value */
5849 index, gspca_dev->usb_buf, 1, 5853 index, gspca_dev->usb_buf, 1,
5850 500); 5854 500);
5855 if (ret < 0) {
5856 PDEBUG(D_ERR, "reg_r_i err %d", ret);
5857 gspca_dev->usb_err = ret;
5858 return 0;
5859 }
5851 return gspca_dev->usb_buf[0]; 5860 return gspca_dev->usb_buf[0];
5852} 5861}
5853 5862
@@ -5861,24 +5870,32 @@ static u8 reg_r(struct gspca_dev *gspca_dev,
5861 return ret; 5870 return ret;
5862} 5871}
5863 5872
5864static void reg_w_i(struct usb_device *dev, 5873static void reg_w_i(struct gspca_dev *gspca_dev,
5865 u8 value, 5874 u8 value,
5866 u16 index) 5875 u16 index)
5867{ 5876{
5868 usb_control_msg(dev, 5877 int ret;
5869 usb_sndctrlpipe(dev, 0), 5878
5879 if (gspca_dev->usb_err < 0)
5880 return;
5881 ret = usb_control_msg(gspca_dev->dev,
5882 usb_sndctrlpipe(gspca_dev->dev, 0),
5870 0xa0, 5883 0xa0,
5871 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 5884 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
5872 value, index, NULL, 0, 5885 value, index, NULL, 0,
5873 500); 5886 500);
5887 if (ret < 0) {
5888 PDEBUG(D_ERR, "reg_w_i err %d", ret);
5889 gspca_dev->usb_err = ret;
5890 }
5874} 5891}
5875 5892
5876static void reg_w(struct usb_device *dev, 5893static void reg_w(struct gspca_dev *gspca_dev,
5877 u8 value, 5894 u8 value,
5878 u16 index) 5895 u16 index)
5879{ 5896{
5880 PDEBUG(D_USBO, "reg w [%04x] = %02x", index, value); 5897 PDEBUG(D_USBO, "reg w [%04x] = %02x", index, value);
5881 reg_w_i(dev, value, index); 5898 reg_w_i(gspca_dev, value, index);
5882} 5899}
5883 5900
5884static u16 i2c_read(struct gspca_dev *gspca_dev, 5901static u16 i2c_read(struct gspca_dev *gspca_dev,
@@ -5887,8 +5904,10 @@ static u16 i2c_read(struct gspca_dev *gspca_dev,
5887 u8 retbyte; 5904 u8 retbyte;
5888 u16 retval; 5905 u16 retval;
5889 5906
5890 reg_w_i(gspca_dev->dev, reg, 0x0092); 5907 if (gspca_dev->usb_err < 0)
5891 reg_w_i(gspca_dev->dev, 0x02, 0x0090); /* <- read command */ 5908 return 0;
5909 reg_w_i(gspca_dev, reg, 0x0092);
5910 reg_w_i(gspca_dev, 0x02, 0x0090); /* <- read command */
5892 msleep(20); 5911 msleep(20);
5893 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */ 5912 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */
5894 if (retbyte != 0x00) 5913 if (retbyte != 0x00)
@@ -5907,10 +5926,12 @@ static u8 i2c_write(struct gspca_dev *gspca_dev,
5907{ 5926{
5908 u8 retbyte; 5927 u8 retbyte;
5909 5928
5910 reg_w_i(gspca_dev->dev, reg, 0x92); 5929 if (gspca_dev->usb_err < 0)
5911 reg_w_i(gspca_dev->dev, valL, 0x93); 5930 return 0;
5912 reg_w_i(gspca_dev->dev, valH, 0x94); 5931 reg_w_i(gspca_dev, reg, 0x92);
5913 reg_w_i(gspca_dev->dev, 0x01, 0x90); /* <- write command */ 5932 reg_w_i(gspca_dev, valL, 0x93);
5933 reg_w_i(gspca_dev, valH, 0x94);
5934 reg_w_i(gspca_dev, 0x01, 0x90); /* <- write command */
5914 msleep(1); 5935 msleep(1);
5915 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */ 5936 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */
5916 if (retbyte != 0x00) 5937 if (retbyte != 0x00)
@@ -5926,7 +5947,7 @@ static void usb_exchange(struct gspca_dev *gspca_dev,
5926 while (action->req) { 5947 while (action->req) {
5927 switch (action->req) { 5948 switch (action->req) {
5928 case 0xa0: /* write register */ 5949 case 0xa0: /* write register */
5929 reg_w(gspca_dev->dev, action->val, action->idx); 5950 reg_w(gspca_dev, action->val, action->idx);
5930 break; 5951 break;
5931 case 0xa1: /* read status */ 5952 case 0xa1: /* read status */
5932 reg_r(gspca_dev, action->idx); 5953 reg_r(gspca_dev, action->idx);
@@ -6000,13 +6021,12 @@ static void setmatrix(struct gspca_dev *gspca_dev)
6000 if (matrix == NULL) 6021 if (matrix == NULL)
6001 return; /* matrix already loaded */ 6022 return; /* matrix already loaded */
6002 for (i = 0; i < ARRAY_SIZE(ov7620_matrix); i++) 6023 for (i = 0; i < ARRAY_SIZE(ov7620_matrix); i++)
6003 reg_w(gspca_dev->dev, matrix[i], 0x010a + i); 6024 reg_w(gspca_dev, matrix[i], 0x010a + i);
6004} 6025}
6005 6026
6006static void setsharpness(struct gspca_dev *gspca_dev) 6027static void setsharpness(struct gspca_dev *gspca_dev)
6007{ 6028{
6008 struct sd *sd = (struct sd *) gspca_dev; 6029 struct sd *sd = (struct sd *) gspca_dev;
6009 struct usb_device *dev = gspca_dev->dev;
6010 int sharpness; 6030 int sharpness;
6011 static const u8 sharpness_tb[][2] = { 6031 static const u8 sharpness_tb[][2] = {
6012 {0x02, 0x03}, 6032 {0x02, 0x03},
@@ -6016,17 +6036,16 @@ static void setsharpness(struct gspca_dev *gspca_dev)
6016 }; 6036 };
6017 6037
6018 sharpness = sd->sharpness; 6038 sharpness = sd->sharpness;
6019 reg_w(dev, sharpness_tb[sharpness][0], 0x01c6); 6039 reg_w(gspca_dev, sharpness_tb[sharpness][0], 0x01c6);
6020 reg_r(gspca_dev, 0x01c8); 6040 reg_r(gspca_dev, 0x01c8);
6021 reg_r(gspca_dev, 0x01c9); 6041 reg_r(gspca_dev, 0x01c9);
6022 reg_r(gspca_dev, 0x01ca); 6042 reg_r(gspca_dev, 0x01ca);
6023 reg_w(dev, sharpness_tb[sharpness][1], 0x01cb); 6043 reg_w(gspca_dev, sharpness_tb[sharpness][1], 0x01cb);
6024} 6044}
6025 6045
6026static void setcontrast(struct gspca_dev *gspca_dev) 6046static void setcontrast(struct gspca_dev *gspca_dev)
6027{ 6047{
6028 struct sd *sd = (struct sd *) gspca_dev; 6048 struct sd *sd = (struct sd *) gspca_dev;
6029 struct usb_device *dev = gspca_dev->dev;
6030 const u8 *Tgamma; 6049 const u8 *Tgamma;
6031 int g, i, brightness, contrast, adj, gp1, gp2; 6050 int g, i, brightness, contrast, adj, gp1, gp2;
6032 u8 gr[16]; 6051 u8 gr[16];
@@ -6064,7 +6083,7 @@ static void setcontrast(struct gspca_dev *gspca_dev)
6064 g = 0xff; 6083 g = 0xff;
6065 else if (g < 0) 6084 else if (g < 0)
6066 g = 0; 6085 g = 0;
6067 reg_w(dev, g, 0x0120 + i); /* gamma */ 6086 reg_w(gspca_dev, g, 0x0120 + i); /* gamma */
6068 if (contrast > 0) 6087 if (contrast > 0)
6069 adj--; 6088 adj--;
6070 else if (contrast < 0) 6089 else if (contrast < 0)
@@ -6078,13 +6097,12 @@ static void setcontrast(struct gspca_dev *gspca_dev)
6078 } 6097 }
6079 gr[15] = (0xff - gp2) / 2; 6098 gr[15] = (0xff - gp2) / 2;
6080 for (i = 0; i < 16; i++) 6099 for (i = 0; i < 16; i++)
6081 reg_w(dev, gr[i], 0x0130 + i); /* gradient */ 6100 reg_w(gspca_dev, gr[i], 0x0130 + i); /* gradient */
6082} 6101}
6083 6102
6084static void setquality(struct gspca_dev *gspca_dev) 6103static void setquality(struct gspca_dev *gspca_dev)
6085{ 6104{
6086 struct sd *sd = (struct sd *) gspca_dev; 6105 struct sd *sd = (struct sd *) gspca_dev;
6087 struct usb_device *dev = gspca_dev->dev;
6088 u8 frxt; 6106 u8 frxt;
6089 6107
6090 switch (sd->sensor) { 6108 switch (sd->sensor) {
@@ -6097,9 +6115,9 @@ static void setquality(struct gspca_dev *gspca_dev)
6097 return; 6115 return;
6098 } 6116 }
6099/*fixme: is it really 0008 0007 0018 for all other sensors? */ 6117/*fixme: is it really 0008 0007 0018 for all other sensors? */
6100 reg_w(dev, QUANT_VAL, 0x0008); 6118 reg_w(gspca_dev, QUANT_VAL, 0x0008);
6101 frxt = 0x30; 6119 frxt = 0x30;
6102 reg_w(dev, frxt, 0x0007); 6120 reg_w(gspca_dev, frxt, 0x0007);
6103#if QUANT_VAL == 0 || QUANT_VAL == 1 || QUANT_VAL == 2 6121#if QUANT_VAL == 0 || QUANT_VAL == 1 || QUANT_VAL == 2
6104 frxt = 0xff; 6122 frxt = 0xff;
6105#elif QUANT_VAL == 3 6123#elif QUANT_VAL == 3
@@ -6109,7 +6127,7 @@ static void setquality(struct gspca_dev *gspca_dev)
6109#else 6127#else
6110 frxt = 0x20; 6128 frxt = 0x20;
6111#endif 6129#endif
6112 reg_w(dev, frxt, 0x0018); 6130 reg_w(gspca_dev, frxt, 0x0018);
6113} 6131}
6114 6132
6115/* Matches the sensor's internal frame rate to the lighting frequency. 6133/* Matches the sensor's internal frame rate to the lighting frequency.
@@ -6117,9 +6135,8 @@ static void setquality(struct gspca_dev *gspca_dev)
6117 * 50Hz, for European and Asian lighting (default) 6135 * 50Hz, for European and Asian lighting (default)
6118 * 60Hz, for American lighting 6136 * 60Hz, for American lighting
6119 * 0 = No Fliker (for outdoore usage) 6137 * 0 = No Fliker (for outdoore usage)
6120 * Returns: 0 for success
6121 */ 6138 */
6122static int setlightfreq(struct gspca_dev *gspca_dev) 6139static void setlightfreq(struct gspca_dev *gspca_dev)
6123{ 6140{
6124 struct sd *sd = (struct sd *) gspca_dev; 6141 struct sd *sd = (struct sd *) gspca_dev;
6125 int i, mode; 6142 int i, mode;
@@ -6209,28 +6226,27 @@ static int setlightfreq(struct gspca_dev *gspca_dev)
6209 i++; /* 320x240 */ 6226 i++; /* 320x240 */
6210 zc3_freq = freq_tb[sd->sensor][i]; 6227 zc3_freq = freq_tb[sd->sensor][i];
6211 if (zc3_freq == NULL) 6228 if (zc3_freq == NULL)
6212 return 0; 6229 return;
6213 usb_exchange(gspca_dev, zc3_freq); 6230 usb_exchange(gspca_dev, zc3_freq);
6214 switch (sd->sensor) { 6231 switch (sd->sensor) {
6215 case SENSOR_GC0305: 6232 case SENSOR_GC0305:
6216 if (mode /* if 320x240 */ 6233 if (mode /* if 320x240 */
6217 && sd->lightfreq == 1) /* and 50Hz */ 6234 && sd->lightfreq == 1) /* and 50Hz */
6218 reg_w(gspca_dev->dev, 0x85, 0x018d); 6235 reg_w(gspca_dev, 0x85, 0x018d);
6219 /* win: 0x80, 0x018d */ 6236 /* win: 0x80, 0x018d */
6220 break; 6237 break;
6221 case SENSOR_OV7620: 6238 case SENSOR_OV7620:
6222 if (!mode) { /* if 640x480 */ 6239 if (!mode) { /* if 640x480 */
6223 if (sd->lightfreq != 0) /* and 50 or 60 Hz */ 6240 if (sd->lightfreq != 0) /* and 50 or 60 Hz */
6224 reg_w(gspca_dev->dev, 0x40, 0x0002); 6241 reg_w(gspca_dev, 0x40, 0x0002);
6225 else 6242 else
6226 reg_w(gspca_dev->dev, 0x44, 0x0002); 6243 reg_w(gspca_dev, 0x44, 0x0002);
6227 } 6244 }
6228 break; 6245 break;
6229 case SENSOR_PAS202B: 6246 case SENSOR_PAS202B:
6230 reg_w(gspca_dev->dev, 0x00, 0x01a7); 6247 reg_w(gspca_dev, 0x00, 0x01a7);
6231 break; 6248 break;
6232 } 6249 }
6233 return 0;
6234} 6250}
6235 6251
6236static void setautogain(struct gspca_dev *gspca_dev) 6252static void setautogain(struct gspca_dev *gspca_dev)
@@ -6242,17 +6258,17 @@ static void setautogain(struct gspca_dev *gspca_dev)
6242 autoval = 0x42; 6258 autoval = 0x42;
6243 else 6259 else
6244 autoval = 0x02; 6260 autoval = 0x02;
6245 reg_w(gspca_dev->dev, autoval, 0x0180); 6261 reg_w(gspca_dev, autoval, 0x0180);
6246} 6262}
6247 6263
6248static void send_unknown(struct usb_device *dev, int sensor) 6264static void send_unknown(struct gspca_dev *gspca_dev, int sensor)
6249{ 6265{
6250 reg_w(dev, 0x01, 0x0000); /* led off */ 6266 reg_w(gspca_dev, 0x01, 0x0000); /* led off */
6251 switch (sensor) { 6267 switch (sensor) {
6252 case SENSOR_PAS106: 6268 case SENSOR_PAS106:
6253 reg_w(dev, 0x03, 0x003a); 6269 reg_w(gspca_dev, 0x03, 0x003a);
6254 reg_w(dev, 0x0c, 0x003b); 6270 reg_w(gspca_dev, 0x0c, 0x003b);
6255 reg_w(dev, 0x08, 0x0038); 6271 reg_w(gspca_dev, 0x08, 0x0038);
6256 break; 6272 break;
6257 case SENSOR_ADCM2700: 6273 case SENSOR_ADCM2700:
6258 case SENSOR_GC0305: 6274 case SENSOR_GC0305:
@@ -6260,27 +6276,27 @@ static void send_unknown(struct usb_device *dev, int sensor)
6260 case SENSOR_MI0360SOC: 6276 case SENSOR_MI0360SOC:
6261 case SENSOR_PB0330: 6277 case SENSOR_PB0330:
6262 case SENSOR_PO2030: 6278 case SENSOR_PO2030:
6263 reg_w(dev, 0x0d, 0x003a); 6279 reg_w(gspca_dev, 0x0d, 0x003a);
6264 reg_w(dev, 0x02, 0x003b); 6280 reg_w(gspca_dev, 0x02, 0x003b);
6265 reg_w(dev, 0x00, 0x0038); 6281 reg_w(gspca_dev, 0x00, 0x0038);
6266 break; 6282 break;
6267 case SENSOR_PAS202B: 6283 case SENSOR_PAS202B:
6268 reg_w(dev, 0x03, 0x003b); 6284 reg_w(gspca_dev, 0x03, 0x003b);
6269 reg_w(dev, 0x0c, 0x003a); 6285 reg_w(gspca_dev, 0x0c, 0x003a);
6270 reg_w(dev, 0x0b, 0x0039); 6286 reg_w(gspca_dev, 0x0b, 0x0039);
6271 reg_w(dev, 0x0b, 0x0038); 6287 reg_w(gspca_dev, 0x0b, 0x0038);
6272 break; 6288 break;
6273 } 6289 }
6274} 6290}
6275 6291
6276/* start probe 2 wires */ 6292/* start probe 2 wires */
6277static void start_2wr_probe(struct usb_device *dev, int sensor) 6293static void start_2wr_probe(struct gspca_dev *gspca_dev, int sensor)
6278{ 6294{
6279 reg_w(dev, 0x01, 0x0000); 6295 reg_w(gspca_dev, 0x01, 0x0000);
6280 reg_w(dev, sensor, 0x0010); 6296 reg_w(gspca_dev, sensor, 0x0010);
6281 reg_w(dev, 0x01, 0x0001); 6297 reg_w(gspca_dev, 0x01, 0x0001);
6282 reg_w(dev, 0x03, 0x0012); 6298 reg_w(gspca_dev, 0x03, 0x0012);
6283 reg_w(dev, 0x01, 0x0012); 6299 reg_w(gspca_dev, 0x01, 0x0012);
6284/* msleep(2); */ 6300/* msleep(2); */
6285} 6301}
6286 6302
@@ -6288,14 +6304,14 @@ static int sif_probe(struct gspca_dev *gspca_dev)
6288{ 6304{
6289 u16 checkword; 6305 u16 checkword;
6290 6306
6291 start_2wr_probe(gspca_dev->dev, 0x0f); /* PAS106 */ 6307 start_2wr_probe(gspca_dev, 0x0f); /* PAS106 */
6292 reg_w(gspca_dev->dev, 0x08, 0x008d); 6308 reg_w(gspca_dev, 0x08, 0x008d);
6293 msleep(150); 6309 msleep(150);
6294 checkword = ((i2c_read(gspca_dev, 0x00) & 0x0f) << 4) 6310 checkword = ((i2c_read(gspca_dev, 0x00) & 0x0f) << 4)
6295 | ((i2c_read(gspca_dev, 0x01) & 0xf0) >> 4); 6311 | ((i2c_read(gspca_dev, 0x01) & 0xf0) >> 4);
6296 PDEBUG(D_PROBE, "probe sif 0x%04x", checkword); 6312 PDEBUG(D_PROBE, "probe sif 0x%04x", checkword);
6297 if (checkword == 0x0007) { 6313 if (checkword == 0x0007) {
6298 send_unknown(gspca_dev->dev, SENSOR_PAS106); 6314 send_unknown(gspca_dev, SENSOR_PAS106);
6299 return 0x0f; /* PAS106 */ 6315 return 0x0f; /* PAS106 */
6300 } 6316 }
6301 return -1; 6317 return -1;
@@ -6303,23 +6319,22 @@ static int sif_probe(struct gspca_dev *gspca_dev)
6303 6319
6304static int vga_2wr_probe(struct gspca_dev *gspca_dev) 6320static int vga_2wr_probe(struct gspca_dev *gspca_dev)
6305{ 6321{
6306 struct usb_device *dev = gspca_dev->dev;
6307 u16 retword; 6322 u16 retword;
6308 6323
6309 start_2wr_probe(dev, 0x00); /* HV7131B */ 6324 start_2wr_probe(gspca_dev, 0x00); /* HV7131B */
6310 i2c_write(gspca_dev, 0x01, 0xaa, 0x00); 6325 i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
6311 retword = i2c_read(gspca_dev, 0x01); 6326 retword = i2c_read(gspca_dev, 0x01);
6312 if (retword != 0) 6327 if (retword != 0)
6313 return 0x00; /* HV7131B */ 6328 return 0x00; /* HV7131B */
6314 6329
6315 start_2wr_probe(dev, 0x04); /* CS2102 */ 6330 start_2wr_probe(gspca_dev, 0x04); /* CS2102 */
6316 i2c_write(gspca_dev, 0x01, 0xaa, 0x00); 6331 i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
6317 retword = i2c_read(gspca_dev, 0x01); 6332 retword = i2c_read(gspca_dev, 0x01);
6318 if (retword != 0) 6333 if (retword != 0)
6319 return 0x04; /* CS2102 */ 6334 return 0x04; /* CS2102 */
6320 6335
6321 start_2wr_probe(dev, 0x06); /* OmniVision */ 6336 start_2wr_probe(gspca_dev, 0x06); /* OmniVision */
6322 reg_w(dev, 0x08, 0x008d); 6337 reg_w(gspca_dev, 0x08, 0x008d);
6323 i2c_write(gspca_dev, 0x11, 0xaa, 0x00); 6338 i2c_write(gspca_dev, 0x11, 0xaa, 0x00);
6324 retword = i2c_read(gspca_dev, 0x11); 6339 retword = i2c_read(gspca_dev, 0x11);
6325 if (retword != 0) { 6340 if (retword != 0) {
@@ -6328,14 +6343,14 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
6328 goto ov_check; 6343 goto ov_check;
6329 } 6344 }
6330 6345
6331 start_2wr_probe(dev, 0x08); /* HDCS2020 */ 6346 start_2wr_probe(gspca_dev, 0x08); /* HDCS2020 */
6332 i2c_write(gspca_dev, 0x1c, 0x00, 0x00); 6347 i2c_write(gspca_dev, 0x1c, 0x00, 0x00);
6333 i2c_write(gspca_dev, 0x15, 0xaa, 0x00); 6348 i2c_write(gspca_dev, 0x15, 0xaa, 0x00);
6334 retword = i2c_read(gspca_dev, 0x15); 6349 retword = i2c_read(gspca_dev, 0x15);
6335 if (retword != 0) 6350 if (retword != 0)
6336 return 0x08; /* HDCS2020 */ 6351 return 0x08; /* HDCS2020 */
6337 6352
6338 start_2wr_probe(dev, 0x0a); /* PB0330 */ 6353 start_2wr_probe(gspca_dev, 0x0a); /* PB0330 */
6339 i2c_write(gspca_dev, 0x07, 0xaa, 0xaa); 6354 i2c_write(gspca_dev, 0x07, 0xaa, 0xaa);
6340 retword = i2c_read(gspca_dev, 0x07); 6355 retword = i2c_read(gspca_dev, 0x07);
6341 if (retword != 0) 6356 if (retword != 0)
@@ -6347,23 +6362,23 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
6347 if (retword != 0) 6362 if (retword != 0)
6348 return 0x0a; /* PB0330 ?? */ 6363 return 0x0a; /* PB0330 ?? */
6349 6364
6350 start_2wr_probe(dev, 0x0c); /* ICM105A */ 6365 start_2wr_probe(gspca_dev, 0x0c); /* ICM105A */
6351 i2c_write(gspca_dev, 0x01, 0x11, 0x00); 6366 i2c_write(gspca_dev, 0x01, 0x11, 0x00);
6352 retword = i2c_read(gspca_dev, 0x01); 6367 retword = i2c_read(gspca_dev, 0x01);
6353 if (retword != 0) 6368 if (retword != 0)
6354 return 0x0c; /* ICM105A */ 6369 return 0x0c; /* ICM105A */
6355 6370
6356 start_2wr_probe(dev, 0x0e); /* PAS202BCB */ 6371 start_2wr_probe(gspca_dev, 0x0e); /* PAS202BCB */
6357 reg_w(dev, 0x08, 0x008d); 6372 reg_w(gspca_dev, 0x08, 0x008d);
6358 i2c_write(gspca_dev, 0x03, 0xaa, 0x00); 6373 i2c_write(gspca_dev, 0x03, 0xaa, 0x00);
6359 msleep(50); 6374 msleep(50);
6360 retword = i2c_read(gspca_dev, 0x03); 6375 retword = i2c_read(gspca_dev, 0x03);
6361 if (retword != 0) { 6376 if (retword != 0) {
6362 send_unknown(dev, SENSOR_PAS202B); 6377 send_unknown(gspca_dev, SENSOR_PAS202B);
6363 return 0x0e; /* PAS202BCB */ 6378 return 0x0e; /* PAS202BCB */
6364 } 6379 }
6365 6380
6366 start_2wr_probe(dev, 0x02); /* TAS5130C */ 6381 start_2wr_probe(gspca_dev, 0x02); /* TAS5130C */
6367 i2c_write(gspca_dev, 0x01, 0xaa, 0x00); 6382 i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
6368 retword = i2c_read(gspca_dev, 0x01); 6383 retword = i2c_read(gspca_dev, 0x01);
6369 if (retword != 0) 6384 if (retword != 0)
@@ -6372,20 +6387,20 @@ ov_check:
6372 reg_r(gspca_dev, 0x0010); /* ?? */ 6387 reg_r(gspca_dev, 0x0010); /* ?? */
6373 reg_r(gspca_dev, 0x0010); 6388 reg_r(gspca_dev, 0x0010);
6374 6389
6375 reg_w(dev, 0x01, 0x0000); 6390 reg_w(gspca_dev, 0x01, 0x0000);
6376 reg_w(dev, 0x01, 0x0001); 6391 reg_w(gspca_dev, 0x01, 0x0001);
6377 reg_w(dev, 0x06, 0x0010); /* OmniVision */ 6392 reg_w(gspca_dev, 0x06, 0x0010); /* OmniVision */
6378 reg_w(dev, 0xa1, 0x008b); 6393 reg_w(gspca_dev, 0xa1, 0x008b);
6379 reg_w(dev, 0x08, 0x008d); 6394 reg_w(gspca_dev, 0x08, 0x008d);
6380 msleep(500); 6395 msleep(500);
6381 reg_w(dev, 0x01, 0x0012); 6396 reg_w(gspca_dev, 0x01, 0x0012);
6382 i2c_write(gspca_dev, 0x12, 0x80, 0x00); /* sensor reset */ 6397 i2c_write(gspca_dev, 0x12, 0x80, 0x00); /* sensor reset */
6383 retword = i2c_read(gspca_dev, 0x0a) << 8; 6398 retword = i2c_read(gspca_dev, 0x0a) << 8;
6384 retword |= i2c_read(gspca_dev, 0x0b); 6399 retword |= i2c_read(gspca_dev, 0x0b);
6385 PDEBUG(D_PROBE, "probe 2wr ov vga 0x%04x", retword); 6400 PDEBUG(D_PROBE, "probe 2wr ov vga 0x%04x", retword);
6386 switch (retword) { 6401 switch (retword) {
6387 case 0x7631: /* OV7630C */ 6402 case 0x7631: /* OV7630C */
6388 reg_w(dev, 0x06, 0x0010); 6403 reg_w(gspca_dev, 0x06, 0x0010);
6389 break; 6404 break;
6390 case 0x7620: /* OV7620 */ 6405 case 0x7620: /* OV7620 */
6391 case 0x7648: /* OV7648 */ 6406 case 0x7648: /* OV7648 */
@@ -6413,21 +6428,20 @@ static const struct sensor_by_chipset_revision chipset_revision_sensor[] = {
6413static int vga_3wr_probe(struct gspca_dev *gspca_dev) 6428static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6414{ 6429{
6415 struct sd *sd = (struct sd *) gspca_dev; 6430 struct sd *sd = (struct sd *) gspca_dev;
6416 struct usb_device *dev = gspca_dev->dev;
6417 int i; 6431 int i;
6418 u8 retbyte; 6432 u8 retbyte;
6419 u16 retword; 6433 u16 retword;
6420 6434
6421/*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/ 6435/*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/
6422 reg_w(dev, 0x02, 0x0010); 6436 reg_w(gspca_dev, 0x02, 0x0010);
6423 reg_r(gspca_dev, 0x0010); 6437 reg_r(gspca_dev, 0x0010);
6424 reg_w(dev, 0x01, 0x0000); 6438 reg_w(gspca_dev, 0x01, 0x0000);
6425 reg_w(dev, 0x00, 0x0010); 6439 reg_w(gspca_dev, 0x00, 0x0010);
6426 reg_w(dev, 0x01, 0x0001); 6440 reg_w(gspca_dev, 0x01, 0x0001);
6427 reg_w(dev, 0x91, 0x008b); 6441 reg_w(gspca_dev, 0x91, 0x008b);
6428 reg_w(dev, 0x03, 0x0012); 6442 reg_w(gspca_dev, 0x03, 0x0012);
6429 reg_w(dev, 0x01, 0x0012); 6443 reg_w(gspca_dev, 0x01, 0x0012);
6430 reg_w(dev, 0x05, 0x0012); 6444 reg_w(gspca_dev, 0x05, 0x0012);
6431 retword = i2c_read(gspca_dev, 0x14); 6445 retword = i2c_read(gspca_dev, 0x14);
6432 if (retword != 0) 6446 if (retword != 0)
6433 return 0x11; /* HV7131R */ 6447 return 0x11; /* HV7131R */
@@ -6438,7 +6452,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6438 if (retword != 0) 6452 if (retword != 0)
6439 return 0x11; /* HV7131R */ 6453 return 0x11; /* HV7131R */
6440 6454
6441 reg_w(dev, 0x02, 0x0010); 6455 reg_w(gspca_dev, 0x02, 0x0010);
6442 retword = reg_r(gspca_dev, 0x000b) << 8; 6456 retword = reg_r(gspca_dev, 0x000b) << 8;
6443 retword |= reg_r(gspca_dev, 0x000a); 6457 retword |= reg_r(gspca_dev, 0x000a);
6444 PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", retword); 6458 PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", retword);
@@ -6448,80 +6462,80 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6448 for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) { 6462 for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) {
6449 if (chipset_revision_sensor[i].revision == retword) { 6463 if (chipset_revision_sensor[i].revision == retword) {
6450 sd->chip_revision = retword; 6464 sd->chip_revision = retword;
6451 send_unknown(dev, SENSOR_PB0330); 6465 send_unknown(gspca_dev, SENSOR_PB0330);
6452 return chipset_revision_sensor[i] 6466 return chipset_revision_sensor[i]
6453 .internal_sensor_id; 6467 .internal_sensor_id;
6454 } 6468 }
6455 } 6469 }
6456 6470
6457 reg_w(dev, 0x01, 0x0000); /* check PB0330 */ 6471 reg_w(gspca_dev, 0x01, 0x0000); /* check PB0330 */
6458 reg_w(dev, 0x01, 0x0001); 6472 reg_w(gspca_dev, 0x01, 0x0001);
6459 reg_w(dev, 0xdd, 0x008b); 6473 reg_w(gspca_dev, 0xdd, 0x008b);
6460 reg_w(dev, 0x0a, 0x0010); 6474 reg_w(gspca_dev, 0x0a, 0x0010);
6461 reg_w(dev, 0x03, 0x0012); 6475 reg_w(gspca_dev, 0x03, 0x0012);
6462 reg_w(dev, 0x01, 0x0012); 6476 reg_w(gspca_dev, 0x01, 0x0012);
6463 retword = i2c_read(gspca_dev, 0x00); 6477 retword = i2c_read(gspca_dev, 0x00);
6464 if (retword != 0) { 6478 if (retword != 0) {
6465 PDEBUG(D_PROBE, "probe 3wr vga type 0a"); 6479 PDEBUG(D_PROBE, "probe 3wr vga type 0a");
6466 return 0x0a; /* PB0330 */ 6480 return 0x0a; /* PB0330 */
6467 } 6481 }
6468 6482
6469 reg_w(dev, 0x01, 0x0000); 6483 reg_w(gspca_dev, 0x01, 0x0000);
6470 reg_w(dev, 0x01, 0x0001); 6484 reg_w(gspca_dev, 0x01, 0x0001);
6471 reg_w(dev, 0x98, 0x008b); 6485 reg_w(gspca_dev, 0x98, 0x008b);
6472 reg_w(dev, 0x01, 0x0010); 6486 reg_w(gspca_dev, 0x01, 0x0010);
6473 reg_w(dev, 0x03, 0x0012); 6487 reg_w(gspca_dev, 0x03, 0x0012);
6474 msleep(2); 6488 msleep(2);
6475 reg_w(dev, 0x01, 0x0012); 6489 reg_w(gspca_dev, 0x01, 0x0012);
6476 retword = i2c_read(gspca_dev, 0x00); 6490 retword = i2c_read(gspca_dev, 0x00);
6477 if (retword != 0) { 6491 if (retword != 0) {
6478 PDEBUG(D_PROBE, "probe 3wr vga type %02x", retword); 6492 PDEBUG(D_PROBE, "probe 3wr vga type %02x", retword);
6479 if (retword == 0x0011) /* VF0250 */ 6493 if (retword == 0x0011) /* VF0250 */
6480 return 0x0250; 6494 return 0x0250;
6481 if (retword == 0x0029) /* gc0305 */ 6495 if (retword == 0x0029) /* gc0305 */
6482 send_unknown(dev, SENSOR_GC0305); 6496 send_unknown(gspca_dev, SENSOR_GC0305);
6483 return retword; 6497 return retword;
6484 } 6498 }
6485 6499
6486 reg_w(dev, 0x01, 0x0000); /* check OmniVision */ 6500 reg_w(gspca_dev, 0x01, 0x0000); /* check OmniVision */
6487 reg_w(dev, 0x01, 0x0001); 6501 reg_w(gspca_dev, 0x01, 0x0001);
6488 reg_w(dev, 0xa1, 0x008b); 6502 reg_w(gspca_dev, 0xa1, 0x008b);
6489 reg_w(dev, 0x08, 0x008d); 6503 reg_w(gspca_dev, 0x08, 0x008d);
6490 reg_w(dev, 0x06, 0x0010); 6504 reg_w(gspca_dev, 0x06, 0x0010);
6491 reg_w(dev, 0x01, 0x0012); 6505 reg_w(gspca_dev, 0x01, 0x0012);
6492 reg_w(dev, 0x05, 0x0012); 6506 reg_w(gspca_dev, 0x05, 0x0012);
6493 if (i2c_read(gspca_dev, 0x1c) == 0x007f /* OV7610 - manufacturer ID */ 6507 if (i2c_read(gspca_dev, 0x1c) == 0x007f /* OV7610 - manufacturer ID */
6494 && i2c_read(gspca_dev, 0x1d) == 0x00a2) { 6508 && i2c_read(gspca_dev, 0x1d) == 0x00a2) {
6495 send_unknown(dev, SENSOR_OV7620); 6509 send_unknown(gspca_dev, SENSOR_OV7620);
6496 return 0x06; /* OmniVision confirm ? */ 6510 return 0x06; /* OmniVision confirm ? */
6497 } 6511 }
6498 6512
6499 reg_w(dev, 0x01, 0x0000); 6513 reg_w(gspca_dev, 0x01, 0x0000);
6500 reg_w(dev, 0x00, 0x0002); 6514 reg_w(gspca_dev, 0x00, 0x0002);
6501 reg_w(dev, 0x01, 0x0010); 6515 reg_w(gspca_dev, 0x01, 0x0010);
6502 reg_w(dev, 0x01, 0x0001); 6516 reg_w(gspca_dev, 0x01, 0x0001);
6503 reg_w(dev, 0xee, 0x008b); 6517 reg_w(gspca_dev, 0xee, 0x008b);
6504 reg_w(dev, 0x03, 0x0012); 6518 reg_w(gspca_dev, 0x03, 0x0012);
6505 reg_w(dev, 0x01, 0x0012); 6519 reg_w(gspca_dev, 0x01, 0x0012);
6506 reg_w(dev, 0x05, 0x0012); 6520 reg_w(gspca_dev, 0x05, 0x0012);
6507 retword = i2c_read(gspca_dev, 0x00) << 8; /* ID 0 */ 6521 retword = i2c_read(gspca_dev, 0x00) << 8; /* ID 0 */
6508 retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */ 6522 retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */
6509 PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword); 6523 PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword);
6510 if (retword == 0x2030) { 6524 if (retword == 0x2030) {
6511 retbyte = i2c_read(gspca_dev, 0x02); /* revision number */ 6525 retbyte = i2c_read(gspca_dev, 0x02); /* revision number */
6512 PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte); 6526 PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte);
6513 send_unknown(dev, SENSOR_PO2030); 6527 send_unknown(gspca_dev, SENSOR_PO2030);
6514 return retword; 6528 return retword;
6515 } 6529 }
6516 6530
6517 reg_w(dev, 0x01, 0x0000); 6531 reg_w(gspca_dev, 0x01, 0x0000);
6518 reg_w(dev, 0x0a, 0x0010); 6532 reg_w(gspca_dev, 0x0a, 0x0010);
6519 reg_w(dev, 0xd3, 0x008b); 6533 reg_w(gspca_dev, 0xd3, 0x008b);
6520 reg_w(dev, 0x01, 0x0001); 6534 reg_w(gspca_dev, 0x01, 0x0001);
6521 reg_w(dev, 0x03, 0x0012); 6535 reg_w(gspca_dev, 0x03, 0x0012);
6522 reg_w(dev, 0x01, 0x0012); 6536 reg_w(gspca_dev, 0x01, 0x0012);
6523 reg_w(dev, 0x05, 0x0012); 6537 reg_w(gspca_dev, 0x05, 0x0012);
6524 reg_w(dev, 0xd3, 0x008b); 6538 reg_w(gspca_dev, 0xd3, 0x008b);
6525 retword = i2c_read(gspca_dev, 0x01); 6539 retword = i2c_read(gspca_dev, 0x01);
6526 if (retword != 0) { 6540 if (retword != 0) {
6527 PDEBUG(D_PROBE, "probe 3wr vga type 0a ? ret: %04x", retword); 6541 PDEBUG(D_PROBE, "probe 3wr vga type 0a ? ret: %04x", retword);
@@ -6739,7 +6753,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
6739 } 6753 }
6740 if (sensor < 0x20) { 6754 if (sensor < 0x20) {
6741 if (sensor == -1 || sensor == 0x10 || sensor == 0x12) 6755 if (sensor == -1 || sensor == 0x10 || sensor == 0x12)
6742 reg_w(gspca_dev->dev, 0x02, 0x0010); 6756 reg_w(gspca_dev, 0x02, 0x0010);
6743 reg_r(gspca_dev, 0x0010); 6757 reg_r(gspca_dev, 0x0010);
6744 } 6758 }
6745 6759
@@ -6776,21 +6790,20 @@ static int sd_config(struct gspca_dev *gspca_dev,
6776 break; 6790 break;
6777 } 6791 }
6778 6792
6779 return 0; 6793 return gspca_dev->usb_err;
6780} 6794}
6781 6795
6782/* this function is called at probe and resume time */ 6796/* this function is called at probe and resume time */
6783static int sd_init(struct gspca_dev *gspca_dev) 6797static int sd_init(struct gspca_dev *gspca_dev)
6784{ 6798{
6785 /* switch off the led */ 6799 /* switch off the led */
6786 reg_w(gspca_dev->dev, 0x01, 0x0000); 6800 reg_w(gspca_dev, 0x01, 0x0000);
6787 return 0; 6801 return 0;
6788} 6802}
6789 6803
6790static int sd_start(struct gspca_dev *gspca_dev) 6804static int sd_start(struct gspca_dev *gspca_dev)
6791{ 6805{
6792 struct sd *sd = (struct sd *) gspca_dev; 6806 struct sd *sd = (struct sd *) gspca_dev;
6793 struct usb_device *dev = gspca_dev->dev;
6794 int mode; 6807 int mode;
6795 static const struct usb_action *init_tb[SENSOR_MAX][2] = { 6808 static const struct usb_action *init_tb[SENSOR_MAX][2] = {
6796 [SENSOR_ADCM2700] = 6809 [SENSOR_ADCM2700] =
@@ -6858,18 +6871,18 @@ static int sd_start(struct gspca_dev *gspca_dev)
6858 case SENSOR_TAS5130C_VF0250: 6871 case SENSOR_TAS5130C_VF0250:
6859/* msleep(100); * ?? */ 6872/* msleep(100); * ?? */
6860 reg_r(gspca_dev, 0x0002); /* --> 0x40 */ 6873 reg_r(gspca_dev, 0x0002); /* --> 0x40 */
6861 reg_w(dev, 0x09, 0x01ad); /* (from win traces) */ 6874 reg_w(gspca_dev, 0x09, 0x01ad); /* (from win traces) */
6862 reg_w(dev, 0x15, 0x01ae); 6875 reg_w(gspca_dev, 0x15, 0x01ae);
6863 if (sd->sensor == SENSOR_TAS5130C) 6876 if (sd->sensor == SENSOR_TAS5130C)
6864 break; 6877 break;
6865 reg_w(dev, 0x0d, 0x003a); 6878 reg_w(gspca_dev, 0x0d, 0x003a);
6866 reg_w(dev, 0x02, 0x003b); 6879 reg_w(gspca_dev, 0x02, 0x003b);
6867 reg_w(dev, 0x00, 0x0038); 6880 reg_w(gspca_dev, 0x00, 0x0038);
6868 break; 6881 break;
6869 case SENSOR_PAS202B: 6882 case SENSOR_PAS202B:
6870 reg_w(dev, 0x03, 0x003b); 6883 reg_w(gspca_dev, 0x03, 0x003b);
6871 reg_w(dev, 0x0c, 0x003a); 6884 reg_w(gspca_dev, 0x0c, 0x003a);
6872 reg_w(dev, 0x0b, 0x0039); 6885 reg_w(gspca_dev, 0x0b, 0x0039);
6873 break; 6886 break;
6874 } 6887 }
6875 6888
@@ -6878,7 +6891,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
6878 case SENSOR_ADCM2700: 6891 case SENSOR_ADCM2700:
6879 case SENSOR_OV7620: 6892 case SENSOR_OV7620:
6880 reg_r(gspca_dev, 0x0008); 6893 reg_r(gspca_dev, 0x0008);
6881 reg_w(dev, 0x00, 0x0008); 6894 reg_w(gspca_dev, 0x00, 0x0008);
6882 break; 6895 break;
6883 case SENSOR_PAS202B: 6896 case SENSOR_PAS202B:
6884 case SENSOR_GC0305: 6897 case SENSOR_GC0305:
@@ -6886,7 +6899,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
6886 reg_r(gspca_dev, 0x0008); 6899 reg_r(gspca_dev, 0x0008);
6887 /* fall thru */ 6900 /* fall thru */
6888 case SENSOR_PO2030: 6901 case SENSOR_PO2030:
6889 reg_w(dev, 0x03, 0x0008); 6902 reg_w(gspca_dev, 0x03, 0x0008);
6890 break; 6903 break;
6891 } 6904 }
6892 setsharpness(gspca_dev); 6905 setsharpness(gspca_dev);
@@ -6907,7 +6920,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
6907 case SENSOR_OV7620: 6920 case SENSOR_OV7620:
6908 case SENSOR_PAS202B: 6921 case SENSOR_PAS202B:
6909 reg_r(gspca_dev, 0x0180); /* from win */ 6922 reg_r(gspca_dev, 0x0180); /* from win */
6910 reg_w(dev, 0x00, 0x0180); 6923 reg_w(gspca_dev, 0x00, 0x0180);
6911 break; 6924 break;
6912 default: 6925 default:
6913 setquality(gspca_dev); 6926 setquality(gspca_dev);
@@ -6917,29 +6930,29 @@ static int sd_start(struct gspca_dev *gspca_dev)
6917 6930
6918 switch (sd->sensor) { 6931 switch (sd->sensor) {
6919 case SENSOR_ADCM2700: 6932 case SENSOR_ADCM2700:
6920 reg_w(dev, 0x09, 0x01ad); /* (from win traces) */ 6933 reg_w(gspca_dev, 0x09, 0x01ad); /* (from win traces) */
6921 reg_w(dev, 0x15, 0x01ae); 6934 reg_w(gspca_dev, 0x15, 0x01ae);
6922 reg_w(dev, 0x02, 0x0180); 6935 reg_w(gspca_dev, 0x02, 0x0180);
6923 /* ms-win + */ 6936 /* ms-win + */
6924 reg_w(dev, 0x40, 0x0117); 6937 reg_w(gspca_dev, 0x40, 0x0117);
6925 break; 6938 break;
6926 case SENSOR_GC0305: 6939 case SENSOR_GC0305:
6927 case SENSOR_TAS5130C: 6940 case SENSOR_TAS5130C:
6928 reg_w(dev, 0x09, 0x01ad); /* (from win traces) */ 6941 reg_w(gspca_dev, 0x09, 0x01ad); /* (from win traces) */
6929 reg_w(dev, 0x15, 0x01ae); 6942 reg_w(gspca_dev, 0x15, 0x01ae);
6930 /* fall thru */ 6943 /* fall thru */
6931 case SENSOR_PAS202B: 6944 case SENSOR_PAS202B:
6932 case SENSOR_PO2030: 6945 case SENSOR_PO2030:
6933/* reg_w(dev, 0x40, ZC3XX_R117_GGAIN); * (from win traces) */ 6946/* reg_w(gspca_dev, 0x40, ZC3XX_R117_GGAIN); * (from win traces) */
6934 reg_r(gspca_dev, 0x0180); 6947 reg_r(gspca_dev, 0x0180);
6935 break; 6948 break;
6936 case SENSOR_OV7620: 6949 case SENSOR_OV7620:
6937 reg_w(dev, 0x09, 0x01ad); 6950 reg_w(gspca_dev, 0x09, 0x01ad);
6938 reg_w(dev, 0x15, 0x01ae); 6951 reg_w(gspca_dev, 0x15, 0x01ae);
6939 i2c_read(gspca_dev, 0x13); /*fixme: returns 0xa3 */ 6952 i2c_read(gspca_dev, 0x13); /*fixme: returns 0xa3 */
6940 i2c_write(gspca_dev, 0x13, 0xa3, 0x00); 6953 i2c_write(gspca_dev, 0x13, 0xa3, 0x00);
6941 /*fixme: returned value to send? */ 6954 /*fixme: returned value to send? */
6942 reg_w(dev, 0x40, 0x0117); 6955 reg_w(gspca_dev, 0x40, 0x0117);
6943 reg_r(gspca_dev, 0x0180); 6956 reg_r(gspca_dev, 0x0180);
6944 break; 6957 break;
6945 } 6958 }
@@ -6948,11 +6961,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
6948 switch (sd->sensor) { 6961 switch (sd->sensor) {
6949 case SENSOR_PO2030: 6962 case SENSOR_PO2030:
6950 msleep(50); 6963 msleep(50);
6951 reg_w(dev, 0x00, 0x0007); /* (from win traces) */ 6964 reg_w(gspca_dev, 0x00, 0x0007); /* (from win traces) */
6952 reg_w(dev, 0x02, ZC3XX_R008_CLOCKSETTING); 6965 reg_w(gspca_dev, 0x02, ZC3XX_R008_CLOCKSETTING);
6953 break; 6966 break;
6954 } 6967 }
6955 return 0; 6968 return gspca_dev->usb_err;
6956} 6969}
6957 6970
6958/* called on streamoff with alt 0 and on disconnect */ 6971/* called on streamoff with alt 0 and on disconnect */
@@ -6962,7 +6975,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
6962 6975
6963 if (!gspca_dev->present) 6976 if (!gspca_dev->present)
6964 return; 6977 return;
6965 send_unknown(gspca_dev->dev, sd->sensor); 6978 send_unknown(gspca_dev, sd->sensor);
6966} 6979}
6967 6980
6968static void sd_pkt_scan(struct gspca_dev *gspca_dev, 6981static void sd_pkt_scan(struct gspca_dev *gspca_dev,
@@ -6997,7 +7010,7 @@ static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
6997 sd->brightness = val; 7010 sd->brightness = val;
6998 if (gspca_dev->streaming) 7011 if (gspca_dev->streaming)
6999 setcontrast(gspca_dev); 7012 setcontrast(gspca_dev);
7000 return 0; 7013 return gspca_dev->usb_err;
7001} 7014}
7002 7015
7003static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) 7016static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
@@ -7015,7 +7028,7 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
7015 sd->contrast = val; 7028 sd->contrast = val;
7016 if (gspca_dev->streaming) 7029 if (gspca_dev->streaming)
7017 setcontrast(gspca_dev); 7030 setcontrast(gspca_dev);
7018 return 0; 7031 return gspca_dev->usb_err;
7019} 7032}
7020 7033
7021static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) 7034static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
@@ -7033,7 +7046,7 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
7033 sd->autogain = val; 7046 sd->autogain = val;
7034 if (gspca_dev->streaming) 7047 if (gspca_dev->streaming)
7035 setautogain(gspca_dev); 7048 setautogain(gspca_dev);
7036 return 0; 7049 return gspca_dev->usb_err;
7037} 7050}
7038 7051
7039static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) 7052static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
@@ -7051,7 +7064,7 @@ static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
7051 sd->gamma = val; 7064 sd->gamma = val;
7052 if (gspca_dev->streaming) 7065 if (gspca_dev->streaming)
7053 setcontrast(gspca_dev); 7066 setcontrast(gspca_dev);
7054 return 0; 7067 return gspca_dev->usb_err;
7055} 7068}
7056 7069
7057static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val) 7070static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
@@ -7069,7 +7082,7 @@ static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
7069 sd->lightfreq = val; 7082 sd->lightfreq = val;
7070 if (gspca_dev->streaming) 7083 if (gspca_dev->streaming)
7071 setlightfreq(gspca_dev); 7084 setlightfreq(gspca_dev);
7072 return 0; 7085 return gspca_dev->usb_err;
7073} 7086}
7074 7087
7075static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val) 7088static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
@@ -7087,7 +7100,7 @@ static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
7087 sd->sharpness = val; 7100 sd->sharpness = val;
7088 if (gspca_dev->streaming) 7101 if (gspca_dev->streaming)
7089 setsharpness(gspca_dev); 7102 setsharpness(gspca_dev);
7090 return 0; 7103 return gspca_dev->usb_err;
7091} 7104}
7092 7105
7093static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val) 7106static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
@@ -7132,7 +7145,7 @@ static int sd_set_jcomp(struct gspca_dev *gspca_dev,
7132 sd->quality = jcomp->quality; 7145 sd->quality = jcomp->quality;
7133 if (gspca_dev->streaming) 7146 if (gspca_dev->streaming)
7134 jpeg_set_qual(sd->jpeg_hdr, sd->quality); 7147 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
7135 return 0; 7148 return gspca_dev->usb_err;
7136} 7149}
7137 7150
7138static int sd_get_jcomp(struct gspca_dev *gspca_dev, 7151static int sd_get_jcomp(struct gspca_dev *gspca_dev,