sunplus.c 29 KB

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