stv06xx.c 17 KB

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