PageRenderTime 68ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 1ms

/linux/drivers/media/video/gspca/sonixj.c

https://bitbucket.org/davidtlwong/mygica_x850x_hybrid
C | 2461 lines | 2037 code | 186 blank | 238 comment | 145 complexity | e309da92e2f06ae29d4308e95dd70c1a MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * Sonix sn9c102p sn9c105 sn9c120 (jpeg) 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 MODULE_NAME "sonixj"
  22. #include "gspca.h"
  23. #include "jpeg.h"
  24. #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
  25. MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
  26. MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
  27. MODULE_LICENSE("GPL");
  28. /* specific webcam descriptor */
  29. struct sd {
  30. struct gspca_dev gspca_dev; /* !! must be the first item */
  31. atomic_t avg_lum;
  32. u32 exposure;
  33. u16 brightness;
  34. u8 contrast;
  35. u8 colors;
  36. u8 autogain;
  37. u8 blue;
  38. u8 red;
  39. u8 gamma;
  40. u8 vflip; /* ov7630/ov7648 only */
  41. u8 infrared; /* mt9v111 only */
  42. u8 freq; /* ov76xx only */
  43. u8 quality; /* image quality */
  44. #define QUALITY_MIN 60
  45. #define QUALITY_MAX 95
  46. #define QUALITY_DEF 80
  47. u8 jpegqual; /* webcam quality */
  48. u8 reg18;
  49. s8 ag_cnt;
  50. #define AG_CNT_START 13
  51. u8 bridge;
  52. #define BRIDGE_SN9C102P 0
  53. #define BRIDGE_SN9C105 1
  54. #define BRIDGE_SN9C110 2
  55. #define BRIDGE_SN9C120 3
  56. u8 sensor; /* Type of image sensor chip */
  57. #define SENSOR_HV7131R 0
  58. #define SENSOR_MI0360 1
  59. #define SENSOR_MO4000 2
  60. #define SENSOR_MT9V111 3
  61. #define SENSOR_OM6802 4
  62. #define SENSOR_OV7630 5
  63. #define SENSOR_OV7648 6
  64. #define SENSOR_OV7660 7
  65. #define SENSOR_SP80708 8
  66. u8 i2c_base;
  67. u8 *jpeg_hdr;
  68. };
  69. /* V4L2 controls supported by the driver */
  70. static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
  71. static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
  72. static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
  73. static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
  74. static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
  75. static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
  76. static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
  77. static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
  78. static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
  79. static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
  80. static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
  81. static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
  82. static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
  83. static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
  84. static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
  85. static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
  86. static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
  87. static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
  88. static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
  89. static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
  90. static struct ctrl sd_ctrls[] = {
  91. #define BRIGHTNESS_IDX 0
  92. {
  93. {
  94. .id = V4L2_CID_BRIGHTNESS,
  95. .type = V4L2_CTRL_TYPE_INTEGER,
  96. .name = "Brightness",
  97. .minimum = 0,
  98. #define BRIGHTNESS_MAX 0xffff
  99. .maximum = BRIGHTNESS_MAX,
  100. .step = 1,
  101. #define BRIGHTNESS_DEF 0x8000
  102. .default_value = BRIGHTNESS_DEF,
  103. },
  104. .set = sd_setbrightness,
  105. .get = sd_getbrightness,
  106. },
  107. #define CONTRAST_IDX 1
  108. {
  109. {
  110. .id = V4L2_CID_CONTRAST,
  111. .type = V4L2_CTRL_TYPE_INTEGER,
  112. .name = "Contrast",
  113. .minimum = 0,
  114. #define CONTRAST_MAX 127
  115. .maximum = CONTRAST_MAX,
  116. .step = 1,
  117. #define CONTRAST_DEF 63
  118. .default_value = CONTRAST_DEF,
  119. },
  120. .set = sd_setcontrast,
  121. .get = sd_getcontrast,
  122. },
  123. #define COLOR_IDX 2
  124. {
  125. {
  126. .id = V4L2_CID_SATURATION,
  127. .type = V4L2_CTRL_TYPE_INTEGER,
  128. .name = "Saturation",
  129. .minimum = 0,
  130. .maximum = 40,
  131. .step = 1,
  132. #define COLOR_DEF 25
  133. .default_value = COLOR_DEF,
  134. },
  135. .set = sd_setcolors,
  136. .get = sd_getcolors,
  137. },
  138. #define BLUE_BALANCE_IDX 3
  139. {
  140. {
  141. .id = V4L2_CID_BLUE_BALANCE,
  142. .type = V4L2_CTRL_TYPE_INTEGER,
  143. .name = "Blue Balance",
  144. .minimum = 24,
  145. .maximum = 40,
  146. .step = 1,
  147. #define BLUE_BALANCE_DEF 32
  148. .default_value = BLUE_BALANCE_DEF,
  149. },
  150. .set = sd_setblue_balance,
  151. .get = sd_getblue_balance,
  152. },
  153. #define RED_BALANCE_IDX 4
  154. {
  155. {
  156. .id = V4L2_CID_RED_BALANCE,
  157. .type = V4L2_CTRL_TYPE_INTEGER,
  158. .name = "Red Balance",
  159. .minimum = 24,
  160. .maximum = 40,
  161. .step = 1,
  162. #define RED_BALANCE_DEF 32
  163. .default_value = RED_BALANCE_DEF,
  164. },
  165. .set = sd_setred_balance,
  166. .get = sd_getred_balance,
  167. },
  168. #define GAMMA_IDX 5
  169. {
  170. {
  171. .id = V4L2_CID_GAMMA,
  172. .type = V4L2_CTRL_TYPE_INTEGER,
  173. .name = "Gamma",
  174. .minimum = 0,
  175. .maximum = 40,
  176. .step = 1,
  177. #define GAMMA_DEF 20
  178. .default_value = GAMMA_DEF,
  179. },
  180. .set = sd_setgamma,
  181. .get = sd_getgamma,
  182. },
  183. #define AUTOGAIN_IDX 6
  184. {
  185. {
  186. .id = V4L2_CID_AUTOGAIN,
  187. .type = V4L2_CTRL_TYPE_BOOLEAN,
  188. .name = "Auto Gain",
  189. .minimum = 0,
  190. .maximum = 1,
  191. .step = 1,
  192. #define AUTOGAIN_DEF 1
  193. .default_value = AUTOGAIN_DEF,
  194. },
  195. .set = sd_setautogain,
  196. .get = sd_getautogain,
  197. },
  198. /* ov7630/ov7648 only */
  199. #define VFLIP_IDX 7
  200. {
  201. {
  202. .id = V4L2_CID_VFLIP,
  203. .type = V4L2_CTRL_TYPE_BOOLEAN,
  204. .name = "Vflip",
  205. .minimum = 0,
  206. .maximum = 1,
  207. .step = 1,
  208. #define VFLIP_DEF 0
  209. .default_value = VFLIP_DEF,
  210. },
  211. .set = sd_setvflip,
  212. .get = sd_getvflip,
  213. },
  214. /* mt9v111 only */
  215. #define INFRARED_IDX 8
  216. {
  217. {
  218. .id = V4L2_CID_INFRARED,
  219. .type = V4L2_CTRL_TYPE_BOOLEAN,
  220. .name = "Infrared",
  221. .minimum = 0,
  222. .maximum = 1,
  223. .step = 1,
  224. #define INFRARED_DEF 0
  225. .default_value = INFRARED_DEF,
  226. },
  227. .set = sd_setinfrared,
  228. .get = sd_getinfrared,
  229. },
  230. /* ov7630/ov7648/ov7660 only */
  231. #define FREQ_IDX 9
  232. {
  233. {
  234. .id = V4L2_CID_POWER_LINE_FREQUENCY,
  235. .type = V4L2_CTRL_TYPE_MENU,
  236. .name = "Light frequency filter",
  237. .minimum = 0,
  238. .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
  239. .step = 1,
  240. #define FREQ_DEF 2
  241. .default_value = FREQ_DEF,
  242. },
  243. .set = sd_setfreq,
  244. .get = sd_getfreq,
  245. },
  246. };
  247. /* table of the disabled controls */
  248. static __u32 ctrl_dis[] = {
  249. (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
  250. /* SENSOR_HV7131R 0 */
  251. (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
  252. /* SENSOR_MI0360 1 */
  253. (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
  254. /* SENSOR_MO4000 2 */
  255. #if 1
  256. (1 << VFLIP_IDX) | (1 << FREQ_IDX),
  257. #else
  258. (1 << AUTOGAIN_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
  259. #endif
  260. /* SENSOR_MT9V111 3 */
  261. (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
  262. /* SENSOR_OM6802 4 */
  263. (1 << INFRARED_IDX),
  264. /* SENSOR_OV7630 5 */
  265. (1 << INFRARED_IDX),
  266. /* SENSOR_OV7648 6 */
  267. (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
  268. /* SENSOR_OV7660 7 */
  269. (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) |
  270. (1 << FREQ_IDX), /* SENSOR_SP80708 8 */
  271. };
  272. static const struct v4l2_pix_format vga_mode[] = {
  273. {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  274. .bytesperline = 160,
  275. .sizeimage = 160 * 120 * 4 / 8 + 590,
  276. .colorspace = V4L2_COLORSPACE_JPEG,
  277. .priv = 2},
  278. {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  279. .bytesperline = 320,
  280. .sizeimage = 320 * 240 * 3 / 8 + 590,
  281. .colorspace = V4L2_COLORSPACE_JPEG,
  282. .priv = 1},
  283. {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
  284. .bytesperline = 640,
  285. /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
  286. .sizeimage = 640 * 480 * 3 / 4 + 590,
  287. .colorspace = V4L2_COLORSPACE_JPEG,
  288. .priv = 0},
  289. };
  290. /*Data from sn9c102p+hv7131r */
  291. static const u8 sn_hv7131[0x1c] = {
  292. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  293. 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
  294. /* reg8 reg9 rega regb regc regd rege regf */
  295. 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10,
  296. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  297. 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
  298. /* reg18 reg19 reg1a reg1b */
  299. 0x0a, 0x00, 0x00, 0x00
  300. };
  301. static const u8 sn_mi0360[0x1c] = {
  302. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  303. 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
  304. /* reg8 reg9 rega regb regc regd rege regf */
  305. 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10,
  306. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  307. 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
  308. /* reg18 reg19 reg1a reg1b */
  309. 0x06, 0x00, 0x00, 0x00
  310. };
  311. static const u8 sn_mo4000[0x1c] = {
  312. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  313. 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
  314. /* reg8 reg9 rega regb regc regd rege regf */
  315. 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  316. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  317. 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
  318. /* reg18 reg19 reg1a reg1b */
  319. 0x08, 0x00, 0x00, 0x00
  320. };
  321. static const u8 sn_mt9v111[0x1c] = {
  322. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  323. 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
  324. /* reg8 reg9 rega regb regc regd rege regf */
  325. 0x81, 0x5c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
  326. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  327. 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
  328. /* reg18 reg19 reg1a reg1b */
  329. 0x06, 0x00, 0x00, 0x00
  330. };
  331. static const u8 sn_om6802[0x1c] = {
  332. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  333. 0x00, 0x23, 0x72, 0x00, 0x1a, 0x34, 0x27, 0x20,
  334. /* reg8 reg9 rega regb regc regd rege regf */
  335. 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  336. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  337. 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
  338. /* reg18 reg19 reg1a reg1b */
  339. 0x05, 0x00, 0x00, 0x00
  340. };
  341. static const u8 sn_ov7630[0x1c] = {
  342. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  343. 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
  344. /* reg8 reg9 rega regb regc regd rege regf */
  345. 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10,
  346. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  347. 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
  348. /* reg18 reg19 reg1a reg1b */
  349. 0x0b, 0x00, 0x00, 0x00
  350. };
  351. static const u8 sn_ov7648[0x1c] = {
  352. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  353. 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
  354. /* reg8 reg9 rega regb regc regd rege regf */
  355. 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
  356. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  357. 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
  358. /* reg18 reg19 reg1a reg1b */
  359. 0x0b, 0x00, 0x00, 0x00
  360. };
  361. static const u8 sn_ov7660[0x1c] = {
  362. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  363. 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
  364. /* reg8 reg9 rega regb regc regd rege regf */
  365. 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  366. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  367. 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
  368. /* reg18 reg19 reg1a reg1b */
  369. 0x07, 0x00, 0x00, 0x00
  370. };
  371. static const u8 sn_sp80708[0x1c] = {
  372. /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
  373. 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
  374. /* reg8 reg9 rega regb regc regd rege regf */
  375. 0x81, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
  376. /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
  377. 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
  378. /* reg18 reg19 reg1a reg1b */
  379. 0x07, 0x00, 0x00, 0x00
  380. };
  381. /* sequence specific to the sensors - !! index = SENSOR_xxx */
  382. static const u8 *sn_tb[] = {
  383. sn_hv7131,
  384. sn_mi0360,
  385. sn_mo4000,
  386. sn_mt9v111,
  387. sn_om6802,
  388. sn_ov7630,
  389. sn_ov7648,
  390. sn_ov7660,
  391. sn_sp80708
  392. };
  393. /* default gamma table */
  394. static const u8 gamma_def[17] = {
  395. 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
  396. 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
  397. };
  398. /* gamma for sensors HV7131R and MT9V111 */
  399. static const u8 gamma_spec_1[17] = {
  400. 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
  401. 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
  402. };
  403. /* gamma for sensor SP80708 */
  404. static const u8 gamma_spec_2[17] = {
  405. 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
  406. 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
  407. };
  408. /* color matrix and offsets */
  409. static const u8 reg84[] = {
  410. 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
  411. 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
  412. 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
  413. 0x00, 0x00, 0x00 /* YUV offsets */
  414. };
  415. static const u8 hv7131r_sensor_init[][8] = {
  416. {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
  417. {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
  418. {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
  419. /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
  420. {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
  421. {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
  422. /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
  423. {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
  424. {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
  425. {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
  426. {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
  427. {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
  428. {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
  429. {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
  430. {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
  431. {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
  432. {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
  433. {0xa1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10},
  434. {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
  435. {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
  436. {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
  437. {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
  438. {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
  439. {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
  440. {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
  441. {}
  442. };
  443. static const u8 mi0360_sensor_init[][8] = {
  444. {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
  445. {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
  446. {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
  447. {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
  448. {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
  449. {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
  450. {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
  451. {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
  452. {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
  453. {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
  454. {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
  455. {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
  456. {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
  457. {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
  458. {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
  459. {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
  460. {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
  461. {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
  462. {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
  463. {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
  464. {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
  465. {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
  466. {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
  467. {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
  468. {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
  469. {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
  470. {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
  471. {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
  472. {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
  473. {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
  474. {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
  475. {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
  476. {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
  477. {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
  478. {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
  479. {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
  480. {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
  481. {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
  482. {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
  483. {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
  484. {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
  485. {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
  486. {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
  487. {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
  488. /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
  489. /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
  490. {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
  491. {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
  492. {}
  493. };
  494. static const u8 mo4000_sensor_init[][8] = {
  495. {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
  496. {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
  497. {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
  498. {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
  499. {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
  500. {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
  501. {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
  502. {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
  503. {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
  504. {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
  505. {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
  506. {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
  507. {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
  508. {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
  509. {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
  510. {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
  511. {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
  512. {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
  513. {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
  514. {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
  515. {}
  516. };
  517. static const u8 mt9v111_sensor_init[][8] = {
  518. {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
  519. /* delay 20 ms */
  520. {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
  521. {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
  522. {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
  523. {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
  524. {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
  525. {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
  526. {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
  527. {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
  528. {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
  529. {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
  530. {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
  531. {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
  532. {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
  533. {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
  534. {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
  535. {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
  536. {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
  537. {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
  538. {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
  539. {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
  540. {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
  541. {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
  542. {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
  543. {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
  544. {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
  545. {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
  546. /*******/
  547. {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
  548. {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
  549. #if 1
  550. {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
  551. #else
  552. {0xb1, 0x5c, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10}, /* shutter width */
  553. #endif
  554. {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
  555. {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
  556. /*******/
  557. {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
  558. {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
  559. {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
  560. {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
  561. {}
  562. };
  563. static const u8 om6802_sensor_init[][8] = {
  564. {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10},
  565. {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10},
  566. {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
  567. {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
  568. /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
  569. {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
  570. /* white balance & auto-exposure */
  571. /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
  572. * set color mode */
  573. /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
  574. * max AGC value in AE */
  575. /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
  576. * preset AGC */
  577. /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
  578. * preset brightness */
  579. /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
  580. * preset contrast */
  581. /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
  582. * preset gamma */
  583. {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
  584. /* luminance mode (0x4f = AE) */
  585. {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
  586. /* preset shutter */
  587. /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
  588. * auto frame rate */
  589. /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
  590. /* {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, */
  591. /* {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, */
  592. /* {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, */
  593. /* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */
  594. {}
  595. };
  596. static const u8 ov7630_sensor_init[][8] = {
  597. {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
  598. {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
  599. /* win: delay 20ms */
  600. {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
  601. {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
  602. /* win: delay 20ms */
  603. {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
  604. /* win: i2c_r from 00 to 80 */
  605. {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
  606. {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
  607. /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
  608. 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
  609. {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
  610. {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
  611. {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
  612. {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
  613. {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
  614. {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
  615. {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
  616. {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
  617. {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
  618. {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
  619. {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
  620. {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
  621. {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
  622. {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
  623. {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
  624. {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
  625. {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
  626. {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
  627. {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
  628. {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
  629. {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
  630. {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
  631. {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
  632. {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
  633. /* */
  634. {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
  635. {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
  636. /*fixme: + 0x12, 0x04*/
  637. /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
  638. * set by setvflip */
  639. {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
  640. {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
  641. {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
  642. /* */
  643. /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
  644. /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
  645. /* */
  646. {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
  647. /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
  648. {}
  649. };
  650. static const u8 ov7648_sensor_init[][8] = {
  651. {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
  652. {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
  653. {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
  654. {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
  655. {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
  656. {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
  657. {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
  658. {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
  659. {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
  660. {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
  661. {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
  662. {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
  663. {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
  664. {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
  665. {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
  666. {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
  667. {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
  668. {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
  669. {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
  670. {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
  671. {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
  672. {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
  673. /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
  674. /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
  675. /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
  676. /*...*/
  677. /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
  678. /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
  679. * set by setvflip */
  680. {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
  681. {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
  682. /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
  683. /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
  684. /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
  685. /*...*/
  686. {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
  687. /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
  688. /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
  689. /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
  690. /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
  691. /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
  692. {}
  693. };
  694. static const u8 ov7660_sensor_init[][8] = {
  695. {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
  696. /* (delay 20ms) */
  697. {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
  698. /* Outformat = rawRGB */
  699. {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
  700. {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
  701. /* GAIN BLUE RED VREF */
  702. {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
  703. /* COM 1 BAVE GEAVE AECHH */
  704. {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
  705. {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
  706. #if 0
  707. {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xf8, 0x10},
  708. #else
  709. {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
  710. #endif
  711. /* AECH CLKRC COM7 COM8 */
  712. {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
  713. {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
  714. /* HSTART HSTOP VSTRT VSTOP */
  715. {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
  716. {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
  717. {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
  718. /* BOS GBOS GROS ROS (BGGR offset) */
  719. /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
  720. {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
  721. /* AEW AEB VPT BBIAS */
  722. {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
  723. /* GbBIAS RSVD EXHCH EXHCL */
  724. {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
  725. /* RBIAS ADVFL ASDVFH YAVE */
  726. {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
  727. /* HSYST HSYEN HREF */
  728. {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
  729. {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
  730. /* ADC ACOM OFON TSLB */
  731. {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
  732. /* COM11 COM12 COM13 COM14 */
  733. {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
  734. /* EDGE COM15 COM16 COM17 */
  735. {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
  736. {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
  737. {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
  738. {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
  739. {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
  740. {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
  741. {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
  742. {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
  743. {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
  744. {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
  745. /* LCC1 LCC2 LCC3 LCC4 */
  746. {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
  747. {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
  748. {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
  749. /* band gap reference [0:3] DBLV */
  750. {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
  751. {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
  752. {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
  753. {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
  754. {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
  755. {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
  756. {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
  757. {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
  758. {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
  759. {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
  760. {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
  761. /****** (some exchanges in the win trace) ******/
  762. {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
  763. /* bits[3..0]reserved */
  764. {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
  765. {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
  766. /* VREF vertical frame ctrl */
  767. {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
  768. {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
  769. {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
  770. {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
  771. {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
  772. /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
  773. /****** (some exchanges in the win trace) ******/
  774. {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
  775. {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
  776. {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
  777. {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
  778. /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
  779. /****** (some exchanges in the win trace) ******/
  780. /******!! startsensor KO if changed !!****/
  781. {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
  782. {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
  783. {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
  784. {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
  785. {}
  786. };
  787. static const u8 sp80708_sensor_init[][8] = {
  788. {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
  789. {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
  790. {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
  791. {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
  792. {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
  793. {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
  794. {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
  795. {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
  796. {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
  797. {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
  798. {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
  799. {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
  800. {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
  801. {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
  802. {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
  803. {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
  804. {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
  805. {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
  806. {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
  807. {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
  808. {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
  809. {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
  810. {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
  811. {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
  812. {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
  813. {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
  814. {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
  815. {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
  816. {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
  817. {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
  818. {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
  819. {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
  820. {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
  821. {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
  822. {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
  823. {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
  824. {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
  825. {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
  826. {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
  827. {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
  828. {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
  829. {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
  830. {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
  831. {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
  832. {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
  833. {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
  834. {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
  835. {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
  836. {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
  837. {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
  838. {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
  839. {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
  840. {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
  841. {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
  842. {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
  843. {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
  844. {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
  845. {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
  846. {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
  847. {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
  848. {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
  849. {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
  850. {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
  851. {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
  852. {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
  853. {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
  854. {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
  855. {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
  856. {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
  857. {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
  858. {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
  859. /********/
  860. {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
  861. {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
  862. {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
  863. {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
  864. {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
  865. {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
  866. {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
  867. {}
  868. };
  869. /* read <len> bytes to gspca_dev->usb_buf */
  870. static void reg_r(struct gspca_dev *gspca_dev,
  871. u16 value, int len)
  872. {
  873. #ifdef GSPCA_DEBUG
  874. if (len > USB_BUF_SZ) {
  875. err("reg_r: buffer overflow");
  876. return;
  877. }
  878. #endif
  879. usb_control_msg(gspca_dev->dev,
  880. usb_rcvctrlpipe(gspca_dev->dev, 0),
  881. 0,
  882. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  883. value, 0,
  884. gspca_dev->usb_buf, len,
  885. 500);
  886. PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
  887. }
  888. static void reg_w1(struct gspca_dev *gspca_dev,
  889. u16 value,
  890. u8 data)
  891. {
  892. PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
  893. gspca_dev->usb_buf[0] = data;
  894. usb_control_msg(gspca_dev->dev,
  895. usb_sndctrlpipe(gspca_dev->dev, 0),
  896. 0x08,
  897. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  898. value,
  899. 0,
  900. gspca_dev->usb_buf, 1,
  901. 500);
  902. }
  903. static void reg_w(struct gspca_dev *gspca_dev,
  904. u16 value,
  905. const u8 *buffer,
  906. int len)
  907. {
  908. PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
  909. value, buffer[0], buffer[1]);
  910. #ifdef GSPCA_DEBUG
  911. if (len > USB_BUF_SZ) {
  912. err("reg_w: buffer overflow");
  913. return;
  914. }
  915. #endif
  916. memcpy(gspca_dev->usb_buf, buffer, len);
  917. usb_control_msg(gspca_dev->dev,
  918. usb_sndctrlpipe(gspca_dev->dev, 0),
  919. 0x08,
  920. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  921. value, 0,
  922. gspca_dev->usb_buf, len,
  923. 500);
  924. }
  925. /* I2C write 1 byte */
  926. static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
  927. {
  928. struct sd *sd = (struct sd *) gspca_dev;
  929. PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
  930. gspca_dev->usb_buf[0] = 0x81 | (2 << 4); /* = a1 */
  931. gspca_dev->usb_buf[1] = sd->i2c_base;
  932. gspca_dev->usb_buf[2] = reg;
  933. gspca_dev->usb_buf[3] = val;
  934. gspca_dev->usb_buf[4] = 0;
  935. gspca_dev->usb_buf[5] = 0;
  936. gspca_dev->usb_buf[6] = 0;
  937. gspca_dev->usb_buf[7] = 0x10;
  938. usb_control_msg(gspca_dev->dev,
  939. usb_sndctrlpipe(gspca_dev->dev, 0),
  940. 0x08,
  941. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  942. 0x08, /* value = i2c */
  943. 0,
  944. gspca_dev->usb_buf, 8,
  945. 500);
  946. }
  947. /* I2C write 8 bytes */
  948. static void i2c_w8(struct gspca_dev *gspca_dev,
  949. const u8 *buffer)
  950. {
  951. memcpy(gspca_dev->usb_buf, buffer, 8);
  952. usb_control_msg(gspca_dev->dev,
  953. usb_sndctrlpipe(gspca_dev->dev, 0),
  954. 0x08,
  955. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
  956. 0x08, 0, /* value, index */
  957. gspca_dev->usb_buf, 8,
  958. 500);
  959. msleep(2);
  960. }
  961. /* read 5 bytes in gspca_dev->usb_buf */
  962. static void i2c_r5(struct gspca_dev *gspca_dev, u8 reg)
  963. {
  964. struct sd *sd = (struct sd *) gspca_dev;
  965. u8 mode[8];
  966. mode[0] = 0x81 | 0x10;
  967. mode[1] = sd->i2c_base;
  968. mode[2] = reg;
  969. mode[3] = 0;
  970. mode[4] = 0;
  971. mode[5] = 0;
  972. mode[6] = 0;
  973. mode[7] = 0x10;
  974. i2c_w8(gspca_dev, mode);
  975. msleep(2);
  976. mode[0] = 0x81 | (5 << 4) | 0x02;
  977. mode[2] = 0;
  978. i2c_w8(gspca_dev, mode);
  979. msleep(2);
  980. reg_r(gspca_dev, 0x0a, 5);
  981. }
  982. static int hv7131r_probe(struct gspca_dev *gspca_dev)
  983. {
  984. i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
  985. msleep(10);
  986. reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
  987. msleep(10);
  988. i2c_r5(gspca_dev, 0); /* read sensor id */
  989. if (gspca_dev->usb_buf[0] == 0x02
  990. && gspca_dev->usb_buf[1] == 0x09
  991. && gspca_dev->usb_buf[2] == 0x01
  992. && gspca_dev->usb_buf[3] == 0x00
  993. && gspca_dev->usb_buf[4] == 0x00) {
  994. PDEBUG(D_PROBE, "Find Sensor sn9c102P HV7131R");
  995. return 0;
  996. }
  997. PDEBUG(D_PROBE, "Find Sensor 0x%02x 0x%02x 0x%02x",
  998. gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
  999. gspca_dev->usb_buf[2]);
  1000. PDEBUG(D_PROBE, "Sensor sn9c102P Not found");
  1001. return -ENODEV;
  1002. }
  1003. static void mi0360_probe(struct gspca_dev *gspca_dev)
  1004. {
  1005. struct sd *sd = (struct sd *) gspca_dev;
  1006. int i, j;
  1007. u16 val = 0;
  1008. static const u8 probe_tb[][4][8] = {
  1009. { /* mi0360 */
  1010. {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
  1011. {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
  1012. {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
  1013. {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
  1014. },
  1015. { /* mt9v111 */
  1016. {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
  1017. {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
  1018. {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
  1019. {}
  1020. },
  1021. };
  1022. for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
  1023. reg_w1(gspca_dev, 0x17, 0x62);
  1024. reg_w1(gspca_dev, 0x01, 0x08);
  1025. for (j = 0; j < 3; j++)
  1026. i2c_w8(gspca_dev, probe_tb[i][j]);
  1027. msleep(2);
  1028. reg_r(gspca_dev, 0x0a, 5);
  1029. val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
  1030. if (probe_tb[i][3][0] != 0)
  1031. i2c_w8(gspca_dev, probe_tb[i][3]);
  1032. reg_w1(gspca_dev, 0x01, 0x29);
  1033. reg_w1(gspca_dev, 0x17, 0x42);
  1034. if (val != 0xffff)
  1035. break;
  1036. }
  1037. switch (val) {
  1038. case 0x823a:
  1039. PDEBUG(D_PROBE, "Sensor mt9v111");
  1040. sd->sensor = SENSOR_MT9V111;
  1041. sd->i2c_base = 0x5c;
  1042. break;
  1043. case 0x8243:
  1044. PDEBUG(D_PROBE, "Sensor mi0360");
  1045. break;
  1046. default:
  1047. PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
  1048. break;
  1049. }
  1050. }
  1051. static int configure_gpio(struct gspca_dev *gspca_dev,
  1052. const u8 *sn9c1xx)
  1053. {
  1054. struct sd *sd = (struct sd *) gspca_dev;
  1055. const u8 *reg9a;
  1056. static const u8 reg9a_def[] =
  1057. #if 1
  1058. {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
  1059. #else
  1060. {0x00, 0x40, 0x20, 0x10, 0x00, 0x04};
  1061. #endif
  1062. static const u8 reg9a_spec[] =
  1063. {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
  1064. static const u8 regd4[] = {0x60, 0x00, 0x00};
  1065. reg_w1(gspca_dev, 0xf1, 0x00);
  1066. #if 1
  1067. reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
  1068. #else
  1069. reg_w1(gspca_dev, 0x01, 0x00); /*jfm: in some win traces*/
  1070. #endif
  1071. /* configure gpio */
  1072. reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
  1073. reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
  1074. reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
  1075. switch (sd->sensor) {
  1076. case SENSOR_OV7660:
  1077. case SENSOR_SP80708:
  1078. reg9a = reg9a_spec;
  1079. break;
  1080. default:
  1081. reg9a = reg9a_def;
  1082. break;
  1083. }
  1084. reg_w(gspca_dev, 0x9a, reg9a, 6);
  1085. reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); /*fixme:jfm was 60 only*/
  1086. reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
  1087. switch (sd->sensor) {
  1088. case SENSOR_MT9V111:
  1089. reg_w1(gspca_dev, 0x01, 0x61);
  1090. reg_w1(gspca_dev, 0x17, 0x61);
  1091. reg_w1(gspca_dev, 0x01, 0x60);
  1092. reg_w1(gspca_dev, 0x01, 0x40);
  1093. break;
  1094. case SENSOR_OM6802:
  1095. reg_w1(gspca_dev, 0x02, 0x71);
  1096. reg_w1(gspca_dev, 0x01, 0x42);
  1097. reg_w1(gspca_dev, 0x17, 0x64);
  1098. reg_w1(gspca_dev, 0x01, 0x42);
  1099. break;
  1100. case SENSOR_OV7630:
  1101. reg_w1(gspca_dev, 0x01, 0x61);
  1102. reg_w1(gspca_dev, 0x17, 0xe2);
  1103. reg_w1(gspca_dev, 0x01, 0x60);
  1104. reg_w1(gspca_dev, 0x01, 0x40);
  1105. break;
  1106. case SENSOR_OV7648:
  1107. reg_w1(gspca_dev, 0x01, 0x63);
  1108. reg_w1(gspca_dev, 0x17, 0x20);
  1109. reg_w1(gspca_dev, 0x01, 0x62);
  1110. reg_w1(gspca_dev, 0x01, 0x42);
  1111. break;
  1112. case SENSOR_OV7660:
  1113. #if 0
  1114. reg_w1(gspca_dev, 0x01, 0x61);
  1115. reg_w1(gspca_dev, 0x17, 0x20);
  1116. reg_w1(gspca_dev, 0x01, 0x60);
  1117. reg_w1(gspca_dev, 0x01, 0x40);
  1118. break;
  1119. #endif
  1120. case SENSOR_SP80708:
  1121. reg_w1(gspca_dev, 0x01, 0x63);
  1122. reg_w1(gspca_dev, 0x17, 0x20);
  1123. reg_w1(gspca_dev, 0x01, 0x62);
  1124. reg_w1(gspca_dev, 0x01, 0x42);
  1125. msleep(100);
  1126. reg_w1(gspca_dev, 0x02, 0x62);
  1127. break;
  1128. /* case SENSOR_HV7131R: */
  1129. /* case SENSOR_MI0360: */
  1130. /* case SENSOR_MO4000: */
  1131. default:
  1132. reg_w1(gspca_dev, 0x01, 0x43);
  1133. reg_w1(gspca_dev, 0x17, 0x61);
  1134. reg_w1(gspca_dev, 0x01, 0x42);
  1135. if (sd->sensor == SENSOR_HV7131R) {
  1136. if (hv7131r_probe(gspca_dev) < 0)
  1137. return -ENODEV;
  1138. }
  1139. break;
  1140. }
  1141. return 0;
  1142. }
  1143. static void hv7131R_InitSensor(struct gspca_dev *gspca_dev)
  1144. {
  1145. int i = 0;
  1146. static const u8 SetSensorClk[] = /* 0x08 Mclk */
  1147. { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 };
  1148. while (hv7131r_sensor_init[i][0]) {
  1149. i2c_w8(gspca_dev, hv7131r_sensor_init[i]);
  1150. i++;
  1151. }
  1152. i2c_w8(gspca_dev, SetSensorClk);
  1153. }
  1154. static void mi0360_InitSensor(struct gspca_dev *gspca_dev)
  1155. {
  1156. int i = 0;
  1157. while (mi0360_sensor_init[i][0]) {
  1158. i2c_w8(gspca_dev, mi0360_sensor_init[i]);
  1159. i++;
  1160. }
  1161. }
  1162. static void mo4000_InitSensor(struct gspca_dev *gspca_dev)
  1163. {
  1164. int i = 0;
  1165. while (mo4000_sensor_init[i][0]) {
  1166. i2c_w8(gspca_dev, mo4000_sensor_init[i]);
  1167. i++;
  1168. }
  1169. }
  1170. static void mt9v111_InitSensor(struct gspca_dev *gspca_dev)
  1171. {
  1172. int i = 0;
  1173. i2c_w8(gspca_dev, mt9v111_sensor_init[i]);
  1174. i++;
  1175. msleep(20);
  1176. while (mt9v111_sensor_init[i][0]) {
  1177. i2c_w8(gspca_dev, mt9v111_sensor_init[i]);
  1178. i++;
  1179. }
  1180. }
  1181. static void om6802_InitSensor(struct gspca_dev *gspca_dev)
  1182. {
  1183. int i = 0;
  1184. while (om6802_sensor_init[i][0]) {
  1185. i2c_w8(gspca_dev, om6802_sensor_init[i]);
  1186. i++;
  1187. }
  1188. }
  1189. static void ov7630_InitSensor(struct gspca_dev *gspca_dev)
  1190. {
  1191. int i = 0;
  1192. i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 76 01 */
  1193. i++;
  1194. i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 (RGB+SRST) */
  1195. i++;
  1196. msleep(20);
  1197. i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */
  1198. i++;
  1199. i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 */
  1200. i++;
  1201. msleep(20);
  1202. i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */
  1203. i++;
  1204. /*jfm:win i2c_r from 00 to 80*/
  1205. while (ov7630_sensor_init[i][0]) {
  1206. i2c_w8(gspca_dev, ov7630_sensor_init[i]);
  1207. i++;
  1208. }
  1209. }
  1210. static void ov7648_InitSensor(struct gspca_dev *gspca_dev)
  1211. {
  1212. int i = 0;
  1213. i2c_w8(gspca_dev, ov7648_sensor_init[i]);
  1214. i++;
  1215. /* win: dble reset */
  1216. i2c_w8(gspca_dev, ov7648_sensor_init[i]); /* reset */
  1217. i++;
  1218. msleep(20);
  1219. /* win: i2c reg read 00..7f */
  1220. while (ov7648_sensor_init[i][0]) {
  1221. i2c_w8(gspca_dev, ov7648_sensor_init[i]);
  1222. i++;
  1223. }
  1224. }
  1225. static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
  1226. {
  1227. int i = 0;
  1228. i2c_w8(gspca_dev, ov7660_sensor_init[i]); /* reset SCCB */
  1229. i++;
  1230. msleep(20);
  1231. while (ov7660_sensor_init[i][0]) {
  1232. i2c_w8(gspca_dev, ov7660_sensor_init[i]);
  1233. i++;
  1234. }
  1235. }
  1236. static void sp80708_InitSensor(struct gspca_dev *gspca_dev)
  1237. {
  1238. int i = 0;
  1239. i2c_w8(gspca_dev, sp80708_sensor_init[i]); /* reset SCCB */
  1240. i++;
  1241. msleep(20);
  1242. while (sp80708_sensor_init[i][0]) {
  1243. i2c_w8(gspca_dev, sp80708_sensor_init[i]);
  1244. i++;
  1245. }
  1246. }
  1247. /* this function is called at probe time */
  1248. static int sd_config(struct gspca_dev *gspca_dev,
  1249. const struct usb_device_id *id)
  1250. {
  1251. struct sd *sd = (struct sd *) gspca_dev;
  1252. struct cam *cam;
  1253. cam = &gspca_dev->cam;
  1254. cam->cam_mode = vga_mode;
  1255. cam->nmodes = ARRAY_SIZE(vga_mode);
  1256. cam->npkt = 24; /* 24 packets per ISOC message */
  1257. sd->bridge = id->driver_info >> 16;
  1258. sd->sensor = id->driver_info >> 8;
  1259. sd->i2c_base = id->driver_info;
  1260. sd->brightness = BRIGHTNESS_DEF;
  1261. sd->contrast = CONTRAST_DEF;
  1262. sd->colors = COLOR_DEF;
  1263. sd->blue = BLUE_BALANCE_DEF;
  1264. sd->red = RED_BALANCE_DEF;
  1265. sd->gamma = GAMMA_DEF;
  1266. sd->autogain = AUTOGAIN_DEF;
  1267. sd->ag_cnt = -1;
  1268. sd->vflip = VFLIP_DEF;
  1269. sd->infrared = INFRARED_DEF;
  1270. sd->freq = FREQ_DEF;
  1271. sd->quality = QUALITY_DEF;
  1272. sd->jpegqual = 80;
  1273. gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
  1274. return 0;
  1275. }
  1276. /* this function is called at probe and resume time */
  1277. static int sd_init(struct gspca_dev *gspca_dev)
  1278. {
  1279. struct sd *sd = (struct sd *) gspca_dev;
  1280. u8 regGpio[] = { 0x29, 0x74 };
  1281. u8 regF1;
  1282. /* setup a selector by bridge */
  1283. reg_w1(gspca_dev, 0xf1, 0x01);
  1284. reg_r(gspca_dev, 0x00, 1);
  1285. reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
  1286. reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
  1287. regF1 = gspca_dev->usb_buf[0];
  1288. PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
  1289. switch (sd->bridge) {
  1290. case BRIDGE_SN9C102P:
  1291. if (regF1 != 0x11)
  1292. return -ENODEV;
  1293. reg_w1(gspca_dev, 0x02, regGpio[1]);
  1294. break;
  1295. case BRIDGE_SN9C105:
  1296. if (regF1 != 0x11)
  1297. return -ENODEV;
  1298. if (sd->sensor == SENSOR_MI0360)
  1299. mi0360_probe(gspca_dev);
  1300. reg_w(gspca_dev, 0x01, regGpio, 2);
  1301. break;
  1302. case BRIDGE_SN9C120:
  1303. if (regF1 != 0x12)
  1304. return -ENODEV;
  1305. if (sd->sensor == SENSOR_MI0360)
  1306. mi0360_probe(gspca_dev);
  1307. regGpio[1] = 0x70;
  1308. reg_w(gspca_dev, 0x01, regGpio, 2);
  1309. break;
  1310. default:
  1311. /* case BRIDGE_SN9C110: */
  1312. /* case BRIDGE_SN9C325: */
  1313. if (regF1 != 0x12)
  1314. return -ENODEV;
  1315. reg_w1(gspca_dev, 0x02, 0x62);
  1316. break;
  1317. }
  1318. reg_w1(gspca_dev, 0xf1, 0x01);
  1319. return 0;
  1320. }
  1321. static u32 setexposure(struct gspca_dev *gspca_dev,
  1322. u32 expo)
  1323. {
  1324. struct sd *sd = (struct sd *) gspca_dev;
  1325. switch (sd->sensor) {
  1326. case SENSOR_HV7131R: {
  1327. u8 Expodoit[] =
  1328. { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 };
  1329. Expodoit[3] = expo >> 16;
  1330. Expodoit[4] = expo >> 8;
  1331. Expodoit[5] = expo;
  1332. i2c_w8(gspca_dev, Expodoit);
  1333. break;
  1334. }
  1335. case SENSOR_MI0360: {
  1336. u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
  1337. { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 };
  1338. static const u8 doit[] = /* update sensor */
  1339. { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
  1340. static const u8 sensorgo[] = /* sensor on */
  1341. { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
  1342. if (expo > 0x0635)
  1343. expo = 0x0635;
  1344. else if (expo < 0x0001)
  1345. expo = 0x0001;
  1346. expoMi[3] = expo >> 8;
  1347. expoMi[4] = expo;
  1348. i2c_w8(gspca_dev, expoMi);
  1349. i2c_w8(gspca_dev, doit);
  1350. i2c_w8(gspca_dev, sensorgo);
  1351. break;
  1352. }
  1353. case SENSOR_MO4000: {
  1354. u8 expoMof[] =
  1355. { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 };
  1356. u8 expoMo10[] =
  1357. { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 };
  1358. static const u8 gainMo[] =
  1359. { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
  1360. if (expo > 0x1fff)
  1361. expo = 0x1fff;
  1362. else if (expo < 0x0001)
  1363. expo = 0x0001;
  1364. expoMof[3] = (expo & 0x03fc) >> 2;
  1365. i2c_w8(gspca_dev, expoMof);
  1366. expoMo10[3] = ((expo & 0x1c00) >> 10)
  1367. | ((expo & 0x0003) << 4);
  1368. i2c_w8(gspca_dev, expoMo10);
  1369. i2c_w8(gspca_dev, gainMo);
  1370. PDEBUG(D_FRAM, "set exposure %d",
  1371. ((expoMo10[3] & 0x07) << 10)
  1372. | (expoMof[3] << 2)
  1373. | ((expoMo10[3] & 0x30) >> 4));
  1374. break;
  1375. }
  1376. case SENSOR_MT9V111: {
  1377. u8 expo_c1[] =
  1378. { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
  1379. #if 0
  1380. static const u8 c2[] =
  1381. { 0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10 };
  1382. static const u8 c3[] =
  1383. { 0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10 };
  1384. #endif
  1385. if (expo > 0x0280)
  1386. expo = 0x0280;
  1387. else if (expo < 0x0040)
  1388. expo = 0x0040;
  1389. expo_c1[3] = expo >> 8;
  1390. expo_c1[4] = expo;
  1391. i2c_w8(gspca_dev, expo_c1);
  1392. #if 0
  1393. i2c_w8(gspca_dev, expo_c2);
  1394. i2c_w8(gspca_dev, expo_c3);
  1395. #endif
  1396. break;
  1397. }
  1398. case SENSOR_OM6802: {
  1399. u8 gainOm[] =
  1400. { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
  1401. if (expo > 0x03ff)
  1402. expo = 0x03ff;
  1403. if (expo < 0x0001)
  1404. expo = 0x0001;
  1405. gainOm[3] = expo >> 2;
  1406. i2c_w8(gspca_dev, gainOm);
  1407. reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f);
  1408. PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
  1409. break;
  1410. }
  1411. }
  1412. return expo;
  1413. }
  1414. static void setbrightness(struct gspca_dev *gspca_dev)
  1415. {
  1416. struct sd *sd = (struct sd *) gspca_dev;
  1417. unsigned int expo;
  1418. u8 k2;
  1419. k2 = ((int) sd->brightness - 0x8000) >> 10;
  1420. switch (sd->sensor) {
  1421. case SENSOR_HV7131R:
  1422. expo = sd->brightness << 4;
  1423. if (expo > 0x002dc6c0)
  1424. expo = 0x002dc6c0;
  1425. else if (expo < 0x02a0)
  1426. expo = 0x02a0;
  1427. sd->exposure = setexposure(gspca_dev, expo);
  1428. break;
  1429. case SENSOR_MI0360:
  1430. case SENSOR_MO4000:
  1431. expo = sd->brightness >> 4;
  1432. sd->exposure = setexposure(gspca_dev, expo);
  1433. break;
  1434. case SENSOR_MT9V111:
  1435. expo = sd->brightness >> 8;
  1436. sd->exposure = setexposure(gspca_dev, expo);
  1437. break;
  1438. case SENSOR_OM6802:
  1439. expo = sd->brightness >> 6;
  1440. sd->exposure = setexposure(gspca_dev, expo);
  1441. k2 = sd->brightn

Large files files are truncated, but you can click here to view the full file