sunplus.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  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->pixfmt.height,
  645. gspca_dev->pixfmt.width,
  646. 0x22); /* JPEG 411 */
  647. jpeg_set_qual(sd->jpeg_hdr, QUALITY);
  648. if (sd->bridge == BRIDGE_SPCA504B)
  649. spca504B_setQtable(gspca_dev);
  650. spca504B_SetSizeType(gspca_dev);
  651. switch (sd->bridge) {
  652. default:
  653. /* case BRIDGE_SPCA504B: */
  654. /* case BRIDGE_SPCA533: */
  655. /* case BRIDGE_SPCA536: */
  656. switch (sd->subtype) {
  657. case MegapixV4:
  658. case LogitechClickSmart820:
  659. case MegaImageVI:
  660. reg_w_riv(gspca_dev, 0xf0, 0, 0);
  661. spca504B_WaitCmdStatus(gspca_dev);
  662. reg_r(gspca_dev, 0xf0, 4, 0);
  663. spca504B_WaitCmdStatus(gspca_dev);
  664. break;
  665. default:
  666. reg_w_riv(gspca_dev, 0x31, 0x0004, 0x00);
  667. spca504B_WaitCmdStatus(gspca_dev);
  668. spca504B_PollingDataReady(gspca_dev);
  669. break;
  670. }
  671. break;
  672. case BRIDGE_SPCA504:
  673. if (sd->subtype == AiptekMiniPenCam13) {
  674. spca504_read_info(gspca_dev);
  675. /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
  676. spca504A_acknowledged_command(gspca_dev, 0x24,
  677. 8, 3, 0x9e, 1);
  678. /* Twice sequential need status 0xff->0x9e->0x9d */
  679. spca504A_acknowledged_command(gspca_dev, 0x24,
  680. 8, 3, 0x9e, 0);
  681. spca504A_acknowledged_command(gspca_dev, 0x24,
  682. 0, 0, 0x9d, 1);
  683. } else {
  684. spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
  685. spca504_read_info(gspca_dev);
  686. spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
  687. spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
  688. }
  689. spca504B_SetSizeType(gspca_dev);
  690. reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05);
  691. /* L92 sno1t.txt */
  692. reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05);
  693. break;
  694. case BRIDGE_SPCA504C:
  695. if (sd->subtype == LogitechClickSmart420) {
  696. write_vector(gspca_dev,
  697. spca504A_clicksmart420_init_data,
  698. ARRAY_SIZE(spca504A_clicksmart420_init_data));
  699. } else {
  700. write_vector(gspca_dev, spca504_pccam600_init_data,
  701. ARRAY_SIZE(spca504_pccam600_init_data));
  702. }
  703. enable = (sd->autogain ? 0x04 : 0x01);
  704. reg_w_riv(gspca_dev, 0x0c, 0x0000, enable);
  705. /* auto exposure */
  706. reg_w_riv(gspca_dev, 0xb0, 0x0000, enable);
  707. /* auto whiteness */
  708. /* set default exposure compensation and whiteness balance */
  709. reg_w_riv(gspca_dev, 0x30, 0x0001, 800); /* ~ 20 fps */
  710. reg_w_riv(gspca_dev, 0x30, 0x0002, 1600);
  711. spca504B_SetSizeType(gspca_dev);
  712. break;
  713. }
  714. init_ctl_reg(gspca_dev);
  715. return gspca_dev->usb_err;
  716. }
  717. static void sd_stopN(struct gspca_dev *gspca_dev)
  718. {
  719. struct sd *sd = (struct sd *) gspca_dev;
  720. switch (sd->bridge) {
  721. default:
  722. /* case BRIDGE_SPCA533: */
  723. /* case BRIDGE_SPCA536: */
  724. /* case BRIDGE_SPCA504B: */
  725. reg_w_riv(gspca_dev, 0x31, 0, 0);
  726. spca504B_WaitCmdStatus(gspca_dev);
  727. spca504B_PollingDataReady(gspca_dev);
  728. break;
  729. case BRIDGE_SPCA504:
  730. case BRIDGE_SPCA504C:
  731. reg_w_riv(gspca_dev, 0x00, 0x2000, 0x0000);
  732. if (sd->subtype == AiptekMiniPenCam13) {
  733. /* spca504a aiptek */
  734. /* spca504A_acknowledged_command(gspca_dev, 0x08,
  735. 6, 0, 0x86, 1); */
  736. spca504A_acknowledged_command(gspca_dev, 0x24,
  737. 0x00, 0x00, 0x9d, 1);
  738. spca504A_acknowledged_command(gspca_dev, 0x01,
  739. 0x0f, 0x00, 0xff, 1);
  740. } else {
  741. spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
  742. reg_w_riv(gspca_dev, 0x01, 0x000f, 0x0000);
  743. }
  744. break;
  745. }
  746. }
  747. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  748. u8 *data, /* isoc packet */
  749. int len) /* iso packet length */
  750. {
  751. struct sd *sd = (struct sd *) gspca_dev;
  752. int i, sof = 0;
  753. static u8 ffd9[] = {0xff, 0xd9};
  754. /* frames are jpeg 4.1.1 without 0xff escape */
  755. switch (sd->bridge) {
  756. case BRIDGE_SPCA533:
  757. if (data[0] == 0xff) {
  758. if (data[1] != 0x01) { /* drop packet */
  759. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  760. return;
  761. }
  762. sof = 1;
  763. data += SPCA533_OFFSET_DATA;
  764. len -= SPCA533_OFFSET_DATA;
  765. } else {
  766. data += 1;
  767. len -= 1;
  768. }
  769. break;
  770. case BRIDGE_SPCA536:
  771. if (data[0] == 0xff) {
  772. sof = 1;
  773. data += SPCA536_OFFSET_DATA;
  774. len -= SPCA536_OFFSET_DATA;
  775. } else {
  776. data += 2;
  777. len -= 2;
  778. }
  779. break;
  780. default:
  781. /* case BRIDGE_SPCA504: */
  782. /* case BRIDGE_SPCA504B: */
  783. switch (data[0]) {
  784. case 0xfe: /* start of frame */
  785. sof = 1;
  786. data += SPCA50X_OFFSET_DATA;
  787. len -= SPCA50X_OFFSET_DATA;
  788. break;
  789. case 0xff: /* drop packet */
  790. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  791. return;
  792. default:
  793. data += 1;
  794. len -= 1;
  795. break;
  796. }
  797. break;
  798. case BRIDGE_SPCA504C:
  799. switch (data[0]) {
  800. case 0xfe: /* start of frame */
  801. sof = 1;
  802. data += SPCA504_PCCAM600_OFFSET_DATA;
  803. len -= SPCA504_PCCAM600_OFFSET_DATA;
  804. break;
  805. case 0xff: /* drop packet */
  806. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  807. return;
  808. default:
  809. data += 1;
  810. len -= 1;
  811. break;
  812. }
  813. break;
  814. }
  815. if (sof) { /* start of frame */
  816. gspca_frame_add(gspca_dev, LAST_PACKET,
  817. ffd9, 2);
  818. /* put the JPEG header in the new frame */
  819. gspca_frame_add(gspca_dev, FIRST_PACKET,
  820. sd->jpeg_hdr, JPEG_HDR_SZ);
  821. }
  822. /* add 0x00 after 0xff */
  823. i = 0;
  824. do {
  825. if (data[i] == 0xff) {
  826. gspca_frame_add(gspca_dev, INTER_PACKET,
  827. data, i + 1);
  828. len -= i;
  829. data += i;
  830. *data = 0x00;
  831. i = 0;
  832. }
  833. i++;
  834. } while (i < len);
  835. gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
  836. }
  837. static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
  838. {
  839. struct gspca_dev *gspca_dev =
  840. container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
  841. struct sd *sd = (struct sd *)gspca_dev;
  842. gspca_dev->usb_err = 0;
  843. if (!gspca_dev->streaming)
  844. return 0;
  845. switch (ctrl->id) {
  846. case V4L2_CID_BRIGHTNESS:
  847. setbrightness(gspca_dev, ctrl->val);
  848. break;
  849. case V4L2_CID_CONTRAST:
  850. setcontrast(gspca_dev, ctrl->val);
  851. break;
  852. case V4L2_CID_SATURATION:
  853. setcolors(gspca_dev, ctrl->val);
  854. break;
  855. case V4L2_CID_AUTOGAIN:
  856. sd->autogain = ctrl->val;
  857. break;
  858. }
  859. return gspca_dev->usb_err;
  860. }
  861. static const struct v4l2_ctrl_ops sd_ctrl_ops = {
  862. .s_ctrl = sd_s_ctrl,
  863. };
  864. static int sd_init_controls(struct gspca_dev *gspca_dev)
  865. {
  866. struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
  867. gspca_dev->vdev.ctrl_handler = hdl;
  868. v4l2_ctrl_handler_init(hdl, 4);
  869. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  870. V4L2_CID_BRIGHTNESS, -128, 127, 1, 0);
  871. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  872. V4L2_CID_CONTRAST, 0, 255, 1, 0x20);
  873. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  874. V4L2_CID_SATURATION, 0, 255, 1, 0x1a);
  875. v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
  876. V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
  877. if (hdl->error) {
  878. pr_err("Could not initialize controls\n");
  879. return hdl->error;
  880. }
  881. return 0;
  882. }
  883. /* sub-driver description */
  884. static const struct sd_desc sd_desc = {
  885. .name = MODULE_NAME,
  886. .config = sd_config,
  887. .init = sd_init,
  888. .init_controls = sd_init_controls,
  889. .start = sd_start,
  890. .stopN = sd_stopN,
  891. .pkt_scan = sd_pkt_scan,
  892. };
  893. /* -- module initialisation -- */
  894. #define BS(bridge, subtype) \
  895. .driver_info = (BRIDGE_ ## bridge << 8) \
  896. | (subtype)
  897. static const struct usb_device_id device_table[] = {
  898. {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)},
  899. {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)},
  900. {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)},
  901. {USB_DEVICE(0x0458, 0x7006), BS(SPCA504B, 0)},
  902. {USB_DEVICE(0x0461, 0x0821), BS(SPCA533, 0)},
  903. {USB_DEVICE(0x046d, 0x0905), BS(SPCA533, LogitechClickSmart820)},
  904. {USB_DEVICE(0x046d, 0x0960), BS(SPCA504C, LogitechClickSmart420)},
  905. {USB_DEVICE(0x0471, 0x0322), BS(SPCA504B, 0)},
  906. {USB_DEVICE(0x04a5, 0x3003), BS(SPCA504B, 0)},
  907. {USB_DEVICE(0x04a5, 0x3008), BS(SPCA533, 0)},
  908. {USB_DEVICE(0x04a5, 0x300a), BS(SPCA533, 0)},
  909. {USB_DEVICE(0x04f1, 0x1001), BS(SPCA504B, 0)},
  910. {USB_DEVICE(0x04fc, 0x500c), BS(SPCA504B, 0)},
  911. {USB_DEVICE(0x04fc, 0x504a), BS(SPCA504, AiptekMiniPenCam13)},
  912. {USB_DEVICE(0x04fc, 0x504b), BS(SPCA504B, 0)},
  913. {USB_DEVICE(0x04fc, 0x5330), BS(SPCA533, 0)},
  914. {USB_DEVICE(0x04fc, 0x5360), BS(SPCA536, 0)},
  915. {USB_DEVICE(0x04fc, 0xffff), BS(SPCA504B, 0)},
  916. {USB_DEVICE(0x052b, 0x1507), BS(SPCA533, MegapixV4)},
  917. {USB_DEVICE(0x052b, 0x1513), BS(SPCA533, MegapixV4)},
  918. {USB_DEVICE(0x052b, 0x1803), BS(SPCA533, MegaImageVI)},
  919. {USB_DEVICE(0x0546, 0x3155), BS(SPCA533, 0)},
  920. {USB_DEVICE(0x0546, 0x3191), BS(SPCA504B, 0)},
  921. {USB_DEVICE(0x0546, 0x3273), BS(SPCA504B, 0)},
  922. {USB_DEVICE(0x055f, 0xc211), BS(SPCA536, 0)},
  923. {USB_DEVICE(0x055f, 0xc230), BS(SPCA533, 0)},
  924. {USB_DEVICE(0x055f, 0xc232), BS(SPCA533, 0)},
  925. {USB_DEVICE(0x055f, 0xc360), BS(SPCA536, 0)},
  926. {USB_DEVICE(0x055f, 0xc420), BS(SPCA504, 0)},
  927. {USB_DEVICE(0x055f, 0xc430), BS(SPCA533, 0)},
  928. {USB_DEVICE(0x055f, 0xc440), BS(SPCA533, 0)},
  929. {USB_DEVICE(0x055f, 0xc520), BS(SPCA504, 0)},
  930. {USB_DEVICE(0x055f, 0xc530), BS(SPCA533, 0)},
  931. {USB_DEVICE(0x055f, 0xc540), BS(SPCA533, 0)},
  932. {USB_DEVICE(0x055f, 0xc630), BS(SPCA533, 0)},
  933. {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)},
  934. {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)},
  935. {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)},
  936. {USB_DEVICE(0x06d6, 0x0041), BS(SPCA504B, 0)},
  937. {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)},
  938. {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)},
  939. {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)},
  940. {USB_DEVICE(0x0733, 0x2221), BS(SPCA533, 0)},
  941. {USB_DEVICE(0x0733, 0x3261), BS(SPCA536, 0)},
  942. {USB_DEVICE(0x0733, 0x3281), BS(SPCA536, 0)},
  943. {USB_DEVICE(0x08ca, 0x0104), BS(SPCA533, 0)},
  944. {USB_DEVICE(0x08ca, 0x0106), BS(SPCA533, 0)},
  945. {USB_DEVICE(0x08ca, 0x2008), BS(SPCA504B, 0)},
  946. {USB_DEVICE(0x08ca, 0x2010), BS(SPCA533, 0)},
  947. {USB_DEVICE(0x08ca, 0x2016), BS(SPCA504B, 0)},
  948. {USB_DEVICE(0x08ca, 0x2018), BS(SPCA504B, 0)},
  949. {USB_DEVICE(0x08ca, 0x2020), BS(SPCA533, 0)},
  950. {USB_DEVICE(0x08ca, 0x2022), BS(SPCA533, 0)},
  951. {USB_DEVICE(0x08ca, 0x2024), BS(SPCA536, 0)},
  952. {USB_DEVICE(0x08ca, 0x2028), BS(SPCA533, 0)},
  953. {USB_DEVICE(0x08ca, 0x2040), BS(SPCA536, 0)},
  954. {USB_DEVICE(0x08ca, 0x2042), BS(SPCA536, 0)},
  955. {USB_DEVICE(0x08ca, 0x2050), BS(SPCA536, 0)},
  956. {USB_DEVICE(0x08ca, 0x2060), BS(SPCA536, 0)},
  957. {USB_DEVICE(0x0d64, 0x0303), BS(SPCA536, 0)},
  958. {}
  959. };
  960. MODULE_DEVICE_TABLE(usb, device_table);
  961. /* -- device connect -- */
  962. static int sd_probe(struct usb_interface *intf,
  963. const struct usb_device_id *id)
  964. {
  965. return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
  966. THIS_MODULE);
  967. }
  968. static struct usb_driver sd_driver = {
  969. .name = MODULE_NAME,
  970. .id_table = device_table,
  971. .probe = sd_probe,
  972. .disconnect = gspca_disconnect,
  973. #ifdef CONFIG_PM
  974. .suspend = gspca_suspend,
  975. .resume = gspca_resume,
  976. .reset_resume = gspca_resume,
  977. #endif
  978. };
  979. module_usb_driver(sd_driver);