sunplus.c 29 KB

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