stv06xx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. * P/N 861037: Sensor HDCS1000 ASIC STV0600
  22. * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
  23. * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
  24. * P/N 861055: Sensor ST VV6410 ASIC STV0610 - LEGO cam
  25. * P/N 861075-0040: Sensor HDCS1000 ASIC
  26. * P/N 961179-0700: Sensor ST VV6410 ASIC STV0602 - Dexxa WebCam USB
  27. * P/N 861040-0000: Sensor ST VV6410 ASIC STV0610 - QuickCam Web
  28. */
  29. #include <linux/input.h>
  30. #include "stv06xx_sensor.h"
  31. MODULE_AUTHOR("Erik Andrén");
  32. MODULE_DESCRIPTION("STV06XX USB Camera Driver");
  33. MODULE_LICENSE("GPL");
  34. static int dump_bridge;
  35. static int dump_sensor;
  36. int stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data)
  37. {
  38. int err;
  39. struct usb_device *udev = sd->gspca_dev.dev;
  40. __u8 *buf = sd->gspca_dev.usb_buf;
  41. u8 len = (i2c_data > 0xff) ? 2 : 1;
  42. buf[0] = i2c_data & 0xff;
  43. buf[1] = (i2c_data >> 8) & 0xff;
  44. err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  45. 0x04, 0x40, address, 0, buf, len,
  46. STV06XX_URB_MSG_TIMEOUT);
  47. PDEBUG(D_CONF, "Written 0x%x to address 0x%x, status: %d",
  48. i2c_data, address, err);
  49. return (err < 0) ? err : 0;
  50. }
  51. int stv06xx_read_bridge(struct sd *sd, u16 address, u8 *i2c_data)
  52. {
  53. int err;
  54. struct usb_device *udev = sd->gspca_dev.dev;
  55. __u8 *buf = sd->gspca_dev.usb_buf;
  56. err = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
  57. 0x04, 0xc0, address, 0, buf, 1,
  58. STV06XX_URB_MSG_TIMEOUT);
  59. *i2c_data = buf[0];
  60. PDEBUG(D_CONF, "Reading 0x%x from address 0x%x, status %d",
  61. *i2c_data, address, err);
  62. return (err < 0) ? err : 0;
  63. }
  64. /* Wraps the normal write sensor bytes / words functions for writing a
  65. single value */
  66. int stv06xx_write_sensor(struct sd *sd, u8 address, u16 value)
  67. {
  68. if (sd->sensor->i2c_len == 2) {
  69. u16 data[2] = { address, value };
  70. return stv06xx_write_sensor_words(sd, data, 1);
  71. } else {
  72. u8 data[2] = { address, value };
  73. return stv06xx_write_sensor_bytes(sd, data, 1);
  74. }
  75. }
  76. static int stv06xx_write_sensor_finish(struct sd *sd)
  77. {
  78. int err = 0;
  79. if (sd->bridge == BRIDGE_STV610) {
  80. struct usb_device *udev = sd->gspca_dev.dev;
  81. __u8 *buf = sd->gspca_dev.usb_buf;
  82. buf[0] = 0;
  83. err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  84. 0x04, 0x40, 0x1704, 0, buf, 1,
  85. STV06XX_URB_MSG_TIMEOUT);
  86. }
  87. return (err < 0) ? err : 0;
  88. }
  89. int stv06xx_write_sensor_bytes(struct sd *sd, const u8 *data, u8 len)
  90. {
  91. int err, i, j;
  92. struct usb_device *udev = sd->gspca_dev.dev;
  93. __u8 *buf = sd->gspca_dev.usb_buf;
  94. PDEBUG(D_CONF, "I2C: Command buffer contains %d entries", len);
  95. for (i = 0; i < len;) {
  96. /* Build the command buffer */
  97. memset(buf, 0, I2C_BUFFER_LENGTH);
  98. for (j = 0; j < I2C_MAX_BYTES && i < len; j++, i++) {
  99. buf[j] = data[2*i];
  100. buf[0x10 + j] = data[2*i+1];
  101. PDEBUG(D_CONF, "I2C: Writing 0x%02x to reg 0x%02x",
  102. data[2*i+1], data[2*i]);
  103. }
  104. buf[0x20] = sd->sensor->i2c_addr;
  105. buf[0x21] = j - 1; /* Number of commands to send - 1 */
  106. buf[0x22] = I2C_WRITE_CMD;
  107. err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  108. 0x04, 0x40, 0x0400, 0, buf,
  109. I2C_BUFFER_LENGTH,
  110. STV06XX_URB_MSG_TIMEOUT);
  111. if (err < 0)
  112. return err;
  113. }
  114. return stv06xx_write_sensor_finish(sd);
  115. }
  116. int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len)
  117. {
  118. int err, i, j;
  119. struct usb_device *udev = sd->gspca_dev.dev;
  120. __u8 *buf = sd->gspca_dev.usb_buf;
  121. PDEBUG(D_CONF, "I2C: Command buffer contains %d entries", len);
  122. for (i = 0; i < len;) {
  123. /* Build the command buffer */
  124. memset(buf, 0, I2C_BUFFER_LENGTH);
  125. for (j = 0; j < I2C_MAX_WORDS && i < len; j++, i++) {
  126. buf[j] = data[2*i];
  127. buf[0x10 + j * 2] = data[2*i+1];
  128. buf[0x10 + j * 2 + 1] = data[2*i+1] >> 8;
  129. PDEBUG(D_CONF, "I2C: Writing 0x%04x to reg 0x%02x",
  130. data[2*i+1], data[2*i]);
  131. }
  132. buf[0x20] = sd->sensor->i2c_addr;
  133. buf[0x21] = j - 1; /* Number of commands to send - 1 */
  134. buf[0x22] = I2C_WRITE_CMD;
  135. err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  136. 0x04, 0x40, 0x0400, 0, buf,
  137. I2C_BUFFER_LENGTH,
  138. STV06XX_URB_MSG_TIMEOUT);
  139. if (err < 0)
  140. return err;
  141. }
  142. return stv06xx_write_sensor_finish(sd);
  143. }
  144. int stv06xx_read_sensor(struct sd *sd, const u8 address, u16 *value)
  145. {
  146. int err;
  147. struct usb_device *udev = sd->gspca_dev.dev;
  148. __u8 *buf = sd->gspca_dev.usb_buf;
  149. err = stv06xx_write_bridge(sd, STV_I2C_FLUSH, sd->sensor->i2c_flush);
  150. if (err < 0)
  151. return err;
  152. /* Clear mem */
  153. memset(buf, 0, I2C_BUFFER_LENGTH);
  154. buf[0] = address;
  155. buf[0x20] = sd->sensor->i2c_addr;
  156. buf[0x21] = 0;
  157. /* Read I2C register */
  158. buf[0x22] = I2C_READ_CMD;
  159. err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  160. 0x04, 0x40, 0x1400, 0, buf, I2C_BUFFER_LENGTH,
  161. STV06XX_URB_MSG_TIMEOUT);
  162. if (err < 0) {
  163. err("I2C: Read error writing address: %d", err);
  164. return err;
  165. }
  166. err = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
  167. 0x04, 0xc0, 0x1410, 0, buf, sd->sensor->i2c_len,
  168. STV06XX_URB_MSG_TIMEOUT);
  169. if (sd->sensor->i2c_len == 2)
  170. *value = buf[0] | (buf[1] << 8);
  171. else
  172. *value = buf[0];
  173. PDEBUG(D_CONF, "I2C: Read 0x%x from address 0x%x, status: %d",
  174. *value, address, err);
  175. return (err < 0) ? err : 0;
  176. }
  177. /* Dumps all bridge registers */
  178. static void stv06xx_dump_bridge(struct sd *sd)
  179. {
  180. int i;
  181. u8 data, buf;
  182. info("Dumping all stv06xx bridge registers");
  183. for (i = 0x1400; i < 0x160f; i++) {
  184. stv06xx_read_bridge(sd, i, &data);
  185. info("Read 0x%x from address 0x%x", data, i);
  186. }
  187. info("Testing stv06xx bridge registers for writability");
  188. for (i = 0x1400; i < 0x160f; i++) {
  189. stv06xx_read_bridge(sd, i, &data);
  190. buf = data;
  191. stv06xx_write_bridge(sd, i, 0xff);
  192. stv06xx_read_bridge(sd, i, &data);
  193. if (data == 0xff)
  194. info("Register 0x%x is read/write", i);
  195. else if (data != buf)
  196. info("Register 0x%x is read/write,"
  197. " but only partially", i);
  198. else
  199. info("Register 0x%x is read-only", i);
  200. stv06xx_write_bridge(sd, i, buf);
  201. }
  202. }
  203. /* this function is called at probe and resume time */
  204. static int stv06xx_init(struct gspca_dev *gspca_dev)
  205. {
  206. struct sd *sd = (struct sd *) gspca_dev;
  207. int err;
  208. PDEBUG(D_PROBE, "Initializing camera");
  209. /* Let the usb init settle for a bit
  210. before performing the initialization */
  211. msleep(250);
  212. err = sd->sensor->init(sd);
  213. if (dump_sensor && sd->sensor->dump)
  214. sd->sensor->dump(sd);
  215. return (err < 0) ? err : 0;
  216. }
  217. /* Start the camera */
  218. static int stv06xx_start(struct gspca_dev *gspca_dev)
  219. {
  220. struct sd *sd = (struct sd *) gspca_dev;
  221. struct usb_host_interface *alt;
  222. struct usb_interface *intf;
  223. int err, packet_size;
  224. intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
  225. alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
  226. if (!alt) {
  227. PDEBUG(D_ERR, "Couldn't get altsetting");
  228. return -EIO;
  229. }
  230. packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
  231. err = stv06xx_write_bridge(sd, STV_ISO_SIZE_L, packet_size);
  232. if (err < 0)
  233. return err;
  234. /* Prepare the sensor for start */
  235. err = sd->sensor->start(sd);
  236. if (err < 0)
  237. goto out;
  238. /* Start isochronous streaming */
  239. err = stv06xx_write_bridge(sd, STV_ISO_ENABLE, 1);
  240. out:
  241. if (err < 0)
  242. PDEBUG(D_STREAM, "Starting stream failed");
  243. else
  244. PDEBUG(D_STREAM, "Started streaming");
  245. return (err < 0) ? err : 0;
  246. }
  247. static int stv06xx_isoc_init(struct gspca_dev *gspca_dev)
  248. {
  249. struct usb_host_interface *alt;
  250. struct sd *sd = (struct sd *) gspca_dev;
  251. /* Start isoc bandwidth "negotiation" at max isoc bandwidth */
  252. alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1];
  253. alt->endpoint[0].desc.wMaxPacketSize =
  254. cpu_to_le16(sd->sensor->max_packet_size[gspca_dev->curr_mode]);
  255. return 0;
  256. }
  257. static int stv06xx_isoc_nego(struct gspca_dev *gspca_dev)
  258. {
  259. int ret, packet_size, min_packet_size;
  260. struct usb_host_interface *alt;
  261. struct sd *sd = (struct sd *) gspca_dev;
  262. alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1];
  263. packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
  264. min_packet_size = sd->sensor->min_packet_size[gspca_dev->curr_mode];
  265. if (packet_size <= min_packet_size)
  266. return -EIO;
  267. packet_size -= 100;
  268. if (packet_size < min_packet_size)
  269. packet_size = min_packet_size;
  270. alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(packet_size);
  271. ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1);
  272. if (ret < 0)
  273. PDEBUG(D_ERR|D_STREAM, "set alt 1 err %d", ret);
  274. return ret;
  275. }
  276. static void stv06xx_stopN(struct gspca_dev *gspca_dev)
  277. {
  278. int err;
  279. struct sd *sd = (struct sd *) gspca_dev;
  280. /* stop ISO-streaming */
  281. err = stv06xx_write_bridge(sd, STV_ISO_ENABLE, 0);
  282. if (err < 0)
  283. goto out;
  284. err = sd->sensor->stop(sd);
  285. out:
  286. if (err < 0)
  287. PDEBUG(D_STREAM, "Failed to stop stream");
  288. else
  289. PDEBUG(D_STREAM, "Stopped streaming");
  290. }
  291. /*
  292. * Analyse an USB packet of the data stream and store it appropriately.
  293. * Each packet contains an integral number of chunks. Each chunk has
  294. * 2-bytes identification, followed by 2-bytes that describe the chunk
  295. * length. Known/guessed chunk identifications are:
  296. * 8001/8005/C001/C005 - Begin new frame
  297. * 8002/8006/C002/C006 - End frame
  298. * 0200/4200 - Contains actual image data, bayer or compressed
  299. * 0005 - 11 bytes of unknown data
  300. * 0100 - 2 bytes of unknown data
  301. * The 0005 and 0100 chunks seem to appear only in compressed stream.
  302. */
  303. static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev,
  304. u8 *data, /* isoc packet */
  305. int len) /* iso packet length */
  306. {
  307. struct sd *sd = (struct sd *) gspca_dev;
  308. PDEBUG(D_PACK, "Packet of length %d arrived", len);
  309. /* A packet may contain several frames
  310. loop until the whole packet is reached */
  311. while (len) {
  312. int id, chunk_len;
  313. if (len < 4) {
  314. PDEBUG(D_PACK, "Packet is smaller than 4 bytes");
  315. return;
  316. }
  317. /* Capture the id */
  318. id = (data[0] << 8) | data[1];
  319. /* Capture the chunk length */
  320. chunk_len = (data[2] << 8) | data[3];
  321. PDEBUG(D_PACK, "Chunk id: %x, length: %d", id, chunk_len);
  322. data += 4;
  323. len -= 4;
  324. if (len < chunk_len) {
  325. PDEBUG(D_ERR, "URB packet length is smaller"
  326. " than the specified chunk length");
  327. gspca_dev->last_packet_type = DISCARD_PACKET;
  328. return;
  329. }
  330. /* First byte seem to be 02=data 2nd byte is unknown??? */
  331. if (sd->bridge == BRIDGE_ST6422 && (id & 0xff00) == 0x0200)
  332. goto frame_data;
  333. switch (id) {
  334. case 0x0200:
  335. case 0x4200:
  336. frame_data:
  337. PDEBUG(D_PACK, "Frame data packet detected");
  338. if (sd->to_skip) {
  339. int skip = (sd->to_skip < chunk_len) ?
  340. sd->to_skip : chunk_len;
  341. data += skip;
  342. len -= skip;
  343. chunk_len -= skip;
  344. sd->to_skip -= skip;
  345. }
  346. gspca_frame_add(gspca_dev, INTER_PACKET,
  347. data, chunk_len);
  348. break;
  349. case 0x8001:
  350. case 0x8005:
  351. case 0xc001:
  352. case 0xc005:
  353. PDEBUG(D_PACK, "Starting new frame");
  354. /* Create a new frame, chunk length should be zero */
  355. gspca_frame_add(gspca_dev, FIRST_PACKET,
  356. NULL, 0);
  357. if (sd->bridge == BRIDGE_ST6422)
  358. sd->to_skip = gspca_dev->width * 4;
  359. if (chunk_len)
  360. PDEBUG(D_ERR, "Chunk length is "
  361. "non-zero on a SOF");
  362. break;
  363. case 0x8002:
  364. case 0x8006:
  365. case 0xc002:
  366. PDEBUG(D_PACK, "End of frame detected");
  367. /* Complete the last frame (if any) */
  368. gspca_frame_add(gspca_dev, LAST_PACKET,
  369. NULL, 0);
  370. if (chunk_len)
  371. PDEBUG(D_ERR, "Chunk length is "
  372. "non-zero on a EOF");
  373. break;
  374. case 0x0005:
  375. PDEBUG(D_PACK, "Chunk 0x005 detected");
  376. /* Unknown chunk with 11 bytes of data,
  377. occurs just before end of each frame
  378. in compressed mode */
  379. break;
  380. case 0x0100:
  381. PDEBUG(D_PACK, "Chunk 0x0100 detected");
  382. /* Unknown chunk with 2 bytes of data,
  383. occurs 2-3 times per USB interrupt */
  384. break;
  385. case 0x42ff:
  386. PDEBUG(D_PACK, "Chunk 0x42ff detected");
  387. /* Special chunk seen sometimes on the ST6422 */
  388. break;
  389. default:
  390. PDEBUG(D_PACK, "Unknown chunk 0x%04x detected", id);
  391. /* Unknown chunk */
  392. }
  393. data += chunk_len;
  394. len -= chunk_len;
  395. }
  396. }
  397. #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
  398. static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
  399. u8 *data, /* interrupt packet data */
  400. int len) /* interrupt packet length */
  401. {
  402. int ret = -EINVAL;
  403. if (len == 1 && data[0] == 0x80) {
  404. input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
  405. input_sync(gspca_dev->input_dev);
  406. ret = 0;
  407. }
  408. if (len == 1 && data[0] == 0x88) {
  409. input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
  410. input_sync(gspca_dev->input_dev);
  411. ret = 0;
  412. }
  413. return ret;
  414. }
  415. #endif
  416. static int stv06xx_config(struct gspca_dev *gspca_dev,
  417. const struct usb_device_id *id);
  418. /* sub-driver description */
  419. static const struct sd_desc sd_desc = {
  420. .name = MODULE_NAME,
  421. .config = stv06xx_config,
  422. .init = stv06xx_init,
  423. .start = stv06xx_start,
  424. .stopN = stv06xx_stopN,
  425. .pkt_scan = stv06xx_pkt_scan,
  426. .isoc_init = stv06xx_isoc_init,
  427. .isoc_nego = stv06xx_isoc_nego,
  428. #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
  429. .int_pkt_scan = sd_int_pkt_scan,
  430. #endif
  431. };
  432. /* This function is called at probe time */
  433. static int stv06xx_config(struct gspca_dev *gspca_dev,
  434. const struct usb_device_id *id)
  435. {
  436. struct sd *sd = (struct sd *) gspca_dev;
  437. struct cam *cam;
  438. PDEBUG(D_PROBE, "Configuring camera");
  439. cam = &gspca_dev->cam;
  440. sd->desc = sd_desc;
  441. sd->bridge = id->driver_info;
  442. gspca_dev->sd_desc = &sd->desc;
  443. if (dump_bridge)
  444. stv06xx_dump_bridge(sd);
  445. sd->sensor = &stv06xx_sensor_st6422;
  446. if (!sd->sensor->probe(sd))
  447. return 0;
  448. sd->sensor = &stv06xx_sensor_vv6410;
  449. if (!sd->sensor->probe(sd))
  450. return 0;
  451. sd->sensor = &stv06xx_sensor_hdcs1x00;
  452. if (!sd->sensor->probe(sd))
  453. return 0;
  454. sd->sensor = &stv06xx_sensor_hdcs1020;
  455. if (!sd->sensor->probe(sd))
  456. return 0;
  457. sd->sensor = &stv06xx_sensor_pb0100;
  458. if (!sd->sensor->probe(sd))
  459. return 0;
  460. sd->sensor = NULL;
  461. return -ENODEV;
  462. }
  463. /* -- module initialisation -- */
  464. static const struct usb_device_id device_table[] = {
  465. /* QuickCam Express */
  466. {USB_DEVICE(0x046d, 0x0840), .driver_info = BRIDGE_STV600 },
  467. /* LEGO cam / QuickCam Web */
  468. {USB_DEVICE(0x046d, 0x0850), .driver_info = BRIDGE_STV610 },
  469. /* Dexxa WebCam USB */
  470. {USB_DEVICE(0x046d, 0x0870), .driver_info = BRIDGE_STV602 },
  471. /* QuickCam Messenger */
  472. {USB_DEVICE(0x046D, 0x08F0), .driver_info = BRIDGE_ST6422 },
  473. /* QuickCam Communicate */
  474. {USB_DEVICE(0x046D, 0x08F5), .driver_info = BRIDGE_ST6422 },
  475. /* QuickCam Messenger (new) */
  476. {USB_DEVICE(0x046D, 0x08F6), .driver_info = BRIDGE_ST6422 },
  477. {}
  478. };
  479. MODULE_DEVICE_TABLE(usb, device_table);
  480. /* -- device connect -- */
  481. static int sd_probe(struct usb_interface *intf,
  482. const struct usb_device_id *id)
  483. {
  484. PDEBUG(D_PROBE, "Probing for a stv06xx device");
  485. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  486. THIS_MODULE);
  487. }
  488. static void sd_disconnect(struct usb_interface *intf)
  489. {
  490. struct gspca_dev *gspca_dev = usb_get_intfdata(intf);
  491. struct sd *sd = (struct sd *) gspca_dev;
  492. PDEBUG(D_PROBE, "Disconnecting the stv06xx device");
  493. if (sd->sensor->disconnect)
  494. sd->sensor->disconnect(sd);
  495. gspca_disconnect(intf);
  496. }
  497. static struct usb_driver sd_driver = {
  498. .name = MODULE_NAME,
  499. .id_table = device_table,
  500. .probe = sd_probe,
  501. .disconnect = sd_disconnect,
  502. #ifdef CONFIG_PM
  503. .suspend = gspca_suspend,
  504. .resume = gspca_resume,
  505. #endif
  506. };
  507. /* -- module insert / remove -- */
  508. static int __init sd_mod_init(void)
  509. {
  510. return usb_register(&sd_driver);
  511. }
  512. static void __exit sd_mod_exit(void)
  513. {
  514. usb_deregister(&sd_driver);
  515. }
  516. module_init(sd_mod_init);
  517. module_exit(sd_mod_exit);
  518. module_param(dump_bridge, bool, S_IRUGO | S_IWUSR);
  519. MODULE_PARM_DESC(dump_bridge, "Dumps all usb bridge registers at startup");
  520. module_param(dump_sensor, bool, S_IRUGO | S_IWUSR);
  521. MODULE_PARM_DESC(dump_sensor, "Dumps all sensor registers at startup");