stv06xx.c 16 KB

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