sunplus.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. /*
  2. * Sunplus spca504(abc) spca533 spca536 library
  3. * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
  4. *
  5. * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
  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. * 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. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  22. #define MODULE_NAME "sunplus"
  23. #include "gspca.h"
  24. #include "jpeg.h"
  25. MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
  26. MODULE_DESCRIPTION("GSPCA/SPCA5xx USB Camera Driver");
  27. MODULE_LICENSE("GPL");
  28. #define QUALITY 85
  29. /* specific webcam descriptor */
  30. struct sd {
  31. struct gspca_dev gspca_dev; /* !! must be the first item */
  32. bool autogain;
  33. u8 bridge;
  34. #define BRIDGE_SPCA504 0
  35. #define BRIDGE_SPCA504B 1
  36. #define BRIDGE_SPCA504C 2
  37. #define BRIDGE_SPCA533 3
  38. #define BRIDGE_SPCA536 4
  39. u8 subtype;
  40. #define AiptekMiniPenCam13 1
  41. #define LogitechClickSmart420 2
  42. #define LogitechClickSmart820 3
  43. #define MegapixV4 4
  44. #define MegaImageVI 5
  45. u8 jpeg_hdr[JPEG_HDR_SZ];
  46. };
  47. static const struct v4l2_pix_format vga_mode[] = {
  48. {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  49. .bytesperline = 320,
  50. .sizeimage = 320 * 240 * 3 / 8 + 590,
  51. .colorspace = V4L2_COLORSPACE_JPEG,
  52. .priv = 2},
  53. {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  54. .bytesperline = 640,
  55. .sizeimage = 640 * 480 * 3 / 8 + 590,
  56. .colorspace = V4L2_COLORSPACE_JPEG,
  57. .priv = 1},
  58. };
  59. static const struct v4l2_pix_format custom_mode[] = {
  60. {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  61. .bytesperline = 320,
  62. .sizeimage = 320 * 240 * 3 / 8 + 590,
  63. .colorspace = V4L2_COLORSPACE_JPEG,
  64. .priv = 2},
  65. {464, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  66. .bytesperline = 464,
  67. .sizeimage = 464 * 480 * 3 / 8 + 590,
  68. .colorspace = V4L2_COLORSPACE_JPEG,
  69. .priv = 1},
  70. };
  71. static const struct v4l2_pix_format vga_mode2[] = {
  72. {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  73. .bytesperline = 176,
  74. .sizeimage = 176 * 144 * 3 / 8 + 590,
  75. .colorspace = V4L2_COLORSPACE_JPEG,
  76. .priv = 4},
  77. {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  78. .bytesperline = 320,
  79. .sizeimage = 320 * 240 * 3 / 8 + 590,
  80. .colorspace = V4L2_COLORSPACE_JPEG,
  81. .priv = 3},
  82. {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  83. .bytesperline = 352,
  84. .sizeimage = 352 * 288 * 3 / 8 + 590,
  85. .colorspace = V4L2_COLORSPACE_JPEG,
  86. .priv = 2},
  87. {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  88. .bytesperline = 640,
  89. .sizeimage = 640 * 480 * 3 / 8 + 590,
  90. .colorspace = V4L2_COLORSPACE_JPEG,
  91. .priv = 1},
  92. };
  93. #define SPCA50X_OFFSET_DATA 10
  94. #define SPCA504_PCCAM600_OFFSET_SNAPSHOT 3
  95. #define SPCA504_PCCAM600_OFFSET_COMPRESS 4
  96. #define SPCA504_PCCAM600_OFFSET_MODE 5
  97. #define SPCA504_PCCAM600_OFFSET_DATA 14
  98. /* Frame packet header offsets for the spca533 */
  99. #define SPCA533_OFFSET_DATA 16
  100. #define SPCA533_OFFSET_FRAMSEQ 15
  101. /* Frame packet header offsets for the spca536 */
  102. #define SPCA536_OFFSET_DATA 4
  103. #define SPCA536_OFFSET_FRAMSEQ 1
  104. struct cmd {
  105. u8 req;
  106. u16 val;
  107. u16 idx;
  108. };
  109. /* Initialisation data for the Creative PC-CAM 600 */
  110. static const struct cmd spca504_pccam600_init_data[] = {
  111. /* {0xa0, 0x0000, 0x0503}, * capture mode */
  112. {0x00, 0x0000, 0x2000},
  113. {0x00, 0x0013, 0x2301},
  114. {0x00, 0x0003, 0x2000},
  115. {0x00, 0x0001, 0x21ac},
  116. {0x00, 0x0001, 0x21a6},
  117. {0x00, 0x0000, 0x21a7}, /* brightness */
  118. {0x00, 0x0020, 0x21a8}, /* contrast */
  119. {0x00, 0x0001, 0x21ac}, /* sat/hue */
  120. {0x00, 0x0000, 0x21ad}, /* hue */
  121. {0x00, 0x001a, 0x21ae}, /* saturation */
  122. {0x00, 0x0002, 0x21a3}, /* gamma */
  123. {0x30, 0x0154, 0x0008},
  124. {0x30, 0x0004, 0x0006},
  125. {0x30, 0x0258, 0x0009},
  126. {0x30, 0x0004, 0x0000},
  127. {0x30, 0x0093, 0x0004},
  128. {0x30, 0x0066, 0x0005},
  129. {0x00, 0x0000, 0x2000},
  130. {0x00, 0x0013, 0x2301},
  131. {0x00, 0x0003, 0x2000},
  132. {0x00, 0x0013, 0x2301},
  133. {0x00, 0x0003, 0x2000},
  134. };
  135. /* Creative PC-CAM 600 specific open data, sent before using the
  136. * generic initialisation data from spca504_open_data.
  137. */
  138. static const struct cmd spca504_pccam600_open_data[] = {
  139. {0x00, 0x0001, 0x2501},
  140. {0x20, 0x0500, 0x0001}, /* snapshot mode */
  141. {0x00, 0x0003, 0x2880},
  142. {0x00, 0x0001, 0x2881},
  143. };
  144. /* Initialisation data for the logitech clicksmart 420 */
  145. static const struct cmd spca504A_clicksmart420_init_data[] = {
  146. /* {0xa0, 0x0000, 0x0503}, * capture mode */
  147. {0x00, 0x0000, 0x2000},
  148. {0x00, 0x0013, 0x2301},
  149. {0x00, 0x0003, 0x2000},
  150. {0x00, 0x0001, 0x21ac},
  151. {0x00, 0x0001, 0x21a6},
  152. {0x00, 0x0000, 0x21a7}, /* brightness */
  153. {0x00, 0x0020, 0x21a8}, /* contrast */
  154. {0x00, 0x0001, 0x21ac}, /* sat/hue */
  155. {0x00, 0x0000, 0x21ad}, /* hue */
  156. {0x00, 0x001a, 0x21ae}, /* saturation */
  157. {0x00, 0x0002, 0x21a3}, /* gamma */
  158. {0x30, 0x0004, 0x000a},
  159. {0xb0, 0x0001, 0x0000},
  160. {0xa1, 0x0080, 0x0001},
  161. {0x30, 0x0049, 0x0000},
  162. {0x30, 0x0060, 0x0005},
  163. {0x0c, 0x0004, 0x0000},
  164. {0x00, 0x0000, 0x0000},
  165. {0x00, 0x0000, 0x2000},
  166. {0x00, 0x0013, 0x2301},
  167. {0x00, 0x0003, 0x2000},
  168. };
  169. /* clicksmart 420 open data ? */
  170. static const struct cmd spca504A_clicksmart420_open_data[] = {
  171. {0x00, 0x0001, 0x2501},
  172. {0x20, 0x0502, 0x0000},
  173. {0x06, 0x0000, 0x0000},
  174. {0x00, 0x0004, 0x2880},
  175. {0x00, 0x0001, 0x2881},
  176. {0xa0, 0x0000, 0x0503},
  177. };
  178. static const u8 qtable_creative_pccam[2][64] = {
  179. { /* Q-table Y-components */
  180. 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
  181. 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
  182. 0x04, 0x04, 0x05, 0x07, 0x0c, 0x11, 0x15, 0x11,
  183. 0x04, 0x05, 0x07, 0x09, 0x0f, 0x1a, 0x18, 0x13,
  184. 0x05, 0x07, 0x0b, 0x11, 0x14, 0x21, 0x1f, 0x17,
  185. 0x07, 0x0b, 0x11, 0x13, 0x18, 0x1f, 0x22, 0x1c,
  186. 0x0f, 0x13, 0x17, 0x1a, 0x1f, 0x24, 0x24, 0x1e,
  187. 0x16, 0x1c, 0x1d, 0x1d, 0x22, 0x1e, 0x1f, 0x1e},
  188. { /* Q-table C-components */
  189. 0x05, 0x05, 0x07, 0x0e, 0x1e, 0x1e, 0x1e, 0x1e,
  190. 0x05, 0x06, 0x08, 0x14, 0x1e, 0x1e, 0x1e, 0x1e,
  191. 0x07, 0x08, 0x11, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  192. 0x0e, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  193. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  194. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  195. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  196. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}
  197. };
  198. /* FIXME: This Q-table is identical to the Creative PC-CAM one,
  199. * except for one byte. Possibly a typo?
  200. * NWG: 18/05/2003.
  201. */
  202. static const u8 qtable_spca504_default[2][64] = {
  203. { /* Q-table Y-components */
  204. 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
  205. 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
  206. 0x04, 0x04, 0x05, 0x07, 0x0c, 0x11, 0x15, 0x11,
  207. 0x04, 0x05, 0x07, 0x09, 0x0f, 0x1a, 0x18, 0x13,
  208. 0x05, 0x07, 0x0b, 0x11, 0x14, 0x21, 0x1f, 0x17,
  209. 0x07, 0x0b, 0x11, 0x13, 0x18, 0x1f, 0x22, 0x1c,
  210. 0x0f, 0x13, 0x17, 0x1a, 0x1f, 0x24, 0x24, 0x1e,
  211. 0x16, 0x1c, 0x1d, 0x1d, 0x1d /* 0x22 */ , 0x1e, 0x1f, 0x1e,
  212. },
  213. { /* Q-table C-components */
  214. 0x05, 0x05, 0x07, 0x0e, 0x1e, 0x1e, 0x1e, 0x1e,
  215. 0x05, 0x06, 0x08, 0x14, 0x1e, 0x1e, 0x1e, 0x1e,
  216. 0x07, 0x08, 0x11, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  217. 0x0e, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  218. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  219. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  220. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
  221. 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}
  222. };
  223. /* read <len> bytes to gspca_dev->usb_buf */
  224. static void reg_r(struct gspca_dev *gspca_dev,
  225. u8 req,
  226. u16 index,
  227. u16 len)
  228. {
  229. int ret;
  230. if (len > USB_BUF_SZ) {
  231. PERR("reg_r: buffer overflow\n");
  232. return;
  233. }
  234. if (gspca_dev->usb_err < 0)
  235. return;
  236. ret = usb_control_msg(gspca_dev->dev,
  237. usb_rcvctrlpipe(gspca_dev->dev, 0),
  238. req,
  239. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  240. 0, /* value */
  241. index,
  242. len ? gspca_dev->usb_buf : NULL, len,
  243. 500);
  244. if (ret < 0) {
  245. pr_err("reg_r err %d\n", ret);
  246. gspca_dev->usb_err = ret;
  247. }
  248. }
  249. /* write one byte */
  250. static void reg_w_1(struct gspca_dev *gspca_dev,
  251. u8 req,
  252. u16 value,
  253. u16 index,
  254. u16 byte)
  255. {
  256. int ret;
  257. if (gspca_dev->usb_err < 0)
  258. return;
  259. gspca_dev->usb_buf[0] = byte;
  260. ret = usb_control_msg(gspca_dev->dev,
  261. usb_sndctrlpipe(gspca_dev->dev, 0),
  262. req,
  263. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  264. value, index,
  265. gspca_dev->usb_buf, 1,
  266. 500);
  267. if (ret < 0) {
  268. pr_err("reg_w_1 err %d\n", ret);
  269. gspca_dev->usb_err = ret;
  270. }
  271. }
  272. /* write req / index / value */
  273. static void reg_w_riv(struct gspca_dev *gspca_dev,
  274. u8 req, u16 index, u16 value)
  275. {
  276. struct usb_device *dev = gspca_dev->dev;
  277. int ret;
  278. if (gspca_dev->usb_err < 0)
  279. return;
  280. ret = usb_control_msg(dev,
  281. usb_sndctrlpipe(dev, 0),
  282. req,
  283. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  284. value, index, NULL, 0, 500);
  285. if (ret < 0) {
  286. pr_err("reg_w_riv err %d\n", ret);
  287. gspca_dev->usb_err = ret;
  288. return;
  289. }
  290. PDEBUG(D_USBO, "reg_w_riv: 0x%02x,0x%04x:0x%04x",
  291. req, index, value);
  292. }
  293. static void write_vector(struct gspca_dev *gspca_dev,
  294. const struct cmd *data, int ncmds)
  295. {
  296. while (--ncmds >= 0) {
  297. reg_w_riv(gspca_dev, data->req, data->idx, data->val);
  298. data++;
  299. }
  300. }
  301. static void setup_qtable(struct gspca_dev *gspca_dev,
  302. const u8 qtable[2][64])
  303. {
  304. int i;
  305. /* loop over y components */
  306. for (i = 0; i < 64; i++)
  307. reg_w_riv(gspca_dev, 0x00, 0x2800 + i, qtable[0][i]);
  308. /* loop over c components */
  309. for (i = 0; i < 64; i++)
  310. reg_w_riv(gspca_dev, 0x00, 0x2840 + i, qtable[1][i]);
  311. }
  312. static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
  313. u8 req, u16 idx, u16 val)
  314. {
  315. reg_w_riv(gspca_dev, req, idx, val);
  316. reg_r(gspca_dev, 0x01, 0x0001, 1);
  317. PDEBUG(D_FRAM, "before wait 0x%04x", gspca_dev->usb_buf[0]);
  318. reg_w_riv(gspca_dev, req, idx, val);
  319. msleep(200);
  320. reg_r(gspca_dev, 0x01, 0x0001, 1);
  321. PDEBUG(D_FRAM, "after wait 0x%04x", gspca_dev->usb_buf[0]);
  322. }
  323. static void spca504_read_info(struct gspca_dev *gspca_dev)
  324. {
  325. int i;
  326. u8 info[6];
  327. if (gspca_debug < D_STREAM)
  328. return;
  329. for (i = 0; i < 6; i++) {
  330. reg_r(gspca_dev, 0, i, 1);
  331. info[i] = gspca_dev->usb_buf[0];
  332. }
  333. PDEBUG(D_STREAM,
  334. "Read info: %d %d %d %d %d %d. Should be 1,0,2,2,0,0",
  335. info[0], info[1], info[2],
  336. info[3], info[4], info[5]);
  337. }
  338. static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
  339. u8 req,
  340. u16 idx, u16 val, u8 endcode, u8 count)
  341. {
  342. u16 status;
  343. reg_w_riv(gspca_dev, req, idx, val);
  344. reg_r(gspca_dev, 0x01, 0x0001, 1);
  345. if (gspca_dev->usb_err < 0)
  346. return;
  347. PDEBUG(D_FRAM, "Status 0x%02x Need 0x%02x",
  348. gspca_dev->usb_buf[0], endcode);
  349. if (!count)
  350. return;
  351. count = 200;
  352. while (--count > 0) {
  353. msleep(10);
  354. /* gsmart mini2 write a each wait setting 1 ms is enough */
  355. /* reg_w_riv(gspca_dev, req, idx, val); */
  356. reg_r(gspca_dev, 0x01, 0x0001, 1);
  357. status = gspca_dev->usb_buf[0];
  358. if (status == endcode) {
  359. PDEBUG(D_FRAM, "status 0x%04x after wait %d",
  360. status, 200 - count);
  361. break;
  362. }
  363. }
  364. }
  365. static void spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
  366. {
  367. int count = 10;
  368. while (--count > 0) {
  369. reg_r(gspca_dev, 0x21, 0, 1);
  370. if ((gspca_dev->usb_buf[0] & 0x01) == 0)
  371. break;
  372. msleep(10);
  373. }
  374. }
  375. static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
  376. {
  377. int count = 50;
  378. while (--count > 0) {
  379. reg_r(gspca_dev, 0x21, 1, 1);
  380. if (gspca_dev->usb_buf[0] != 0) {
  381. reg_w_1(gspca_dev, 0x21, 0, 1, 0);
  382. reg_r(gspca_dev, 0x21, 1, 1);
  383. spca504B_PollingDataReady(gspca_dev);
  384. break;
  385. }
  386. msleep(10);
  387. }
  388. }
  389. static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
  390. {
  391. u8 *data;
  392. if (gspca_debug < D_STREAM)
  393. return;
  394. data = gspca_dev->usb_buf;
  395. reg_r(gspca_dev, 0x20, 0, 5);
  396. PDEBUG(D_STREAM, "FirmWare: %d %d %d %d %d",
  397. data[0], data[1], data[2], data[3], data[4]);
  398. reg_r(gspca_dev, 0x23, 0, 64);
  399. reg_r(gspca_dev, 0x23, 1, 64);
  400. }
  401. static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
  402. {
  403. struct sd *sd = (struct sd *) gspca_dev;
  404. u8 Size;
  405. Size = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
  406. switch (sd->bridge) {
  407. case BRIDGE_SPCA533:
  408. reg_w_riv(gspca_dev, 0x31, 0, 0);
  409. spca504B_WaitCmdStatus(gspca_dev);
  410. spca504B_PollingDataReady(gspca_dev);
  411. spca50x_GetFirmware(gspca_dev);
  412. reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */
  413. reg_r(gspca_dev, 0x24, 8, 1);
  414. reg_w_1(gspca_dev, 0x25, 0, 4, Size);
  415. reg_r(gspca_dev, 0x25, 4, 1); /* size */
  416. spca504B_PollingDataReady(gspca_dev);
  417. /* Init the cam width height with some values get on init ? */
  418. reg_w_riv(gspca_dev, 0x31, 0x0004, 0x00);
  419. spca504B_WaitCmdStatus(gspca_dev);
  420. spca504B_PollingDataReady(gspca_dev);
  421. break;
  422. default:
  423. /* case BRIDGE_SPCA504B: */
  424. /* case BRIDGE_SPCA536: */
  425. reg_w_1(gspca_dev, 0x25, 0, 4, Size);
  426. reg_r(gspca_dev, 0x25, 4, 1); /* size */
  427. reg_w_1(gspca_dev, 0x27, 0, 0, 6);
  428. reg_r(gspca_dev, 0x27, 0, 1); /* type */
  429. spca504B_PollingDataReady(gspca_dev);
  430. break;
  431. case BRIDGE_SPCA504:
  432. Size += 3;
  433. if (sd->subtype == AiptekMiniPenCam13) {
  434. /* spca504a aiptek */
  435. spca504A_acknowledged_command(gspca_dev,
  436. 0x08, Size, 0,
  437. 0x80 | (Size & 0x0f), 1);
  438. spca504A_acknowledged_command(gspca_dev,
  439. 1, 3, 0, 0x9f, 0);
  440. } else {
  441. spca504_acknowledged_command(gspca_dev, 0x08, Size, 0);
  442. }
  443. break;
  444. case BRIDGE_SPCA504C:
  445. /* capture mode */
  446. reg_w_riv(gspca_dev, 0xa0, (0x0500 | (Size & 0x0f)), 0x00);
  447. reg_w_riv(gspca_dev, 0x20, 0x01, 0x0500 | (Size & 0x0f));
  448. break;
  449. }
  450. }
  451. static void spca504_wait_status(struct gspca_dev *gspca_dev)
  452. {
  453. int cnt;
  454. cnt = 256;
  455. while (--cnt > 0) {
  456. /* With this we get the status, when return 0 it's all ok */
  457. reg_r(gspca_dev, 0x06, 0x00, 1);
  458. if (gspca_dev->usb_buf[0] == 0)
  459. return;
  460. msleep(10);
  461. }
  462. }
  463. static void spca504B_setQtable(struct gspca_dev *gspca_dev)
  464. {
  465. reg_w_1(gspca_dev, 0x26, 0, 0, 3);
  466. reg_r(gspca_dev, 0x26, 0, 1);
  467. spca504B_PollingDataReady(gspca_dev);
  468. }
  469. static void setbrightness(struct gspca_dev *gspca_dev, s32 val)
  470. {
  471. struct sd *sd = (struct sd *) gspca_dev;
  472. u16 reg;
  473. reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f0 : 0x21a7;
  474. reg_w_riv(gspca_dev, 0x00, reg, val);
  475. }
  476. static void setcontrast(struct gspca_dev *gspca_dev, s32 val)
  477. {
  478. struct sd *sd = (struct sd *) gspca_dev;
  479. u16 reg;
  480. reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f1 : 0x21a8;
  481. reg_w_riv(gspca_dev, 0x00, reg, val);
  482. }
  483. static void setcolors(struct gspca_dev *gspca_dev, s32 val)
  484. {
  485. struct sd *sd = (struct sd *) gspca_dev;
  486. u16 reg;
  487. reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f6 : 0x21ae;
  488. reg_w_riv(gspca_dev, 0x00, reg, val);
  489. }
  490. static void init_ctl_reg(struct gspca_dev *gspca_dev)
  491. {
  492. struct sd *sd = (struct sd *) gspca_dev;
  493. int pollreg = 1;
  494. switch (sd->bridge) {
  495. case BRIDGE_SPCA504:
  496. case BRIDGE_SPCA504C:
  497. pollreg = 0;
  498. /* fall thru */
  499. default:
  500. /* case BRIDGE_SPCA533: */
  501. /* case BRIDGE_SPCA504B: */
  502. reg_w_riv(gspca_dev, 0, 0x21ad, 0x00); /* hue */
  503. reg_w_riv(gspca_dev, 0, 0x21ac, 0x01); /* sat/hue */
  504. reg_w_riv(gspca_dev, 0, 0x21a3, 0x00); /* gamma */
  505. break;
  506. case BRIDGE_SPCA536:
  507. reg_w_riv(gspca_dev, 0, 0x20f5, 0x40);
  508. reg_w_riv(gspca_dev, 0, 0x20f4, 0x01);
  509. reg_w_riv(gspca_dev, 0, 0x2089, 0x00);
  510. break;
  511. }
  512. if (pollreg)
  513. spca504B_PollingDataReady(gspca_dev);
  514. }
  515. /* this function is called at probe time */
  516. static int sd_config(struct gspca_dev *gspca_dev,
  517. const struct usb_device_id *id)
  518. {
  519. struct sd *sd = (struct sd *) gspca_dev;
  520. struct cam *cam;
  521. cam = &gspca_dev->cam;
  522. sd->bridge = id->driver_info >> 8;
  523. sd->subtype = id->driver_info;
  524. if (sd->subtype == AiptekMiniPenCam13) {
  525. /* try to get the firmware as some cam answer 2.0.1.2.2
  526. * and should be a spca504b then overwrite that setting */
  527. reg_r(gspca_dev, 0x20, 0, 1);
  528. switch (gspca_dev->usb_buf[0]) {
  529. case 1:
  530. break; /* (right bridge/subtype) */
  531. case 2:
  532. sd->bridge = BRIDGE_SPCA504B;
  533. sd->subtype = 0;
  534. break;
  535. default:
  536. return -ENODEV;
  537. }
  538. }
  539. switch (sd->bridge) {
  540. default:
  541. /* case BRIDGE_SPCA504B: */
  542. /* case BRIDGE_SPCA504: */
  543. /* case BRIDGE_SPCA536: */
  544. cam->cam_mode = vga_mode;
  545. cam->nmodes = ARRAY_SIZE(vga_mode);
  546. break;
  547. case BRIDGE_SPCA533:
  548. cam->cam_mode = custom_mode;
  549. if (sd->subtype == MegaImageVI) /* 320x240 only */
  550. cam->nmodes = ARRAY_SIZE(custom_mode) - 1;
  551. else
  552. cam->nmodes = ARRAY_SIZE(custom_mode);
  553. break;
  554. case BRIDGE_SPCA504C:
  555. cam->cam_mode = vga_mode2;
  556. cam->nmodes = ARRAY_SIZE(vga_mode2);
  557. break;
  558. }
  559. return 0;
  560. }
  561. /* this function is called at probe and resume time */
  562. static int sd_init(struct gspca_dev *gspca_dev)
  563. {
  564. struct sd *sd = (struct sd *) gspca_dev;
  565. switch (sd->bridge) {
  566. case BRIDGE_SPCA504B:
  567. reg_w_riv(gspca_dev, 0x1d, 0x00, 0);
  568. reg_w_riv(gspca_dev, 0x00, 0x2306, 0x01);
  569. reg_w_riv(gspca_dev, 0x00, 0x0d04, 0x00);
  570. reg_w_riv(gspca_dev, 0x00, 0x2000, 0x00);
  571. reg_w_riv(gspca_dev, 0x00, 0x2301, 0x13);
  572. reg_w_riv(gspca_dev, 0x00, 0x2306, 0x00);
  573. /* fall thru */
  574. case BRIDGE_SPCA533:
  575. spca504B_PollingDataReady(gspca_dev);
  576. spca50x_GetFirmware(gspca_dev);
  577. break;
  578. case BRIDGE_SPCA536:
  579. spca50x_GetFirmware(gspca_dev);
  580. reg_r(gspca_dev, 0x00, 0x5002, 1);
  581. reg_w_1(gspca_dev, 0x24, 0, 0, 0);
  582. reg_r(gspca_dev, 0x24, 0, 1);
  583. spca504B_PollingDataReady(gspca_dev);
  584. reg_w_riv(gspca_dev, 0x34, 0, 0);
  585. spca504B_WaitCmdStatus(gspca_dev);
  586. break;
  587. case BRIDGE_SPCA504C: /* pccam600 */
  588. PDEBUG(D_STREAM, "Opening SPCA504 (PC-CAM 600)");
  589. reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0000);
  590. reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0001); /* reset */
  591. spca504_wait_status(gspca_dev);
  592. if (sd->subtype == LogitechClickSmart420)
  593. write_vector(gspca_dev,
  594. spca504A_clicksmart420_open_data,
  595. ARRAY_SIZE(spca504A_clicksmart420_open_data));
  596. else
  597. write_vector(gspca_dev, spca504_pccam600_open_data,
  598. ARRAY_SIZE(spca504_pccam600_open_data));
  599. setup_qtable(gspca_dev, qtable_creative_pccam);
  600. break;
  601. default:
  602. /* case BRIDGE_SPCA504: */
  603. PDEBUG(D_STREAM, "Opening SPCA504");
  604. if (sd->subtype == AiptekMiniPenCam13) {
  605. spca504_read_info(gspca_dev);
  606. /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
  607. spca504A_acknowledged_command(gspca_dev, 0x24,
  608. 8, 3, 0x9e, 1);
  609. /* Twice sequential need status 0xff->0x9e->0x9d */
  610. spca504A_acknowledged_command(gspca_dev, 0x24,
  611. 8, 3, 0x9e, 0);
  612. spca504A_acknowledged_command(gspca_dev, 0x24,
  613. 0, 0, 0x9d, 1);
  614. /******************************/
  615. /* spca504a aiptek */
  616. spca504A_acknowledged_command(gspca_dev, 0x08,
  617. 6, 0, 0x86, 1);
  618. /* reg_write (dev, 0, 0x2000, 0); */
  619. /* reg_write (dev, 0, 0x2883, 1); */
  620. /* spca504A_acknowledged_command (gspca_dev, 0x08,
  621. 6, 0, 0x86, 1); */
  622. /* spca504A_acknowledged_command (gspca_dev, 0x24,
  623. 0, 0, 0x9D, 1); */
  624. reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05);
  625. /* L92 sno1t.txt */
  626. reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05);
  627. spca504A_acknowledged_command(gspca_dev, 0x01,
  628. 0x0f, 0, 0xff, 0);
  629. }
  630. /* setup qtable */
  631. reg_w_riv(gspca_dev, 0, 0x2000, 0);
  632. reg_w_riv(gspca_dev, 0, 0x2883, 1);
  633. setup_qtable(gspca_dev, qtable_spca504_default);
  634. break;
  635. }
  636. return gspca_dev->usb_err;
  637. }
  638. static int sd_start(struct gspca_dev *gspca_dev)
  639. {
  640. struct sd *sd = (struct sd *) gspca_dev;
  641. int enable;
  642. /* create the JPEG header */
  643. jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
  644. gspca_dev->pixfmt.width,
  645. 0x22); /* JPEG 411 */
  646. jpeg_set_qual(sd->jpeg_hdr, QUALITY);
  647. if (sd->bridge == BRIDGE_SPCA504B)
  648. spca504B_setQtable(gspca_dev);
  649. spca504B_SetSizeType(gspca_dev);
  650. switch (sd->bridge) {
  651. default:
  652. /* case BRIDGE_SPCA504B: */
  653. /* case BRIDGE_SPCA533: */
  654. /* case BRIDGE_SPCA536: */
  655. switch (sd->subtype) {
  656. case MegapixV4:
  657. case LogitechClickSmart820:
  658. case MegaImageVI:
  659. reg_w_riv(gspca_dev, 0xf0, 0, 0);
  660. spca504B_WaitCmdStatus(gspca_dev);
  661. reg_r(gspca_dev, 0xf0, 4, 0);
  662. spca504B_WaitCmdStatus(gspca_dev);
  663. break;
  664. default:
  665. reg_w_riv(gspca_dev, 0x31, 0x0004, 0x00);
  666. spca504B_WaitCmdStatus(gspca_dev);
  667. spca504B_PollingDataReady(gspca_dev);
  668. break;
  669. }
  670. break;
  671. case BRIDGE_SPCA504:
  672. if (sd->subtype == AiptekMiniPenCam13) {
  673. spca504_read_info(gspca_dev);
  674. /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
  675. spca504A_acknowledged_command(gspca_dev, 0x24,
  676. 8, 3, 0x9e, 1);
  677. /* Twice sequential need status 0xff->0x9e->0x9d */
  678. spca504A_acknowledged_command(gspca_dev, 0x24,
  679. 8, 3, 0x9e, 0);
  680. spca504A_acknowledged_command(gspca_dev, 0x24,
  681. 0, 0, 0x9d, 1);
  682. } else {
  683. spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
  684. spca504_read_info(gspca_dev);
  685. spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
  686. spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
  687. }
  688. spca504B_SetSizeType(gspca_dev);
  689. reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05);
  690. /* L92 sno1t.txt */
  691. reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05);
  692. break;
  693. case BRIDGE_SPCA504C:
  694. if (sd->subtype == LogitechClickSmart420) {
  695. write_vector(gspca_dev,
  696. spca504A_clicksmart420_init_data,
  697. ARRAY_SIZE(spca504A_clicksmart420_init_data));
  698. } else {
  699. write_vector(gspca_dev, spca504_pccam600_init_data,
  700. ARRAY_SIZE(spca504_pccam600_init_data));
  701. }
  702. enable = (sd->autogain ? 0x04 : 0x01);
  703. reg_w_riv(gspca_dev, 0x0c, 0x0000, enable);
  704. /* auto exposure */
  705. reg_w_riv(gspca_dev, 0xb0, 0x0000, enable);
  706. /* auto whiteness */
  707. /* set default exposure compensation and whiteness balance */
  708. reg_w_riv(gspca_dev, 0x30, 0x0001, 800); /* ~ 20 fps */
  709. reg_w_riv(gspca_dev, 0x30, 0x0002, 1600);
  710. spca504B_SetSizeType(gspca_dev);
  711. break;
  712. }
  713. init_ctl_reg(gspca_dev);
  714. return gspca_dev->usb_err;
  715. }
  716. static void sd_stopN(struct gspca_dev *gspca_dev)
  717. {
  718. struct sd *sd = (struct sd *) gspca_dev;
  719. switch (sd->bridge) {
  720. default:
  721. /* case BRIDGE_SPCA533: */
  722. /* case BRIDGE_SPCA536: */
  723. /* case BRIDGE_SPCA504B: */
  724. reg_w_riv(gspca_dev, 0x31, 0, 0);
  725. spca504B_WaitCmdStatus(gspca_dev);
  726. spca504B_PollingDataReady(gspca_dev);
  727. break;
  728. case BRIDGE_SPCA504:
  729. case BRIDGE_SPCA504C:
  730. reg_w_riv(gspca_dev, 0x00, 0x2000, 0x0000);
  731. if (sd->subtype == AiptekMiniPenCam13) {
  732. /* spca504a aiptek */
  733. /* spca504A_acknowledged_command(gspca_dev, 0x08,
  734. 6, 0, 0x86, 1); */
  735. spca504A_acknowledged_command(gspca_dev, 0x24,
  736. 0x00, 0x00, 0x9d, 1);
  737. spca504A_acknowledged_command(gspca_dev, 0x01,
  738. 0x0f, 0x00, 0xff, 1);
  739. } else {
  740. spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
  741. reg_w_riv(gspca_dev, 0x01, 0x000f, 0x0000);
  742. }
  743. break;
  744. }
  745. }
  746. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  747. u8 *data, /* isoc packet */
  748. int len) /* iso packet length */
  749. {
  750. struct sd *sd = (struct sd *) gspca_dev;
  751. int i, sof = 0;
  752. static u8 ffd9[] = {0xff, 0xd9};
  753. /* frames are jpeg 4.1.1 without 0xff escape */
  754. switch (sd->bridge) {
  755. case BRIDGE_SPCA533:
  756. if (data[0] == 0xff) {
  757. if (data[1] != 0x01) { /* drop packet */
  758. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  759. return;
  760. }
  761. sof = 1;
  762. data += SPCA533_OFFSET_DATA;
  763. len -= SPCA533_OFFSET_DATA;
  764. } else {
  765. data += 1;
  766. len -= 1;
  767. }
  768. break;
  769. case BRIDGE_SPCA536:
  770. if (data[0] == 0xff) {
  771. sof = 1;
  772. data += SPCA536_OFFSET_DATA;
  773. len -= SPCA536_OFFSET_DATA;
  774. } else {
  775. data += 2;
  776. len -= 2;
  777. }
  778. break;
  779. default:
  780. /* case BRIDGE_SPCA504: */
  781. /* case BRIDGE_SPCA504B: */
  782. switch (data[0]) {
  783. case 0xfe: /* start of frame */
  784. sof = 1;
  785. data += SPCA50X_OFFSET_DATA;
  786. len -= SPCA50X_OFFSET_DATA;
  787. break;
  788. case 0xff: /* drop packet */
  789. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  790. return;
  791. default:
  792. data += 1;
  793. len -= 1;
  794. break;
  795. }
  796. break;
  797. case BRIDGE_SPCA504C:
  798. switch (data[0]) {
  799. case 0xfe: /* start of frame */
  800. sof = 1;
  801. data += SPCA504_PCCAM600_OFFSET_DATA;
  802. len -= SPCA504_PCCAM600_OFFSET_DATA;
  803. break;
  804. case 0xff: /* drop packet */
  805. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  806. return;
  807. default:
  808. data += 1;
  809. len -= 1;
  810. break;
  811. }
  812. break;
  813. }
  814. if (sof) { /* start of frame */
  815. gspca_frame_add(gspca_dev, LAST_PACKET,
  816. ffd9, 2);
  817. /* put the JPEG header in the new frame */
  818. gspca_frame_add(gspca_dev, FIRST_PACKET,
  819. sd->jpeg_hdr, JPEG_HDR_SZ);
  820. }
  821. /* add 0x00 after 0xff */
  822. i = 0;
  823. do {
  824. if (data[i] == 0xff) {
  825. gspca_frame_add(gspca_dev, INTER_PACKET,
  826. data, i + 1);
  827. len -= i;
  828. data += i;
  829. *data = 0x00;
  830. i = 0;
  831. }
  832. i++;
  833. } while (i < len);
  834. gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
  835. }
  836. static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
  837. {
  838. struct gspca_dev *gspca_dev =
  839. container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
  840. struct sd *sd = (struct sd *)gspca_dev;
  841. gspca_dev->usb_err = 0;
  842. if (!gspca_dev->streaming)
  843. return 0;
  844. switch (ctrl->id) {
  845. case V4L2_CID_BRIGHTNESS:
  846. setbrightness(gspca_dev, ctrl->val);
  847. break;
  848. case V4L2_CID_CONTRAST:
  849. setcontrast(gspca_dev, ctrl->val);
  850. break;
  851. case V4L2_CID_SATURATION:
  852. setcolors(gspca_dev, ctrl->val);
  853. break;
  854. case V4L2_CID_AUTOGAIN:
  855. sd->autogain = ctrl->val;
  856. break;
  857. }
  858. return gspca_dev->usb_err;
  859. }
  860. static const struct v4l2_ctrl_ops sd_ctrl_ops = {
  861. .s_ctrl = sd_s_ctrl,
  862. };
  863. static int sd_init_controls(struct gspca_dev *gspca_dev)
  864. {
  865. struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
  866. gspca_dev->vdev.ctrl_handler = hdl;
  867. v4l2_ctrl_handler_init(hdl, 4);
  868. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  869. V4L2_CID_BRIGHTNESS, -128, 127, 1, 0);
  870. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  871. V4L2_CID_CONTRAST, 0, 255, 1, 0x20);
  872. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  873. V4L2_CID_SATURATION, 0, 255, 1, 0x1a);
  874. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  875. V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
  876. if (hdl->error) {
  877. pr_err("Could not initialize controls\n");
  878. return hdl->error;
  879. }
  880. return 0;
  881. }
  882. /* sub-driver description */
  883. static const struct sd_desc sd_desc = {
  884. .name = MODULE_NAME,
  885. .config = sd_config,
  886. .init = sd_init,
  887. .init_controls = sd_init_controls,
  888. .start = sd_start,
  889. .stopN = sd_stopN,
  890. .pkt_scan = sd_pkt_scan,
  891. };
  892. /* -- module initialisation -- */
  893. #define BS(bridge, subtype) \
  894. .driver_info = (BRIDGE_ ## bridge << 8) \
  895. | (subtype)
  896. static const struct usb_device_id device_table[] = {
  897. {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)},
  898. {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)},
  899. {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)},
  900. {USB_DEVICE(0x0458, 0x7006), BS(SPCA504B, 0)},
  901. {USB_DEVICE(0x0461, 0x0821), BS(SPCA533, 0)},
  902. {USB_DEVICE(0x046d, 0x0905), BS(SPCA533, LogitechClickSmart820)},
  903. {USB_DEVICE(0x046d, 0x0960), BS(SPCA504C, LogitechClickSmart420)},
  904. {USB_DEVICE(0x0471, 0x0322), BS(SPCA504B, 0)},
  905. {USB_DEVICE(0x04a5, 0x3003), BS(SPCA504B, 0)},
  906. {USB_DEVICE(0x04a5, 0x3008), BS(SPCA533, 0)},
  907. {USB_DEVICE(0x04a5, 0x300a), BS(SPCA533, 0)},
  908. {USB_DEVICE(0x04f1, 0x1001), BS(SPCA504B, 0)},
  909. {USB_DEVICE(0x04fc, 0x500c), BS(SPCA504B, 0)},
  910. {USB_DEVICE(0x04fc, 0x504a), BS(SPCA504, AiptekMiniPenCam13)},
  911. {USB_DEVICE(0x04fc, 0x504b), BS(SPCA504B, 0)},
  912. {USB_DEVICE(0x04fc, 0x5330), BS(SPCA533, 0)},
  913. {USB_DEVICE(0x04fc, 0x5360), BS(SPCA536, 0)},
  914. {USB_DEVICE(0x04fc, 0xffff), BS(SPCA504B, 0)},
  915. {USB_DEVICE(0x052b, 0x1507), BS(SPCA533, MegapixV4)},
  916. {USB_DEVICE(0x052b, 0x1513), BS(SPCA533, MegapixV4)},
  917. {USB_DEVICE(0x052b, 0x1803), BS(SPCA533, MegaImageVI)},
  918. {USB_DEVICE(0x0546, 0x3155), BS(SPCA533, 0)},
  919. {USB_DEVICE(0x0546, 0x3191), BS(SPCA504B, 0)},
  920. {USB_DEVICE(0x0546, 0x3273), BS(SPCA504B, 0)},
  921. {USB_DEVICE(0x055f, 0xc211), BS(SPCA536, 0)},
  922. {USB_DEVICE(0x055f, 0xc230), BS(SPCA533, 0)},
  923. {USB_DEVICE(0x055f, 0xc232), BS(SPCA533, 0)},
  924. {USB_DEVICE(0x055f, 0xc360), BS(SPCA536, 0)},
  925. {USB_DEVICE(0x055f, 0xc420), BS(SPCA504, 0)},
  926. {USB_DEVICE(0x055f, 0xc430), BS(SPCA533, 0)},
  927. {USB_DEVICE(0x055f, 0xc440), BS(SPCA533, 0)},
  928. {USB_DEVICE(0x055f, 0xc520), BS(SPCA504, 0)},
  929. {USB_DEVICE(0x055f, 0xc530), BS(SPCA533, 0)},
  930. {USB_DEVICE(0x055f, 0xc540), BS(SPCA533, 0)},
  931. {USB_DEVICE(0x055f, 0xc630), BS(SPCA533, 0)},
  932. {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)},
  933. {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)},
  934. {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)},
  935. {USB_DEVICE(0x06d6, 0x0041), BS(SPCA504B, 0)},
  936. {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)},
  937. {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)},
  938. {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)},
  939. {USB_DEVICE(0x0733, 0x2221), BS(SPCA533, 0)},
  940. {USB_DEVICE(0x0733, 0x3261), BS(SPCA536, 0)},
  941. {USB_DEVICE(0x0733, 0x3281), BS(SPCA536, 0)},
  942. {USB_DEVICE(0x08ca, 0x0104), BS(SPCA533, 0)},
  943. {USB_DEVICE(0x08ca, 0x0106), BS(SPCA533, 0)},
  944. {USB_DEVICE(0x08ca, 0x2008), BS(SPCA504B, 0)},
  945. {USB_DEVICE(0x08ca, 0x2010), BS(SPCA533, 0)},
  946. {USB_DEVICE(0x08ca, 0x2016), BS(SPCA504B, 0)},
  947. {USB_DEVICE(0x08ca, 0x2018), BS(SPCA504B, 0)},
  948. {USB_DEVICE(0x08ca, 0x2020), BS(SPCA533, 0)},
  949. {USB_DEVICE(0x08ca, 0x2022), BS(SPCA533, 0)},
  950. {USB_DEVICE(0x08ca, 0x2024), BS(SPCA536, 0)},
  951. {USB_DEVICE(0x08ca, 0x2028), BS(SPCA533, 0)},
  952. {USB_DEVICE(0x08ca, 0x2040), BS(SPCA536, 0)},
  953. {USB_DEVICE(0x08ca, 0x2042), BS(SPCA536, 0)},
  954. {USB_DEVICE(0x08ca, 0x2050), BS(SPCA536, 0)},
  955. {USB_DEVICE(0x08ca, 0x2060), BS(SPCA536, 0)},
  956. {USB_DEVICE(0x0d64, 0x0303), BS(SPCA536, 0)},
  957. {}
  958. };
  959. MODULE_DEVICE_TABLE(usb, device_table);
  960. /* -- device connect -- */
  961. static int sd_probe(struct usb_interface *intf,
  962. const struct usb_device_id *id)
  963. {
  964. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  965. THIS_MODULE);
  966. }
  967. static struct usb_driver sd_driver = {
  968. .name = MODULE_NAME,
  969. .id_table = device_table,
  970. .probe = sd_probe,
  971. .disconnect = gspca_disconnect,
  972. #ifdef CONFIG_PM
  973. .suspend = gspca_suspend,
  974. .resume = gspca_resume,
  975. .reset_resume = gspca_resume,
  976. #endif
  977. };
  978. module_usb_driver(sd_driver);