sunplus.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  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."
  335. " Should be 1,0,2,2,0,0",
  336. info[0], info[1], info[2],
  337. info[3], info[4], info[5]);
  338. }
  339. static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
  340. u8 req,
  341. u16 idx, u16 val, u8 endcode, u8 count)
  342. {
  343. u16 status;
  344. reg_w_riv(gspca_dev, req, idx, val);
  345. reg_r(gspca_dev, 0x01, 0x0001, 1);
  346. if (gspca_dev->usb_err < 0)
  347. return;
  348. PDEBUG(D_FRAM, "Status 0x%02x Need 0x%02x",
  349. gspca_dev->usb_buf[0], endcode);
  350. if (!count)
  351. return;
  352. count = 200;
  353. while (--count > 0) {
  354. msleep(10);
  355. /* gsmart mini2 write a each wait setting 1 ms is enough */
  356. /* reg_w_riv(gspca_dev, req, idx, val); */
  357. reg_r(gspca_dev, 0x01, 0x0001, 1);
  358. status = gspca_dev->usb_buf[0];
  359. if (status == endcode) {
  360. PDEBUG(D_FRAM, "status 0x%04x after wait %d",
  361. status, 200 - count);
  362. break;
  363. }
  364. }
  365. }
  366. static void spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
  367. {
  368. int count = 10;
  369. while (--count > 0) {
  370. reg_r(gspca_dev, 0x21, 0, 1);
  371. if ((gspca_dev->usb_buf[0] & 0x01) == 0)
  372. break;
  373. msleep(10);
  374. }
  375. }
  376. static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
  377. {
  378. int count = 50;
  379. while (--count > 0) {
  380. reg_r(gspca_dev, 0x21, 1, 1);
  381. if (gspca_dev->usb_buf[0] != 0) {
  382. reg_w_1(gspca_dev, 0x21, 0, 1, 0);
  383. reg_r(gspca_dev, 0x21, 1, 1);
  384. spca504B_PollingDataReady(gspca_dev);
  385. break;
  386. }
  387. msleep(10);
  388. }
  389. }
  390. static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
  391. {
  392. u8 *data;
  393. if (gspca_debug < D_STREAM)
  394. return;
  395. data = gspca_dev->usb_buf;
  396. reg_r(gspca_dev, 0x20, 0, 5);
  397. PDEBUG(D_STREAM, "FirmWare: %d %d %d %d %d",
  398. data[0], data[1], data[2], data[3], data[4]);
  399. reg_r(gspca_dev, 0x23, 0, 64);
  400. reg_r(gspca_dev, 0x23, 1, 64);
  401. }
  402. static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
  403. {
  404. struct sd *sd = (struct sd *) gspca_dev;
  405. u8 Size;
  406. Size = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
  407. switch (sd->bridge) {
  408. case BRIDGE_SPCA533:
  409. reg_w_riv(gspca_dev, 0x31, 0, 0);
  410. spca504B_WaitCmdStatus(gspca_dev);
  411. spca504B_PollingDataReady(gspca_dev);
  412. spca50x_GetFirmware(gspca_dev);
  413. reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */
  414. reg_r(gspca_dev, 0x24, 8, 1);
  415. reg_w_1(gspca_dev, 0x25, 0, 4, Size);
  416. reg_r(gspca_dev, 0x25, 4, 1); /* size */
  417. spca504B_PollingDataReady(gspca_dev);
  418. /* Init the cam width height with some values get on init ? */
  419. reg_w_riv(gspca_dev, 0x31, 0x0004, 0x00);
  420. spca504B_WaitCmdStatus(gspca_dev);
  421. spca504B_PollingDataReady(gspca_dev);
  422. break;
  423. default:
  424. /* case BRIDGE_SPCA504B: */
  425. /* case BRIDGE_SPCA536: */
  426. reg_w_1(gspca_dev, 0x25, 0, 4, Size);
  427. reg_r(gspca_dev, 0x25, 4, 1); /* size */
  428. reg_w_1(gspca_dev, 0x27, 0, 0, 6);
  429. reg_r(gspca_dev, 0x27, 0, 1); /* type */
  430. spca504B_PollingDataReady(gspca_dev);
  431. break;
  432. case BRIDGE_SPCA504:
  433. Size += 3;
  434. if (sd->subtype == AiptekMiniPenCam13) {
  435. /* spca504a aiptek */
  436. spca504A_acknowledged_command(gspca_dev,
  437. 0x08, Size, 0,
  438. 0x80 | (Size & 0x0f), 1);
  439. spca504A_acknowledged_command(gspca_dev,
  440. 1, 3, 0, 0x9f, 0);
  441. } else {
  442. spca504_acknowledged_command(gspca_dev, 0x08, Size, 0);
  443. }
  444. break;
  445. case BRIDGE_SPCA504C:
  446. /* capture mode */
  447. reg_w_riv(gspca_dev, 0xa0, (0x0500 | (Size & 0x0f)), 0x00);
  448. reg_w_riv(gspca_dev, 0x20, 0x01, 0x0500 | (Size & 0x0f));
  449. break;
  450. }
  451. }
  452. static void spca504_wait_status(struct gspca_dev *gspca_dev)
  453. {
  454. int cnt;
  455. cnt = 256;
  456. while (--cnt > 0) {
  457. /* With this we get the status, when return 0 it's all ok */
  458. reg_r(gspca_dev, 0x06, 0x00, 1);
  459. if (gspca_dev->usb_buf[0] == 0)
  460. return;
  461. msleep(10);
  462. }
  463. }
  464. static void spca504B_setQtable(struct gspca_dev *gspca_dev)
  465. {
  466. reg_w_1(gspca_dev, 0x26, 0, 0, 3);
  467. reg_r(gspca_dev, 0x26, 0, 1);
  468. spca504B_PollingDataReady(gspca_dev);
  469. }
  470. static void setbrightness(struct gspca_dev *gspca_dev, s32 val)
  471. {
  472. struct sd *sd = (struct sd *) gspca_dev;
  473. u16 reg;
  474. reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f0 : 0x21a7;
  475. reg_w_riv(gspca_dev, 0x00, reg, val);
  476. }
  477. static void setcontrast(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 ? 0x20f1 : 0x21a8;
  482. reg_w_riv(gspca_dev, 0x00, reg, val);
  483. }
  484. static void setcolors(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 ? 0x20f6 : 0x21ae;
  489. reg_w_riv(gspca_dev, 0x00, reg, val);
  490. }
  491. static void init_ctl_reg(struct gspca_dev *gspca_dev)
  492. {
  493. struct sd *sd = (struct sd *) gspca_dev;
  494. int pollreg = 1;
  495. switch (sd->bridge) {
  496. case BRIDGE_SPCA504:
  497. case BRIDGE_SPCA504C:
  498. pollreg = 0;
  499. /* fall thru */
  500. default:
  501. /* case BRIDGE_SPCA533: */
  502. /* case BRIDGE_SPCA504B: */
  503. reg_w_riv(gspca_dev, 0, 0x21ad, 0x00); /* hue */
  504. reg_w_riv(gspca_dev, 0, 0x21ac, 0x01); /* sat/hue */
  505. reg_w_riv(gspca_dev, 0, 0x21a3, 0x00); /* gamma */
  506. break;
  507. case BRIDGE_SPCA536:
  508. reg_w_riv(gspca_dev, 0, 0x20f5, 0x40);
  509. reg_w_riv(gspca_dev, 0, 0x20f4, 0x01);
  510. reg_w_riv(gspca_dev, 0, 0x2089, 0x00);
  511. break;
  512. }
  513. if (pollreg)
  514. spca504B_PollingDataReady(gspca_dev);
  515. }
  516. /* this function is called at probe time */
  517. static int sd_config(struct gspca_dev *gspca_dev,
  518. const struct usb_device_id *id)
  519. {
  520. struct sd *sd = (struct sd *) gspca_dev;
  521. struct cam *cam;
  522. cam = &gspca_dev->cam;
  523. sd->bridge = id->driver_info >> 8;
  524. sd->subtype = id->driver_info;
  525. if (sd->subtype == AiptekMiniPenCam13) {
  526. /* try to get the firmware as some cam answer 2.0.1.2.2
  527. * and should be a spca504b then overwrite that setting */
  528. reg_r(gspca_dev, 0x20, 0, 1);
  529. switch (gspca_dev->usb_buf[0]) {
  530. case 1:
  531. break; /* (right bridge/subtype) */
  532. case 2:
  533. sd->bridge = BRIDGE_SPCA504B;
  534. sd->subtype = 0;
  535. break;
  536. default:
  537. return -ENODEV;
  538. }
  539. }
  540. switch (sd->bridge) {
  541. default:
  542. /* case BRIDGE_SPCA504B: */
  543. /* case BRIDGE_SPCA504: */
  544. /* case BRIDGE_SPCA536: */
  545. cam->cam_mode = vga_mode;
  546. cam->nmodes = ARRAY_SIZE(vga_mode);
  547. break;
  548. case BRIDGE_SPCA533:
  549. cam->cam_mode = custom_mode;
  550. if (sd->subtype == MegaImageVI) /* 320x240 only */
  551. cam->nmodes = ARRAY_SIZE(custom_mode) - 1;
  552. else
  553. cam->nmodes = ARRAY_SIZE(custom_mode);
  554. break;
  555. case BRIDGE_SPCA504C:
  556. cam->cam_mode = vga_mode2;
  557. cam->nmodes = ARRAY_SIZE(vga_mode2);
  558. break;
  559. }
  560. return 0;
  561. }
  562. /* this function is called at probe and resume time */
  563. static int sd_init(struct gspca_dev *gspca_dev)
  564. {
  565. struct sd *sd = (struct sd *) gspca_dev;
  566. switch (sd->bridge) {
  567. case BRIDGE_SPCA504B:
  568. reg_w_riv(gspca_dev, 0x1d, 0x00, 0);
  569. reg_w_riv(gspca_dev, 0x00, 0x2306, 0x01);
  570. reg_w_riv(gspca_dev, 0x00, 0x0d04, 0x00);
  571. reg_w_riv(gspca_dev, 0x00, 0x2000, 0x00);
  572. reg_w_riv(gspca_dev, 0x00, 0x2301, 0x13);
  573. reg_w_riv(gspca_dev, 0x00, 0x2306, 0x00);
  574. /* fall thru */
  575. case BRIDGE_SPCA533:
  576. spca504B_PollingDataReady(gspca_dev);
  577. spca50x_GetFirmware(gspca_dev);
  578. break;
  579. case BRIDGE_SPCA536:
  580. spca50x_GetFirmware(gspca_dev);
  581. reg_r(gspca_dev, 0x00, 0x5002, 1);
  582. reg_w_1(gspca_dev, 0x24, 0, 0, 0);
  583. reg_r(gspca_dev, 0x24, 0, 1);
  584. spca504B_PollingDataReady(gspca_dev);
  585. reg_w_riv(gspca_dev, 0x34, 0, 0);
  586. spca504B_WaitCmdStatus(gspca_dev);
  587. break;
  588. case BRIDGE_SPCA504C: /* pccam600 */
  589. PDEBUG(D_STREAM, "Opening SPCA504 (PC-CAM 600)");
  590. reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0000);
  591. reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0001); /* reset */
  592. spca504_wait_status(gspca_dev);
  593. if (sd->subtype == LogitechClickSmart420)
  594. write_vector(gspca_dev,
  595. spca504A_clicksmart420_open_data,
  596. ARRAY_SIZE(spca504A_clicksmart420_open_data));
  597. else
  598. write_vector(gspca_dev, spca504_pccam600_open_data,
  599. ARRAY_SIZE(spca504_pccam600_open_data));
  600. setup_qtable(gspca_dev, qtable_creative_pccam);
  601. break;
  602. default:
  603. /* case BRIDGE_SPCA504: */
  604. PDEBUG(D_STREAM, "Opening SPCA504");
  605. if (sd->subtype == AiptekMiniPenCam13) {
  606. spca504_read_info(gspca_dev);
  607. /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
  608. spca504A_acknowledged_command(gspca_dev, 0x24,
  609. 8, 3, 0x9e, 1);
  610. /* Twice sequential need status 0xff->0x9e->0x9d */
  611. spca504A_acknowledged_command(gspca_dev, 0x24,
  612. 8, 3, 0x9e, 0);
  613. spca504A_acknowledged_command(gspca_dev, 0x24,
  614. 0, 0, 0x9d, 1);
  615. /******************************/
  616. /* spca504a aiptek */
  617. spca504A_acknowledged_command(gspca_dev, 0x08,
  618. 6, 0, 0x86, 1);
  619. /* reg_write (dev, 0, 0x2000, 0); */
  620. /* reg_write (dev, 0, 0x2883, 1); */
  621. /* spca504A_acknowledged_command (gspca_dev, 0x08,
  622. 6, 0, 0x86, 1); */
  623. /* spca504A_acknowledged_command (gspca_dev, 0x24,
  624. 0, 0, 0x9D, 1); */
  625. reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05);
  626. /* L92 sno1t.txt */
  627. reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05);
  628. spca504A_acknowledged_command(gspca_dev, 0x01,
  629. 0x0f, 0, 0xff, 0);
  630. }
  631. /* setup qtable */
  632. reg_w_riv(gspca_dev, 0, 0x2000, 0);
  633. reg_w_riv(gspca_dev, 0, 0x2883, 1);
  634. setup_qtable(gspca_dev, qtable_spca504_default);
  635. break;
  636. }
  637. return gspca_dev->usb_err;
  638. }
  639. static int sd_start(struct gspca_dev *gspca_dev)
  640. {
  641. struct sd *sd = (struct sd *) gspca_dev;
  642. int enable;
  643. /* create the JPEG header */
  644. jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->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(0x0733, 0x1311), BS(SPCA533, 0)},
  936. {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)},
  937. {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)},
  938. {USB_DEVICE(0x0733, 0x2221), BS(SPCA533, 0)},
  939. {USB_DEVICE(0x0733, 0x3261), BS(SPCA536, 0)},
  940. {USB_DEVICE(0x0733, 0x3281), BS(SPCA536, 0)},
  941. {USB_DEVICE(0x08ca, 0x0104), BS(SPCA533, 0)},
  942. {USB_DEVICE(0x08ca, 0x0106), BS(SPCA533, 0)},
  943. {USB_DEVICE(0x08ca, 0x2008), BS(SPCA504B, 0)},
  944. {USB_DEVICE(0x08ca, 0x2010), BS(SPCA533, 0)},
  945. {USB_DEVICE(0x08ca, 0x2016), BS(SPCA504B, 0)},
  946. {USB_DEVICE(0x08ca, 0x2018), BS(SPCA504B, 0)},
  947. {USB_DEVICE(0x08ca, 0x2020), BS(SPCA533, 0)},
  948. {USB_DEVICE(0x08ca, 0x2022), BS(SPCA533, 0)},
  949. {USB_DEVICE(0x08ca, 0x2024), BS(SPCA536, 0)},
  950. {USB_DEVICE(0x08ca, 0x2028), BS(SPCA533, 0)},
  951. {USB_DEVICE(0x08ca, 0x2040), BS(SPCA536, 0)},
  952. {USB_DEVICE(0x08ca, 0x2042), BS(SPCA536, 0)},
  953. {USB_DEVICE(0x08ca, 0x2050), BS(SPCA536, 0)},
  954. {USB_DEVICE(0x08ca, 0x2060), BS(SPCA536, 0)},
  955. {USB_DEVICE(0x0d64, 0x0303), BS(SPCA536, 0)},
  956. {}
  957. };
  958. MODULE_DEVICE_TABLE(usb, device_table);
  959. /* -- device connect -- */
  960. static int sd_probe(struct usb_interface *intf,
  961. const struct usb_device_id *id)
  962. {
  963. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  964. THIS_MODULE);
  965. }
  966. static struct usb_driver sd_driver = {
  967. .name = MODULE_NAME,
  968. .id_table = device_table,
  969. .probe = sd_probe,
  970. .disconnect = gspca_disconnect,
  971. #ifdef CONFIG_PM
  972. .suspend = gspca_suspend,
  973. .resume = gspca_resume,
  974. .reset_resume = gspca_resume,
  975. #endif
  976. };
  977. module_usb_driver(sd_driver);