• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher
3  *		      Mark Cave-Ayland, Carlo E Prelz, Dick Streefland
4  * Copyright (c) 2002, 2003 Tuukka Toivonen
5  * Copyright (c) 2008 Erik Andrén
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * P/N 861037:      Sensor HDCS1000        ASIC STV0600
18  * P/N 861050-0010: Sensor HDCS1000        ASIC STV0600
19  * P/N 861050-0020: Sensor Photobit PB100  ASIC STV0600-1 - QuickCam Express
20  * P/N 861055:      Sensor ST VV6410       ASIC STV0610   - LEGO cam
21  * P/N 861075-0040: Sensor HDCS1000        ASIC
22  * P/N 961179-0700: Sensor ST VV6410       ASIC STV0602   - Dexxa WebCam USB
23  * P/N 861040-0000: Sensor ST VV6410       ASIC STV0610   - QuickCam Web
24  */
25 
26 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27 
28 #include <linux/input.h>
29 #include "stv06xx_sensor.h"
30 
31 MODULE_AUTHOR("Erik Andrén");
32 MODULE_DESCRIPTION("STV06XX USB Camera Driver");
33 MODULE_LICENSE("GPL");
34 
35 static bool dump_bridge;
36 static bool dump_sensor;
37 
stv06xx_write_bridge(struct sd * sd,u16 address,u16 i2c_data)38 int stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data)
39 {
40 	int err;
41 	struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
42 	struct usb_device *udev = sd->gspca_dev.dev;
43 	__u8 *buf = sd->gspca_dev.usb_buf;
44 
45 	u8 len = (i2c_data > 0xff) ? 2 : 1;
46 
47 	buf[0] = i2c_data & 0xff;
48 	buf[1] = (i2c_data >> 8) & 0xff;
49 
50 	err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
51 			      0x04, 0x40, address, 0, buf, len,
52 			      STV06XX_URB_MSG_TIMEOUT);
53 
54 	PDEBUG(D_CONF, "Written 0x%x to address 0x%x, status: %d",
55 	       i2c_data, address, err);
56 
57 	return (err < 0) ? err : 0;
58 }
59 
stv06xx_read_bridge(struct sd * sd,u16 address,u8 * i2c_data)60 int stv06xx_read_bridge(struct sd *sd, u16 address, u8 *i2c_data)
61 {
62 	int err;
63 	struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
64 	struct usb_device *udev = sd->gspca_dev.dev;
65 	__u8 *buf = sd->gspca_dev.usb_buf;
66 
67 	err = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
68 			      0x04, 0xc0, address, 0, buf, 1,
69 			      STV06XX_URB_MSG_TIMEOUT);
70 
71 	*i2c_data = buf[0];
72 
73 	PDEBUG(D_CONF, "Reading 0x%x from address 0x%x, status %d",
74 	       *i2c_data, address, err);
75 
76 	return (err < 0) ? err : 0;
77 }
78 
79 /* Wraps the normal write sensor bytes / words functions for writing a
80    single value */
stv06xx_write_sensor(struct sd * sd,u8 address,u16 value)81 int stv06xx_write_sensor(struct sd *sd, u8 address, u16 value)
82 {
83 	if (sd->sensor->i2c_len == 2) {
84 		u16 data[2] = { address, value };
85 		return stv06xx_write_sensor_words(sd, data, 1);
86 	} else {
87 		u8 data[2] = { address, value };
88 		return stv06xx_write_sensor_bytes(sd, data, 1);
89 	}
90 }
91 
stv06xx_write_sensor_finish(struct sd * sd)92 static int stv06xx_write_sensor_finish(struct sd *sd)
93 {
94 	int err = 0;
95 
96 	if (sd->bridge == BRIDGE_STV610) {
97 		struct usb_device *udev = sd->gspca_dev.dev;
98 		__u8 *buf = sd->gspca_dev.usb_buf;
99 
100 		buf[0] = 0;
101 		err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
102 				      0x04, 0x40, 0x1704, 0, buf, 1,
103 				      STV06XX_URB_MSG_TIMEOUT);
104 	}
105 
106 	return (err < 0) ? err : 0;
107 }
108 
stv06xx_write_sensor_bytes(struct sd * sd,const u8 * data,u8 len)109 int stv06xx_write_sensor_bytes(struct sd *sd, const u8 *data, u8 len)
110 {
111 	int err, i, j;
112 	struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
113 	struct usb_device *udev = sd->gspca_dev.dev;
114 	__u8 *buf = sd->gspca_dev.usb_buf;
115 
116 	PDEBUG(D_CONF, "I2C: Command buffer contains %d entries", len);
117 	for (i = 0; i < len;) {
118 		/* Build the command buffer */
119 		memset(buf, 0, I2C_BUFFER_LENGTH);
120 		for (j = 0; j < I2C_MAX_BYTES && i < len; j++, i++) {
121 			buf[j] = data[2*i];
122 			buf[0x10 + j] = data[2*i+1];
123 			PDEBUG(D_CONF, "I2C: Writing 0x%02x to reg 0x%02x",
124 			data[2*i+1], data[2*i]);
125 		}
126 		buf[0x20] = sd->sensor->i2c_addr;
127 		buf[0x21] = j - 1; /* Number of commands to send - 1 */
128 		buf[0x22] = I2C_WRITE_CMD;
129 		err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
130 				      0x04, 0x40, 0x0400, 0, buf,
131 				      I2C_BUFFER_LENGTH,
132 				      STV06XX_URB_MSG_TIMEOUT);
133 		if (err < 0)
134 			return err;
135 	}
136 	return stv06xx_write_sensor_finish(sd);
137 }
138 
stv06xx_write_sensor_words(struct sd * sd,const u16 * data,u8 len)139 int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len)
140 {
141 	int err, i, j;
142 	struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
143 	struct usb_device *udev = sd->gspca_dev.dev;
144 	__u8 *buf = sd->gspca_dev.usb_buf;
145 
146 	PDEBUG(D_CONF, "I2C: Command buffer contains %d entries", len);
147 
148 	for (i = 0; i < len;) {
149 		/* Build the command buffer */
150 		memset(buf, 0, I2C_BUFFER_LENGTH);
151 		for (j = 0; j < I2C_MAX_WORDS && i < len; j++, i++) {
152 			buf[j] = data[2*i];
153 			buf[0x10 + j * 2] = data[2*i+1];
154 			buf[0x10 + j * 2 + 1] = data[2*i+1] >> 8;
155 			PDEBUG(D_CONF, "I2C: Writing 0x%04x to reg 0x%02x",
156 				data[2*i+1], data[2*i]);
157 		}
158 		buf[0x20] = sd->sensor->i2c_addr;
159 		buf[0x21] = j - 1; /* Number of commands to send - 1 */
160 		buf[0x22] = I2C_WRITE_CMD;
161 		err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
162 				0x04, 0x40, 0x0400, 0, buf,
163 				I2C_BUFFER_LENGTH,
164 				STV06XX_URB_MSG_TIMEOUT);
165 		if (err < 0)
166 			return err;
167 	}
168 	return stv06xx_write_sensor_finish(sd);
169 }
170 
stv06xx_read_sensor(struct sd * sd,const u8 address,u16 * value)171 int stv06xx_read_sensor(struct sd *sd, const u8 address, u16 *value)
172 {
173 	int err;
174 	struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
175 	struct usb_device *udev = sd->gspca_dev.dev;
176 	__u8 *buf = sd->gspca_dev.usb_buf;
177 
178 	err = stv06xx_write_bridge(sd, STV_I2C_FLUSH, sd->sensor->i2c_flush);
179 	if (err < 0)
180 		return err;
181 
182 	/* Clear mem */
183 	memset(buf, 0, I2C_BUFFER_LENGTH);
184 
185 	buf[0] = address;
186 	buf[0x20] = sd->sensor->i2c_addr;
187 	buf[0x21] = 0;
188 
189 	/* Read I2C register */
190 	buf[0x22] = I2C_READ_CMD;
191 
192 	err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
193 			      0x04, 0x40, 0x1400, 0, buf, I2C_BUFFER_LENGTH,
194 			      STV06XX_URB_MSG_TIMEOUT);
195 	if (err < 0) {
196 		pr_err("I2C: Read error writing address: %d\n", err);
197 		return err;
198 	}
199 
200 	err = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
201 			      0x04, 0xc0, 0x1410, 0, buf, sd->sensor->i2c_len,
202 			      STV06XX_URB_MSG_TIMEOUT);
203 	if (sd->sensor->i2c_len == 2)
204 		*value = buf[0] | (buf[1] << 8);
205 	else
206 		*value = buf[0];
207 
208 	PDEBUG(D_CONF, "I2C: Read 0x%x from address 0x%x, status: %d",
209 	       *value, address, err);
210 
211 	return (err < 0) ? err : 0;
212 }
213 
214 /* Dumps all bridge registers */
stv06xx_dump_bridge(struct sd * sd)215 static void stv06xx_dump_bridge(struct sd *sd)
216 {
217 	int i;
218 	u8 data, buf;
219 
220 	pr_info("Dumping all stv06xx bridge registers\n");
221 	for (i = 0x1400; i < 0x160f; i++) {
222 		stv06xx_read_bridge(sd, i, &data);
223 
224 		pr_info("Read 0x%x from address 0x%x\n", data, i);
225 	}
226 
227 	pr_info("Testing stv06xx bridge registers for writability\n");
228 	for (i = 0x1400; i < 0x160f; i++) {
229 		stv06xx_read_bridge(sd, i, &data);
230 		buf = data;
231 
232 		stv06xx_write_bridge(sd, i, 0xff);
233 		stv06xx_read_bridge(sd, i, &data);
234 		if (data == 0xff)
235 			pr_info("Register 0x%x is read/write\n", i);
236 		else if (data != buf)
237 			pr_info("Register 0x%x is read/write, but only partially\n",
238 				i);
239 		else
240 			pr_info("Register 0x%x is read-only\n", i);
241 
242 		stv06xx_write_bridge(sd, i, buf);
243 	}
244 }
245 
246 /* this function is called at probe and resume time */
stv06xx_init(struct gspca_dev * gspca_dev)247 static int stv06xx_init(struct gspca_dev *gspca_dev)
248 {
249 	struct sd *sd = (struct sd *) gspca_dev;
250 	int err;
251 
252 	PDEBUG(D_PROBE, "Initializing camera");
253 
254 	/* Let the usb init settle for a bit
255 	   before performing the initialization */
256 	msleep(250);
257 
258 	err = sd->sensor->init(sd);
259 
260 	if (dump_sensor && sd->sensor->dump)
261 		sd->sensor->dump(sd);
262 
263 	return (err < 0) ? err : 0;
264 }
265 
266 /* this function is called at probe time */
stv06xx_init_controls(struct gspca_dev * gspca_dev)267 static int stv06xx_init_controls(struct gspca_dev *gspca_dev)
268 {
269 	struct sd *sd = (struct sd *) gspca_dev;
270 
271 	PDEBUG(D_PROBE, "Initializing controls");
272 
273 	gspca_dev->vdev.ctrl_handler = &gspca_dev->ctrl_handler;
274 	return sd->sensor->init_controls(sd);
275 }
276 
277 /* Start the camera */
stv06xx_start(struct gspca_dev * gspca_dev)278 static int stv06xx_start(struct gspca_dev *gspca_dev)
279 {
280 	struct sd *sd = (struct sd *) gspca_dev;
281 	struct usb_host_interface *alt;
282 	struct usb_interface *intf;
283 	int err, packet_size;
284 
285 	intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
286 	alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
287 	if (!alt) {
288 		PERR("Couldn't get altsetting");
289 		return -EIO;
290 	}
291 
292 	if (alt->desc.bNumEndpoints < 1)
293 		return -ENODEV;
294 
295 	packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
296 	err = stv06xx_write_bridge(sd, STV_ISO_SIZE_L, packet_size);
297 	if (err < 0)
298 		return err;
299 
300 	/* Prepare the sensor for start */
301 	err = sd->sensor->start(sd);
302 	if (err < 0)
303 		goto out;
304 
305 	/* Start isochronous streaming */
306 	err = stv06xx_write_bridge(sd, STV_ISO_ENABLE, 1);
307 
308 out:
309 	if (err < 0)
310 		PDEBUG(D_STREAM, "Starting stream failed");
311 	else
312 		PDEBUG(D_STREAM, "Started streaming");
313 
314 	return (err < 0) ? err : 0;
315 }
316 
stv06xx_isoc_init(struct gspca_dev * gspca_dev)317 static int stv06xx_isoc_init(struct gspca_dev *gspca_dev)
318 {
319 	struct usb_interface_cache *intfc;
320 	struct usb_host_interface *alt;
321 	struct sd *sd = (struct sd *) gspca_dev;
322 
323 	intfc = gspca_dev->dev->actconfig->intf_cache[0];
324 
325 	if (intfc->num_altsetting < 2)
326 		return -ENODEV;
327 
328 	alt = &intfc->altsetting[1];
329 
330 	if (alt->desc.bNumEndpoints < 1)
331 		return -ENODEV;
332 
333 	/* Start isoc bandwidth "negotiation" at max isoc bandwidth */
334 	alt->endpoint[0].desc.wMaxPacketSize =
335 		cpu_to_le16(sd->sensor->max_packet_size[gspca_dev->curr_mode]);
336 
337 	return 0;
338 }
339 
stv06xx_isoc_nego(struct gspca_dev * gspca_dev)340 static int stv06xx_isoc_nego(struct gspca_dev *gspca_dev)
341 {
342 	int ret, packet_size, min_packet_size;
343 	struct usb_host_interface *alt;
344 	struct sd *sd = (struct sd *) gspca_dev;
345 
346 	/*
347 	 * Existence of altsetting and endpoint was verified in
348 	 * stv06xx_isoc_init()
349 	 */
350 	alt = &gspca_dev->dev->actconfig->intf_cache[0]->altsetting[1];
351 	packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
352 	min_packet_size = sd->sensor->min_packet_size[gspca_dev->curr_mode];
353 	if (packet_size <= min_packet_size)
354 		return -EIO;
355 
356 	packet_size -= 100;
357 	if (packet_size < min_packet_size)
358 		packet_size = min_packet_size;
359 	alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(packet_size);
360 
361 	ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1);
362 	if (ret < 0)
363 		PERR("set alt 1 err %d", ret);
364 
365 	return ret;
366 }
367 
stv06xx_stopN(struct gspca_dev * gspca_dev)368 static void stv06xx_stopN(struct gspca_dev *gspca_dev)
369 {
370 	int err;
371 	struct sd *sd = (struct sd *) gspca_dev;
372 
373 	/* stop ISO-streaming */
374 	err = stv06xx_write_bridge(sd, STV_ISO_ENABLE, 0);
375 	if (err < 0)
376 		goto out;
377 
378 	err = sd->sensor->stop(sd);
379 
380 out:
381 	if (err < 0)
382 		PDEBUG(D_STREAM, "Failed to stop stream");
383 	else
384 		PDEBUG(D_STREAM, "Stopped streaming");
385 }
386 
387 /*
388  * Analyse an USB packet of the data stream and store it appropriately.
389  * Each packet contains an integral number of chunks. Each chunk has
390  * 2-bytes identification, followed by 2-bytes that describe the chunk
391  * length. Known/guessed chunk identifications are:
392  * 8001/8005/C001/C005 - Begin new frame
393  * 8002/8006/C002/C006 - End frame
394  * 0200/4200           - Contains actual image data, bayer or compressed
395  * 0005                - 11 bytes of unknown data
396  * 0100                - 2 bytes of unknown data
397  * The 0005 and 0100 chunks seem to appear only in compressed stream.
398  */
stv06xx_pkt_scan(struct gspca_dev * gspca_dev,u8 * data,int len)399 static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev,
400 			u8 *data,			/* isoc packet */
401 			int len)			/* iso packet length */
402 {
403 	struct sd *sd = (struct sd *) gspca_dev;
404 
405 	PDEBUG(D_PACK, "Packet of length %d arrived", len);
406 
407 	/* A packet may contain several frames
408 	   loop until the whole packet is reached */
409 	while (len) {
410 		int id, chunk_len;
411 
412 		if (len < 4) {
413 			PDEBUG(D_PACK, "Packet is smaller than 4 bytes");
414 			return;
415 		}
416 
417 		/* Capture the id */
418 		id = (data[0] << 8) | data[1];
419 
420 		/* Capture the chunk length */
421 		chunk_len = (data[2] << 8) | data[3];
422 		PDEBUG(D_PACK, "Chunk id: %x, length: %d", id, chunk_len);
423 
424 		data += 4;
425 		len -= 4;
426 
427 		if (len < chunk_len) {
428 			PERR("URB packet length is smaller than the specified chunk length");
429 			gspca_dev->last_packet_type = DISCARD_PACKET;
430 			return;
431 		}
432 
433 		/* First byte seem to be 02=data 2nd byte is unknown??? */
434 		if (sd->bridge == BRIDGE_ST6422 && (id & 0xff00) == 0x0200)
435 			goto frame_data;
436 
437 		switch (id) {
438 		case 0x0200:
439 		case 0x4200:
440 frame_data:
441 			PDEBUG(D_PACK, "Frame data packet detected");
442 
443 			if (sd->to_skip) {
444 				int skip = (sd->to_skip < chunk_len) ?
445 					    sd->to_skip : chunk_len;
446 				data += skip;
447 				len -= skip;
448 				chunk_len -= skip;
449 				sd->to_skip -= skip;
450 			}
451 
452 			gspca_frame_add(gspca_dev, INTER_PACKET,
453 					data, chunk_len);
454 			break;
455 
456 		case 0x8001:
457 		case 0x8005:
458 		case 0xc001:
459 		case 0xc005:
460 			PDEBUG(D_PACK, "Starting new frame");
461 
462 			/* Create a new frame, chunk length should be zero */
463 			gspca_frame_add(gspca_dev, FIRST_PACKET,
464 					NULL, 0);
465 
466 			if (sd->bridge == BRIDGE_ST6422)
467 				sd->to_skip = gspca_dev->pixfmt.width * 4;
468 
469 			if (chunk_len)
470 				PERR("Chunk length is non-zero on a SOF");
471 			break;
472 
473 		case 0x8002:
474 		case 0x8006:
475 		case 0xc002:
476 			PDEBUG(D_PACK, "End of frame detected");
477 
478 			/* Complete the last frame (if any) */
479 			gspca_frame_add(gspca_dev, LAST_PACKET,
480 					NULL, 0);
481 
482 			if (chunk_len)
483 				PERR("Chunk length is non-zero on a EOF");
484 			break;
485 
486 		case 0x0005:
487 			PDEBUG(D_PACK, "Chunk 0x005 detected");
488 			/* Unknown chunk with 11 bytes of data,
489 			   occurs just before end of each frame
490 			   in compressed mode */
491 			break;
492 
493 		case 0x0100:
494 			PDEBUG(D_PACK, "Chunk 0x0100 detected");
495 			/* Unknown chunk with 2 bytes of data,
496 			   occurs 2-3 times per USB interrupt */
497 			break;
498 		case 0x42ff:
499 			PDEBUG(D_PACK, "Chunk 0x42ff detected");
500 			/* Special chunk seen sometimes on the ST6422 */
501 			break;
502 		default:
503 			PDEBUG(D_PACK, "Unknown chunk 0x%04x detected", id);
504 			/* Unknown chunk */
505 		}
506 		data    += chunk_len;
507 		len     -= chunk_len;
508 	}
509 }
510 
511 #if IS_ENABLED(CONFIG_INPUT)
sd_int_pkt_scan(struct gspca_dev * gspca_dev,u8 * data,int len)512 static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
513 			u8 *data,		/* interrupt packet data */
514 			int len)		/* interrupt packet length */
515 {
516 	int ret = -EINVAL;
517 
518 	if (len == 1 && (data[0] == 0x80 || data[0] == 0x10)) {
519 		input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
520 		input_sync(gspca_dev->input_dev);
521 		ret = 0;
522 	}
523 
524 	if (len == 1 && (data[0] == 0x88 || data[0] == 0x11)) {
525 		input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
526 		input_sync(gspca_dev->input_dev);
527 		ret = 0;
528 	}
529 
530 	return ret;
531 }
532 #endif
533 
534 static int stv06xx_config(struct gspca_dev *gspca_dev,
535 			  const struct usb_device_id *id);
536 
537 /* sub-driver description */
538 static const struct sd_desc sd_desc = {
539 	.name = MODULE_NAME,
540 	.config = stv06xx_config,
541 	.init = stv06xx_init,
542 	.init_controls = stv06xx_init_controls,
543 	.start = stv06xx_start,
544 	.stopN = stv06xx_stopN,
545 	.pkt_scan = stv06xx_pkt_scan,
546 	.isoc_init = stv06xx_isoc_init,
547 	.isoc_nego = stv06xx_isoc_nego,
548 #if IS_ENABLED(CONFIG_INPUT)
549 	.int_pkt_scan = sd_int_pkt_scan,
550 #endif
551 };
552 
553 /* This function is called at probe time */
stv06xx_config(struct gspca_dev * gspca_dev,const struct usb_device_id * id)554 static int stv06xx_config(struct gspca_dev *gspca_dev,
555 			  const struct usb_device_id *id)
556 {
557 	struct sd *sd = (struct sd *) gspca_dev;
558 
559 	PDEBUG(D_PROBE, "Configuring camera");
560 
561 	sd->bridge = id->driver_info;
562 	gspca_dev->sd_desc = &sd_desc;
563 
564 	if (dump_bridge)
565 		stv06xx_dump_bridge(sd);
566 
567 	sd->sensor = &stv06xx_sensor_st6422;
568 	if (!sd->sensor->probe(sd))
569 		return 0;
570 
571 	sd->sensor = &stv06xx_sensor_vv6410;
572 	if (!sd->sensor->probe(sd))
573 		return 0;
574 
575 	sd->sensor = &stv06xx_sensor_hdcs1x00;
576 	if (!sd->sensor->probe(sd))
577 		return 0;
578 
579 	sd->sensor = &stv06xx_sensor_hdcs1020;
580 	if (!sd->sensor->probe(sd))
581 		return 0;
582 
583 	sd->sensor = &stv06xx_sensor_pb0100;
584 	if (!sd->sensor->probe(sd))
585 		return 0;
586 
587 	sd->sensor = NULL;
588 	return -ENODEV;
589 }
590 
591 
592 
593 /* -- module initialisation -- */
594 static const struct usb_device_id device_table[] = {
595 	{USB_DEVICE(0x046d, 0x0840), .driver_info = BRIDGE_STV600 }, 	/* QuickCam Express */
596 	{USB_DEVICE(0x046d, 0x0850), .driver_info = BRIDGE_STV610 },	/* LEGO cam / QuickCam Web */
597 	{USB_DEVICE(0x046d, 0x0870), .driver_info = BRIDGE_STV602 },	/* Dexxa WebCam USB */
598 	{USB_DEVICE(0x046D, 0x08F0), .driver_info = BRIDGE_ST6422 },	/* QuickCam Messenger */
599 	{USB_DEVICE(0x046D, 0x08F5), .driver_info = BRIDGE_ST6422 },	/* QuickCam Communicate */
600 	{USB_DEVICE(0x046D, 0x08F6), .driver_info = BRIDGE_ST6422 },	/* QuickCam Messenger (new) */
601 	{}
602 };
603 MODULE_DEVICE_TABLE(usb, device_table);
604 
605 /* -- device connect -- */
sd_probe(struct usb_interface * intf,const struct usb_device_id * id)606 static int sd_probe(struct usb_interface *intf,
607 			const struct usb_device_id *id)
608 {
609 	return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
610 			       THIS_MODULE);
611 }
612 
sd_disconnect(struct usb_interface * intf)613 static void sd_disconnect(struct usb_interface *intf)
614 {
615 	struct gspca_dev *gspca_dev = usb_get_intfdata(intf);
616 	struct sd *sd = (struct sd *) gspca_dev;
617 	void *priv = sd->sensor_priv;
618 	PDEBUG(D_PROBE, "Disconnecting the stv06xx device");
619 
620 	sd->sensor = NULL;
621 	gspca_disconnect(intf);
622 	kfree(priv);
623 }
624 
625 static struct usb_driver sd_driver = {
626 	.name = MODULE_NAME,
627 	.id_table = device_table,
628 	.probe = sd_probe,
629 	.disconnect = sd_disconnect,
630 #ifdef CONFIG_PM
631 	.suspend = gspca_suspend,
632 	.resume = gspca_resume,
633 	.reset_resume = gspca_resume,
634 #endif
635 };
636 
637 module_usb_driver(sd_driver);
638 
639 module_param(dump_bridge, bool, S_IRUGO | S_IWUSR);
640 MODULE_PARM_DESC(dump_bridge, "Dumps all usb bridge registers at startup");
641 
642 module_param(dump_sensor, bool, S_IRUGO | S_IWUSR);
643 MODULE_PARM_DESC(dump_sensor, "Dumps all sensor registers at startup");
644