spca561.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. /*
  2. * Sunplus spca561 subdriver
  3. *
  4. * Copyright (C) 2004 Michel Xhaard mxhaard@magic.fr
  5. *
  6. * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #define MODULE_NAME "spca561"
  23. #include "gspca.h"
  24. MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
  25. MODULE_DESCRIPTION("GSPCA/SPCA561 USB Camera Driver");
  26. MODULE_LICENSE("GPL");
  27. /* specific webcam descriptor */
  28. struct sd {
  29. struct gspca_dev gspca_dev; /* !! must be the first item */
  30. __u16 contrast; /* rev72a only */
  31. #define CONTRAST_MIN 0x0000
  32. #define CONTRAST_DEF 0x2000
  33. #define CONTRAST_MAX 0x3fff
  34. __u16 exposure; /* rev12a only */
  35. #define EXPOSURE_MIN 0x0120
  36. #define EXPOSURE_DEF 0x20ae
  37. #define EXPOSURE_MAX 0x5720
  38. __u8 brightness; /* rev72a only */
  39. #define BRIGHTNESS_MIN 0
  40. #define BRIGHTNESS_DEF 32
  41. #define BRIGHTNESS_MAX 63
  42. __u8 white; /* rev12a only */
  43. #define WHITE_MIN 0
  44. #define WHITE_DEF 0x40
  45. #define WHITE_MAX 0x7f
  46. __u8 autogain;
  47. #define AUTOGAIN_MIN 0
  48. #define AUTOGAIN_DEF 1
  49. #define AUTOGAIN_MAX 1
  50. __u8 gain; /* rev12a only */
  51. #define GAIN_MIN 0x0
  52. #define GAIN_DEF 0x24
  53. #define GAIN_MAX 0x24
  54. __u8 chip_revision;
  55. #define Rev012A 0
  56. #define Rev072A 1
  57. signed char ag_cnt;
  58. #define AG_CNT_START 13
  59. };
  60. static struct v4l2_pix_format sif_mode[] = {
  61. {160, 120, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE,
  62. .bytesperline = 160,
  63. .sizeimage = 160 * 120,
  64. .colorspace = V4L2_COLORSPACE_SRGB,
  65. .priv = 3},
  66. {176, 144, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE,
  67. .bytesperline = 176,
  68. .sizeimage = 176 * 144,
  69. .colorspace = V4L2_COLORSPACE_SRGB,
  70. .priv = 2},
  71. {320, 240, V4L2_PIX_FMT_SPCA561, V4L2_FIELD_NONE,
  72. .bytesperline = 320,
  73. .sizeimage = 320 * 240 * 4 / 8,
  74. .colorspace = V4L2_COLORSPACE_SRGB,
  75. .priv = 1},
  76. {352, 288, V4L2_PIX_FMT_SPCA561, V4L2_FIELD_NONE,
  77. .bytesperline = 352,
  78. .sizeimage = 352 * 288 * 4 / 8,
  79. .colorspace = V4L2_COLORSPACE_SRGB,
  80. .priv = 0},
  81. };
  82. /*
  83. * Initialization data
  84. * I'm not very sure how to split initialization from open data
  85. * chunks. For now, we'll consider everything as initialization
  86. */
  87. /* Frame packet header offsets for the spca561 */
  88. #define SPCA561_OFFSET_SNAP 1
  89. #define SPCA561_OFFSET_TYPE 2
  90. #define SPCA561_OFFSET_COMPRESS 3
  91. #define SPCA561_OFFSET_FRAMSEQ 4
  92. #define SPCA561_OFFSET_GPIO 5
  93. #define SPCA561_OFFSET_USBBUFF 6
  94. #define SPCA561_OFFSET_WIN2GRAVE 7
  95. #define SPCA561_OFFSET_WIN2RAVE 8
  96. #define SPCA561_OFFSET_WIN2BAVE 9
  97. #define SPCA561_OFFSET_WIN2GBAVE 10
  98. #define SPCA561_OFFSET_WIN1GRAVE 11
  99. #define SPCA561_OFFSET_WIN1RAVE 12
  100. #define SPCA561_OFFSET_WIN1BAVE 13
  101. #define SPCA561_OFFSET_WIN1GBAVE 14
  102. #define SPCA561_OFFSET_FREQ 15
  103. #define SPCA561_OFFSET_VSYNC 16
  104. #define SPCA561_OFFSET_DATA 1
  105. #define SPCA561_INDEX_I2C_BASE 0x8800
  106. #define SPCA561_SNAPBIT 0x20
  107. #define SPCA561_SNAPCTRL 0x40
  108. static void reg_w_val(struct usb_device *dev, __u16 index, __u8 value)
  109. {
  110. int ret;
  111. ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
  112. 0, /* request */
  113. USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  114. value, index, NULL, 0, 500);
  115. PDEBUG(D_USBO, "reg write: 0x%02x:0x%02x", index, value);
  116. if (ret < 0)
  117. PDEBUG(D_ERR, "reg write: error %d", ret);
  118. }
  119. static void write_vector(struct gspca_dev *gspca_dev,
  120. const __u16 data[][2])
  121. {
  122. struct usb_device *dev = gspca_dev->dev;
  123. int i;
  124. i = 0;
  125. while (data[i][1] != 0) {
  126. reg_w_val(dev, data[i][1], data[i][0]);
  127. i++;
  128. }
  129. }
  130. /* read 'len' bytes to gspca_dev->usb_buf */
  131. static void reg_r(struct gspca_dev *gspca_dev,
  132. __u16 index, __u16 length)
  133. {
  134. usb_control_msg(gspca_dev->dev,
  135. usb_rcvctrlpipe(gspca_dev->dev, 0),
  136. 0, /* request */
  137. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  138. 0, /* value */
  139. index, gspca_dev->usb_buf, length, 500);
  140. }
  141. static void reg_w_buf(struct gspca_dev *gspca_dev,
  142. __u16 index, const __u8 *buffer, __u16 len)
  143. {
  144. memcpy(gspca_dev->usb_buf, buffer, len);
  145. usb_control_msg(gspca_dev->dev,
  146. usb_sndctrlpipe(gspca_dev->dev, 0),
  147. 0, /* request */
  148. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  149. 0, /* value */
  150. index, gspca_dev->usb_buf, len, 500);
  151. }
  152. static void i2c_write(struct gspca_dev *gspca_dev, __u16 valeur, __u16 reg)
  153. {
  154. int retry = 60;
  155. __u8 DataLow;
  156. __u8 DataHight;
  157. DataLow = valeur;
  158. DataHight = valeur >> 8;
  159. reg_w_val(gspca_dev->dev, 0x8801, reg);
  160. reg_w_val(gspca_dev->dev, 0x8805, DataLow);
  161. reg_w_val(gspca_dev->dev, 0x8800, DataHight);
  162. while (retry--) {
  163. reg_r(gspca_dev, 0x8803, 1);
  164. if (!gspca_dev->usb_buf[0])
  165. break;
  166. }
  167. }
  168. static int i2c_read(struct gspca_dev *gspca_dev, __u16 reg, __u8 mode)
  169. {
  170. int retry = 60;
  171. __u8 value;
  172. __u8 vallsb;
  173. reg_w_val(gspca_dev->dev, 0x8804, 0x92);
  174. reg_w_val(gspca_dev->dev, 0x8801, reg);
  175. reg_w_val(gspca_dev->dev, 0x8802, (mode | 0x01));
  176. while (retry--) {
  177. reg_r(gspca_dev, 0x8803, 1);
  178. if (!gspca_dev->usb_buf)
  179. break;
  180. }
  181. if (retry == 0)
  182. return -1;
  183. reg_r(gspca_dev, 0x8800, 1);
  184. value = gspca_dev->usb_buf[0];
  185. reg_r(gspca_dev, 0x8805, 1);
  186. vallsb = gspca_dev->usb_buf[0];
  187. return ((int) value << 8) | vallsb;
  188. }
  189. static const __u16 spca561_init_data[][2] = {
  190. {0x0000, 0x8114}, /* Software GPIO output data */
  191. {0x0001, 0x8114}, /* Software GPIO output data */
  192. {0x0000, 0x8112}, /* Some kind of reset */
  193. {0x0003, 0x8701}, /* PCLK clock delay adjustment */
  194. {0x0001, 0x8703}, /* HSYNC from cmos inverted */
  195. {0x0011, 0x8118}, /* Enable and conf sensor */
  196. {0x0001, 0x8118}, /* Conf sensor */
  197. {0x0092, 0x8804}, /* I know nothing about these */
  198. {0x0010, 0x8802}, /* 0x88xx registers, so I won't */
  199. /***************/
  200. {0x000d, 0x8805}, /* sensor default setting */
  201. {0x0001, 0x8801}, /* 1 <- 0x0d */
  202. {0x0000, 0x8800},
  203. {0x0018, 0x8805},
  204. {0x0002, 0x8801}, /* 2 <- 0x18 */
  205. {0x0000, 0x8800},
  206. {0x0065, 0x8805},
  207. {0x0004, 0x8801}, /* 4 <- 0x01 0x65 */
  208. {0x0001, 0x8800},
  209. {0x0021, 0x8805},
  210. {0x0005, 0x8801}, /* 5 <- 0x21 */
  211. {0x0000, 0x8800},
  212. {0x00aa, 0x8805},
  213. {0x0007, 0x8801}, /* 7 <- 0xaa */
  214. {0x0000, 0x8800},
  215. {0x0004, 0x8805},
  216. {0x0020, 0x8801}, /* 0x20 <- 0x15 0x04 */
  217. {0x0015, 0x8800},
  218. {0x0002, 0x8805},
  219. {0x0039, 0x8801}, /* 0x39 <- 0x02 */
  220. {0x0000, 0x8800},
  221. {0x0010, 0x8805},
  222. {0x0035, 0x8801}, /* 0x35 <- 0x10 */
  223. {0x0000, 0x8800},
  224. {0x0049, 0x8805},
  225. {0x0009, 0x8801}, /* 0x09 <- 0x10 0x49 */
  226. {0x0010, 0x8800},
  227. {0x000b, 0x8805},
  228. {0x0028, 0x8801}, /* 0x28 <- 0x0b */
  229. {0x0000, 0x8800},
  230. {0x000f, 0x8805},
  231. {0x003b, 0x8801}, /* 0x3b <- 0x0f */
  232. {0x0000, 0x8800},
  233. {0x0000, 0x8805},
  234. {0x003c, 0x8801}, /* 0x3c <- 0x00 */
  235. {0x0000, 0x8800},
  236. /***************/
  237. {0x0018, 0x8601}, /* Pixel/line selection for color separation */
  238. {0x0000, 0x8602}, /* Optical black level for user setting */
  239. {0x0060, 0x8604}, /* Optical black horizontal offset */
  240. {0x0002, 0x8605}, /* Optical black vertical offset */
  241. {0x0000, 0x8603}, /* Non-automatic optical black level */
  242. {0x0002, 0x865b}, /* Horizontal offset for valid pixels */
  243. {0x0000, 0x865f}, /* Vertical valid pixels window (x2) */
  244. {0x00b0, 0x865d}, /* Horizontal valid pixels window (x2) */
  245. {0x0090, 0x865e}, /* Vertical valid lines window (x2) */
  246. {0x00e0, 0x8406}, /* Memory buffer threshold */
  247. {0x0000, 0x8660}, /* Compensation memory stuff */
  248. {0x0002, 0x8201}, /* Output address for r/w serial EEPROM */
  249. {0x0008, 0x8200}, /* Clear valid bit for serial EEPROM */
  250. {0x0001, 0x8200}, /* OprMode to be executed by hardware */
  251. {0x0007, 0x8201}, /* Output address for r/w serial EEPROM */
  252. {0x0008, 0x8200}, /* Clear valid bit for serial EEPROM */
  253. {0x0001, 0x8200}, /* OprMode to be executed by hardware */
  254. {0x0010, 0x8660}, /* Compensation memory stuff */
  255. {0x0018, 0x8660}, /* Compensation memory stuff */
  256. {0x0004, 0x8611}, /* R offset for white balance */
  257. {0x0004, 0x8612}, /* Gr offset for white balance */
  258. {0x0007, 0x8613}, /* B offset for white balance */
  259. {0x0000, 0x8614}, /* Gb offset for white balance */
  260. {0x008c, 0x8651}, /* R gain for white balance */
  261. {0x008c, 0x8652}, /* Gr gain for white balance */
  262. {0x00b5, 0x8653}, /* B gain for white balance */
  263. {0x008c, 0x8654}, /* Gb gain for white balance */
  264. {0x0002, 0x8502}, /* Maximum average bit rate stuff */
  265. {0x0011, 0x8802},
  266. {0x0087, 0x8700}, /* Set master clock (96Mhz????) */
  267. {0x0081, 0x8702}, /* Master clock output enable */
  268. {0x0000, 0x8500}, /* Set image type (352x288 no compression) */
  269. /* Originally was 0x0010 (352x288 compression) */
  270. {0x0002, 0x865b}, /* Horizontal offset for valid pixels */
  271. {0x0003, 0x865c}, /* Vertical offset for valid lines */
  272. /***************//* sensor active */
  273. {0x0003, 0x8801}, /* 0x03 <- 0x01 0x21 //289 */
  274. {0x0021, 0x8805},
  275. {0x0001, 0x8800},
  276. {0x0004, 0x8801}, /* 0x04 <- 0x01 0x65 //357 */
  277. {0x0065, 0x8805},
  278. {0x0001, 0x8800},
  279. {0x0005, 0x8801}, /* 0x05 <- 0x2f */
  280. {0x002f, 0x8805},
  281. {0x0000, 0x8800},
  282. {0x0006, 0x8801}, /* 0x06 <- 0 */
  283. {0x0000, 0x8805},
  284. {0x0000, 0x8800},
  285. {0x000a, 0x8801}, /* 0x0a <- 2 */
  286. {0x0002, 0x8805},
  287. {0x0000, 0x8800},
  288. {0x0009, 0x8801}, /* 0x09 <- 0x1061 */
  289. {0x0061, 0x8805},
  290. {0x0010, 0x8800},
  291. {0x0035, 0x8801}, /* 0x35 <-0x14 */
  292. {0x0014, 0x8805},
  293. {0x0000, 0x8800},
  294. {0x0030, 0x8112}, /* ISO and drop packet enable */
  295. {0x0000, 0x8112}, /* Some kind of reset ???? */
  296. {0x0009, 0x8118}, /* Enable sensor and set standby */
  297. {0x0000, 0x8114}, /* Software GPIO output data */
  298. {0x0000, 0x8114}, /* Software GPIO output data */
  299. {0x0001, 0x8114}, /* Software GPIO output data */
  300. {0x0000, 0x8112}, /* Some kind of reset ??? */
  301. {0x0003, 0x8701},
  302. {0x0001, 0x8703},
  303. {0x0011, 0x8118},
  304. {0x0001, 0x8118},
  305. /***************/
  306. {0x0092, 0x8804},
  307. {0x0010, 0x8802},
  308. {0x000d, 0x8805},
  309. {0x0001, 0x8801},
  310. {0x0000, 0x8800},
  311. {0x0018, 0x8805},
  312. {0x0002, 0x8801},
  313. {0x0000, 0x8800},
  314. {0x0065, 0x8805},
  315. {0x0004, 0x8801},
  316. {0x0001, 0x8800},
  317. {0x0021, 0x8805},
  318. {0x0005, 0x8801},
  319. {0x0000, 0x8800},
  320. {0x00aa, 0x8805},
  321. {0x0007, 0x8801}, /* mode 0xaa */
  322. {0x0000, 0x8800},
  323. {0x0004, 0x8805},
  324. {0x0020, 0x8801},
  325. {0x0015, 0x8800}, /* mode 0x0415 */
  326. {0x0002, 0x8805},
  327. {0x0039, 0x8801},
  328. {0x0000, 0x8800},
  329. {0x0010, 0x8805},
  330. {0x0035, 0x8801},
  331. {0x0000, 0x8800},
  332. {0x0049, 0x8805},
  333. {0x0009, 0x8801},
  334. {0x0010, 0x8800},
  335. {0x000b, 0x8805},
  336. {0x0028, 0x8801},
  337. {0x0000, 0x8800},
  338. {0x000f, 0x8805},
  339. {0x003b, 0x8801},
  340. {0x0000, 0x8800},
  341. {0x0000, 0x8805},
  342. {0x003c, 0x8801},
  343. {0x0000, 0x8800},
  344. {0x0002, 0x8502},
  345. {0x0039, 0x8801},
  346. {0x0000, 0x8805},
  347. {0x0000, 0x8800},
  348. {0x0087, 0x8700}, /* overwrite by start */
  349. {0x0081, 0x8702},
  350. {0x0000, 0x8500},
  351. /* {0x0010, 0x8500}, -- Previous line was this */
  352. {0x0002, 0x865b},
  353. {0x0003, 0x865c},
  354. /***************/
  355. {0x0003, 0x8801}, /* 0x121-> 289 */
  356. {0x0021, 0x8805},
  357. {0x0001, 0x8800},
  358. {0x0004, 0x8801}, /* 0x165 -> 357 */
  359. {0x0065, 0x8805},
  360. {0x0001, 0x8800},
  361. {0x0005, 0x8801}, /* 0x2f //blanking control colonne */
  362. {0x002f, 0x8805},
  363. {0x0000, 0x8800},
  364. {0x0006, 0x8801}, /* 0x00 //blanking mode row */
  365. {0x0000, 0x8805},
  366. {0x0000, 0x8800},
  367. {0x000a, 0x8801}, /* 0x01 //0x02 */
  368. {0x0001, 0x8805},
  369. {0x0000, 0x8800},
  370. {0x0009, 0x8801}, /* 0x1061 - setexposure times && pixel clock
  371. * 0001 0 | 000 0110 0001 */
  372. {0x0061, 0x8805}, /* 61 31 */
  373. {0x0008, 0x8800}, /* 08 */
  374. {0x0035, 0x8801}, /* 0x14 - set gain general */
  375. {0x001f, 0x8805}, /* 0x14 */
  376. {0x0000, 0x8800},
  377. {0x000e, 0x8112}, /* white balance - was 30 */
  378. {}
  379. };
  380. /******************** QC Express etch2 stuff ********************/
  381. static const __u16 Pb100_1map8300[][2] = {
  382. /* reg, value */
  383. {0x8320, 0x3304},
  384. {0x8303, 0x0125}, /* image area */
  385. {0x8304, 0x0169},
  386. {0x8328, 0x000b},
  387. {0x833c, 0x0001}, /*fixme: win:07*/
  388. {0x832f, 0x1904}, /*fixme: was 0419*/
  389. {0x8307, 0x00aa},
  390. {0x8301, 0x0003},
  391. {0x8302, 0x000e},
  392. {}
  393. };
  394. static const __u16 Pb100_2map8300[][2] = {
  395. /* reg, value */
  396. {0x8339, 0x0000},
  397. {0x8307, 0x00aa},
  398. {}
  399. };
  400. static const __u16 spca561_161rev12A_data1[][2] = {
  401. {0x29, 0x8118}, /* white balance - was 21 */
  402. {0x08, 0x8114}, /* white balance - was 01 */
  403. {0x0e, 0x8112}, /* white balance - was 00 */
  404. {0x00, 0x8102}, /* white balance - new */
  405. {0x92, 0x8804},
  406. {0x04, 0x8802}, /* windows uses 08 */
  407. {}
  408. };
  409. static const __u16 spca561_161rev12A_data2[][2] = {
  410. {0x21, 0x8118},
  411. {0x10, 0x8500},
  412. {0x07, 0x8601},
  413. {0x07, 0x8602},
  414. {0x04, 0x8501},
  415. {0x21, 0x8118},
  416. {0x07, 0x8201}, /* windows uses 02 */
  417. {0x08, 0x8200},
  418. {0x01, 0x8200},
  419. {0x00, 0x8114},
  420. {0x01, 0x8114}, /* windows uses 00 */
  421. {0x90, 0x8604},
  422. {0x00, 0x8605},
  423. {0xb0, 0x8603},
  424. /* sensor gains */
  425. {0x07, 0x8601}, /* white balance - new */
  426. {0x07, 0x8602}, /* white balance - new */
  427. {0x00, 0x8610}, /* *red */
  428. {0x00, 0x8611}, /* 3f *green */
  429. {0x00, 0x8612}, /* green *blue */
  430. {0x00, 0x8613}, /* blue *green */
  431. {0x43, 0x8614}, /* green *red - white balance - was 0x35 */
  432. {0x40, 0x8615}, /* 40 *green - white balance - was 0x35 */
  433. {0x71, 0x8616}, /* 7a *blue - white balance - was 0x35 */
  434. {0x40, 0x8617}, /* 40 *green - white balance - was 0x35 */
  435. {0x0c, 0x8620}, /* 0c */
  436. {0xc8, 0x8631}, /* c8 */
  437. {0xc8, 0x8634}, /* c8 */
  438. {0x23, 0x8635}, /* 23 */
  439. {0x1f, 0x8636}, /* 1f */
  440. {0xdd, 0x8637}, /* dd */
  441. {0xe1, 0x8638}, /* e1 */
  442. {0x1d, 0x8639}, /* 1d */
  443. {0x21, 0x863a}, /* 21 */
  444. {0xe3, 0x863b}, /* e3 */
  445. {0xdf, 0x863c}, /* df */
  446. {0xf0, 0x8505},
  447. {0x32, 0x850a},
  448. /* {0x99, 0x8700}, * - white balance - new (removed) */
  449. {}
  450. };
  451. static void sensor_mapwrite(struct gspca_dev *gspca_dev,
  452. const __u16 sensormap[][2])
  453. {
  454. int i = 0;
  455. __u8 usbval[2];
  456. while (sensormap[i][0]) {
  457. usbval[0] = sensormap[i][1];
  458. usbval[1] = sensormap[i][1] >> 8;
  459. reg_w_buf(gspca_dev, sensormap[i][0], usbval, 2);
  460. i++;
  461. }
  462. }
  463. static void init_161rev12A(struct gspca_dev *gspca_dev)
  464. {
  465. /* sensor_reset(gspca_dev); (not in win) */
  466. write_vector(gspca_dev, spca561_161rev12A_data1);
  467. sensor_mapwrite(gspca_dev, Pb100_1map8300);
  468. /*fixme: should be in sd_start*/
  469. write_vector(gspca_dev, spca561_161rev12A_data2);
  470. sensor_mapwrite(gspca_dev, Pb100_2map8300);
  471. }
  472. /* this function is called at probe time */
  473. static int sd_config(struct gspca_dev *gspca_dev,
  474. const struct usb_device_id *id)
  475. {
  476. struct sd *sd = (struct sd *) gspca_dev;
  477. struct cam *cam;
  478. __u16 vendor, product;
  479. __u8 data1, data2;
  480. /* Read frm global register the USB product and vendor IDs, just to
  481. * prove that we can communicate with the device. This works, which
  482. * confirms at we are communicating properly and that the device
  483. * is a 561. */
  484. reg_r(gspca_dev, 0x8104, 1);
  485. data1 = gspca_dev->usb_buf[0];
  486. reg_r(gspca_dev, 0x8105, 1);
  487. data2 = gspca_dev->usb_buf[0];
  488. vendor = (data2 << 8) | data1;
  489. reg_r(gspca_dev, 0x8106, 1);
  490. data1 = gspca_dev->usb_buf[0];
  491. reg_r(gspca_dev, 0x8107, 1);
  492. data2 = gspca_dev->usb_buf[0];
  493. product = (data2 << 8) | data1;
  494. if (vendor != id->idVendor || product != id->idProduct) {
  495. PDEBUG(D_PROBE, "Bad vendor / product from device");
  496. return -EINVAL;
  497. }
  498. cam = &gspca_dev->cam;
  499. cam->epaddr = 0x01;
  500. gspca_dev->nbalt = 7 + 1; /* choose alternate 7 first */
  501. cam->cam_mode = sif_mode;
  502. cam->nmodes = ARRAY_SIZE(sif_mode);
  503. sd->chip_revision = id->driver_info;
  504. sd->brightness = BRIGHTNESS_DEF;
  505. sd->contrast = CONTRAST_DEF;
  506. sd->white = WHITE_DEF;
  507. sd->exposure = EXPOSURE_DEF;
  508. sd->autogain = AUTOGAIN_DEF;
  509. sd->gain = GAIN_DEF;
  510. return 0;
  511. }
  512. /* this function is called at open time */
  513. static int sd_open_12a(struct gspca_dev *gspca_dev)
  514. {
  515. PDEBUG(D_STREAM, "Chip revision: 012a");
  516. init_161rev12A(gspca_dev);
  517. return 0;
  518. }
  519. static int sd_open_72a(struct gspca_dev *gspca_dev)
  520. {
  521. PDEBUG(D_STREAM, "Chip revision: 072a");
  522. write_vector(gspca_dev, spca561_init_data);
  523. return 0;
  524. }
  525. static void setcontrast(struct gspca_dev *gspca_dev)
  526. {
  527. struct sd *sd = (struct sd *) gspca_dev;
  528. struct usb_device *dev = gspca_dev->dev;
  529. __u8 lowb;
  530. switch (sd->chip_revision) {
  531. case Rev072A:
  532. lowb = sd->contrast >> 8;
  533. reg_w_val(dev, 0x8651, lowb);
  534. reg_w_val(dev, 0x8652, lowb);
  535. reg_w_val(dev, 0x8653, lowb);
  536. reg_w_val(dev, 0x8654, lowb);
  537. break;
  538. default: {
  539. /* case Rev012A: { */
  540. static const __u8 Reg8391[] =
  541. { 0x92, 0x30, 0x20, 0x00, 0x0c, 0x00, 0x00, 0x00 };
  542. reg_w_buf(gspca_dev, 0x8391, Reg8391, 8);
  543. reg_w_buf(gspca_dev, 0x8390, Reg8391, 8);
  544. break;
  545. }
  546. }
  547. }
  548. /* rev12a only */
  549. static void setwhite(struct gspca_dev *gspca_dev)
  550. {
  551. struct sd *sd = (struct sd *) gspca_dev;
  552. __u16 white;
  553. __u8 reg8614, reg8616;
  554. white = sd->white;
  555. if (sd->white == 0) {
  556. PDEBUG(D_CONF, "Discarding null whiteness");
  557. return;
  558. }
  559. /* try to emulate MS-win as possible */
  560. if (white < 0x45)
  561. reg8616 = white;
  562. else
  563. reg8616 = 0x93 + (white >> 2);
  564. reg8614 = 0x28 + (white >> 4);
  565. reg_w_val(gspca_dev->dev, 0x8616, reg8616);
  566. reg_w_val(gspca_dev->dev, 0x8614, reg8614);
  567. }
  568. /* rev 12a only */
  569. static void setexposure(struct gspca_dev *gspca_dev)
  570. {
  571. struct sd *sd = (struct sd *) gspca_dev;
  572. struct usb_device *dev = gspca_dev->dev;
  573. reg_w_val(dev, 0x8309, sd->gain);
  574. }
  575. /* rev 12a only */
  576. static void setgain(struct gspca_dev *gspca_dev)
  577. {
  578. struct sd *sd = (struct sd *) gspca_dev;
  579. struct usb_device *dev = gspca_dev->dev;
  580. reg_w_val(dev, 0x8335, sd->gain);
  581. }
  582. static void setautogain(struct gspca_dev *gspca_dev)
  583. {
  584. struct sd *sd = (struct sd *) gspca_dev;
  585. if (sd->chip_revision == Rev072A) {
  586. if (sd->autogain)
  587. sd->ag_cnt = AG_CNT_START;
  588. else
  589. sd->ag_cnt = -1;
  590. }
  591. }
  592. static void sd_start_12a(struct gspca_dev *gspca_dev)
  593. {
  594. struct usb_device *dev = gspca_dev->dev;
  595. int Clck;
  596. __u8 Reg8307[] = { 0xaa, 0x00 };
  597. int mode;
  598. mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
  599. switch (mode) {
  600. case 0:
  601. case 1:
  602. Clck = 0x8a;
  603. break;
  604. case 2:
  605. Clck = 0x85;
  606. break;
  607. default:
  608. Clck = 0x83;
  609. break;
  610. }
  611. if (mode <= 1) {
  612. /* Use compression on 320x240 and above */
  613. reg_w_val(dev, 0x8500, 0x10 | mode);
  614. } else {
  615. /* I couldn't get the compression to work below 320x240
  616. * Fortunately at these resolutions the bandwidth
  617. * is sufficient to push raw frames at ~20fps */
  618. reg_w_val(dev, 0x8500, mode);
  619. } /* -- qq@kuku.eu.org */
  620. reg_w_buf(gspca_dev, 0x8307, Reg8307, 2);
  621. reg_w_val(gspca_dev->dev, 0x8700, Clck);
  622. /* 0x8f 0x85 0x27 clock */
  623. reg_w_val(gspca_dev->dev, 0x8112, 0x1e | 0x20);
  624. reg_w_val(gspca_dev->dev, 0x850b, 0x03);
  625. setcontrast(gspca_dev);
  626. setwhite(gspca_dev);
  627. }
  628. static void sd_start_72a(struct gspca_dev *gspca_dev)
  629. {
  630. struct usb_device *dev = gspca_dev->dev;
  631. int Clck;
  632. int mode;
  633. mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
  634. switch (mode) {
  635. default:
  636. /* case 0:
  637. case 1: */
  638. Clck = 0x25;
  639. break;
  640. case 2:
  641. Clck = 0x22;
  642. break;
  643. case 3:
  644. Clck = 0x21;
  645. break;
  646. }
  647. reg_w_val(dev, 0x8500, mode); /* mode */
  648. reg_w_val(dev, 0x8700, Clck); /* 0x27 clock */
  649. reg_w_val(dev, 0x8112, 0x10 | 0x20);
  650. setautogain(gspca_dev);
  651. }
  652. static void sd_stopN(struct gspca_dev *gspca_dev)
  653. {
  654. reg_w_val(gspca_dev->dev, 0x8112, 0x20);
  655. reg_w_val(gspca_dev->dev, 0x8102, 0x00); /* white balance - new */
  656. }
  657. static void sd_stop0(struct gspca_dev *gspca_dev)
  658. {
  659. }
  660. /* this function is called at close time */
  661. static void sd_close(struct gspca_dev *gspca_dev)
  662. {
  663. reg_w_val(gspca_dev->dev, 0x8114, 0);
  664. }
  665. /* rev72a only */
  666. static void do_autogain(struct gspca_dev *gspca_dev)
  667. {
  668. struct sd *sd = (struct sd *) gspca_dev;
  669. int expotimes;
  670. int pixelclk;
  671. int gainG;
  672. __u8 R, Gr, Gb, B;
  673. int y;
  674. __u8 luma_mean = 110;
  675. __u8 luma_delta = 20;
  676. __u8 spring = 4;
  677. if (sd->ag_cnt < 0)
  678. return;
  679. if (--sd->ag_cnt >= 0)
  680. return;
  681. sd->ag_cnt = AG_CNT_START;
  682. switch (sd->chip_revision) {
  683. case Rev072A:
  684. reg_r(gspca_dev, 0x8621, 1);
  685. Gr = gspca_dev->usb_buf[0];
  686. reg_r(gspca_dev, 0x8622, 1);
  687. R = gspca_dev->usb_buf[0];
  688. reg_r(gspca_dev, 0x8623, 1);
  689. B = gspca_dev->usb_buf[0];
  690. reg_r(gspca_dev, 0x8624, 1);
  691. Gb = gspca_dev->usb_buf[0];
  692. y = (77 * R + 75 * (Gr + Gb) + 29 * B) >> 8;
  693. /* u= (128*B-(43*(Gr+Gb+R))) >> 8; */
  694. /* v= (128*R-(53*(Gr+Gb))-21*B) >> 8; */
  695. /* PDEBUG(D_CONF,"reading Y %d U %d V %d ",y,u,v); */
  696. if (y < luma_mean - luma_delta ||
  697. y > luma_mean + luma_delta) {
  698. expotimes = i2c_read(gspca_dev, 0x09, 0x10);
  699. pixelclk = 0x0800;
  700. expotimes = expotimes & 0x07ff;
  701. /* PDEBUG(D_PACK,
  702. "Exposition Times 0x%03X Clock 0x%04X ",
  703. expotimes,pixelclk); */
  704. gainG = i2c_read(gspca_dev, 0x35, 0x10);
  705. /* PDEBUG(D_PACK,
  706. "reading Gain register %d", gainG); */
  707. expotimes += (luma_mean - y) >> spring;
  708. gainG += (luma_mean - y) / 50;
  709. /* PDEBUG(D_PACK,
  710. "compute expotimes %d gain %d",
  711. expotimes,gainG); */
  712. if (gainG > 0x3f)
  713. gainG = 0x3f;
  714. else if (gainG < 4)
  715. gainG = 3;
  716. i2c_write(gspca_dev, gainG, 0x35);
  717. if (expotimes >= 0x0256)
  718. expotimes = 0x0256;
  719. else if (expotimes < 4)
  720. expotimes = 3;
  721. i2c_write(gspca_dev, expotimes | pixelclk, 0x09);
  722. }
  723. break;
  724. case Rev012A:
  725. /* sensor registers is access and memory mapped to 0x8300 */
  726. /* readind all 0x83xx block the sensor */
  727. /*
  728. * The data from the header seem wrong where is the luma
  729. * and chroma mean value
  730. * at the moment set exposure in contrast set
  731. */
  732. break;
  733. }
  734. }
  735. static void sd_pkt_scan(struct gspca_dev *gspca_dev,
  736. struct gspca_frame *frame, /* target */
  737. __u8 *data, /* isoc packet */
  738. int len) /* iso packet length */
  739. {
  740. switch (data[0]) {
  741. case 0: /* start of frame */
  742. frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
  743. data, 0);
  744. data += SPCA561_OFFSET_DATA;
  745. len -= SPCA561_OFFSET_DATA;
  746. if (data[1] & 0x10) {
  747. /* compressed bayer */
  748. gspca_frame_add(gspca_dev, FIRST_PACKET,
  749. frame, data, len);
  750. } else {
  751. /* raw bayer (with a header, which we skip) */
  752. data += 20;
  753. len -= 20;
  754. gspca_frame_add(gspca_dev, FIRST_PACKET,
  755. frame, data, len);
  756. }
  757. return;
  758. case 0xff: /* drop */
  759. /* gspca_dev->last_packet_type = DISCARD_PACKET; */
  760. return;
  761. }
  762. data++;
  763. len--;
  764. gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
  765. }
  766. /* rev 72a only */
  767. static void setbrightness(struct gspca_dev *gspca_dev)
  768. {
  769. struct sd *sd = (struct sd *) gspca_dev;
  770. __u8 value;
  771. value = sd->brightness;
  772. reg_w_val(gspca_dev->dev, 0x8611, value);
  773. reg_w_val(gspca_dev->dev, 0x8612, value);
  774. reg_w_val(gspca_dev->dev, 0x8613, value);
  775. reg_w_val(gspca_dev->dev, 0x8614, value);
  776. }
  777. static void getbrightness(struct gspca_dev *gspca_dev)
  778. {
  779. struct sd *sd = (struct sd *) gspca_dev;
  780. __u16 tot;
  781. tot = 0;
  782. reg_r(gspca_dev, 0x8611, 1);
  783. tot += gspca_dev->usb_buf[0];
  784. reg_r(gspca_dev, 0x8612, 1);
  785. tot += gspca_dev->usb_buf[0];
  786. reg_r(gspca_dev, 0x8613, 1);
  787. tot += gspca_dev->usb_buf[0];
  788. reg_r(gspca_dev, 0x8614, 1);
  789. tot += gspca_dev->usb_buf[0];
  790. sd->brightness = tot >> 2;
  791. }
  792. /* rev72a only */
  793. static void getcontrast(struct gspca_dev *gspca_dev)
  794. {
  795. struct sd *sd = (struct sd *) gspca_dev;
  796. __u16 tot;
  797. tot = 0;
  798. reg_r(gspca_dev, 0x8651, 1);
  799. tot += gspca_dev->usb_buf[0];
  800. reg_r(gspca_dev, 0x8652, 1);
  801. tot += gspca_dev->usb_buf[0];
  802. reg_r(gspca_dev, 0x8653, 1);
  803. tot += gspca_dev->usb_buf[0];
  804. reg_r(gspca_dev, 0x8654, 1);
  805. tot += gspca_dev->usb_buf[0];
  806. sd->contrast = tot << 6;
  807. PDEBUG(D_CONF, "get contrast %d", sd->contrast);
  808. }
  809. /* rev 72a only */
  810. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
  811. {
  812. struct sd *sd = (struct sd *) gspca_dev;
  813. sd->brightness = val;
  814. if (gspca_dev->streaming)
  815. setbrightness(gspca_dev);
  816. return 0;
  817. }
  818. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
  819. {
  820. struct sd *sd = (struct sd *) gspca_dev;
  821. getbrightness(gspca_dev);
  822. *val = sd->brightness;
  823. return 0;
  824. }
  825. /* rev 72a only */
  826. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
  827. {
  828. struct sd *sd = (struct sd *) gspca_dev;
  829. sd->contrast = val;
  830. if (gspca_dev->streaming)
  831. setcontrast(gspca_dev);
  832. return 0;
  833. }
  834. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
  835. {
  836. struct sd *sd = (struct sd *) gspca_dev;
  837. getcontrast(gspca_dev);
  838. *val = sd->contrast;
  839. return 0;
  840. }
  841. static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
  842. {
  843. struct sd *sd = (struct sd *) gspca_dev;
  844. sd->autogain = val;
  845. if (gspca_dev->streaming)
  846. setautogain(gspca_dev);
  847. return 0;
  848. }
  849. static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
  850. {
  851. struct sd *sd = (struct sd *) gspca_dev;
  852. *val = sd->autogain;
  853. return 0;
  854. }
  855. /* rev12a only */
  856. static int sd_setwhite(struct gspca_dev *gspca_dev, __s32 val)
  857. {
  858. struct sd *sd = (struct sd *) gspca_dev;
  859. sd->white = val;
  860. if (gspca_dev->streaming)
  861. setwhite(gspca_dev);
  862. return 0;
  863. }
  864. static int sd_getwhite(struct gspca_dev *gspca_dev, __s32 *val)
  865. {
  866. struct sd *sd = (struct sd *) gspca_dev;
  867. *val = sd->white;
  868. return 0;
  869. }
  870. /* rev12a only */
  871. static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val)
  872. {
  873. struct sd *sd = (struct sd *) gspca_dev;
  874. sd->exposure = val;
  875. if (gspca_dev->streaming)
  876. setexposure(gspca_dev);
  877. return 0;
  878. }
  879. static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val)
  880. {
  881. struct sd *sd = (struct sd *) gspca_dev;
  882. *val = sd->exposure;
  883. return 0;
  884. }
  885. /* rev12a only */
  886. static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val)
  887. {
  888. struct sd *sd = (struct sd *) gspca_dev;
  889. sd->gain = val;
  890. if (gspca_dev->streaming)
  891. setgain(gspca_dev);
  892. return 0;
  893. }
  894. static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val)
  895. {
  896. struct sd *sd = (struct sd *) gspca_dev;
  897. *val = sd->gain;
  898. return 0;
  899. }
  900. /* control tables */
  901. static struct ctrl sd_ctrls_12a[] = {
  902. {
  903. {
  904. .id = V4L2_CID_DO_WHITE_BALANCE,
  905. .type = V4L2_CTRL_TYPE_INTEGER,
  906. .name = "While Balance",
  907. .minimum = WHITE_MIN,
  908. .maximum = WHITE_MAX,
  909. .step = 1,
  910. .default_value = WHITE_DEF,
  911. },
  912. .set = sd_setwhite,
  913. .get = sd_getwhite,
  914. },
  915. {
  916. {
  917. .id = V4L2_CID_EXPOSURE,
  918. .type = V4L2_CTRL_TYPE_INTEGER,
  919. .name = "Exposure",
  920. .minimum = EXPOSURE_MIN,
  921. .maximum = EXPOSURE_MAX,
  922. .step = 1,
  923. .default_value = EXPOSURE_DEF,
  924. },
  925. .set = sd_setexposure,
  926. .get = sd_getexposure,
  927. },
  928. {
  929. {
  930. .id = V4L2_CID_AUTOGAIN,
  931. .type = V4L2_CTRL_TYPE_BOOLEAN,
  932. .name = "Auto Gain",
  933. .minimum = AUTOGAIN_MIN,
  934. .maximum = AUTOGAIN_MAX,
  935. .step = 1,
  936. .default_value = AUTOGAIN_DEF,
  937. },
  938. .set = sd_setautogain,
  939. .get = sd_getautogain,
  940. },
  941. {
  942. {
  943. .id = V4L2_CID_GAIN,
  944. .type = V4L2_CTRL_TYPE_INTEGER,
  945. .name = "Gain",
  946. .minimum = GAIN_MIN,
  947. .maximum = GAIN_MAX,
  948. .step = 1,
  949. .default_value = GAIN_DEF,
  950. },
  951. .set = sd_setgain,
  952. .get = sd_getgain,
  953. },
  954. };
  955. static struct ctrl sd_ctrls_72a[] = {
  956. {
  957. {
  958. .id = V4L2_CID_BRIGHTNESS,
  959. .type = V4L2_CTRL_TYPE_INTEGER,
  960. .name = "Brightness",
  961. .minimum = BRIGHTNESS_MIN,
  962. .maximum = BRIGHTNESS_MAX,
  963. .step = 1,
  964. .default_value = BRIGHTNESS_DEF,
  965. },
  966. .set = sd_setbrightness,
  967. .get = sd_getbrightness,
  968. },
  969. {
  970. {
  971. .id = V4L2_CID_CONTRAST,
  972. .type = V4L2_CTRL_TYPE_INTEGER,
  973. .name = "Contrast",
  974. .minimum = CONTRAST_MIN,
  975. .maximum = CONTRAST_MAX,
  976. .step = 1,
  977. .default_value = CONTRAST_DEF,
  978. },
  979. .set = sd_setcontrast,
  980. .get = sd_getcontrast,
  981. },
  982. {
  983. {
  984. .id = V4L2_CID_AUTOGAIN,
  985. .type = V4L2_CTRL_TYPE_BOOLEAN,
  986. .name = "Auto Gain",
  987. .minimum = AUTOGAIN_MIN,
  988. .maximum = AUTOGAIN_MAX,
  989. .step = 1,
  990. .default_value = AUTOGAIN_DEF,
  991. },
  992. .set = sd_setautogain,
  993. .get = sd_getautogain,
  994. },
  995. };
  996. /* sub-driver description */
  997. static const struct sd_desc sd_desc_12a = {
  998. .name = MODULE_NAME,
  999. .ctrls = sd_ctrls_12a,
  1000. .nctrls = ARRAY_SIZE(sd_ctrls_12a),
  1001. .config = sd_config,
  1002. .open = sd_open_12a,
  1003. .start = sd_start_12a,
  1004. .stopN = sd_stopN,
  1005. .stop0 = sd_stop0,
  1006. .close = sd_close,
  1007. .pkt_scan = sd_pkt_scan,
  1008. /* .dq_callback = do_autogain, * fixme */
  1009. };
  1010. static const struct sd_desc sd_desc_72a = {
  1011. .name = MODULE_NAME,
  1012. .ctrls = sd_ctrls_72a,
  1013. .nctrls = ARRAY_SIZE(sd_ctrls_72a),
  1014. .config = sd_config,
  1015. .open = sd_open_72a,
  1016. .start = sd_start_72a,
  1017. .stopN = sd_stopN,
  1018. .stop0 = sd_stop0,
  1019. .close = sd_close,
  1020. .pkt_scan = sd_pkt_scan,
  1021. .dq_callback = do_autogain,
  1022. };
  1023. static const struct sd_desc *sd_desc[2] = {
  1024. &sd_desc_12a,
  1025. &sd_desc_72a
  1026. };
  1027. /* -- module initialisation -- */
  1028. static const __devinitdata struct usb_device_id device_table[] = {
  1029. {USB_DEVICE(0x041e, 0x401a), .driver_info = Rev072A},
  1030. {USB_DEVICE(0x041e, 0x403b), .driver_info = Rev012A},
  1031. {USB_DEVICE(0x0458, 0x7004), .driver_info = Rev072A},
  1032. {USB_DEVICE(0x046d, 0x0928), .driver_info = Rev012A},
  1033. {USB_DEVICE(0x046d, 0x0929), .driver_info = Rev012A},
  1034. {USB_DEVICE(0x046d, 0x092a), .driver_info = Rev012A},
  1035. {USB_DEVICE(0x046d, 0x092b), .driver_info = Rev012A},
  1036. {USB_DEVICE(0x046d, 0x092c), .driver_info = Rev012A},
  1037. {USB_DEVICE(0x046d, 0x092d), .driver_info = Rev012A},
  1038. {USB_DEVICE(0x046d, 0x092e), .driver_info = Rev012A},
  1039. {USB_DEVICE(0x046d, 0x092f), .driver_info = Rev012A},
  1040. {USB_DEVICE(0x04fc, 0x0561), .driver_info = Rev072A},
  1041. {USB_DEVICE(0x060b, 0xa001), .driver_info = Rev072A},
  1042. {USB_DEVICE(0x10fd, 0x7e50), .driver_info = Rev072A},
  1043. {USB_DEVICE(0xabcd, 0xcdee), .driver_info = Rev072A},
  1044. {}
  1045. };
  1046. MODULE_DEVICE_TABLE(usb, device_table);
  1047. /* -- device connect -- */
  1048. static int sd_probe(struct usb_interface *intf,
  1049. const struct usb_device_id *id)
  1050. {
  1051. return gspca_dev_probe(intf, id,
  1052. sd_desc[id->driver_info],
  1053. sizeof(struct sd),
  1054. THIS_MODULE);
  1055. }
  1056. static struct usb_driver sd_driver = {
  1057. .name = MODULE_NAME,
  1058. .id_table = device_table,
  1059. .probe = sd_probe,
  1060. .disconnect = gspca_disconnect,
  1061. };
  1062. /* -- module insert / remove -- */
  1063. static int __init sd_mod_init(void)
  1064. {
  1065. if (usb_register(&sd_driver) < 0)
  1066. return -1;
  1067. PDEBUG(D_PROBE, "registered");
  1068. return 0;
  1069. }
  1070. static void __exit sd_mod_exit(void)
  1071. {
  1072. usb_deregister(&sd_driver);
  1073. PDEBUG(D_PROBE, "deregistered");
  1074. }
  1075. module_init(sd_mod_init);
  1076. module_exit(sd_mod_exit);