diff options
Diffstat (limited to 'drivers/media/video/gspca/stk014.c')
-rw-r--r-- | drivers/media/video/gspca/stk014.c | 86 |
1 files changed, 41 insertions, 45 deletions
diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c index d676cd16aa74..c78ee0d3e59b 100644 --- a/drivers/media/video/gspca/stk014.c +++ b/drivers/media/video/gspca/stk014.c | |||
@@ -23,8 +23,8 @@ | |||
23 | #include "gspca.h" | 23 | #include "gspca.h" |
24 | #include "jpeg.h" | 24 | #include "jpeg.h" |
25 | 25 | ||
26 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5) | 26 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7) |
27 | static const char version[] = "2.1.5"; | 27 | static const char version[] = "2.1.7"; |
28 | 28 | ||
29 | MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); | 29 | MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); |
30 | MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver"); | 30 | MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver"); |
@@ -127,7 +127,7 @@ static struct v4l2_pix_format vga_mode[] = { | |||
127 | 127 | ||
128 | /* -- read a register -- */ | 128 | /* -- read a register -- */ |
129 | static int reg_r(struct gspca_dev *gspca_dev, | 129 | static int reg_r(struct gspca_dev *gspca_dev, |
130 | __u16 index, __u8 *buf) | 130 | __u16 index) |
131 | { | 131 | { |
132 | struct usb_device *dev = gspca_dev->dev; | 132 | struct usb_device *dev = gspca_dev->dev; |
133 | int ret; | 133 | int ret; |
@@ -137,11 +137,13 @@ static int reg_r(struct gspca_dev *gspca_dev, | |||
137 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 137 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
138 | 0x00, | 138 | 0x00, |
139 | index, | 139 | index, |
140 | buf, 1, | 140 | gspca_dev->usb_buf, 1, |
141 | 500); | 141 | 500); |
142 | if (ret < 0) | 142 | if (ret < 0) { |
143 | PDEBUG(D_ERR, "reg_r err %d", ret); | 143 | PDEBUG(D_ERR, "reg_r err %d", ret); |
144 | return ret; | 144 | return ret; |
145 | } | ||
146 | return gspca_dev->usb_buf[0]; | ||
145 | } | 147 | } |
146 | 148 | ||
147 | /* -- write a register -- */ | 149 | /* -- write a register -- */ |
@@ -164,58 +166,55 @@ static int reg_w(struct gspca_dev *gspca_dev, | |||
164 | return ret; | 166 | return ret; |
165 | } | 167 | } |
166 | 168 | ||
167 | /* -- get a value -- */ | 169 | /* -- get a bulk value (4 bytes) -- */ |
168 | static int rcv_val(struct gspca_dev *gspca_dev, | 170 | static int rcv_val(struct gspca_dev *gspca_dev, |
169 | int ads, | 171 | int ads) |
170 | int len) | ||
171 | { | 172 | { |
172 | struct usb_device *dev = gspca_dev->dev; | 173 | struct usb_device *dev = gspca_dev->dev; |
173 | int alen, ret; | 174 | int alen, ret; |
174 | unsigned char bulk_buf[4]; | ||
175 | 175 | ||
176 | reg_w(gspca_dev, 0x634, (ads >> 16) & 0xff); | 176 | reg_w(gspca_dev, 0x634, (ads >> 16) & 0xff); |
177 | reg_w(gspca_dev, 0x635, (ads >> 8) & 0xff); | 177 | reg_w(gspca_dev, 0x635, (ads >> 8) & 0xff); |
178 | reg_w(gspca_dev, 0x636, ads & 0xff); | 178 | reg_w(gspca_dev, 0x636, ads & 0xff); |
179 | reg_w(gspca_dev, 0x637, 0); | 179 | reg_w(gspca_dev, 0x637, 0); |
180 | reg_w(gspca_dev, 0x638, len & 0xff); | 180 | reg_w(gspca_dev, 0x638, 4); /* len & 0xff */ |
181 | reg_w(gspca_dev, 0x639, len >> 8); | 181 | reg_w(gspca_dev, 0x639, 0); /* len >> 8 */ |
182 | reg_w(gspca_dev, 0x63a, 0); | 182 | reg_w(gspca_dev, 0x63a, 0); |
183 | reg_w(gspca_dev, 0x63b, 0); | 183 | reg_w(gspca_dev, 0x63b, 0); |
184 | reg_w(gspca_dev, 0x630, 5); | 184 | reg_w(gspca_dev, 0x630, 5); |
185 | if (len > sizeof bulk_buf) | ||
186 | return -1; | ||
187 | ret = usb_bulk_msg(dev, | 185 | ret = usb_bulk_msg(dev, |
188 | usb_rcvbulkpipe(dev, 5), | 186 | usb_rcvbulkpipe(dev, 5), |
189 | bulk_buf, | 187 | gspca_dev->usb_buf, |
190 | len, | 188 | 4, /* length */ |
191 | &alen, | 189 | &alen, |
192 | 500); /* timeout in milliseconds */ | 190 | 500); /* timeout in milliseconds */ |
193 | return ret; | 191 | return ret; |
194 | } | 192 | } |
195 | 193 | ||
196 | /* -- send a value -- */ | 194 | /* -- send a bulk value -- */ |
197 | static int snd_val(struct gspca_dev *gspca_dev, | 195 | static int snd_val(struct gspca_dev *gspca_dev, |
198 | int ads, | 196 | int ads, |
199 | unsigned int val) | 197 | unsigned int val) |
200 | { | 198 | { |
201 | struct usb_device *dev = gspca_dev->dev; | 199 | struct usb_device *dev = gspca_dev->dev; |
202 | int alen, ret; | 200 | int alen, ret; |
203 | __u8 value, seq; | 201 | __u8 seq = 0; |
204 | unsigned char bulk_buf[4]; | ||
205 | 202 | ||
206 | if (ads == 0x003f08) { | 203 | if (ads == 0x003f08) { |
207 | ret = reg_r(gspca_dev, 0x0704, &value); | 204 | ret = reg_r(gspca_dev, 0x0704); |
208 | if (ret < 0) | 205 | if (ret < 0) |
209 | goto ko; | 206 | goto ko; |
210 | ret = reg_r(gspca_dev, 0x0705, &seq); | 207 | ret = reg_r(gspca_dev, 0x0705); |
211 | if (ret < 0) | 208 | if (ret < 0) |
212 | goto ko; | 209 | goto ko; |
213 | ret = reg_r(gspca_dev, 0x0650, &value); | 210 | seq = ret; /* keep the sequence number */ |
211 | ret = reg_r(gspca_dev, 0x0650); | ||
214 | if (ret < 0) | 212 | if (ret < 0) |
215 | goto ko; | 213 | goto ko; |
216 | reg_w(gspca_dev, 0x654, seq); | 214 | reg_w(gspca_dev, 0x654, seq); |
217 | } else | 215 | } else { |
218 | reg_w(gspca_dev, 0x654, (ads >> 16) & 0xff); | 216 | reg_w(gspca_dev, 0x654, (ads >> 16) & 0xff); |
217 | } | ||
219 | reg_w(gspca_dev, 0x655, (ads >> 8) & 0xff); | 218 | reg_w(gspca_dev, 0x655, (ads >> 8) & 0xff); |
220 | reg_w(gspca_dev, 0x656, ads & 0xff); | 219 | reg_w(gspca_dev, 0x656, ads & 0xff); |
221 | reg_w(gspca_dev, 0x657, 0); | 220 | reg_w(gspca_dev, 0x657, 0); |
@@ -224,13 +223,13 @@ static int snd_val(struct gspca_dev *gspca_dev, | |||
224 | reg_w(gspca_dev, 0x65a, 0); | 223 | reg_w(gspca_dev, 0x65a, 0); |
225 | reg_w(gspca_dev, 0x65b, 0); | 224 | reg_w(gspca_dev, 0x65b, 0); |
226 | reg_w(gspca_dev, 0x650, 5); | 225 | reg_w(gspca_dev, 0x650, 5); |
227 | bulk_buf[0] = (val >> 24) & 0xff; | 226 | gspca_dev->usb_buf[0] = val >> 24; |
228 | bulk_buf[1] = (val >> 16) & 0xff; | 227 | gspca_dev->usb_buf[1] = val >> 16; |
229 | bulk_buf[2] = (val >> 8) & 0xff; | 228 | gspca_dev->usb_buf[2] = val >> 8; |
230 | bulk_buf[3] = val & 0xff; | 229 | gspca_dev->usb_buf[3] = val; |
231 | ret = usb_bulk_msg(dev, | 230 | ret = usb_bulk_msg(dev, |
232 | usb_sndbulkpipe(dev, 6), | 231 | usb_sndbulkpipe(dev, 6), |
233 | bulk_buf, | 232 | gspca_dev->usb_buf, |
234 | 4, | 233 | 4, |
235 | &alen, | 234 | &alen, |
236 | 500); /* timeout in milliseconds */ | 235 | 500); /* timeout in milliseconds */ |
@@ -303,7 +302,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
303 | cam->dev_name = (char *) id->driver_info; | 302 | cam->dev_name = (char *) id->driver_info; |
304 | cam->epaddr = 0x02; | 303 | cam->epaddr = 0x02; |
305 | gspca_dev->cam.cam_mode = vga_mode; | 304 | gspca_dev->cam.cam_mode = vga_mode; |
306 | gspca_dev->cam.nmodes = sizeof vga_mode / sizeof vga_mode[0]; | 305 | gspca_dev->cam.nmodes = ARRAY_SIZE(vga_mode); |
307 | sd->brightness = BRIGHTNESS_DEF; | 306 | sd->brightness = BRIGHTNESS_DEF; |
308 | sd->contrast = CONTRAST_DEF; | 307 | sd->contrast = CONTRAST_DEF; |
309 | sd->colors = COLOR_DEF; | 308 | sd->colors = COLOR_DEF; |
@@ -314,16 +313,15 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
314 | /* this function is called at open time */ | 313 | /* this function is called at open time */ |
315 | static int sd_open(struct gspca_dev *gspca_dev) | 314 | static int sd_open(struct gspca_dev *gspca_dev) |
316 | { | 315 | { |
317 | __u8 value; | ||
318 | int ret; | 316 | int ret; |
319 | 317 | ||
320 | /* check if the device responds */ | 318 | /* check if the device responds */ |
321 | usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1); | 319 | usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1); |
322 | ret = reg_r(gspca_dev, 0x0740, &value); | 320 | ret = reg_r(gspca_dev, 0x0740); |
323 | if (ret < 0) | 321 | if (ret < 0) |
324 | return ret; | 322 | return ret; |
325 | if (value != 0xff) { | 323 | if (ret != 0xff) { |
326 | PDEBUG(D_ERR|D_STREAM, "init reg: 0x%02x", value); | 324 | PDEBUG(D_ERR|D_STREAM, "init reg: 0x%02x", ret); |
327 | return -1; | 325 | return -1; |
328 | } | 326 | } |
329 | return 0; | 327 | return 0; |
@@ -332,7 +330,6 @@ static int sd_open(struct gspca_dev *gspca_dev) | |||
332 | /* -- start the camera -- */ | 330 | /* -- start the camera -- */ |
333 | static void sd_start(struct gspca_dev *gspca_dev) | 331 | static void sd_start(struct gspca_dev *gspca_dev) |
334 | { | 332 | { |
335 | __u8 dum; | ||
336 | int ret, value; | 333 | int ret, value; |
337 | 334 | ||
338 | /* work on alternate 1 */ | 335 | /* work on alternate 1 */ |
@@ -355,11 +352,11 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
355 | gspca_dev->iface, gspca_dev->alt); | 352 | gspca_dev->iface, gspca_dev->alt); |
356 | goto out; | 353 | goto out; |
357 | } | 354 | } |
358 | ret = reg_r(gspca_dev, 0x0630, &dum); | 355 | ret = reg_r(gspca_dev, 0x0630); |
359 | if (ret < 0) | 356 | if (ret < 0) |
360 | goto out; | 357 | goto out; |
361 | rcv_val(gspca_dev, 0x000020, 4); /* << (value ff ff ff ff) */ | 358 | rcv_val(gspca_dev, 0x000020); /* << (value ff ff ff ff) */ |
362 | ret = reg_r(gspca_dev, 0x0650, &dum); | 359 | ret = reg_r(gspca_dev, 0x0650); |
363 | if (ret < 0) | 360 | if (ret < 0) |
364 | goto out; | 361 | goto out; |
365 | snd_val(gspca_dev, 0x000020, 0xffffffff); | 362 | snd_val(gspca_dev, 0x000020, 0xffffffff); |
@@ -389,14 +386,13 @@ out: | |||
389 | static void sd_stopN(struct gspca_dev *gspca_dev) | 386 | static void sd_stopN(struct gspca_dev *gspca_dev) |
390 | { | 387 | { |
391 | struct usb_device *dev = gspca_dev->dev; | 388 | struct usb_device *dev = gspca_dev->dev; |
392 | __u8 value; | ||
393 | 389 | ||
394 | set_par(gspca_dev, 0x02000000); | 390 | set_par(gspca_dev, 0x02000000); |
395 | set_par(gspca_dev, 0x02000000); | 391 | set_par(gspca_dev, 0x02000000); |
396 | usb_set_interface(dev, gspca_dev->iface, 1); | 392 | usb_set_interface(dev, gspca_dev->iface, 1); |
397 | reg_r(gspca_dev, 0x0630, &value); | 393 | reg_r(gspca_dev, 0x0630); |
398 | rcv_val(gspca_dev, 0x000020, 4); /* << (value ff ff ff ff) */ | 394 | rcv_val(gspca_dev, 0x000020); /* << (value ff ff ff ff) */ |
399 | reg_r(gspca_dev, 0x0650, &value); | 395 | reg_r(gspca_dev, 0x0650); |
400 | snd_val(gspca_dev, 0x000020, 0xffffffff); | 396 | snd_val(gspca_dev, 0x000020, 0xffffffff); |
401 | reg_w(gspca_dev, 0x0620, 0); | 397 | reg_w(gspca_dev, 0x0620, 0); |
402 | reg_w(gspca_dev, 0x0630, 0); | 398 | reg_w(gspca_dev, 0x0630, 0); |
@@ -538,10 +534,10 @@ static int sd_querymenu(struct gspca_dev *gspca_dev, | |||
538 | } | 534 | } |
539 | 535 | ||
540 | /* sub-driver description */ | 536 | /* sub-driver description */ |
541 | static struct sd_desc sd_desc = { | 537 | static const struct sd_desc sd_desc = { |
542 | .name = MODULE_NAME, | 538 | .name = MODULE_NAME, |
543 | .ctrls = sd_ctrls, | 539 | .ctrls = sd_ctrls, |
544 | .nctrls = sizeof sd_ctrls / sizeof sd_ctrls[0], | 540 | .nctrls = ARRAY_SIZE(sd_ctrls), |
545 | .config = sd_config, | 541 | .config = sd_config, |
546 | .open = sd_open, | 542 | .open = sd_open, |
547 | .start = sd_start, | 543 | .start = sd_start, |
@@ -554,7 +550,7 @@ static struct sd_desc sd_desc = { | |||
554 | 550 | ||
555 | /* -- module initialisation -- */ | 551 | /* -- module initialisation -- */ |
556 | #define DVNM(name) .driver_info = (kernel_ulong_t) name | 552 | #define DVNM(name) .driver_info = (kernel_ulong_t) name |
557 | static __devinitdata struct usb_device_id device_table[] = { | 553 | static const __devinitdata struct usb_device_id device_table[] = { |
558 | {USB_DEVICE(0x05e1, 0x0893), DVNM("Syntek DV4000")}, | 554 | {USB_DEVICE(0x05e1, 0x0893), DVNM("Syntek DV4000")}, |
559 | {} | 555 | {} |
560 | }; | 556 | }; |