sunplus.c 30 KB

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