diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2008-07-03 10:09:12 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:16:41 -0400 |
commit | bf7f0b98426b54c29ec8100a3f1963114c2f2ef0 (patch) | |
tree | c3d43d2240020fded85674066fd2cb7a5a503f86 /drivers/media/video/gspca/mars.c | |
parent | 0d2a722ddae5e736a5c36a1b99ee4ca59a8373bc (diff) |
V4L/DVB (8193): gspca: Input buffer may be changed on reg write.
Done for conex, etoms, pac7311, sonixj, t613 and tv8532.
Code cleanup for some other subdrivers.
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/mars.c')
-rw-r--r-- | drivers/media/video/gspca/mars.c | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c index d8cd2148f301..6556e0a330fa 100644 --- a/drivers/media/video/gspca/mars.c +++ b/drivers/media/video/gspca/mars.c | |||
@@ -79,49 +79,35 @@ enum { | |||
79 | }; | 79 | }; |
80 | 80 | ||
81 | static int pcam_reg_write(struct usb_device *dev, | 81 | static int pcam_reg_write(struct usb_device *dev, |
82 | __u16 index, unsigned char *value, int length) | 82 | __u16 index, __u8 *value, int len) |
83 | { | 83 | { |
84 | int rc; | 84 | int rc; |
85 | 85 | ||
86 | rc = usb_control_msg(dev, | 86 | rc = usb_control_msg(dev, |
87 | usb_sndbulkpipe(dev, 4), | 87 | usb_sndbulkpipe(dev, 4), |
88 | 0x12, | 88 | 0x12, |
89 | /* ?? 0xc8 = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_??? !? */ | 89 | /* ?? 0xc8 = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_??? !? */ |
90 | 0xc8, | 90 | 0xc8, |
91 | 0, /* value */ | 91 | 0, /* value */ |
92 | index, value, length, 500); | 92 | index, value, len, 500); |
93 | PDEBUG(D_USBO, "reg write: 0x%02X , result = 0x%x", index, rc); | ||
94 | |||
95 | if (rc < 0) | 93 | if (rc < 0) |
96 | PDEBUG(D_ERR, "reg write: error %d", rc); | 94 | PDEBUG(D_ERR, "reg write [%02x] error %d", index, rc); |
97 | return rc; | 95 | return rc; |
98 | } | 96 | } |
99 | 97 | ||
100 | static void MISensor_BulkWrite(struct usb_device *dev, unsigned short *pch, | 98 | static void MISensor_BulkWrite(struct usb_device *dev, |
101 | char Address) | 99 | unsigned short *pch, |
100 | char Address) | ||
102 | { | 101 | { |
103 | int result; | 102 | __u8 data[6]; |
104 | unsigned char data[6]; | ||
105 | 103 | ||
106 | data[0] = 0x1f; | 104 | data[0] = 0x1f; |
107 | data[1] = 0; | 105 | data[1] = 0; /* control byte */ |
108 | data[2] = Address; | 106 | data[2] = Address; |
109 | data[3] = *pch >> 8; /* high byte */ | 107 | data[3] = *pch >> 8; /* high byte */ |
110 | data[4] = *pch; /* low byte */ | 108 | data[4] = *pch; /* low byte */ |
111 | data[5] = 0; | ||
112 | |||
113 | result = usb_control_msg(dev, | ||
114 | usb_sndbulkpipe(dev, 4), | ||
115 | 0x12, | ||
116 | /* ?? 0xc8 = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_??? !? */ | ||
117 | 0xc8, | ||
118 | 0, /* value */ | ||
119 | Address, /* index */ | ||
120 | data, 5, 500); | ||
121 | PDEBUG(D_USBO, "bulk write 0x%02x = 0x%04x", Address, *pch); | ||
122 | 109 | ||
123 | if (result < 0) | 110 | pcam_reg_write(dev, Address, data, 5); |
124 | PDEBUG(D_ERR, "reg write: error %d", result); | ||
125 | } | 111 | } |
126 | 112 | ||
127 | /* this function is called at probe time */ | 113 | /* this function is called at probe time */ |
@@ -167,7 +153,7 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
167 | data[0] = 0x01; /* address */ | 153 | data[0] = 0x01; /* address */ |
168 | data[1] = 0x01; | 154 | data[1] = 0x01; |
169 | 155 | ||
170 | err_code = pcam_reg_write(dev, data[0], data, 0x02); | 156 | err_code = pcam_reg_write(dev, data[0], data, 2); |
171 | if (err_code < 0) | 157 | if (err_code < 0) |
172 | return; | 158 | return; |
173 | 159 | ||
@@ -193,14 +179,14 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
193 | data[10] = 0x5d; /* reg 9, I2C device address | 179 | data[10] = 0x5d; /* reg 9, I2C device address |
194 | * [for PAS5101 (0x40)] [for MI (0x5d)] */ | 180 | * [for PAS5101 (0x40)] [for MI (0x5d)] */ |
195 | 181 | ||
196 | err_code = pcam_reg_write(dev, data[0], data, 0x0b); | 182 | err_code = pcam_reg_write(dev, data[0], data, 11); |
197 | if (err_code < 0) | 183 | if (err_code < 0) |
198 | return; | 184 | return; |
199 | 185 | ||
200 | data[0] = 0x23; /* address */ | 186 | data[0] = 0x23; /* address */ |
201 | data[1] = 0x09; /* reg 35, append frame header */ | 187 | data[1] = 0x09; /* reg 35, append frame header */ |
202 | 188 | ||
203 | err_code = pcam_reg_write(dev, data[0], data, 0x02); | 189 | err_code = pcam_reg_write(dev, data[0], data, 2); |
204 | if (err_code < 0) { | 190 | if (err_code < 0) { |
205 | PDEBUG(D_ERR, "Register write failed"); | 191 | PDEBUG(D_ERR, "Register write failed"); |
206 | return; | 192 | return; |
@@ -213,7 +199,7 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
213 | /* else */ | 199 | /* else */ |
214 | data[1] = 50; /* 50 reg 60, pc-cam frame size | 200 | data[1] = 50; /* 50 reg 60, pc-cam frame size |
215 | * (unit: 4KB) 200KB */ | 201 | * (unit: 4KB) 200KB */ |
216 | err_code = pcam_reg_write(dev, data[0], data, 0x02); | 202 | err_code = pcam_reg_write(dev, data[0], data, 2); |
217 | if (err_code < 0) | 203 | if (err_code < 0) |
218 | return; | 204 | return; |
219 | 205 | ||
@@ -255,13 +241,13 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
255 | /* auto dark-gain */ | 241 | /* auto dark-gain */ |
256 | data[0] = 0x5e; /* address */ | 242 | data[0] = 0x5e; /* address */ |
257 | 243 | ||
258 | err_code = pcam_reg_write(dev, data[0], data, 0x06); | 244 | err_code = pcam_reg_write(dev, data[0], data, 6); |
259 | if (err_code < 0) | 245 | if (err_code < 0) |
260 | return; | 246 | return; |
261 | 247 | ||
262 | data[0] = 0x67; | 248 | data[0] = 0x67; |
263 | data[1] = 0x13; /* reg 103, first pixel B, disable sharpness */ | 249 | data[1] = 0x13; /* reg 103, first pixel B, disable sharpness */ |
264 | err_code = pcam_reg_write(dev, data[0], data, 0x02); | 250 | err_code = pcam_reg_write(dev, data[0], data, 2); |
265 | if (err_code < 0) | 251 | if (err_code < 0) |
266 | return; | 252 | return; |
267 | 253 | ||
@@ -340,7 +326,7 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
340 | 326 | ||
341 | data[0] = 0x00; | 327 | data[0] = 0x00; |
342 | data[1] = 0x4d; /* ISOC transfering enable... */ | 328 | data[1] = 0x4d; /* ISOC transfering enable... */ |
343 | pcam_reg_write(dev, data[0], data, 0x02); | 329 | pcam_reg_write(dev, data[0], data, 2); |
344 | } | 330 | } |
345 | 331 | ||
346 | static void sd_stopN(struct gspca_dev *gspca_dev) | 332 | static void sd_stopN(struct gspca_dev *gspca_dev) |