sunplus.c 29 KB

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