diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2008-07-14 08:38:29 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:26:14 -0400 |
commit | 739570bb218bb4607df1f197282561e97a98e54a (patch) | |
tree | 25555dfe5ac873bc96866c486d6f6c1dcabf24f4 /drivers/media/video/gspca/zc3xx.c | |
parent | 5b77ae7776183d733ec86727bcc34c52a336afd6 (diff) |
V4L/DVB (8352): gspca: Buffers for USB exchanges cannot be in the stack.
gspca: Protect dq_callback() against simultaneous USB exchanges.
Temporary buffer for USB exchanges added in the device struct.
(all) Use a temporary buffer for all USB exchanges.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/gspca/zc3xx.c')
-rw-r--r-- | drivers/media/video/gspca/zc3xx.c | 199 |
1 files changed, 100 insertions, 99 deletions
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c index bac45a193653..548c4c8c3f33 100644 --- a/drivers/media/video/gspca/zc3xx.c +++ b/drivers/media/video/gspca/zc3xx.c | |||
@@ -24,8 +24,8 @@ | |||
24 | 24 | ||
25 | #include "gspca.h" | 25 | #include "gspca.h" |
26 | 26 | ||
27 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5) | 27 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7) |
28 | static const char version[] = "2.1.5"; | 28 | static const char version[] = "2.1.7"; |
29 | 29 | ||
30 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>, " | 30 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>, " |
31 | "Serge A. Suchkov <Serge.A.S@tochka.ru>"); | 31 | "Serge A. Suchkov <Serge.A.S@tochka.ru>"); |
@@ -6214,23 +6214,27 @@ static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = { | |||
6214 | {} | 6214 | {} |
6215 | }; | 6215 | }; |
6216 | 6216 | ||
6217 | static void reg_r_i(struct usb_device *dev, | 6217 | static int reg_r_i(struct gspca_dev *gspca_dev, |
6218 | __u16 index, __u8 *buffer) | 6218 | __u16 index) |
6219 | { | 6219 | { |
6220 | usb_control_msg(dev, | 6220 | usb_control_msg(gspca_dev->dev, |
6221 | usb_rcvctrlpipe(dev, 0), | 6221 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
6222 | 0xa1, | 6222 | 0xa1, |
6223 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 6223 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
6224 | 0x01, /* value */ | 6224 | 0x01, /* value */ |
6225 | index, buffer, 1, | 6225 | index, gspca_dev->usb_buf, 1, |
6226 | 500); | 6226 | 500); |
6227 | return gspca_dev->usb_buf[0]; | ||
6227 | } | 6228 | } |
6228 | 6229 | ||
6229 | static void reg_r(struct usb_device *dev, | 6230 | static int reg_r(struct gspca_dev *gspca_dev, |
6230 | __u16 index, __u8 *buffer) | 6231 | __u16 index) |
6231 | { | 6232 | { |
6232 | reg_r_i(dev, index, buffer); | 6233 | int ret; |
6233 | PDEBUG(D_USBI, "reg r [%04x] -> %02x", index, *buffer); | 6234 | |
6235 | ret = reg_r_i(gspca_dev, index); | ||
6236 | PDEBUG(D_USBI, "reg r [%04x] -> %02x", index, ret); | ||
6237 | return ret; | ||
6234 | } | 6238 | } |
6235 | 6239 | ||
6236 | static void reg_w_i(struct usb_device *dev, | 6240 | static void reg_w_i(struct usb_device *dev, |
@@ -6253,55 +6257,54 @@ static void reg_w(struct usb_device *dev, | |||
6253 | reg_w_i(dev, value, index); | 6257 | reg_w_i(dev, value, index); |
6254 | } | 6258 | } |
6255 | 6259 | ||
6256 | static __u16 i2c_read(struct usb_device *dev, __u8 reg) | 6260 | static __u16 i2c_read(struct gspca_dev *gspca_dev, |
6261 | __u8 reg) | ||
6257 | { | 6262 | { |
6258 | __u8 retbyte; | 6263 | __u8 retbyte; |
6259 | __u8 retval[2]; | 6264 | __u8 retval[2]; |
6260 | 6265 | ||
6261 | reg_w_i(dev, reg, 0x92); | 6266 | reg_w_i(gspca_dev->dev, reg, 0x92); |
6262 | reg_w_i(dev, 0x02, 0x90); /* <- read command */ | 6267 | reg_w_i(gspca_dev->dev, 0x02, 0x90); /* <- read command */ |
6263 | msleep(25); | 6268 | msleep(25); |
6264 | reg_r_i(dev, 0x0091, &retbyte); /* read status */ | 6269 | retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */ |
6265 | reg_r_i(dev, 0x0095, &retval[0]); /* read Lowbyte */ | 6270 | retval[0] = reg_r_i(gspca_dev, 0x0095); /* read Lowbyte */ |
6266 | reg_r_i(dev, 0x0096, &retval[1]); /* read Hightbyte */ | 6271 | retval[1] = reg_r_i(gspca_dev, 0x0096); /* read Hightbyte */ |
6267 | PDEBUG(D_USBO, "i2c r [%02x] -> (%02x) %02x%02x", | 6272 | PDEBUG(D_USBO, "i2c r [%02x] -> (%02x) %02x%02x", |
6268 | reg, retbyte, retval[1], retval[0]); | 6273 | reg, retbyte, retval[1], retval[0]); |
6269 | return (retval[1] << 8) | retval[0]; | 6274 | return (retval[1] << 8) | retval[0]; |
6270 | } | 6275 | } |
6271 | 6276 | ||
6272 | static __u8 i2c_write(struct usb_device *dev, | 6277 | static __u8 i2c_write(struct gspca_dev *gspca_dev, |
6273 | __u8 reg, | 6278 | __u8 reg, |
6274 | __u8 valL, | 6279 | __u8 valL, |
6275 | __u8 valH) | 6280 | __u8 valH) |
6276 | { | 6281 | { |
6277 | __u8 retbyte; | 6282 | __u8 retbyte; |
6278 | 6283 | ||
6279 | reg_w_i(dev, reg, 0x92); | 6284 | reg_w_i(gspca_dev->dev, reg, 0x92); |
6280 | reg_w_i(dev, valL, 0x93); | 6285 | reg_w_i(gspca_dev->dev, valL, 0x93); |
6281 | reg_w_i(dev, valH, 0x94); | 6286 | reg_w_i(gspca_dev->dev, valH, 0x94); |
6282 | reg_w_i(dev, 0x01, 0x90); /* <- write command */ | 6287 | reg_w_i(gspca_dev->dev, 0x01, 0x90); /* <- write command */ |
6283 | msleep(5); | 6288 | msleep(5); |
6284 | reg_r_i(dev, 0x0091, &retbyte); /* read status */ | 6289 | retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */ |
6285 | PDEBUG(D_USBO, "i2c w [%02x] %02x%02x (%02x)", | 6290 | PDEBUG(D_USBO, "i2c w [%02x] %02x%02x (%02x)", |
6286 | reg, valH, valL, retbyte); | 6291 | reg, valH, valL, retbyte); |
6287 | return retbyte; | 6292 | return retbyte; |
6288 | } | 6293 | } |
6289 | 6294 | ||
6290 | static void usb_exchange(struct usb_device *dev, | 6295 | static void usb_exchange(struct gspca_dev *gspca_dev, |
6291 | const struct usb_action *action) | 6296 | const struct usb_action *action) |
6292 | { | 6297 | { |
6293 | __u8 buffread; | ||
6294 | |||
6295 | while (action->req) { | 6298 | while (action->req) { |
6296 | switch (action->req) { | 6299 | switch (action->req) { |
6297 | case 0xa0: /* write register */ | 6300 | case 0xa0: /* write register */ |
6298 | reg_w(dev, action->val, action->idx); | 6301 | reg_w(gspca_dev->dev, action->val, action->idx); |
6299 | break; | 6302 | break; |
6300 | case 0xa1: /* read status */ | 6303 | case 0xa1: /* read status */ |
6301 | reg_r(dev, action->idx, &buffread); | 6304 | reg_r(gspca_dev, action->idx); |
6302 | break; | 6305 | break; |
6303 | case 0xaa: | 6306 | case 0xaa: |
6304 | i2c_write(dev, | 6307 | i2c_write(gspca_dev, |
6305 | action->val, /* reg */ | 6308 | action->val, /* reg */ |
6306 | action->idx & 0xff, /* valL */ | 6309 | action->idx & 0xff, /* valL */ |
6307 | action->idx >> 8); /* valH */ | 6310 | action->idx >> 8); /* valH */ |
@@ -6376,7 +6379,6 @@ static void setsharpness(struct gspca_dev *gspca_dev) | |||
6376 | struct sd *sd = (struct sd *) gspca_dev; | 6379 | struct sd *sd = (struct sd *) gspca_dev; |
6377 | struct usb_device *dev = gspca_dev->dev; | 6380 | struct usb_device *dev = gspca_dev->dev; |
6378 | int sharpness; | 6381 | int sharpness; |
6379 | __u8 retbyte; | ||
6380 | static const __u8 sharpness_tb[][2] = { | 6382 | static const __u8 sharpness_tb[][2] = { |
6381 | {0x02, 0x03}, | 6383 | {0x02, 0x03}, |
6382 | {0x04, 0x07}, | 6384 | {0x04, 0x07}, |
@@ -6386,9 +6388,9 @@ static void setsharpness(struct gspca_dev *gspca_dev) | |||
6386 | 6388 | ||
6387 | sharpness = sd->sharpness; | 6389 | sharpness = sd->sharpness; |
6388 | reg_w(dev, sharpness_tb[sharpness][0], 0x01c6); | 6390 | reg_w(dev, sharpness_tb[sharpness][0], 0x01c6); |
6389 | reg_r(dev, 0x01c8, &retbyte); | 6391 | reg_r(gspca_dev, 0x01c8); |
6390 | reg_r(dev, 0x01c9, &retbyte); | 6392 | reg_r(gspca_dev, 0x01c9); |
6391 | reg_r(dev, 0x01ca, &retbyte); | 6393 | reg_r(gspca_dev, 0x01ca); |
6392 | reg_w(dev, sharpness_tb[sharpness][1], 0x01cb); | 6394 | reg_w(dev, sharpness_tb[sharpness][1], 0x01cb); |
6393 | } | 6395 | } |
6394 | 6396 | ||
@@ -6398,7 +6400,7 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
6398 | struct usb_device *dev = gspca_dev->dev; | 6400 | struct usb_device *dev = gspca_dev->dev; |
6399 | const __u8 *Tgamma, *Tgradient; | 6401 | const __u8 *Tgamma, *Tgradient; |
6400 | int g, i, k; | 6402 | int g, i, k; |
6401 | static const __u8 kgamma_tb[16] = /* delta for contrast */ | 6403 | static const __u8 kgamma_tb[16] = /* delta for contrast */ |
6402 | {0x15, 0x0d, 0x0a, 0x09, 0x08, 0x08, 0x08, 0x08, | 6404 | {0x15, 0x0d, 0x0a, 0x09, 0x08, 0x08, 0x08, 0x08, |
6403 | 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}; | 6405 | 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}; |
6404 | static const __u8 kgrad_tb[16] = | 6406 | static const __u8 kgrad_tb[16] = |
@@ -6623,7 +6625,7 @@ static int setlightfreq(struct gspca_dev *gspca_dev) | |||
6623 | i++; /* 640x480 */ | 6625 | i++; /* 640x480 */ |
6624 | zc3_freq = freq_tb[(int) sd->sensor][i]; | 6626 | zc3_freq = freq_tb[(int) sd->sensor][i]; |
6625 | if (zc3_freq != NULL) { | 6627 | if (zc3_freq != NULL) { |
6626 | usb_exchange(gspca_dev->dev, zc3_freq); | 6628 | usb_exchange(gspca_dev, zc3_freq); |
6627 | switch (sd->sensor) { | 6629 | switch (sd->sensor) { |
6628 | case SENSOR_GC0305: | 6630 | case SENSOR_GC0305: |
6629 | if (mode /* if 320x240 */ | 6631 | if (mode /* if 320x240 */ |
@@ -6687,44 +6689,45 @@ static void start_2wr_probe(struct usb_device *dev, int sensor) | |||
6687 | /* msleep(2); */ | 6689 | /* msleep(2); */ |
6688 | } | 6690 | } |
6689 | 6691 | ||
6690 | static int sif_probe(struct usb_device *dev) | 6692 | static int sif_probe(struct gspca_dev *gspca_dev) |
6691 | { | 6693 | { |
6692 | __u16 checkword; | 6694 | __u16 checkword; |
6693 | 6695 | ||
6694 | start_2wr_probe(dev, 0x0f); /* PAS106 */ | 6696 | start_2wr_probe(gspca_dev->dev, 0x0f); /* PAS106 */ |
6695 | reg_w(dev, 0x08, 0x008d); | 6697 | reg_w(gspca_dev->dev, 0x08, 0x008d); |
6696 | msleep(150); | 6698 | msleep(150); |
6697 | checkword = ((i2c_read(dev, 0x00) & 0x0f) << 4) | 6699 | checkword = ((i2c_read(gspca_dev, 0x00) & 0x0f) << 4) |
6698 | | ((i2c_read(dev, 0x01) & 0xf0) >> 4); | 6700 | | ((i2c_read(gspca_dev, 0x01) & 0xf0) >> 4); |
6699 | PDEBUG(D_PROBE, "probe sif 0x%04x", checkword); | 6701 | PDEBUG(D_PROBE, "probe sif 0x%04x", checkword); |
6700 | if (checkword == 0x0007) { | 6702 | if (checkword == 0x0007) { |
6701 | send_unknown(dev, SENSOR_PAS106); | 6703 | send_unknown(gspca_dev->dev, SENSOR_PAS106); |
6702 | return 0x0f; /* PAS106 */ | 6704 | return 0x0f; /* PAS106 */ |
6703 | } | 6705 | } |
6704 | return -1; | 6706 | return -1; |
6705 | } | 6707 | } |
6706 | 6708 | ||
6707 | static int vga_2wr_probe(struct usb_device *dev) | 6709 | static int vga_2wr_probe(struct gspca_dev *gspca_dev) |
6708 | { | 6710 | { |
6711 | struct usb_device *dev = gspca_dev->dev; | ||
6709 | __u8 retbyte; | 6712 | __u8 retbyte; |
6710 | __u16 checkword; | 6713 | __u16 checkword; |
6711 | 6714 | ||
6712 | start_2wr_probe(dev, 0x00); /* HV7131B */ | 6715 | start_2wr_probe(dev, 0x00); /* HV7131B */ |
6713 | i2c_write(dev, 0x01, 0xaa, 0x00); | 6716 | i2c_write(gspca_dev, 0x01, 0xaa, 0x00); |
6714 | retbyte = i2c_read(dev, 0x01); | 6717 | retbyte = i2c_read(gspca_dev, 0x01); |
6715 | if (retbyte != 0) | 6718 | if (retbyte != 0) |
6716 | return 0x00; /* HV7131B */ | 6719 | return 0x00; /* HV7131B */ |
6717 | 6720 | ||
6718 | start_2wr_probe(dev, 0x04); /* CS2102 */ | 6721 | start_2wr_probe(dev, 0x04); /* CS2102 */ |
6719 | i2c_write(dev, 0x01, 0xaa, 0x00); | 6722 | i2c_write(gspca_dev, 0x01, 0xaa, 0x00); |
6720 | retbyte = i2c_read(dev, 0x01); | 6723 | retbyte = i2c_read(gspca_dev, 0x01); |
6721 | if (retbyte != 0) | 6724 | if (retbyte != 0) |
6722 | return 0x04; /* CS2102 */ | 6725 | return 0x04; /* CS2102 */ |
6723 | 6726 | ||
6724 | start_2wr_probe(dev, 0x06); /* OmniVision */ | 6727 | start_2wr_probe(dev, 0x06); /* OmniVision */ |
6725 | reg_w(dev, 0x08, 0x8d); | 6728 | reg_w(dev, 0x08, 0x8d); |
6726 | i2c_write(dev, 0x11, 0xaa, 0x00); | 6729 | i2c_write(gspca_dev, 0x11, 0xaa, 0x00); |
6727 | retbyte = i2c_read(dev, 0x11); | 6730 | retbyte = i2c_read(gspca_dev, 0x11); |
6728 | if (retbyte != 0) { | 6731 | if (retbyte != 0) { |
6729 | /* (should have returned 0xaa) --> Omnivision? */ | 6732 | /* (should have returned 0xaa) --> Omnivision? */ |
6730 | /* reg_r 0x10 -> 0x06 --> */ | 6733 | /* reg_r 0x10 -> 0x06 --> */ |
@@ -6732,45 +6735,45 @@ static int vga_2wr_probe(struct usb_device *dev) | |||
6732 | } | 6735 | } |
6733 | 6736 | ||
6734 | start_2wr_probe(dev, 0x08); /* HDCS2020 */ | 6737 | start_2wr_probe(dev, 0x08); /* HDCS2020 */ |
6735 | i2c_write(dev, 0x15, 0xaa, 0x00); | 6738 | i2c_write(gspca_dev, 0x15, 0xaa, 0x00); |
6736 | retbyte = i2c_read(dev, 0x15); | 6739 | retbyte = i2c_read(gspca_dev, 0x15); |
6737 | if (retbyte != 0) | 6740 | if (retbyte != 0) |
6738 | return 0x08; /* HDCS2020 */ | 6741 | return 0x08; /* HDCS2020 */ |
6739 | 6742 | ||
6740 | start_2wr_probe(dev, 0x0a); /* PB0330 */ | 6743 | start_2wr_probe(dev, 0x0a); /* PB0330 */ |
6741 | i2c_write(dev, 0x07, 0xaa, 0xaa); | 6744 | i2c_write(gspca_dev, 0x07, 0xaa, 0xaa); |
6742 | retbyte = i2c_read(dev, 0x07); | 6745 | retbyte = i2c_read(gspca_dev, 0x07); |
6743 | if (retbyte != 0) | 6746 | if (retbyte != 0) |
6744 | return 0x0a; /* PB0330 */ | 6747 | return 0x0a; /* PB0330 */ |
6745 | retbyte = i2c_read(dev, 0x03); | 6748 | retbyte = i2c_read(gspca_dev, 0x03); |
6746 | if (retbyte != 0) | 6749 | if (retbyte != 0) |
6747 | return 0x0a; /* PB0330 ?? */ | 6750 | return 0x0a; /* PB0330 ?? */ |
6748 | retbyte = i2c_read(dev, 0x04); | 6751 | retbyte = i2c_read(gspca_dev, 0x04); |
6749 | if (retbyte != 0) | 6752 | if (retbyte != 0) |
6750 | return 0x0a; /* PB0330 ?? */ | 6753 | return 0x0a; /* PB0330 ?? */ |
6751 | 6754 | ||
6752 | start_2wr_probe(dev, 0x0c); /* ICM105A */ | 6755 | start_2wr_probe(dev, 0x0c); /* ICM105A */ |
6753 | i2c_write(dev, 0x01, 0x11, 0x00); | 6756 | i2c_write(gspca_dev, 0x01, 0x11, 0x00); |
6754 | retbyte = i2c_read(dev, 0x01); | 6757 | retbyte = i2c_read(gspca_dev, 0x01); |
6755 | if (retbyte != 0) | 6758 | if (retbyte != 0) |
6756 | return 0x0c; /* ICM105A */ | 6759 | return 0x0c; /* ICM105A */ |
6757 | 6760 | ||
6758 | start_2wr_probe(dev, 0x0e); /* PAS202BCB */ | 6761 | start_2wr_probe(dev, 0x0e); /* PAS202BCB */ |
6759 | reg_w(dev, 0x08, 0x8d); | 6762 | reg_w(dev, 0x08, 0x8d); |
6760 | i2c_write(dev, 0x03, 0xaa, 0x00); | 6763 | i2c_write(gspca_dev, 0x03, 0xaa, 0x00); |
6761 | msleep(500); | 6764 | msleep(500); |
6762 | retbyte = i2c_read(dev, 0x03); | 6765 | retbyte = i2c_read(gspca_dev, 0x03); |
6763 | if (retbyte != 0) | 6766 | if (retbyte != 0) |
6764 | return 0x0e; /* PAS202BCB */ | 6767 | return 0x0e; /* PAS202BCB */ |
6765 | 6768 | ||
6766 | start_2wr_probe(dev, 0x02); /* ?? */ | 6769 | start_2wr_probe(dev, 0x02); /* ?? */ |
6767 | i2c_write(dev, 0x01, 0xaa, 0x00); | 6770 | i2c_write(gspca_dev, 0x01, 0xaa, 0x00); |
6768 | retbyte = i2c_read(dev, 0x01); | 6771 | retbyte = i2c_read(gspca_dev, 0x01); |
6769 | if (retbyte != 0) | 6772 | if (retbyte != 0) |
6770 | return 0x02; /* ?? */ | 6773 | return 0x02; /* ?? */ |
6771 | ov_check: | 6774 | ov_check: |
6772 | reg_r(dev, 0x0010, &retbyte); /* ?? */ | 6775 | reg_r(gspca_dev, 0x0010); /* ?? */ |
6773 | reg_r(dev, 0x0010, &retbyte); | 6776 | reg_r(gspca_dev, 0x0010); |
6774 | 6777 | ||
6775 | reg_w(dev, 0x01, 0x0000); | 6778 | reg_w(dev, 0x01, 0x0000); |
6776 | reg_w(dev, 0x01, 0x0001); | 6779 | reg_w(dev, 0x01, 0x0001); |
@@ -6779,10 +6782,10 @@ ov_check: | |||
6779 | reg_w(dev, 0x08, 0x008d); | 6782 | reg_w(dev, 0x08, 0x008d); |
6780 | msleep(500); | 6783 | msleep(500); |
6781 | reg_w(dev, 0x01, 0x0012); | 6784 | reg_w(dev, 0x01, 0x0012); |
6782 | i2c_write(dev, 0x12, 0x80, 0x00); /* sensor reset */ | 6785 | i2c_write(gspca_dev, 0x12, 0x80, 0x00); /* sensor reset */ |
6783 | retbyte = i2c_read(dev, 0x0a); | 6786 | retbyte = i2c_read(gspca_dev, 0x0a); |
6784 | checkword = retbyte << 8; | 6787 | checkword = retbyte << 8; |
6785 | retbyte = i2c_read(dev, 0x0b); | 6788 | retbyte = i2c_read(gspca_dev, 0x0b); |
6786 | checkword |= retbyte; | 6789 | checkword |= retbyte; |
6787 | PDEBUG(D_PROBE, "probe 2wr ov vga 0x%04x", checkword); | 6790 | PDEBUG(D_PROBE, "probe 2wr ov vga 0x%04x", checkword); |
6788 | switch (checkword) { | 6791 | switch (checkword) { |
@@ -6821,7 +6824,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6821 | 6824 | ||
6822 | /*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/ | 6825 | /*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/ |
6823 | reg_w(dev, 0x02, 0x0010); | 6826 | reg_w(dev, 0x02, 0x0010); |
6824 | reg_r(dev, 0x10, &retbyte); | 6827 | reg_r(gspca_dev, 0x10); |
6825 | reg_w(dev, 0x01, 0x0000); | 6828 | reg_w(dev, 0x01, 0x0000); |
6826 | reg_w(dev, 0x00, 0x0010); | 6829 | reg_w(dev, 0x00, 0x0010); |
6827 | reg_w(dev, 0x01, 0x0001); | 6830 | reg_w(dev, 0x01, 0x0001); |
@@ -6829,23 +6832,23 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6829 | reg_w(dev, 0x03, 0x0012); | 6832 | reg_w(dev, 0x03, 0x0012); |
6830 | reg_w(dev, 0x01, 0x0012); | 6833 | reg_w(dev, 0x01, 0x0012); |
6831 | reg_w(dev, 0x05, 0x0012); | 6834 | reg_w(dev, 0x05, 0x0012); |
6832 | retbyte = i2c_read(dev, 0x14); | 6835 | retbyte = i2c_read(gspca_dev, 0x14); |
6833 | if (retbyte != 0) | 6836 | if (retbyte != 0) |
6834 | return 0x11; /* HV7131R */ | 6837 | return 0x11; /* HV7131R */ |
6835 | retbyte = i2c_read(dev, 0x15); | 6838 | retbyte = i2c_read(gspca_dev, 0x15); |
6836 | if (retbyte != 0) | 6839 | if (retbyte != 0) |
6837 | return 0x11; /* HV7131R */ | 6840 | return 0x11; /* HV7131R */ |
6838 | retbyte = i2c_read(dev, 0x16); | 6841 | retbyte = i2c_read(gspca_dev, 0x16); |
6839 | if (retbyte != 0) | 6842 | if (retbyte != 0) |
6840 | return 0x11; /* HV7131R */ | 6843 | return 0x11; /* HV7131R */ |
6841 | 6844 | ||
6842 | reg_w(dev, 0x02, 0x0010); | 6845 | reg_w(dev, 0x02, 0x0010); |
6843 | reg_r(dev, 0x000b, &retbyte); | 6846 | retbyte = reg_r(gspca_dev, 0x000b); |
6844 | checkword = retbyte << 8; | 6847 | checkword = retbyte << 8; |
6845 | reg_r(dev, 0x000a, &retbyte); | 6848 | retbyte = reg_r(gspca_dev, 0x000a); |
6846 | checkword |= retbyte; | 6849 | checkword |= retbyte; |
6847 | PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", checkword); | 6850 | PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", checkword); |
6848 | reg_r(dev, 0x0010, &retbyte); | 6851 | reg_r(gspca_dev, 0x0010); |
6849 | /* this is tested only once anyway */ | 6852 | /* this is tested only once anyway */ |
6850 | i = 0; | 6853 | i = 0; |
6851 | while (chipset_revision_sensor[i].revision) { | 6854 | while (chipset_revision_sensor[i].revision) { |
@@ -6863,7 +6866,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6863 | reg_w(dev, 0x0a, 0x0010); | 6866 | reg_w(dev, 0x0a, 0x0010); |
6864 | reg_w(dev, 0x03, 0x0012); | 6867 | reg_w(dev, 0x03, 0x0012); |
6865 | reg_w(dev, 0x01, 0x0012); | 6868 | reg_w(dev, 0x01, 0x0012); |
6866 | retbyte = i2c_read(dev, 0x00); | 6869 | retbyte = i2c_read(gspca_dev, 0x00); |
6867 | if (retbyte != 0) { | 6870 | if (retbyte != 0) { |
6868 | PDEBUG(D_PROBE, "probe 3wr vga type 0a ?"); | 6871 | PDEBUG(D_PROBE, "probe 3wr vga type 0a ?"); |
6869 | return 0x0a; /* ?? */ | 6872 | return 0x0a; /* ?? */ |
@@ -6876,7 +6879,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6876 | reg_w(dev, 0x03, 0x0012); | 6879 | reg_w(dev, 0x03, 0x0012); |
6877 | msleep(2); | 6880 | msleep(2); |
6878 | reg_w(dev, 0x01, 0x0012); | 6881 | reg_w(dev, 0x01, 0x0012); |
6879 | retbyte = i2c_read(dev, 0x00); | 6882 | retbyte = i2c_read(gspca_dev, 0x00); |
6880 | if (retbyte != 0) { | 6883 | if (retbyte != 0) { |
6881 | PDEBUG(D_PROBE, "probe 3wr vga type %02x", retbyte); | 6884 | PDEBUG(D_PROBE, "probe 3wr vga type %02x", retbyte); |
6882 | send_unknown(dev, SENSOR_GC0305); | 6885 | send_unknown(dev, SENSOR_GC0305); |
@@ -6890,8 +6893,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6890 | reg_w(dev, 0x06, 0x0010); | 6893 | reg_w(dev, 0x06, 0x0010); |
6891 | reg_w(dev, 0x01, 0x0012); | 6894 | reg_w(dev, 0x01, 0x0012); |
6892 | reg_w(dev, 0x05, 0x0012); | 6895 | reg_w(dev, 0x05, 0x0012); |
6893 | if (i2c_read(dev, 0x1c) == 0x7f /* OV7610 - manufacturer ID */ | 6896 | if (i2c_read(gspca_dev, 0x1c) == 0x7f /* OV7610 - manufacturer ID */ |
6894 | && i2c_read(dev, 0x1d) == 0xa2) { | 6897 | && i2c_read(gspca_dev, 0x1d) == 0xa2) { |
6895 | send_unknown(dev, SENSOR_OV7620); | 6898 | send_unknown(dev, SENSOR_OV7620); |
6896 | return 0x06; /* OmniVision confirm ? */ | 6899 | return 0x06; /* OmniVision confirm ? */ |
6897 | } | 6900 | } |
@@ -6905,13 +6908,13 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6905 | /* msleep(150); */ | 6908 | /* msleep(150); */ |
6906 | reg_w(dev, 0x01, 0x12); | 6909 | reg_w(dev, 0x01, 0x12); |
6907 | reg_w(dev, 0x05, 0x12); | 6910 | reg_w(dev, 0x05, 0x12); |
6908 | retbyte = i2c_read(dev, 0x00); /* ID 0 */ | 6911 | retbyte = i2c_read(gspca_dev, 0x00); /* ID 0 */ |
6909 | checkword = retbyte << 8; | 6912 | checkword = retbyte << 8; |
6910 | retbyte = i2c_read(dev, 0x01); /* ID 1 */ | 6913 | retbyte = i2c_read(gspca_dev, 0x01); /* ID 1 */ |
6911 | checkword |= retbyte; | 6914 | checkword |= retbyte; |
6912 | PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", checkword); | 6915 | PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", checkword); |
6913 | if (checkword == 0x2030) { | 6916 | if (checkword == 0x2030) { |
6914 | retbyte = i2c_read(dev, 0x02); /* revision number */ | 6917 | retbyte = i2c_read(gspca_dev, 0x02); /* revision number */ |
6915 | PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte); | 6918 | PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte); |
6916 | send_unknown(dev, SENSOR_PO2030); | 6919 | send_unknown(dev, SENSOR_PO2030); |
6917 | return checkword; | 6920 | return checkword; |
@@ -6925,7 +6928,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6925 | reg_w(dev, 0x01, 0x12); | 6928 | reg_w(dev, 0x01, 0x12); |
6926 | reg_w(dev, 0x05, 0x01); | 6929 | reg_w(dev, 0x05, 0x01); |
6927 | reg_w(dev, 0xd3, 0x8b); | 6930 | reg_w(dev, 0xd3, 0x8b); |
6928 | retbyte = i2c_read(dev, 0x01); | 6931 | retbyte = i2c_read(gspca_dev, 0x01); |
6929 | if (retbyte != 0) { | 6932 | if (retbyte != 0) { |
6930 | PDEBUG(D_PROBE, "probe 3wr vga type 0a ?"); | 6933 | PDEBUG(D_PROBE, "probe 3wr vga type 0a ?"); |
6931 | return 0x0a; /* ?? */ | 6934 | return 0x0a; /* ?? */ |
@@ -6936,7 +6939,6 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6936 | static int zcxx_probeSensor(struct gspca_dev *gspca_dev) | 6939 | static int zcxx_probeSensor(struct gspca_dev *gspca_dev) |
6937 | { | 6940 | { |
6938 | struct sd *sd = (struct sd *) gspca_dev; | 6941 | struct sd *sd = (struct sd *) gspca_dev; |
6939 | struct usb_device *dev = gspca_dev->dev; | ||
6940 | int sensor, sensor2; | 6942 | int sensor, sensor2; |
6941 | 6943 | ||
6942 | switch (sd->sensor) { | 6944 | switch (sd->sensor) { |
@@ -6944,7 +6946,7 @@ static int zcxx_probeSensor(struct gspca_dev *gspca_dev) | |||
6944 | case SENSOR_TAS5130C_VF0250: | 6946 | case SENSOR_TAS5130C_VF0250: |
6945 | return -1; /* don't probe */ | 6947 | return -1; /* don't probe */ |
6946 | } | 6948 | } |
6947 | sensor = vga_2wr_probe(dev); | 6949 | sensor = vga_2wr_probe(gspca_dev); |
6948 | if (sensor >= 0) { | 6950 | if (sensor >= 0) { |
6949 | if (sensor < 0x7600) | 6951 | if (sensor < 0x7600) |
6950 | return sensor; | 6952 | return sensor; |
@@ -6956,7 +6958,7 @@ static int zcxx_probeSensor(struct gspca_dev *gspca_dev) | |||
6956 | return sensor; | 6958 | return sensor; |
6957 | return sensor2; | 6959 | return sensor2; |
6958 | } | 6960 | } |
6959 | return sif_probe(dev); | 6961 | return sif_probe(gspca_dev); |
6960 | } | 6962 | } |
6961 | 6963 | ||
6962 | /* this function is called at probe time */ | 6964 | /* this function is called at probe time */ |
@@ -6966,7 +6968,6 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
6966 | struct sd *sd = (struct sd *) gspca_dev; | 6968 | struct sd *sd = (struct sd *) gspca_dev; |
6967 | struct cam *cam; | 6969 | struct cam *cam; |
6968 | int sensor; | 6970 | int sensor; |
6969 | __u8 bsensor; | ||
6970 | int vga = 1; /* 1: vga, 0: sif */ | 6971 | int vga = 1; /* 1: vga, 0: sif */ |
6971 | static const __u8 gamma[SENSOR_MAX] = { | 6972 | static const __u8 gamma[SENSOR_MAX] = { |
6972 | 5, /* SENSOR_CS2102 0 */ | 6973 | 5, /* SENSOR_CS2102 0 */ |
@@ -7122,7 +7123,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
7122 | reg_w(gspca_dev->dev, 0x02, 0x0010); | 7123 | reg_w(gspca_dev->dev, 0x02, 0x0010); |
7123 | else | 7124 | else |
7124 | reg_w(gspca_dev->dev, sensor & 0x0f, 0x0010); | 7125 | reg_w(gspca_dev->dev, sensor & 0x0f, 0x0010); |
7125 | reg_r(gspca_dev->dev, 0x0010, &bsensor); | 7126 | reg_r(gspca_dev, 0x0010); |
7126 | } | 7127 | } |
7127 | 7128 | ||
7128 | cam = &gspca_dev->cam; | 7129 | cam = &gspca_dev->cam; |
@@ -7163,7 +7164,6 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
7163 | struct usb_device *dev = gspca_dev->dev; | 7164 | struct usb_device *dev = gspca_dev->dev; |
7164 | const struct usb_action *zc3_init; | 7165 | const struct usb_action *zc3_init; |
7165 | int mode; | 7166 | int mode; |
7166 | __u8 retbyte; | ||
7167 | static const struct usb_action *init_tb[SENSOR_MAX][2] = { | 7167 | static const struct usb_action *init_tb[SENSOR_MAX][2] = { |
7168 | {cs2102_InitialScale, cs2102_Initial}, /* 0 */ | 7168 | {cs2102_InitialScale, cs2102_Initial}, /* 0 */ |
7169 | {cs2102K_InitialScale, cs2102K_Initial}, /* 1 */ | 7169 | {cs2102K_InitialScale, cs2102K_Initial}, /* 1 */ |
@@ -7194,7 +7194,7 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
7194 | zcxx_probeSensor(gspca_dev); | 7194 | zcxx_probeSensor(gspca_dev); |
7195 | break; | 7195 | break; |
7196 | case SENSOR_PAS106: | 7196 | case SENSOR_PAS106: |
7197 | usb_exchange(dev, pas106b_Initial_com); | 7197 | usb_exchange(gspca_dev, pas106b_Initial_com); |
7198 | break; | 7198 | break; |
7199 | case SENSOR_PB0330: | 7199 | case SENSOR_PB0330: |
7200 | if (mode) { | 7200 | if (mode) { |
@@ -7210,14 +7210,14 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
7210 | } | 7210 | } |
7211 | break; | 7211 | break; |
7212 | } | 7212 | } |
7213 | usb_exchange(dev, zc3_init); | 7213 | usb_exchange(gspca_dev, zc3_init); |
7214 | 7214 | ||
7215 | switch (sd->sensor) { | 7215 | switch (sd->sensor) { |
7216 | case SENSOR_GC0305: | 7216 | case SENSOR_GC0305: |
7217 | case SENSOR_OV7620: | 7217 | case SENSOR_OV7620: |
7218 | case SENSOR_PO2030: | 7218 | case SENSOR_PO2030: |
7219 | msleep(100); /* ?? */ | 7219 | msleep(100); /* ?? */ |
7220 | reg_r(dev, 0x0002, &retbyte); /* --> 0x40 */ | 7220 | reg_r(gspca_dev, 0x0002); /* --> 0x40 */ |
7221 | reg_w(dev, 0x09, 0x01ad); /* (from win traces) */ | 7221 | reg_w(dev, 0x09, 0x01ad); /* (from win traces) */ |
7222 | reg_w(dev, 0x15, 0x01ae); | 7222 | reg_w(dev, 0x15, 0x01ae); |
7223 | reg_w(dev, 0x0d, 0x003a); | 7223 | reg_w(dev, 0x0d, 0x003a); |
@@ -7230,11 +7230,11 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
7230 | setbrightness(gspca_dev); | 7230 | setbrightness(gspca_dev); |
7231 | switch (sd->sensor) { | 7231 | switch (sd->sensor) { |
7232 | case SENSOR_OV7620: | 7232 | case SENSOR_OV7620: |
7233 | reg_r(dev, 0x0008, &retbyte); | 7233 | reg_r(gspca_dev, 0x0008); |
7234 | reg_w(dev, 0x00, 0x0008); | 7234 | reg_w(dev, 0x00, 0x0008); |
7235 | break; | 7235 | break; |
7236 | case SENSOR_GC0305: | 7236 | case SENSOR_GC0305: |
7237 | reg_r(dev, 0x0008, &retbyte); | 7237 | reg_r(gspca_dev, 0x0008); |
7238 | /* fall thru */ | 7238 | /* fall thru */ |
7239 | case SENSOR_PO2030: | 7239 | case SENSOR_PO2030: |
7240 | reg_w(dev, 0x03, 0x0008); | 7240 | reg_w(dev, 0x03, 0x0008); |
@@ -7259,7 +7259,7 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
7259 | setmatrix(gspca_dev); /* one more time? */ | 7259 | setmatrix(gspca_dev); /* one more time? */ |
7260 | switch (sd->sensor) { | 7260 | switch (sd->sensor) { |
7261 | case SENSOR_OV7620: | 7261 | case SENSOR_OV7620: |
7262 | reg_r(dev, 0x0180, &retbyte); /* from win */ | 7262 | reg_r(gspca_dev, 0x0180); /* from win */ |
7263 | reg_w(dev, 0x00, 0x0180); | 7263 | reg_w(dev, 0x00, 0x0180); |
7264 | break; | 7264 | break; |
7265 | default: | 7265 | default: |
@@ -7277,7 +7277,7 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
7277 | break; | 7277 | break; |
7278 | case SENSOR_PO2030: | 7278 | case SENSOR_PO2030: |
7279 | reg_w(dev, 0x40, 0x0117); /* (from win traces) */ | 7279 | reg_w(dev, 0x40, 0x0117); /* (from win traces) */ |
7280 | reg_r(dev, 0x0180, &retbyte); | 7280 | reg_r(gspca_dev, 0x0180); |
7281 | break; | 7281 | break; |
7282 | } | 7282 | } |
7283 | 7283 | ||
@@ -7289,22 +7289,23 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
7289 | reg_w(dev, 0x15, 0x01ae); | 7289 | reg_w(dev, 0x15, 0x01ae); |
7290 | reg_w(dev, 0x40, 0x0180); | 7290 | reg_w(dev, 0x40, 0x0180); |
7291 | reg_w(dev, 0x40, 0x0117); | 7291 | reg_w(dev, 0x40, 0x0117); |
7292 | reg_r(dev, 0x0180, &retbyte); | 7292 | reg_r(gspca_dev, 0x0180); |
7293 | sd->autogain = 1; | 7293 | sd->autogain = 1; |
7294 | setautogain(gspca_dev); | 7294 | setautogain(gspca_dev); |
7295 | break; | 7295 | break; |
7296 | case SENSOR_OV7620: | 7296 | case SENSOR_OV7620: |
7297 | i2c_read(dev, 0x13); /*fixme: returns 0xa3 */ | 7297 | i2c_read(gspca_dev, 0x13); /*fixme: returns 0xa3 */ |
7298 | i2c_write(dev, 0x13, 0xa3, 0x00); /*fixme: same to send? */ | 7298 | i2c_write(gspca_dev, 0x13, 0xa3, 0x00); |
7299 | /*fixme: returned value to send? */ | ||
7299 | reg_w(dev, 0x40, 0x0117); /* (from win traces) */ | 7300 | reg_w(dev, 0x40, 0x0117); /* (from win traces) */ |
7300 | reg_r(dev, 0x0180, &retbyte); | 7301 | reg_r(gspca_dev, 0x0180); |
7301 | setautogain(gspca_dev); | 7302 | setautogain(gspca_dev); |
7302 | msleep(500); | 7303 | msleep(500); |
7303 | break; | 7304 | break; |
7304 | case SENSOR_PO2030: | 7305 | case SENSOR_PO2030: |
7305 | msleep(500); | 7306 | msleep(500); |
7306 | reg_r(dev, 0x0008, &retbyte); | 7307 | reg_r(gspca_dev, 0x0008); |
7307 | reg_r(dev, 0x0007, &retbyte); | 7308 | reg_r(gspca_dev, 0x0007); |
7308 | reg_w(dev, 0x00, 0x0007); /* (from win traces) */ | 7309 | reg_w(dev, 0x00, 0x0007); /* (from win traces) */ |
7309 | reg_w(dev, 0x02, 0x0008); | 7310 | reg_w(dev, 0x02, 0x0008); |
7310 | break; | 7311 | break; |