Exynos4412 OV5640摄像头(一)—— 驱动

素颜马尾好姑娘i 2022-01-21 06:15 2296阅读 0赞

以下是迅为4412开发板提供的OV5640摄像头驱动,将OV5640注册为I2C设备,提供设备节点/dev/video0。

驱动下载:https://download.csdn.net/download/q1449516487/11231317

详情参考代码:

  1. #include <linux/init.h>
  2. #include <linux/module.h>
  3. #include <linux/i2c.h>
  4. #include <linux/platform_device.h>
  5. #include <linux/videodev2.h>
  6. #include <media/v4l2-subdev.h>
  7. #include <media/soc_camera.h>
  8. #include <media/v4l2-chip-ident.h>
  9. #include <linux/delay.h>
  10. /* add by cym 20130605 */
  11. #include <linux/videodev2_samsung.h>
  12. #include <linux/regulator/consumer.h>
  13. #include <mach/gpio.h>
  14. #include <plat/gpio-cfg.h>
  15. #include <mach/regs-gpio.h>
  16. #include <mach/regs-clock.h>
  17. /* end add */
  18. /* add by cym 20130605 */
  19. enum {
  20. AUTO_FOCUS_FAILED,
  21. AUTO_FOCUS_DONE,
  22. AUTO_FOCUS_CANCELLED,
  23. };
  24. #ifndef CONFIG_TC4_EVT
  25. //static struct regulator *vdd18_5m_cam_regulator = NULL;
  26. //static struct regulator *vdd28_5m_cam_regulator = NULL;
  27. struct regulator *ov_vddaf_cam_regulator = NULL;
  28. struct regulator *ov_vdd5m_cam_regulator = NULL;
  29. struct regulator *ov_vdd18_cam_regulator = NULL;
  30. struct regulator *ov_vdd28_cam_regulator = NULL;
  31. int down_af_firmware_flag = 0;
  32. #endif
  33. /* end add */
  34. /* ANSI Color codes */
  35. #define VT(CODES) "\033[" CODES "m"
  36. #define VT_NORMAL VT("")
  37. #define VT_RED VT("0;32;31")
  38. #define VT_GREEN VT("1;32")
  39. #define VT_YELLOW VT("1;33")
  40. #define VT_BLUE VT("1;34")
  41. #define VT_PURPLE VT("0;35")
  42. #define OV5640_DBG
  43. #define xprintk(fmt, ...) \
  44. printk("%s()->%d " fmt, __func__, __LINE__, ## __VA_ARGS__)
  45. #ifdef OV5640_DBG
  46. #define _DBG(color, fmt, ...) \
  47. xprintk(color "" fmt VT_NORMAL, ## __VA_ARGS__)
  48. #define OV_INFO(fmt, args...) _DBG(VT_GREEN, fmt, ## args)
  49. #define OV_ERR(fmt, args...) _DBG(VT_RED, fmt, ## args)
  50. #else
  51. #define OV_INFO(fmt, args...) do {} while(0)
  52. #define OV_ERR(fmt, args...) do {} while(0)
  53. #endif
  54. #define _INFO(color, fmt, ...) \
  55. xprintk(color "::" fmt ""VT_NORMAL, ## __VA_ARGS__)
  56. /* mainly used in test code */
  57. #define INFO_PURLPLE(fmt, args...) _INFO(VT_PURPLE, fmt, ## args)
  58. #define INFO_RED(fmt, args...) _INFO(VT_RED, fmt, ## args)
  59. #define INFO_GREEN(fmt, args...) _INFO(VT_GREEN, fmt, ## args)
  60. #define INFO_BLUE(fmt, args...) _INFO(VT_BLUE, fmt, ## args)
  61. #define OV5640_I2C_NAME "ov5640"
  62. /*
  63. * I2C write address: 0x78, read: 0x79 , give up least significant bit.
  64. */
  65. #define OV5640_I2C_ADDR (0x78 >> 1)
  66. /*
  67. * sensor ID
  68. */
  69. #define OV5640 0x5640
  70. #define VERSION(id, vers) ((id << 8) | (vers & 0XFF))
  71. /* default format */
  72. #define QVGA_WIDTH 320
  73. #define QVGA_HEIGHT 240
  74. #define VGA_WIDTH 640
  75. #define VGA_HEIGHT 480
  76. #define XGA_WIDTH 1024
  77. #define XGA_HEIGHT 768
  78. #define SXGA_WIDTH 1280
  79. #define SXGA_HEIGHT 960
  80. #define UXGA_WIDTH 1600
  81. #define UXGA_HEIGHT 1200
  82. #define QXGA_WIDTH 2048
  83. #define QXGA_HEIGHT 1536
  84. #define QSXGA_WIDTH 2560
  85. #define QSXGA_HEIGHT 1920 //normally 2048, but ov5640 only support simple qsxga
  86. #define CAPTURE_FRAME_RATE 500 /* multiplied by 100 */
  87. #define PREVIEW_FRAME_RATE 1500 /* multiplied by 100 */
  88. #define OV5640_COLUMN_SKIP 0
  89. #define OV5640_ROW_SKIP 0
  90. #define OV5640_MAX_WIDTH (QSXGA_WIDTH)
  91. #define OV5640_MAX_HEIGHT (QSXGA_HEIGHT)
  92. #define OV5640_HFLIP 0x1
  93. #define OV5640_VFLIP 0x2
  94. enum ov5640_resolution {
  95. RESV_VGA = 1,
  96. RESV_XGA,
  97. RESV_SXGA,
  98. RESV_UXGA,
  99. RESV_QXGA,
  100. RESV_QSXGA,
  101. };
  102. struct regval {
  103. unsigned short reg;
  104. unsigned char val;
  105. };
  106. struct ov5640_color_format {
  107. enum v4l2_mbus_pixelcode code;
  108. enum v4l2_colorspace colorspace;
  109. };
  110. struct ov5640_win_size {
  111. char *name;
  112. enum ov5640_resolution resv;
  113. unsigned int width;
  114. unsigned int height;
  115. const struct regval *regs;
  116. };
  117. struct ov5640_priv {
  118. struct v4l2_subdev subdev;
  119. const struct ov5640_color_format *cfmt;
  120. const struct ov5640_win_size *win;
  121. int model;
  122. int brightness;
  123. int contrast;
  124. int saturation;
  125. int hue;
  126. int exposure;
  127. int sharpness;
  128. int colorfx;
  129. int flip_flag;
  130. };
  131. static const struct regval ov5640_init_regs[] = {
  132. /* for the setting , 24M Mlck input and 24M Plck output */
  133. {0x3103, 0x11},
  134. {0x3008, 0x82}, /* soft reset */
  135. {0x3008, 0x42},
  136. {0x3103, 0x03}, /* input clock, from PLL */
  137. {0x3017, 0xff}, /* d[9:0] pins I/O ctrl */
  138. {0x3018, 0xff},
  139. /* system control */
  140. {0x3034, 0x1a}, /* MIPI 10-bit mode */
  141. {0x3035, 0x11}, /* clock, PLL sets */
  142. {0x3036, 0x46},
  143. {0x3037, 0x13},
  144. {0x3108, 0x01}, /* SCCB CLK root divider */
  145. {0x3630, 0x36},
  146. {0x3631, 0x0e},
  147. {0x3632, 0xe2},
  148. {0x3633, 0x12},
  149. {0x3621, 0xe0},
  150. {0x3704, 0xa0},
  151. {0x3703, 0x5a},
  152. {0x3715, 0x78},
  153. {0x3717, 0x01},
  154. {0x370b, 0x60},
  155. {0x3705, 0x1a},
  156. {0x3905, 0x02},
  157. {0x3906, 0x10},
  158. {0x3901, 0x0a},
  159. {0x3731, 0x12},
  160. {0x3600, 0x08},
  161. {0x3601, 0x33},
  162. {0x302d, 0x60},
  163. {0x3620, 0x52},
  164. {0x371b, 0x20},
  165. {0x471c, 0x50},
  166. {0x3a13, 0x43},
  167. {0x3a18, 0x00},
  168. {0x3a19, 0xf8},
  169. {0x3635, 0x13},
  170. {0x3636, 0x03},
  171. {0x3634, 0x40},
  172. {0x3622, 0x01},
  173. {0x3c01, 0x34}, /* 50/60HZ detector */
  174. {0x3c04, 0x28},
  175. {0x3c05, 0x98},
  176. {0x3c06, 0x00},
  177. {0x3c07, 0x08},
  178. {0x3c08, 0x00},
  179. {0x3c09, 0x1c},
  180. {0x3c0a, 0x9c},
  181. {0x3c0b, 0x40},
  182. {0x3820, 0x41}, /* mirror and flip */
  183. {0x3821, 0x07},
  184. {0x3814, 0x31}, /* image windowing */
  185. {0x3815, 0x31},
  186. {0x3800, 0x00},
  187. {0x3801, 0x00},
  188. {0x3802, 0x00},
  189. {0x3803, 0x04},
  190. {0x3804, 0x0a},
  191. {0x3805, 0x3f},
  192. {0x3806, 0x07},
  193. {0x3807, 0x9b},
  194. {0x3808, 0x02}, /* 0x280==640 */
  195. {0x3809, 0x80},
  196. {0x380a, 0x01}, /* 0x1e0==480 */
  197. {0x380b, 0xe0},
  198. {0x380c, 0x07},
  199. {0x380d, 0x68},
  200. {0x380e, 0x03},
  201. {0x380f, 0xd8},
  202. {0x3810, 0x00},
  203. {0x3811, 0x10},
  204. {0x3812, 0x00},
  205. {0x3813, 0x06},
  206. {0x3618, 0x00},
  207. {0x3612, 0x29},
  208. {0x3708, 0x64},
  209. {0x3709, 0x52},
  210. {0x370c, 0x03},
  211. {0x3a02, 0x03}, /* AEC/AGC control */
  212. {0x3a03, 0xd8},
  213. {0x3a08, 0x01},
  214. {0x3a09, 0x27},
  215. {0x3a0a, 0x00},
  216. {0x3a0b, 0xf6},
  217. {0x3a0e, 0x03},
  218. {0x3a0d, 0x04},
  219. {0x3a14, 0x03},
  220. {0x3a15, 0xd8},
  221. {0x4001, 0x02}, /* BLC start line */
  222. {0x4004, 0x02}, /* BLC line number */
  223. {0x3000, 0x00}, /* block enable */
  224. {0x3002, 0x1c},
  225. {0x3004, 0xff}, /* clock enable */
  226. {0x3006, 0xc3},
  227. {0x300e, 0x58},
  228. {0x302e, 0x00},
  229. {0x4300, 0x32}, /* format ctrl: YUV422 UYVY */
  230. {0x501f, 0x00}, /* format MUX ctrl: ISP YUV422 */
  231. {0x4713, 0x03}, /* jpeg mode select: mode 3 */
  232. {0x4407, 0x04}, /* jpeg ctrl */
  233. {0x440e, 0x00},
  234. {0x460b, 0x35}, /* VFIFO ctrl */
  235. {0x460c, 0x22},
  236. {0x3824, 0x02},
  237. {0x5000, 0xa7}, /* ISP top ctrl */
  238. {0x5001, 0xa3},
  239. {0x5180, 0xff}, /* AWB ctrl */
  240. {0x5181, 0xf2},
  241. {0x5182, 0x00},
  242. {0x5183, 0x14},
  243. {0x5184, 0x25},
  244. {0x5185, 0x24},
  245. {0x5186, 0x09},
  246. {0x5187, 0x09},
  247. {0x5188, 0x09},
  248. {0x5189, 0x75},
  249. {0x518a, 0x54},
  250. {0x518b, 0xe0},
  251. {0x518c, 0xb2},
  252. {0x518d, 0x42},
  253. {0x518e, 0x3d},
  254. {0x518f, 0x56},
  255. {0x5190, 0x46},
  256. {0x5191, 0xf8},
  257. {0x5192, 0x04},
  258. {0x5193, 0x70},
  259. {0x5194, 0xf0},
  260. {0x5195, 0xf0},
  261. {0x5196, 0x03},
  262. {0x5197, 0x01},
  263. {0x5198, 0x04},
  264. {0x5199, 0x12},
  265. {0x519a, 0x04},
  266. {0x519b, 0x00},
  267. {0x519c, 0x06},
  268. {0x519d, 0x82},
  269. {0x519e, 0x38},
  270. {0x5381, 0x1e}, /* Color matrix */
  271. {0x5382, 0x5b},
  272. {0x5383, 0x08},
  273. {0x5384, 0x0a},
  274. {0x5385, 0x7e},
  275. {0x5386, 0x88},
  276. {0x5387, 0x7c},
  277. {0x5388, 0x6c},
  278. {0x5389, 0x10},
  279. {0x538a, 0x01},
  280. {0x538b, 0x98},
  281. {0x5300, 0x08}, /* Color interpolation */
  282. {0x5301, 0x30},
  283. {0x5302, 0x10},
  284. {0x5303, 0x00},
  285. {0x5304, 0x08},
  286. {0x5305, 0x30},
  287. {0x5306, 0x08},
  288. {0x5307, 0x16},
  289. {0x5309, 0x08},
  290. {0x530a, 0x30},
  291. {0x530b, 0x04},
  292. {0x530c, 0x06},
  293. {0x5480, 0x01}, /* gamma ctrl */
  294. {0x5481, 0x08},
  295. {0x5482, 0x14},
  296. {0x5483, 0x28},
  297. {0x5484, 0x51},
  298. {0x5485, 0x65},
  299. {0x5486, 0x71},
  300. {0x5487, 0x7d},
  301. {0x5488, 0x87},
  302. {0x5489, 0x91},
  303. {0x548a, 0x9a},
  304. {0x548b, 0xaa},
  305. {0x548c, 0xb8},
  306. {0x548d, 0xcd},
  307. {0x548e, 0xdd},
  308. {0x548f, 0xea},
  309. {0x5490, 0x1d},
  310. {0x5580, 0x02}, /* special digital effects(SDE) */
  311. {0x5583, 0x40},
  312. {0x5584, 0x10},
  313. {0x5589, 0x10},
  314. {0x558a, 0x00},
  315. {0x558b, 0xf8},
  316. {0x5800, 0x23}, /* LENC ctrl */
  317. {0x5801, 0x14},
  318. {0x5802, 0x0f},
  319. {0x5803, 0x0f},
  320. {0x5804, 0x12},
  321. {0x5805, 0x26},
  322. {0x5806, 0x0c},
  323. {0x5807, 0x08},
  324. {0x5808, 0x05},
  325. {0x5809, 0x05},
  326. {0x580a, 0x08},
  327. {0x580b, 0x0d},
  328. {0x580c, 0x08},
  329. {0x580d, 0x03},
  330. {0x580e, 0x00},
  331. {0x580f, 0x00},
  332. {0x5810, 0x03},
  333. {0x5811, 0x09},
  334. {0x5812, 0x07},
  335. {0x5813, 0x03},
  336. {0x5814, 0x00},
  337. {0x5815, 0x01},
  338. {0x5816, 0x03},
  339. {0x5817, 0x08},
  340. {0x5818, 0x0d},
  341. {0x5819, 0x08},
  342. {0x581a, 0x05},
  343. {0x581b, 0x06},
  344. {0x581c, 0x08},
  345. {0x581d, 0x0e},
  346. {0x581e, 0x29},
  347. {0x581f, 0x17},
  348. {0x5820, 0x11},
  349. {0x5821, 0x11},
  350. {0x5822, 0x15},
  351. {0x5823, 0x28},
  352. {0x5824, 0x46},
  353. {0x5825, 0x26},
  354. {0x5826, 0x08},
  355. {0x5827, 0x26},
  356. {0x5828, 0x64},
  357. {0x5829, 0x26},
  358. {0x582a, 0x24},
  359. {0x582b, 0x22},
  360. {0x582c, 0x24},
  361. {0x582d, 0x24},
  362. {0x582e, 0x06},
  363. {0x582f, 0x22},
  364. {0x5830, 0x40},
  365. {0x5831, 0x42},
  366. {0x5832, 0x24},
  367. {0x5833, 0x26},
  368. {0x5834, 0x24},
  369. {0x5835, 0x22},
  370. {0x5836, 0x22},
  371. {0x5837, 0x26},
  372. {0x5838, 0x44},
  373. {0x5839, 0x24},
  374. {0x583a, 0x26},
  375. {0x583b, 0x28},
  376. {0x583c, 0x42},
  377. {0x583d, 0xce},
  378. {0x5025, 0x00},
  379. {0x3a0f, 0x30}, /* AEC functions */
  380. {0x3a10, 0x28},
  381. {0x3a1b, 0x30},
  382. {0x3a1e, 0x26},
  383. {0x3a11, 0x60},
  384. {0x3a1f, 0x14},
  385. {0x3008, 0x02}, /* soft reset/pwd default value */
  386. {0x3035, 0x21}, /* SC PLL ctrl */
  387. {0x3c01, 0xb4}, /* Band, 0x50Hz */
  388. {0x3c00, 0x04},
  389. {0x3a19, 0x7c}, /* gain ceiling */
  390. {0x5800, 0x2c}, /* OV5640 LENC setting */
  391. {0x5801, 0x17},
  392. {0x5802, 0x11},
  393. {0x5803, 0x11},
  394. {0x5804, 0x15},
  395. {0x5805, 0x29},
  396. {0x5806, 0x08},
  397. {0x5807, 0x06},
  398. {0x5808, 0x04},
  399. {0x5809, 0x04},
  400. {0x580a, 0x05},
  401. {0x580b, 0x07},
  402. {0x580c, 0x06},
  403. {0x580d, 0x03},
  404. {0x580e, 0x01},
  405. {0x580f, 0x01},
  406. {0x5810, 0x03},
  407. {0x5811, 0x06},
  408. {0x5812, 0x06},
  409. {0x5813, 0x02},
  410. {0x5814, 0x01},
  411. {0x5815, 0x01},
  412. {0x5816, 0x04},
  413. {0x5817, 0x07},
  414. {0x5818, 0x06},
  415. {0x5819, 0x07},
  416. {0x581a, 0x06},
  417. {0x581b, 0x06},
  418. {0x581c, 0x06},
  419. {0x581d, 0x0e},
  420. {0x581e, 0x31},
  421. {0x581f, 0x12},
  422. {0x5820, 0x11},
  423. {0x5821, 0x11},
  424. {0x5822, 0x11},
  425. {0x5823, 0x2f},
  426. {0x5824, 0x12},
  427. {0x5825, 0x25},
  428. {0x5826, 0x39},
  429. {0x5827, 0x29},
  430. {0x5828, 0x27},
  431. {0x5829, 0x39},
  432. {0x582a, 0x26},
  433. {0x582b, 0x33},
  434. {0x582c, 0x24},
  435. {0x582d, 0x39},
  436. {0x582e, 0x28},
  437. {0x582f, 0x21},
  438. {0x5830, 0x40},
  439. {0x5831, 0x21},
  440. {0x5832, 0x17},
  441. {0x5833, 0x17},
  442. {0x5834, 0x15},
  443. {0x5835, 0x11},
  444. {0x5836, 0x24},
  445. {0x5837, 0x27},
  446. {0x5838, 0x26},
  447. {0x5839, 0x26},
  448. {0x583a, 0x26},
  449. {0x583b, 0x28},
  450. {0x583c, 0x14},
  451. {0x583d, 0xee},
  452. {0x4005, 0x1a}, /* BLC always update */
  453. {0x5381, 0x26}, /* color matrix ctrl */
  454. {0x5382, 0x50},
  455. {0x5383, 0x0c},
  456. {0x5384, 0x09},
  457. {0x5385, 0x74},
  458. {0x5386, 0x7d},
  459. {0x5387, 0x7e},
  460. {0x5388, 0x75},
  461. {0x5389, 0x09},
  462. {0x538b, 0x98},
  463. {0x538a, 0x01},
  464. {0x5580, 0x02}, /* (SDE)UVAdjust Auto Mode */
  465. {0x5588, 0x01},
  466. {0x5583, 0x40},
  467. {0x5584, 0x10},
  468. {0x5589, 0x0f},
  469. {0x558a, 0x00},
  470. {0x558b, 0x3f},
  471. {0x5308, 0x25}, /* De-Noise, 0xAuto */
  472. {0x5304, 0x08},
  473. {0x5305, 0x30},
  474. {0x5306, 0x10},
  475. {0x5307, 0x20},
  476. {0x5180, 0xff}, /* awb ctrl */
  477. {0x5181, 0xf2},
  478. {0x5182, 0x11},
  479. {0x5183, 0x14},
  480. {0x5184, 0x25},
  481. {0x5185, 0x24},
  482. {0x5186, 0x10},
  483. {0x5187, 0x12},
  484. {0x5188, 0x10},
  485. {0x5189, 0x80},
  486. {0x518a, 0x54},
  487. {0x518b, 0xb8},
  488. {0x518c, 0xb2},
  489. {0x518d, 0x42},
  490. {0x518e, 0x3a},
  491. {0x518f, 0x56},
  492. {0x5190, 0x46},
  493. {0x5191, 0xf0},
  494. {0x5192, 0xf},
  495. {0x5193, 0x70},
  496. {0x5194, 0xf0},
  497. {0x5195, 0xf0},
  498. {0x5196, 0x3},
  499. {0x5197, 0x1},
  500. {0x5198, 0x6},
  501. {0x5199, 0x62},
  502. {0x519a, 0x4},
  503. {0x519b, 0x0},
  504. {0x519c, 0x4},
  505. {0x519d, 0xe7},
  506. {0x519e, 0x38},
  507. };
  508. static const struct regval ov5640_qsxga_regs[] = {
  509. {0x3820, 0x40}, /* diff. init */
  510. {0x3821, 0x06},
  511. {0x3814, 0x11}, /* image windowing */
  512. {0x3815, 0x11},
  513. {0x3803, 0x00},
  514. {0x3807, 0x9f},
  515. {0x3808, 0x0a}, /* 0x0a20==2592 */
  516. {0x3809, 0x20},
  517. {0x380a, 0x07}, /* 0x798==1944 */
  518. {0x380b, 0x98},
  519. {0x380c, 0x0b},
  520. {0x380d, 0x1c},
  521. {0x380e, 0x07},
  522. {0x380f, 0xb0},
  523. {0x3813, 0x04},
  524. {0x3618, 0x04},
  525. {0x3612, 0x4b},
  526. {0x3708, 0x21},
  527. {0x3709, 0x12},
  528. {0x370c, 0x00},
  529. {0x3a02, 0x07}, /* night mode */
  530. {0x3a03, 0xb0},
  531. {0x3a0e, 0x06},
  532. {0x3a0d, 0x08},
  533. {0x3a14, 0x07},
  534. {0x3a15, 0xb0},
  535. {0x4004, 0x06}, /* BLC line number */
  536. {0x5000, 0x07}, /* black/white pixel cancell, color interp. enable */
  537. {0x5181, 0x52}, /* AWB */
  538. {0x5182, 0x00},
  539. {0x5197, 0x01},
  540. {0x519e, 0x38},
  541. {0x3035, 0x21}, /* SC PLL */
  542. {0x5000, 0x27},
  543. {0x5001, 0x83}, /* special effect, color matrix, AWB enable */
  544. {0x3035, 0x71},
  545. {0x4713, 0x02}, /* jpeg mode 2 */
  546. {0x3036, 0x69},
  547. {0x4407, 0x0c}, /* jpeg ctrl */
  548. {0x460b, 0x37},
  549. {0x460c, 0x20},
  550. {0x3824, 0x01},
  551. {0x4005, 0x1A},
  552. };
  553. /*
  554. static const struct regval ov5640_qsxga_to_qvga_regs[] = {
  555. };
  556. */
  557. static const struct regval ov5640_qsxga_to_vga_regs[] = {
  558. {0x3800, 0x00}, /* image windowing */
  559. {0x3801, 0x00},
  560. {0x3802, 0x00},
  561. {0x3803, 0x00},
  562. {0x3804, 0xA },
  563. {0x3805, 0x3f},
  564. {0x3806, 0x7 },
  565. {0x3807, 0x9f},
  566. {0x3808, 0x2 }, /* 0x280== 640*/
  567. {0x3809, 0x80},
  568. {0x380a, 0x1 }, /* 0x1e0== 480*/
  569. {0x380b, 0xe0},
  570. {0x380c, 0xc },
  571. {0x380d, 0x80},
  572. {0x380e, 0x7 },
  573. {0x380f, 0xd0},
  574. {0x5001, 0xa3}, /* SDE, scaling, color matrix, AWB enable */
  575. {0x5680, 0x0 }, /* AVG ctrl */
  576. {0x5681, 0x0 },
  577. {0x5682, 0xA },
  578. {0x5683, 0x20},
  579. {0x5684, 0x0 },
  580. {0x5685, 0x0 },
  581. {0x5686, 0x7 },
  582. {0x5687, 0x98},
  583. };
  584. static const struct regval ov5640_qsxga_to_xga_regs[] = {
  585. {0x3800, 0x00},
  586. {0x3801, 0x00},
  587. {0x3802, 0x00},
  588. {0x3803, 0x00},
  589. {0x3804, 0xA },
  590. {0x3805, 0x3f},
  591. {0x3806, 0x7 },
  592. {0x3807, 0x9f},
  593. {0x3808, 0x4 }, /* 0x400==1024 */
  594. {0x3809, 0x0 },
  595. {0x380a, 0x3 }, /* 0x300== 768*/
  596. {0x380b, 0x0 },
  597. {0x380c, 0xc },
  598. {0x380d, 0x80},
  599. {0x380e, 0x7 },
  600. {0x380f, 0xd0},
  601. {0x5001, 0xa3},
  602. {0x5680, 0x0 },
  603. {0x5681, 0x0 },
  604. {0x5682, 0xA },
  605. {0x5683, 0x20},
  606. {0x5684, 0x0 },
  607. {0x5685, 0x0 },
  608. {0x5686, 0x7 },
  609. {0x5687, 0x98},
  610. };
  611. static const struct regval ov5640_qsxga_to_sxga_regs[] = {
  612. {0x3800, 0x00},
  613. {0x3801, 0x00},
  614. {0x3802, 0x00},
  615. {0x3803, 0x00},
  616. {0x3804, 0xA },
  617. {0x3805, 0x3f},
  618. {0x3806, 0x7 },
  619. {0x3807, 0x9f},
  620. {0x3808, 0x5 }, /* 0x500==1280 */
  621. {0x3809, 0x0 },
  622. {0x380a, 0x3 }, /* 0x3c0==960 */
  623. {0x380b, 0xc0},
  624. {0x380c, 0xc },
  625. {0x380d, 0x80},
  626. {0x380e, 0x7 },
  627. {0x380f, 0xd0},
  628. {0x5001, 0xa3},
  629. {0x5680, 0x0 },
  630. {0x5681, 0x0 },
  631. {0x5682, 0xA },
  632. {0x5683, 0x20},
  633. {0x5684, 0x0 },
  634. {0x5685, 0x0 },
  635. {0x5686, 0x7 },
  636. {0x5687, 0x98},
  637. };
  638. static const struct regval ov5640_qsxga_to_uxga_regs[] = {
  639. #if 0
  640. {0x3800, 0x00},
  641. {0x3801, 0x00},
  642. {0x3802, 0x00},
  643. {0x3803, 0x00},
  644. {0x3804, 0xA },
  645. {0x3805, 0x3f},
  646. {0x3806, 0x7 },
  647. {0x3807, 0x9f},
  648. {0x3808, 0x6 }, /* 0x640== 1600*/
  649. {0x3809, 0x40},
  650. {0x380a, 0x4 }, /* 0x4b0==1200 */
  651. {0x380b, 0xb0},
  652. {0x380c, 0xc },
  653. {0x380d, 0x80},
  654. {0x380e, 0x7 },
  655. {0x380f, 0xd0},
  656. {0x5001, 0xa3},
  657. {0x5680, 0x0 },
  658. {0x5681, 0x0 },
  659. {0x5682, 0xA },
  660. {0x5683, 0x20},
  661. {0x5684, 0x0 },
  662. {0x5685, 0x0 },
  663. {0x5686, 0x7 },
  664. {0x5687, 0x98},
  665. #else
  666. {0x3503, 0x07},
  667. {0x3a00, 0x38},
  668. {0x4050, 0x6e},
  669. {0x4051, 0x8f},
  670. {0x5302, 0x1c},
  671. {0x5303, 0x08},
  672. {0x5306, 0x0c},
  673. {0x5307, 0x1c},
  674. {0x3820, 0x40},
  675. {0x3821, 0x06},
  676. {0x3800, 0x00},
  677. {0x3801, 0x00},
  678. {0x3802, 0x00},
  679. {0x3803, 0x00},
  680. {0x3804, 0x0a},
  681. {0x3805, 0x3f},
  682. {0x3806, 0x07},
  683. {0x3807, 0x9f},
  684. {0x3808, 0x0a},
  685. {0x3809, 0x20},
  686. {0x380a, 0x07},
  687. {0x380b, 0x98},
  688. {0x3810, 0x00},
  689. {0x3811, 0x10},
  690. {0x3812, 0x00},
  691. {0x3813, 0x04},
  692. {0x3814, 0x11},
  693. {0x3815, 0x11},
  694. {0x3034, 0x1a},
  695. {0x3035, 0x11},
  696. {0x3036, 0x46},
  697. {0x3037, 0x13},
  698. {0x3038, 0x00},
  699. {0x3039, 0x00},
  700. {0x380c, 0x0b},
  701. {0x380d, 0x1c},
  702. {0x380e, 0x07},
  703. {0x380f, 0xb0},
  704. {0x3a08, 0x00},
  705. {0x3a09, 0xc5},
  706. {0x3a0e, 0x0a},
  707. {0x3a0a, 0x00},
  708. {0x3a0b, 0xa4},
  709. {0x3a0d, 0x0c},
  710. {0x3618, 0x04},
  711. {0x3612, 0x2b},
  712. {0x3709, 0x12},
  713. {0x370c, 0x00},
  714. {0x4004, 0x06},
  715. {0x3002, 0x00},
  716. {0x3006, 0xff},
  717. {0x4713, 0x02},
  718. {0x4407, 0x04},
  719. {0x460b, 0x37},
  720. {0x460c, 0x22},
  721. {0x4837, 0x16},
  722. {0x3824, 0x01},
  723. {0x5001, 0x83},
  724. {0x4202,0x00},
  725. #endif
  726. };
  727. static const struct regval ov5640_qsxga_to_qxga_regs[] = {
  728. {0x3800, 0x00},
  729. {0x3801, 0x00},
  730. {0x3802, 0x00},
  731. {0x3803, 0x00},
  732. {0x3804, 0xA },
  733. {0x3805, 0x3f},
  734. {0x3806, 0x7 },
  735. {0x3807, 0x9f},
  736. {0x3808, 0x8 }, /* 0x800==2048 */
  737. {0x3809, 0x0 },
  738. {0x380a, 0x6 }, /* 0x600==1536 */
  739. {0x380b, 0x0 },
  740. {0x380c, 0xc },
  741. {0x380d, 0x80},
  742. {0x380e, 0x7 },
  743. {0x380f, 0xd0},
  744. {0x5001, 0xa3},
  745. {0x5680, 0x0 },
  746. {0x5681, 0x0 },
  747. {0x5682, 0xA },
  748. {0x5683, 0x20},
  749. {0x5684, 0x0 },
  750. {0x5685, 0x0 },
  751. {0x5686, 0x7 },
  752. {0x5687, 0x98},
  753. };
  754. #if 0
  755. static const struct v4l2_queryctrl ov5640_controls[] = {
  756. {
  757. .id = V4L2_CID_VFLIP,
  758. .type = V4L2_CTRL_TYPE_BOOLEAN,
  759. .name = "Flip Vertically",
  760. .minimum = 0,
  761. .maximum = 1,
  762. .step = 1,
  763. .default_value = 0,
  764. },
  765. {
  766. .id = V4L2_CID_HFLIP,
  767. .type = V4L2_CTRL_TYPE_BOOLEAN,
  768. .name = "Flip Horizontally",
  769. .minimum = 0,
  770. .maximum = 1,
  771. .step = 1,
  772. .default_value = 0,
  773. },
  774. };
  775. #endif
  776. /* QVGA: 320*240 */
  777. /*
  778. static const struct ov5640_win_size ov5640_win_qvga = {
  779. .name = "QVGA",
  780. .width = QVGA_WIDTH,
  781. .height = QVGA_HEIGHT,
  782. .regs = ov5640_qsxga_to_qvga_regs,
  783. };
  784. */
  785. static const struct ov5640_win_size ov5640_wins[] = {
  786. {
  787. .name = "VGA", /* VGA: 640*480 */
  788. .resv = RESV_VGA,
  789. .width = VGA_WIDTH,
  790. .height = VGA_HEIGHT,
  791. .regs = ov5640_qsxga_to_vga_regs,
  792. },
  793. {
  794. .name = "XGA", /* XGA: 1024*768 */
  795. .resv = RESV_XGA,
  796. .width = XGA_WIDTH,
  797. .height = XGA_HEIGHT,
  798. .regs = ov5640_qsxga_to_xga_regs,
  799. },
  800. {
  801. .name = "SXGA", /* SXGA: 1280*960 */
  802. .resv = RESV_SXGA,
  803. .width = SXGA_WIDTH,
  804. .height = SXGA_HEIGHT,
  805. .regs = ov5640_qsxga_to_sxga_regs,
  806. },
  807. {
  808. .name = "UXGA", /* UXGA: 1600*1200 */
  809. .resv = RESV_UXGA,
  810. .width = UXGA_WIDTH,
  811. .height = UXGA_HEIGHT,
  812. .regs = ov5640_qsxga_to_uxga_regs,
  813. },
  814. {
  815. .name = "QXGA", /* QXGA: 2048*1536 */
  816. .resv = RESV_QXGA,
  817. .width = QXGA_WIDTH,
  818. .height = QXGA_HEIGHT,
  819. .regs = ov5640_qsxga_to_qxga_regs,
  820. },
  821. {
  822. .name = "QSXGA", /* QSXGA: 2560*1920*/
  823. .resv = RESV_QSXGA,
  824. .width = QSXGA_WIDTH,
  825. .height = QSXGA_HEIGHT,
  826. .regs = ov5640_qsxga_regs,
  827. },
  828. };
  829. /*
  830. * supported color format list
  831. */
  832. static const struct ov5640_color_format ov5640_cfmts[] = {
  833. {
  834. .code = 2,//cym V4L2_MBUS_FMT_YUYV8_2X8_BE,
  835. .colorspace = V4L2_COLORSPACE_JPEG,
  836. },
  837. {
  838. .code = 3, //cym V4L2_MBUS_FMT_YUYV8_2X8_LE,
  839. .colorspace = V4L2_COLORSPACE_JPEG,
  840. },
  841. {
  842. .code = 0x2007, //cym V4L2_MBUS_FMT_YUYV8_2X8_LE,
  843. .colorspace = V4L2_COLORSPACE_JPEG,
  844. },
  845. };
  846. static int i2cc_get_reg(struct i2c_client *client,
  847. unsigned short reg, unsigned char *value)
  848. {
  849. unsigned char buffer[2];
  850. int ret = 0;
  851. int err = 0;
  852. buffer[0] = (reg >> 8) & 0xFF;
  853. buffer[1] = reg & 0xFF;
  854. if (2 != (ret = i2c_master_send(client, buffer, 2))) {
  855. err = -2;
  856. OV_ERR("i2cc out error: ret == %d (should be 2)\n", ret);
  857. }
  858. if (1 != (ret = i2c_master_recv(client, buffer, 1))) {
  859. err = -1;
  860. OV_ERR("i2cc in error: ret == %d (should be 1)\n", ret);
  861. }
  862. //OV_INFO("ov5640 client: read 0x%x = 0x%x\n", reg, buffer[0]);
  863. *value = buffer[0];
  864. return (err);
  865. }
  866. static int i2cc_set_reg(struct i2c_client *client,
  867. unsigned short reg, unsigned char value)
  868. {
  869. unsigned char buffer[3];
  870. int ret = 0;
  871. int err = 0;
  872. buffer[0] = (reg >> 8) & 0xFF;
  873. buffer[1] = reg & 0xFF;
  874. buffer[2] = value;
  875. //OV_INFO("ov5640 client: writing 0x%x = 0x%x\n", reg, value);
  876. if (3 != (ret = i2c_master_send(client, buffer, 3))) {
  877. OV_ERR("i2cc out error: ret = %d (should be 3)\n", ret);
  878. err = -3;
  879. }
  880. return (err);
  881. }
  882. #if 1
  883. /* add by dg 2015-07-15*/
  884. /*************************************************************************
  885. * FUNCTION
  886. * OV5640_FOCUS_AD5820_Init
  887. *
  888. * DESCRIPTION
  889. * This function is to load micro code for AF function
  890. *
  891. * PARAMETERS
  892. * None
  893. *
  894. * RETURNS
  895. * None
  896. *
  897. * GLOBALS AFFECTED
  898. *
  899. *************************************************************************/
  900. static u8 AD5820_Config[] =
  901. {
  902. 0x02, 0x0f, 0xd6, 0x02, 0x0a, 0x39, 0xc2, 0x01, 0x22, 0x22, 0x00, 0x02, 0x0f, 0xb2, 0xe5, 0x1f, //0x8000,
  903. 0x70, 0x72, 0xf5, 0x1e, 0xd2, 0x35, 0xff, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe4, 0xf6, 0x08, //0x8010,
  904. 0xf6, 0x0f, 0xbf, 0x34, 0xf2, 0x90, 0x0e, 0x93, 0xe4, 0x93, 0xff, 0xe5, 0x4b, 0xc3, 0x9f, 0x50, //0x8020,
  905. 0x04, 0x7f, 0x05, 0x80, 0x02, 0x7f, 0xfb, 0x78, 0xbd, 0xa6, 0x07, 0x12, 0x0f, 0x04, 0x40, 0x04, //0x8030,
  906. 0x7f, 0x03, 0x80, 0x02, 0x7f, 0x30, 0x78, 0xbc, 0xa6, 0x07, 0xe6, 0x18, 0xf6, 0x08, 0xe6, 0x78, //0x8040,
  907. 0xb9, 0xf6, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xbf, 0x76, 0x33, 0xe4, 0x08, 0xf6, 0x78, //0x8050,
  908. 0xb8, 0x76, 0x01, 0x75, 0x4a, 0x02, 0x78, 0xb6, 0xf6, 0x08, 0xf6, 0x74, 0xff, 0x78, 0xc1, 0xf6, //0x8060,
  909. 0x08, 0xf6, 0x75, 0x1f, 0x01, 0x78, 0xbc, 0xe6, 0x75, 0xf0, 0x05, 0xa4, 0xf5, 0x4b, 0x12, 0x0a, //0x8070,
  910. 0xff, 0xc2, 0x37, 0x22, 0x78, 0xb8, 0xe6, 0xd3, 0x94, 0x00, 0x40, 0x02, 0x16, 0x22, 0xe5, 0x1f, //0x8080,
  911. 0xb4, 0x05, 0x23, 0xe4, 0xf5, 0x1f, 0xc2, 0x01, 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x78, //0x8090,
  912. 0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x90, 0x30, 0x28, 0xf0, //0x80a0,
  913. 0x75, 0x1e, 0x10, 0xd2, 0x35, 0x22, 0xe5, 0x4b, 0x75, 0xf0, 0x05, 0x84, 0x78, 0xbc, 0xf6, 0x90, //0x80b0,
  914. 0x0e, 0x8c, 0xe4, 0x93, 0xff, 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x78, //0x80c0,
  915. 0xbc, 0xe6, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0xef, 0x12, 0x0f, 0x0b, //0x80d0,
  916. 0xd3, 0x78, 0xb7, 0x96, 0xee, 0x18, 0x96, 0x40, 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xb9, 0xf6, 0x78, //0x80e0,
  917. 0xb6, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x8c, 0xe4, 0x93, 0x12, 0x0f, 0x0b, 0xc3, 0x78, //0x80f0,
  918. 0xc2, 0x96, 0xee, 0x18, 0x96, 0x50, 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xc1, 0xa6, //0x8100,
  919. 0x06, 0x08, 0xa6, 0x07, 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xc3, 0x78, 0xc2, 0x96, 0xff, 0xee, //0x8110,
  920. 0x18, 0x96, 0x78, 0xc3, 0xf6, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x95, 0xe4, 0x18, 0x12, 0x0e, 0xe9, //0x8120,
  921. 0x40, 0x02, 0xd2, 0x37, 0x78, 0xbc, 0xe6, 0x08, 0x26, 0x08, 0xf6, 0xe5, 0x1f, 0x64, 0x01, 0x70, //0x8130,
  922. 0x4a, 0xe6, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xdf, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, 0x39, 0x12, //0x8140,
  923. 0x0f, 0x02, 0x40, 0x04, 0x7f, 0xfe, 0x80, 0x02, 0x7f, 0x02, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9, //0x8150,
  924. 0xe6, 0x24, 0x03, 0x78, 0xbf, 0xf6, 0x78, 0xb9, 0xe6, 0x24, 0xfd, 0x78, 0xc0, 0xf6, 0x12, 0x0f, //0x8160,
  925. 0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6, //0x8170,
  926. 0x07, 0x75, 0x1f, 0x02, 0x78, 0xb8, 0x76, 0x01, 0x02, 0x02, 0x4a, 0xe5, 0x1f, 0x64, 0x02, 0x60, //0x8180,
  927. 0x03, 0x02, 0x02, 0x2a, 0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x08, //0x8190,
  928. 0x12, 0x0e, 0xda, 0x50, 0x03, 0x02, 0x02, 0x28, 0x12, 0x0f, 0x02, 0x40, 0x04, 0x7f, 0xff, 0x80, //0x81a0,
  929. 0x02, 0x7f, 0x01, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9, 0xe6, 0x04, 0x78, 0xbf, 0xf6, 0x78, 0xb9, //0x81b0,
  930. 0xe6, 0x14, 0x78, 0xc0, 0xf6, 0x18, 0x12, 0x0f, 0x04, 0x40, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, //0x81c0,
  931. 0x00, 0x78, 0xbf, 0xa6, 0x07, 0xd3, 0x08, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x40, 0x04, 0xe6, 0xff, //0x81d0,
  932. 0x80, 0x02, 0x7f, 0x00, 0x78, 0xc0, 0xa6, 0x07, 0xc3, 0x18, 0xe6, 0x64, 0x80, 0x94, 0xb3, 0x50, //0x81e0,
  933. 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xbf, 0xa6, 0x07, 0xc3, 0x08, 0xe6, 0x64, 0x80, //0x81f0,
  934. 0x94, 0xb3, 0x50, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xc0, 0xa6, 0x07, 0x12, 0x0f, //0x8200,
  935. 0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6, //0x8210,
  936. 0x07, 0x75, 0x1f, 0x03, 0x78, 0xb8, 0x76, 0x01, 0x80, 0x20, 0xe5, 0x1f, 0x64, 0x03, 0x70, 0x26, //0x8220,
  937. 0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, //0x8230,
  938. 0x09, 0x78, 0xb9, 0xe6, 0x78, 0xbe, 0xf6, 0x75, 0x1f, 0x04, 0x78, 0xbe, 0xe6, 0x75, 0xf0, 0x05, //0x8240,
  939. 0xa4, 0xf5, 0x4b, 0x02, 0x0a, 0xff, 0xe5, 0x1f, 0xb4, 0x04, 0x10, 0x90, 0x0e, 0x94, 0xe4, 0x78, //0x8250,
  940. 0xc3, 0x12, 0x0e, 0xe9, 0x40, 0x02, 0xd2, 0x37, 0x75, 0x1f, 0x05, 0x22, 0x30, 0x01, 0x03, 0x02, //0x8260,
  941. 0x04, 0xc0, 0x30, 0x02, 0x03, 0x02, 0x04, 0xc0, 0x90, 0x51, 0xa5, 0xe0, 0x78, 0x93, 0xf6, 0xa3, //0x8270,
  942. 0xe0, 0x08, 0xf6, 0xa3, 0xe0, 0x08, 0xf6, 0xe5, 0x1f, 0x70, 0x3c, 0x75, 0x1e, 0x20, 0xd2, 0x35, //0x8280,
  943. 0x12, 0x0c, 0x7a, 0x78, 0x7e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xa6, 0x09, 0x18, 0x76, //0x8290,
  944. 0x01, 0x12, 0x0c, 0x5b, 0x78, 0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xe6, 0x78, 0x6e, //0x82a0,
  945. 0xf6, 0x75, 0x1f, 0x01, 0x78, 0x93, 0xe6, 0x78, 0x90, 0xf6, 0x78, 0x94, 0xe6, 0x78, 0x91, 0xf6, //0x82b0,
  946. 0x78, 0x95, 0xe6, 0x78, 0x92, 0xf6, 0x22, 0x79, 0x90, 0xe7, 0xd3, 0x78, 0x93, 0x96, 0x40, 0x05, //0x82c0,
  947. 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x93, 0xe7, 0x78, 0x90, 0x96, 0xff, 0x78, 0x88, 0x76, //0x82d0,
  948. 0x00, 0x08, 0xa6, 0x07, 0x79, 0x91, 0xe7, 0xd3, 0x78, 0x94, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, //0x82e0,
  949. 0x80, 0x08, 0xc3, 0x79, 0x94, 0xe7, 0x78, 0x91, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x79, 0x92, 0xe7, //0x82f0,
  950. 0xd3, 0x78, 0x95, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x95, 0xe7, 0x78, //0x8300,
  951. 0x92, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x12, 0x0c, 0x5b, 0x78, 0x8a, 0xe6, 0x25, 0xe0, 0x24, 0x4e, //0x8310,
  952. 0xf8, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8a, 0xe6, 0x24, 0x6e, 0xf8, 0xa6, 0x09, 0x78, 0x8a, //0x8320,
  953. 0xe6, 0x24, 0x01, 0xff, 0xe4, 0x33, 0xfe, 0xd3, 0xef, 0x94, 0x0f, 0xee, 0x64, 0x80, 0x94, 0x80, //0x8330,
  954. 0x40, 0x04, 0x7f, 0x00, 0x80, 0x05, 0x78, 0x8a, 0xe6, 0x04, 0xff, 0x78, 0x8a, 0xa6, 0x07, 0xe5, //0x8340,
  955. 0x1f, 0xb4, 0x01, 0x0a, 0xe6, 0x60, 0x03, 0x02, 0x04, 0xc0, 0x75, 0x1f, 0x02, 0x22, 0x12, 0x0c, //0x8350,
  956. 0x7a, 0x78, 0x80, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x12, 0x0c, 0x7a, 0x78, 0x82, 0xa6, 0x06, 0x08, //0x8360,
  957. 0xa6, 0x07, 0x78, 0x6e, 0xe6, 0x78, 0x8c, 0xf6, 0x78, 0x6e, 0xe6, 0x78, 0x8d, 0xf6, 0x7f, 0x01, //0x8370,
  958. 0xef, 0x25, 0xe0, 0x24, 0x4f, 0xf9, 0xc3, 0x78, 0x81, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x50, //0x8380,
  959. 0x0a, 0x12, 0x0c, 0x82, 0x78, 0x80, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, //0x8390,
  960. 0x8c, 0xe6, 0xc3, 0x97, 0x50, 0x08, 0x74, 0x6e, 0x2f, 0xf8, 0xe6, 0x78, 0x8c, 0xf6, 0xef, 0x25, //0x83a0,
  961. 0xe0, 0x24, 0x4f, 0xf9, 0xd3, 0x78, 0x83, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x40, 0x0a, 0x12, //0x83b0,
  962. 0x0c, 0x82, 0x78, 0x82, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, 0x8d, 0xe6, //0x83c0,
  963. 0xd3, 0x97, 0x40, 0x08, 0x74, 0x6e, 0x2f, 0xf8, 0xe6, 0x78, 0x8d, 0xf6, 0x0f, 0xef, 0x64, 0x10, //0x83d0,
  964. 0x70, 0x9e, 0xc3, 0x79, 0x81, 0xe7, 0x78, 0x83, 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0x78, 0x84, //0x83e0,
  965. 0xf6, 0x08, 0xa6, 0x07, 0xc3, 0x79, 0x8c, 0xe7, 0x78, 0x8d, 0x96, 0x08, 0xf6, 0xd3, 0x79, 0x81, //0x83f0,
  966. 0xe7, 0x78, 0x7f, 0x96, 0x19, 0xe7, 0x18, 0x96, 0x40, 0x05, 0x09, 0xe7, 0x08, 0x80, 0x06, 0xc3, //0x8400,
  967. 0x79, 0x7f, 0xe7, 0x78, 0x81, 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0xfe, 0x78, 0x86, 0xa6, 0x06, //0x8410,
  968. 0x08, 0xa6, 0x07, 0x79, 0x8c, 0xe7, 0xd3, 0x78, 0x8b, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, //0x8420,
  969. 0x08, 0xc3, 0x79, 0x8b, 0xe7, 0x78, 0x8c, 0x96, 0xff, 0x78, 0x8f, 0xa6, 0x07, 0xe5, 0x1f, 0x64, //0x8430,
  970. 0x02, 0x70, 0x69, 0x90, 0x0e, 0x91, 0x93, 0xff, 0x18, 0xe6, 0xc3, 0x9f, 0x50, 0x72, 0x12, 0x0c, //0x8440,
  971. 0x4a, 0x12, 0x0c, 0x2f, 0x90, 0x0e, 0x8e, 0x12, 0x0c, 0x38, 0x78, 0x80, 0x12, 0x0c, 0x6b, 0x7b, //0x8450,
  972. 0x04, 0x12, 0x0c, 0x1d, 0xc3, 0x12, 0x06, 0x45, 0x50, 0x56, 0x90, 0x0e, 0x92, 0xe4, 0x93, 0xff, //0x8460,
  973. 0x78, 0x8f, 0xe6, 0x9f, 0x40, 0x02, 0x80, 0x11, 0x90, 0x0e, 0x90, 0xe4, 0x93, 0xff, 0xd3, 0x78, //0x8470,
  974. 0x89, 0xe6, 0x9f, 0x18, 0xe6, 0x94, 0x00, 0x40, 0x03, 0x75, 0x1f, 0x05, 0x12, 0x0c, 0x4a, 0x12, //0x8480,
  975. 0x0c, 0x2f, 0x90, 0x0e, 0x8f, 0x12, 0x0c, 0x38, 0x78, 0x7e, 0x12, 0x0c, 0x6b, 0x7b, 0x40, 0x12, //0x8490,
  976. 0x0c, 0x1d, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x18, 0x75, 0x1f, 0x05, 0x22, 0xe5, 0x1f, 0xb4, 0x05, //0x84a0,
  977. 0x0f, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0xd2, 0x36, //0x84b0,
  978. 0x22, 0xef, 0x8d, 0xf0, 0xa4, 0xa8, 0xf0, 0xcf, 0x8c, 0xf0, 0xa4, 0x28, 0xce, 0x8d, 0xf0, 0xa4, //0x84c0,
  979. 0x2e, 0xfe, 0x22, 0xbc, 0x00, 0x0b, 0xbe, 0x00, 0x29, 0xef, 0x8d, 0xf0, 0x84, 0xff, 0xad, 0xf0, //0x84d0,
  980. 0x22, 0xe4, 0xcc, 0xf8, 0x75, 0xf0, 0x08, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xec, 0x33, 0xfc, //0x84e0,
  981. 0xee, 0x9d, 0xec, 0x98, 0x40, 0x05, 0xfc, 0xee, 0x9d, 0xfe, 0x0f, 0xd5, 0xf0, 0xe9, 0xe4, 0xce, //0x84f0,
  982. 0xfd, 0x22, 0xed, 0xf8, 0xf5, 0xf0, 0xee, 0x84, 0x20, 0xd2, 0x1c, 0xfe, 0xad, 0xf0, 0x75, 0xf0, //0x8500,
  983. 0x08, 0xef, 0x2f, 0xff, 0xed, 0x33, 0xfd, 0x40, 0x07, 0x98, 0x50, 0x06, 0xd5, 0xf0, 0xf2, 0x22, //0x8510,
  984. 0xc3, 0x98, 0xfd, 0x0f, 0xd5, 0xf0, 0xea, 0x22, 0xe8, 0x8f, 0xf0, 0xa4, 0xcc, 0x8b, 0xf0, 0xa4, //0x8520,
  985. 0x2c, 0xfc, 0xe9, 0x8e, 0xf0, 0xa4, 0x2c, 0xfc, 0x8a, 0xf0, 0xed, 0xa4, 0x2c, 0xfc, 0xea, 0x8e, //0x8530,
  986. 0xf0, 0xa4, 0xcd, 0xa8, 0xf0, 0x8b, 0xf0, 0xa4, 0x2d, 0xcc, 0x38, 0x25, 0xf0, 0xfd, 0xe9, 0x8f, //0x8540,
  987. 0xf0, 0xa4, 0x2c, 0xcd, 0x35, 0xf0, 0xfc, 0xeb, 0x8e, 0xf0, 0xa4, 0xfe, 0xa9, 0xf0, 0xeb, 0x8f, //0x8550,
  988. 0xf0, 0xa4, 0xcf, 0xc5, 0xf0, 0x2e, 0xcd, 0x39, 0xfe, 0xe4, 0x3c, 0xfc, 0xea, 0xa4, 0x2d, 0xce, //0x8560,
  989. 0x35, 0xf0, 0xfd, 0xe4, 0x3c, 0xfc, 0x22, 0x75, 0xf0, 0x08, 0x75, 0x82, 0x00, 0xef, 0x2f, 0xff, //0x8570,
  990. 0xee, 0x33, 0xfe, 0xcd, 0x33, 0xcd, 0xcc, 0x33, 0xcc, 0xc5, 0x82, 0x33, 0xc5, 0x82, 0x9b, 0xed, //0x8580,
  991. 0x9a, 0xec, 0x99, 0xe5, 0x82, 0x98, 0x40, 0x0c, 0xf5, 0x82, 0xee, 0x9b, 0xfe, 0xed, 0x9a, 0xfd, //0x8590,
  992. 0xec, 0x99, 0xfc, 0x0f, 0xd5, 0xf0, 0xd6, 0xe4, 0xce, 0xfb, 0xe4, 0xcd, 0xfa, 0xe4, 0xcc, 0xf9, //0x85a0,
  993. 0xa8, 0x82, 0x22, 0xb8, 0x00, 0xc1, 0xb9, 0x00, 0x59, 0xba, 0x00, 0x2d, 0xec, 0x8b, 0xf0, 0x84, //0x85b0,
  994. 0xcf, 0xce, 0xcd, 0xfc, 0xe5, 0xf0, 0xcb, 0xf9, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, //0x85c0,
  995. 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xeb, 0x33, 0xfb, 0x10, 0xd7, 0x03, 0x99, 0x40, 0x04, 0xeb, //0x85d0,
  996. 0x99, 0xfb, 0x0f, 0xd8, 0xe5, 0xe4, 0xf9, 0xfa, 0x22, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, //0x85e0,
  997. 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xc9, 0x33, 0xc9, 0x10, 0xd7, 0x05, 0x9b, 0xe9, 0x9a, //0x85f0,
  998. 0x40, 0x07, 0xec, 0x9b, 0xfc, 0xe9, 0x9a, 0xf9, 0x0f, 0xd8, 0xe0, 0xe4, 0xc9, 0xfa, 0xe4, 0xcc, //0x8600,
  999. 0xfb, 0x22, 0x75, 0xf0, 0x10, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xcc, 0x33, //0x8610,
  1000. 0xcc, 0xc8, 0x33, 0xc8, 0x10, 0xd7, 0x07, 0x9b, 0xec, 0x9a, 0xe8, 0x99, 0x40, 0x0a, 0xed, 0x9b, //0x8620,
  1001. 0xfd, 0xec, 0x9a, 0xfc, 0xe8, 0x99, 0xf8, 0x0f, 0xd5, 0xf0, 0xda, 0xe4, 0xcd, 0xfb, 0xe4, 0xcc, //0x8630,
  1002. 0xfa, 0xe4, 0xc8, 0xf9, 0x22, 0xeb, 0x9f, 0xf5, 0xf0, 0xea, 0x9e, 0x42, 0xf0, 0xe9, 0x9d, 0x42, //0x8640,
  1003. 0xf0, 0xe8, 0x9c, 0x45, 0xf0, 0x22, 0xe8, 0x60, 0x0f, 0xec, 0xc3, 0x13, 0xfc, 0xed, 0x13, 0xfd, //0x8650,
  1004. 0xee, 0x13, 0xfe, 0xef, 0x13, 0xff, 0xd8, 0xf1, 0x22, 0xe8, 0x60, 0x0f, 0xef, 0xc3, 0x33, 0xff, //0x8660,
  1005. 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xd8, 0xf1, 0x22, 0xe4, 0x93, 0xfc, 0x74, //0x8670,
  1006. 0x01, 0x93, 0xfd, 0x74, 0x02, 0x93, 0xfe, 0x74, 0x03, 0x93, 0xff, 0x22, 0xe6, 0xfb, 0x08, 0xe6, //0x8680,
  1007. 0xf9, 0x08, 0xe6, 0xfa, 0x08, 0xe6, 0xcb, 0xf8, 0x22, 0xec, 0xf6, 0x08, 0xed, 0xf6, 0x08, 0xee, //0x8690,
  1008. 0xf6, 0x08, 0xef, 0xf6, 0x22, 0xa4, 0x25, 0x82, 0xf5, 0x82, 0xe5, 0xf0, 0x35, 0x83, 0xf5, 0x83, //0x86a0,
  1009. 0x22, 0xd0, 0x83, 0xd0, 0x82, 0xf8, 0xe4, 0x93, 0x70, 0x12, 0x74, 0x01, 0x93, 0x70, 0x0d, 0xa3, //0x86b0,
  1010. 0xa3, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf5, 0x82, 0x88, 0x83, 0xe4, 0x73, 0x74, 0x02, 0x93, 0x68, //0x86c0,
  1011. 0x60, 0xef, 0xa3, 0xa3, 0xa3, 0x80, 0xdf, 0x90, 0x38, 0x04, 0x78, 0x52, 0x12, 0x0b, 0xfd, 0x90, //0x86d0,
  1012. 0x38, 0x00, 0xe0, 0xfe, 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x10, //0x86e0,
  1013. 0x12, 0x0b, 0x92, 0x90, 0x38, 0x06, 0x78, 0x54, 0x12, 0x0b, 0xfd, 0x90, 0x38, 0x02, 0xe0, 0xfe, //0x86f0,
  1014. 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x12, 0x12, 0x0b, 0x92, 0xa3, //0x8700,
  1015. 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x52, 0x79, 0x52, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x14, 0xe0, 0xb4, //0x8710,
  1016. 0x71, 0x15, 0x78, 0x52, 0xe6, 0xfe, 0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, //0x8720,
  1017. 0xf9, 0x79, 0x53, 0xf7, 0xee, 0x19, 0xf7, 0x90, 0x38, 0x15, 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x54, //0x8730,
  1018. 0x79, 0x54, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x15, 0xe0, 0xb4, 0x71, 0x15, 0x78, 0x54, 0xe6, 0xfe, //0x8740,
  1019. 0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0x79, 0x55, 0xf7, 0xee, 0x19, //0x8750,
  1020. 0xf7, 0x79, 0x52, 0x12, 0x0b, 0xd9, 0x09, 0x12, 0x0b, 0xd9, 0xaf, 0x47, 0x12, 0x0b, 0xb2, 0xe5, //0x8760,
  1021. 0x44, 0xfb, 0x7a, 0x00, 0xfd, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x5a, 0xa6, 0x06, 0x08, 0xa6, //0x8770,
  1022. 0x07, 0xaf, 0x45, 0x12, 0x0b, 0xb2, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x56, 0xa6, //0x8780,
  1023. 0x06, 0x08, 0xa6, 0x07, 0xaf, 0x48, 0x78, 0x54, 0x12, 0x0b, 0xb4, 0xe5, 0x43, 0xfb, 0xfd, 0x7c, //0x8790,
  1024. 0x00, 0x12, 0x04, 0xd3, 0x78, 0x5c, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xaf, 0x46, 0x7e, 0x00, 0x78, //0x87a0,
  1025. 0x54, 0x12, 0x0b, 0xb6, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x58, 0xa6, 0x06, 0x08, //0x87b0,
  1026. 0xa6, 0x07, 0xc3, 0x78, 0x5b, 0xe6, 0x94, 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, 0x00, //0x87c0,
  1027. 0x08, 0x76, 0x08, 0xc3, 0x78, 0x5d, 0xe6, 0x94, 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, //0x87d0,
  1028. 0x00, 0x08, 0x76, 0x08, 0x78, 0x5a, 0x12, 0x0b, 0xc6, 0xff, 0xd3, 0x78, 0x57, 0xe6, 0x9f, 0x18, //0x87e0,
  1029. 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5a, 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x57, 0x12, 0x0c, 0x08, //0x87f0,
  1030. 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x78, 0x5e, 0x12, 0x0b, 0xbe, 0xff, 0xd3, 0x78, 0x59, 0xe6, //0x8800,
  1031. 0x9f, 0x18, 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5c, 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x59, 0x12, //0x8810,
  1032. 0x0c, 0x08, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0xe4, 0xfc, 0xfd, 0x78, 0x62, 0x12, 0x06, 0x99, //0x8820,
  1033. 0x78, 0x5a, 0x12, 0x0b, 0xc6, 0x78, 0x57, 0x26, 0xff, 0xee, 0x18, 0x36, 0xfe, 0x78, 0x66, 0x12, //0x8830,
  1034. 0x0b, 0xbe, 0x78, 0x59, 0x26, 0xff, 0xee, 0x18, 0x36, 0xfe, 0xe4, 0xfc, 0xfd, 0x78, 0x6a, 0x12, //0x8840,
  1035. 0x06, 0x99, 0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x08, //0x8850,
  1036. 0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x99, 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12, //0x8860,
  1037. 0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x0a, 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12, //0x8870,
  1038. 0x06, 0x99, 0x78, 0x61, 0xe6, 0x90, 0x60, 0x01, 0xf0, 0x78, 0x65, 0xe6, 0xa3, 0xf0, 0x78, 0x69, //0x8880,
  1039. 0xe6, 0xa3, 0xf0, 0x78, 0x55, 0xe6, 0xa3, 0xf0, 0x7d, 0x01, 0x78, 0x61, 0x12, 0x0b, 0xe9, 0x24, //0x8890,
  1040. 0x01, 0x12, 0x0b, 0xa6, 0x78, 0x65, 0x12, 0x0b, 0xe9, 0x24, 0x02, 0x12, 0x0b, 0xa6, 0x78, 0x69, //0x88a0,
  1041. 0x12, 0x0b, 0xe9, 0x24, 0x03, 0x12, 0x0b, 0xa6, 0x78, 0x6d, 0x12, 0x0b, 0xe9, 0x24, 0x04, 0x12, //0x88b0,
  1042. 0x0b, 0xa6, 0x0d, 0xbd, 0x05, 0xd4, 0xc2, 0x0e, 0xc2, 0x06, 0x22, 0x85, 0x08, 0x41, 0x90, 0x30, //0x88c0,
  1043. 0x24, 0xe0, 0xf5, 0x3d, 0xa3, 0xe0, 0xf5, 0x3e, 0xa3, 0xe0, 0xf5, 0x3f, 0xa3, 0xe0, 0xf5, 0x40, //0x88d0,
  1044. 0xa3, 0xe0, 0xf5, 0x3c, 0xd2, 0x34, 0xe5, 0x41, 0x12, 0x06, 0xb1, 0x09, 0x31, 0x03, 0x09, 0x35, //0x88e0,
  1045. 0x04, 0x09, 0x3b, 0x05, 0x09, 0x3e, 0x06, 0x09, 0x41, 0x07, 0x09, 0x4a, 0x08, 0x09, 0x5b, 0x12, //0x88f0,
  1046. 0x09, 0x73, 0x18, 0x09, 0x89, 0x19, 0x09, 0x5e, 0x1a, 0x09, 0x6a, 0x1b, 0x09, 0xad, 0x80, 0x09, //0x8900,
  1047. 0xb2, 0x81, 0x0a, 0x1d, 0x8f, 0x0a, 0x09, 0x90, 0x0a, 0x1d, 0x91, 0x0a, 0x1d, 0x92, 0x0a, 0x1d, //0x8910,
  1048. 0x93, 0x0a, 0x1d, 0x94, 0x0a, 0x1d, 0x98, 0x0a, 0x17, 0x9f, 0x0a, 0x1a, 0xec, 0x00, 0x00, 0x0a, //0x8920,
  1049. 0x38, 0x12, 0x0f, 0x74, 0x22, 0x12, 0x0f, 0x74, 0xd2, 0x03, 0x22, 0xd2, 0x03, 0x22, 0xc2, 0x03, //0x8930,
  1050. 0x22, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x02, 0x0a, 0x1d, 0xc2, 0x01, 0xc2, 0x02, 0xc2, 0x03, //0x8940,
  1051. 0x12, 0x0d, 0x0d, 0x75, 0x1e, 0x70, 0xd2, 0x35, 0x02, 0x0a, 0x1d, 0x02, 0x0a, 0x04, 0x85, 0x40, //0x8950,
  1052. 0x4a, 0x85, 0x3c, 0x4b, 0x12, 0x0a, 0xff, 0x02, 0x0a, 0x1d, 0x85, 0x4a, 0x40, 0x85, 0x4b, 0x3c, //0x8960,
  1053. 0x02, 0x0a, 0x1d, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x85, 0x40, 0x31, 0x85, 0x3f, 0x30, 0x85, 0x3e, //0x8970,
  1054. 0x2f, 0x85, 0x3d, 0x2e, 0x12, 0x0f, 0x46, 0x80, 0x1f, 0x75, 0x22, 0x00, 0x75, 0x23, 0x01, 0x74, //0x8980,
  1055. 0xff, 0xf5, 0x2d, 0xf5, 0x2c, 0xf5, 0x2b, 0xf5, 0x2a, 0x12, 0x0f, 0x46, 0x85, 0x2d, 0x40, 0x85, //0x8990,
  1056. 0x2c, 0x3f, 0x85, 0x2b, 0x3e, 0x85, 0x2a, 0x3d, 0xe4, 0xf5, 0x3c, 0x80, 0x70, 0x12, 0x0f, 0x16, //0x89a0,
  1057. 0x80, 0x6b, 0x85, 0x3d, 0x45, 0x85, 0x3e, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xe5, 0x45, 0xc3, //0x89b0,
  1058. 0x9f, 0x50, 0x02, 0x8f, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff, 0xe5, 0x46, 0xc3, 0x9f, 0x50, 0x02, //0x89c0,
  1059. 0x8f, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xfd, 0xe5, 0x45, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5, //0x89d0,
  1060. 0x44, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, 0x44, 0x9f, 0xf5, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff, //0x89e0,
  1061. 0xfd, 0xe5, 0x46, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5, 0x43, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, //0x89f0,
  1062. 0x43, 0x9f, 0xf5, 0x46, 0x12, 0x06, 0xd7, 0x80, 0x14, 0x85, 0x40, 0x48, 0x85, 0x3f, 0x47, 0x85, //0x8a00,
  1063. 0x3e, 0x46, 0x85, 0x3d, 0x45, 0x80, 0x06, 0x02, 0x06, 0xd7, 0x12, 0x0d, 0x7e, 0x90, 0x30, 0x24, //0x8a10,
  1064. 0xe5, 0x3d, 0xf0, 0xa3, 0xe5, 0x3e, 0xf0, 0xa3, 0xe5, 0x3f, 0xf0, 0xa3, 0xe5, 0x40, 0xf0, 0xa3, //0x8a20,
  1065. 0xe5, 0x3c, 0xf0, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, //0x8a30,
  1066. 0xd0, 0x90, 0x3f, 0x0c, 0xe0, 0xf5, 0x32, 0xe5, 0x32, 0x30, 0xe3, 0x74, 0x30, 0x36, 0x66, 0x90, //0x8a40,
  1067. 0x60, 0x19, 0xe0, 0xf5, 0x0a, 0xa3, 0xe0, 0xf5, 0x0b, 0x90, 0x60, 0x1d, 0xe0, 0xf5, 0x14, 0xa3, //0x8a50,
  1068. 0xe0, 0xf5, 0x15, 0x90, 0x60, 0x21, 0xe0, 0xf5, 0x0c, 0xa3, 0xe0, 0xf5, 0x0d, 0x90, 0x60, 0x29, //0x8a60,
  1069. 0xe0, 0xf5, 0x0e, 0xa3, 0xe0, 0xf5, 0x0f, 0x90, 0x60, 0x31, 0xe0, 0xf5, 0x10, 0xa3, 0xe0, 0xf5, //0x8a70,
  1070. 0x11, 0x90, 0x60, 0x39, 0xe0, 0xf5, 0x12, 0xa3, 0xe0, 0xf5, 0x13, 0x30, 0x01, 0x06, 0x30, 0x33, //0x8a80,
  1071. 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x09, 0x30, 0x02, 0x06, 0x30, 0x33, 0x03, 0xd3, 0x80, 0x01, //0x8a90,
  1072. 0xc3, 0x92, 0x0a, 0x30, 0x33, 0x0c, 0x30, 0x03, 0x09, 0x20, 0x02, 0x06, 0x20, 0x01, 0x03, 0xd3, //0x8aa0,
  1073. 0x80, 0x01, 0xc3, 0x92, 0x0b, 0x90, 0x30, 0x01, 0xe0, 0x44, 0x40, 0xf0, 0xe0, 0x54, 0xbf, 0xf0, //0x8ab0,
  1074. 0xe5, 0x32, 0x30, 0xe1, 0x14, 0x30, 0x34, 0x11, 0x90, 0x30, 0x22, 0xe0, 0xf5, 0x08, 0xe4, 0xf0, //0x8ac0,
  1075. 0x30, 0x00, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x08, 0xe5, 0x32, 0x30, 0xe5, 0x12, 0x90, 0x56, //0x8ad0,
  1076. 0xa1, 0xe0, 0xf5, 0x09, 0x30, 0x31, 0x09, 0x30, 0x05, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x0d, //0x8ae0,
  1077. 0x90, 0x3f, 0x0c, 0xe5, 0x32, 0xf0, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, //0x8af0,
  1078. 0x0e, 0x7e, 0xe4, 0x93, 0xfe, 0x74, 0x01, 0x93, 0xff, 0xc3, 0x90, 0x0e, 0x7c, 0x74, 0x01, 0x93, //0x8b00,
  1079. 0x9f, 0xff, 0xe4, 0x93, 0x9e, 0xfe, 0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0xab, //0x8b10,
  1080. 0x3b, 0xaa, 0x3a, 0xa9, 0x39, 0xa8, 0x38, 0xaf, 0x4b, 0xfc, 0xfd, 0xfe, 0x12, 0x05, 0x28, 0x12, //0x8b20,
  1081. 0x0d, 0xe1, 0xe4, 0x7b, 0xff, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0xb3, 0x12, 0x0d, 0xe1, 0x90, 0x0e, //0x8b30,
  1082. 0x69, 0xe4, 0x12, 0x0d, 0xf6, 0x12, 0x0d, 0xe1, 0xe4, 0x85, 0x4a, 0x37, 0xf5, 0x36, 0xf5, 0x35, //0x8b40,
  1083. 0xf5, 0x34, 0xaf, 0x37, 0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0xa3, 0x12, 0x0d, 0xf6, 0x8f, 0x37, //0x8b50,
  1084. 0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0xe5, 0x3b, 0x45, 0x37, 0xf5, 0x3b, 0xe5, 0x3a, 0x45, 0x36, //0x8b60,
  1085. 0xf5, 0x3a, 0xe5, 0x39, 0x45, 0x35, 0xf5, 0x39, 0xe5, 0x38, 0x45, 0x34, 0xf5, 0x38, 0xe4, 0xf5, //0x8b70,
  1086. 0x22, 0xf5, 0x23, 0x85, 0x3b, 0x31, 0x85, 0x3a, 0x30, 0x85, 0x39, 0x2f, 0x85, 0x38, 0x2e, 0x02, //0x8b80,
  1087. 0x0f, 0x46, 0xe0, 0xa3, 0xe0, 0x75, 0xf0, 0x02, 0xa4, 0xff, 0xae, 0xf0, 0xc3, 0x08, 0xe6, 0x9f, //0x8b90,
  1088. 0xf6, 0x18, 0xe6, 0x9e, 0xf6, 0x22, 0xff, 0xe5, 0xf0, 0x34, 0x60, 0x8f, 0x82, 0xf5, 0x83, 0xec, //0x8ba0,
  1089. 0xf0, 0x22, 0x78, 0x52, 0x7e, 0x00, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x02, 0x04, 0xc1, 0xe4, 0xfc, //0x8bb0,
  1090. 0xfd, 0x12, 0x06, 0x99, 0x78, 0x5c, 0xe6, 0xc3, 0x13, 0xfe, 0x08, 0xe6, 0x13, 0x22, 0x78, 0x52, //0x8bc0,
  1091. 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0xe4, 0xfc, 0xfd, 0x22, 0xe7, 0xc4, 0xf8, 0x54, 0xf0, 0xc8, 0x68, //0x8bd0,
  1092. 0xf7, 0x09, 0xe7, 0xc4, 0x54, 0x0f, 0x48, 0xf7, 0x22, 0xe6, 0xfc, 0xed, 0x75, 0xf0, 0x04, 0xa4, //0x8be0,
  1093. 0x22, 0x12, 0x06, 0x7c, 0x8f, 0x48, 0x8e, 0x47, 0x8d, 0x46, 0x8c, 0x45, 0x22, 0xe0, 0xfe, 0xa3, //0x8bf0,
  1094. 0xe0, 0xfd, 0xee, 0xf6, 0xed, 0x08, 0xf6, 0x22, 0x13, 0xff, 0xc3, 0xe6, 0x9f, 0xff, 0x18, 0xe6, //0x8c00,
  1095. 0x9e, 0xfe, 0x22, 0xe6, 0xc3, 0x13, 0xf7, 0x08, 0xe6, 0x13, 0x09, 0xf7, 0x22, 0xad, 0x39, 0xac, //0x8c10,
  1096. 0x38, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0x28, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0xab, //0x8c20,
  1097. 0x37, 0xaa, 0x36, 0xa9, 0x35, 0xa8, 0x34, 0x22, 0x93, 0xff, 0xe4, 0xfc, 0xfd, 0xfe, 0x12, 0x05, //0x8c30,
  1098. 0x28, 0x8f, 0x37, 0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0x22, 0x78, 0x84, 0xe6, 0xfe, 0x08, 0xe6, //0x8c40,
  1099. 0xff, 0xe4, 0x8f, 0x37, 0x8e, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0x22, 0x90, 0x0e, 0x8c, 0xe4, 0x93, //0x8c50,
  1100. 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe6, 0xfe, 0x08, 0xe6, 0xff, //0x8c60,
  1101. 0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0x22, 0x78, 0x4e, 0xe6, 0xfe, 0x08, 0xe6, //0x8c70,
  1102. 0xff, 0x22, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x22, 0x78, 0x89, //0x8c80,
  1103. 0xef, 0x26, 0xf6, 0x18, 0xe4, 0x36, 0xf6, 0x22, 0x75, 0x89, 0x03, 0x75, 0xa8, 0x01, 0x75, 0xb8, //0x8c90,
  1104. 0x04, 0x75, 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x15, 0x75, 0x37, 0x0d, 0x12, 0x0e, 0x9a, //0x8ca0,
  1105. 0x12, 0x00, 0x09, 0x12, 0x0f, 0x16, 0x12, 0x00, 0x06, 0xd2, 0x00, 0xd2, 0x34, 0xd2, 0xaf, 0x75, //0x8cb0,
  1106. 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x49, 0x75, 0x37, 0x03, 0x12, 0x0e, 0x9a, 0x30, 0x08, //0x8cc0,
  1107. 0x09, 0xc2, 0x34, 0x12, 0x08, 0xcb, 0xc2, 0x08, 0xd2, 0x34, 0x30, 0x0b, 0x09, 0xc2, 0x36, 0x12, //0x8cd0,
  1108. 0x02, 0x6c, 0xc2, 0x0b, 0xd2, 0x36, 0x30, 0x09, 0x09, 0xc2, 0x36, 0x12, 0x00, 0x0e, 0xc2, 0x09, //0x8ce0,
  1109. 0xd2, 0x36, 0x30, 0x0e, 0x03, 0x12, 0x06, 0xd7, 0x30, 0x35, 0xd3, 0x90, 0x30, 0x29, 0xe5, 0x1e, //0x8cf0,
  1110. 0xf0, 0xb4, 0x10, 0x05, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0xc2, 0x35, 0x80, 0xc1, 0xe4, 0xf5, 0x4b, //0x8d00,
  1111. 0x90, 0x0e, 0x7a, 0x93, 0xff, 0xe4, 0x8f, 0x37, 0xf5, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0xaf, 0x37, //0x8d10,
  1112. 0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0x90, 0x0e, 0x6a, 0x12, 0x0d, 0xf6, 0x8f, 0x37, 0x8e, 0x36, //0x8d20,
  1113. 0x8d, 0x35, 0x8c, 0x34, 0x90, 0x0e, 0x72, 0x12, 0x06, 0x7c, 0xef, 0x45, 0x37, 0xf5, 0x37, 0xee, //0x8d30,
  1114. 0x45, 0x36, 0xf5, 0x36, 0xed, 0x45, 0x35, 0xf5, 0x35, 0xec, 0x45, 0x34, 0xf5, 0x34, 0xe4, 0xf5, //0x8d40,
  1115. 0x22, 0xf5, 0x23, 0x85, 0x37, 0x31, 0x85, 0x36, 0x30, 0x85, 0x35, 0x2f, 0x85, 0x34, 0x2e, 0x12, //0x8d50,
  1116. 0x0f, 0x46, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x72, 0x12, 0x0d, 0xea, 0x12, 0x0f, 0x46, //0x8d60,
  1117. 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x6e, 0x12, 0x0d, 0xea, 0x02, 0x0f, 0x46, 0xe5, 0x40, //0x8d70,
  1118. 0x24, 0xf2, 0xf5, 0x37, 0xe5, 0x3f, 0x34, 0x43, 0xf5, 0x36, 0xe5, 0x3e, 0x34, 0xa2, 0xf5, 0x35, //0x8d80,
  1119. 0xe5, 0x3d, 0x34, 0x28, 0xf5, 0x34, 0xe5, 0x37, 0xff, 0xe4, 0xfe, 0xfd, 0xfc, 0x78, 0x18, 0x12, //0x8d90,
  1120. 0x06, 0x69, 0x8f, 0x40, 0x8e, 0x3f, 0x8d, 0x3e, 0x8c, 0x3d, 0xe5, 0x37, 0x54, 0xa0, 0xff, 0xe5, //0x8da0,
  1121. 0x36, 0xfe, 0xe4, 0xfd, 0xfc, 0x78, 0x07, 0x12, 0x06, 0x56, 0x78, 0x10, 0x12, 0x0f, 0x9a, 0xe4, //0x8db0,
  1122. 0xff, 0xfe, 0xe5, 0x35, 0xfd, 0xe4, 0xfc, 0x78, 0x0e, 0x12, 0x06, 0x56, 0x12, 0x0f, 0x9d, 0xe4, //0x8dc0,
  1123. 0xff, 0xfe, 0xfd, 0xe5, 0x34, 0xfc, 0x78, 0x18, 0x12, 0x06, 0x56, 0x78, 0x08, 0x12, 0x0f, 0x9a, //0x8dd0,
  1124. 0x22, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0x22, 0x12, 0x06, 0x7c, 0x8f, 0x31, 0x8e, //0x8de0,
  1125. 0x30, 0x8d, 0x2f, 0x8c, 0x2e, 0x22, 0x93, 0xf9, 0xf8, 0x02, 0x06, 0x69, 0x00, 0x00, 0x00, 0x00, //0x8df0,
  1126. 0x12, 0x01, 0x17, 0x08, 0x31, 0x15, 0x53, 0x54, 0x44, 0x20, 0x20, 0x20, 0x20, 0x20, 0x13, 0x01, //0x8e00,
  1127. 0x10, 0x01, 0x56, 0x40, 0x1a, 0x30, 0x29, 0x7e, 0x00, 0x30, 0x04, 0x20, 0xdf, 0x30, 0x05, 0x40, //0x8e10,
  1128. 0xbf, 0x50, 0x03, 0x00, 0xfd, 0x50, 0x27, 0x01, 0xfe, 0x60, 0x00, 0x11, 0x00, 0x3f, 0x05, 0x30, //0x8e20,
  1129. 0x00, 0x3f, 0x06, 0x22, 0x00, 0x3f, 0x01, 0x2a, 0x00, 0x3f, 0x02, 0x00, 0x00, 0x36, 0x06, 0x07, //0x8e30,
  1130. 0x00, 0x3f, 0x0b, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x40, 0xbf, 0x30, 0x01, 0x00, //0x8e40,
  1131. 0xbf, 0x30, 0x29, 0x70, 0x00, 0x3a, 0x00, 0x00, 0xff, 0x3a, 0x00, 0x00, 0xff, 0x36, 0x03, 0x36, //0x8e50,
  1132. 0x02, 0x41, 0x44, 0x58, 0x20, 0x18, 0x10, 0x0a, 0x04, 0x04, 0x00, 0x03, 0xff, 0x64, 0x00, 0x00, //0x8e60,
  1133. 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x06, 0x00, 0x03, 0x51, 0x00, 0x7a, //0x8e70,
  1134. 0x50, 0x3c, 0x28, 0x1e, 0x10, 0x10, 0x50, 0x2d, 0x28, 0x16, 0x10, 0x10, 0x02, 0x00, 0x10, 0x0c, //0x8e80,
  1135. 0x10, 0x04, 0x0c, 0x6e, 0x06, 0x05, 0x00, 0xa5, 0x5a, 0x00, 0xae, 0x35, 0xaf, 0x36, 0xe4, 0xfd, //0x8e90,
  1136. 0xed, 0xc3, 0x95, 0x37, 0x50, 0x33, 0x12, 0x0f, 0xe2, 0xe4, 0x93, 0xf5, 0x38, 0x74, 0x01, 0x93, //0x8ea0,
  1137. 0xf5, 0x39, 0x45, 0x38, 0x60, 0x23, 0x85, 0x39, 0x82, 0x85, 0x38, 0x83, 0xe0, 0xfc, 0x12, 0x0f, //0x8eb0,
  1138. 0xe2, 0x74, 0x03, 0x93, 0x52, 0x04, 0x12, 0x0f, 0xe2, 0x74, 0x02, 0x93, 0x42, 0x04, 0x85, 0x39, //0x8ec0,
  1139. 0x82, 0x85, 0x38, 0x83, 0xec, 0xf0, 0x0d, 0x80, 0xc7, 0x22, 0x78, 0xbe, 0xe6, 0xd3, 0x08, 0xff, //0x8ed0,
  1140. 0xe6, 0x64, 0x80, 0xf8, 0xef, 0x64, 0x80, 0x98, 0x22, 0x93, 0xff, 0x7e, 0x00, 0xe6, 0xfc, 0x08, //0x8ee0,
  1141. 0xe6, 0xfd, 0x12, 0x04, 0xc1, 0x78, 0xc1, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0xd3, 0xef, 0x9d, 0xee, //0x8ef0,
  1142. 0x9c, 0x22, 0x78, 0xbd, 0xd3, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x22, 0x25, 0xe0, 0x24, 0x0a, 0xf8, //0x8f00,
  1143. 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe5, 0x3c, 0xd3, 0x94, 0x00, 0x40, 0x0b, 0x90, 0x0e, 0x88, //0x8f10,
  1144. 0x12, 0x0b, 0xf1, 0x90, 0x0e, 0x86, 0x80, 0x09, 0x90, 0x0e, 0x82, 0x12, 0x0b, 0xf1, 0x90, 0x0e, //0x8f20,
  1145. 0x80, 0xe4, 0x93, 0xf5, 0x44, 0xa3, 0xe4, 0x93, 0xf5, 0x43, 0xd2, 0x06, 0x30, 0x06, 0x03, 0xd3, //0x8f30,
  1146. 0x80, 0x01, 0xc3, 0x92, 0x0e, 0x22, 0xa2, 0xaf, 0x92, 0x32, 0xc2, 0xaf, 0xe5, 0x23, 0x45, 0x22, //0x8f40,
  1147. 0x90, 0x0e, 0x5d, 0x60, 0x0e, 0x12, 0x0f, 0xcb, 0xe0, 0xf5, 0x2c, 0x12, 0x0f, 0xc8, 0xe0, 0xf5, //0x8f50,
  1148. 0x2d, 0x80, 0x0c, 0x12, 0x0f, 0xcb, 0xe5, 0x30, 0xf0, 0x12, 0x0f, 0xc8, 0xe5, 0x31, 0xf0, 0xa2, //0x8f60,
  1149. 0x32, 0x92, 0xaf, 0x22, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, //0x8f70,
  1150. 0x33, 0xd2, 0x36, 0xd2, 0x01, 0xc2, 0x02, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0x22, //0x8f80,
  1151. 0xfb, 0xd3, 0xed, 0x9b, 0x74, 0x80, 0xf8, 0x6c, 0x98, 0x22, 0x12, 0x06, 0x69, 0xe5, 0x40, 0x2f, //0x8f90,
  1152. 0xf5, 0x40, 0xe5, 0x3f, 0x3e, 0xf5, 0x3f, 0xe5, 0x3e, 0x3d, 0xf5, 0x3e, 0xe5, 0x3d, 0x3c, 0xf5, //0x8fa0,
  1153. 0x3d, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0x90, 0x3f, 0x0d, 0xe0, 0xf5, 0x33, 0xe5, 0x33, //0x8fb0,
  1154. 0xf0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, 0x0e, 0x5f, 0xe4, 0x93, 0xfe, 0x74, 0x01, //0x8fc0,
  1155. 0x93, 0xf5, 0x82, 0x8e, 0x83, 0x22, 0x78, 0x7f, 0xe4, 0xf6, 0xd8, 0xfd, 0x75, 0x81, 0xcd, 0x02, //0x8fd0,
  1156. 0x0c, 0x98, 0x8f, 0x82, 0x8e, 0x83, 0x75, 0xf0, 0x04, 0xed, 0x02, 0x06, 0xa5, //0x8fe0
  1157. };
  1158. #define SENSORDB(fmt, arg...) printk(fmt, ##arg)
  1159. static struct timeval OV5640YUV_ktv1, OV5640YUV_ktv2;
  1160. struct i2c_client * g_client=NULL;
  1161. #define UINT32 unsigned int
  1162. #define UINT8 u8
  1163. typedef enum
  1164. {
  1165. OV5640_720P, //1M 1280x960
  1166. OV5640_5M, //5M 2592x1944
  1167. } OV5640_RES_TYPE;
  1168. OV5640_RES_TYPE OV5640YUV_g_RES=OV5640_720P;
  1169. typedef enum
  1170. {
  1171. OV5640_MODE_PREVIEW, //1M 1280x960
  1172. OV5640_MODE_CAPTURE //5M 2592x1944
  1173. } OV5640_MODE;
  1174. OV5640_MODE g_iOV5640YUV_Mode=OV5640_MODE_PREVIEW;
  1175. #define KAL_FALSE false
  1176. #define KAL_TRUE true
  1177. #define kal_uint32 unsigned int
  1178. #define kal_uint16 u16
  1179. #define kal_uint8 unsigned char
  1180. #define UINT16 u16
  1181. #define UINT8 unsigned char
  1182. #define kal_bool bool
  1183. #define Sleep msleep
  1184. UINT8 OV5640YUVPixelClockDivider=0;
  1185. kal_uint32 OV5640YUV_sensor_pclk=56000000;
  1186. kal_uint32 OV5640YUV_PV_pclk = 5600;
  1187. kal_uint32 OV5640YUV_CAP_pclk = 5600;
  1188. kal_uint16 OV5640YUV_pv_exposure_lines=0x100,OV5640YUV_g_iBackupExtraExp = 0,OV5640YUV_extra_exposure_lines = 0;
  1189. kal_uint16 OV5640YUV_sensor_id=0;
  1190. //MSDK_SENSOR_CONFIG_STRUCT OV5640YUVSensorConfigData;
  1191. kal_uint32 OV5640YUV_FAC_SENSOR_REG;
  1192. kal_uint16 OV5640YUV_sensor_flip_value;
  1193. //liuxinming add
  1194. kal_uint32 back_shutter = 0;
  1195. kal_uint32 back_pv_gain = 0;
  1196. kal_uint32 tem = 0;
  1197. bool OV5640YUV_MPEG4_encode_mode = KAL_FALSE;
  1198. bool OV5640YUV_night_mode = KAL_FALSE;
  1199. #define ERROR_NONE 1
  1200. inline void OV5640YUV_imgSensorProfileStart(void)
  1201. {
  1202. do_gettimeofday(&OV5640YUV_ktv1);
  1203. }
  1204. inline void OV5640YUV_imgSensorProfileEnd(char *tag)
  1205. {
  1206. unsigned long TimeIntervalUS;
  1207. do_gettimeofday(&OV5640YUV_ktv2);
  1208. TimeIntervalUS = (OV5640YUV_ktv2.tv_sec - OV5640YUV_ktv1.tv_sec) * 1000000 + (OV5640YUV_ktv2.tv_usec - OV5640YUV_ktv1.tv_usec);
  1209. SENSORDB("[%s]Profile = %lu\n",tag, TimeIntervalUS);
  1210. }
  1211. u8 OV5640YUV_read_cmos_sensor(u16 addr)
  1212. {
  1213. unsigned char value=0;
  1214. i2cc_get_reg(g_client,addr,&value);
  1215. return value;
  1216. }
  1217. void OV5640YUV_write_cmos_sensor(u16 addr,u32 param)
  1218. {
  1219. i2cc_set_reg(g_client,addr,param);
  1220. }
  1221. static void OV5640_FOCUS_AD5820_Check_MCU()
  1222. {
  1223. u8 check[13] = {0x00};
  1224. //mcu on
  1225. check[0] = OV5640YUV_read_cmos_sensor(0x3000);
  1226. check[1] = OV5640YUV_read_cmos_sensor(0x3004);
  1227. //soft reset of mcu
  1228. check[2] = OV5640YUV_read_cmos_sensor(0x3f00);
  1229. //afc on
  1230. check[3] = OV5640YUV_read_cmos_sensor(0x3001);
  1231. check[4] = OV5640YUV_read_cmos_sensor(0x3005);
  1232. //gpio1,gpio2
  1233. check[5] = OV5640YUV_read_cmos_sensor(0x3018);
  1234. check[6] = OV5640YUV_read_cmos_sensor(0x301e);
  1235. check[7] = OV5640YUV_read_cmos_sensor(0x301b);
  1236. check[8] = OV5640YUV_read_cmos_sensor(0x3042);
  1237. //y0
  1238. check[9] = OV5640YUV_read_cmos_sensor(0x3018);
  1239. check[10] = OV5640YUV_read_cmos_sensor(0x301e);
  1240. check[11] = OV5640YUV_read_cmos_sensor(0x301b);
  1241. check[12] = OV5640YUV_read_cmos_sensor(0x3042);
  1242. int i = 0;
  1243. for(i = 0; i < 13; i++)
  1244. SENSORDB("check[%d]=0x%x\n", i, check[i]);
  1245. }
  1246. static void OV5640_FOCUS_AD5820_Init(void)
  1247. {
  1248. u8 state=0x8F;
  1249. unsigned int iteration = 100;
  1250. int totalCnt = 0;
  1251. int sentCnt = 0;
  1252. int index=0;
  1253. u16 addr = 0x8000;
  1254. u8 buf[256];
  1255. int len = 128;
  1256. // OV5640YUV_imgSensorProfileStart();
  1257. OV5640YUV_write_cmos_sensor(0x3000, 0x20);
  1258. totalCnt = ARRAY_SIZE(AD5820_Config);
  1259. #if 0//Brust mode
  1260. while (index < totalCnt) {
  1261. sentCnt = totalCnt - index > len ? len : totalCnt - index;
  1262. buf[0] = addr >> 8;
  1263. buf[1] = addr & 0xff;
  1264. memcpy(&buf[2], &AD5820_Config[index], len );
  1265. OV5640YUV_multi_write_cmos_sensor(buf, sentCnt + 2);
  1266. addr += len ;
  1267. index += len ;
  1268. }
  1269. #else//single mode
  1270. for(sentCnt =0; sentCnt<totalCnt; sentCnt++)
  1271. {
  1272. OV5640YUV_write_cmos_sensor(addr,AD5820_Config[sentCnt]);
  1273. addr++;
  1274. }
  1275. #endif
  1276. mdelay(10);
  1277. OV5640YUV_write_cmos_sensor(0x3022, 0x00);
  1278. OV5640YUV_write_cmos_sensor(0x3023, 0x00);
  1279. OV5640YUV_write_cmos_sensor(0x3024, 0x00);
  1280. OV5640YUV_write_cmos_sensor(0x3025, 0x00);
  1281. OV5640YUV_write_cmos_sensor(0x3026, 0x00);
  1282. OV5640YUV_write_cmos_sensor(0x3027, 0x00);
  1283. OV5640YUV_write_cmos_sensor(0x3028, 0x00);
  1284. OV5640YUV_write_cmos_sensor(0x3029, 0x7f);
  1285. OV5640YUV_write_cmos_sensor(0x3000, 0x00);
  1286. do {
  1287. state = (u8)OV5640YUV_read_cmos_sensor(0x3029);
  1288. mdelay(5);
  1289. if (iteration-- == 0)
  1290. {
  1291. break;
  1292. }
  1293. } while(state!=0x70);
  1294. OV5640YUV_imgSensorProfileEnd("OV5640_FOCUS_AD5820_Init");
  1295. OV5640_FOCUS_AD5820_Check_MCU();
  1296. return;
  1297. } /* OV5640_FOCUS_AD5820_Init */
  1298. void OV5640YUV_Sensor_Dvp_Init(void)
  1299. {
  1300. OV5640YUV_write_cmos_sensor(0x4740, 0x20);//liuxinming
  1301. OV5640YUV_write_cmos_sensor(0x3008, 0x42);
  1302. OV5640YUV_write_cmos_sensor(0x3103, 0x03);
  1303. OV5640YUV_write_cmos_sensor(0x3017, 0x7f);
  1304. OV5640YUV_write_cmos_sensor(0x3018, 0xff);
  1305. OV5640YUV_write_cmos_sensor(0x302c, 0x82);
  1306. OV5640YUV_write_cmos_sensor(0x3108, 0x01);
  1307. OV5640YUV_write_cmos_sensor(0x3630, 0x2e);//2e
  1308. OV5640YUV_write_cmos_sensor(0x3632, 0xe2);
  1309. OV5640YUV_write_cmos_sensor(0x3633, 0x23);//23
  1310. OV5640YUV_write_cmos_sensor(0x3621, 0xe0);
  1311. OV5640YUV_write_cmos_sensor(0x3704, 0xa0);
  1312. OV5640YUV_write_cmos_sensor(0x3703, 0x5a);
  1313. OV5640YUV_write_cmos_sensor(0x3715, 0x78);
  1314. OV5640YUV_write_cmos_sensor(0x3717, 0x01);
  1315. OV5640YUV_write_cmos_sensor(0x370b, 0x60);
  1316. OV5640YUV_write_cmos_sensor(0x3705, 0x1a);
  1317. OV5640YUV_write_cmos_sensor(0x3905, 0x02);
  1318. OV5640YUV_write_cmos_sensor(0x3906, 0x10);
  1319. OV5640YUV_write_cmos_sensor(0x3901, 0x0a);
  1320. OV5640YUV_write_cmos_sensor(0x3731, 0x12);
  1321. OV5640YUV_write_cmos_sensor(0x3600, 0x08);
  1322. OV5640YUV_write_cmos_sensor(0x3601, 0x33);
  1323. OV5640YUV_write_cmos_sensor(0x302d, 0x60);
  1324. OV5640YUV_write_cmos_sensor(0x3620, 0x52);
  1325. OV5640YUV_write_cmos_sensor(0x371b, 0x20);
  1326. OV5640YUV_write_cmos_sensor(0x471c, 0x50);
  1327. OV5640YUV_write_cmos_sensor(0x3a18, 0x00);
  1328. OV5640YUV_write_cmos_sensor(0x3a19, 0xf8);
  1329. OV5640YUV_write_cmos_sensor(0x3635, 0x1c);//1c
  1330. OV5640YUV_write_cmos_sensor(0x3634, 0x40);
  1331. OV5640YUV_write_cmos_sensor(0x3622, 0x01);
  1332. OV5640YUV_write_cmos_sensor(0x3c04, 0x28);
  1333. OV5640YUV_write_cmos_sensor(0x3c05, 0x98);
  1334. OV5640YUV_write_cmos_sensor(0x3c06, 0x00);
  1335. OV5640YUV_write_cmos_sensor(0x3c07, 0x08);
  1336. OV5640YUV_write_cmos_sensor(0x3c08, 0x00);
  1337. OV5640YUV_write_cmos_sensor(0x3c09, 0x1c);
  1338. OV5640YUV_write_cmos_sensor(0x3c0a, 0x9c);
  1339. OV5640YUV_write_cmos_sensor(0x3c0b, 0x40);
  1340. // OV5640YUV_write_cmos_sensor(0x3820, 0x47);
  1341. // OV5640YUV_write_cmos_sensor(0x3821, 0x01);
  1342. //dg add 2015-07-24 for stop flip & mirror image
  1343. OV5640YUV_write_cmos_sensor(0x3820, 0x40);
  1344. OV5640YUV_write_cmos_sensor(0x3821, 0x06);
  1345. //windows setup
  1346. OV5640YUV_write_cmos_sensor(0x3800, 0x00);
  1347. OV5640YUV_write_cmos_sensor(0x3801, 0x00);
  1348. OV5640YUV_write_cmos_sensor(0x3802, 0x00);
  1349. OV5640YUV_write_cmos_sensor(0x3803, 0x04);
  1350. //dg add 2015-07-25 to adjust X_AADR_END long for image windeos show
  1351. OV5640YUV_write_cmos_sensor(0x3804, 0x0a);
  1352. OV5640YUV_write_cmos_sensor(0x3805, 0x5f); //3f-5f->Good
  1353. OV5640YUV_write_cmos_sensor(0x3806, 0x07);
  1354. OV5640YUV_write_cmos_sensor(0x3807, 0x9b);
  1355. #if 1
  1356. OV5640YUV_write_cmos_sensor(0x3808, 0x05);//1280
  1357. OV5640YUV_write_cmos_sensor(0x3809, 0x00);
  1358. OV5640YUV_write_cmos_sensor(0x380a, 0x03);//960
  1359. OV5640YUV_write_cmos_sensor(0x380b, 0xc0);
  1360. #else
  1361. OV5640YUV_write_cmos_sensor(0x3808, 0x05);
  1362. OV5640YUV_write_cmos_sensor(0x3809, 0x80);
  1363. OV5640YUV_write_cmos_sensor(0x380a, 0x01);
  1364. OV5640YUV_write_cmos_sensor(0x380b, 0xe0);
  1365. #endif
  1366. //OV5640YUV_write_cmos_sensor(0x3810, 0x00);
  1367. // OV5640YUV_write_cmos_sensor(0x3811, 0x10);
  1368. //dg add 2015-07-25 to adjust X OFFSET position coordinate for image windeos show
  1369. OV5640YUV_write_cmos_sensor(0x3810, 0x00); // 00->01->00
  1370. OV5640YUV_write_cmos_sensor(0x3811, 0xED); // 10->00->F0->EF->EE->ED->Good
  1371. OV5640YUV_write_cmos_sensor(0x3812, 0x00);
  1372. OV5640YUV_write_cmos_sensor(0x3813, 0x06);
  1373. OV5640YUV_write_cmos_sensor(0x3814, 0x31);
  1374. OV5640YUV_write_cmos_sensor(0x3815, 0x31);
  1375. OV5640YUV_write_cmos_sensor(0x3034, 0x1a);
  1376. OV5640YUV_write_cmos_sensor(0x3035, 0x21); //15fps
  1377. OV5640YUV_write_cmos_sensor(0x3036, 0x46);
  1378. OV5640YUV_write_cmos_sensor(0x3037, 0x13);
  1379. OV5640YUV_write_cmos_sensor(0x3038, 0x00);
  1380. OV5640YUV_write_cmos_sensor(0x3039, 0x00);
  1381. OV5640YUV_write_cmos_sensor(0x380c, 0x07);
  1382. OV5640YUV_write_cmos_sensor(0x380d, 0x68);
  1383. OV5640YUV_write_cmos_sensor(0x380e, 0x03); //03
  1384. OV5640YUV_write_cmos_sensor(0x380f, 0xd8); //d8
  1385. OV5640YUV_write_cmos_sensor(0x3c01, 0xb4);
  1386. OV5640YUV_write_cmos_sensor(0x3c00, 0x04);
  1387. OV5640YUV_write_cmos_sensor(0x3a08, 0x00);
  1388. OV5640YUV_write_cmos_sensor(0x3a09, 0x93);
  1389. OV5640YUV_write_cmos_sensor(0x3a0e, 0x06);
  1390. OV5640YUV_write_cmos_sensor(0x3a0a, 0x00);
  1391. OV5640YUV_write_cmos_sensor(0x3a0b, 0x7b);
  1392. OV5640YUV_write_cmos_sensor(0x3a0d, 0x08);
  1393. OV5640YUV_write_cmos_sensor(0x3a00, 0x38); //25fps-20fps
  1394. OV5640YUV_write_cmos_sensor(0x3a02, 0x03);
  1395. OV5640YUV_write_cmos_sensor(0x3a03, 0xd8);
  1396. OV5640YUV_write_cmos_sensor(0x3a14, 0x03);
  1397. OV5640YUV_write_cmos_sensor(0x3a15, 0xd8);
  1398. OV5640YUV_write_cmos_sensor(0x3618, 0x00);
  1399. OV5640YUV_write_cmos_sensor(0x3612, 0x29);
  1400. OV5640YUV_write_cmos_sensor(0x3708, 0x64);
  1401. OV5640YUV_write_cmos_sensor(0x3709, 0x52);
  1402. OV5640YUV_write_cmos_sensor(0x370c, 0x03);
  1403. OV5640YUV_write_cmos_sensor(0x4001, 0x02);
  1404. OV5640YUV_write_cmos_sensor(0x4004, 0x02);
  1405. OV5640YUV_write_cmos_sensor(0x3000, 0x00);
  1406. OV5640YUV_write_cmos_sensor(0x3002, 0x1c);
  1407. OV5640YUV_write_cmos_sensor(0x3004, 0xff);
  1408. OV5640YUV_write_cmos_sensor(0x3006, 0xc3);
  1409. OV5640YUV_write_cmos_sensor(0x300e, 0x58);
  1410. OV5640YUV_write_cmos_sensor(0x302e, 0x00);
  1411. //OV5640YUV_write_cmos_sensor(0x4300, 0x30);
  1412. OV5640YUV_write_cmos_sensor(0x4300, 0x32); //dg changge from 0x30->0x33
  1413. OV5640YUV_write_cmos_sensor(0x501f, 0x00);
  1414. OV5640YUV_write_cmos_sensor(0x4713, 0x03);
  1415. OV5640YUV_write_cmos_sensor(0x4407, 0x04);
  1416. OV5640YUV_write_cmos_sensor(0x460b, 0x35);
  1417. OV5640YUV_write_cmos_sensor(0x460c, 0x22);//add by bright
  1418. OV5640YUV_write_cmos_sensor(0x3824, 0x01);//add by bright
  1419. OV5640YUV_write_cmos_sensor(0x5001, 0xa3);
  1420. OV5640YUV_write_cmos_sensor(0x3406, 0x01);//awbinit
  1421. OV5640YUV_write_cmos_sensor(0x3400, 0x06);
  1422. OV5640YUV_write_cmos_sensor(0x3401, 0x80);
  1423. OV5640YUV_write_cmos_sensor(0x3402, 0x04);
  1424. OV5640YUV_write_cmos_sensor(0x3403, 0x00);
  1425. OV5640YUV_write_cmos_sensor(0x3404, 0x06);
  1426. OV5640YUV_write_cmos_sensor(0x3405, 0x00);
  1427. //awb
  1428. OV5640YUV_write_cmos_sensor(0x5180, 0xff);
  1429. OV5640YUV_write_cmos_sensor(0x5181, 0xf2);
  1430. OV5640YUV_write_cmos_sensor(0x5182, 0x00);
  1431. OV5640YUV_write_cmos_sensor(0x5183, 0x14);
  1432. OV5640YUV_write_cmos_sensor(0x5184, 0x25);
  1433. OV5640YUV_write_cmos_sensor(0x5185, 0x24);
  1434. OV5640YUV_write_cmos_sensor(0x5186, 0x16);
  1435. OV5640YUV_write_cmos_sensor(0x5187, 0x16);
  1436. OV5640YUV_write_cmos_sensor(0x5188, 0x16);
  1437. OV5640YUV_write_cmos_sensor(0x5189, 0x72);
  1438. OV5640YUV_write_cmos_sensor(0x518a, 0x68);
  1439. OV5640YUV_write_cmos_sensor(0x518b, 0xf0);
  1440. OV5640YUV_write_cmos_sensor(0x518c, 0xb2);
  1441. OV5640YUV_write_cmos_sensor(0x518d, 0x50);
  1442. OV5640YUV_write_cmos_sensor(0x518e, 0x30);
  1443. OV5640YUV_write_cmos_sensor(0x518f, 0x30);
  1444. OV5640YUV_write_cmos_sensor(0x5190, 0x50);
  1445. OV5640YUV_write_cmos_sensor(0x5191, 0xf8);
  1446. OV5640YUV_write_cmos_sensor(0x5192, 0x04);
  1447. OV5640YUV_write_cmos_sensor(0x5193, 0x70);
  1448. OV5640YUV_write_cmos_sensor(0x5194, 0xf0);
  1449. OV5640YUV_write_cmos_sensor(0x5195, 0xf0);
  1450. OV5640YUV_write_cmos_sensor(0x5196, 0x03);
  1451. OV5640YUV_write_cmos_sensor(0x5197, 0x01);
  1452. OV5640YUV_write_cmos_sensor(0x5198, 0x04);
  1453. OV5640YUV_write_cmos_sensor(0x5199, 0x12);
  1454. OV5640YUV_write_cmos_sensor(0x519a, 0x04);
  1455. OV5640YUV_write_cmos_sensor(0x519b, 0x00);
  1456. OV5640YUV_write_cmos_sensor(0x519c, 0x06);
  1457. OV5640YUV_write_cmos_sensor(0x519d, 0x82);
  1458. OV5640YUV_write_cmos_sensor(0x519e, 0x38);
  1459. //color matrix
  1460. OV5640YUV_write_cmos_sensor(0x5381, 0x1e);
  1461. OV5640YUV_write_cmos_sensor(0x5382, 0x5b);
  1462. OV5640YUV_write_cmos_sensor(0x5383, 0x14);
  1463. OV5640YUV_write_cmos_sensor(0x5384, 0x06);
  1464. OV5640YUV_write_cmos_sensor(0x5385, 0x82);
  1465. OV5640YUV_write_cmos_sensor(0x5386, 0x88);
  1466. OV5640YUV_write_cmos_sensor(0x5387, 0x7c);
  1467. OV5640YUV_write_cmos_sensor(0x5388, 0x60);
  1468. OV5640YUV_write_cmos_sensor(0x5389, 0x1c);
  1469. OV5640YUV_write_cmos_sensor(0x538a, 0x01);
  1470. OV5640YUV_write_cmos_sensor(0x538b, 0x98);
  1471. //sharp&noise
  1472. OV5640YUV_write_cmos_sensor(0x5300, 0x08);
  1473. OV5640YUV_write_cmos_sensor(0x5301, 0x30);
  1474. OV5640YUV_write_cmos_sensor(0x5302, 0x3f);
  1475. OV5640YUV_write_cmos_sensor(0x5303, 0x10);
  1476. OV5640YUV_write_cmos_sensor(0x5304, 0x08);
  1477. OV5640YUV_write_cmos_sensor(0x5305, 0x30);
  1478. OV5640YUV_write_cmos_sensor(0x5306, 0x18);
  1479. OV5640YUV_write_cmos_sensor(0x5307, 0x28);
  1480. OV5640YUV_write_cmos_sensor(0x5309, 0x08);
  1481. OV5640YUV_write_cmos_sensor(0x530a, 0x30);
  1482. OV5640YUV_write_cmos_sensor(0x530b, 0x04);
  1483. OV5640YUV_write_cmos_sensor(0x530c, 0x06);
  1484. //gamma
  1485. OV5640YUV_write_cmos_sensor(0x5480, 0x01);
  1486. OV5640YUV_write_cmos_sensor(0x5481, 0x06);
  1487. OV5640YUV_write_cmos_sensor(0x5482, 0x12);
  1488. OV5640YUV_write_cmos_sensor(0x5483, 0x1e);
  1489. OV5640YUV_write_cmos_sensor(0x5484, 0x4a);
  1490. OV5640YUV_write_cmos_sensor(0x5485, 0x58);
  1491. OV5640YUV_write_cmos_sensor(0x5486, 0x65);
  1492. OV5640YUV_write_cmos_sensor(0x5487, 0x72);
  1493. OV5640YUV_write_cmos_sensor(0x5488, 0x7d);
  1494. OV5640YUV_write_cmos_sensor(0x5489, 0x88);
  1495. OV5640YUV_write_cmos_sensor(0x548a, 0x92);
  1496. OV5640YUV_write_cmos_sensor(0x548b, 0xa3);
  1497. OV5640YUV_write_cmos_sensor(0x548c, 0xb2);
  1498. OV5640YUV_write_cmos_sensor(0x548d, 0xc8);
  1499. OV5640YUV_write_cmos_sensor(0x548e, 0xdd);
  1500. OV5640YUV_write_cmos_sensor(0x548f, 0xf0);
  1501. OV5640YUV_write_cmos_sensor(0x5490, 0x15);
  1502. //UV adjust
  1503. OV5640YUV_write_cmos_sensor(0x5580, 0x06);
  1504. OV5640YUV_write_cmos_sensor(0x5583, 0x40);
  1505. OV5640YUV_write_cmos_sensor(0x5584, 0x10);
  1506. OV5640YUV_write_cmos_sensor(0x5589, 0x10);
  1507. OV5640YUV_write_cmos_sensor(0x558a, 0x00);
  1508. OV5640YUV_write_cmos_sensor(0x558b, 0xf8);
  1509. //lens shading
  1510. OV5640YUV_write_cmos_sensor(0x5000, 0xa7);
  1511. OV5640YUV_write_cmos_sensor(0x5800, 0x20);
  1512. OV5640YUV_write_cmos_sensor(0x5801, 0x19);
  1513. OV5640YUV_write_cmos_sensor(0x5802, 0x17);
  1514. OV5640YUV_write_cmos_sensor(0x5803, 0x16);
  1515. OV5640YUV_write_cmos_sensor(0x5804, 0x18);
  1516. OV5640YUV_write_cmos_sensor(0x5805, 0x21);
  1517. OV5640YUV_write_cmos_sensor(0x5806, 0x0F);
  1518. OV5640YUV_write_cmos_sensor(0x5807, 0x0A);
  1519. OV5640YUV_write_cmos_sensor(0x5808, 0x07);
  1520. OV5640YUV_write_cmos_sensor(0x5809, 0x07);
  1521. OV5640YUV_write_cmos_sensor(0x580a, 0x0A);
  1522. OV5640YUV_write_cmos_sensor(0x580b, 0x0C);
  1523. OV5640YUV_write_cmos_sensor(0x580c, 0x0A);
  1524. OV5640YUV_write_cmos_sensor(0x580d, 0x03);
  1525. OV5640YUV_write_cmos_sensor(0x580e, 0x01);
  1526. OV5640YUV_write_cmos_sensor(0x580f, 0x01);
  1527. OV5640YUV_write_cmos_sensor(0x5810, 0x03);
  1528. OV5640YUV_write_cmos_sensor(0x5811, 0x09);
  1529. OV5640YUV_write_cmos_sensor(0x5812, 0x0A);
  1530. OV5640YUV_write_cmos_sensor(0x5813, 0x03);
  1531. OV5640YUV_write_cmos_sensor(0x5814, 0x01);
  1532. OV5640YUV_write_cmos_sensor(0x5815, 0x01);
  1533. OV5640YUV_write_cmos_sensor(0x5816, 0x03);
  1534. OV5640YUV_write_cmos_sensor(0x5817, 0x08);
  1535. OV5640YUV_write_cmos_sensor(0x5818, 0x10);
  1536. OV5640YUV_write_cmos_sensor(0x5819, 0x0A);
  1537. OV5640YUV_write_cmos_sensor(0x581a, 0x06);
  1538. OV5640YUV_write_cmos_sensor(0x581b, 0x06);
  1539. OV5640YUV_write_cmos_sensor(0x581c, 0x08);
  1540. OV5640YUV_write_cmos_sensor(0x581d, 0x0E);
  1541. OV5640YUV_write_cmos_sensor(0x581e, 0x22);
  1542. OV5640YUV_write_cmos_sensor(0x581f, 0x18);
  1543. OV5640YUV_write_cmos_sensor(0x5820, 0x13);
  1544. OV5640YUV_write_cmos_sensor(0x5821, 0x12);
  1545. OV5640YUV_write_cmos_sensor(0x5822, 0x16);
  1546. OV5640YUV_write_cmos_sensor(0x5823, 0x1E);
  1547. OV5640YUV_write_cmos_sensor(0x5824, 0x64);
  1548. OV5640YUV_write_cmos_sensor(0x5825, 0x2A);
  1549. OV5640YUV_write_cmos_sensor(0x5826, 0x2C);
  1550. OV5640YUV_write_cmos_sensor(0x5827, 0x2A);
  1551. OV5640YUV_write_cmos_sensor(0x5828, 0x46);
  1552. OV5640YUV_write_cmos_sensor(0x5829, 0x2A);
  1553. OV5640YUV_write_cmos_sensor(0x582a, 0x26);
  1554. OV5640YUV_write_cmos_sensor(0x582b, 0x24);
  1555. OV5640YUV_write_cmos_sensor(0x582c, 0x26);
  1556. OV5640YUV_write_cmos_sensor(0x582d, 0x2A);
  1557. OV5640YUV_write_cmos_sensor(0x582e, 0x28);
  1558. OV5640YUV_write_cmos_sensor(0x582f, 0x42);
  1559. OV5640YUV_write_cmos_sensor(0x5830, 0x40);
  1560. OV5640YUV_write_cmos_sensor(0x5831, 0x42);
  1561. OV5640YUV_write_cmos_sensor(0x5832, 0x08);
  1562. OV5640YUV_write_cmos_sensor(0x5833, 0x28);
  1563. OV5640YUV_write_cmos_sensor(0x5834, 0x26);
  1564. OV5640YUV_write_cmos_sensor(0x5835, 0x24);
  1565. OV5640YUV_write_cmos_sensor(0x5836, 0x26);
  1566. OV5640YUV_write_cmos_sensor(0x5837, 0x2A);
  1567. OV5640YUV_write_cmos_sensor(0x5838, 0x44);
  1568. OV5640YUV_write_cmos_sensor(0x5839, 0x4A);
  1569. OV5640YUV_write_cmos_sensor(0x583a, 0x2C);
  1570. OV5640YUV_write_cmos_sensor(0x583b, 0x2a);
  1571. OV5640YUV_write_cmos_sensor(0x583c, 0x46);
  1572. OV5640YUV_write_cmos_sensor(0x583d, 0xCE);
  1573. OV5640YUV_write_cmos_sensor(0x5688, 0x22);
  1574. OV5640YUV_write_cmos_sensor(0x5689, 0x22);
  1575. OV5640YUV_write_cmos_sensor(0x568a, 0x42);
  1576. OV5640YUV_write_cmos_sensor(0x568b, 0x24);
  1577. OV5640YUV_write_cmos_sensor(0x568c, 0x42);
  1578. OV5640YUV_write_cmos_sensor(0x568d, 0x24);
  1579. OV5640YUV_write_cmos_sensor(0x568e, 0x22);
  1580. OV5640YUV_write_cmos_sensor(0x568f, 0x22);
  1581. OV5640YUV_write_cmos_sensor(0x5025, 0x00);
  1582. OV5640YUV_write_cmos_sensor(0x3a0f, 0x30);
  1583. OV5640YUV_write_cmos_sensor(0x3a10, 0x28);
  1584. OV5640YUV_write_cmos_sensor(0x3a1b, 0x30);
  1585. OV5640YUV_write_cmos_sensor(0x3a1e, 0x28);
  1586. OV5640YUV_write_cmos_sensor(0x3a11, 0x61);
  1587. OV5640YUV_write_cmos_sensor(0x3a1f, 0x10);
  1588. OV5640YUV_write_cmos_sensor(0x4005, 0x1a);
  1589. OV5640YUV_write_cmos_sensor(0x3406, 0x00);//awbinit
  1590. OV5640YUV_write_cmos_sensor(0x3503, 0x00);//awbinit
  1591. OV5640YUV_write_cmos_sensor(0x3008, 0x02);
  1592. }
  1593. //set constant focus
  1594. static void OV5640_FOCUS_AD5820_Constant_Focus(void)
  1595. {
  1596. UINT8 state = 0x8F;
  1597. UINT32 iteration = 300;
  1598. //send constant focus mode command to firmware
  1599. OV5640YUV_write_cmos_sensor(0x3023,0x01);
  1600. OV5640YUV_write_cmos_sensor(0x3022,0x04);
  1601. return;
  1602. }
  1603. static void OV5640_FOCUS_AD5820_Single_Focus()
  1604. {
  1605. UINT8 state = 0x8F;
  1606. UINT32 iteration = 100;
  1607. OV5640YUV_write_cmos_sensor(0x3023,0x01);
  1608. OV5640YUV_write_cmos_sensor(0x3022,0x03);
  1609. iteration = 100;
  1610. do{
  1611. state = (UINT8)OV5640YUV_read_cmos_sensor(0x3023);
  1612. if(state == 0x00)
  1613. {
  1614. SENSORDB("single focused!\n");
  1615. break;
  1616. }
  1617. // mdelay(30);
  1618. mdelay(3);
  1619. iteration --;
  1620. }while(iteration);
  1621. return;
  1622. }
  1623. static void OV5640_FOCUS_AD5820_Pause_Focus()
  1624. {
  1625. UINT8 state = 0x8F;
  1626. UINT32 iteration = 100;
  1627. //send idle command to firmware
  1628. OV5640YUV_write_cmos_sensor(0x3023,0x01);
  1629. OV5640YUV_write_cmos_sensor(0x3022,0x06);
  1630. iteration = 100;
  1631. do{
  1632. state = (UINT8)OV5640YUV_read_cmos_sensor(0x3023);
  1633. if(state == 0x00)
  1634. {
  1635. break;
  1636. }
  1637. msleep(30);
  1638. // msleep(10);
  1639. iteration --;
  1640. }while(iteration);
  1641. if(iteration==0)
  1642. {
  1643. printk("pause focus fail.........state is 0x%x...",state);
  1644. return ;
  1645. }
  1646. printk("pause focus OK ......");
  1647. }
  1648. static void OV5640_FOCUS_AD5820_Cancel_Focus()
  1649. {
  1650. UINT8 state = 0x8F;
  1651. UINT32 iteration = 100;
  1652. //send idle command to firmware
  1653. OV5640YUV_write_cmos_sensor(0x3023,0x01);
  1654. OV5640YUV_write_cmos_sensor(0x3022,0x08);
  1655. iteration = 100;
  1656. do{
  1657. state = (UINT8)OV5640YUV_read_cmos_sensor(0x3023);
  1658. if(state == 0x00)
  1659. {
  1660. break;
  1661. }
  1662. msleep(30);
  1663. iteration --;
  1664. }while(iteration);
  1665. }
  1666. void OV5640YUV_set_720P_init(void)
  1667. {
  1668. //OV5640YUV_write_cmos_sensor(0x3008, 0x42);
  1669. OV5640YUV_write_cmos_sensor(0x5189, 0x72);
  1670. OV5640YUV_write_cmos_sensor(0x3503, 0x00);//AE
  1671. //OV5640YUV_write_cmos_sensor(0x3406, 0x00);//AWB
  1672. OV5640YUV_write_cmos_sensor(0x3a00, 0x38);//enable night
  1673. OV5640YUV_write_cmos_sensor(0x5302, 0x20);
  1674. OV5640YUV_write_cmos_sensor(0x5303, 0x08);
  1675. OV5640YUV_write_cmos_sensor(0x5306, 0x10);//18
  1676. OV5640YUV_write_cmos_sensor(0x5307, 0x20);//28
  1677. //OV5640YUV_write_cmos_sensor(0x3820, 0x47);
  1678. // OV5640YUV_write_cmos_sensor(0x3821, 0x01);
  1679. //dg add 2015-07-24 for stop flip image
  1680. OV5640YUV_write_cmos_sensor(0x3820, 0x40);
  1681. OV5640YUV_write_cmos_sensor(0x3821, 0x06);
  1682. OV5640YUV_write_cmos_sensor(0x3108, 0x01);
  1683. //windows setup
  1684. OV5640YUV_write_cmos_sensor(0x3800, 0x00);
  1685. OV5640YUV_write_cmos_sensor(0x3801, 0x00);
  1686. OV5640YUV_write_cmos_sensor(0x3802, 0x00);
  1687. OV5640YUV_write_cmos_sensor(0x3803, 0x04);
  1688. //dg add 2015-07-25 to adjust X_AADR_END long for image windeos show
  1689. OV5640YUV_write_cmos_sensor(0x3804, 0x0a);
  1690. OV5640YUV_write_cmos_sensor(0x3805, 0x5f); //3f-5f->Good
  1691. OV5640YUV_write_cmos_sensor(0x3806, 0x07);
  1692. OV5640YUV_write_cmos_sensor(0x3807, 0x9b);
  1693. #if 1
  1694. OV5640YUV_write_cmos_sensor(0x3808, 0x05);//1280
  1695. OV5640YUV_write_cmos_sensor(0x3809, 0x00);
  1696. OV5640YUV_write_cmos_sensor(0x380a, 0x03);//960
  1697. OV5640YUV_write_cmos_sensor(0x380b, 0xc0);
  1698. #else
  1699. OV5640YUV_write_cmos_sensor(0x3808, 0x05);
  1700. OV5640YUV_write_cmos_sensor(0x3809, 0x80);
  1701. OV5640YUV_write_cmos_sensor(0x380a, 0x01);
  1702. OV5640YUV_write_cmos_sensor(0x380b, 0xe0);
  1703. #endif
  1704. //OV5640YUV_write_cmos_sensor(0x3810, 0x00);
  1705. // OV5640YUV_write_cmos_sensor(0x3811, 0x10);
  1706. //dg add 2015-07-25 to adjust X OFFSET position coordinate for image windeos show
  1707. OV5640YUV_write_cmos_sensor(0x3810, 0x00); // 00->01->00
  1708. OV5640YUV_write_cmos_sensor(0x3811, 0xED); // 10->00->F0->EF->EE->ED->Good
  1709. OV5640YUV_write_cmos_sensor(0x3812, 0x00);
  1710. OV5640YUV_write_cmos_sensor(0x3813, 0x06);
  1711. OV5640YUV_write_cmos_sensor(0x3814, 0x31);
  1712. OV5640YUV_write_cmos_sensor(0x3815, 0x31);
  1713. OV5640YUV_write_cmos_sensor(0x3034, 0x1a);
  1714. OV5640YUV_write_cmos_sensor(0x3035, 0x21); //25fps
  1715. OV5640YUV_write_cmos_sensor(0x3036, 0x46);
  1716. OV5640YUV_write_cmos_sensor(0x3037, 0x13);
  1717. OV5640YUV_write_cmos_sensor(0x3038, 0x00);
  1718. OV5640YUV_write_cmos_sensor(0x3039, 0x00);
  1719. OV5640YUV_write_cmos_sensor(0x380c, 0x07);
  1720. OV5640YUV_write_cmos_sensor(0x380d, 0x68);
  1721. OV5640YUV_write_cmos_sensor(0x380e, 0x03);
  1722. OV5640YUV_write_cmos_sensor(0x380f, 0xd8);
  1723. OV5640YUV_write_cmos_sensor(0x3a08, 0x00);
  1724. OV5640YUV_write_cmos_sensor(0x3a09, 0x93);
  1725. OV5640YUV_write_cmos_sensor(0x3a0e, 0x06);
  1726. OV5640YUV_write_cmos_sensor(0x3a0a, 0x00);
  1727. OV5640YUV_write_cmos_sensor(0x3a0b, 0x7b);
  1728. OV5640YUV_write_cmos_sensor(0x3a0d, 0x08);
  1729. OV5640YUV_write_cmos_sensor(0x3618, 0x00);
  1730. OV5640YUV_write_cmos_sensor(0x3612, 0x29);
  1731. OV5640YUV_write_cmos_sensor(0x3709, 0x52);
  1732. OV5640YUV_write_cmos_sensor(0x370c, 0x03);
  1733. OV5640YUV_write_cmos_sensor(0x4004, 0x02);
  1734. OV5640YUV_write_cmos_sensor(0x460b, 0x35);
  1735. OV5640YUV_write_cmos_sensor(0x460c, 0x22);
  1736. OV5640YUV_write_cmos_sensor(0x4837, 0x15);
  1737. OV5640YUV_write_cmos_sensor(0x3824, 0x01);
  1738. OV5640YUV_write_cmos_sensor(0x5001, 0xa3);
  1739. //OV5640YUV_write_cmos_sensor(0x3008, 0x02);
  1740. }
  1741. void OV5640YUV_set_5M_init(void)
  1742. {
  1743. //OV5640YUV_write_cmos_sensor(0x3008, 0x42);
  1744. OV5640YUV_write_cmos_sensor(0x5189, 0x66);
  1745. OV5640YUV_write_cmos_sensor(0x3503, 0x07);//AE
  1746. //OV5640YUV_write_cmos_sensor(0x3406, 0x01);//AWB
  1747. OV5640YUV_write_cmos_sensor(0x3a00, 0x38);//disable night
  1748. OV5640YUV_write_cmos_sensor(0x5302, 0x30);
  1749. OV5640YUV_write_cmos_sensor(0x5303, 0x10);
  1750. OV5640YUV_write_cmos_sensor(0x5306, 0x08);
  1751. OV5640YUV_write_cmos_sensor(0x5307, 0x18);
  1752. OV5640YUV_write_cmos_sensor(0x3820, 0x40); //46
  1753. OV5640YUV_write_cmos_sensor(0x3821, 0x06); //00
  1754. OV5640YUV_write_cmos_sensor(0x3800, 0x00);
  1755. OV5640YUV_write_cmos_sensor(0x3801, 0x00);
  1756. OV5640YUV_write_cmos_sensor(0x3802, 0x00);
  1757. OV5640YUV_write_cmos_sensor(0x3803, 0x00);
  1758. OV5640YUV_write_cmos_sensor(0x3804, 0x0a);
  1759. OV5640YUV_write_cmos_sensor(0x3805, 0x3f);
  1760. OV5640YUV_write_cmos_sensor(0x3806, 0x07);
  1761. OV5640YUV_write_cmos_sensor(0x3807, 0x9f);
  1762. OV5640YUV_write_cmos_sensor(0x3808, 0x0a);
  1763. OV5640YUV_write_cmos_sensor(0x3809, 0x20);
  1764. OV5640YUV_write_cmos_sensor(0x380a, 0x07);
  1765. OV5640YUV_write_cmos_sensor(0x380b, 0x98);
  1766. OV5640YUV_write_cmos_sensor(0x3810, 0x00);
  1767. OV5640YUV_write_cmos_sensor(0x3811, 0x10);
  1768. OV5640YUV_write_cmos_sensor(0x3812, 0x00);
  1769. OV5640YUV_write_cmos_sensor(0x3813, 0x04);
  1770. OV5640YUV_write_cmos_sensor(0x3814, 0x11);
  1771. OV5640YUV_write_cmos_sensor(0x3815, 0x11);
  1772. OV5640YUV_write_cmos_sensor(0x3034, 0x1a);
  1773. OV5640YUV_write_cmos_sensor(0x3035, 0x11); //10fps
  1774. OV5640YUV_write_cmos_sensor(0x3036, 0x46);
  1775. OV5640YUV_write_cmos_sensor(0x3037, 0x13);
  1776. OV5640YUV_write_cmos_sensor(0x3038, 0x00);
  1777. OV5640YUV_write_cmos_sensor(0x3039, 0x00);
  1778. OV5640YUV_write_cmos_sensor(0x380c, 0x0b);
  1779. OV5640YUV_write_cmos_sensor(0x380d, 0x1c);
  1780. OV5640YUV_write_cmos_sensor(0x380e, 0x07);
  1781. OV5640YUV_write_cmos_sensor(0x380f, 0xb0);
  1782. OV5640YUV_write_cmos_sensor(0x3a08, 0x00);
  1783. OV5640YUV_write_cmos_sensor(0x3a09, 0xc5);
  1784. OV5640YUV_write_cmos_sensor(0x3a0e, 0x0a);
  1785. OV5640YUV_write_cmos_sensor(0x3a0a, 0x00);
  1786. OV5640YUV_write_cmos_sensor(0x3a0b, 0xa4);
  1787. OV5640YUV_write_cmos_sensor(0x3a0d, 0x0c);
  1788. OV5640YUV_write_cmos_sensor(0x3618, 0x04);
  1789. OV5640YUV_write_cmos_sensor(0x3612, 0x2b);
  1790. OV5640YUV_write_cmos_sensor(0x3709, 0x12);
  1791. OV5640YUV_write_cmos_sensor(0x370c, 0x00);
  1792. OV5640YUV_write_cmos_sensor(0x4004, 0x06);
  1793. OV5640YUV_write_cmos_sensor(0x3002, 0x00);
  1794. OV5640YUV_write_cmos_sensor(0x3006, 0xff);
  1795. OV5640YUV_write_cmos_sensor(0x4713, 0x02);
  1796. OV5640YUV_write_cmos_sensor(0x4407, 0x04);
  1797. OV5640YUV_write_cmos_sensor(0x460b, 0x37);
  1798. OV5640YUV_write_cmos_sensor(0x460c, 0x22);
  1799. OV5640YUV_write_cmos_sensor(0x4837, 0x16);
  1800. OV5640YUV_write_cmos_sensor(0x3824, 0x01);
  1801. OV5640YUV_write_cmos_sensor(0x5001, 0x83);
  1802. //OV5640YUV_write_cmos_sensor(0x3008, 0x02);
  1803. mdelay(300);//liuxinming
  1804. }
  1805. void OV5640YUV_set_720P(void)
  1806. {
  1807. SENSORDB("OV5640YUV_set_720P Start \n");
  1808. OV5640YUV_g_RES = OV5640_720P;
  1809. OV5640YUV_set_720P_init();
  1810. OV5640YUV_PV_pclk = 5600;
  1811. OV5640YUV_sensor_pclk=56000000;
  1812. SENSORDB("Set 720P End\n");
  1813. }
  1814. void OV5640YUV_set_5M(void)
  1815. {
  1816. SENSORDB("Set 5M begin\n");
  1817. OV5640YUV_g_RES = OV5640_5M;
  1818. OV5640YUV_set_5M_init();
  1819. OV5640YUV_CAP_pclk = 5600;
  1820. OV5640YUV_sensor_pclk=56000000;
  1821. SENSORDB("Set 5M End\n");
  1822. }
  1823. /*************************************************************************
  1824. * FUNCTION
  1825. * OV5640_night_mode
  1826. *
  1827. * DESCRIPTION
  1828. * This function night mode of OV5640.
  1829. *
  1830. * PARAMETERS
  1831. * none
  1832. *
  1833. * RETURNS
  1834. * None
  1835. *
  1836. * GLOBALS AFFECTED
  1837. *
  1838. *************************************************************************/
  1839. void OV5640YUV_NightMode(bool bEnable)
  1840. {
  1841. if(bEnable)
  1842. {
  1843. OV5640YUV_night_mode = true;
  1844. if(OV5640YUV_MPEG4_encode_mode== true)
  1845. {
  1846. OV5640YUV_write_cmos_sensor(0x3034, 0x1a);
  1847. OV5640YUV_write_cmos_sensor(0x3035, 0x21); //10fps
  1848. OV5640YUV_write_cmos_sensor(0x3036, 0x46);
  1849. OV5640YUV_write_cmos_sensor(0x3037, 0x13);
  1850. OV5640YUV_write_cmos_sensor(0x3038, 0x00);
  1851. OV5640YUV_write_cmos_sensor(0x3039, 0x00);
  1852. OV5640YUV_write_cmos_sensor(0x380c, 0x07);
  1853. OV5640YUV_write_cmos_sensor(0x380d, 0x68);
  1854. OV5640YUV_write_cmos_sensor(0x380e, 0x05);
  1855. OV5640YUV_write_cmos_sensor(0x380f, 0xc4);
  1856. OV5640YUV_write_cmos_sensor(0x3c01, 0xb4);
  1857. OV5640YUV_write_cmos_sensor(0x3c00, 0x04);
  1858. OV5640YUV_write_cmos_sensor(0x3a08, 0x00);
  1859. OV5640YUV_write_cmos_sensor(0x3a09, 0x93);
  1860. OV5640YUV_write_cmos_sensor(0x3a0e, 0x0a);
  1861. OV5640YUV_write_cmos_sensor(0x3a0a, 0x00);
  1862. OV5640YUV_write_cmos_sensor(0x3a0b, 0x7b);
  1863. OV5640YUV_write_cmos_sensor(0x3a0d, 0x0c);
  1864. OV5640YUV_write_cmos_sensor(0x3a00, 0x38);
  1865. OV5640YUV_write_cmos_sensor(0x3a02 ,0x05);
  1866. OV5640YUV_write_cmos_sensor(0x3a03 ,0xc4);
  1867. OV5640YUV_write_cmos_sensor(0x3a14 ,0x05);
  1868. OV5640YUV_write_cmos_sensor(0x3a15 ,0xc4);
  1869. }
  1870. else
  1871. {
  1872. OV5640YUV_write_cmos_sensor(0x3a00, 0x3c);//25fps-5fps
  1873. OV5640YUV_write_cmos_sensor(0x3a02 ,0x0b);
  1874. OV5640YUV_write_cmos_sensor(0x3a03 ,0x88);
  1875. OV5640YUV_write_cmos_sensor(0x3a14 ,0x0b);
  1876. OV5640YUV_write_cmos_sensor(0x3a15 ,0x88);
  1877. }
  1878. }
  1879. else
  1880. {
  1881. OV5640YUV_night_mode = false;
  1882. if(OV5640YUV_MPEG4_encode_mode==false)
  1883. {
  1884. OV5640YUV_write_cmos_sensor(0x3034, 0x1a);
  1885. OV5640YUV_write_cmos_sensor(0x3035, 0x21); //15fps
  1886. OV5640YUV_write_cmos_sensor(0x3036, 0x46);
  1887. OV5640YUV_write_cmos_sensor(0x3037, 0x13);
  1888. OV5640YUV_write_cmos_sensor(0x3038, 0x00);
  1889. OV5640YUV_write_cmos_sensor(0x3039, 0x00);
  1890. OV5640YUV_write_cmos_sensor(0x380c, 0x07);
  1891. OV5640YUV_write_cmos_sensor(0x380d, 0x68);
  1892. OV5640YUV_write_cmos_sensor(0x380e, 0x03);
  1893. OV5640YUV_write_cmos_sensor(0x380f, 0xd8);
  1894. OV5640YUV_write_cmos_sensor(0x3c01, 0xb4);
  1895. OV5640YUV_write_cmos_sensor(0x3c00, 0x04);
  1896. OV5640YUV_write_cmos_sensor(0x3a08, 0x00);
  1897. OV5640YUV_write_cmos_sensor(0x3a09, 0x93);
  1898. OV5640YUV_write_cmos_sensor(0x3a0e, 0x06);
  1899. OV5640YUV_write_cmos_sensor(0x3a0a, 0x00);
  1900. OV5640YUV_write_cmos_sensor(0x3a0b, 0x7b);
  1901. OV5640YUV_write_cmos_sensor(0x3a0d, 0x08);
  1902. OV5640YUV_write_cmos_sensor(0x3a00, 0x38);
  1903. OV5640YUV_write_cmos_sensor(0x3a02 ,0x03);
  1904. OV5640YUV_write_cmos_sensor(0x3a03 ,0xd8);
  1905. OV5640YUV_write_cmos_sensor(0x3a14 ,0x03);
  1906. OV5640YUV_write_cmos_sensor(0x3a15 ,0xd8);
  1907. }
  1908. else
  1909. {
  1910. OV5640YUV_write_cmos_sensor(0x3a00, 0x38);//25fps-20fps
  1911. OV5640YUV_write_cmos_sensor(0x3a02 ,0x03);
  1912. OV5640YUV_write_cmos_sensor(0x3a03 ,0xd8);
  1913. OV5640YUV_write_cmos_sensor(0x3a14 ,0x03);
  1914. OV5640YUV_write_cmos_sensor(0x3a15 ,0xd8);
  1915. }
  1916. }
  1917. }
  1918. static void OV5640YUV_SetDummy(const kal_uint16 iPixels, const kal_uint16 iLines)
  1919. {
  1920. return ;
  1921. }
  1922. static void OV5640YUV_set_AE_mode(kal_bool AE_enable)
  1923. {
  1924. kal_uint8 temp_AE_reg = 0;
  1925. if (AE_enable == KAL_TRUE)
  1926. {
  1927. OV5640YUV_write_cmos_sensor(0x3503, 0x00);
  1928. }
  1929. else
  1930. {
  1931. OV5640YUV_write_cmos_sensor(0x3503, 0x07);
  1932. }
  1933. }
  1934. #if 0
  1935. static void OV5640YUV_set_AWB_mode(kal_bool AWB_enable)
  1936. {
  1937. kal_uint8 temp_AWB_reg = 0;
  1938. if (AWB_enable == KAL_TRUE)
  1939. {
  1940. OV5640YUV_write_cmos_sensor(0x3406, 0x00);
  1941. }
  1942. else
  1943. {
  1944. OV5640YUV_write_cmos_sensor(0x3406, 0x01);
  1945. }
  1946. }
  1947. #endif
  1948. /*************************************************************************
  1949. * FUNCTION
  1950. * OV5640YUV_SetGain
  1951. *
  1952. * DESCRIPTION
  1953. * This function is to set global gain to sensor.
  1954. *
  1955. * PARAMETERS
  1956. * gain : sensor global gain(base: 0x40)
  1957. *
  1958. * RETURNS
  1959. * the actually gain set to sensor.
  1960. *
  1961. * GLOBALS AFFECTED
  1962. *
  1963. *************************************************************************/
  1964. //! Due to the OV5640 set gain will happen race condition.
  1965. //! It need to use a critical section to protect it.
  1966. //static atomic_t OV5640_SetGain_Flag;
  1967. //static wait_queue_head_t OV5640_SetGain_waitQueue;
  1968. void OV5640YUV_SetGain(UINT16 iGain)
  1969. {
  1970. kal_uint8 iReg;
  1971. int timeOut = 0;
  1972. #if 0
  1973. if (atomic_read(&OV5640_SetGain_Flag) == 1) {
  1974. timeOut = wait_event_interruptible_timeout(
  1975. OV5640_SetGain_waitQueue, atomic_read(&OV5640_SetGain_Flag) == 0, 1 * HZ);
  1976. if (timeOut == 0) {
  1977. SENSORDB("[OV5640YUV_SetGain] Set Gain Wait Queue time out \n");
  1978. return;
  1979. }
  1980. }
  1981. atomic_set(&OV5640_SetGain_Flag, 1);
  1982. #endif
  1983. OV5640YUV_write_cmos_sensor(0x3212, 0x00);
  1984. OV5640YUV_write_cmos_sensor(0x350B, (kal_uint32)iGain);
  1985. OV5640YUV_write_cmos_sensor(0x3212, 0x10);
  1986. OV5640YUV_write_cmos_sensor(0x3212, 0xA0);
  1987. #if 0
  1988. atomic_set(&OV5640_SetGain_Flag, 0);
  1989. wake_up_interruptible(&OV5640_SetGain_waitQueue);
  1990. #endif
  1991. } /* OV5640YUV_SetGain */
  1992. /*************************************************************************
  1993. * FUNCTION
  1994. * OV5640YUV_read_shutter
  1995. *
  1996. * DESCRIPTION
  1997. * This function to Get exposure time.
  1998. *
  1999. * PARAMETERS
  2000. * None
  2001. *
  2002. * RETURNS
  2003. * shutter : exposured lines
  2004. *
  2005. * GLOBALS AFFECTED
  2006. *
  2007. *************************************************************************/
  2008. UINT16 OV5640YUV_read_shutter(void)
  2009. {
  2010. kal_uint8 temp_reg1, temp_reg2, temp_reg3;
  2011. kal_uint16 temp_reg;
  2012. temp_reg1 = OV5640YUV_read_cmos_sensor(0x3500);
  2013. temp_reg2 = OV5640YUV_read_cmos_sensor(0x3501);
  2014. temp_reg3 = OV5640YUV_read_cmos_sensor(0x3502);
  2015. // SENSORDB("ov5640read shutter 0x3500=0x%x,0x3501=0x%x,0x3502=0x%x\n",
  2016. // temp_reg1,temp_reg2,temp_reg3);
  2017. temp_reg = ((temp_reg1<<12) & 0xF000) | ((temp_reg2<<4) & 0x0FF0) | ((temp_reg3>>4) & 0x0F);
  2018. //SENSORDB("ov5640read shutter = 0x%x\n", temp_reg);
  2019. return (UINT16)temp_reg;
  2020. }
  2021. void OV5640YUV_write_shutter(kal_uint16 shutter)
  2022. {
  2023. kal_uint16 iExp = shutter;
  2024. kal_uint16 OV5640_g_iExtra_ExpLines = 0 ;
  2025. int timeOut = 0;
  2026. OV5640YUV_write_cmos_sensor(0x3500, (iExp >> 12) & 0xFF);
  2027. OV5640YUV_write_cmos_sensor(0x3501, (iExp >> 4 ) & 0xFF);
  2028. OV5640YUV_write_cmos_sensor(0x3502, (iExp <<4 ) & 0xFF);
  2029. } /* write_OV5640_shutter */
  2030. /*************************************************************************
  2031. * FUNCTION
  2032. * OV5640YUV_SetShutter
  2033. *
  2034. * DESCRIPTION
  2035. * This function set e-shutter of OV5640 to change exposure time.
  2036. *
  2037. * PARAMETERS
  2038. * shutter : exposured lines
  2039. *
  2040. * RETURNS
  2041. * None
  2042. *
  2043. * GLOBALS AFFECTED
  2044. *
  2045. *************************************************************************/
  2046. void OV5640YUV_SetShutter(kal_uint16 iShutter)
  2047. {
  2048. if (iShutter < 1)
  2049. iShutter = 1;
  2050. OV5640YUV_pv_exposure_lines = iShutter;
  2051. OV5640YUV_write_shutter(iShutter);
  2052. //SENSORDB("iShutter = %d\n", iShutter);
  2053. } /* OV5640YUV_SetShutter */
  2054. /*************************************************************************
  2055. * FUNCTION
  2056. * read_OV5640YUV_gain
  2057. *
  2058. * DESCRIPTION
  2059. * This function is to set global gain to sensor.
  2060. *
  2061. * PARAMETERS
  2062. * None
  2063. *
  2064. * RETURNS
  2065. * gain : sensor global gain(base: 0x40)
  2066. *
  2067. * GLOBALS AFFECTED
  2068. *
  2069. *************************************************************************/
  2070. kal_uint16 read_OV5640YUV_gain(void)
  2071. {
  2072. kal_uint8 temp_gain;
  2073. kal_uint16 gain;
  2074. gain = OV5640YUV_read_cmos_sensor(0x350B);
  2075. return gain;
  2076. } /* read_OV5640YUV_gain */
  2077. void write_OV5640YUV_gain(kal_uint16 gain)
  2078. {
  2079. OV5640YUV_SetGain(gain);
  2080. }
  2081. /*************************************************************************
  2082. * FUNCTION
  2083. * OV5640YUVPreview
  2084. *
  2085. * DESCRIPTION
  2086. * This function start the sensor preview.
  2087. *
  2088. * PARAMETERS
  2089. * *image_window : address pointer of pixel numbers in one period of HSYNC
  2090. * *sensor_config_data : address pointer of line numbers in one period of VSYNC
  2091. *
  2092. * RETURNS
  2093. * None
  2094. *
  2095. * GLOBALS AFFECTED
  2096. *
  2097. *************************************************************************/
  2098. UINT32 OV5640YUVPreview()
  2099. {
  2100. // kal_uint16 iStartX = 0, iStartY = 0;
  2101. g_iOV5640YUV_Mode = OV5640_MODE_PREVIEW;
  2102. OV5640YUV_write_cmos_sensor(0x4202,0x0f);
  2103. // msleep(30);
  2104. msleep(5);
  2105. OV5640YUV_set_720P();
  2106. OV5640YUV_write_cmos_sensor(0x4202,0x00);
  2107. // msleep(30);
  2108. // dg cancle ,donot focus start,otherwise picture is not working well.
  2109. //dg use after
  2110. // OV5640YUV_write_cmos_sensor(0x3023,0x01);
  2111. // OV5640YUV_write_cmos_sensor(0x3022,0x04);
  2112. #if 0
  2113. if (tem){
  2114. OV5640YUV_SetShutter(back_shutter);
  2115. write_OV5640YUV_gain(back_pv_gain);
  2116. }
  2117. tem =0;
  2118. #endif
  2119. //OV5640YUV_write_cmos_sensor(0x3820, 0x46);
  2120. //OV5640YUV_write_cmos_sensor(0x3821, 0x00);
  2121. /*
  2122. if(sensor_config_data->SensorOperationMode==MSDK_SENSOR_OPERATION_MODE_VIDEO) // MPEG4 Encode Mode
  2123. {
  2124. OV5640YUV_MPEG4_encode_mode = KAL_TRUE;
  2125. }
  2126. else
  2127. {
  2128. OV5640YUV_MPEG4_encode_mode = KAL_FALSE;
  2129. }
  2130. iStartX += OV5640_IMAGE_SENSOR_PV_STARTX;
  2131. iStartY += OV5640_IMAGE_SENSOR_PV_STARTY;
  2132. */
  2133. // sensor_config_data->SensorImageMirror = IMAGE_HV_MIRROR;
  2134. // OV5640YUV_Set_Mirror_Flip(sensor_config_data->SensorImageMirror);
  2135. /*************************************************************************************************************/
  2136. //dg cancle 2015-07-18
  2137. //OV5640YUV_write_cmos_sensor(0x3820,0x47);
  2138. //OV5640YUV_write_cmos_sensor(0x3821,0x01);
  2139. // OV5640YUV_write_cmos_sensor(0x4514,0x00);
  2140. /*************************************************************************************************************/
  2141. #if 0
  2142. OV5640YUV_dummy_pixels = 0;
  2143. OV5640YUV_dummy_lines = 0;
  2144. OV5640YUV_PV_dummy_pixels = OV5640YUV_dummy_pixels;
  2145. OV5640YUV_PV_dummy_lines = OV5640YUV_dummy_lines;
  2146. //OV5640YUV_SetDummy(OV5640YUV_dummy_pixels, OV5640YUV_dummy_lines);
  2147. #endif
  2148. //OV5640YUV_NightMode(OV5640YUV_night_mode);
  2149. OV5640YUV_NightMode(false);
  2150. #if 0
  2151. memcpy(&OV5640YUVSensorConfigData, sensor_config_data, sizeof(MSDK_SENSOR_CONFIG_STRUCT));
  2152. image_window->GrabStartX= iStartX;
  2153. image_window->GrabStartY= iStartY;
  2154. image_window->ExposureWindowWidth= OV5640_IMAGE_SENSOR_PV_WIDTH - 2*iStartX;
  2155. image_window->ExposureWindowHeight= OV5640_IMAGE_SENSOR_PV_HEIGHT - 2*iStartY;
  2156. #endif
  2157. return 0;
  2158. }
  2159. UINT32 OV5640YUVCapture( )
  2160. {
  2161. kal_uint32 shutter = 0;
  2162. kal_uint32 temp_shutter = 0;
  2163. kal_uint16 iStartX = 0, iStartY = 0;
  2164. kal_uint32 pv_gain = 0;
  2165. kal_uint8 temp = 0;//for night mode
  2166. if(g_iOV5640YUV_Mode == OV5640_MODE_PREVIEW)
  2167. {
  2168. g_iOV5640YUV_Mode = OV5640_MODE_CAPTURE;
  2169. // if(sensor_config_data->EnableShutterTansfer==KAL_TRUE)
  2170. // shutter=sensor_config_data->CaptureShutter;
  2171. temp= OV5640YUV_read_cmos_sensor(0x3a00);
  2172. OV5640YUV_write_cmos_sensor(0x3a00,temp&0xfb);
  2173. OV5640YUV_set_AE_mode(KAL_FALSE);
  2174. //OV5640YUV_set_AWB_mode(KAL_FALSE);
  2175. shutter = OV5640YUV_read_shutter();
  2176. pv_gain = read_OV5640YUV_gain();
  2177. back_shutter = shutter;
  2178. back_pv_gain = pv_gain;
  2179. tem = 1;
  2180. SENSORDB("Preview Shutter = %d, Gain = %d\n", shutter, pv_gain);
  2181. #if 0
  2182. if ((image_window->ImageTargetWidth<= OV5640_IMAGE_SENSOR_PV_WIDTH) &&
  2183. (image_window->ImageTargetHeight<= OV5640_IMAGE_SENSOR_PV_HEIGHT))
  2184. {
  2185. OV5640YUV_dummy_pixels= 0;
  2186. OV5640YUV_dummy_lines = 0;
  2187. iStartX = OV5640_IMAGE_SENSOR_PV_STARTX;
  2188. iStartY = OV5640_IMAGE_SENSOR_PV_STARTY;
  2189. image_window->GrabStartX=iStartX;
  2190. image_window->GrabStartY=iStartY;
  2191. image_window->ExposureWindowWidth=OV5640_IMAGE_SENSOR_PV_WIDTH - 2*iStartX;
  2192. image_window->ExposureWindowHeight=OV5640_IMAGE_SENSOR_PV_HEIGHT- 2*iStartY;
  2193. }
  2194. else
  2195. {
  2196. #endif
  2197. OV5640_FOCUS_AD5820_Single_Focus();
  2198. OV5640YUV_write_cmos_sensor(0x4202,0x0f);
  2199. Sleep(30);
  2200. OV5640YUV_set_5M();
  2201. OV5640YUV_write_cmos_sensor(0x4202,0x00);
  2202. Sleep(30);
  2203. #if 0
  2204. OV5640YUV_dummy_pixels= 0;
  2205. OV5640YUV_dummy_lines = 0;
  2206. OV5640YUV_CAP_pclk = 560;
  2207. OV5640YUV_PV_pclk = 560;
  2208. //temp_shutter = (shutter*(OV5640_PV_PERIOD_PIXEL_NUMS_HTS+OV5640YUV_PV_dummy_pixels)*OV5640YUV_CAP_pclk)
  2209. // /(OV5640_FULL_PERIOD_PIXEL_NUMS_HTS+OV5640YUV_dummy_pixels)/OV5640YUV_PV_pclk;
  2210. //shutter = (kal_uint32)(temp_shutter);
  2211. shutter = shutter*4/3;
  2212. SENSORDB("cap shutter calutaed = %d, 0x%x\n", shutter,shutter);
  2213. iStartX = 2* OV5640_IMAGE_SENSOR_PV_STARTX;
  2214. iStartY = 2* OV5640_IMAGE_SENSOR_PV_STARTY;
  2215. image_window->GrabStartX=iStartX;
  2216. image_window->GrabStartY=iStartY;
  2217. image_window->ExposureWindowWidth=OV5640_IMAGE_SENSOR_FULL_WIDTH -2*iStartX;
  2218. image_window->ExposureWindowHeight=OV5640_IMAGE_SENSOR_FULL_HEIGHT-2*iStartY;
  2219. }
  2220. sensor_config_data->Lines = image_window->ExposureWindowHeight;
  2221. sensor_config_data->Shutter =shutter;
  2222. OV5640YUV_SetDummy(OV5640YUV_dummy_pixels, OV5640YUV_dummy_lines);
  2223. #endif
  2224. OV5640YUV_SetShutter(shutter);
  2225. write_OV5640YUV_gain(pv_gain);
  2226. #if 0
  2227. memcpy(&OV5640YUVSensorConfigData, sensor_config_data, sizeof(MSDK_SENSOR_CONFIG_STRUCT));
  2228. #endif
  2229. // sensor_config_data->SensorImageMirror = IMAGE_NORMAL;
  2230. // OV5640YUV_Set_Mirror_Flip(sensor_config_data->SensorImageMirror);
  2231. }
  2232. /*************************************************************************************************************/
  2233. OV5640YUV_write_cmos_sensor(0x3820,0x46);
  2234. OV5640YUV_write_cmos_sensor(0x3821,0x00);
  2235. OV5640YUV_write_cmos_sensor(0x4514,0x88);
  2236. /*************************************************************************************************************/
  2237. return ERROR_NONE;
  2238. }
  2239. #endif //end dg add 2015-07-15
  2240. /* add by cym 20130605 */
  2241. static int ov5640_power(int flag)
  2242. {
  2243. int err;
  2244. printk("cym: ov5640 sensor is power %s\n",flag == 1 ?"on":"off");
  2245. //Attention: Power On the all the camera module when system turn on
  2246. //Here only control the reset&&powerdown pin
  2247. /* Camera A */
  2248. if(1 == flag)
  2249. {
  2250. //poweron
  2251. #ifndef CONFIG_TC4_EVT
  2252. regulator_enable(ov_vdd18_cam_regulator);
  2253. udelay(10);
  2254. regulator_enable(ov_vdd28_cam_regulator);
  2255. udelay(10);
  2256. regulator_enable(ov_vdd5m_cam_regulator); //DOVDD DVDD 1.8v
  2257. udelay(10);
  2258. regulator_enable(ov_vddaf_cam_regulator); //AVDD 2.8v
  2259. udelay(10);
  2260. #endif
  2261. #if 1
  2262. //pwdn GPF0_5: 2M PWDN
  2263. err = gpio_request(EXYNOS4_GPF0(5), "GPF0_5");
  2264. if (err)
  2265. printk(KERN_ERR "#### failed to request GPF0_5 ####\n");
  2266. s3c_gpio_setpull(EXYNOS4_GPF0(5), S3C_GPIO_PULL_NONE);
  2267. gpio_direction_output(EXYNOS4_GPF0(5), 1);
  2268. gpio_free(EXYNOS4_GPF0(5));
  2269. #endif
  2270. //pwdn1 GPF2_4: 5M PWDN
  2271. err = gpio_request(EXYNOS4_GPL0(3), "GPL0_3");
  2272. if (err)
  2273. printk(KERN_ERR "#### failed to request GPL0_3 ####\n");
  2274. s3c_gpio_setpull(EXYNOS4_GPL0(3), S3C_GPIO_PULL_NONE);
  2275. gpio_direction_output(EXYNOS4_GPL0(3), 0);
  2276. gpio_free(EXYNOS4_GPL0(3));
  2277. msleep(20);
  2278. //reset
  2279. err = gpio_request(EXYNOS4_GPL0(1), "GPL0_1");
  2280. if (err)
  2281. printk(KERN_ERR "#### failed to request GPL0_1 ####\n");
  2282. s3c_gpio_setpull(EXYNOS4_GPL0(1), S3C_GPIO_PULL_NONE);
  2283. gpio_direction_output(EXYNOS4_GPL0(1), 1);
  2284. msleep(10);
  2285. gpio_direction_output(EXYNOS4_GPL0(1), 0);
  2286. msleep(10);
  2287. gpio_direction_output(EXYNOS4_GPL0(1), 1);
  2288. gpio_free(EXYNOS4_GPL0(1));
  2289. msleep(20);
  2290. }
  2291. else
  2292. {
  2293. err = gpio_request(EXYNOS4_GPL0(1), "GPF0");
  2294. if (err)
  2295. printk(KERN_ERR "#### failed to request GPF0_4 ####\n");
  2296. s3c_gpio_setpull(EXYNOS4_GPL0(1), S3C_GPIO_PULL_NONE);
  2297. gpio_direction_output(EXYNOS4_GPL0(1), 0);
  2298. gpio_free(EXYNOS4_GPL0(1));
  2299. #if 1
  2300. //powerdown GPF0_5: 2M PWDN
  2301. err = gpio_request(EXYNOS4_GPF0(5), "GPF0_5");
  2302. if (err)
  2303. printk(KERN_ERR "#### failed to request GPE0_5 ####\n");
  2304. s3c_gpio_setpull(EXYNOS4_GPF0(5), S3C_GPIO_PULL_NONE);
  2305. gpio_direction_output(EXYNOS4_GPF0(5), 1);
  2306. gpio_free(EXYNOS4_GPF0(5));
  2307. #endif
  2308. //pwdn1 GPF2_4: 5M PWDN
  2309. err = gpio_request(EXYNOS4_GPL0(3), "GPL0_3");
  2310. if (err)
  2311. printk(KERN_ERR "#### failed to request GPF2_4 ####\n");
  2312. s3c_gpio_setpull(EXYNOS4_GPL0(3), S3C_GPIO_PULL_NONE);
  2313. gpio_direction_output(EXYNOS4_GPL0(3), 1);
  2314. gpio_free(EXYNOS4_GPL0(3));
  2315. #ifndef CONFIG_TC4_EVT
  2316. regulator_disable(ov_vdd18_cam_regulator);
  2317. udelay(10);
  2318. regulator_disable(ov_vdd28_cam_regulator);
  2319. udelay(10);
  2320. regulator_disable(ov_vdd5m_cam_regulator);
  2321. udelay(10);
  2322. regulator_disable(ov_vddaf_cam_regulator);
  2323. udelay(10);
  2324. #endif
  2325. }
  2326. return 0;
  2327. }
  2328. #define DEV_DBG_EN 1
  2329. #define REG_ADDR_STEP 2
  2330. #define REG_DATA_STEP 1
  2331. #define REG_STEP (REG_ADDR_STEP+REG_DATA_STEP)
  2332. #define csi_dev_err(x,arg...) printk(KERN_INFO"[OV5640]"x,##arg)
  2333. #define csi_dev_print(x,arg...) printk(KERN_INFO"[OV5640]"x,##arg)
  2334. struct regval_list {
  2335. unsigned char reg_num[REG_ADDR_STEP];
  2336. unsigned char value[REG_DATA_STEP];
  2337. };
  2338. static char ov5640_sensor_af_fw_regs[] = {
  2339. 0x02, 0x0f, 0xd6, 0x02, 0x0a, 0x39, 0xc2, 0x01, 0x22, 0x22, 0x00, 0x02, 0x0f, 0xb2, 0xe5, 0x1f, //0x8000,
  2340. 0x70, 0x72, 0xf5, 0x1e, 0xd2, 0x35, 0xff, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe4, 0xf6, 0x08, //0x8010,
  2341. 0xf6, 0x0f, 0xbf, 0x34, 0xf2, 0x90, 0x0e, 0x93, 0xe4, 0x93, 0xff, 0xe5, 0x4b, 0xc3, 0x9f, 0x50, //0x8020,
  2342. 0x04, 0x7f, 0x05, 0x80, 0x02, 0x7f, 0xfb, 0x78, 0xbd, 0xa6, 0x07, 0x12, 0x0f, 0x04, 0x40, 0x04, //0x8030,
  2343. 0x7f, 0x03, 0x80, 0x02, 0x7f, 0x30, 0x78, 0xbc, 0xa6, 0x07, 0xe6, 0x18, 0xf6, 0x08, 0xe6, 0x78, //0x8040,
  2344. 0xb9, 0xf6, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xbf, 0x76, 0x33, 0xe4, 0x08, 0xf6, 0x78, //0x8050,
  2345. 0xb8, 0x76, 0x01, 0x75, 0x4a, 0x02, 0x78, 0xb6, 0xf6, 0x08, 0xf6, 0x74, 0xff, 0x78, 0xc1, 0xf6, //0x8060,
  2346. 0x08, 0xf6, 0x75, 0x1f, 0x01, 0x78, 0xbc, 0xe6, 0x75, 0xf0, 0x05, 0xa4, 0xf5, 0x4b, 0x12, 0x0a, //0x8070,
  2347. 0xff, 0xc2, 0x37, 0x22, 0x78, 0xb8, 0xe6, 0xd3, 0x94, 0x00, 0x40, 0x02, 0x16, 0x22, 0xe5, 0x1f, //0x8080,
  2348. 0xb4, 0x05, 0x23, 0xe4, 0xf5, 0x1f, 0xc2, 0x01, 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x78, //0x8090,
  2349. 0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x90, 0x30, 0x28, 0xf0, //0x80a0,
  2350. 0x75, 0x1e, 0x10, 0xd2, 0x35, 0x22, 0xe5, 0x4b, 0x75, 0xf0, 0x05, 0x84, 0x78, 0xbc, 0xf6, 0x90, //0x80b0,
  2351. 0x0e, 0x8c, 0xe4, 0x93, 0xff, 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x78, //0x80c0,
  2352. 0xbc, 0xe6, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0xef, 0x12, 0x0f, 0x0b, //0x80d0,
  2353. 0xd3, 0x78, 0xb7, 0x96, 0xee, 0x18, 0x96, 0x40, 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xb9, 0xf6, 0x78, //0x80e0,
  2354. 0xb6, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x8c, 0xe4, 0x93, 0x12, 0x0f, 0x0b, 0xc3, 0x78, //0x80f0,
  2355. 0xc2, 0x96, 0xee, 0x18, 0x96, 0x50, 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xc1, 0xa6, //0x8100,
  2356. 0x06, 0x08, 0xa6, 0x07, 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xc3, 0x78, 0xc2, 0x96, 0xff, 0xee, //0x8110,
  2357. 0x18, 0x96, 0x78, 0xc3, 0xf6, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x95, 0xe4, 0x18, 0x12, 0x0e, 0xe9, //0x8120,
  2358. 0x40, 0x02, 0xd2, 0x37, 0x78, 0xbc, 0xe6, 0x08, 0x26, 0x08, 0xf6, 0xe5, 0x1f, 0x64, 0x01, 0x70, //0x8130,
  2359. 0x4a, 0xe6, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xdf, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, 0x39, 0x12, //0x8140,
  2360. 0x0f, 0x02, 0x40, 0x04, 0x7f, 0xfe, 0x80, 0x02, 0x7f, 0x02, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9, //0x8150,
  2361. 0xe6, 0x24, 0x03, 0x78, 0xbf, 0xf6, 0x78, 0xb9, 0xe6, 0x24, 0xfd, 0x78, 0xc0, 0xf6, 0x12, 0x0f, //0x8160,
  2362. 0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6, //0x8170,
  2363. 0x07, 0x75, 0x1f, 0x02, 0x78, 0xb8, 0x76, 0x01, 0x02, 0x02, 0x4a, 0xe5, 0x1f, 0x64, 0x02, 0x60, //0x8180,
  2364. 0x03, 0x02, 0x02, 0x2a, 0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x08, //0x8190,
  2365. 0x12, 0x0e, 0xda, 0x50, 0x03, 0x02, 0x02, 0x28, 0x12, 0x0f, 0x02, 0x40, 0x04, 0x7f, 0xff, 0x80, //0x81a0,
  2366. 0x02, 0x7f, 0x01, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9, 0xe6, 0x04, 0x78, 0xbf, 0xf6, 0x78, 0xb9, //0x81b0,
  2367. 0xe6, 0x14, 0x78, 0xc0, 0xf6, 0x18, 0x12, 0x0f, 0x04, 0x40, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, //0x81c0,
  2368. 0x00, 0x78, 0xbf, 0xa6, 0x07, 0xd3, 0x08, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x40, 0x04, 0xe6, 0xff, //0x81d0,
  2369. 0x80, 0x02, 0x7f, 0x00, 0x78, 0xc0, 0xa6, 0x07, 0xc3, 0x18, 0xe6, 0x64, 0x80, 0x94, 0xb3, 0x50, //0x81e0,
  2370. 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xbf, 0xa6, 0x07, 0xc3, 0x08, 0xe6, 0x64, 0x80, //0x81f0,
  2371. 0x94, 0xb3, 0x50, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xc0, 0xa6, 0x07, 0x12, 0x0f, //0x8200,
  2372. 0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6, //0x8210,
  2373. 0x07, 0x75, 0x1f, 0x03, 0x78, 0xb8, 0x76, 0x01, 0x80, 0x20, 0xe5, 0x1f, 0x64, 0x03, 0x70, 0x26, //0x8220,
  2374. 0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, //0x8230,
  2375. 0x09, 0x78, 0xb9, 0xe6, 0x78, 0xbe, 0xf6, 0x75, 0x1f, 0x04, 0x78, 0xbe, 0xe6, 0x75, 0xf0, 0x05, //0x8240,
  2376. 0xa4, 0xf5, 0x4b, 0x02, 0x0a, 0xff, 0xe5, 0x1f, 0xb4, 0x04, 0x10, 0x90, 0x0e, 0x94, 0xe4, 0x78, //0x8250,
  2377. 0xc3, 0x12, 0x0e, 0xe9, 0x40, 0x02, 0xd2, 0x37, 0x75, 0x1f, 0x05, 0x22, 0x30, 0x01, 0x03, 0x02, //0x8260,
  2378. 0x04, 0xc0, 0x30, 0x02, 0x03, 0x02, 0x04, 0xc0, 0x90, 0x51, 0xa5, 0xe0, 0x78, 0x93, 0xf6, 0xa3, //0x8270,
  2379. 0xe0, 0x08, 0xf6, 0xa3, 0xe0, 0x08, 0xf6, 0xe5, 0x1f, 0x70, 0x3c, 0x75, 0x1e, 0x20, 0xd2, 0x35, //0x8280,
  2380. 0x12, 0x0c, 0x7a, 0x78, 0x7e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xa6, 0x09, 0x18, 0x76, //0x8290,
  2381. 0x01, 0x12, 0x0c, 0x5b, 0x78, 0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xe6, 0x78, 0x6e, //0x82a0,
  2382. 0xf6, 0x75, 0x1f, 0x01, 0x78, 0x93, 0xe6, 0x78, 0x90, 0xf6, 0x78, 0x94, 0xe6, 0x78, 0x91, 0xf6, //0x82b0,
  2383. 0x78, 0x95, 0xe6, 0x78, 0x92, 0xf6, 0x22, 0x79, 0x90, 0xe7, 0xd3, 0x78, 0x93, 0x96, 0x40, 0x05, //0x82c0,
  2384. 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x93, 0xe7, 0x78, 0x90, 0x96, 0xff, 0x78, 0x88, 0x76, //0x82d0,
  2385. 0x00, 0x08, 0xa6, 0x07, 0x79, 0x91, 0xe7, 0xd3, 0x78, 0x94, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, //0x82e0,
  2386. 0x80, 0x08, 0xc3, 0x79, 0x94, 0xe7, 0x78, 0x91, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x79, 0x92, 0xe7, //0x82f0,
  2387. 0xd3, 0x78, 0x95, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x95, 0xe7, 0x78, //0x8300,
  2388. 0x92, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x12, 0x0c, 0x5b, 0x78, 0x8a, 0xe6, 0x25, 0xe0, 0x24, 0x4e, //0x8310,
  2389. 0xf8, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8a, 0xe6, 0x24, 0x6e, 0xf8, 0xa6, 0x09, 0x78, 0x8a, //0x8320,
  2390. 0xe6, 0x24, 0x01, 0xff, 0xe4, 0x33, 0xfe, 0xd3, 0xef, 0x94, 0x0f, 0xee, 0x64, 0x80, 0x94, 0x80, //0x8330,
  2391. 0x40, 0x04, 0x7f, 0x00, 0x80, 0x05, 0x78, 0x8a, 0xe6, 0x04, 0xff, 0x78, 0x8a, 0xa6, 0x07, 0xe5, //0x8340,
  2392. 0x1f, 0xb4, 0x01, 0x0a, 0xe6, 0x60, 0x03, 0x02, 0x04, 0xc0, 0x75, 0x1f, 0x02, 0x22, 0x12, 0x0c, //0x8350,
  2393. 0x7a, 0x78, 0x80, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x12, 0x0c, 0x7a, 0x78, 0x82, 0xa6, 0x06, 0x08, //0x8360,
  2394. 0xa6, 0x07, 0x78, 0x6e, 0xe6, 0x78, 0x8c, 0xf6, 0x78, 0x6e, 0xe6, 0x78, 0x8d, 0xf6, 0x7f, 0x01, //0x8370,
  2395. 0xef, 0x25, 0xe0, 0x24, 0x4f, 0xf9, 0xc3, 0x78, 0x81, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x50, //0x8380,
  2396. 0x0a, 0x12, 0x0c, 0x82, 0x78, 0x80, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, //0x8390,
  2397. 0x8c, 0xe6, 0xc3, 0x97, 0x50, 0x08, 0x74, 0x6e, 0x2f, 0xf8, 0xe6, 0x78, 0x8c, 0xf6, 0xef, 0x25, //0x83a0,
  2398. 0xe0, 0x24, 0x4f, 0xf9, 0xd3, 0x78, 0x83, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x40, 0x0a, 0x12, //0x83b0,
  2399. 0x0c, 0x82, 0x78, 0x82, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, 0x8d, 0xe6, //0x83c0,
  2400. 0xd3, 0x97, 0x40, 0x08, 0x74, 0x6e, 0x2f, 0xf8, 0xe6, 0x78, 0x8d, 0xf6, 0x0f, 0xef, 0x64, 0x10, //0x83d0,
  2401. 0x70, 0x9e, 0xc3, 0x79, 0x81, 0xe7, 0x78, 0x83, 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0x78, 0x84, //0x83e0,
  2402. 0xf6, 0x08, 0xa6, 0x07, 0xc3, 0x79, 0x8c, 0xe7, 0x78, 0x8d, 0x96, 0x08, 0xf6, 0xd3, 0x79, 0x81, //0x83f0,
  2403. 0xe7, 0x78, 0x7f, 0x96, 0x19, 0xe7, 0x18, 0x96, 0x40, 0x05, 0x09, 0xe7, 0x08, 0x80, 0x06, 0xc3, //0x8400,
  2404. 0x79, 0x7f, 0xe7, 0x78, 0x81, 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0xfe, 0x78, 0x86, 0xa6, 0x06, //0x8410,
  2405. 0x08, 0xa6, 0x07, 0x79, 0x8c, 0xe7, 0xd3, 0x78, 0x8b, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, //0x8420,
  2406. 0x08, 0xc3, 0x79, 0x8b, 0xe7, 0x78, 0x8c, 0x96, 0xff, 0x78, 0x8f, 0xa6, 0x07, 0xe5, 0x1f, 0x64, //0x8430,
  2407. 0x02, 0x70, 0x69, 0x90, 0x0e, 0x91, 0x93, 0xff, 0x18, 0xe6, 0xc3, 0x9f, 0x50, 0x72, 0x12, 0x0c, //0x8440,
  2408. 0x4a, 0x12, 0x0c, 0x2f, 0x90, 0x0e, 0x8e, 0x12, 0x0c, 0x38, 0x78, 0x80, 0x12, 0x0c, 0x6b, 0x7b, //0x8450,
  2409. 0x04, 0x12, 0x0c, 0x1d, 0xc3, 0x12, 0x06, 0x45, 0x50, 0x56, 0x90, 0x0e, 0x92, 0xe4, 0x93, 0xff, //0x8460,
  2410. 0x78, 0x8f, 0xe6, 0x9f, 0x40, 0x02, 0x80, 0x11, 0x90, 0x0e, 0x90, 0xe4, 0x93, 0xff, 0xd3, 0x78, //0x8470,
  2411. 0x89, 0xe6, 0x9f, 0x18, 0xe6, 0x94, 0x00, 0x40, 0x03, 0x75, 0x1f, 0x05, 0x12, 0x0c, 0x4a, 0x12, //0x8480,
  2412. 0x0c, 0x2f, 0x90, 0x0e, 0x8f, 0x12, 0x0c, 0x38, 0x78, 0x7e, 0x12, 0x0c, 0x6b, 0x7b, 0x40, 0x12, //0x8490,
  2413. 0x0c, 0x1d, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x18, 0x75, 0x1f, 0x05, 0x22, 0xe5, 0x1f, 0xb4, 0x05, //0x84a0,
  2414. 0x0f, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0xd2, 0x36, //0x84b0,
  2415. 0x22, 0xef, 0x8d, 0xf0, 0xa4, 0xa8, 0xf0, 0xcf, 0x8c, 0xf0, 0xa4, 0x28, 0xce, 0x8d, 0xf0, 0xa4, //0x84c0,
  2416. 0x2e, 0xfe, 0x22, 0xbc, 0x00, 0x0b, 0xbe, 0x00, 0x29, 0xef, 0x8d, 0xf0, 0x84, 0xff, 0xad, 0xf0, //0x84d0,
  2417. 0x22, 0xe4, 0xcc, 0xf8, 0x75, 0xf0, 0x08, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xec, 0x33, 0xfc, //0x84e0,
  2418. 0xee, 0x9d, 0xec, 0x98, 0x40, 0x05, 0xfc, 0xee, 0x9d, 0xfe, 0x0f, 0xd5, 0xf0, 0xe9, 0xe4, 0xce, //0x84f0,
  2419. 0xfd, 0x22, 0xed, 0xf8, 0xf5, 0xf0, 0xee, 0x84, 0x20, 0xd2, 0x1c, 0xfe, 0xad, 0xf0, 0x75, 0xf0, //0x8500,
  2420. 0x08, 0xef, 0x2f, 0xff, 0xed, 0x33, 0xfd, 0x40, 0x07, 0x98, 0x50, 0x06, 0xd5, 0xf0, 0xf2, 0x22, //0x8510,
  2421. 0xc3, 0x98, 0xfd, 0x0f, 0xd5, 0xf0, 0xea, 0x22, 0xe8, 0x8f, 0xf0, 0xa4, 0xcc, 0x8b, 0xf0, 0xa4, //0x8520,
  2422. 0x2c, 0xfc, 0xe9, 0x8e, 0xf0, 0xa4, 0x2c, 0xfc, 0x8a, 0xf0, 0xed, 0xa4, 0x2c, 0xfc, 0xea, 0x8e, //0x8530,
  2423. 0xf0, 0xa4, 0xcd, 0xa8, 0xf0, 0x8b, 0xf0, 0xa4, 0x2d, 0xcc, 0x38, 0x25, 0xf0, 0xfd, 0xe9, 0x8f, //0x8540,
  2424. 0xf0, 0xa4, 0x2c, 0xcd, 0x35, 0xf0, 0xfc, 0xeb, 0x8e, 0xf0, 0xa4, 0xfe, 0xa9, 0xf0, 0xeb, 0x8f, //0x8550,
  2425. 0xf0, 0xa4, 0xcf, 0xc5, 0xf0, 0x2e, 0xcd, 0x39, 0xfe, 0xe4, 0x3c, 0xfc, 0xea, 0xa4, 0x2d, 0xce, //0x8560,
  2426. 0x35, 0xf0, 0xfd, 0xe4, 0x3c, 0xfc, 0x22, 0x75, 0xf0, 0x08, 0x75, 0x82, 0x00, 0xef, 0x2f, 0xff, //0x8570,
  2427. 0xee, 0x33, 0xfe, 0xcd, 0x33, 0xcd, 0xcc, 0x33, 0xcc, 0xc5, 0x82, 0x33, 0xc5, 0x82, 0x9b, 0xed, //0x8580,
  2428. 0x9a, 0xec, 0x99, 0xe5, 0x82, 0x98, 0x40, 0x0c, 0xf5, 0x82, 0xee, 0x9b, 0xfe, 0xed, 0x9a, 0xfd, //0x8590,
  2429. 0xec, 0x99, 0xfc, 0x0f, 0xd5, 0xf0, 0xd6, 0xe4, 0xce, 0xfb, 0xe4, 0xcd, 0xfa, 0xe4, 0xcc, 0xf9, //0x85a0,
  2430. 0xa8, 0x82, 0x22, 0xb8, 0x00, 0xc1, 0xb9, 0x00, 0x59, 0xba, 0x00, 0x2d, 0xec, 0x8b, 0xf0, 0x84, //0x85b0,
  2431. 0xcf, 0xce, 0xcd, 0xfc, 0xe5, 0xf0, 0xcb, 0xf9, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, //0x85c0,
  2432. 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xeb, 0x33, 0xfb, 0x10, 0xd7, 0x03, 0x99, 0x40, 0x04, 0xeb, //0x85d0,
  2433. 0x99, 0xfb, 0x0f, 0xd8, 0xe5, 0xe4, 0xf9, 0xfa, 0x22, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, //0x85e0,
  2434. 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xc9, 0x33, 0xc9, 0x10, 0xd7, 0x05, 0x9b, 0xe9, 0x9a, //0x85f0,
  2435. 0x40, 0x07, 0xec, 0x9b, 0xfc, 0xe9, 0x9a, 0xf9, 0x0f, 0xd8, 0xe0, 0xe4, 0xc9, 0xfa, 0xe4, 0xcc, //0x8600,
  2436. 0xfb, 0x22, 0x75, 0xf0, 0x10, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xcc, 0x33, //0x8610,
  2437. 0xcc, 0xc8, 0x33, 0xc8, 0x10, 0xd7, 0x07, 0x9b, 0xec, 0x9a, 0xe8, 0x99, 0x40, 0x0a, 0xed, 0x9b, //0x8620,
  2438. 0xfd, 0xec, 0x9a, 0xfc, 0xe8, 0x99, 0xf8, 0x0f, 0xd5, 0xf0, 0xda, 0xe4, 0xcd, 0xfb, 0xe4, 0xcc, //0x8630,
  2439. 0xfa, 0xe4, 0xc8, 0xf9, 0x22, 0xeb, 0x9f, 0xf5, 0xf0, 0xea, 0x9e, 0x42, 0xf0, 0xe9, 0x9d, 0x42, //0x8640,
  2440. 0xf0, 0xe8, 0x9c, 0x45, 0xf0, 0x22, 0xe8, 0x60, 0x0f, 0xec, 0xc3, 0x13, 0xfc, 0xed, 0x13, 0xfd, //0x8650,
  2441. 0xee, 0x13, 0xfe, 0xef, 0x13, 0xff, 0xd8, 0xf1, 0x22, 0xe8, 0x60, 0x0f, 0xef, 0xc3, 0x33, 0xff, //0x8660,
  2442. 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xd8, 0xf1, 0x22, 0xe4, 0x93, 0xfc, 0x74, //0x8670,
  2443. 0x01, 0x93, 0xfd, 0x74, 0x02, 0x93, 0xfe, 0x74, 0x03, 0x93, 0xff, 0x22, 0xe6, 0xfb, 0x08, 0xe6, //0x8680,
  2444. 0xf9, 0x08, 0xe6, 0xfa, 0x08, 0xe6, 0xcb, 0xf8, 0x22, 0xec, 0xf6, 0x08, 0xed, 0xf6, 0x08, 0xee, //0x8690,
  2445. 0xf6, 0x08, 0xef, 0xf6, 0x22, 0xa4, 0x25, 0x82, 0xf5, 0x82, 0xe5, 0xf0, 0x35, 0x83, 0xf5, 0x83, //0x86a0,
  2446. 0x22, 0xd0, 0x83, 0xd0, 0x82, 0xf8, 0xe4, 0x93, 0x70, 0x12, 0x74, 0x01, 0x93, 0x70, 0x0d, 0xa3, //0x86b0,
  2447. 0xa3, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf5, 0x82, 0x88, 0x83, 0xe4, 0x73, 0x74, 0x02, 0x93, 0x68, //0x86c0,
  2448. 0x60, 0xef, 0xa3, 0xa3, 0xa3, 0x80, 0xdf, 0x90, 0x38, 0x04, 0x78, 0x52, 0x12, 0x0b, 0xfd, 0x90, //0x86d0,
  2449. 0x38, 0x00, 0xe0, 0xfe, 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x10, //0x86e0,
  2450. 0x12, 0x0b, 0x92, 0x90, 0x38, 0x06, 0x78, 0x54, 0x12, 0x0b, 0xfd, 0x90, 0x38, 0x02, 0xe0, 0xfe, //0x86f0,
  2451. 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x12, 0x12, 0x0b, 0x92, 0xa3, //0x8700,
  2452. 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x52, 0x79, 0x52, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x14, 0xe0, 0xb4, //0x8710,
  2453. 0x71, 0x15, 0x78, 0x52, 0xe6, 0xfe, 0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, //0x8720,
  2454. 0xf9, 0x79, 0x53, 0xf7, 0xee, 0x19, 0xf7, 0x90, 0x38, 0x15, 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x54, //0x8730,
  2455. 0x79, 0x54, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x15, 0xe0, 0xb4, 0x71, 0x15, 0x78, 0x54, 0xe6, 0xfe, //0x8740,
  2456. 0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0x79, 0x55, 0xf7, 0xee, 0x19, //0x8750,
  2457. 0xf7, 0x79, 0x52, 0x12, 0x0b, 0xd9, 0x09, 0x12, 0x0b, 0xd9, 0xaf, 0x47, 0x12, 0x0b, 0xb2, 0xe5, //0x8760,
  2458. 0x44, 0xfb, 0x7a, 0x00, 0xfd, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x5a, 0xa6, 0x06, 0x08, 0xa6, //0x8770,
  2459. 0x07, 0xaf, 0x45, 0x12, 0x0b, 0xb2, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x56, 0xa6, //0x8780,
  2460. 0x06, 0x08, 0xa6, 0x07, 0xaf, 0x48, 0x78, 0x54, 0x12, 0x0b, 0xb4, 0xe5, 0x43, 0xfb, 0xfd, 0x7c, //0x8790,
  2461. 0x00, 0x12, 0x04, 0xd3, 0x78, 0x5c, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xaf, 0x46, 0x7e, 0x00, 0x78, //0x87a0,
  2462. 0x54, 0x12, 0x0b, 0xb6, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x58, 0xa6, 0x06, 0x08, //0x87b0,
  2463. 0xa6, 0x07, 0xc3, 0x78, 0x5b, 0xe6, 0x94, 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, 0x00, //0x87c0,
  2464. 0x08, 0x76, 0x08, 0xc3, 0x78, 0x5d, 0xe6, 0x94, 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, //0x87d0,
  2465. 0x00, 0x08, 0x76, 0x08, 0x78, 0x5a, 0x12, 0x0b, 0xc6, 0xff, 0xd3, 0x78, 0x57, 0xe6, 0x9f, 0x18, //0x87e0,
  2466. 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5a, 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x57, 0x12, 0x0c, 0x08, //0x87f0,
  2467. 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x78, 0x5e, 0x12, 0x0b, 0xbe, 0xff, 0xd3, 0x78, 0x59, 0xe6, //0x8800,
  2468. 0x9f, 0x18, 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5c, 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x59, 0x12, //0x8810,
  2469. 0x0c, 0x08, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0xe4, 0xfc, 0xfd, 0x78, 0x62, 0x12, 0x06, 0x99, //0x8820,
  2470. 0x78, 0x5a, 0x12, 0x0b, 0xc6, 0x78, 0x57, 0x26, 0xff, 0xee, 0x18, 0x36, 0xfe, 0x78, 0x66, 0x12, //0x8830,
  2471. 0x0b, 0xbe, 0x78, 0x59, 0x26, 0xff, 0xee, 0x18, 0x36, 0xfe, 0xe4, 0xfc, 0xfd, 0x78, 0x6a, 0x12, //0x8840,
  2472. 0x06, 0x99, 0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x08, //0x8850,
  2473. 0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x99, 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12, //0x8860,
  2474. 0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x0a, 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12, //0x8870,
  2475. 0x06, 0x99, 0x78, 0x61, 0xe6, 0x90, 0x60, 0x01, 0xf0, 0x78, 0x65, 0xe6, 0xa3, 0xf0, 0x78, 0x69, //0x8880,
  2476. 0xe6, 0xa3, 0xf0, 0x78, 0x55, 0xe6, 0xa3, 0xf0, 0x7d, 0x01, 0x78, 0x61, 0x12, 0x0b, 0xe9, 0x24, //0x8890,
  2477. 0x01, 0x12, 0x0b, 0xa6, 0x78, 0x65, 0x12, 0x0b, 0xe9, 0x24, 0x02, 0x12, 0x0b, 0xa6, 0x78, 0x69, //0x88a0,
  2478. 0x12, 0x0b, 0xe9, 0x24, 0x03, 0x12, 0x0b, 0xa6, 0x78, 0x6d, 0x12, 0x0b, 0xe9, 0x24, 0x04, 0x12, //0x88b0,
  2479. 0x0b, 0xa6, 0x0d, 0xbd, 0x05, 0xd4, 0xc2, 0x0e, 0xc2, 0x06, 0x22, 0x85, 0x08, 0x41, 0x90, 0x30, //0x88c0,
  2480. 0x24, 0xe0, 0xf5, 0x3d, 0xa3, 0xe0, 0xf5, 0x3e, 0xa3, 0xe0, 0xf5, 0x3f, 0xa3, 0xe0, 0xf5, 0x40, //0x88d0,
  2481. 0xa3, 0xe0, 0xf5, 0x3c, 0xd2, 0x34, 0xe5, 0x41, 0x12, 0x06, 0xb1, 0x09, 0x31, 0x03, 0x09, 0x35, //0x88e0,
  2482. 0x04, 0x09, 0x3b, 0x05, 0x09, 0x3e, 0x06, 0x09, 0x41, 0x07, 0x09, 0x4a, 0x08, 0x09, 0x5b, 0x12, //0x88f0,
  2483. 0x09, 0x73, 0x18, 0x09, 0x89, 0x19, 0x09, 0x5e, 0x1a, 0x09, 0x6a, 0x1b, 0x09, 0xad, 0x80, 0x09, //0x8900,
  2484. 0xb2, 0x81, 0x0a, 0x1d, 0x8f, 0x0a, 0x09, 0x90, 0x0a, 0x1d, 0x91, 0x0a, 0x1d, 0x92, 0x0a, 0x1d, //0x8910,
  2485. 0x93, 0x0a, 0x1d, 0x94, 0x0a, 0x1d, 0x98, 0x0a, 0x17, 0x9f, 0x0a, 0x1a, 0xec, 0x00, 0x00, 0x0a, //0x8920,
  2486. 0x38, 0x12, 0x0f, 0x74, 0x22, 0x12, 0x0f, 0x74, 0xd2, 0x03, 0x22, 0xd2, 0x03, 0x22, 0xc2, 0x03, //0x8930,
  2487. 0x22, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x02, 0x0a, 0x1d, 0xc2, 0x01, 0xc2, 0x02, 0xc2, 0x03, //0x8940,
  2488. 0x12, 0x0d, 0x0d, 0x75, 0x1e, 0x70, 0xd2, 0x35, 0x02, 0x0a, 0x1d, 0x02, 0x0a, 0x04, 0x85, 0x40, //0x8950,
  2489. 0x4a, 0x85, 0x3c, 0x4b, 0x12, 0x0a, 0xff, 0x02, 0x0a, 0x1d, 0x85, 0x4a, 0x40, 0x85, 0x4b, 0x3c, //0x8960,
  2490. 0x02, 0x0a, 0x1d, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x85, 0x40, 0x31, 0x85, 0x3f, 0x30, 0x85, 0x3e, //0x8970,
  2491. 0x2f, 0x85, 0x3d, 0x2e, 0x12, 0x0f, 0x46, 0x80, 0x1f, 0x75, 0x22, 0x00, 0x75, 0x23, 0x01, 0x74, //0x8980,
  2492. 0xff, 0xf5, 0x2d, 0xf5, 0x2c, 0xf5, 0x2b, 0xf5, 0x2a, 0x12, 0x0f, 0x46, 0x85, 0x2d, 0x40, 0x85, //0x8990,
  2493. 0x2c, 0x3f, 0x85, 0x2b, 0x3e, 0x85, 0x2a, 0x3d, 0xe4, 0xf5, 0x3c, 0x80, 0x70, 0x12, 0x0f, 0x16, //0x89a0,
  2494. 0x80, 0x6b, 0x85, 0x3d, 0x45, 0x85, 0x3e, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xe5, 0x45, 0xc3, //0x89b0,
  2495. 0x9f, 0x50, 0x02, 0x8f, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff, 0xe5, 0x46, 0xc3, 0x9f, 0x50, 0x02, //0x89c0,
  2496. 0x8f, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xfd, 0xe5, 0x45, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5, //0x89d0,
  2497. 0x44, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, 0x44, 0x9f, 0xf5, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff, //0x89e0,
  2498. 0xfd, 0xe5, 0x46, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5, 0x43, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, //0x89f0,
  2499. 0x43, 0x9f, 0xf5, 0x46, 0x12, 0x06, 0xd7, 0x80, 0x14, 0x85, 0x40, 0x48, 0x85, 0x3f, 0x47, 0x85, //0x8a00,
  2500. 0x3e, 0x46, 0x85, 0x3d, 0x45, 0x80, 0x06, 0x02, 0x06, 0xd7, 0x12, 0x0d, 0x7e, 0x90, 0x30, 0x24, //0x8a10,
  2501. 0xe5, 0x3d, 0xf0, 0xa3, 0xe5, 0x3e, 0xf0, 0xa3, 0xe5, 0x3f, 0xf0, 0xa3, 0xe5, 0x40, 0xf0, 0xa3, //0x8a20,
  2502. 0xe5, 0x3c, 0xf0, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, //0x8a30,
  2503. 0xd0, 0x90, 0x3f, 0x0c, 0xe0, 0xf5, 0x32, 0xe5, 0x32, 0x30, 0xe3, 0x74, 0x30, 0x36, 0x66, 0x90, //0x8a40,
  2504. 0x60, 0x19, 0xe0, 0xf5, 0x0a, 0xa3, 0xe0, 0xf5, 0x0b, 0x90, 0x60, 0x1d, 0xe0, 0xf5, 0x14, 0xa3, //0x8a50,
  2505. 0xe0, 0xf5, 0x15, 0x90, 0x60, 0x21, 0xe0, 0xf5, 0x0c, 0xa3, 0xe0, 0xf5, 0x0d, 0x90, 0x60, 0x29, //0x8a60,
  2506. 0xe0, 0xf5, 0x0e, 0xa3, 0xe0, 0xf5, 0x0f, 0x90, 0x60, 0x31, 0xe0, 0xf5, 0x10, 0xa3, 0xe0, 0xf5, //0x8a70,
  2507. 0x11, 0x90, 0x60, 0x39, 0xe0, 0xf5, 0x12, 0xa3, 0xe0, 0xf5, 0x13, 0x30, 0x01, 0x06, 0x30, 0x33, //0x8a80,
  2508. 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x09, 0x30, 0x02, 0x06, 0x30, 0x33, 0x03, 0xd3, 0x80, 0x01, //0x8a90,
  2509. 0xc3, 0x92, 0x0a, 0x30, 0x33, 0x0c, 0x30, 0x03, 0x09, 0x20, 0x02, 0x06, 0x20, 0x01, 0x03, 0xd3, //0x8aa0,
  2510. 0x80, 0x01, 0xc3, 0x92, 0x0b, 0x90, 0x30, 0x01, 0xe0, 0x44, 0x40, 0xf0, 0xe0, 0x54, 0xbf, 0xf0, //0x8ab0,
  2511. 0xe5, 0x32, 0x30, 0xe1, 0x14, 0x30, 0x34, 0x11, 0x90, 0x30, 0x22, 0xe0, 0xf5, 0x08, 0xe4, 0xf0, //0x8ac0,
  2512. 0x30, 0x00, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x08, 0xe5, 0x32, 0x30, 0xe5, 0x12, 0x90, 0x56, //0x8ad0,
  2513. 0xa1, 0xe0, 0xf5, 0x09, 0x30, 0x31, 0x09, 0x30, 0x05, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x0d, //0x8ae0,
  2514. 0x90, 0x3f, 0x0c, 0xe5, 0x32, 0xf0, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, //0x8af0,
  2515. 0x0e, 0x7e, 0xe4, 0x93, 0xfe, 0x74, 0x01, 0x93, 0xff, 0xc3, 0x90, 0x0e, 0x7c, 0x74, 0x01, 0x93, //0x8b00,
  2516. 0x9f, 0xff, 0xe4, 0x93, 0x9e, 0xfe, 0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0xab, //0x8b10,
  2517. 0x3b, 0xaa, 0x3a, 0xa9, 0x39, 0xa8, 0x38, 0xaf, 0x4b, 0xfc, 0xfd, 0xfe, 0x12, 0x05, 0x28, 0x12, //0x8b20,
  2518. 0x0d, 0xe1, 0xe4, 0x7b, 0xff, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0xb3, 0x12, 0x0d, 0xe1, 0x90, 0x0e, //0x8b30,
  2519. 0x69, 0xe4, 0x12, 0x0d, 0xf6, 0x12, 0x0d, 0xe1, 0xe4, 0x85, 0x4a, 0x37, 0xf5, 0x36, 0xf5, 0x35, //0x8b40,
  2520. 0xf5, 0x34, 0xaf, 0x37, 0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0xa3, 0x12, 0x0d, 0xf6, 0x8f, 0x37, //0x8b50,
  2521. 0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0xe5, 0x3b, 0x45, 0x37, 0xf5, 0x3b, 0xe5, 0x3a, 0x45, 0x36, //0x8b60,
  2522. 0xf5, 0x3a, 0xe5, 0x39, 0x45, 0x35, 0xf5, 0x39, 0xe5, 0x38, 0x45, 0x34, 0xf5, 0x38, 0xe4, 0xf5, //0x8b70,
  2523. 0x22, 0xf5, 0x23, 0x85, 0x3b, 0x31, 0x85, 0x3a, 0x30, 0x85, 0x39, 0x2f, 0x85, 0x38, 0x2e, 0x02, //0x8b80,
  2524. 0x0f, 0x46, 0xe0, 0xa3, 0xe0, 0x75, 0xf0, 0x02, 0xa4, 0xff, 0xae, 0xf0, 0xc3, 0x08, 0xe6, 0x9f, //0x8b90,
  2525. 0xf6, 0x18, 0xe6, 0x9e, 0xf6, 0x22, 0xff, 0xe5, 0xf0, 0x34, 0x60, 0x8f, 0x82, 0xf5, 0x83, 0xec, //0x8ba0,
  2526. 0xf0, 0x22, 0x78, 0x52, 0x7e, 0x00, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x02, 0x04, 0xc1, 0xe4, 0xfc, //0x8bb0,
  2527. 0xfd, 0x12, 0x06, 0x99, 0x78, 0x5c, 0xe6, 0xc3, 0x13, 0xfe, 0x08, 0xe6, 0x13, 0x22, 0x78, 0x52, //0x8bc0,
  2528. 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0xe4, 0xfc, 0xfd, 0x22, 0xe7, 0xc4, 0xf8, 0x54, 0xf0, 0xc8, 0x68, //0x8bd0,
  2529. 0xf7, 0x09, 0xe7, 0xc4, 0x54, 0x0f, 0x48, 0xf7, 0x22, 0xe6, 0xfc, 0xed, 0x75, 0xf0, 0x04, 0xa4, //0x8be0,
  2530. 0x22, 0x12, 0x06, 0x7c, 0x8f, 0x48, 0x8e, 0x47, 0x8d, 0x46, 0x8c, 0x45, 0x22, 0xe0, 0xfe, 0xa3, //0x8bf0,
  2531. 0xe0, 0xfd, 0xee, 0xf6, 0xed, 0x08, 0xf6, 0x22, 0x13, 0xff, 0xc3, 0xe6, 0x9f, 0xff, 0x18, 0xe6, //0x8c00,
  2532. 0x9e, 0xfe, 0x22, 0xe6, 0xc3, 0x13, 0xf7, 0x08, 0xe6, 0x13, 0x09, 0xf7, 0x22, 0xad, 0x39, 0xac, //0x8c10,
  2533. 0x38, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0x28, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0xab, //0x8c20,
  2534. 0x37, 0xaa, 0x36, 0xa9, 0x35, 0xa8, 0x34, 0x22, 0x93, 0xff, 0xe4, 0xfc, 0xfd, 0xfe, 0x12, 0x05, //0x8c30,
  2535. 0x28, 0x8f, 0x37, 0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0x22, 0x78, 0x84, 0xe6, 0xfe, 0x08, 0xe6, //0x8c40,
  2536. 0xff, 0xe4, 0x8f, 0x37, 0x8e, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0x22, 0x90, 0x0e, 0x8c, 0xe4, 0x93, //0x8c50,
  2537. 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe6, 0xfe, 0x08, 0xe6, 0xff, //0x8c60,
  2538. 0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0x22, 0x78, 0x4e, 0xe6, 0xfe, 0x08, 0xe6, //0x8c70,
  2539. 0xff, 0x22, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x22, 0x78, 0x89, //0x8c80,
  2540. 0xef, 0x26, 0xf6, 0x18, 0xe4, 0x36, 0xf6, 0x22, 0x75, 0x89, 0x03, 0x75, 0xa8, 0x01, 0x75, 0xb8, //0x8c90,
  2541. 0x04, 0x75, 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x15, 0x75, 0x37, 0x0d, 0x12, 0x0e, 0x9a, //0x8ca0,
  2542. 0x12, 0x00, 0x09, 0x12, 0x0f, 0x16, 0x12, 0x00, 0x06, 0xd2, 0x00, 0xd2, 0x34, 0xd2, 0xaf, 0x75, //0x8cb0,
  2543. 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x49, 0x75, 0x37, 0x03, 0x12, 0x0e, 0x9a, 0x30, 0x08, //0x8cc0,
  2544. 0x09, 0xc2, 0x34, 0x12, 0x08, 0xcb, 0xc2, 0x08, 0xd2, 0x34, 0x30, 0x0b, 0x09, 0xc2, 0x36, 0x12, //0x8cd0,
  2545. 0x02, 0x6c, 0xc2, 0x0b, 0xd2, 0x36, 0x30, 0x09, 0x09, 0xc2, 0x36, 0x12, 0x00, 0x0e, 0xc2, 0x09, //0x8ce0,
  2546. 0xd2, 0x36, 0x30, 0x0e, 0x03, 0x12, 0x06, 0xd7, 0x30, 0x35, 0xd3, 0x90, 0x30, 0x29, 0xe5, 0x1e, //0x8cf0,
  2547. 0xf0, 0xb4, 0x10, 0x05, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0xc2, 0x35, 0x80, 0xc1, 0xe4, 0xf5, 0x4b, //0x8d00,
  2548. 0x90, 0x0e, 0x7a, 0x93, 0xff, 0xe4, 0x8f, 0x37, 0xf5, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0xaf, 0x37, //0x8d10,
  2549. 0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0x90, 0x0e, 0x6a, 0x12, 0x0d, 0xf6, 0x8f, 0x37, 0x8e, 0x36, //0x8d20,
  2550. 0x8d, 0x35, 0x8c, 0x34, 0x90, 0x0e, 0x72, 0x12, 0x06, 0x7c, 0xef, 0x45, 0x37, 0xf5, 0x37, 0xee, //0x8d30,
  2551. 0x45, 0x36, 0xf5, 0x36, 0xed, 0x45, 0x35, 0xf5, 0x35, 0xec, 0x45, 0x34, 0xf5, 0x34, 0xe4, 0xf5, //0x8d40,
  2552. 0x22, 0xf5, 0x23, 0x85, 0x37, 0x31, 0x85, 0x36, 0x30, 0x85, 0x35, 0x2f, 0x85, 0x34, 0x2e, 0x12, //0x8d50,
  2553. 0x0f, 0x46, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x72, 0x12, 0x0d, 0xea, 0x12, 0x0f, 0x46, //0x8d60,
  2554. 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x6e, 0x12, 0x0d, 0xea, 0x02, 0x0f, 0x46, 0xe5, 0x40, //0x8d70,
  2555. 0x24, 0xf2, 0xf5, 0x37, 0xe5, 0x3f, 0x34, 0x43, 0xf5, 0x36, 0xe5, 0x3e, 0x34, 0xa2, 0xf5, 0x35, //0x8d80,
  2556. 0xe5, 0x3d, 0x34, 0x28, 0xf5, 0x34, 0xe5, 0x37, 0xff, 0xe4, 0xfe, 0xfd, 0xfc, 0x78, 0x18, 0x12, //0x8d90,
  2557. 0x06, 0x69, 0x8f, 0x40, 0x8e, 0x3f, 0x8d, 0x3e, 0x8c, 0x3d, 0xe5, 0x37, 0x54, 0xa0, 0xff, 0xe5, //0x8da0,
  2558. 0x36, 0xfe, 0xe4, 0xfd, 0xfc, 0x78, 0x07, 0x12, 0x06, 0x56, 0x78, 0x10, 0x12, 0x0f, 0x9a, 0xe4, //0x8db0,
  2559. 0xff, 0xfe, 0xe5, 0x35, 0xfd, 0xe4, 0xfc, 0x78, 0x0e, 0x12, 0x06, 0x56, 0x12, 0x0f, 0x9d, 0xe4, //0x8dc0,
  2560. 0xff, 0xfe, 0xfd, 0xe5, 0x34, 0xfc, 0x78, 0x18, 0x12, 0x06, 0x56, 0x78, 0x08, 0x12, 0x0f, 0x9a, //0x8dd0,
  2561. 0x22, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0x22, 0x12, 0x06, 0x7c, 0x8f, 0x31, 0x8e, //0x8de0,
  2562. 0x30, 0x8d, 0x2f, 0x8c, 0x2e, 0x22, 0x93, 0xf9, 0xf8, 0x02, 0x06, 0x69, 0x00, 0x00, 0x00, 0x00, //0x8df0,
  2563. 0x12, 0x01, 0x17, 0x08, 0x31, 0x15, 0x53, 0x54, 0x44, 0x20, 0x20, 0x20, 0x20, 0x20, 0x13, 0x01, //0x8e00,
  2564. 0x10, 0x01, 0x56, 0x40, 0x1a, 0x30, 0x29, 0x7e, 0x00, 0x30, 0x04, 0x20, 0xdf, 0x30, 0x05, 0x40, //0x8e10,
  2565. 0xbf, 0x50, 0x03, 0x00, 0xfd, 0x50, 0x27, 0x01, 0xfe, 0x60, 0x00, 0x11, 0x00, 0x3f, 0x05, 0x30, //0x8e20,
  2566. 0x00, 0x3f, 0x06, 0x22, 0x00, 0x3f, 0x01, 0x2a, 0x00, 0x3f, 0x02, 0x00, 0x00, 0x36, 0x06, 0x07, //0x8e30,
  2567. 0x00, 0x3f, 0x0b, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x40, 0xbf, 0x30, 0x01, 0x00, //0x8e40,
  2568. 0xbf, 0x30, 0x29, 0x70, 0x00, 0x3a, 0x00, 0x00, 0xff, 0x3a, 0x00, 0x00, 0xff, 0x36, 0x03, 0x36, //0x8e50,
  2569. 0x02, 0x41, 0x44, 0x58, 0x20, 0x18, 0x10, 0x0a, 0x04, 0x04, 0x00, 0x03, 0xff, 0x64, 0x00, 0x00, //0x8e60,
  2570. 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x06, 0x00, 0x03, 0x51, 0x00, 0x7a, //0x8e70,
  2571. 0x50, 0x3c, 0x28, 0x1e, 0x10, 0x10, 0x50, 0x2d, 0x28, 0x16, 0x10, 0x10, 0x02, 0x00, 0x10, 0x0c, //0x8e80,
  2572. 0x10, 0x04, 0x0c, 0x6e, 0x06, 0x05, 0x00, 0xa5, 0x5a, 0x00, 0xae, 0x35, 0xaf, 0x36, 0xe4, 0xfd, //0x8e90,
  2573. 0xed, 0xc3, 0x95, 0x37, 0x50, 0x33, 0x12, 0x0f, 0xe2, 0xe4, 0x93, 0xf5, 0x38, 0x74, 0x01, 0x93, //0x8ea0,
  2574. 0xf5, 0x39, 0x45, 0x38, 0x60, 0x23, 0x85, 0x39, 0x82, 0x85, 0x38, 0x83, 0xe0, 0xfc, 0x12, 0x0f, //0x8eb0,
  2575. 0xe2, 0x74, 0x03, 0x93, 0x52, 0x04, 0x12, 0x0f, 0xe2, 0x74, 0x02, 0x93, 0x42, 0x04, 0x85, 0x39, //0x8ec0,
  2576. 0x82, 0x85, 0x38, 0x83, 0xec, 0xf0, 0x0d, 0x80, 0xc7, 0x22, 0x78, 0xbe, 0xe6, 0xd3, 0x08, 0xff, //0x8ed0,
  2577. 0xe6, 0x64, 0x80, 0xf8, 0xef, 0x64, 0x80, 0x98, 0x22, 0x93, 0xff, 0x7e, 0x00, 0xe6, 0xfc, 0x08, //0x8ee0,
  2578. 0xe6, 0xfd, 0x12, 0x04, 0xc1, 0x78, 0xc1, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0xd3, 0xef, 0x9d, 0xee, //0x8ef0,
  2579. 0x9c, 0x22, 0x78, 0xbd, 0xd3, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x22, 0x25, 0xe0, 0x24, 0x0a, 0xf8, //0x8f00,
  2580. 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe5, 0x3c, 0xd3, 0x94, 0x00, 0x40, 0x0b, 0x90, 0x0e, 0x88, //0x8f10,
  2581. 0x12, 0x0b, 0xf1, 0x90, 0x0e, 0x86, 0x80, 0x09, 0x90, 0x0e, 0x82, 0x12, 0x0b, 0xf1, 0x90, 0x0e, //0x8f20,
  2582. 0x80, 0xe4, 0x93, 0xf5, 0x44, 0xa3, 0xe4, 0x93, 0xf5, 0x43, 0xd2, 0x06, 0x30, 0x06, 0x03, 0xd3, //0x8f30,
  2583. 0x80, 0x01, 0xc3, 0x92, 0x0e, 0x22, 0xa2, 0xaf, 0x92, 0x32, 0xc2, 0xaf, 0xe5, 0x23, 0x45, 0x22, //0x8f40,
  2584. 0x90, 0x0e, 0x5d, 0x60, 0x0e, 0x12, 0x0f, 0xcb, 0xe0, 0xf5, 0x2c, 0x12, 0x0f, 0xc8, 0xe0, 0xf5, //0x8f50,
  2585. 0x2d, 0x80, 0x0c, 0x12, 0x0f, 0xcb, 0xe5, 0x30, 0xf0, 0x12, 0x0f, 0xc8, 0xe5, 0x31, 0xf0, 0xa2, //0x8f60,
  2586. 0x32, 0x92, 0xaf, 0x22, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, //0x8f70,
  2587. 0x33, 0xd2, 0x36, 0xd2, 0x01, 0xc2, 0x02, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0x22, //0x8f80,
  2588. 0xfb, 0xd3, 0xed, 0x9b, 0x74, 0x80, 0xf8, 0x6c, 0x98, 0x22, 0x12, 0x06, 0x69, 0xe5, 0x40, 0x2f, //0x8f90,
  2589. 0xf5, 0x40, 0xe5, 0x3f, 0x3e, 0xf5, 0x3f, 0xe5, 0x3e, 0x3d, 0xf5, 0x3e, 0xe5, 0x3d, 0x3c, 0xf5, //0x8fa0,
  2590. 0x3d, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0x90, 0x3f, 0x0d, 0xe0, 0xf5, 0x33, 0xe5, 0x33, //0x8fb0,
  2591. 0xf0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, 0x0e, 0x5f, 0xe4, 0x93, 0xfe, 0x74, 0x01, //0x8fc0,
  2592. 0x93, 0xf5, 0x82, 0x8e, 0x83, 0x22, 0x78, 0x7f, 0xe4, 0xf6, 0xd8, 0xfd, 0x75, 0x81, 0xcd, 0x02, //0x8fd0,
  2593. 0x0c, 0x98, 0x8f, 0x82, 0x8e, 0x83, 0x75, 0xf0, 0x04, 0xed, 0x02, 0x06, 0xa5, //0x8fe0
  2594. };
  2595. static int ov5640_sensor_read(struct v4l2_subdev *sd, unsigned char *reg,
  2596. unsigned char *value)
  2597. {
  2598. struct i2c_client *client = v4l2_get_subdevdata(sd);
  2599. u8 data[REG_STEP];
  2600. struct i2c_msg msg;
  2601. int ret,i;
  2602. for(i = 0; i < REG_ADDR_STEP; i++)
  2603. data[i] = reg[i];
  2604. for(i = REG_ADDR_STEP; i < REG_STEP; i++)
  2605. data[i] = 0xff;
  2606. /*
  2607. * Send out the register address...
  2608. */
  2609. msg.addr = client->addr;
  2610. msg.flags = 0;
  2611. msg.len = REG_ADDR_STEP;
  2612. msg.buf = data;
  2613. ret = i2c_transfer(client->adapter, &msg, 1);
  2614. if (ret < 0) {
  2615. csi_dev_err("Error %d on register write\n", ret);
  2616. return ret;
  2617. }
  2618. /*
  2619. * ...then read back the result.
  2620. */
  2621. msg.flags = I2C_M_RD;
  2622. msg.len = REG_DATA_STEP;
  2623. msg.buf = &data[REG_ADDR_STEP];
  2624. ret = i2c_transfer(client->adapter, &msg, 1);
  2625. if (ret >= 0) {
  2626. for(i = 0; i < REG_DATA_STEP; i++)
  2627. value[i] = data[i+REG_ADDR_STEP];
  2628. ret = 0;
  2629. }
  2630. else {
  2631. csi_dev_err("Error %d on register read\n", ret);
  2632. }
  2633. return ret;
  2634. }
  2635. static int ov5640_sensor_write(struct v4l2_subdev *sd, unsigned char *reg,
  2636. unsigned char *value)
  2637. {
  2638. struct i2c_client *client = v4l2_get_subdevdata(sd);
  2639. struct i2c_msg msg;
  2640. unsigned char data[REG_STEP];
  2641. int ret,i;
  2642. for(i = 0; i < REG_ADDR_STEP; i++)
  2643. data[i] = reg[i];
  2644. for(i = REG_ADDR_STEP; i < REG_STEP; i++)
  2645. data[i] = value[i-REG_ADDR_STEP];
  2646. msg.addr = client->addr;
  2647. msg.flags = 0;
  2648. msg.len = REG_STEP;
  2649. msg.buf = data;
  2650. ret = i2c_transfer(client->adapter, &msg, 1);
  2651. if (ret > 0) {
  2652. ret = 0;
  2653. }
  2654. else if (ret < 0) {
  2655. csi_dev_print("addr = 0x%4x, value = 0x%2x\n ",reg[0]*256+reg[1],value[0]);
  2656. csi_dev_err("sensor_write error!\n");
  2657. }
  2658. return ret;
  2659. }
  2660. #if 0
  2661. static int sensor_write_im(struct v4l2_subdev *sd, unsigned int addr,
  2662. unsigned char value)
  2663. {
  2664. struct i2c_client *client = v4l2_get_subdevdata(sd);
  2665. struct i2c_msg msg;
  2666. unsigned char data[REG_STEP];
  2667. int ret;
  2668. unsigned int retry=0;
  2669. data[0] = (addr&0xff00)>>8;
  2670. data[1] = addr&0x00ff;
  2671. data[2] = value;
  2672. msg.addr = client->addr;
  2673. msg.flags = 0;
  2674. msg.len = REG_STEP;
  2675. msg.buf = data;
  2676. sensor_write_im_transfer:
  2677. ret = i2c_transfer(client->adapter, &msg, 1);
  2678. if (ret > 0) {
  2679. ret = 0;
  2680. }
  2681. else if (ret < 0) {
  2682. if(retry<3) {
  2683. retry++;
  2684. csi_dev_err("sensor_write retry %d!\n",retry);
  2685. goto sensor_write_im_transfer;
  2686. }
  2687. csi_dev_err("addr = 0x%4x, value = 0x%4x\n ",addr,value);
  2688. csi_dev_err("sensor_write error!\n");
  2689. }
  2690. return ret;
  2691. }
  2692. #endif
  2693. static int ov5640_sensor_write_array(struct v4l2_subdev *sd, struct regval_list *vals , uint size)
  2694. {
  2695. int i,ret;
  2696. unsigned int cnt;
  2697. // unsigned char rd;
  2698. if (size == 0)
  2699. return -EINVAL;
  2700. for(i = 0; i < size ; i++)
  2701. {
  2702. if(vals->reg_num[0] == 0xff && vals->reg_num[1] == 0xff) {
  2703. mdelay(vals->value[0]);
  2704. }
  2705. else {
  2706. cnt=0;
  2707. ret = ov5640_sensor_write(sd, vals->reg_num, vals->value);
  2708. while( ret < 0 && cnt < 3)
  2709. {
  2710. if(ret<0)
  2711. csi_dev_err("sensor_write_err!\n");
  2712. ret = ov5640_sensor_write(sd, vals->reg_num, vals->value);
  2713. cnt++;
  2714. }
  2715. if(cnt>0)
  2716. csi_dev_err("csi i2c retry cnt=%d\n",cnt);
  2717. if(ret<0 && cnt >=3)
  2718. return ret;
  2719. }
  2720. vals++;
  2721. }
  2722. return 0;
  2723. }
  2724. static int ov5640_sensor_write_continuous(struct v4l2_subdev *sd, int addr, char vals[] , uint size)
  2725. {
  2726. int i,ret;
  2727. struct regval_list reg_addr;
  2728. if (size == 0)
  2729. return -EINVAL;
  2730. for(i = 0; i < size ; i++)
  2731. {
  2732. reg_addr.reg_num[0] = (addr&0xff00)>>8;
  2733. reg_addr.reg_num[1] = (addr&0x00ff);
  2734. ret = ov5640_sensor_write(sd, reg_addr.reg_num, &vals[i]);
  2735. if (ret < 0)
  2736. {
  2737. csi_dev_err("sensor_write_err!\n");
  2738. return ret;
  2739. }
  2740. addr++;
  2741. }
  2742. return 0;
  2743. }
  2744. /* stuff about auto focus */
  2745. static int ov5640_sensor_download_af_fw(struct v4l2_subdev *sd)
  2746. {
  2747. int ret,cnt;
  2748. struct regval_list regs;
  2749. struct regval_list af_fw_reset_reg[] = {
  2750. {
  2751. {0x30,0x00},{0x20}},
  2752. };
  2753. struct regval_list af_fw_start_reg[] = {
  2754. {
  2755. {0x30,0x22},{0x00}},
  2756. {
  2757. {0x30,0x23},{0x00}},
  2758. {
  2759. {0x30,0x24},{0x00}},
  2760. {
  2761. {0x30,0x25},{0x00}},
  2762. {
  2763. {0x30,0x26},{0x00}},
  2764. {
  2765. {0x30,0x27},{0x00}},
  2766. {
  2767. {0x30,0x28},{0x00}},
  2768. {
  2769. {0x30,0x29},{0x7f}},//0x7f
  2770. {
  2771. {0x30,0x00},{0x00}}, //start firmware for af
  2772. };
  2773. //reset sensor MCU
  2774. ret = ov5640_sensor_write_array(sd, af_fw_reset_reg, ARRAY_SIZE(af_fw_reset_reg));
  2775. if(ret < 0) {
  2776. csi_dev_err("reset sensor MCU error\n");
  2777. return ret;
  2778. }
  2779. //download af fw
  2780. ret =ov5640_sensor_write_continuous(sd, 0x8000, ov5640_sensor_af_fw_regs, ARRAY_SIZE(ov5640_sensor_af_fw_regs));
  2781. if(ret < 0) {
  2782. csi_dev_err("download af fw error\n");
  2783. return ret;
  2784. }
  2785. //start af firmware
  2786. ret = ov5640_sensor_write_array(sd, af_fw_start_reg, ARRAY_SIZE(af_fw_start_reg));
  2787. if(ret < 0) {
  2788. csi_dev_err("start af firmware error\n");
  2789. return ret;
  2790. }
  2791. mdelay(10);
  2792. //check the af firmware status
  2793. regs.reg_num[0] = 0x30;
  2794. regs.reg_num[1] = 0x29;
  2795. regs.value[0] = 0xff;
  2796. cnt = 0;
  2797. while(regs.value[0]!=0x70) {
  2798. mdelay(5);
  2799. ret = ov5640_sensor_read(sd, regs.reg_num, regs.value);
  2800. if (ret < 0)
  2801. {
  2802. csi_dev_err("sensor check the af firmware status err !\n");
  2803. return ret;
  2804. }
  2805. cnt++;
  2806. if(cnt > 200) {
  2807. csi_dev_err("AF firmware check status time out !\n");
  2808. return -EFAULT;
  2809. }
  2810. }
  2811. csi_dev_print("AF firmware check status complete,0x3029 = 0x%x\n",regs.value[0]);
  2812. #if DEV_DBG_EN == 1
  2813. regs.reg_num[0] = 0x30;
  2814. regs.reg_num[1] = 0x00;
  2815. ov5640_sensor_read(sd, regs.reg_num, regs.value);
  2816. csi_dev_print("0x3000 = 0x%x\n",regs.value[0]);
  2817. regs.reg_num[0] = 0x30;
  2818. regs.reg_num[1] = 0x04;
  2819. ov5640_sensor_read(sd, regs.reg_num, regs.value);
  2820. csi_dev_print("0x3004 = 0x%x\n",regs.value[0]);
  2821. regs.reg_num[0] = 0x30;
  2822. regs.reg_num[1] = 0x01;
  2823. ov5640_sensor_read(sd, regs.reg_num, regs.value);
  2824. csi_dev_print("0x3001 = 0x%x\n",regs.value[0]);
  2825. regs.reg_num[0] = 0x30;
  2826. regs.reg_num[1] = 0x05;
  2827. ov5640_sensor_read(sd, regs.reg_num, regs.value);
  2828. csi_dev_print("0x3005 = 0x%x\n",regs.value[0]);
  2829. #endif
  2830. return 0;
  2831. }
  2832. static int ov5640_sensor_s_release_af(struct v4l2_subdev *sd)
  2833. {
  2834. struct regval_list regs;
  2835. int ret;
  2836. //release focus
  2837. csi_dev_print("sensor_s_release_af\n");
  2838. //trig single af
  2839. regs.reg_num[0] = 0x30;
  2840. regs.reg_num[1] = 0x22;
  2841. regs.value[0] = 0x03;
  2842. ret = ov5640_sensor_write(sd, regs.reg_num, regs.value);
  2843. if (ret < 0)
  2844. {
  2845. csi_dev_err("sensor tigger single af err !\n");
  2846. return ret;
  2847. }
  2848. //release single af
  2849. regs.reg_num[0] = 0x30;
  2850. regs.reg_num[1] = 0x22;
  2851. regs.value[0] = 0x08;
  2852. ret = ov5640_sensor_write(sd, regs.reg_num, regs.value);
  2853. if (ret < 0)
  2854. {
  2855. csi_dev_err("release focus err !\n");
  2856. return ret;
  2857. }
  2858. return 0;
  2859. }
  2860. static int ov5640_sensor_s_af_zone(struct v4l2_subdev *sd, unsigned int xc, unsigned int yc)
  2861. {
  2862. //struct sensor_info *info = to_state(sd);
  2863. struct regval_list regs;
  2864. int ret;
  2865. csi_dev_print("sensor_s_af_zone\n");
  2866. csi_dev_print("af zone input xc=%d,yc=%d\n",xc,yc);
  2867. #if 0
  2868. if(info->width == 0 || info->height == 0) {
  2869. csi_dev_err("current width or height is zero!\n");
  2870. return -EINVAL;
  2871. }
  2872. #endif
  2873. xc = xc * 80 /640;
  2874. yc = yc * 60 / 480;
  2875. //csi_dev_dbg("af zone after xc=%d,yc=%d\n",xc,yc);
  2876. //set x center
  2877. regs.reg_num[0] = 0x30;
  2878. regs.reg_num[1] = 0x24;
  2879. regs.value[0] = xc;
  2880. ret = ov5640_sensor_write(sd, regs.reg_num, regs.value);
  2881. if (ret < 0)
  2882. {
  2883. csi_dev_err("sensor_s_af_zone_xc error!\n");
  2884. return ret;
  2885. }
  2886. //set y center
  2887. regs.reg_num[0] = 0x30;
  2888. regs.reg_num[1] = 0x25;
  2889. regs.value[0] = yc;
  2890. ret = ov5640_sensor_write(sd, regs.reg_num, regs.value);
  2891. if (ret < 0)
  2892. {
  2893. csi_dev_err("sensor_s_af_zone_yc error!\n");
  2894. return ret;
  2895. }
  2896. //set af zone
  2897. regs.reg_num[0] = 0x30;
  2898. regs.reg_num[1] = 0x22;
  2899. regs.value[0] = 0x81;
  2900. ret = ov5640_sensor_write(sd, regs.reg_num, regs.value);
  2901. if (ret < 0)
  2902. {
  2903. csi_dev_err("sensor_s_af_zone error!\n");
  2904. return ret;
  2905. }
  2906. mdelay(5);
  2907. return 0;
  2908. }
  2909. static int ov5640_sensor_s_pause_af(struct v4l2_subdev *sd)
  2910. {
  2911. struct regval_list regs;
  2912. int ret;
  2913. //pause af poisition
  2914. csi_dev_print("sensor_s_pause_af\n");
  2915. regs.reg_num[0] = 0x30;
  2916. regs.reg_num[1] = 0x22;
  2917. regs.value[0] = 0x06;
  2918. ret = ov5640_sensor_write(sd, regs.reg_num, regs.value);
  2919. if (ret < 0)
  2920. {
  2921. csi_dev_err("sensor pause af err !\n");
  2922. return ret;
  2923. }
  2924. mdelay(5);
  2925. return 0;
  2926. }
  2927. static int ov5640_get_auto_focus_result(struct v4l2_subdev *sd,
  2928. struct v4l2_control *ctrl)
  2929. {
  2930. struct regval_list regs;
  2931. int ret,cnt;
  2932. regs.reg_num[0] = 0x30;
  2933. regs.reg_num[1] = 0x23;
  2934. regs.value[0] = 0xff;
  2935. cnt = 0;
  2936. //dg add 2015-07-13 0x3022 register:
  2937. // 0x03 - Trig Single Auto Focus
  2938. // 0x06 - Pause Auto Focus
  2939. // 0x08 - Release Focus
  2940. // 0x12 - Re-launch Focus Zones
  2941. // 0x00 – command is finished
  2942. //send idle command to firmware
  2943. OV5640YUV_write_cmos_sensor(0x3023,0x01);
  2944. OV5640YUV_write_cmos_sensor(0x3022,0x06); //pause auto focus
  2945. //wait for af pause complete
  2946. regs.reg_num[0] = 0x30;
  2947. regs.reg_num[1] = 0x29;//dg change 0x23 to 0x29;
  2948. regs.value[0] = 0xff;
  2949. cnt = 0;
  2950. while(regs.value[0]!=0x10)// dg change 0x00 to 0x10
  2951. {
  2952. mdelay(50);
  2953. ret = ov5640_sensor_read(sd, regs.reg_num, regs.value);
  2954. if (ret < 0)
  2955. {
  2956. csi_dev_err("sensor get af pause status err !\n");
  2957. return ret;
  2958. }
  2959. cnt++;
  2960. if(cnt>1000) {
  2961. csi_dev_err("Single AF pause is timeout,value = 0x%x\n",regs.value[0]);
  2962. return -EFAULT;
  2963. }
  2964. }
  2965. printk("pause focus ok.....................");
  2966. //ov5640_sensor_s_af_zone(sd, 640, 480);
  2967. ctrl->value = AUTO_FOCUS_DONE;
  2968. return 0;
  2969. }
  2970. static int ov5640_sensor_s_single_af(struct v4l2_subdev *sd)
  2971. {
  2972. struct regval_list regs;
  2973. int ret;
  2974. csi_dev_print("sensor_s_single_af\n");
  2975. #if 1
  2976. //trig single af
  2977. regs.reg_num[0] = 0x30;
  2978. regs.reg_num[1] = 0x23;
  2979. regs.value[0] = 0x01;
  2980. ret = ov5640_sensor_write(sd, regs.reg_num, regs.value);
  2981. if (ret < 0)
  2982. {
  2983. csi_dev_err("sensor tigger single af err !\n");
  2984. return ret;
  2985. }
  2986. #endif
  2987. regs.reg_num[0] = 0x30;
  2988. regs.reg_num[1] = 0x22;
  2989. regs.value[0] = 0x03;
  2990. ret = ov5640_sensor_write(sd, regs.reg_num, regs.value);
  2991. if (ret < 0)
  2992. {
  2993. csi_dev_err("sensor tigger single af err !\n");
  2994. return ret;
  2995. }
  2996. #if 1
  2997. //wait for af complete
  2998. regs.reg_num[0] = 0x30;
  2999. regs.reg_num[1] = 0x29;//dg change 0x23 to 0x29;
  3000. regs.value[0] = 0xff;
  3001. int cnt = 0;
  3002. while(regs.value[0]!=0x10)// dg change 0x00 to 0x10)
  3003. {
  3004. mdelay(50);
  3005. ret = ov5640_sensor_read(sd, regs.reg_num, regs.value);
  3006. if (ret < 0)
  3007. {
  3008. csi_dev_err("sensor get af status err !\n");
  3009. return ret;
  3010. }
  3011. cnt++;
  3012. if(cnt>100) {
  3013. csi_dev_err("Single AF is timeout,value = 0x%x\n",regs.value[0]);
  3014. return -EFAULT;
  3015. }
  3016. }
  3017. #else
  3018. ;
  3019. #endif
  3020. csi_dev_print("Single AF is complete,value = 0x%x\n",regs.value[0]);
  3021. return 0;
  3022. }
  3023. /* end add */
  3024. static inline struct ov5640_priv *to_ov5640(const struct i2c_client *client)
  3025. {
  3026. return container_of(i2c_get_clientdata(client), struct ov5640_priv, subdev);
  3027. }
  3028. static int write_regs(struct i2c_client *client,
  3029. const struct regval *regs, int array_len)
  3030. {
  3031. int i;
  3032. int ret = 0;
  3033. for (i = 0; i < array_len; i++) {
  3034. if ((ret = i2cc_set_reg(client, regs->reg, regs->val))) {
  3035. OV_ERR("error to set reg:0x%d -> value:%d(index:%d)\n", regs->reg,
  3036. regs->val, i);
  3037. break;
  3038. }
  3039. regs++;
  3040. }
  3041. // INFO_BLUE("------*------- write array regs over -------*------ \n");
  3042. return (ret);
  3043. }
  3044. static int ov5640_set_bus_param(struct soc_camera_device *icd,
  3045. unsigned long flags)
  3046. {
  3047. INFO_PURLPLE("\n");
  3048. return 0;
  3049. }
  3050. static unsigned long ov5640_query_bus_param(struct soc_camera_device *icd)
  3051. {
  3052. struct soc_camera_link *icl = to_soc_camera_link(icd);
  3053. /* camera can do 10 bit transfers, but omit it now */
  3054. unsigned long flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_MASTER |
  3055. SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_HIGH |
  3056. SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8;
  3057. return soc_camera_apply_sensor_flags(icl, flags);
  3058. }
  3059. static int ov5640_g_chip_ident(struct v4l2_subdev *sd,
  3060. struct v4l2_dbg_chip_ident *id)
  3061. {
  3062. struct i2c_client *client = v4l2_get_subdevdata(sd);
  3063. struct ov5640_priv *priv = to_ov5640(client);
  3064. id->ident = priv->model;
  3065. id->revision = 0;
  3066. return (0);
  3067. }
  3068. static const struct ov5640_win_size *select_win(
  3069. unsigned int width, unsigned int height)
  3070. {
  3071. const struct ov5640_win_size *ret = NULL;
  3072. int size = ARRAY_SIZE(ov5640_wins);
  3073. unsigned int diff = -1;
  3074. unsigned int tmp;
  3075. int i;
  3076. //width = 1600;
  3077. //height = 1200;
  3078. for (i = 0; i < size; i++) {
  3079. tmp = abs(width - ov5640_wins[i].width) +
  3080. abs(height - ov5640_wins[i].height);
  3081. if (tmp < diff) {
  3082. diff = tmp;
  3083. ret = ov5640_wins + i;
  3084. }
  3085. }
  3086. return (ret);
  3087. }
  3088. static int ov5640_try_fmt(struct v4l2_subdev *sd,
  3089. struct v4l2_mbus_framefmt *vmf)
  3090. {
  3091. struct i2c_client *client = v4l2_get_subdevdata(sd);
  3092. struct ov5640_priv *priv = to_ov5640(client);
  3093. const struct ov5640_win_size *win;
  3094. int found = 0;
  3095. int i;
  3096. win = select_win(vmf->width, vmf->height);
  3097. vmf->width = win->width;
  3098. vmf->height = win->height;
  3099. vmf->field = V4L2_FIELD_NONE;
  3100. for (i = 0; i < ARRAY_SIZE(ov5640_cfmts); i++) {
  3101. if (ov5640_cfmts[i].code == vmf->code) {
  3102. found = 1;
  3103. break;
  3104. }
  3105. }
  3106. if (found) {
  3107. vmf->colorspace = ov5640_cfmts[i].colorspace;
  3108. } else {
  3109. /* Unsupported format requested. Propose either */
  3110. if (priv->cfmt) {
  3111. /* the current one or */
  3112. vmf->colorspace = priv->cfmt->colorspace;
  3113. vmf->code = priv->cfmt->code;
  3114. } else {
  3115. /* the default one */
  3116. vmf->colorspace = ov5640_cfmts[0].colorspace;
  3117. vmf->code = ov5640_cfmts[0].code;
  3118. }
  3119. }
  3120. INFO_GREEN("code:%d-%s %dX%d\n",
  3121. vmf->code, win->name, vmf->width, vmf->height);
  3122. return (0);
  3123. }
  3124. /* start or stop streaming from the device */
  3125. static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
  3126. {
  3127. struct i2c_client *client = v4l2_get_subdevdata(sd);
  3128. struct ov5640_priv *priv = to_ov5640(client);
  3129. if (!enable) {
  3130. INFO_PURLPLE("stream down\n");
  3131. // set regs to enter sleep mode, already in DVP mode
  3132. // i2cc_set_reg(client, 0x3008, 0x42); //dg cancel 2015-07-18, ov5640 power down,beacuse it cause some command not running.
  3133. return (0);
  3134. }
  3135. #if 0
  3136. if (NULL == priv->win || NULL == priv->cfmt) {
  3137. OV_ERR("win or cfmt select error!\n");
  3138. return (-EPERM);
  3139. }
  3140. #endif
  3141. INFO_PURLPLE("stream on\n");
  3142. //set regs to leave sleep mode, in DVP mode , needn't to set 0x300e to 0xc
  3143. // i2cc_set_reg(client, 0x3008, 0x02); //dg cancel 2015-07-18,//dg cancel 2015-07-18, ov5640 power down,beacuse it cause some command not running.
  3144. #if 0
  3145. INFO_GREEN("format: %d, win:%s\n", priv->cfmt->code, priv->win->name);
  3146. // wait for 2 Vsync, and capture the 3rd frame, (1 / 7.5) * 2 =. 267ms
  3147. mdelay(270);
  3148. if(0 == down_af_firmware_flag)
  3149. {
  3150. ov5640_sensor_download_af_fw(sd);
  3151. down_af_firmware_flag = 1;
  3152. }
  3153. #endif
  3154. OV5640YUVPreview();
  3155. // OV5640YUVCapture();
  3156. //ov5640_sensor_s_single_af(sd);
  3157. //dg add 2015-07-15
  3158. //OV5640_FOCUS_AD5820_Single_Focus();
  3159. // OV5640_FOCUS_AD5820_Constant_Focus();
  3160. return (0);
  3161. }
  3162. static int reset_ov5640(struct i2c_client *client)
  3163. {
  3164. int ret = i2cc_set_reg(client, 0x3008, 0x82);
  3165. mdelay(5);
  3166. return (ret);
  3167. }
  3168. #if 0 //remove by cym 20130807
  3169. static int ov5640_get_params(struct i2c_client *client, unsigned int *width,
  3170. unsigned int *height, enum v4l2_mbus_pixelcode code)
  3171. {
  3172. struct ov5640_priv *priv = to_ov5640(client);
  3173. int ret = -EINVAL;
  3174. int i;
  3175. /* select format */
  3176. priv->cfmt = NULL;
  3177. for (i = 0; i < ARRAY_SIZE(ov5640_cfmts); i++) {
  3178. if (code == ov5640_cfmts[i].code) {
  3179. priv->cfmt = ov5640_cfmts + i;
  3180. break;
  3181. }
  3182. }
  3183. if (NULL == priv->cfmt) {
  3184. return (ret);
  3185. }
  3186. priv->win = select_win(*width, *height);
  3187. *width = priv->win->width;
  3188. *height = priv->win->height;
  3189. INFO_PURLPLE("current params: %s %dX%d\n",
  3190. priv->win->name, *width, *height);
  3191. return (0);
  3192. }
  3193. #endif
  3194. static inline void init_setting_values(struct ov5640_priv *priv)
  3195. {
  3196. priv->flip_flag = OV5640_HFLIP;
  3197. }
  3198. #if 1 //remove by cym 20130807
  3199. static void get_preview_params(struct i2c_client *client,
  3200. unsigned int *exposure, unsigned short *maxlines, unsigned short *gain)
  3201. {
  3202. unsigned char ret_h = 0;
  3203. unsigned char ret_m = 0;
  3204. unsigned char ret_l = 0;
  3205. i2cc_get_reg(client, 0x3500, &ret_h);
  3206. i2cc_get_reg(client, 0x3501, &ret_m);
  3207. i2cc_get_reg(client, 0x3502, &ret_l);
  3208. *exposure = ((ret_h << 16) + (ret_m << 8) + ret_l) >> 4;
  3209. INFO_GREEN("expl:0x%x, expm:0x%x, exph:0x%x\n",
  3210. ret_l, ret_m, ret_h);
  3211. i2cc_get_reg(client, 0x350c, &ret_h);
  3212. i2cc_get_reg(client, 0x350d, &ret_l);
  3213. *maxlines = (ret_h << 8) + ret_l;
  3214. //i2cc_get_reg(client, 0x350a, &ret_h);
  3215. i2cc_get_reg(client, 0x350b, &ret_l);
  3216. *gain = /*((ret_h & 0x1) << 8) + */ret_l;
  3217. INFO_GREEN("exposure:0x%x, maxlines:0x%x, gain:0x%x\n",
  3218. *exposure, *maxlines, *gain);
  3219. }
  3220. #endif
  3221. #if 1 //remove by cym 20130807
  3222. static void manual_set_exposure_and_gain(struct i2c_client *client,
  3223. unsigned int p_exposure, unsigned short p_maxlines, unsigned short p_gain)
  3224. {
  3225. unsigned char ret_h = 0;
  3226. unsigned char ret_l = 0;
  3227. unsigned char exp_h;
  3228. unsigned char exp_m;
  3229. unsigned char exp_l;
  3230. unsigned char lines_10ms;
  3231. unsigned short cap_maxlines;
  3232. unsigned short cap_exposure;
  3233. unsigned short cap_gain;
  3234. // unsigned short gain;
  3235. unsigned int cap_exp_gain;
  3236. i2cc_get_reg(client, 0x350c, &ret_h);
  3237. i2cc_get_reg(client, 0x350d, &ret_l);
  3238. cap_maxlines = (ret_h << 8) + ret_l;
  3239. //p_maxlines = 980;
  3240. //cap_maxlines = 1964;
  3241. INFO_GREEN("cap_maxlines: 0x%x\n", cap_maxlines);
  3242. // for 50HZ, if 60HZ, devided by 12000
  3243. lines_10ms = CAPTURE_FRAME_RATE * cap_maxlines / 10000 * 13 / 12;
  3244. if (0 == p_maxlines) {
  3245. p_maxlines = 1;
  3246. }
  3247. cap_exposure = ((p_exposure * CAPTURE_FRAME_RATE * cap_maxlines) /
  3248. (p_maxlines * PREVIEW_FRAME_RATE)) * 6 / 5;
  3249. //cap_exp_gain = 1126 * cap_exposure * cap_gain;
  3250. cap_exp_gain = cap_exposure * p_gain; // in night mode, need multiply 2 again.
  3251. //cap_exp_gain >>= 9;
  3252. if (cap_exp_gain < (long)cap_maxlines * 16) {
  3253. cap_exposure = cap_exp_gain / 16;
  3254. if (cap_exposure > lines_10ms) {
  3255. cap_exposure /= lines_10ms;
  3256. cap_exposure *= lines_10ms;
  3257. }
  3258. } else {
  3259. cap_exposure = cap_maxlines;
  3260. }
  3261. if (0 == cap_exposure) {
  3262. cap_exposure = 1;
  3263. }
  3264. cap_gain = ((cap_exp_gain << 1) / cap_exposure + 1) >> 1;
  3265. exp_l = (cap_exposure << 4) & 0xFF;
  3266. exp_m = (cap_exposure >> 4) & 0xFF;
  3267. exp_h = (cap_exposure >> 12) & 0xFF;
  3268. INFO_GREEN("gain:0x%x, expl:0x%x, expm:0x%x, exph:0x%x, cap_maxlines:0x%x\n",
  3269. cap_gain, exp_l, exp_m, exp_h, cap_maxlines);
  3270. i2cc_set_reg(client, 0x350b, cap_gain);
  3271. i2cc_set_reg(client, 0x3502, exp_l);
  3272. i2cc_set_reg(client, 0x3501, exp_m);
  3273. i2cc_set_reg(client, 0x3500, exp_h);
  3274. /*
  3275. * add delay-time, to avoid boundary problem between dark and bright
  3276. */
  3277. mdelay(100);
  3278. }
  3279. #endif
  3280. static int ov5640_set_params(struct i2c_client *client, unsigned int *width,
  3281. unsigned int *height, enum v4l2_mbus_pixelcode code)
  3282. {
  3283. struct ov5640_priv *priv = to_ov5640(client);
  3284. int ret = -EINVAL;
  3285. int i;
  3286. const struct regval *reg_list = NULL;
  3287. int list_len = 0;
  3288. printk("%s(%d): code = %d\n", __FUNCTION__, __LINE__, code);
  3289. printk("%s(%d): width = %d, height = %d\n", __FUNCTION__, __LINE__, *width, *height);
  3290. /* select format */
  3291. priv->cfmt = NULL;
  3292. for (i = 0; i < ARRAY_SIZE(ov5640_cfmts); i++) {
  3293. if (code == ov5640_cfmts[i].code) {
  3294. priv->cfmt = ov5640_cfmts + i;
  3295. break;
  3296. }
  3297. }
  3298. if (NULL == priv->cfmt) {
  3299. printk("%s(%d)\n", __FUNCTION__, __LINE__);
  3300. return (ret);
  3301. }
  3302. /* select win size, now only one, so select directly */
  3303. priv->win = select_win(*width, *height);
  3304. /* set hardware regs needed */
  3305. if (RESV_VGA == priv->win->resv) {
  3306. reset_ov5640(client);
  3307. /* set default regs */
  3308. write_regs(client, ov5640_init_regs, ARRAY_SIZE(ov5640_init_regs));
  3309. init_setting_values(priv);
  3310. }
  3311. switch (priv->win->resv) {
  3312. case RESV_XGA: {
  3313. reg_list = ov5640_qsxga_to_xga_regs;
  3314. list_len = ARRAY_SIZE(ov5640_qsxga_to_xga_regs);
  3315. break;
  3316. }
  3317. case RESV_SXGA: {
  3318. reg_list = ov5640_qsxga_to_sxga_regs;
  3319. list_len = ARRAY_SIZE(ov5640_qsxga_to_sxga_regs);
  3320. break;
  3321. }
  3322. case RESV_UXGA: {
  3323. reg_list = ov5640_qsxga_to_uxga_regs;
  3324. list_len = ARRAY_SIZE(ov5640_qsxga_to_uxga_regs);
  3325. break;
  3326. }
  3327. case RESV_QXGA: {
  3328. reg_list = ov5640_qsxga_to_qxga_regs;
  3329. list_len = ARRAY_SIZE(ov5640_qsxga_to_qxga_regs);
  3330. break;
  3331. }
  3332. case RESV_QSXGA:
  3333. default:
  3334. break;
  3335. }
  3336. #if 0 //remove by cym 20130807
  3337. if (RESV_VGA != priv->win->resv) {
  3338. unsigned int preview_exp;
  3339. unsigned short preview_maxl;
  3340. unsigned short preview_gain;
  3341. /* manually set exposure and gain */
  3342. // i2cc_set_reg(client, 0x3503, 0x07);
  3343. get_preview_params(client, &preview_exp, &preview_maxl, &preview_gain);
  3344. write_regs(client, ov5640_qsxga_regs, ARRAY_SIZE(ov5640_qsxga_regs));
  3345. write_regs(client, ov5640_qsxga_to_uxga_regs, ARRAY_SIZE(ov5640_qsxga_to_uxga_regs));
  3346. if (NULL != reg_list) {
  3347. ;//write_regs(client, reg_list, list_len);
  3348. }
  3349. //manual_set_exposure_and_gain(client, preview_exp, preview_maxl, preview_gain);
  3350. }
  3351. #endif
  3352. *width = priv->win->width;
  3353. *height = priv->win->height;
  3354. INFO_PURLPLE("ok, params are width:%d-height:%d\n", *width, *height);
  3355. return (0);
  3356. }
  3357. static int ov5640_g_fmt(struct v4l2_subdev *sd,
  3358. struct v4l2_mbus_framefmt *vmf)
  3359. {
  3360. struct i2c_client *client = v4l2_get_subdevdata(sd);
  3361. // struct ov5640_priv *priv = to_ov5640(client);
  3362. struct soc_camera_device *icd = client->dev.platform_data;
  3363. #if 0
  3364. if (NULL == priv->win || NULL == priv->cfmt) {
  3365. unsigned int width = VGA_WIDTH;
  3366. unsigned int height = VGA_HEIGHT;
  3367. int ret = 0;
  3368. ret = ov5640_get_params(client, &width, &height, 2);
  3369. //cym V4L2_MBUS_FMT_YUYV8_2X8_BE);
  3370. if (ret < 0) {
  3371. return (ret);
  3372. }
  3373. }
  3374. vmf->width = priv->win->width;
  3375. vmf->height = priv->win->height;
  3376. vmf->code = priv->cfmt->code;
  3377. vmf->colorspace = priv->cfmt->colorspace;
  3378. vmf->field = V4L2_FIELD_NONE;
  3379. #else
  3380. //printk("%s(%d)\n", __FUNCTION__, __LINE__);
  3381. vmf->width = icd->user_width;
  3382. //printk("%s(%d)\n", __FUNCTION__, __LINE__);
  3383. vmf->height = icd->user_height;
  3384. //printk("%s(%d)\n", __FUNCTION__, __LINE__);
  3385. vmf->code = 2;//priv->cfmt->code;
  3386. //printk("%s(%d)\n", __FUNCTION__, __LINE__);
  3387. vmf->colorspace = V4L2_COLORSPACE_JPEG;//priv->cfmt->colorspace;
  3388. vmf->field = V4L2_FIELD_NONE;
  3389. #endif
  3390. INFO_GREEN("ok, get fmt w:%dXh:%d-code:%d-csp:%d\n",
  3391. vmf->width, vmf->height, vmf->code, vmf->colorspace);
  3392. return (0);
  3393. }
  3394. static int ov5640_s_fmt(struct v4l2_subdev *sd,
  3395. struct v4l2_mbus_framefmt *vmf)
  3396. {
  3397. struct i2c_client *client = v4l2_get_subdevdata(sd);
  3398. struct ov5640_priv *priv = to_ov5640(client);
  3399. //ov5640_g_fmt(sd, vmf);
  3400. //printk("*********** %s, line = %d(code = 0x%x, w:%d, h:%d)\n", __FUNCTION__, __LINE__,
  3401. // vmf->code, vmf->width, vmf->height);
  3402. #if 0
  3403. int ret = ov5640_set_params(client, &vmf->width, &vmf->height, vmf->code);
  3404. printk("%s(%d): rest = %d\n", __FUNCTION__, __LINE__, ret);
  3405. if (!ret)
  3406. vmf->colorspace = priv->cfmt->colorspace;
  3407. return (ret);
  3408. #endif
  3409. return 1;
  3410. //INFO_PURLPLE("\n");
  3411. }
  3412. // TODO..... modify
  3413. static int ov5640_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *vcc)
  3414. {
  3415. vcc->bounds.left = OV5640_COLUMN_SKIP;
  3416. vcc->bounds.top = OV5640_ROW_SKIP;
  3417. vcc->bounds.width = OV5640_MAX_WIDTH;
  3418. vcc->bounds.height = OV5640_MAX_HEIGHT;
  3419. vcc->defrect = vcc->bounds; /* set default rect. */
  3420. vcc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  3421. vcc->pixelaspect.numerator = 1;
  3422. vcc->pixelaspect.denominator = 1;
  3423. INFO_PURLPLE("\n");
  3424. return (0);
  3425. }
  3426. // TODO..... modify
  3427. static int ov5640_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *vc)
  3428. {
  3429. vc->c.left = 0;
  3430. vc->c.top = 0;
  3431. vc->c.width = QSXGA_WIDTH;
  3432. vc->c.height = QSXGA_HEIGHT;
  3433. vc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  3434. INFO_BLUE("\n");
  3435. return (0);
  3436. }
  3437. static int ov5640_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
  3438. enum v4l2_mbus_pixelcode *code)
  3439. {
  3440. if (index >= ARRAY_SIZE(ov5640_cfmts))
  3441. return -EINVAL;
  3442. *code = ov5640_cfmts[index].code;
  3443. OV_INFO("fmt index:%d\n", index);
  3444. return 0;
  3445. }
  3446. static int ov5640_enum_framesizes(struct v4l2_subdev *sd,
  3447. struct v4l2_frmsizeenum *fsize)
  3448. {
  3449. //struct s5k4ecgx_state *state =
  3450. // container_of(sd, struct s5k4ecgx_state, sd);
  3451. //struct i2c_client *client = v4l2_get_subdevdata(sd);
  3452. //struct ov5640_priv *priv = to_ov5640(client);
  3453. //printk("********************** %s(%d) **************************\n", __FUNCTION__, __LINE__);
  3454. fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
  3455. fsize->discrete.width = 640;//state->pix.width;
  3456. fsize->discrete.height = 480;//state->pix.height;
  3457. return 0;
  3458. }
  3459. static int ov5640_set_brightness(struct i2c_client *client, int bright)
  3460. {
  3461. struct ov5640_priv *priv = to_ov5640(client);
  3462. unsigned char reg5587, reg5588;
  3463. if (bright < -4 || 4 < bright) {
  3464. OV_ERR("brightness - %d is out of range[-4, 4]\n", bright);
  3465. return (-ERANGE);
  3466. }
  3467. if (bright < 0) {
  3468. reg5587 = 0x10 * (-bright);
  3469. reg5588 = 0x09; /* bit[3] is Y bright sign */
  3470. } else {
  3471. reg5587 = 0x10 * bright;
  3472. reg5588 = 0x01;
  3473. }
  3474. i2cc_set_reg(client, 0x5001, 0xff);
  3475. i2cc_set_reg(client, 0x5587, reg5587);
  3476. i2cc_set_reg(client, 0x5580, 0x04);
  3477. i2cc_set_reg(client, 0x5588, reg5588);
  3478. priv->brightness = bright;
  3479. OV_INFO("brightness:%d, reg5587:0x%x, reg5588:0x%x\n",
  3480. bright, reg5587, reg5588);
  3481. return (0);
  3482. }
  3483. static int ov5640_set_contrast(struct i2c_client *client, int contrast)
  3484. {
  3485. struct ov5640_priv *priv = to_ov5640(client);
  3486. unsigned char y_gain, reg5588;
  3487. if (contrast < -4 || 4 < contrast) {
  3488. OV_ERR("contrast - %d is out of range[-4, 4]\n", contrast);
  3489. return (-ERANGE);
  3490. }
  3491. if (0 == contrast) {
  3492. reg5588 = 0x1;
  3493. } else {
  3494. reg5588 = 0x41;
  3495. }
  3496. y_gain = 0x20 + 0x4 * contrast;
  3497. i2cc_set_reg(client, 0x5001, 0xff);
  3498. i2cc_set_reg(client, 0x5580, 0x04);
  3499. i2cc_set_reg(client, 0x5586, y_gain);
  3500. i2cc_set_reg(client, 0x5585, y_gain);
  3501. i2cc_set_reg(client, 0x5588, reg5588);
  3502. priv->contrast = contrast;
  3503. OV_INFO("contrast:%d, y_gain:0x%x, reg5588:0x%x\n", contrast, y_gain, reg5588);
  3504. return (0);
  3505. }
  3506. /* auto, manual seperated is ok?? */
  3507. static int ov5640_set_saturation(struct i2c_client *client, int saturation)
  3508. {
  3509. struct ov5640_priv *priv = to_ov5640(client);
  3510. unsigned char uv_max, uv_min, reg5588;
  3511. if (saturation < -4 || 4 < saturation) {
  3512. OV_ERR("saturation - %d is out of range[-4, 4]\n", saturation);
  3513. return (-ERANGE);
  3514. }
  3515. if (0 == saturation) { /* different from application notes */
  3516. uv_max = 0x40; /* max value for UV adjust */
  3517. uv_min = 0x10; /* min value for UV adjust */
  3518. reg5588 = 0x01; /* bit[6]==0, auto saturation */
  3519. } else {
  3520. uv_max = 0x40 + 0x10 * saturation; /* U sat. */
  3521. uv_min = uv_max; /* v sat */
  3522. reg5588 = 0x41; /* bit[6]==1, manual saturation */
  3523. }
  3524. i2cc_set_reg(client, 0x5001, 0xff); /* init is 0xa3 */
  3525. i2cc_set_reg(client, 0x5583, uv_max);
  3526. i2cc_set_reg(client, 0x5584, uv_min);
  3527. i2cc_set_reg(client, 0x5580, 0x02); /* bit[1], enable(1)/disabe(0) saturation */
  3528. i2cc_set_reg(client, 0x5588, reg5588);
  3529. priv->saturation = saturation;
  3530. OV_INFO("saturation:%d\n", saturation);
  3531. return (0);
  3532. }
  3533. /* XXX:effect is reversed to note's picture exept -180. check it */
  3534. static int ov5640_set_hue(struct i2c_client *client, int hue)
  3535. {
  3536. struct ov5640_priv *priv = to_ov5640(client);
  3537. unsigned char reg5581, reg5582, reg5588;
  3538. switch (hue) {
  3539. case -180:
  3540. reg5581 = 0x80;
  3541. reg5582 = 0x00;
  3542. reg5588 = 0x32;
  3543. break;
  3544. case -150:
  3545. reg5581 = 0x6f;
  3546. reg5582 = 0x40;
  3547. reg5588 = 0x32;
  3548. break;
  3549. case -120:
  3550. reg5581 = 0x40;
  3551. reg5582 = 0x6f;
  3552. reg5588 = 0x32;
  3553. break;
  3554. case -90:
  3555. reg5581 = 0x00;
  3556. reg5582 = 0x80;
  3557. reg5588 = 0x02;
  3558. break;
  3559. case -60:
  3560. reg5581 = 0x40;
  3561. reg5582 = 0x6f;
  3562. reg5588 = 0x02;
  3563. break;
  3564. case -30:
  3565. reg5581 = 0x6f;
  3566. reg5582 = 0x40;
  3567. reg5588 = 0x02;
  3568. break;
  3569. case 0:
  3570. reg5581 = 0x80;
  3571. reg5582 = 0x00;
  3572. reg5588 = 0x01;
  3573. break;
  3574. case 30:
  3575. reg5581 = 0x6f;
  3576. reg5582 = 0x40;
  3577. reg5588 = 0x01;
  3578. break;
  3579. case 60:
  3580. reg5581 = 0x40;
  3581. reg5582 = 0x6f;
  3582. reg5588 = 0x01;
  3583. break;
  3584. case 90:
  3585. reg5581 = 0x00;
  3586. reg5582 = 0x80;
  3587. reg5588 = 0x31;
  3588. break;
  3589. case 120:
  3590. reg5581 = 0x40;
  3591. reg5582 = 0x6f;
  3592. reg5588 = 0x31;
  3593. break;
  3594. case 150:
  3595. reg5581 = 0x6f;
  3596. reg5582 = 0x40;
  3597. reg5588 = 0x31;
  3598. break;
  3599. default:
  3600. OV_ERR("hue - %d is out of range[-180, 150]/step-30\n", hue);
  3601. return (-ERANGE);
  3602. }
  3603. i2cc_set_reg(client, 0x5001, 0xff);
  3604. i2cc_set_reg(client, 0x5580, 0x01); /* XXXX:diff. from defualt value */
  3605. i2cc_set_reg(client, 0x5581, reg5581); /* hue cos coefficient */
  3606. i2cc_set_reg(client, 0x5582, reg5582); /* hue sin coefficient */
  3607. i2cc_set_reg(client, 0x5588, reg5588);
  3608. priv->hue = hue;
  3609. OV_INFO("hue: %d, 5581:0x%x, 5582:0x%x, 5588:0x%x\n",
  3610. hue, reg5581, reg5582, reg5588);
  3611. return (0);
  3612. }
  3613. /* default value here is different from init one. */
  3614. static int ov5640_set_exposure_level(struct i2c_client *client, int level)
  3615. {
  3616. struct ov5640_priv *priv = to_ov5640(client);
  3617. unsigned char reg3a0f, reg3a10;
  3618. unsigned char reg3a1b, reg3a1e;
  3619. unsigned char reg3a11, reg3a1f;
  3620. reg3a0f = 0x38 + 0x8 * level;
  3621. reg3a10 = 0x30 + 0x8 * level;
  3622. reg3a1b = reg3a0f;
  3623. reg3a1e = reg3a10;
  3624. reg3a1f = 0x10;
  3625. switch (level) {
  3626. case -5: /* -1.7EV */
  3627. reg3a11 = 0x20;
  3628. break;
  3629. case -4: /* -1.3EV */
  3630. reg3a11 = 0x30;
  3631. break;
  3632. case -3: /* -1.0EV */
  3633. reg3a11 = 0x41;
  3634. break;
  3635. case -2: /* -0.7EV */
  3636. reg3a11 = 0x51;
  3637. break;
  3638. case -1: /* -0.3EV */
  3639. reg3a11 = 0x61;
  3640. break;
  3641. case 0: /* 0EV, default */
  3642. reg3a11 = 0x61;
  3643. break;
  3644. case 1: /* 0.3EV */
  3645. reg3a11 = 0x71;
  3646. break;
  3647. case 2: /* 0.7EV */
  3648. reg3a11 = 0x80;
  3649. reg3a1f = 0x20;
  3650. break;
  3651. case 3: /* 1.0EV */
  3652. reg3a11 = 0x90;
  3653. reg3a1f = 0x20;
  3654. break;
  3655. case 4: /* 1.3EV */
  3656. reg3a11 = 0x91;
  3657. reg3a1f = 0x20;
  3658. break;
  3659. case 5: /* 1.7EV */
  3660. reg3a11 = 0xa0;
  3661. reg3a1f = 0x20;
  3662. break;
  3663. default:
  3664. OV_ERR("exposure - %d is out of range[-5, 5]\n", level);
  3665. return (-ERANGE);
  3666. }
  3667. OV_INFO("exposure: %d, 0x3a0f:0x%x, 0x3a10:0x%x\n", level, reg3a0f, reg3a10);
  3668. //OV_INFO("0x3a1b:0x%x, 0x3a1e:0x%x\n", reg3a1b, reg3a1e);
  3669. OV_INFO("0x3a11:0x%x, 0x3a1f:0x%x\n\n", reg3a11, reg3a1f);
  3670. i2cc_set_reg(client, 0x3a0f, reg3a0f); /* stable range high limit(enter) */
  3671. i2cc_set_reg(client, 0x3a10, reg3a10); /* stable range low limit(enter) */
  3672. i2cc_set_reg(client, 0x3a11, reg3a11); /* fast zone high limit */
  3673. i2cc_set_reg(client, 0x3a1b, reg3a1b); /* stable range high limit(go out) */
  3674. i2cc_set_reg(client, 0x3a1e, reg3a1e); /* stable range low limit(go out) */
  3675. i2cc_set_reg(client, 0x3a1f, reg3a1f); /* fast zone low limit */
  3676. priv->exposure = level;
  3677. return (0);
  3678. }
  3679. #define OV5640_FLIP_VAL ((unsigned char)0x06)
  3680. #define OV5640_FLIP_MASK (~(OV5640_FLIP_VAL))
  3681. static int ov5640_set_flip(struct i2c_client *client, struct v4l2_control *ctrl)
  3682. {
  3683. struct ov5640_priv *priv = to_ov5640(client);
  3684. unsigned char reg3820, reg3821;
  3685. OV_INFO("old flag: %d\n", priv->flip_flag);
  3686. switch (ctrl->id) {
  3687. case V4L2_CID_HFLIP:
  3688. if (ctrl->value) {
  3689. priv->flip_flag |= OV5640_HFLIP;
  3690. } else {
  3691. priv->flip_flag &= ~OV5640_HFLIP;
  3692. }
  3693. break;
  3694. case V4L2_CID_VFLIP:
  3695. if (ctrl->value) {
  3696. priv->flip_flag |= OV5640_VFLIP;
  3697. } else {
  3698. priv->flip_flag &= ~OV5640_VFLIP;
  3699. }
  3700. break;
  3701. default:
  3702. OV_ERR("set flip out of range\n");
  3703. return (-ERANGE);
  3704. }
  3705. OV_INFO("new flag: %d\n", priv->flip_flag);
  3706. i2cc_get_reg(client, 0x3820, &reg3820);
  3707. i2cc_get_reg(client, 0x3821, &reg3821);
  3708. if (priv->flip_flag & OV5640_VFLIP) {
  3709. reg3820 |= OV5640_FLIP_VAL;
  3710. } else {
  3711. reg3820 &= OV5640_FLIP_MASK;
  3712. }
  3713. if (priv->flip_flag & OV5640_HFLIP) {
  3714. reg3821 |= OV5640_FLIP_VAL;
  3715. } else {
  3716. reg3821 &= OV5640_FLIP_MASK;
  3717. }
  3718. /* have a bug which flip a half picture only. */
  3719. //i2cc_set_reg(client, 0x3212, 0x00); /* enable group0, when add no flip */
  3720. i2cc_set_reg(client, 0x3820, reg3820);
  3721. i2cc_set_reg(client, 0x3821, reg3821);
  3722. //i2cc_set_reg(client, 0x3212, 0x10); /* end group0 */
  3723. //i2cc_set_reg(client, 0x3212, 0xa1); /* launch group1 */
  3724. OV_INFO("0x3820:0x%x, 0x3821:0x%x\n", reg3820, reg3821);
  3725. return (0);
  3726. }
  3727. static int ov5640_set_sharpness(struct i2c_client *client, int sharp)
  3728. {
  3729. struct ov5640_priv *priv = to_ov5640(client);
  3730. unsigned char reg5302;
  3731. switch (sharp) {
  3732. case -1: /*auto sharpness*/
  3733. break;
  3734. case 0: /* sharpness off */
  3735. reg5302 = 0x00;
  3736. break;
  3737. case 1:
  3738. reg5302 = 0x02;
  3739. break;
  3740. case 2:
  3741. reg5302 = 0x04;
  3742. break;
  3743. case 3:
  3744. reg5302 = 0x08;
  3745. break;
  3746. case 4:
  3747. reg5302 = 0x0c;
  3748. break;
  3749. case 5:
  3750. reg5302 = 0x10;
  3751. break;
  3752. case 6:
  3753. reg5302 = 0x14;
  3754. break;
  3755. case 7:
  3756. reg5302 = 0x18;
  3757. break;
  3758. case 8:
  3759. reg5302 = 0x20;
  3760. break;
  3761. default:
  3762. OV_ERR("set sharpness is out of range - %d[-1,8]\n", sharp);
  3763. return (-ERANGE);
  3764. }
  3765. if (0 <= sharp) {
  3766. i2cc_set_reg(client, 0x5308, 0x65);
  3767. i2cc_set_reg(client, 0x5302, reg5302);
  3768. OV_INFO("sharp:%d, 5302:0x%x\n", sharp, reg5302);
  3769. } else {
  3770. const struct regval ov5640_auto_sharpness[] = {
  3771. {0x5308, 0x25},
  3772. {0x5300, 0x08},
  3773. {0x5301, 0x30},
  3774. {0x5302, 0x10},
  3775. {0x5303, 0x00},
  3776. {0x5309, 0x08},
  3777. {0x530a, 0x30},
  3778. {0x530b, 0x04},
  3779. {0x530c, 0x06},
  3780. };
  3781. int len = ARRAY_SIZE(ov5640_auto_sharpness);
  3782. write_regs(client, ov5640_auto_sharpness, len);
  3783. OV_INFO("sharp:%d, len:%d\n", sharp, len);
  3784. }
  3785. priv->sharpness = sharp;
  3786. return (0);
  3787. }
  3788. static int ov5640_set_colorfx(struct i2c_client *client, int effect)
  3789. {
  3790. struct ov5640_priv *priv = to_ov5640(client);
  3791. unsigned char reg5583, reg5584, reg5001, reg5580;
  3792. reg5001 = 0xff;
  3793. reg5580 = 0x18;
  3794. switch (effect) {
  3795. case 0: /* normal */
  3796. reg5001 = 0x7f;
  3797. reg5580 = 0x00;
  3798. break;
  3799. case 1: /* black and white */
  3800. reg5583 = 0x80;
  3801. reg5584 = 0x80;
  3802. break;
  3803. case 2: /* sepia , antique */
  3804. reg5583 = 0x40;
  3805. reg5584 = 0xa0;
  3806. break;
  3807. case 3: /* negative */
  3808. reg5001 = 0xff;
  3809. reg5580 = 0x40;
  3810. break;
  3811. case 4: /* bluish */
  3812. reg5583 = 0xa0;
  3813. reg5584 = 0x40;
  3814. break;
  3815. case 5: /* greenish */
  3816. reg5583 = 0x60;
  3817. reg5584 = 0x60;
  3818. break;
  3819. case 6: /* reddish */
  3820. reg5583 = 0x80;
  3821. reg5584 = 0xc0;
  3822. break;
  3823. default:
  3824. OV_ERR("set color effects out of range - %d[0,6]\n", effect);
  3825. return (-ERANGE);
  3826. }
  3827. i2cc_set_reg(client, 0x5001, reg5001);
  3828. i2cc_set_reg(client, 0x5580, reg5580);
  3829. OV_INFO("effect:%d, 0x5001:0x%x, 0x5580:0x%x\n", effect, reg5001, reg5580);
  3830. if (0 != effect && 3 != effect) {
  3831. i2cc_set_reg(client, 0x5583, reg5583);
  3832. i2cc_set_reg(client, 0x5584, reg5584);
  3833. OV_INFO("0x5583:0x%x, 0x5584:0x%x\n", reg5583, reg5584);
  3834. }
  3835. priv->colorfx = effect;
  3836. return (0);
  3837. }
  3838. /* Must be sorted from low to high control ID! */
  3839. static const u32 ov5640_user_ctrls[] = {
  3840. V4L2_CID_USER_CLASS,
  3841. V4L2_CID_BRIGHTNESS,
  3842. V4L2_CID_CONTRAST,
  3843. V4L2_CID_SATURATION,
  3844. V4L2_CID_HUE,
  3845. // V4L2_CID_BLACK_LEVEL,
  3846. V4L2_CID_AUTO_WHITE_BALANCE,
  3847. // V4L2_CID_DO_WHITE_BALANCE,
  3848. // V4L2_CID_RED_BALANCE,
  3849. // V4L2_CID_BLUE_BALANCE,
  3850. // V4L2_CID_GAMMA,
  3851. V4L2_CID_EXPOSURE,
  3852. V4L2_CID_AUTOGAIN,
  3853. V4L2_CID_GAIN,
  3854. V4L2_CID_HFLIP,
  3855. V4L2_CID_VFLIP,
  3856. V4L2_CID_POWER_LINE_FREQUENCY,
  3857. // V4L2_CID_HUE_AUTO,
  3858. V4L2_CID_WHITE_BALANCE_TEMPERATURE,
  3859. V4L2_CID_SHARPNESS,
  3860. // V4L2_CID_BACKLIGHT_COMPENSATION,
  3861. // V4L2_CID_CHROMA_AGC,
  3862. // V4L2_CID_CHROMA_GAIN,
  3863. // V4L2_CID_COLOR_KILLER,
  3864. V4L2_CID_COLORFX,
  3865. // V4L2_CID_AUTOBRIGHTNESS,
  3866. V4L2_CID_BAND_STOP_FILTER,
  3867. // V4L2_CID_ROTATE,
  3868. // V4L2_CID_BG_COLOR,
  3869. 0,
  3870. };
  3871. static const u32 ov5640_camera_ctrls[] = {
  3872. V4L2_CID_CAMERA_CLASS,
  3873. V4L2_CID_EXPOSURE_AUTO,
  3874. // V4L2_CID_EXPOSURE_ABSOLUTE,
  3875. // V4L2_CID_EXPOSURE_AUTO_PRIORITY,
  3876. // V4L2_CID_PAN_RELATIVE,
  3877. // V4L2_CID_TILT_RELATIVE,
  3878. // V4L2_CID_PAN_RESET,
  3879. // V4L2_CID_TILT_RESET,
  3880. // V4L2_CID_PAN_ABSOLUTE,
  3881. // V4L2_CID_TILT_ABSOLUTE,
  3882. // V4L2_CID_FOCUS_ABSOLUTE,
  3883. // V4L2_CID_FOCUS_RELATIVE,
  3884. // V4L2_CID_FOCUS_AUTO,
  3885. // V4L2_CID_ZOOM_ABSOLUTE,
  3886. // V4L2_CID_ZOOM_RELATIVE,
  3887. // V4L2_CID_ZOOM_CONTINUOUS,
  3888. // V4L2_CID_IRIS_ABSOLUTE,
  3889. // V4L2_CID_IRIS_RELATIVE,
  3890. // V4L2_CID_PRIVACY,
  3891. //cym V4L2_CID_SCENE_EXPOSURE,
  3892. 0,
  3893. };
  3894. static const u32 *ov5640_ctrl_classes[] = {
  3895. ov5640_user_ctrls,
  3896. ov5640_camera_ctrls,
  3897. NULL,
  3898. };
  3899. static int ov5640_queryctrl(struct v4l2_subdev *sd,
  3900. struct v4l2_queryctrl *qc)
  3901. {
  3902. //struct i2c_client *client = v4l2_get_subdevdata(sd);
  3903. qc->id = v4l2_ctrl_next(ov5640_ctrl_classes, qc->id);
  3904. if (qc->id == 0) {
  3905. return (-EINVAL);
  3906. }
  3907. OV_INFO("%s: id-%s\n", __func__, v4l2_ctrl_get_name(qc->id));
  3908. /* Fill in min, max, step and default value for these controls. */
  3909. switch (qc->id) {
  3910. /* Standard V4L2 controls */
  3911. case V4L2_CID_USER_CLASS:
  3912. return v4l2_ctrl_query_fill(qc, 0, 0, 0, 0);
  3913. case V4L2_CID_BRIGHTNESS:
  3914. return v4l2_ctrl_query_fill(qc, -4, 4, 1, 0);
  3915. case V4L2_CID_CONTRAST:
  3916. return v4l2_ctrl_query_fill(qc, -4, 4, 1, 0);
  3917. case V4L2_CID_SATURATION:
  3918. return v4l2_ctrl_query_fill(qc, -4, 4, 1, 0);
  3919. case V4L2_CID_HUE:
  3920. return v4l2_ctrl_query_fill(qc, -180, 150, 30, 0);
  3921. #if 0
  3922. // case V4L2_CID_BLACK_LEVEL:
  3923. case V4L2_CID_AUTO_WHITE_BALANCE:
  3924. return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
  3925. // case V4L2_CID_DO_WHITE_BALANCE:
  3926. // case V4L2_CID_RED_BALANCE:
  3927. // case V4L2_CID_BLUE_BALANCE:
  3928. // case V4L2_CID_GAMMA:
  3929. #endif
  3930. case V4L2_CID_EXPOSURE:
  3931. return v4l2_ctrl_query_fill(qc, -5, 5, 1, 0);
  3932. #if 0
  3933. case V4L2_CID_AUTOGAIN:
  3934. return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
  3935. case V4L2_CID_GAIN:
  3936. return v4l2_ctrl_query_fill(qc, 0, 0xFFU, 1, 128);
  3937. #endif
  3938. case V4L2_CID_HFLIP:
  3939. case V4L2_CID_VFLIP:
  3940. return v4l2_ctrl_query_fill(qc, 0, 1, 1, 0);
  3941. #if 0
  3942. case V4L2_CID_POWER_LINE_FREQUENCY:
  3943. return v4l2_ctrl_query_fill(qc, 0, 2, 1, 1);
  3944. // case V4L2_CID_HUE_AUTO:
  3945. case V4L2_CID_WHITE_BALANCE_TEMPERATURE:
  3946. return v4l2_ctrl_query_fill(qc, 0, 3, 1, 0);
  3947. #endif
  3948. case V4L2_CID_SHARPNESS:
  3949. return v4l2_ctrl_query_fill(qc, -1, 8, 1, -1);
  3950. // case V4L2_CID_BACKLIGHT_COMPENSATION:
  3951. // case V4L2_CID_CHROMA_AGC:
  3952. // case V4L2_CID_CHROMA_GAIN:
  3953. // case V4L2_CID_COLOR_KILLER:
  3954. case V4L2_CID_COLORFX:
  3955. return v4l2_ctrl_query_fill(qc, 0, 6, 1, 0);
  3956. // case V4L2_CID_AUTOBRIGHTNESS:
  3957. #if 0
  3958. case V4L2_CID_BAND_STOP_FILTER:
  3959. return v4l2_ctrl_query_fill(qc, 0, 63, 1, 2);
  3960. // case V4L2_CID_ROTATE:
  3961. // case V4L2_CID_BG_COLOR:
  3962. #endif
  3963. case V4L2_CID_CAMERA_CLASS:
  3964. return v4l2_ctrl_query_fill(qc, 0, 0, 0, 0);
  3965. #if 0
  3966. case V4L2_CID_EXPOSURE_AUTO:
  3967. return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
  3968. // case V4L2_CID_EXPOSURE_ABSOLUTE:
  3969. // case V4L2_CID_EXPOSURE_AUTO_PRIORITY:
  3970. // case V4L2_CID_PAN_RELATIVE:
  3971. // case V4L2_CID_TILT_RELATIVE:
  3972. // case V4L2_CID_PAN_RESET:
  3973. // case V4L2_CID_TILT_RESET:
  3974. // case V4L2_CID_PAN_ABSOLUTE:
  3975. // case V4L2_CID_TILT_ABSOLUTE:
  3976. // case V4L2_CID_FOCUS_ABSOLUTE:
  3977. // case V4L2_CID_FOCUS_RELATIVE:
  3978. // case V4L2_CID_FOCUS_AUTO:
  3979. // case V4L2_CID_ZOOM_ABSOLUTE:
  3980. // case V4L2_CID_ZOOM_RELATIVE:
  3981. // case V4L2_CID_ZOOM_CONTINUOUS:
  3982. // case V4L2_CID_IRIS_ABSOLUTE:
  3983. // case V4L2_CID_IRIS_RELATIVE:
  3984. // case V4L2_CID_PRIVACY:
  3985. case V4L2_CID_SCENE_EXPOSURE:
  3986. return v4l2_ctrl_query_fill(qc, 0, 1, 1, 0);
  3987. #endif
  3988. default:
  3989. OV_ERR("invalid control ctrl: %s\n", v4l2_ctrl_get_name(qc->id));
  3990. qc->flags |= V4L2_CTRL_FLAG_DISABLED;
  3991. return (-EINVAL);
  3992. }
  3993. return (0);
  3994. }
  3995. static int ov5640_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
  3996. {
  3997. struct i2c_client *client = v4l2_get_subdevdata(sd);
  3998. //struct ov5640_priv *priv = to_ov5640(client);
  3999. int ret = 0;
  4000. //int val = 0;
  4001. /* add by cym 20130812 */
  4002. int err = 0;
  4003. //int value = ctrl->value;
  4004. /* end add */
  4005. OV_INFO("%s: control ctrl- %s\n", __func__, v4l2_ctrl_get_name(ctrl->id));
  4006. printk("%s: control ctrl- id = %d\n", __func__, ctrl->id-V4L2_CID_PRIVATE_BASE);
  4007. switch (ctrl->id) {
  4008. case V4L2_CID_BRIGHTNESS:
  4009. ov5640_set_brightness(client, ctrl->value);
  4010. break;
  4011. case V4L2_CID_CONTRAST:
  4012. ov5640_set_contrast(client, ctrl->value);
  4013. break;
  4014. case V4L2_CID_SATURATION:
  4015. ov5640_set_saturation(client, ctrl->value);
  4016. break;
  4017. case V4L2_CID_HUE:
  4018. ov5640_set_hue(client, ctrl->value);
  4019. break;
  4020. #if 0
  4021. // case V4L2_CID_BLACK_LEVEL:
  4022. // ov5640_set_black_level(sd, ctrl->value);
  4023. // break;
  4024. case V4L2_CID_AUTO_WHITE_BALANCE:
  4025. ov5640_set_awb(client, ctrl->value);
  4026. break;
  4027. // case V4L2_CID_DO_WHITE_BALANCE:
  4028. // ov5640_set_do_white_balance(sd, ctrl->value);
  4029. // break;
  4030. // case V4L2_CID_RED_BALANCE:
  4031. // ov5640_set_red_balance(sd, ctrl->value);
  4032. // break;
  4033. // case V4L2_CID_BLUE_BALANCE:
  4034. // ov5640_set_blue_balance(sd, ctrl->value);
  4035. // break;
  4036. // case V4L2_CID_GAMMA:
  4037. // ov5640_set_gamma(sd, ctrl->value);
  4038. // break;
  4039. #endif
  4040. case V4L2_CID_EXPOSURE:
  4041. ov5640_set_exposure_level(client, ctrl->value);
  4042. break;
  4043. #if 0
  4044. case V4L2_CID_AUTOGAIN:
  4045. ov5640_set_autogain(sd, ctrl->value);
  4046. break;
  4047. case V4L2_CID_GAIN:
  4048. ov5640_set_gain(sd, ctrl->value);
  4049. break;
  4050. #endif
  4051. case V4L2_CID_HFLIP:
  4052. case V4L2_CID_VFLIP:
  4053. ov5640_set_flip(client, ctrl);
  4054. break;
  4055. #if 0
  4056. case V4L2_CID_POWER_LINE_FREQUENCY:
  4057. ov5640_set_power_line_frequency(sd, ctrl->value);
  4058. break;
  4059. // case V4L2_CID_HUE_AUTO:
  4060. // ov5640_set_hue_auto(sd, ctrl->value);
  4061. // break;
  4062. case V4L2_CID_WHITE_BALANCE_TEMPERATURE:
  4063. set_white_balance_temperature(client, ctrl->value);
  4064. break;
  4065. #endif
  4066. case V4L2_CID_SHARPNESS:
  4067. ov5640_set_sharpness(client, ctrl->value);
  4068. break;
  4069. // case V4L2_CID_BACKLIGHT_COMPENSATION:
  4070. // ov5640_set_backlight_compensation(sd, ctrl->value);
  4071. // break;
  4072. // case V4L2_CID_CHROMA_AGC:
  4073. // ov5640_set_chroma_agc(sd, ctrl->value);
  4074. // break;
  4075. // case V4L2_CID_CHROMA_GAIN:
  4076. // ov5640_set_chroma_gain(sd, ctrl->value);
  4077. // break;
  4078. // case V4L2_CID_COLOR_KILLER:
  4079. // ov5640_set_color_killer(sd, ctrl->value);
  4080. // break;
  4081. case V4L2_CID_COLORFX:
  4082. ov5640_set_colorfx(client, ctrl->value);
  4083. break;
  4084. #if 0
  4085. // case V4L2_CID_AUTOBRIGHTNESS:
  4086. // ov5640_set_autobrightness(sd, ctrl->value);
  4087. // break;
  4088. case V4L2_CID_BAND_STOP_FILTER:
  4089. ov5640_set_band_stop_filter(sd, ctrl->value);
  4090. break;
  4091. // case V4L2_CID_ROTATE:
  4092. // ov5640_set_rotate(sd, ctrl->value);
  4093. // break;
  4094. // case V4L2_CID_BG_COLOR:
  4095. // ov5640_set_bg_color(sd, ctrl->value);
  4096. // break;
  4097. case V4L2_CID_EXPOSURE_AUTO:
  4098. ov5640_set_exposure_auto(sd, ctrl->value);
  4099. break;
  4100. // case V4L2_CID_EXPOSURE_ABSOLUTE:
  4101. // case V4L2_CID_EXPOSURE_AUTO_PRIORITY:
  4102. // case V4L2_CID_PAN_RELATIVE:
  4103. // case V4L2_CID_TILT_RELATIVE:
  4104. // case V4L2_CID_PAN_RESET:
  4105. // case V4L2_CID_TILT_RESET:
  4106. // case V4L2_CID_PAN_ABSOLUTE:
  4107. // case V4L2_CID_TILT_ABSOLUTE:
  4108. // case V4L2_CID_FOCUS_ABSOLUTE:
  4109. // case V4L2_CID_FOCUS_RELATIVE:
  4110. // case V4L2_CID_FOCUS_AUTO:
  4111. // case V4L2_CID_ZOOM_ABSOLUTE:
  4112. // case V4L2_CID_ZOOM_RELATIVE:
  4113. // case V4L2_CID_ZOOM_CONTINUOUS:
  4114. // case V4L2_CID_IRIS_ABSOLUTE:
  4115. // case V4L2_CID_IRIS_RELATIVE:
  4116. // case V4L2_CID_PRIVACY:
  4117. case V4L2_CID_SCENE_EXPOSURE:
  4118. ov5640_set_scene_exposure(sd, ctrl->value);
  4119. break;
  4120. #endif
  4121. /* add by cym 20130812 */
  4122. case V4L2_CID_CAMERA_SET_AUTO_FOCUS:
  4123. {
  4124. printk("auto focus......\n");
  4125. err = ov5640_sensor_s_single_af(sd);
  4126. // OV5640_FOCUS_AD5820_Single_Focus();
  4127. // OV5640_FOCUS_AD5820_Constant_Focus();
  4128. }
  4129. break;
  4130. /* end add */
  4131. default:
  4132. OV_ERR("invalid control ctrl: %s\n", v4l2_ctrl_get_name(ctrl->id));
  4133. return (-EINVAL);
  4134. }
  4135. return (ret);
  4136. }
  4137. static int ov5640_init(struct v4l2_subdev *sd, u32 val)
  4138. {
  4139. struct i2c_client *client = v4l2_get_subdevdata(sd);
  4140. struct ov5640_priv *priv = to_ov5640(client);
  4141. unsigned char pid;
  4142. unsigned char version;
  4143. //int err = -EINVAL;
  4144. /* add by cym 20121121 */
  4145. ov5640_power(1);
  4146. /* end add */
  4147. //dg add 2015-07-15
  4148. i2cc_set_reg(client, 0x3103,0x11);
  4149. i2cc_set_reg(client, 0x3008,0x82);
  4150. mdelay(20);
  4151. // check and show product ID and manufacturer ID
  4152. i2cc_get_reg(client, 0x300a, &pid);
  4153. i2cc_get_reg(client, 0x300b, &version);
  4154. printk("%s: version = 0x%x%x\n", __FUNCTION__, pid, version);
  4155. if (OV5640 != VERSION(pid, version)) {
  4156. OV_ERR("ov5640 probed failed!!\n");
  4157. return (-ENODEV);
  4158. }
  4159. priv->model = 1;//cym V4L2_IDENT_OV5640;
  4160. //ov5640_sensor_download_af_fw(sd);
  4161. //ov5640_sensor_s_single_af(sd);
  4162. //dg add 2015-07-25
  4163. OV5640_FOCUS_AD5820_Init();
  4164. OV5640YUV_Sensor_Dvp_Init();
  4165. down_af_firmware_flag =1;
  4166. INFO_BLUE("ov5640 device probed success\n");
  4167. return 0;
  4168. }
  4169. static int ov5640_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
  4170. {
  4171. struct i2c_client *client = v4l2_get_subdevdata(sd);
  4172. struct ov5640_priv *priv = to_ov5640(client);
  4173. int err = 0;
  4174. OV_INFO("%s: control ctrl- %s\n", __func__, v4l2_ctrl_get_name(ctrl->id));
  4175. printk("%s: control ctrl- id = %d\n", __func__, ctrl->id);
  4176. switch (ctrl->id) {
  4177. case V4L2_CID_BRIGHTNESS:
  4178. ctrl->value = priv->brightness;
  4179. break;
  4180. case V4L2_CID_CONTRAST:
  4181. ctrl->value = priv->contrast;
  4182. break;
  4183. case V4L2_CID_SATURATION:
  4184. ctrl->value = priv->saturation;
  4185. break;
  4186. case V4L2_CID_HUE:
  4187. ctrl->value = priv->hue;
  4188. break;
  4189. // case V4L2_CID_BLACK_LEVEL:
  4190. // ctrl->value = priv->black_level;
  4191. // break;
  4192. #if 0
  4193. case V4L2_CID_AUTO_WHITE_BALANCE:
  4194. ctrl->value = priv->auto_white_balance;
  4195. break;
  4196. // case V4L2_CID_DO_WHITE_BALANCE:
  4197. // ctrl->value = priv->do_white_balance;
  4198. // break;
  4199. // case V4L2_CID_RED_BALANCE:
  4200. // ctrl->value = priv->red_balance;
  4201. // break;
  4202. // case V4L2_CID_BLUE_BALANCE:
  4203. // ctrl->value = priv->blue_balance;
  4204. // break;
  4205. // case V4L2_CID_GAMMA:
  4206. // ctrl->value = priv->gamma;
  4207. // break;
  4208. #endif
  4209. case V4L2_CID_EXPOSURE:
  4210. ctrl->value = priv->exposure;
  4211. break;
  4212. #if 0
  4213. case V4L2_CID_AUTOGAIN:
  4214. ctrl->value = priv->autogain;
  4215. break;
  4216. case V4L2_CID_GAIN:
  4217. ctrl->value = priv->gain;
  4218. break;
  4219. #endif
  4220. case V4L2_CID_HFLIP:
  4221. ctrl->value = !!(priv->flip_flag & OV5640_HFLIP);
  4222. break;
  4223. case V4L2_CID_VFLIP:
  4224. ctrl->value = !!(priv->flip_flag & OV5640_VFLIP);
  4225. break;
  4226. #if 0
  4227. case V4L2_CID_POWER_LINE_FREQUENCY:
  4228. ctrl->value = priv->power_line_frequency;
  4229. break;
  4230. // case V4L2_CID_HUE_AUTO:
  4231. // ctrl->value = priv->hue_auto;
  4232. // break;
  4233. case V4L2_CID_WHITE_BALANCE_TEMPERATURE:
  4234. ctrl->value = priv->white_balance_temperature;
  4235. break;
  4236. #endif
  4237. case V4L2_CID_SHARPNESS:
  4238. ctrl->value = priv->sharpness;
  4239. break;
  4240. // case V4L2_CID_BACKLIGHT_COMPENSATION:
  4241. // ctrl->value = priv->backlight_compensation;
  4242. // break;
  4243. // case V4L2_CID_CHROMA_AGC:
  4244. // ctrl->value = priv->chroma_agc;
  4245. // break;
  4246. // case V4L2_CID_CHROMA_GAIN:
  4247. // ctrl->value = priv->chroma_gain;
  4248. // break;
  4249. // case V4L2_CID_COLOR_KILLER:
  4250. // ctrl->value = priv->color_killer;
  4251. // break;
  4252. case V4L2_CID_COLORFX:
  4253. ctrl->value = priv->colorfx;
  4254. break;
  4255. #if 0
  4256. // case V4L2_CID_AUTOBRIGHTNESS:
  4257. // ctrl->value = priv->autobrightness;
  4258. // break;
  4259. case V4L2_CID_BAND_STOP_FILTER:
  4260. ctrl->value = priv->band_stop_filter;
  4261. break;
  4262. // case V4L2_CID_ROTATE:
  4263. // ctrl->value = priv->rotate;
  4264. // break;
  4265. // case V4L2_CID_BG_COLOR:
  4266. // ctrl->value = priv->bg_color;
  4267. // break;
  4268. case V4L2_CID_EXPOSURE_AUTO:
  4269. ctrl->value = priv->exposure_auto;
  4270. break;
  4271. // case V4L2_CID_EXPOSURE_ABSOLUTE:
  4272. // case V4L2_CID_EXPOSURE_AUTO_PRIORITY:
  4273. // case V4L2_CID_PAN_RELATIVE:
  4274. // case V4L2_CID_TILT_RELATIVE:
  4275. // case V4L2_CID_PAN_RESET:
  4276. // case V4L2_CID_TILT_RESET:
  4277. // case V4L2_CID_PAN_ABSOLUTE:
  4278. // case V4L2_CID_TILT_ABSOLUTE:
  4279. // case V4L2_CID_FOCUS_ABSOLUTE:
  4280. // case V4L2_CID_FOCUS_RELATIVE:
  4281. // case V4L2_CID_FOCUS_AUTO:
  4282. // case V4L2_CID_ZOOM_ABSOLUTE:
  4283. // case V4L2_CID_ZOOM_RELATIVE:
  4284. // case V4L2_CID_ZOOM_CONTINUOUS:
  4285. // case V4L2_CID_IRIS_ABSOLUTE:
  4286. // case V4L2_CID_IRIS_RELATIVE:
  4287. // case V4L2_CID_PRIVACY:
  4288. case V4L2_CID_SCENE_EXPOSURE:
  4289. ctrl->value = priv->scene_exposure;
  4290. break;
  4291. #endif
  4292. /* add by cym 20130829 */
  4293. case V4L2_CID_CAMERA_AUTO_FOCUS_RESULT:
  4294. //android4.0 use this, it is very important for take picture,android4.4 not use.
  4295. err = ov5640_get_auto_focus_result(sd, ctrl);
  4296. break;
  4297. /* end add */
  4298. default:
  4299. OV_ERR("invalid control ctrl: %s\n", v4l2_ctrl_get_name(ctrl->id));
  4300. return (-EINVAL);
  4301. }
  4302. return (0);
  4303. }
  4304. static int ov5640_s_ext_ctrls(struct v4l2_subdev *sd,
  4305. struct v4l2_ext_controls *ctrls)
  4306. {
  4307. //struct i2c_client *client = v4l2_get_subdevdata(sd);
  4308. struct v4l2_control ctrl;
  4309. int i;
  4310. int err = 0;
  4311. if ((ctrls->ctrl_class != V4L2_CTRL_CLASS_USER)
  4312. && (ctrls->ctrl_class != V4L2_CTRL_CLASS_CAMERA)) {
  4313. OV_ERR("ctrl class[%s] is illegal.\n", v4l2_ctrl_get_name(ctrls->ctrl_class));
  4314. return (-EINVAL);
  4315. }
  4316. for (i = 0; i < ctrls->count; i++) {
  4317. ctrl.id = ctrls->controls[i].id;
  4318. ctrl.value = ctrls->controls[i].value;
  4319. err = ov5640_s_ctrl(sd, &ctrl);
  4320. //ctrls->controls[i].value = ctrl.value;
  4321. if (err) {
  4322. ctrls->error_idx = i;
  4323. break;
  4324. }
  4325. }
  4326. return (err);
  4327. }
  4328. static int ov5640_g_ext_ctrls(struct v4l2_subdev *sd,
  4329. struct v4l2_ext_controls *ctrls)
  4330. {
  4331. //struct i2c_client *client = v4l2_get_subdevdata(sd);
  4332. struct v4l2_control ctrl;
  4333. int i;
  4334. int err = 0;
  4335. if ((ctrls->ctrl_class != V4L2_CTRL_CLASS_USER)
  4336. && (ctrls->ctrl_class != V4L2_CTRL_CLASS_CAMERA)) {
  4337. OV_ERR("ctrl class[%s] is illegal.\n", v4l2_ctrl_get_name(ctrls->ctrl_class));
  4338. return (-EINVAL);
  4339. }
  4340. for (i = 0; i < ctrls->count; i++) {
  4341. ctrl.id = ctrls->controls[i].id;
  4342. //ctrl.value = ctrls->controls[i].value;
  4343. err = ov5640_g_ctrl(sd, &ctrl);
  4344. ctrls->controls[i].value = ctrl.value;
  4345. if (err) {
  4346. ctrls->error_idx = i;
  4347. break;
  4348. }
  4349. }
  4350. return (err);
  4351. }
  4352. static int ov5640_try_ctrl(struct v4l2_subdev *sd,
  4353. struct v4l2_ext_control *ctrl)
  4354. {
  4355. struct v4l2_queryctrl qctrl;
  4356. const char **menu_items = NULL;
  4357. int err;
  4358. qctrl.id = ctrl->id;
  4359. err = ov5640_queryctrl(sd, &qctrl);
  4360. if (err)
  4361. return (err);
  4362. if (qctrl.type == V4L2_CTRL_TYPE_MENU)
  4363. menu_items = v4l2_ctrl_get_menu(qctrl.id);
  4364. return v4l2_ctrl_check(ctrl, &qctrl, menu_items);
  4365. }
  4366. static int ov5640_try_ext_ctrls(struct v4l2_subdev *sd,
  4367. struct v4l2_ext_controls *ctrls)
  4368. {
  4369. //struct i2c_client *client = v4l2_get_subdevdata(sd);
  4370. int i;
  4371. int err = 0;
  4372. if ((ctrls->ctrl_class != V4L2_CTRL_CLASS_USER)
  4373. && (ctrls->ctrl_class != V4L2_CTRL_CLASS_CAMERA)) {
  4374. OV_ERR("ctrl_class[%s] is illegal.\n", v4l2_ctrl_get_name(ctrls->ctrl_class));
  4375. return (-EINVAL);
  4376. }
  4377. for (i = 0; i < ctrls->count; i++) {
  4378. err = ov5640_try_ctrl(sd, &ctrls->controls[i]);
  4379. if (err) {
  4380. ctrls->error_idx = i;
  4381. break;
  4382. }
  4383. }
  4384. return (err);
  4385. }
  4386. #ifdef CONFIG_VIDEO_ADV_DEBUG
  4387. static int ov5640_g_register(struct v4l2_subdev *sd,
  4388. struct v4l2_dbg_register *reg)
  4389. {
  4390. struct i2c_client *client = v4l2_get_subdevdata(sd);
  4391. unsigned char val;
  4392. int err;
  4393. reg->size = 2;
  4394. if (reg->reg > 0x603f) {
  4395. return (-EINVAL);
  4396. }
  4397. err = i2cc_get_reg(client, reg->reg, &val);
  4398. if (err) {
  4399. return (err);
  4400. }
  4401. reg->val = val;
  4402. return (0);
  4403. }
  4404. static int ov5640_s_register(struct v4l2_subdev *sd,
  4405. struct v4l2_dbg_register *reg)
  4406. {
  4407. struct i2c_client *client = v4l2_get_subdevdata(sd);
  4408. if (reg->reg > 0x603f) {
  4409. return (-EINVAL);
  4410. }
  4411. return (i2cc_set_reg(client, (unsigned short)reg->reg,(unsigned char)reg->val));
  4412. }
  4413. #endif
  4414. static struct soc_camera_ops ov5640_ops = {
  4415. .set_bus_param = ov5640_set_bus_param,
  4416. .query_bus_param = ov5640_query_bus_param,
  4417. //.controls = ov5640_controls,
  4418. //.num_controls = ARRAY_SIZE(ov5640_controls),
  4419. };
  4420. static struct v4l2_subdev_core_ops ov5640_subdev_core_ops = {
  4421. .init = ov5640_init,
  4422. .g_ctrl = ov5640_g_ctrl,
  4423. .s_ctrl = ov5640_s_ctrl,
  4424. .queryctrl = ov5640_queryctrl,
  4425. .g_ext_ctrls = ov5640_g_ext_ctrls,
  4426. .s_ext_ctrls = ov5640_s_ext_ctrls,
  4427. .try_ext_ctrls = ov5640_try_ext_ctrls,
  4428. .g_chip_ident = ov5640_g_chip_ident,
  4429. #ifdef CONFIG_VIDEO_ADV_DEBUG
  4430. .g_register = ov5640_g_register,
  4431. .s_register = ov5640_s_register,
  4432. #endif
  4433. };
  4434. static struct v4l2_subdev_video_ops ov5640_subdev_video_ops = {
  4435. .s_stream = ov5640_s_stream,
  4436. .g_mbus_fmt = ov5640_g_fmt,
  4437. .s_mbus_fmt = ov5640_s_fmt,
  4438. .try_mbus_fmt = ov5640_try_fmt,
  4439. .cropcap = ov5640_cropcap,
  4440. .g_crop = ov5640_g_crop,
  4441. .enum_mbus_fmt = ov5640_enum_fmt,
  4442. .enum_framesizes = ov5640_enum_framesizes,
  4443. };
  4444. static struct v4l2_subdev_ops ov5640_subdev_ops = {
  4445. .core = &ov5640_subdev_core_ops,
  4446. .video = &ov5640_subdev_video_ops,
  4447. };
  4448. #if 0 //remove by cym 20130807
  4449. static int ov5640_video_probe(struct soc_camera_device *icd,
  4450. struct i2c_client *client)
  4451. {
  4452. struct ov5640_priv *priv = to_ov5640(client);
  4453. unsigned char pid;
  4454. unsigned char version;
  4455. /*
  4456. * We must have a parent by now. And it cannot be a wrong one.
  4457. * So this entire test is completely redundant.
  4458. */
  4459. if (NULL == icd->dev.parent ||
  4460. to_soc_camera_host(icd->dev.parent)->nr != icd->iface) {
  4461. OV_ERR("error : has a wrong parent\n");
  4462. //return (-ENODEV);
  4463. }
  4464. // check and show product ID and manufacturer ID
  4465. i2cc_get_reg(client, 0x300a, &pid);
  4466. i2cc_get_reg(client, 0x300b, &version);
  4467. if (OV5640 != VERSION(pid, version)) {
  4468. OV_ERR("ov5640 probed failed!!\n");
  4469. return (-ENODEV);
  4470. }
  4471. priv->model = 1;//cym V4L2_IDENT_OV5640;
  4472. INFO_BLUE("ov5640 device probed success\n");
  4473. return (0);
  4474. }
  4475. #endif
  4476. static int ov5640_probe(struct i2c_client *client,
  4477. const struct i2c_device_id *did)
  4478. {
  4479. struct ov5640_priv *priv;
  4480. struct v4l2_subdev *sd = NULL;
  4481. struct soc_camera_device *icd = client->dev.platform_data;
  4482. //struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
  4483. struct soc_camera_link *icl;
  4484. int ret = 0;
  4485. OV_INFO("ov5640 probe start...\n");
  4486. if (NULL == icd) {
  4487. ret = -EINVAL;
  4488. OV_ERR("error: missing soc camera device\n");
  4489. goto failed;
  4490. }
  4491. g_client=client;
  4492. /* add by cym 20130605 */
  4493. #ifndef CONFIG_TC4_EVT
  4494. ov_vdd18_cam_regulator = regulator_get(NULL, "vdd18_cam");
  4495. if (IS_ERR(ov_vdd18_cam_regulator)) {
  4496. printk("%s: failed to get %s\n", __func__, "vdd18_cam");
  4497. ret = -ENODEV;
  4498. goto err_regulator;
  4499. }
  4500. ov_vdd28_cam_regulator = regulator_get(NULL, "vdda28_2m");
  4501. if (IS_ERR(ov_vdd28_cam_regulator)) {
  4502. printk("%s: failed to get %s\n", __func__, "vdda28_2m");
  4503. ret = -ENODEV;
  4504. goto err_regulator;
  4505. }
  4506. ov_vddaf_cam_regulator = regulator_get(NULL, "vdd28_af");
  4507. if (IS_ERR(ov_vddaf_cam_regulator)) {
  4508. printk("%s: failed to get %s\n", __func__, "vdd28_af");
  4509. ret = -ENODEV;
  4510. goto err_regulator;
  4511. }
  4512. ov_vdd5m_cam_regulator = regulator_get(NULL, "vdd28_cam");
  4513. if (IS_ERR(ov_vdd5m_cam_regulator)) {
  4514. printk("%s: failed to get %s\n", __func__, "vdd28_cam");
  4515. ret = -ENODEV;
  4516. goto err_regulator;
  4517. }
  4518. // ov5640_power(1);
  4519. #endif
  4520. /* end add */
  4521. icl = to_soc_camera_link(icd);
  4522. if (NULL == icl) {
  4523. ret = -EINVAL;
  4524. OV_ERR("error: missing soc camera link\n");
  4525. //cym goto failed;
  4526. }
  4527. ret = i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA);
  4528. if (0 == ret) {
  4529. ret = -EINVAL;
  4530. OV_ERR("I2C DOESN'T support I2C_FUNC_SMBUS_BYTE_DATA\n");
  4531. goto failed;
  4532. }
  4533. priv = (struct ov5640_priv *)kzalloc(sizeof(struct ov5640_priv), GFP_KERNEL);
  4534. if (NULL == priv) {
  4535. ret = -ENOMEM;
  4536. OV_ERR("alloc ov5640_priv struct failed!\n");
  4537. goto failed;
  4538. }
  4539. sd = &priv->subdev;
  4540. strcpy(sd->name, OV5640_I2C_NAME);
  4541. v4l2_i2c_subdev_init(sd, client, &ov5640_subdev_ops);
  4542. icd->ops = &ov5640_ops;
  4543. #if 0
  4544. ret = ov5640_video_probe(icd, client);
  4545. if (ret) {
  4546. icd->ops = NULL;
  4547. kfree(priv);
  4548. OV_ERR("error : failed to probe camera device");
  4549. }
  4550. #endif
  4551. failed:
  4552. //return (ret);
  4553. return (0);
  4554. #ifndef CONFIG_TC4_EVT
  4555. err_regulator:
  4556. ov5640_power(0);
  4557. regulator_put(ov_vddaf_cam_regulator);
  4558. regulator_put(ov_vdd5m_cam_regulator);
  4559. /* add by cym 20130506 */
  4560. regulator_put(ov_vdd18_cam_regulator);
  4561. regulator_put(ov_vdd28_cam_regulator);
  4562. /* end add */
  4563. return ret;
  4564. #endif
  4565. }
  4566. static int ov5640_remove(struct i2c_client *client)
  4567. {
  4568. struct ov5640_priv *priv = to_ov5640(client);
  4569. struct soc_camera_device *icd = client->dev.platform_data;
  4570. struct v4l2_subdev *sd = i2c_get_clientdata(client);
  4571. v4l2_device_unregister_subdev(sd);
  4572. //icd->ops = NULL;
  4573. kfree(priv);
  4574. INFO_RED("ov5640 device removed!\n");
  4575. #ifndef CONFIG_TC4_EVT
  4576. ov5640_power(0);
  4577. regulator_put(ov_vddaf_cam_regulator);
  4578. regulator_put(ov_vdd5m_cam_regulator);
  4579. regulator_put(ov_vdd18_cam_regulator);
  4580. regulator_put(ov_vdd28_cam_regulator);
  4581. down_af_firmware_flag = 0;
  4582. /* end add */
  4583. #endif
  4584. return (0);
  4585. }
  4586. #if 0
  4587. static int ov5640_detect(struct i2c_client *client, struct i2c_board_info *info)
  4588. {
  4589. strcpy(info->type, OV5640_I2C_NAME);
  4590. return 0;
  4591. }
  4592. #endif
  4593. static const struct i2c_device_id ov5640_id[] = {
  4594. { OV5640_I2C_NAME, 0 },
  4595. { }
  4596. };
  4597. MODULE_DEVICE_TABLE(i2c, ov5640_id);
  4598. static const unsigned short ov5640_addrs[] = {
  4599. OV5640_I2C_ADDR,
  4600. I2C_CLIENT_END,
  4601. };
  4602. #if 0
  4603. struct i2c_board_info ov5640_info = {
  4604. I2C_BOARD_INFO(OV5640_I2C_NAME, OV5640_I2C_ADDR),
  4605. };
  4606. #endif
  4607. static struct i2c_driver ov5640_i2c_driver = {
  4608. .driver = {
  4609. .name = OV5640_I2C_NAME,
  4610. .owner = THIS_MODULE,
  4611. },
  4612. .class = I2C_CLASS_HWMON,
  4613. .probe = ov5640_probe,
  4614. .remove = ov5640_remove,
  4615. .id_table = ov5640_id,
  4616. .address_list = ov5640_addrs,
  4617. };
  4618. /*
  4619. * module function
  4620. */
  4621. static int __init ov5640_module_init(void)
  4622. {
  4623. OV_INFO("install module\n");
  4624. printk("%s\n", __FUNCTION__);
  4625. return i2c_add_driver(&ov5640_i2c_driver);
  4626. }
  4627. static void __exit ov5640_module_exit(void)
  4628. {
  4629. OV_INFO("uninstall module\n");
  4630. i2c_del_driver(&ov5640_i2c_driver);
  4631. }
  4632. module_init(ov5640_module_init);
  4633. module_exit(ov5640_module_exit);
  4634. MODULE_DESCRIPTION("SoC Camera driver for ov5640");
  4635. MODULE_AUTHOR("caoym@topeet.com ");
  4636. MODULE_LICENSE("GPL v2");

发表评论

表情:
评论列表 (有 0 条评论,2296人围观)

还没有评论,来说两句吧...

相关阅读