sunplus.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  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. gspca_err(gspca_dev, "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. * Make sure the buffer is zeroed to avoid uninitialized
  245. * values.
  246. */
  247. memset(gspca_dev->usb_buf, 0, USB_BUF_SZ);
  248. }
  249. }
  250. /* write one byte */
  251. static void reg_w_1(struct gspca_dev *gspca_dev,
  252. u8 req,
  253. u16 value,
  254. u16 index,
  255. u16 byte)
  256. {
  257. int ret;
  258. if (gspca_dev->usb_err < 0)
  259. return;
  260. gspca_dev->usb_buf[0] = byte;
  261. ret = usb_control_msg(gspca_dev->dev,
  262. usb_sndctrlpipe(gspca_dev->dev, 0),
  263. req,
  264. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  265. value, index,
  266. gspca_dev->usb_buf, 1,
  267. 500);
  268. if (ret < 0) {
  269. pr_err("reg_w_1 err %d\n", ret);
  270. gspca_dev->usb_err = ret;
  271. }
  272. }
  273. /* write req / index / value */
  274. static void reg_w_riv(struct gspca_dev *gspca_dev,
  275. u8 req, u16 index, u16 value)
  276. {
  277. struct usb_device *dev = gspca_dev->dev;
  278. int ret;
  279. if (gspca_dev->usb_err < 0)
  280. return;
  281. ret = usb_control_msg(dev,
  282. usb_sndctrlpipe(dev, 0),
  283. req,
  284. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  285. value, index, NULL, 0, 500);
  286. if (ret < 0) {
  287. pr_err("reg_w_riv err %d\n", ret);
  288. gspca_dev->usb_err = ret;
  289. return;
  290. }
  291. gspca_dbg(gspca_dev, D_USBO, "reg_w_riv: 0x%02x,0x%04x:0x%04x\n",
  292. req, index, value);
  293. }
  294. static void write_vector(struct gspca_dev *gspca_dev,
  295. const struct cmd *data, int ncmds)
  296. {
  297. while (--ncmds >= 0) {
  298. reg_w_riv(gspca_dev, data->req, data->idx, data->val);
  299. data++;
  300. }
  301. }
  302. static void setup_qtable(struct gspca_dev *gspca_dev,
  303. const u8 qtable[2][64])
  304. {
  305. int i;
  306. /* loop over y components */
  307. for (i = 0; i < 64; i++)
  308. reg_w_riv(gspca_dev, 0x00, 0x2800 + i, qtable[0][i]);
  309. /* loop over c components */
  310. for (i = 0; i < 64; i++)
  311. reg_w_riv(gspca_dev, 0x00, 0x2840 + i, qtable[1][i]);
  312. }
  313. static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
  314. u8 req, u16 idx, u16 val)
  315. {
  316. reg_w_riv(gspca_dev, req, idx, val);
  317. reg_r(gspca_dev, 0x01, 0x0001, 1);
  318. gspca_dbg(gspca_dev, D_FRAM, "before wait 0x%04x\n",
  319. gspca_dev->usb_buf[0]);
  320. reg_w_riv(gspca_dev, req, idx, val);
  321. msleep(200);
  322. reg_r(gspca_dev, 0x01, 0x0001, 1);
  323. gspca_dbg(gspca_dev, D_FRAM, "after wait 0x%04x\n",
  324. gspca_dev->usb_buf[0]);
  325. }
  326. static void spca504_read_info(struct gspca_dev *gspca_dev)
  327. {
  328. int i;
  329. u8 info[6];
  330. if (gspca_debug < D_STREAM)
  331. return;
  332. for (i = 0; i < 6; i++) {
  333. reg_r(gspca_dev, 0, i, 1);
  334. info[i] = gspca_dev->usb_buf[0];
  335. }
  336. gspca_dbg(gspca_dev, D_STREAM,
  337. "Read info: %d %d %d %d %d %d. Should be 1,0,2,2,0,0\n",
  338. info[0], info[1], info[2],
  339. info[3], info[4], info[5]);
  340. }
  341. static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
  342. u8 req,
  343. u16 idx, u16 val, u8 endcode, u8 count)
  344. {
  345. u16 status;
  346. reg_w_riv(gspca_dev, req, idx, val);
  347. reg_r(gspca_dev, 0x01, 0x0001, 1);
  348. if (gspca_dev->usb_err < 0)
  349. return;
  350. gspca_dbg(gspca_dev, D_FRAM, "Status 0x%02x Need 0x%02x\n",
  351. gspca_dev->usb_buf[0], endcode);
  352. if (!count)
  353. return;
  354. count = 200;
  355. while (--count > 0) {
  356. msleep(10);
  357. /* gsmart mini2 write a each wait setting 1 ms is enough */
  358. /* reg_w_riv(gspca_dev, req, idx, val); */
  359. reg_r(gspca_dev, 0x01, 0x0001, 1);
  360. status = gspca_dev->usb_buf[0];
  361. if (status == endcode) {
  362. gspca_dbg(gspca_dev, D_FRAM, "status 0x%04x after wait %d\n",
  363. status, 200 - count);
  364. break;
  365. }
  366. }
  367. }
  368. static void spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
  369. {
  370. int count = 10;
  371. while (--count > 0) {
  372. reg_r(gspca_dev, 0x21, 0, 1);
  373. if ((gspca_dev->usb_buf[0] & 0x01) == 0)
  374. break;
  375. msleep(10);
  376. }
  377. }
  378. static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
  379. {
  380. int count = 50;
  381. while (--count > 0) {
  382. reg_r(gspca_dev, 0x21, 1, 1);
  383. if (gspca_dev->usb_buf[0] != 0) {
  384. reg_w_1(gspca_dev, 0x21, 0, 1, 0);
  385. reg_r(gspca_dev, 0x21, 1, 1);
  386. spca504B_PollingDataReady(gspca_dev);
  387. break;
  388. }
  389. msleep(10);
  390. }
  391. }
  392. static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
  393. {
  394. u8 *data;
  395. if (gspca_debug < D_STREAM)
  396. return;
  397. data = gspca_dev->usb_buf;
  398. reg_r(gspca_dev, 0x20, 0, 5);
  399. gspca_dbg(gspca_dev, D_STREAM, "FirmWare: %d %d %d %d %d\n",
  400. data[0], data[1], data[2], data[3], data[4]);
  401. reg_r(gspca_dev, 0x23, 0, 64);
  402. reg_r(gspca_dev, 0x23, 1, 64);
  403. }
  404. static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
  405. {
  406. struct sd *sd = (struct sd *) gspca_dev;
  407. u8 Size;
  408. Size = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
  409. switch (sd->bridge) {
  410. case BRIDGE_SPCA533:
  411. reg_w_riv(gspca_dev, 0x31, 0, 0);
  412. spca504B_WaitCmdStatus(gspca_dev);
  413. spca504B_PollingDataReady(gspca_dev);
  414. spca50x_GetFirmware(gspca_dev);
  415. reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */
  416. reg_r(gspca_dev, 0x24, 8, 1);
  417. reg_w_1(gspca_dev, 0x25, 0, 4, Size);
  418. reg_r(gspca_dev, 0x25, 4, 1); /* size */
  419. spca504B_PollingDataReady(gspca_dev);
  420. /* Init the cam width height with some values get on init ? */
  421. reg_w_riv(gspca_dev, 0x31, 0x0004, 0x00);
  422. spca504B_WaitCmdStatus(gspca_dev);
  423. spca504B_PollingDataReady(gspca_dev);
  424. break;
  425. default:
  426. /* case BRIDGE_SPCA504B: */
  427. /* case BRIDGE_SPCA536: */
  428. reg_w_1(gspca_dev, 0x25, 0, 4, Size);
  429. reg_r(gspca_dev, 0x25, 4, 1); /* size */
  430. reg_w_1(gspca_dev, 0x27, 0, 0, 6);
  431. reg_r(gspca_dev, 0x27, 0, 1); /* type */
  432. spca504B_PollingDataReady(gspca_dev);
  433. break;
  434. case BRIDGE_SPCA504:
  435. Size += 3;
  436. if (sd->subtype == AiptekMiniPenCam13) {
  437. /* spca504a aiptek */
  438. spca504A_acknowledged_command(gspca_dev,
  439. 0x08, Size, 0,
  440. 0x80 | (Size & 0x0f), 1);
  441. spca504A_acknowledged_command(gspca_dev,
  442. 1, 3, 0, 0x9f, 0);
  443. } else {
  444. spca504_acknowledged_command(gspca_dev, 0x08, Size, 0);
  445. }
  446. break;
  447. case BRIDGE_SPCA504C:
  448. /* capture mode */
  449. reg_w_riv(gspca_dev, 0xa0, (0x0500 | (Size & 0x0f)), 0x00);
  450. reg_w_riv(gspca_dev, 0x20, 0x01, 0x0500 | (Size & 0x0f));
  451. break;
  452. }
  453. }
  454. static void spca504_wait_status(struct gspca_dev *gspca_dev)
  455. {
  456. int cnt;
  457. cnt = 256;
  458. while (--cnt > 0) {
  459. /* With this we get the status, when return 0 it's all ok */
  460. reg_r(gspca_dev, 0x06, 0x00, 1);
  461. if (gspca_dev->usb_buf[0] == 0)
  462. return;
  463. msleep(10);
  464. }
  465. }
  466. static void spca504B_setQtable(struct gspca_dev *gspca_dev)
  467. {
  468. reg_w_1(gspca_dev, 0x26, 0, 0, 3);
  469. reg_r(gspca_dev, 0x26, 0, 1);
  470. spca504B_PollingDataReady(gspca_dev);
  471. }
  472. static void setbrightness(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 ? 0x20f0 : 0x21a7;
  477. reg_w_riv(gspca_dev, 0x00, reg, val);
  478. }
  479. static void setcontrast(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 ? 0x20f1 : 0x21a8;
  484. reg_w_riv(gspca_dev, 0x00, reg, val);
  485. }
  486. static void setcolors(struct gspca_dev *gspca_dev, s32 val)
  487. {
  488. struct sd *sd = (struct sd *) gspca_dev;
  489. u16 reg;
  490. reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f6 : 0x21ae;
  491. reg_w_riv(gspca_dev, 0x00, reg, val);
  492. }
  493. static void init_ctl_reg(struct gspca_dev *gspca_dev)
  494. {
  495. struct sd *sd = (struct sd *) gspca_dev;
  496. int pollreg = 1;
  497. switch (sd->bridge) {
  498. case BRIDGE_SPCA504:
  499. case BRIDGE_SPCA504C:
  500. pollreg = 0;
  501. /* fall thru */
  502. default:
  503. /* case BRIDGE_SPCA533: */
  504. /* case BRIDGE_SPCA504B: */
  505. reg_w_riv(gspca_dev, 0, 0x21ad, 0x00); /* hue */
  506. reg_w_riv(gspca_dev, 0, 0x21ac, 0x01); /* sat/hue */
  507. reg_w_riv(gspca_dev, 0, 0x21a3, 0x00); /* gamma */
  508. break;
  509. case BRIDGE_SPCA536:
  510. reg_w_riv(gspca_dev, 0, 0x20f5, 0x40);
  511. reg_w_riv(gspca_dev, 0, 0x20f4, 0x01);
  512. reg_w_riv(gspca_dev, 0, 0x2089, 0x00);
  513. break;
  514. }
  515. if (pollreg)
  516. spca504B_PollingDataReady(gspca_dev);
  517. }
  518. /* this function is called at probe time */
  519. static int sd_config(struct gspca_dev *gspca_dev,
  520. const struct usb_device_id *id)
  521. {
  522. struct sd *sd = (struct sd *) gspca_dev;
  523. struct cam *cam;
  524. cam = &gspca_dev->cam;
  525. sd->bridge = id->driver_info >> 8;
  526. sd->subtype = id->driver_info;
  527. if (sd->subtype == AiptekMiniPenCam13) {
  528. /* try to get the firmware as some cam answer 2.0.1.2.2
  529. * and should be a spca504b then overwrite that setting */
  530. reg_r(gspca_dev, 0x20, 0, 1);
  531. switch (gspca_dev->usb_buf[0]) {
  532. case 1:
  533. break; /* (right bridge/subtype) */
  534. case 2:
  535. sd->bridge = BRIDGE_SPCA504B;
  536. sd->subtype = 0;
  537. break;
  538. default:
  539. return -ENODEV;
  540. }
  541. }
  542. switch (sd->bridge) {
  543. default:
  544. /* case BRIDGE_SPCA504B: */
  545. /* case BRIDGE_SPCA504: */
  546. /* case BRIDGE_SPCA536: */
  547. cam->cam_mode = vga_mode;
  548. cam->nmodes = ARRAY_SIZE(vga_mode);
  549. break;
  550. case BRIDGE_SPCA533:
  551. cam->cam_mode = custom_mode;
  552. if (sd->subtype == MegaImageVI) /* 320x240 only */
  553. cam->nmodes = ARRAY_SIZE(custom_mode) - 1;
  554. else
  555. cam->nmodes = ARRAY_SIZE(custom_mode);
  556. break;
  557. case BRIDGE_SPCA504C:
  558. cam->cam_mode = vga_mode2;
  559. cam->nmodes = ARRAY_SIZE(vga_mode2);
  560. break;
  561. }
  562. return 0;
  563. }
  564. /* this function is called at probe and resume time */
  565. static int sd_init(struct gspca_dev *gspca_dev)
  566. {
  567. struct sd *sd = (struct sd *) gspca_dev;
  568. switch (sd->bridge) {
  569. case BRIDGE_SPCA504B:
  570. reg_w_riv(gspca_dev, 0x1d, 0x00, 0);
  571. reg_w_riv(gspca_dev, 0x00, 0x2306, 0x01);
  572. reg_w_riv(gspca_dev, 0x00, 0x0d04, 0x00);
  573. reg_w_riv(gspca_dev, 0x00, 0x2000, 0x00);
  574. reg_w_riv(gspca_dev, 0x00, 0x2301, 0x13);
  575. reg_w_riv(gspca_dev, 0x00, 0x2306, 0x00);
  576. /* fall thru */
  577. case BRIDGE_SPCA533:
  578. spca504B_PollingDataReady(gspca_dev);
  579. spca50x_GetFirmware(gspca_dev);
  580. break;
  581. case BRIDGE_SPCA536:
  582. spca50x_GetFirmware(gspca_dev);
  583. reg_r(gspca_dev, 0x00, 0x5002, 1);
  584. reg_w_1(gspca_dev, 0x24, 0, 0, 0);
  585. reg_r(gspca_dev, 0x24, 0, 1);
  586. spca504B_PollingDataReady(gspca_dev);
  587. reg_w_riv(gspca_dev, 0x34, 0, 0);
  588. spca504B_WaitCmdStatus(gspca_dev);
  589. break;
  590. case BRIDGE_SPCA504C: /* pccam600 */
  591. gspca_dbg(gspca_dev, D_STREAM, "Opening SPCA504 (PC-CAM 600)\n");
  592. reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0000);
  593. reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0001); /* reset */
  594. spca504_wait_status(gspca_dev);
  595. if (sd->subtype == LogitechClickSmart420)
  596. write_vector(gspca_dev,
  597. spca504A_clicksmart420_open_data,
  598. ARRAY_SIZE(spca504A_clicksmart420_open_data));
  599. else
  600. write_vector(gspca_dev, spca504_pccam600_open_data,
  601. ARRAY_SIZE(spca504_pccam600_open_data));
  602. setup_qtable(gspca_dev, qtable_creative_pccam);
  603. break;
  604. default:
  605. /* case BRIDGE_SPCA504: */
  606. gspca_dbg(gspca_dev, D_STREAM, "Opening SPCA504\n");
  607. if (sd->subtype == AiptekMiniPenCam13) {
  608. spca504_read_info(gspca_dev);
  609. /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
  610. spca504A_acknowledged_command(gspca_dev, 0x24,
  611. 8, 3, 0x9e, 1);
  612. /* Twice sequential need status 0xff->0x9e->0x9d */
  613. spca504A_acknowledged_command(gspca_dev, 0x24,
  614. 8, 3, 0x9e, 0);
  615. spca504A_acknowledged_command(gspca_dev, 0x24,
  616. 0, 0, 0x9d, 1);
  617. /******************************/
  618. /* spca504a aiptek */
  619. spca504A_acknowledged_command(gspca_dev, 0x08,
  620. 6, 0, 0x86, 1);
  621. /* reg_write (dev, 0, 0x2000, 0); */
  622. /* reg_write (dev, 0, 0x2883, 1); */
  623. /* spca504A_acknowledged_command (gspca_dev, 0x08,
  624. 6, 0, 0x86, 1); */
  625. /* spca504A_acknowledged_command (gspca_dev, 0x24,
  626. 0, 0, 0x9D, 1); */
  627. reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05);
  628. /* L92 sno1t.txt */
  629. reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05);
  630. spca504A_acknowledged_command(gspca_dev, 0x01,
  631. 0x0f, 0, 0xff, 0);
  632. }
  633. /* setup qtable */
  634. reg_w_riv(gspca_dev, 0, 0x2000, 0);
  635. reg_w_riv(gspca_dev, 0, 0x2883, 1);
  636. setup_qtable(gspca_dev, qtable_spca504_default);
  637. break;
  638. }
  639. return gspca_dev->usb_err;
  640. }
  641. static int sd_start(struct gspca_dev *gspca_dev)
  642. {
  643. struct sd *sd = (struct sd *) gspca_dev;
  644. int enable;
  645. /* create the JPEG header */
  646. jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
  647. gspca_dev->pixfmt.width,
  648. 0x22); /* JPEG 411 */
  649. jpeg_set_qual(sd->jpeg_hdr, QUALITY);
  650. if (sd->bridge == BRIDGE_SPCA504B)
  651. spca504B_setQtable(gspca_dev);
  652. spca504B_SetSizeType(gspca_dev);
  653. switch (sd->bridge) {
  654. default:
  655. /* case BRIDGE_SPCA504B: */
  656. /* case BRIDGE_SPCA533: */
  657. /* case BRIDGE_SPCA536: */
  658. switch (sd->subtype) {
  659. case MegapixV4:
  660. case LogitechClickSmart820:
  661. case MegaImageVI:
  662. reg_w_riv(gspca_dev, 0xf0, 0, 0);
  663. spca504B_WaitCmdStatus(gspca_dev);
  664. reg_r(gspca_dev, 0xf0, 4, 0);
  665. spca504B_WaitCmdStatus(gspca_dev);
  666. break;
  667. default:
  668. reg_w_riv(gspca_dev, 0x31, 0x0004, 0x00);
  669. spca504B_WaitCmdStatus(gspca_dev);
  670. spca504B_PollingDataReady(gspca_dev);
  671. break;
  672. }
  673. break;
  674. case BRIDGE_SPCA504:
  675. if (sd->subtype == AiptekMiniPenCam13) {
  676. spca504_read_info(gspca_dev);
  677. /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
  678. spca504A_acknowledged_command(gspca_dev, 0x24,
  679. 8, 3, 0x9e, 1);
  680. /* Twice sequential need status 0xff->0x9e->0x9d */
  681. spca504A_acknowledged_command(gspca_dev, 0x24,
  682. 8, 3, 0x9e, 0);
  683. spca504A_acknowledged_command(gspca_dev, 0x24,
  684. 0, 0, 0x9d, 1);
  685. } else {
  686. spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
  687. spca504_read_info(gspca_dev);
  688. spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
  689. spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
  690. }
  691. spca504B_SetSizeType(gspca_dev);
  692. reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05);
  693. /* L92 sno1t.txt */
  694. reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05);
  695. break;
  696. case BRIDGE_SPCA504C:
  697. if (sd->subtype == LogitechClickSmart420) {
  698. write_vector(gspca_dev,
  699. spca504A_clicksmart420_init_data,
  700. ARRAY_SIZE(spca504A_clicksmart420_init_data));
  701. } else {
  702. write_vector(gspca_dev, spca504_pccam600_init_data,
  703. ARRAY_SIZE(spca504_pccam600_init_data));
  704. }
  705. enable = (sd->autogain ? 0x04 : 0x01);
  706. reg_w_riv(gspca_dev, 0x0c, 0x0000, enable);
  707. /* auto exposure */
  708. reg_w_riv(gspca_dev, 0xb0, 0x0000, enable);
  709. /* auto whiteness */
  710. /* set default exposure compensation and whiteness balance */
  711. reg_w_riv(gspca_dev, 0x30, 0x0001, 800); /* ~ 20 fps */
  712. reg_w_riv(gspca_dev, 0x30, 0x0002, 1600);
  713. spca504B_SetSizeType(gspca_dev);
  714. break;
  715. }
  716. init_ctl_reg(gspca_dev);
  717. return gspca_dev->usb_err;
  718. }
  719. static void sd_stopN(struct gspca_dev *gspca_dev)
  720. {
  721. struct sd *sd = (struct sd *) gspca_dev;
  722. switch (sd->bridge) {
  723. default:
  724. /* case BRIDGE_SPCA533: */
  725. /* case BRIDGE_SPCA536: */
  726. /* case BRIDGE_SPCA504B: */
  727. reg_w_riv(gspca_dev, 0x31, 0, 0);
  728. spca504B_WaitCmdStatus(gspca_dev);
  729. spca504B_PollingDataReady(gspca_dev);
  730. break;
  731. case BRIDGE_SPCA504:
  732. case BRIDGE_SPCA504C:
  733. reg_w_riv(gspca_dev, 0x00, 0x2000, 0x0000);
  734. if (sd->subtype == AiptekMiniPenCam13) {
  735. /* spca504a aiptek */
  736. /* spca504A_acknowledged_command(gspca_dev, 0x08,
  737. 6, 0, 0x86, 1); */
  738. spca504A_acknowledged_command(gspca_dev, 0x24,
  739. 0x00, 0x00, 0x9d, 1);
  740. spca504A_acknowledged_command(gspca_dev, 0x01,
  741. 0x0f, 0x00, 0xff, 1);
  742. } else {
  743. spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
  744. reg_w_riv(gspca_dev, 0x01, 0x000f, 0x0000);
  745. }
  746. break;
  747. }
  748. }
  749. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  750. u8 *data, /* isoc packet */
  751. int len) /* iso packet length */
  752. {
  753. struct sd *sd = (struct sd *) gspca_dev;
  754. int i, sof = 0;
  755. static u8 ffd9[] = {0xff, 0xd9};
  756. /* frames are jpeg 4.1.1 without 0xff escape */
  757. switch (sd->bridge) {
  758. case BRIDGE_SPCA533:
  759. if (data[0] == 0xff) {
  760. if (data[1] != 0x01) { /* drop packet */
  761. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  762. return;
  763. }
  764. sof = 1;
  765. data += SPCA533_OFFSET_DATA;
  766. len -= SPCA533_OFFSET_DATA;
  767. } else {
  768. data += 1;
  769. len -= 1;
  770. }
  771. break;
  772. case BRIDGE_SPCA536:
  773. if (data[0] == 0xff) {
  774. sof = 1;
  775. data += SPCA536_OFFSET_DATA;
  776. len -= SPCA536_OFFSET_DATA;
  777. } else {
  778. data += 2;
  779. len -= 2;
  780. }
  781. break;
  782. default:
  783. /* case BRIDGE_SPCA504: */
  784. /* case BRIDGE_SPCA504B: */
  785. switch (data[0]) {
  786. case 0xfe: /* start of frame */
  787. sof = 1;
  788. data += SPCA50X_OFFSET_DATA;
  789. len -= SPCA50X_OFFSET_DATA;
  790. break;
  791. case 0xff: /* drop packet */
  792. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  793. return;
  794. default:
  795. data += 1;
  796. len -= 1;
  797. break;
  798. }
  799. break;
  800. case BRIDGE_SPCA504C:
  801. switch (data[0]) {
  802. case 0xfe: /* start of frame */
  803. sof = 1;
  804. data += SPCA504_PCCAM600_OFFSET_DATA;
  805. len -= SPCA504_PCCAM600_OFFSET_DATA;
  806. break;
  807. case 0xff: /* drop packet */
  808. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  809. return;
  810. default:
  811. data += 1;
  812. len -= 1;
  813. break;
  814. }
  815. break;
  816. }
  817. if (sof) { /* start of frame */
  818. gspca_frame_add(gspca_dev, LAST_PACKET,
  819. ffd9, 2);
  820. /* put the JPEG header in the new frame */
  821. gspca_frame_add(gspca_dev, FIRST_PACKET,
  822. sd->jpeg_hdr, JPEG_HDR_SZ);
  823. }
  824. /* add 0x00 after 0xff */
  825. i = 0;
  826. do {
  827. if (data[i] == 0xff) {
  828. gspca_frame_add(gspca_dev, INTER_PACKET,
  829. data, i + 1);
  830. len -= i;
  831. data += i;
  832. *data = 0x00;
  833. i = 0;
  834. }
  835. i++;
  836. } while (i < len);
  837. gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
  838. }
  839. static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
  840. {
  841. struct gspca_dev *gspca_dev =
  842. container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
  843. struct sd *sd = (struct sd *)gspca_dev;
  844. gspca_dev->usb_err = 0;
  845. if (!gspca_dev->streaming)
  846. return 0;
  847. switch (ctrl->id) {
  848. case V4L2_CID_BRIGHTNESS:
  849. setbrightness(gspca_dev, ctrl->val);
  850. break;
  851. case V4L2_CID_CONTRAST:
  852. setcontrast(gspca_dev, ctrl->val);
  853. break;
  854. case V4L2_CID_SATURATION:
  855. setcolors(gspca_dev, ctrl->val);
  856. break;
  857. case V4L2_CID_AUTOGAIN:
  858. sd->autogain = ctrl->val;
  859. break;
  860. }
  861. return gspca_dev->usb_err;
  862. }
  863. static const struct v4l2_ctrl_ops sd_ctrl_ops = {
  864. .s_ctrl = sd_s_ctrl,
  865. };
  866. static int sd_init_controls(struct gspca_dev *gspca_dev)
  867. {
  868. struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
  869. gspca_dev->vdev.ctrl_handler = hdl;
  870. v4l2_ctrl_handler_init(hdl, 4);
  871. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  872. V4L2_CID_BRIGHTNESS, -128, 127, 1, 0);
  873. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  874. V4L2_CID_CONTRAST, 0, 255, 1, 0x20);
  875. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  876. V4L2_CID_SATURATION, 0, 255, 1, 0x1a);
  877. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  878. V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
  879. if (hdl->error) {
  880. pr_err("Could not initialize controls\n");
  881. return hdl->error;
  882. }
  883. return 0;
  884. }
  885. /* sub-driver description */
  886. static const struct sd_desc sd_desc = {
  887. .name = MODULE_NAME,
  888. .config = sd_config,
  889. .init = sd_init,
  890. .init_controls = sd_init_controls,
  891. .start = sd_start,
  892. .stopN = sd_stopN,
  893. .pkt_scan = sd_pkt_scan,
  894. };
  895. /* -- module initialisation -- */
  896. #define BS(bridge, subtype) \
  897. .driver_info = (BRIDGE_ ## bridge << 8) \
  898. | (subtype)
  899. static const struct usb_device_id device_table[] = {
  900. {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)},
  901. {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)},
  902. {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)},
  903. {USB_DEVICE(0x0458, 0x7006), BS(SPCA504B, 0)},
  904. {USB_DEVICE(0x0461, 0x0821), BS(SPCA533, 0)},
  905. {USB_DEVICE(0x046d, 0x0905), BS(SPCA533, LogitechClickSmart820)},
  906. {USB_DEVICE(0x046d, 0x0960), BS(SPCA504C, LogitechClickSmart420)},
  907. {USB_DEVICE(0x0471, 0x0322), BS(SPCA504B, 0)},
  908. {USB_DEVICE(0x04a5, 0x3003), BS(SPCA504B, 0)},
  909. {USB_DEVICE(0x04a5, 0x3008), BS(SPCA533, 0)},
  910. {USB_DEVICE(0x04a5, 0x300a), BS(SPCA533, 0)},
  911. {USB_DEVICE(0x04f1, 0x1001), BS(SPCA504B, 0)},
  912. {USB_DEVICE(0x04fc, 0x500c), BS(SPCA504B, 0)},
  913. {USB_DEVICE(0x04fc, 0x504a), BS(SPCA504, AiptekMiniPenCam13)},
  914. {USB_DEVICE(0x04fc, 0x504b), BS(SPCA504B, 0)},
  915. {USB_DEVICE(0x04fc, 0x5330), BS(SPCA533, 0)},
  916. {USB_DEVICE(0x04fc, 0x5360), BS(SPCA536, 0)},
  917. {USB_DEVICE(0x04fc, 0xffff), BS(SPCA504B, 0)},
  918. {USB_DEVICE(0x052b, 0x1507), BS(SPCA533, MegapixV4)},
  919. {USB_DEVICE(0x052b, 0x1513), BS(SPCA533, MegapixV4)},
  920. {USB_DEVICE(0x052b, 0x1803), BS(SPCA533, MegaImageVI)},
  921. {USB_DEVICE(0x0546, 0x3155), BS(SPCA533, 0)},
  922. {USB_DEVICE(0x0546, 0x3191), BS(SPCA504B, 0)},
  923. {USB_DEVICE(0x0546, 0x3273), BS(SPCA504B, 0)},
  924. {USB_DEVICE(0x055f, 0xc211), BS(SPCA536, 0)},
  925. {USB_DEVICE(0x055f, 0xc230), BS(SPCA533, 0)},
  926. {USB_DEVICE(0x055f, 0xc232), BS(SPCA533, 0)},
  927. {USB_DEVICE(0x055f, 0xc360), BS(SPCA536, 0)},
  928. {USB_DEVICE(0x055f, 0xc420), BS(SPCA504, 0)},
  929. {USB_DEVICE(0x055f, 0xc430), BS(SPCA533, 0)},
  930. {USB_DEVICE(0x055f, 0xc440), BS(SPCA533, 0)},
  931. {USB_DEVICE(0x055f, 0xc520), BS(SPCA504, 0)},
  932. {USB_DEVICE(0x055f, 0xc530), BS(SPCA533, 0)},
  933. {USB_DEVICE(0x055f, 0xc540), BS(SPCA533, 0)},
  934. {USB_DEVICE(0x055f, 0xc630), BS(SPCA533, 0)},
  935. {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)},
  936. {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)},
  937. {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)},
  938. {USB_DEVICE(0x06d6, 0x0041), BS(SPCA504B, 0)},
  939. {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)},
  940. {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)},
  941. {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)},
  942. {USB_DEVICE(0x0733, 0x2221), BS(SPCA533, 0)},
  943. {USB_DEVICE(0x0733, 0x3261), BS(SPCA536, 0)},
  944. {USB_DEVICE(0x0733, 0x3281), BS(SPCA536, 0)},
  945. {USB_DEVICE(0x08ca, 0x0104), BS(SPCA533, 0)},
  946. {USB_DEVICE(0x08ca, 0x0106), BS(SPCA533, 0)},
  947. {USB_DEVICE(0x08ca, 0x2008), BS(SPCA504B, 0)},
  948. {USB_DEVICE(0x08ca, 0x2010), BS(SPCA533, 0)},
  949. {USB_DEVICE(0x08ca, 0x2016), BS(SPCA504B, 0)},
  950. {USB_DEVICE(0x08ca, 0x2018), BS(SPCA504B, 0)},
  951. {USB_DEVICE(0x08ca, 0x2020), BS(SPCA533, 0)},
  952. {USB_DEVICE(0x08ca, 0x2022), BS(SPCA533, 0)},
  953. {USB_DEVICE(0x08ca, 0x2024), BS(SPCA536, 0)},
  954. {USB_DEVICE(0x08ca, 0x2028), BS(SPCA533, 0)},
  955. {USB_DEVICE(0x08ca, 0x2040), BS(SPCA536, 0)},
  956. {USB_DEVICE(0x08ca, 0x2042), BS(SPCA536, 0)},
  957. {USB_DEVICE(0x08ca, 0x2050), BS(SPCA536, 0)},
  958. {USB_DEVICE(0x08ca, 0x2060), BS(SPCA536, 0)},
  959. {USB_DEVICE(0x0d64, 0x0303), BS(SPCA536, 0)},
  960. {}
  961. };
  962. MODULE_DEVICE_TABLE(usb, device_table);
  963. /* -- device connect -- */
  964. static int sd_probe(struct usb_interface *intf,
  965. const struct usb_device_id *id)
  966. {
  967. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  968. THIS_MODULE);
  969. }
  970. static struct usb_driver sd_driver = {
  971. .name = MODULE_NAME,
  972. .id_table = device_table,
  973. .probe = sd_probe,
  974. .disconnect = gspca_disconnect,
  975. #ifdef CONFIG_PM
  976. .suspend = gspca_suspend,
  977. .resume = gspca_resume,
  978. .reset_resume = gspca_resume,
  979. #endif
  980. };
  981. module_usb_driver(sd_driver);