camera: add commit ov3660.c file
authorddl <ddl@rock-chips.com>
Wed, 16 May 2012 03:32:49 +0000 (11:32 +0800)
committerddl <ddl@rock-chips.com>
Wed, 16 May 2012 03:32:49 +0000 (11:32 +0800)
drivers/media/video/ov3660.c [new file with mode: 0755]

diff --git a/drivers/media/video/ov3660.c b/drivers/media/video/ov3660.c
new file mode 100755 (executable)
index 0000000..2684555
--- /dev/null
@@ -0,0 +1,3573 @@
+/*\r
+o* Driver for MT9M001 CMOS Image Sensor from Micron\r
+ *\r
+ * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License version 2 as\r
+ * published by the Free Software Foundation.\r
+ */\r
+\r
+#include <linux/videodev2.h>\r
+#include <linux/slab.h>\r
+#include <linux/i2c.h>\r
+#include <linux/log2.h>\r
+#include <linux/platform_device.h>\r
+#include <linux/delay.h>\r
+#include <linux/circ_buf.h>\r
+#include <linux/miscdevice.h>\r
+#include <media/v4l2-common.h>\r
+#include <media/v4l2-chip-ident.h>\r
+#include <media/soc_camera.h>\r
+#include <plat/rk_camera.h>\r
+\r
+\r
+\r
+static int debug;\r
+\r
+\r
+\r
+module_param(debug, int, S_IRUGO|S_IWUSR);\r
+\r
+#define dprintk(level, fmt, ...) do {                  \\r
+       if (debug >= level)                                     \\r
+       printk(KERN_WARNING fmt , ## __VA_ARGS__); } while (0)\r
+\r
+#define SENSOR_TR(format, ...) printk(KERN_ERR format, ## __VA_ARGS__)\r
+#define SENSOR_DG(format, ...) dprintk(1, format, ## __VA_ARGS__)\r
+\r
+\r
+#define _CONS(a,b) a##b\r
+#define CONS(a,b) _CONS(a,b)\r
+\r
+#define __STR(x) #x\r
+#define _STR(x) __STR(x)\r
+#define STR(x) _STR(x)\r
+\r
+#define MIN(x,y)   ((x<y) ? x: y)\r
+#define MAX(x,y)    ((x>y) ? x: y)\r
+\r
+/* Sensor Driver Configuration */\r
+#define SENSOR_NAME ov3660\r
+#define SENSOR_V4L2_IDENT  V4L2_IDENT_OV3660\r
+#define SENSOR_ID 0x3660\r
+#define SENSOR_MIN_WIDTH    800\r
+#define SENSOR_MIN_HEIGHT   600\r
+#define SENSOR_MAX_WIDTH    2048\r
+#define SENSOR_MAX_HEIGHT   1536\r
+#define SENSOR_INIT_WIDTH      800                     /* Sensor pixel size for sensor_init_data array */\r
+#define SENSOR_INIT_HEIGHT  600\r
+#define SENSOR_INIT_WINSEQADR sensor_svga\r
+#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8\r
+\r
+#define CONFIG_SENSOR_WhiteBalance     1\r
+#define CONFIG_SENSOR_Brightness       0\r
+#define CONFIG_SENSOR_Contrast      0\r
+#define CONFIG_SENSOR_Saturation    0\r
+#define CONFIG_SENSOR_Effect        1\r
+#define CONFIG_SENSOR_Scene         1\r
+#define CONFIG_SENSOR_DigitalZoom   0\r
+#define CONFIG_SENSOR_Focus         0\r
+#define CONFIG_SENSOR_Exposure      0\r
+#define CONFIG_SENSOR_Flash         1\r
+#define CONFIG_SENSOR_Mirror        0\r
+#define CONFIG_SENSOR_Flip          0\r
+\r
+#define CONFIG_SENSOR_I2C_SPEED     350000       /* Hz */\r
+/* Sensor write register continues by preempt_disable/preempt_enable for current process not be scheduled */\r
+#define CONFIG_SENSOR_I2C_NOSCHED   0\r
+#define CONFIG_SENSOR_I2C_RDWRCHK   0\r
+\r
+#define SENSOR_BUS_PARAM  (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|\\r
+                          SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |\\r
+                          SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8  |SOCAM_MCLK_24MHZ)\r
+\r
+#define COLOR_TEMPERATURE_CLOUDY_DN  6500\r
+#define COLOR_TEMPERATURE_CLOUDY_UP    8000\r
+#define COLOR_TEMPERATURE_CLEARDAY_DN  5000\r
+#define COLOR_TEMPERATURE_CLEARDAY_UP    6500\r
+#define COLOR_TEMPERATURE_OFFICE_DN     3500\r
+#define COLOR_TEMPERATURE_OFFICE_UP     5000\r
+#define COLOR_TEMPERATURE_HOME_DN       2500\r
+#define COLOR_TEMPERATURE_HOME_UP       3500\r
+\r
+#define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))\r
+#define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)\r
+\r
+#define SENSOR_AF_IS_ERR    (0x00<<0)\r
+#define SENSOR_AF_IS_OK                (0x01<<0)\r
+#define SENSOR_INIT_IS_ERR   (0x00<<28)\r
+#define SENSOR_INIT_IS_OK    (0x01<<28)\r
+\r
+struct reginfo\r
+{\r
+    u16 reg;\r
+    u8 val;\r
+};\r
+\r
+//flash off in fixed time to prevent from too hot , zyc\r
+struct  flash_timer{\r
+    struct soc_camera_device *icd;\r
+    struct hrtimer timer;\r
+};\r
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);\r
+\r
+static struct  flash_timer flash_off_timer;\r
+//for user defined if user want to customize the series , zyc\r
+/* init 800*600 SVGA */\r
+static struct reginfo sensor_init_data[] =\r
+{\r
+       //Jacky_M\r
+       {0x3008,0x82},\r
+       {0x3103,0x13},\r
+       {0x3008,0x42},\r
+       {0x3017,0xff},\r
+       {0x3018,0xff},\r
+       //{0x302c,0x43},\r
+       {0x3032,0x00},\r
+       {0x3901,0x13},\r
+       {0x3704,0x80},\r
+       {0x3717,0x00},\r
+       {0x371b,0x60},\r
+       {0x370b,0x10},\r
+       {0x3624,0x03},\r
+       {0x3622,0x80},\r
+       {0x3614,0x80},\r
+       {0x3630,0x52},\r
+       {0x3632,0x07},\r
+       {0x3633,0xd2},\r
+       {0x3619,0x75},\r
+       {0x371c,0x00},\r
+       {0x370b,0x12},\r
+       {0x3704,0x80},\r
+       {0x3600,0x08},\r
+       {0x3620,0x43},\r
+       {0x3702,0x20},\r
+       {0x3739,0x48},\r
+       {0x3730,0x20},\r
+       {0x370c,0x0c},\r
+       {0x3a18,0x00},\r
+       {0x3a19,0xf8},\r
+       {0x3000,0x10},\r
+       {0x3004,0xef},\r
+       {0x6700,0x05},\r
+       {0x6701,0x19},\r
+       {0x6702,0xfd},\r
+       {0x6703,0xd1},\r
+       {0x6704,0xff},\r
+       {0x6705,0xff},\r
+       {0x3002,0x1c},\r
+       {0x3006,0xc3},\r
+       {0x3800,0x00},\r
+       {0x3801,0x00},\r
+       {0x3802,0x00},\r
+       {0x3803,0x00},\r
+       {0x3804,0x08},\r
+       {0x3805,0x1f},\r
+       {0x3806,0x06},\r
+       {0x3807,0x07},\r
+       {0x3808,0x04},\r
+       {0x3809,0x00},\r
+       {0x380a,0x03},\r
+       {0x380b,0x00},\r
+       {0x380c,0x08},\r
+       {0x380d,0xfc},\r
+       {0x380e,0x03},\r
+       {0x380f,0x14},\r
+       {0x3810,0x00},\r
+       {0x3811,0x08},\r
+       {0x3812,0x00},\r
+       {0x3813,0x02},\r
+       {0x3814,0x31},\r
+       {0x3815,0x31},\r
+       {0x3820,0x01},\r
+       {0x3821,0x01},\r
+       {0x3824,0x01},\r
+       {0x3826,0x23},\r
+       {0x3a02,0x30},\r
+       {0x3a03,0xc0},\r
+       {0x3a08,0x00},\r
+       {0x3a09,0xec},\r
+       {0x3a0a,0x00},\r
+       {0x3a0b,0xc5},\r
+       {0x3a0d,0x04},\r
+       {0x3a0e,0x03},\r
+       {0x3a14,0x30},\r
+       {0x3a15,0x72},\r
+       {0x3618,0x00},\r
+       {0x3623,0x00},\r
+       {0x3708,0x64},\r
+       {0x3709,0x52},\r
+       {0x4300,0x30},//0x32},//0x31},//0x30},\r
+       {0x440e,0x09},\r
+       {0x4514,0xaa},\r
+       {0x4520,0x0b},\r
+       {0x460b,0x37},\r
+       {0x460c,0x20},\r
+       {0x4713,0x02},\r
+       {0x471c,0xd0},\r
+       {0x5086,0x00},\r
+       {0x5000,0x07},\r
+       {0x5001,0x03},\r
+       {0x5002,0x00},\r
+       {0x501f,0x00},\r
+       {0x3008,0x02},\r
+       {0x302c,0x43},  \r
+       {0x3a00,0x38},\r
+       {0x303c,0x12},  //0x15//jack change to 0x15\r
+       {0x440e,0x08}, \r
+       \r
+       {0x5180,0xff},\r
+       {0x5181,0xf2},\r
+       {0x5182,0x0 },\r
+       {0x5183,0x14},\r
+       {0x5184,0x25},\r
+       {0x5185,0x24},\r
+       {0x5186,0x9 },\r
+       {0x5187,0x9 },\r
+       {0x5188,0x9 },\r
+       {0x5189,0x75},\r
+       {0x518a,0x54},\r
+       {0x518b,0xe0},\r
+       {0x518c,0xb2},\r
+       {0x518d,0x42},\r
+       {0x518e,0x3d},\r
+       {0x518f,0x56},\r
+       {0x5190,0x46},\r
+       {0x5191,0xf8},\r
+       {0x5192,0x4 },\r
+       {0x5193,0x70},\r
+       {0x5194,0xf0},\r
+       {0x5195,0xf0},\r
+       {0x5196,0x3 },\r
+       {0x5197,0x1 },\r
+       {0x5198,0x4 },\r
+       {0x5199,0x12},\r
+       {0x519a,0x4 },\r
+       {0x519b,0x0 },\r
+       {0x519c,0x6 },\r
+       {0x519d,0x82},\r
+       {0x519e,0x38},\r
+       {0x5381,0x1c},  \r
+       {0x5382,0x5a},\r
+       {0x5383,0x6 },\r
+       {0x5384,0xa },\r
+       {0x5385,0x7e},\r
+       {0x5386,0x88},\r
+       {0x5387,0x7c},\r
+       {0x5388,0x6c},\r
+       {0x5389,0x10},\r
+       {0x538a,0x1 },\r
+       {0x538b,0x98},\r
+       {0x5000,0x27}, \r
+       {0x5481,0x8 },\r
+       {0x5482,0x14},\r
+       {0x5483,0x28},\r
+       {0x5484,0x51},\r
+       {0x5485,0x65},\r
+       {0x5486,0x71},\r
+       {0x5487,0x7d},\r
+       {0x5488,0x87},\r
+       {0x5489,0x91},\r
+       {0x548a,0x9a},\r
+       {0x548b,0xaa},\r
+       {0x548c,0xb8},\r
+       {0x548d,0xcd},\r
+       {0x548e,0xdd},\r
+       {0x548f,0xea},\r
+       {0x5490,0x1d},\r
+       {0x3821,0x06},\r
+       {0x4514,0xbb},\r
+       {0x3a0f,0x38},\r
+       {0x3a10,0x30},\r
+       {0x3a1b,0x38},\r
+       {0x3a1e,0x30},\r
+       {0x3a11,0x70},\r
+       {0x3a1f,0x14},\r
+       {0x3a18,0x0 },\r
+       {0x3808,0x03},\r
+       {0x3809,0x20},\r
+       {0x380a,0x02},\r
+       {0x380b,0x58},\r
+\r
+//  preview vga\r
+{0x303c, 0x12},\r
+{0x3824, 0x02},\r
+{0x460c, 0x22},        \r
+//XGA Windowing\r
+{0x5001, 0x83},\r
+{0x3800, 0x00},\r
+{0x3801, 0x00},\r
+{0x3802, 0x00},\r
+{0x3803, 0x00},\r
+{0x3804, 0x08},\r
+{0x3805, 0x1f},\r
+{0x3806, 0x06},\r
+{0x3807, 0x09},\r
+{0x3808, 0x04},\r
+{0x3809, 0x00},\r
+{0x380a, 0x03},\r
+{0x380b, 0x00},\r
+{0x380c, 0x08},\r
+{0x380d, 0xfc},\r
+{0x380e, 0x03},\r
+{0x380f, 0x14},\r
+{0x3810, 0x00},\r
+{0x3811, 0x08},\r
+{0x3812, 0x00},\r
+{0x3813, 0x02},\r
+{0x3814, 0x31},\r
+{0x3815, 0x31},\r
+       \r
+{0x3708, 0x66},\r
+{0x3709, 0x12},\r
+{0x370c, 0x0c},\r
+{0x4520, 0x0b},\r
+{0x302c, 0x03},\r
+\r
+//Bining mode\r
+{0x3820, 0x01},\r
+{0x3821, 0x03},//0x01\r
+{0x4514, 0xaa},        \r
+\r
+//vga  \r
+{0x5001, 0xa3},\r
+{0x3808, 0x02},\r
+{0x3809, 0x80},\r
+{0x380a, 0x01},\r
+{0x380b, 0xe0},\r
+{0x380c, 0x08},\r
+{0x380d, 0xfc},\r
+{0x380e, 0x03},\r
+{0x380f, 0x14},\r
+{0x3810, 0x00},\r
+{0x3811, 0x08},\r
+{0x3812, 0x00},\r
+{0x3813, 0x02},\r
+{0x3814, 0x31},\r
+{0x3815, 0x31},\r
+\r
+\r
+       {0x5001,0xa7},\r
+       //ISP\r
+       {0x5000, 0xa7},\r
+{0x5001, 0x03},\r
+//OV3660 LENC setting\r
+{0x5800, 0x23},\r
+{0x5801, 0x10},\r
+{0x5802, 0xe },\r
+{0x5803, 0xe },\r
+{0x5804, 0x11},\r
+{0x5805, 0x1e},\r
+{0x5806, 0xa },\r
+{0x5807, 0x7 },\r
+{0x5808, 0x5 },\r
+{0x5809, 0x5 },\r
+{0x580a, 0x7 },\r
+{0x580b, 0xc },\r
+{0x580c, 0x7 },\r
+{0x580d, 0x3 },\r
+{0x580e, 0x0 },\r
+{0x580f, 0x0 },\r
+{0x5810, 0x3 },\r
+{0x5811, 0x8 },\r
+{0x5812, 0x8 },\r
+{0x5813, 0x3 },\r
+{0x5814, 0x0 },\r
+{0x5815, 0x0 },\r
+{0x5816, 0x3 },\r
+{0x5817, 0x9 },\r
+{0x5818, 0xb },\r
+{0x5819, 0x7 },\r
+{0x581a, 0x5 },\r
+{0x581b, 0x5 },\r
+{0x581c, 0x8 },\r
+{0x581d, 0xc },\r
+{0x581e, 0x1d},\r
+{0x581f, 0x10},\r
+{0x5820, 0xf },\r
+{0x5821, 0xf },\r
+{0x5822, 0x11},\r
+{0x5823, 0x1e},\r
+{0x5824, 0x45},\r
+{0x5825, 0x29},\r
+{0x5826, 0x1b},\r
+{0x5827, 0x29},\r
+{0x5828, 0x44},\r
+{0x5829, 0x1b},\r
+{0x582a, 0x28},\r
+{0x582b, 0x36},\r
+{0x582c, 0x27},\r
+{0x582d, 0x1a},\r
+{0x582e, 0x1b},\r
+{0x582f, 0x33},\r
+{0x5830, 0x50},\r
+{0x5831, 0x43},\r
+{0x5832, 0x19},\r
+{0x5833, 0x1b},\r
+{0x5834, 0x27},\r
+{0x5835, 0x34},\r
+{0x5836, 0x37},\r
+{0x5837, 0x1a},\r
+{0x5838, 0x47},\r
+{0x5839, 0x19},\r
+{0x583a, 0xa },\r
+{0x583b, 0x19},\r
+{0x583c, 0x35},\r
+{0x583d, 0xce},\r
+       \r
+       \r
+       {0x5180,0xff},//         //;IQ setting example //;Sample_AWB\r
+       {0x5181,0xf2},//\r
+       {0x5182,0x0 },//\r
+       {0x5183,0x14},//\r
+       {0x5184,0x25},//\r
+       {0x5185,0x24},//\r
+       {0x5186,0x0d},//\r
+       {0x5187,0x0f},//\r
+       {0x5188,0x0f},//\r
+       {0x5189,0x75},//\r
+       {0x518a,0x54},//\r
+       {0x518b,0xe0},//\r
+       {0x518c,0xb2},//\r
+       {0x518d,0x3e},//\r
+       {0x518e,0x39},//\r
+       {0x518f,0x52},//\r
+       {0x5190,0x47},//\r
+       {0x5191,0xf8},//\r
+       {0x5192,0x4 },//\r
+       {0x5193,0x70},//\r
+       {0x5194,0xf0},//\r
+       {0x5195,0xf0},//\r
+       {0x5196,0x3 },//\r
+       {0x5197,0x1 },//\r
+       {0x5198,0x4 },//\r
+       {0x5199,0x68},//\r
+       {0x519a,0x4 },//\r
+       {0x519b,0x0 },//\r
+       {0x519c,0x07 },//\r
+       {0x519d,0xa5},//\r
+       {0x519e,0x38},//\r
+       {0x5381,0x1c},//         //;Sample_CMX\r
+       {0x5382,0x5a},//\r
+       {0x5383,0x6 },//\r
+       {0x5384,0x09 },//\r
+       {0x5385,0x71},//\r
+       {0x5386,0x7a},//\r
+       {0x5387,0x70},//\r
+       {0x5388,0x61},//\r
+       {0x5389,0x0e},//\r
+\r
+       {0x538b,0x98},//\r
+       {0x538a,0x1 },//\r
\r
+       {0x3a0f,0x38},//\r
+       {0x3a10,0x30},//\r
+       {0x3a1b,0x38},//\r
+       {0x3a1e,0x30},//\r
+       {0x3a11,0x70},//\r
+       {0x3a1f,0x14},//\r
+//     {0x3a18,0x0 },//\r
+{0x5000,0xa7},\r
+       {0x3503,0x00},\r
+       {0x0000, 0x00}\r
+};\r
+\r
+/* 1280x720 */\r
+static struct reginfo sensor_720p[]=\r
+  {\r
\r
+       {0x3008,0x82},//\r
+       {0x3103,0x13},//\r
+       {0x3008,0x42},//\r
+       {0x3017,0xff},//\r
+       {0x3018,0xff},//\r
+       {0x302c,0x43},//\r
+       {0x3032,0x00},//\r
+       {0x3901,0x13},//\r
+       {0x3704,0x80},//\r
+       {0x3717,0x00},//\r
+       {0x371b,0x60},//\r
+       {0x370b,0x10},//\r
+       {0x3624,0x03},//\r
+       {0x3622,0x80},//\r
+       {0x3614,0x80},//\r
+       {0x3630,0x52},//\r
+       {0x3632,0x07},//\r
+       {0x3633,0xd2},//\r
+       {0x3619,0x75},//\r
+       {0x371c,0x00},//\r
+       {0x370b,0x12},//\r
+       {0x3704,0x80},//\r
+       {0x3600,0x08},//\r
+       {0x3620,0x43},//\r
+       {0x3702,0x20},//\r
+       {0x3739,0x48},//\r
+       {0x3730,0x20},//\r
+       {0x370c,0x0c},//\r
+       {0x3a18,0x00},//\r
+       {0x3a19,0xf8},//\r
+       {0x3000,0x10},//\r
+       {0x3004,0xef},//\r
+       {0x6700,0x05},//\r
+       {0x6701,0x19},//\r
+       {0x6702,0xfd},//\r
+       {0x6703,0xd1},//\r
+       {0x6704,0xff},//\r
+       {0x6705,0xff},//\r
+       {0x3002,0x1c},//\r
+       {0x3006,0xc3},//\r
+       {0x3800,0x01},//\r
+       {0x3801,0x80},//\r
+       {0x3802,0x01},//\r
+       {0x3803,0x98},//\r
+       {0x3804,0x06},//\r
+       {0x3805,0x9f},//\r
+       {0x3806,0x04},//\r
+       {0x3807,0x73},//\r
+       {0x3808,0x05},//\r
+       {0x3809,0x00},//\r
+       {0x380a,0x02},//\r
+       {0x380b,0xd0},//\r
+       {0x380c,0x08},//\r
+       {0x380d,0xfc},//\r
+       {0x380e,0x02},//\r
+       {0x380f,0xec},//\r
+       {0x3810,0x00},//\r
+       {0x3811,0x10},//\r
+       {0x3812,0x00},//\r
+       {0x3813,0x06},//\r
+       {0x3814,0x11},//\r
+       {0x3815,0x11},//\r
+       {0x3820,0x40},//\r
+       {0x3821,0x00},//\r
+       {0x3824,0x01},//\r
+       {0x3826,0x23},//\r
+       {0x3a02,0x30},//\r
+       {0x3a03,0xc0},//\r
+       {0x3a08,0x00},//\r
+       {0x3a09,0xe0},//\r
+       {0x3a0a,0x00},//\r
+       {0x3a0b,0xbb},//\r
+       {0x3a0d,0x04},//\r
+       {0x3a0e,0x03},//\r
+       {0x3a14,0x30},//\r
+       {0x3a15,0x72},//\r
+       {0x3618,0x78},//\r
+       {0x3623,0x00},//\r
+       {0x3708,0x21},//\r
+       {0x3709,0x12},//\r
+       {0x4300,0x30},//\r
+       {0x440e,0x09},//\r
+       {0x4514,0x00},//\r
+       {0x4520,0xb0},//\r
+       {0x460b,0x37},//\r
+       {0x460c,0x20},//\r
+       {0x4713,0x02},//\r
+       {0x471c,0xd0},//\r
+       {0x5086,0x00},//\r
+       {0x5000,0x07},//\r
+       {0x5001,0x03},//\r
+       {0x5002,0x00},//\r
+       {0x501f,0x00},//\r
+       {0x302c,0x43},//  \r
+       {0x3a00,0x38},//\r
+       {0x303c,0x14},//  ;15fps\r
+       {0x440e,0x08},//  ;for MBIST\r
+       {0x3821,0x06},//  ;mirror on\r
+       {0x3008,0x02},//\r
+       //ISP\r
+       {0x5180,0xff},//         //;IQ setting example //;Sample_AWB\r
+       {0x5181,0xf2},//\r
+       {0x5182,0x0 },//\r
+       {0x5183,0x14},//\r
+       {0x5184,0x25},//\r
+       {0x5185,0x24},//\r
+       {0x5186,0x9 },//\r
+       {0x5187,0x9 },//\r
+       {0x5188,0x9 },//\r
+       {0x5189,0x75},//\r
+       {0x518a,0x54},//\r
+       {0x518b,0xe0},//\r
+       {0x518c,0xb2},//\r
+       {0x518d,0x42},//\r
+       {0x518e,0x3d},//\r
+       {0x518f,0x56},//\r
+       {0x5190,0x46},//\r
+       {0x5191,0xf8},//\r
+       {0x5192,0x4 },//\r
+       {0x5193,0x70},//\r
+       {0x5194,0xf0},//\r
+       {0x5195,0xf0},//\r
+       {0x5196,0x3 },//\r
+       {0x5197,0x1 },//\r
+       {0x5198,0x4 },//\r
+       {0x5199,0x12},//\r
+       {0x519a,0x4 },//\r
+       {0x519b,0x0 },//\r
+       {0x519c,0x6 },//\r
+       {0x519d,0x82},//\r
+       {0x519e,0x38},//\r
+       {0x5381,0x1c},//         //;Sample_CMX\r
+       {0x5382,0x5a},//\r
+       {0x5383,0x6 },//\r
+       {0x5384,0xa },//\r
+       {0x5385,0x7e},//\r
+       {0x5386,0x88},//\r
+       {0x5387,0x7c},//\r
+       {0x5388,0x6c},//\r
+       {0x5389,0x10},//\r
+       {0x538a,0x1 },//\r
+       {0x538b,0x98},//\r
+       {0x5000,0x27},// //;Sample_gamma;enable gamma\r
+       {0x5481,0x8 },//\r
+       {0x5482,0x14},//\r
+       {0x5483,0x28},//\r
+       {0x5484,0x51},//\r
+       {0x5485,0x65},//\r
+       {0x5486,0x71},//\r
+       {0x5487,0x7d},//\r
+       {0x5488,0x87},//\r
+       {0x5489,0x91},//\r
+       {0x548a,0x9a},//\r
+       {0x548b,0xaa},//\r
+       {0x548c,0xb8},//\r
+       {0x548d,0xcd},//\r
+       {0x548e,0xdd},//\r
+       {0x548f,0xea},//\r
+       {0x5490,0x1d},//\r
+       {0x3a0f,0x38},//        //;Example_EV\r
+       {0x3a10,0x30},//\r
+       {0x3a1b,0x38},//\r
+       {0x3a1e,0x30},//\r
+       {0x3a11,0x70},//\r
+       {0x3a1f,0x14},//\r
+       {0x3a18,0x0 },//\r
+\r
+       {0x0000, 0x00}\r
+};\r
+/* 2048*1536 QXGA */\r
+static struct reginfo sensor_qxga[] =\r
+{\r
+\r
+{0x303b,0x1b},\r
+{0x303c,0x13},// ;13\r
+{0x303d,0x30},\r
+\r
+{0x3108,0x16},\r
+\r
+{0x3824,0x01},\r
+{0x460C,0x20},\r
+\r
+{0x5001,0x03},\r
+{0x3800,0x00},\r
+{0x3801,0x00},\r
+{0x3802,0x00},\r
+{0x3803,0x00},\r
+{0x3804,0x08},\r
+{0x3805,0x1f},\r
+{0x3806,0x06},\r
+{0x3807,0x0b},\r
+{0x3808,0x08},\r
+{0x3809,0x00},\r
+{0x380a,0x06},\r
+{0x380b,0x00},\r
+{0x380c,0x08},\r
+{0x380d,0xfc},\r
+{0x380e,0x06},\r
+{0x380f,0x1c},\r
+{0x3810,0x00},\r
+{0x3811,0x10},\r
+{0x3812,0x00},\r
+{0x3813,0x06},\r
+{0x3814,0x11},\r
+{0x3815,0x11},\r
+\r
+{0x3708,0x63},\r
+{0x3709,0x12},\r
+{0x370c,0x0c},\r
+{0x4520,0xb0},\r
+{0x302c,0x03},\r
+\r
+       \r
+{0x3820,0x10},//0x40\r
+{0x3821,0x06},//0x00\r
+{0x4514,0x00},\r
+{0x5000,0xa7},\r
+{0x0000, 0x00}\r
\r
+};\r
+\r
+/* 1600X1200 UXGA */\r
+static struct reginfo sensor_uxga[] =\r
+ {\r
\r
+       {0x0000, 0x00}\r
+};\r
+\r
+/* 1280X1024 SXGA */\r
+static struct reginfo sensor_sxga[] =\r
+{\r
+       {0x0, 0x0}\r
+};\r
+/* 1024X768 SXGA */\r
+static struct reginfo sensor_xga[] =\r
+{\r
+       {0x0, 0x0}\r
+};\r
+/* 800X600 SVGA*/\r
+static struct reginfo sensor_svga[] =\r
+{\r
+\r
+       {0x3008,0x82},//\r
+       {0x3103,0x13},//\r
+       {0x3008,0x42},//\r
+       {0x3017,0xff},//\r
+       {0x3018,0xff},//\r
+       {0x302c,0x43},//\r
+       {0x3032,0x00},//\r
+       {0x3901,0x13},//\r
+       {0x3704,0x80},//\r
+       {0x3717,0x00},//\r
+       {0x371b,0x60},//\r
+       {0x370b,0x10},//\r
+       {0x3624,0x03},//\r
+       {0x3622,0x80},//\r
+       {0x3614,0x80},//\r
+       {0x3630,0x52},//\r
+       {0x3632,0x07},//\r
+       {0x3633,0xd2},//\r
+       {0x3619,0x75},//\r
+       {0x371c,0x00},//\r
+       {0x370b,0x12},//\r
+       {0x3704,0x80},//\r
+       {0x3600,0x08},//\r
+       {0x3620,0x43},//\r
+       {0x3702,0x20},//\r
+       {0x3739,0x48},//\r
+       {0x3730,0x20},//\r
+       {0x370c,0x0c},//\r
+       {0x3a18,0x00},//\r
+       {0x3a19,0xf8},//\r
+       {0x3000,0x10},//\r
+       {0x3004,0xef},//\r
+       {0x6700,0x05},//\r
+       {0x6701,0x19},//\r
+       {0x6702,0xfd},//\r
+       {0x6703,0xd1},//\r
+       {0x6704,0xff},//\r
+       {0x6705,0xff},//\r
+       {0x3002,0x1c},//\r
+       {0x3006,0xc3},//\r
+       {0x3800,0x00},//\r
+       {0x3801,0x00},//\r
+       {0x3802,0x00},//\r
+       {0x3803,0x00},//\r
+       {0x3804,0x08},//\r
+       {0x3805,0x1f},//\r
+       {0x3806,0x06},//\r
+       {0x3807,0x0b},//\r
+       {0x3808,0x08},//\r
+       {0x3809,0x00},//\r
+       {0x380a,0x06},//\r
+       {0x380b,0x00},//\r
+       {0x380c,0x08},//\r
+       {0x380d,0xfc},//\r
+       {0x380e,0x06},//\r
+       {0x380f,0x1c},//\r
+       {0x3810,0x00},//\r
+       {0x3811,0x10},//\r
+       {0x3812,0x00},//\r
+       {0x3813,0x06},//\r
+       {0x3814,0x11},//\r
+       {0x3815,0x11},//\r
+       {0x3820,0x40},//\r
+       {0x3821,0x00},//\r
+       {0x3824,0x01},//\r
+       {0x3826,0x23},//\r
+       {0x3a02,0x30},//\r
+       {0x3a03,0xc0},//\r
+       {0x3a08,0x00},//\r
+       {0x3a09,0xea},//\r
+       {0x3a0a,0x00},//\r
+       {0x3a0b,0xc3},//\r
+       {0x3a0d,0x08},//\r
+       {0x3a0e,0x06},//\r
+       {0x3a14,0x30},//\r
+       {0x3a15,0x72},//\r
+       {0x3618,0x78},//\r
+       {0x3623,0x00},//\r
+       {0x3708,0x21},//\r
+       {0x3709,0x12},//\r
+       {0x4300,0x30},//\r
+       {0x440e,0x09},//\r
+       {0x4514,0x00},//\r
+       {0x4520,0xb0},//\r
+       {0x460b,0x37},//\r
+       {0x460c,0x20},//\r
+       {0x4713,0x02},//\r
+       {0x471c,0xd0},//\r
+       {0x5086,0x00},//\r
+       {0x5000,0x07},//\r
+       {0x5001,0x03},//\r
+       {0x5002,0x00},//\r
+       {0x501f,0x00},//\r
+       {0x302c,0x43},//  \r
+       {0x3a00,0x38},//\r
+       {0x303c,0x14},//  ;5fps\r
+       {0x440e,0x08},//  ;for MBIST\r
+       {0x3821,0x06},//  ;mirror on\r
+       {0x3008,0x02},//\r
+       {0x5180,0x00},//     //;IQ setting example //;Sample_AWB\r
+       {0x5181,0xf2},//\r
+       {0x5182,0x0 },//\r
+       {0x5183,0x14},//\r
+       {0x5184,0x25},//\r
+       {0x5185,0x24},//\r
+       {0x5186,0x9 },//\r
+       {0x5187,0x9 },//\r
+       {0x5188,0x9 },//\r
+       {0x5189,0x75},//\r
+       {0x518a,0x54},//\r
+       {0x518b,0xe0},//\r
+       {0x518c,0xb2},//\r
+       {0x518d,0x42},//\r
+       {0x518e,0x3d},//\r
+       {0x518f,0x56},//\r
+       {0x5190,0x46},//\r
+       {0x5191,0xf8},//\r
+       {0x5192,0x4 },//\r
+       {0x5193,0x70},//\r
+       {0x5194,0xf0},//\r
+       {0x5195,0xf0},//\r
+       {0x5196,0x3 },//\r
+       {0x5197,0x1 },//\r
+       {0x5198,0x4 },//\r
+       {0x5199,0x12},//\r
+       {0x519a,0x4 },//\r
+       {0x519b,0x0 },//\r
+       {0x519c,0x6 },//\r
+       {0x519d,0x82},//\r
+       {0x519e,0x38},//\r
+       {0x5381,0x1c},//     //;Sample_CMX\r
+       {0x5382,0x5a},//\r
+       {0x5383,0x6 },//\r
+       {0x5384,0xa },//\r
+       {0x5385,0x7e},//\r
+       {0x5386,0x88},//\r
+       {0x5387,0x7c},//\r
+       {0x5388,0x6c},//\r
+       {0x5389,0x10},//\r
+       {0x538a,0x1 },//\r
+       {0x538b,0x98},//\r
+       {0x5000,0x27},// //;Sample_gamma;enable gamma\r
+       {0x5481,0x8 },//\r
+       {0x5482,0x14},//\r
+       {0x5483,0x28},//\r
+       {0x5484,0x51},//\r
+       {0x5485,0x65},//\r
+       {0x5486,0x71},//\r
+       {0x5487,0x7d},//\r
+       {0x5488,0x87},//\r
+       {0x5489,0x91},//\r
+       {0x548a,0x9a},//\r
+       {0x548b,0xaa},//\r
+       {0x548c,0xb8},//\r
+       {0x548d,0xcd},//\r
+       {0x548e,0xdd},//\r
+       {0x548f,0xea},//\r
+       {0x5490,0x1d},//\r
+       {0x3a0f,0x38},//    //;Example_EV\r
+       {0x3a10,0x30},//\r
+       {0x3a1b,0x38},//\r
+       {0x3a1e,0x30},//\r
+       {0x3a11,0x70},//\r
+       {0x3a1f,0x14},//\r
+       {0x3a18,0x0 },//\r
+    {0x3406, 0x00},\r
+    {0x3400, 0x07},\r
+    {0x3401, 0x02},\r
+    {0x3402, 0x04},\r
+    {0x3403, 0x00},\r
+    {0x3404, 0x05},\r
+    {0x3405, 0x15},\r
+    //AWB \r
+{0x5180 ,0xff},\r
+{0x5181 ,0xf2},\r
+{0x5182 ,0x0 },\r
+{0x5183 ,0x14},\r
+{0x5184 ,0x25},\r
+{0x5185 ,0x24},\r
+{0x5186 ,0xd },\r
+{0x5187 ,0xf },\r
+{0x5188 ,0xf },\r
+{0x5189 ,0x75},\r
+{0x518a ,0x54},\r
+{0x518b ,0xe0},\r
+{0x518c ,0xb2},\r
+{0x518d ,0x3e},\r
+{0x518e ,0x39},\r
+{0x518f ,0x52},\r
+\r
+\r
+{0x5190 ,0x47},\r
+{0x5191 ,0xf8},\r
+{0x5192 ,0x4 },\r
+{0x5193 ,0x70},\r
+{0x5194 ,0xf0},\r
+{0x5195 ,0xf0},\r
+{0x5196 ,0x3 },\r
+{0x5197 ,0x1 },\r
+{0x5198 ,0x4 },\r
+{0x5199 ,0x68},\r
+{0x519a ,0x4 },\r
+{0x519b ,0x0 },\r
+{0x519c ,0x7 },\r
+{0x519d ,0xa5},\r
+{0x519e ,0x38},\r
+\r
+       {0x0000, 0x00}\r
+};\r
+\r
+/* 640X480 VGA *///preview\r
+static struct reginfo sensor_vga[] =\r
+{\r
+//  preview vga\r
+{0x303c, 0x12},\r
+{0x3824, 0x02},\r
+{0x460c, 0x22},        \r
+//XGA Windowing\r
+{0x5001, 0x83},\r
+{0x3800, 0x00},\r
+{0x3801, 0x00},\r
+{0x3802, 0x00},\r
+{0x3803, 0x00},\r
+{0x3804, 0x08},\r
+{0x3805, 0x1f},\r
+{0x3806, 0x06},\r
+{0x3807, 0x09},\r
+{0x3808, 0x04},\r
+{0x3809, 0x00},\r
+{0x380a, 0x03},\r
+{0x380b, 0x00},\r
+{0x380c, 0x08},\r
+{0x380d, 0xfc},\r
+{0x380e, 0x03},\r
+{0x380f, 0x14},\r
+{0x3810, 0x00},\r
+{0x3811, 0x08},\r
+{0x3812, 0x00},\r
+{0x3813, 0x02},\r
+{0x3814, 0x31},\r
+{0x3815, 0x31},\r
+       \r
+{0x3708, 0x66},\r
+{0x3709, 0x12},\r
+{0x370c, 0x0c},\r
+{0x4520, 0x0b},\r
+{0x302c, 0x03},\r
+\r
+//Bining mode\r
+{0x3820, 0x01},\r
+{0x3821, 0x03},//0x01\r
+{0x4514, 0xaa},        \r
+\r
+//vga  \r
+{0x5000, 0xa7},\r
+{0x5001, 0xa3},\r
+{0x3808, 0x02},\r
+{0x3809, 0x80},\r
+{0x380a, 0x01},\r
+{0x380b, 0xe0},\r
+{0x380c, 0x08},\r
+{0x380d, 0xfc},\r
+{0x380e, 0x03},\r
+{0x380f, 0x14},\r
+{0x3810, 0x00},\r
+{0x3811, 0x08},\r
+{0x3812, 0x00},\r
+{0x3813, 0x02},\r
+{0x3814, 0x31},\r
+{0x3815, 0x31},\r
+       {0x3503,0x00},\r
+       {0x0000, 0x00}\r
+};\r
+\r
+/* 352X288 CIF */\r
+static struct reginfo sensor_cif[] =\r
+{\r
+       {0x0, 0x0}\r
+};\r
+\r
+/* 320*240 QVGA */\r
+static  struct reginfo sensor_qvga[] =\r
+{\r
+  \r
+\r
+       {0x0000, 0x00}\r
+};\r
+\r
+/* 176X144 QCIF*/\r
+static struct reginfo sensor_qcif[] =\r
+{\r
+       {0x0, 0x0}\r
+};\r
+\r
+static  struct reginfo sensor_ClrFmt_YUYV[]=\r
+{\r
+    {0x4300, 0x30},\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_ClrFmt_UYVY[]=\r
+{\r
+    {0x4300, 0x32},\r
+    {0x0000, 0x00}\r
+};\r
+\r
+#if CONFIG_SENSOR_WhiteBalance\r
+static  struct reginfo sensor_WhiteB_Auto[]=\r
+{\r
+\r
+{0x3406, 0x00},\r
+       {0x5180,0xff},//         //;IQ setting example //;Sample_AWB\r
+       {0x5181,0xf2},//\r
+       {0x5182,0x0 },//\r
+       {0x5183,0x14},//\r
+       {0x5184,0x25},//\r
+       {0x5185,0x24},//\r
+       {0x5186,0x0d},//\r
+       {0x5187,0x0f},//\r
+       {0x5188,0x0f},//\r
+       {0x5189,0x75},//\r
+       {0x518a,0x54},//\r
+       {0x518b,0xe0},//\r
+       {0x518c,0xb2},//\r
+       {0x518d,0x3e},//\r
+       {0x518e,0x39},//\r
+       {0x518f,0x52},//\r
+       {0x5190,0x47},//\r
+       {0x5191,0xf8},//\r
+       {0x5192,0x4 },//\r
+       {0x5193,0x70},//\r
+       {0x5194,0xf0},//\r
+       {0x5195,0xf0},//\r
+       {0x5196,0x3 },//\r
+       {0x5197,0x1 },//\r
+       {0x5198,0x4 },//\r
+       {0x5199,0x68},//\r
+       {0x519a,0x4 },//\r
+       {0x519b,0x0 },//\r
+       {0x519c,0x07 },//\r
+       {0x519d,0xa5},//\r
+       {0x519e,0x38},//\r
+{0x0000, 0x00}\r
+};\r
+/* Cloudy Colour Temperature : 6500K - 8000K  */\r
+static  struct reginfo sensor_WhiteB_Cloudy[]=\r
+{\r
+   \r
+    {0x3406, 0x01},\r
+    {0x3400, 0x07},\r
+    {0x3401, 0x02},\r
+    {0x3402, 0x04},\r
+    {0x3403, 0x00},\r
+    {0x3404, 0x05},\r
+    {0x3405, 0x15},\r
+    {0x0000, 0x00}\r
+};\r
+/* ClearDay Colour Temperature : 5000K - 6500K  */\r
+static  struct reginfo sensor_WhiteB_ClearDay[]=\r
+{\r
+    //Sunny\r
+    {0x3406, 0x01},\r
+    {0x3400, 0x07},\r
+    {0x3401, 0x02},\r
+    {0x3402, 0x04},\r
+    {0x3403, 0x00},\r
+    {0x3404, 0x05},\r
+    {0x3405, 0x15},\r
+    {0x0000, 0x00}\r
+};\r
+/* Office Colour Temperature : 3500K - 5000K  */\r
+static  struct reginfo sensor_WhiteB_TungstenLamp1[]=\r
+{\r
+    //Office\r
+    {0x3406, 0x01},\r
+    {0x3400, 0x06},\r
+    {0x3401, 0x2a},\r
+    {0x3402, 0x04},\r
+    {0x3403, 0x00},\r
+    {0x3404, 0x07},\r
+    {0x3405, 0x24},\r
+    {0x0000, 0x00}\r
+\r
+};\r
+/* Home Colour Temperature : 2500K - 3500K  */\r
+static  struct reginfo sensor_WhiteB_TungstenLamp2[]=\r
+{\r
+    //Home\r
+    {0x3406, 0x01},\r
+    {0x3400, 0x04},\r
+    {0x3401, 0x58},\r
+    {0x3402, 0x04},\r
+    {0x3403, 0x00},\r
+    {0x3404, 0x07},\r
+    {0x3405, 0x24},\r
+    {0x0000, 0x00}\r
+};\r
+static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,\r
+    sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,\r
+};\r
+#endif\r
+\r
+#if CONFIG_SENSOR_Brightness\r
+static  struct reginfo sensor_Brightness0[]=\r
+{\r
+    // Brightness -2\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Brightness1[]=\r
+{\r
+    // Brightness -1\r
+\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Brightness2[]=\r
+{\r
+    //  Brightness 0\r
+\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Brightness3[]=\r
+{\r
+    // Brightness +1\r
+\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Brightness4[]=\r
+{\r
+    //  Brightness +2\r
+\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Brightness5[]=\r
+{\r
+    //  Brightness +3\r
+\r
+    {0x0000, 0x00}\r
+};\r
+static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,\r
+    sensor_Brightness4, sensor_Brightness5,NULL,\r
+};\r
+\r
+#endif\r
+\r
+#if CONFIG_SENSOR_Effect\r
+static  struct reginfo sensor_Effect_Normal[] =\r
+{\r
+    {0x507b, 0x00},\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Effect_WandB[] =\r
+{\r
+    {0x507b, 0x20},\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Effect_Sepia[] =\r
+{\r
+    {0x507b, 0x18},\r
+    {0x507e, 0x40},\r
+    {0x507f, 0xa0},\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Effect_Negative[] =\r
+{\r
+    //Negative\r
+    {0x507b, 0x40}, //bit[6] negative\r
+    {0x0000, 0x00}\r
+};\r
+static  struct reginfo sensor_Effect_Bluish[] =\r
+{\r
+    // Bluish\r
+    {0x507b, 0x18},\r
+    {0x507e, 0xa0},\r
+    {0x507f, 0x40},\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Effect_Green[] =\r
+{\r
+    //  Greenish\r
+    {0x507b, 0x18},\r
+    {0x507e, 0x60},\r
+    {0x507f, 0x60},\r
+    {0x0000, 0x00}\r
+};\r
+static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,\r
+    sensor_Effect_Bluish, sensor_Effect_Green,NULL,\r
+};\r
+#endif\r
+#if CONFIG_SENSOR_Exposure\r
+static  struct reginfo sensor_Exposure0[]=\r
+{\r
+       {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure1[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure2[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure3[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure4[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure5[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure6[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,\r
+    sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,\r
+};\r
+#endif\r
+#if CONFIG_SENSOR_Saturation\r
+static  struct reginfo sensor_Saturation0[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Saturation1[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Saturation2[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};\r
+\r
+#endif\r
+#if CONFIG_SENSOR_Contrast\r
+static  struct reginfo sensor_Contrast0[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Contrast1[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Contrast2[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Contrast3[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Contrast4[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+\r
+static  struct reginfo sensor_Contrast5[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Contrast6[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,\r
+    sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,\r
+};\r
+\r
+#endif\r
+#if CONFIG_SENSOR_Mirror\r
+static  struct reginfo sensor_MirrorOn[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_MirrorOff[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};\r
+#endif\r
+#if CONFIG_SENSOR_Flip\r
+static  struct reginfo sensor_FlipOn[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_FlipOff[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};\r
+\r
+#endif\r
+#if CONFIG_SENSOR_Scene\r
+static  struct reginfo sensor_SceneAuto[] =\r
+{\r
+       //Jacky_M\r
+    {0x3a00, 0x78},\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_SceneNight[] =\r
+{\r
+    {0x3003, 0x80},\r
+       {0x3004, 0x20},\r
+       {0x3005, 0x18},\r
+       {0x3006, 0x0d},\r
+       {0x3a00, 0x7c},\r
+       {0x3a02 ,0x07},\r
+       {0x3a03 ,0x38},\r
+       {0x3a14 ,0x07},\r
+       {0x3a15 ,0x38},\r
+    {0x0000, 0x00}\r
+};\r
+static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};\r
+\r
+#endif\r
+#if CONFIG_SENSOR_DigitalZoom\r
+static struct reginfo sensor_Zoom0[] =\r
+{\r
+    {0x0, 0x0},\r
+};\r
+\r
+static struct reginfo sensor_Zoom1[] =\r
+{\r
+     {0x0, 0x0},\r
+};\r
+\r
+static struct reginfo sensor_Zoom2[] =\r
+{\r
+    {0x0, 0x0},\r
+};\r
+\r
+\r
+static struct reginfo sensor_Zoom3[] =\r
+{\r
+    {0x0, 0x0},\r
+};\r
+static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};\r
+#endif\r
+\r
+#if CONFIG_SENSOR_ISO\r
+static struct reginfo sensor_ISO100[] =\r
+{\r
+\r
+    {0x0, 0x0},\r
+};\r
+\r
+static struct reginfo sensor_ISO200[] =\r
+{\r
+\r
+     {0x0, 0x0},\r
+};\r
+\r
+static struct reginfo sensor_ISO400[] =\r
+{\r
+\r
+    {0x0, 0x0},\r
+};\r
+\r
+\r
+static struct reginfo sensor_ISO800[] =\r
+{\r
+\r
+    {0x0, 0x0},\r
+};\r
+static struct reginfo *sensor_ISOSeqe[] = {sensor_ISO100, sensor_ISO200, sensor_ISO400, sensor_ISO800, NULL,};\r
+#endif\r
+\r
+static const struct v4l2_querymenu sensor_menus[] =\r
+{\r
+       #if CONFIG_SENSOR_WhiteBalance\r
+    { .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 0,  .name = "auto",  .reserved = 0, }, {  .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 1, .name = "incandescent",  .reserved = 0,},\r
+    { .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 2,  .name = "fluorescent", .reserved = 0,}, {  .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3,  .name = "daylight", .reserved = 0,},\r
+    { .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 4,  .name = "cloudy-daylight", .reserved = 0,},\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Effect\r
+    { .id = V4L2_CID_EFFECT,  .index = 0,  .name = "none",  .reserved = 0, }, {  .id = V4L2_CID_EFFECT,  .index = 1, .name = "mono",  .reserved = 0,},\r
+    { .id = V4L2_CID_EFFECT,  .index = 2,  .name = "negative", .reserved = 0,}, {  .id = V4L2_CID_EFFECT, .index = 3,  .name = "sepia", .reserved = 0,},\r
+    { .id = V4L2_CID_EFFECT,  .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT,  .index = 5,  .name = "aqua", .reserved = 0,},\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Scene\r
+    { .id = V4L2_CID_SCENE,  .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE,  .index = 1,  .name = "night", .reserved = 0,},\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Flash\r
+    { .id = V4L2_CID_FLASH,  .index = 0,  .name = "off",  .reserved = 0, }, {  .id = V4L2_CID_FLASH,  .index = 1, .name = "auto",  .reserved = 0,},\r
+    { .id = V4L2_CID_FLASH,  .index = 2,  .name = "on", .reserved = 0,}, {  .id = V4L2_CID_FLASH, .index = 3,  .name = "torch", .reserved = 0,},\r
+    #endif\r
+};\r
+\r
+\r
+\r
+\r
+static struct v4l2_queryctrl sensor_controls[] =\r
+{\r
+       #if CONFIG_SENSOR_WhiteBalance\r
+    {\r
+        .id            = V4L2_CID_DO_WHITE_BALANCE,\r
+        .type          = V4L2_CTRL_TYPE_MENU,\r
+        .name          = "White Balance Control",\r
+        .minimum       = 0,\r
+        .maximum       = 4,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Brightness\r
+       {\r
+        .id            = V4L2_CID_BRIGHTNESS,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Brightness Control",\r
+        .minimum       = -3,\r
+        .maximum       = 2,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Effect\r
+       {\r
+        .id            = V4L2_CID_EFFECT,\r
+        .type          = V4L2_CTRL_TYPE_MENU,\r
+        .name          = "Effect Control",\r
+        .minimum       = 0,\r
+        .maximum       = 5,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+       #endif\r
+\r
+       #if CONFIG_SENSOR_Exposure\r
+       {\r
+        .id            = V4L2_CID_EXPOSURE,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Exposure Control",\r
+        .minimum       = 0,\r
+        .maximum       = 6,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+       #endif\r
+\r
+       #if CONFIG_SENSOR_Saturation\r
+       {\r
+        .id            = V4L2_CID_SATURATION,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Saturation Control",\r
+        .minimum       = 0,\r
+        .maximum       = 2,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Contrast\r
+       {\r
+        .id            = V4L2_CID_CONTRAST,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Contrast Control",\r
+        .minimum       = -3,\r
+        .maximum       = 3,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+       #endif\r
+\r
+       #if CONFIG_SENSOR_Mirror\r
+       {\r
+        .id            = V4L2_CID_HFLIP,\r
+        .type          = V4L2_CTRL_TYPE_BOOLEAN,\r
+        .name          = "Mirror Control",\r
+        .minimum       = 0,\r
+        .maximum       = 1,\r
+        .step          = 1,\r
+        .default_value = 1,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Flip\r
+       {\r
+        .id            = V4L2_CID_VFLIP,\r
+        .type          = V4L2_CTRL_TYPE_BOOLEAN,\r
+        .name          = "Flip Control",\r
+        .minimum       = 0,\r
+        .maximum       = 1,\r
+        .step          = 1,\r
+        .default_value = 1,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Scene\r
+    {\r
+        .id            = V4L2_CID_SCENE,\r
+        .type          = V4L2_CTRL_TYPE_MENU,\r
+        .name          = "Scene Control",\r
+        .minimum       = 0,\r
+        .maximum       = 1,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_DigitalZoom\r
+    {\r
+        .id            = V4L2_CID_ZOOM_RELATIVE,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "DigitalZoom Control",\r
+        .minimum       = -1,\r
+        .maximum       = 1,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    }, {\r
+        .id            = V4L2_CID_ZOOM_ABSOLUTE,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "DigitalZoom Control",\r
+        .minimum       = 0,\r
+        .maximum       = 3,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Focus\r
+       {\r
+        .id            = V4L2_CID_FOCUS_RELATIVE,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Focus Control",\r
+        .minimum       = -1,\r
+        .maximum       = 1,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    }, {\r
+        .id            = V4L2_CID_FOCUS_ABSOLUTE,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Focus Control",\r
+        .minimum       = 0,\r
+        .maximum       = 255,\r
+        .step          = 1,\r
+        .default_value = 125,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Flash\r
+       {\r
+        .id            = V4L2_CID_FLASH,\r
+        .type          = V4L2_CTRL_TYPE_MENU,\r
+        .name          = "Flash Control",\r
+        .minimum       = 0,\r
+        .maximum       = 3,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+       #endif\r
+};\r
+\r
+static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);\r
+static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);\r
+static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);\r
+static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);\r
+static int sensor_g_ext_controls(struct v4l2_subdev *sd,  struct v4l2_ext_controls *ext_ctrl);\r
+static int sensor_s_ext_controls(struct v4l2_subdev *sd,  struct v4l2_ext_controls *ext_ctrl);\r
+static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);\r
+static int sensor_resume(struct soc_camera_device *icd);\r
+static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);\r
+static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);\r
+#if CONFIG_SENSOR_Effect\r
+static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);\r
+#endif\r
+#if CONFIG_SENSOR_WhiteBalance\r
+static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);\r
+#endif\r
+static int sensor_deactivate(struct i2c_client *client);\r
+\r
+static struct soc_camera_ops sensor_ops =\r
+{\r
+    .suspend                     = sensor_suspend,\r
+    .resume                       = sensor_resume,\r
+    .set_bus_param             = sensor_set_bus_param,\r
+    .query_bus_param   = sensor_query_bus_param,\r
+    .controls          = sensor_controls,\r
+    .menus                         = sensor_menus,\r
+    .num_controls              = ARRAY_SIZE(sensor_controls),\r
+    .num_menus         = ARRAY_SIZE(sensor_menus),\r
+};\r
+\r
+/* only one fixed colorspace per pixelcode */\r
+struct sensor_datafmt {\r
+       enum v4l2_mbus_pixelcode code;\r
+       enum v4l2_colorspace colorspace;\r
+};\r
+\r
+/* Find a data format by a pixel code in an array */\r
+static const struct sensor_datafmt *sensor_find_datafmt(\r
+       enum v4l2_mbus_pixelcode code, const struct sensor_datafmt *fmt,\r
+       int n)\r
+{\r
+       int i;\r
+       for (i = 0; i < n; i++)\r
+               if (fmt[i].code == code)\r
+                       return fmt + i;\r
+\r
+       return NULL;\r
+}\r
+\r
+static const struct sensor_datafmt sensor_colour_fmts[] = {\r
+       {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},\r
+       {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG}         \r
+};\r
+\r
+\r
+typedef struct sensor_info_priv_s\r
+{\r
+    int whiteBalance;\r
+    int brightness;\r
+    int contrast;\r
+    int saturation;\r
+    int effect;\r
+    int scene;\r
+    int digitalzoom;\r
+    int focus;\r
+    int flash;\r
+    int exposure;\r
+       bool snap2preview;\r
+       bool video2preview;\r
+    unsigned char mirror;                                        /* HFLIP */\r
+    unsigned char flip;                                          /* VFLIP */\r
+    unsigned int winseqe_cur_addr;\r
+       struct sensor_datafmt fmt;\r
+    unsigned int funmodule_state;\r
+} sensor_info_priv_t;\r
+\r
+struct SENSOR\r
+{\r
+    struct v4l2_subdev subdev;\r
+    struct i2c_client *client;\r
+    sensor_info_priv_t info_priv;\r
+    int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */\r
+#if CONFIG_SENSOR_I2C_NOSCHED\r
+       atomic_t tasklock_cnt;\r
+#endif\r
+       struct rk29camera_platform_data *sensor_io_request;\r
+    struct rk29camera_gpio_res *sensor_gpio_res;\r
+};\r
+\r
+\r
+static struct SENSOR* to_sensor(const struct i2c_client *client)\r
+{\r
+    return container_of(i2c_get_clientdata(client), struct SENSOR, subdev);\r
+}\r
+\r
+static int sensor_task_lock(struct i2c_client *client, int lock)\r
+{\r
+#if CONFIG_SENSOR_I2C_NOSCHED\r
+       int cnt = 3;\r
+    struct SENSOR *sensor = to_sensor(client);\r
+\r
+       if (lock) {\r
+               if (atomic_read(&sensor->tasklock_cnt) == 0) {\r
+                       while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {\r
+                               SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());\r
+                               msleep(35);\r
+                               cnt--;\r
+                       }\r
+                       if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {\r
+                               SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());\r
+                               goto sensor_task_lock_err;\r
+                       }\r
+                       preempt_disable();\r
+               }\r
+\r
+               atomic_add(1, &sensor->tasklock_cnt);\r
+       } else {\r
+               if (atomic_read(&sensor->tasklock_cnt) > 0) {\r
+                       atomic_sub(1, &sensor->tasklock_cnt);\r
+\r
+                       if (atomic_read(&sensor->tasklock_cnt) == 0)\r
+                               preempt_enable();\r
+               }\r
+       }\r
+       return 0;\r
+sensor_task_lock_err:\r
+       return -1;  \r
+#else\r
+    return 0;\r
+#endif\r
+\r
+}\r
+\r
+/* sensor register write */\r
+static int sensor_write(struct i2c_client *client, u16 reg, u8 val)\r
+{\r
+    int err,cnt;\r
+    u8 buf[3];\r
+    struct i2c_msg msg[1];\r
+\r
+    buf[0] = reg >> 8;\r
+    buf[1] = reg & 0xFF;\r
+    buf[2] = val;\r
+\r
+    msg->addr = client->addr;\r
+    msg->flags = client->flags;\r
+    msg->buf = buf;\r
+    msg->len = sizeof(buf);\r
+    msg->scl_rate = CONFIG_SENSOR_I2C_SPEED;         /* ddl@rock-chips.com : 100kHz */\r
+    msg->read_type = 0;               /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */\r
+\r
+    cnt = 3;\r
+    err = -EAGAIN;\r
+    while ((cnt-- > 0) && (err < 0)) {                       /* ddl@rock-chips.com :  Transfer again if transent is failed   */\r
+        err = i2c_transfer(client->adapter, msg, 1);\r
+\r
+        if (err >= 0) {\r
+            return 0;\r
+        } else {\r
+               SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg, val);\r
+               udelay(10);\r
+        }\r
+    }\r
+\r
+    return err;\r
+}\r
+\r
+/* sensor register read */\r
+static int sensor_read(struct i2c_client *client, u16 reg, u8 *val)\r
+{\r
+    int err,cnt;\r
+    u8 buf[2];\r
+    struct i2c_msg msg[2];\r
+\r
+    buf[0] = reg >> 8;\r
+    buf[1] = reg & 0xFF;\r
+\r
+    msg[0].addr = client->addr;\r
+    msg[0].flags = client->flags;\r
+    msg[0].buf = buf;\r
+    msg[0].len = sizeof(buf);\r
+    msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED;       /* ddl@rock-chips.com : 100kHz */\r
+    msg[0].read_type = 2;   /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */\r
+\r
+    msg[1].addr = client->addr;\r
+    msg[1].flags = client->flags|I2C_M_RD;\r
+    msg[1].buf = buf;\r
+    msg[1].len = 1;\r
+    msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED;                       /* ddl@rock-chips.com : 100kHz */\r
+    msg[1].read_type = 2;                             /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */\r
+\r
+    cnt = 3;\r
+    err = -EAGAIN;\r
+    while ((cnt-- > 0) && (err < 0)) {                       /* ddl@rock-chips.com :  Transfer again if transent is failed   */\r
+        err = i2c_transfer(client->adapter, msg, 2);\r
+\r
+        if (err >= 0) {\r
+            *val = buf[0];\r
+            return 0;\r
+        } else {\r
+               SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);\r
+            udelay(10);\r
+        }\r
+    }\r
+\r
+    return err;\r
+}\r
+\r
+/* write a array of registers  */\r
+static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)\r
+{\r
+    int err = 0, cnt;\r
+    int i = 0;\r
+#if CONFIG_SENSOR_I2C_RDWRCHK    \r
+       char valchk;\r
+#endif\r
+\r
+       cnt = 0;\r
+       if (sensor_task_lock(client, 1) < 0)\r
+               goto sensor_write_array_end;\r
+\r
+    while (regarray[i].reg != 0)\r
+    {\r
+        err = sensor_write(client, regarray[i].reg, regarray[i].val);\r
+       \r
+        if (err < 0)\r
+        {\r
+            if (cnt-- > 0) {\r
+                           SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);\r
+                               i = 0;\r
+                               continue;\r
+            } else {\r
+                SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());\r
+                err = -EPERM;\r
+                               goto sensor_write_array_end;\r
+            }\r
+        } else {\r
+        #if CONFIG_SENSOR_I2C_RDWRCHK\r
+                       sensor_read(client, regarray[i].reg, &valchk);\r
+                       if (valchk != regarray[i].val)\r
+                               SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);\r
+               #endif\r
+        }\r
+        i++;\r
+    }\r
+\r
+sensor_write_array_end:\r
+       sensor_task_lock(client,0);\r
+       return err;\r
+}\r
+#if CONFIG_SENSOR_I2C_RDWRCHK\r
+static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)\r
+{\r
+    int cnt;\r
+    int i = 0;\r
+       char valchk;\r
+\r
+       cnt = 0;\r
+       valchk = 0;\r
+    while (regarray[i].reg != 0)\r
+    {\r
+               sensor_read(client, regarray[i].reg, &valchk);\r
+               if (valchk != regarray[i].val)\r
+                       SENSOR_TR("%s Reg:0x%x read(0x%x, 0x%x) error\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);\r
+\r
+        i++;\r
+    }\r
+    return 0;\r
+}\r
+#endif\r
+static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)\r
+{\r
+       struct soc_camera_link *icl = to_soc_camera_link(icd);\r
+       int ret = 0;\r
+\r
+    SENSOR_DG("%s %s  cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);\r
+       switch (cmd)\r
+       {\r
+               case Sensor_PowerDown:\r
+               {\r
+                       if (icl->powerdown) {\r
+                               ret = icl->powerdown(icd->pdev, on);\r
+                               if (ret == RK29_CAM_IO_SUCCESS) {\r
+                                       if (on == 1) {\r
+                                               mdelay(50);\r
+                                       }\r
+                                       if (on == 0) {\r
+                                               mdelay(2);\r
+                                               if (icl->reset)\r
+                                                       icl->reset(icd->pdev);\r
+                                       }\r
+                               } else if (ret == RK29_CAM_EIO_REQUESTFAIL) {\r
+                                       ret = -ENODEV;\r
+                                       goto sensor_power_end;\r
+                               }\r
+                       }\r
+                       break;\r
+               }\r
+               case Sensor_Flash:\r
+               {\r
+                       struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+               struct SENSOR *sensor = to_sensor(client);\r
+\r
+                       if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {\r
+                               sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);\r
+                if(on) {\r
+                    //flash off after 2 secs\r
+                    hrtimer_cancel(&(flash_off_timer.timer));\r
+                    hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);\r
+                }\r
+                       }\r
+            break;\r
+               }\r
+               default:\r
+               {\r
+                       SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);\r
+                       break;\r
+               }\r
+       }\r
+sensor_power_end:\r
+       return ret;\r
+}\r
+\r
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer)\r
+{\r
+    struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);\r
+    \r
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);\r
+   \r
+    return 0;\r
+}\r
+\r
+static int sensor_init(struct v4l2_subdev *sd, u32 val)\r
+{\r
+    struct i2c_client *client = v4l2_get_subdevdata(sd);\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    struct SENSOR *sensor = to_sensor(client);\r
+       const struct v4l2_queryctrl *qctrl;\r
+       const struct sensor_datafmt *fmt;\r
+unsigned char value;\r
+int ret,pid = 0;\r
+\r
+    SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);\r
+\r
+       if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {\r
+               ret = -ENODEV;\r
+               goto sensor_INIT_ERR;\r
+       }\r
+\r
+    /* soft reset */\r
+       printk("jack+sensor_init begin\n");\r
+       if (sensor_task_lock(client,1)<0)\r
+               goto sensor_INIT_ERR;\r
+\r
+\r
+    if (ret != 0)\r
+    {\r
+        SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());\r
+        ret = -ENODEV;\r
+               goto sensor_INIT_ERR;\r
+    }\r
+    mdelay(5);  //delay 5 microseconds\r
+\r
+       /* check if it is an sensor sensor */\r
+    ret = sensor_read(client, 0x300a, &value);\r
+    if (ret != 0) {\r
+        SENSOR_TR("read chip id high byte failed\n");\r
+        ret = -ENODEV;\r
+        goto sensor_INIT_ERR;\r
+    }\r
+\r
+    pid |= (value << 8);\r
+\r
+    ret = sensor_read(client, 0x300b, &value);\r
+    if (ret != 0) {\r
+        SENSOR_TR("read chip id low byte failed\n");\r
+        ret = -ENODEV;\r
+        goto sensor_INIT_ERR;\r
+    }\r
+\r
+    pid |= (value & 0xff);\r
+    SENSOR_DG("\n %s  pid = 0x%x\n", SENSOR_NAME_STRING(), pid);\r
+    if (pid == SENSOR_ID) {\r
+        sensor->model = SENSOR_V4L2_IDENT;\r
+    } else {\r
+        SENSOR_TR("error: %s mismatched   pid = 0x%x\n", SENSOR_NAME_STRING(), pid);\r
+        ret = -ENODEV;\r
+        goto sensor_INIT_ERR;\r
+    }\r
+\r
+    ret = sensor_write_array(client, sensor_init_data);\r
+    if (ret != 0)\r
+    {\r
+        SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());\r
+        goto sensor_INIT_ERR;\r
+    }\r
+       sensor_task_lock(client,0);\r
+    //icd->user_width = SENSOR_INIT_WIDTH;\r
+    //icd->user_height = SENSOR_INIT_HEIGHT;\r
+    sensor->info_priv.winseqe_cur_addr  = (int)SENSOR_INIT_WINSEQADR;\r
+       fmt = sensor_find_datafmt(SENSOR_INIT_PIXFMT,sensor_colour_fmts, ARRAY_SIZE(sensor_colour_fmts));\r
+    if (!fmt) {\r
+        SENSOR_TR("error: %s initial array colour fmts is not support!!",SENSOR_NAME_STRING());\r
+        ret = -EINVAL;\r
+        goto sensor_INIT_ERR;\r
+    }\r
+       sensor->info_priv.fmt = *fmt;\r
+\r
+    /* sensor sensor information for initialization  */\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);\r
+       if (qctrl)\r
+       sensor->info_priv.whiteBalance = qctrl->default_value;\r
+    flash_off_timer.icd = icd;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);\r
+       if (qctrl)\r
+       sensor->info_priv.brightness = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);\r
+       if (qctrl)\r
+       sensor->info_priv.effect = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);\r
+       if (qctrl)\r
+        sensor->info_priv.exposure = qctrl->default_value;\r
+\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);\r
+       if (qctrl)\r
+        sensor->info_priv.saturation = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);\r
+       if (qctrl)\r
+        sensor->info_priv.contrast = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);\r
+       if (qctrl)\r
+        sensor->info_priv.mirror = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);\r
+       if (qctrl)\r
+        sensor->info_priv.flip = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);\r
+       if (qctrl)\r
+        sensor->info_priv.scene = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);\r
+       if (qctrl)\r
+        sensor->info_priv.digitalzoom = qctrl->default_value;\r
+\r
+    /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code  */\r
+       #if CONFIG_SENSOR_Focus\r
+    sensor_set_focus();\r
+    qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);\r
+       if (qctrl)\r
+        sensor->info_priv.focus = qctrl->default_value;\r
+       #endif\r
+\r
+       #if CONFIG_SENSOR_Flash \r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);\r
+       if (qctrl)\r
+        sensor->info_priv.flash = qctrl->default_value;\r
+    flash_off_timer.icd = icd;\r
+    #endif\r
+\r
+    SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),((val == 0)?__FUNCTION__:"sensor_reinit"),icd->user_width,icd->user_height);\r
+    sensor->info_priv.funmodule_state |= SENSOR_INIT_IS_OK;    \r
+    return 0;\r
+sensor_INIT_ERR:\r
+    sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;\r
+       sensor_task_lock(client,0);\r
+       sensor_deactivate(client);\r
+    return ret;\r
+}\r
+\r
+static int sensor_deactivate(struct i2c_client *client)\r
+{\r
+       struct soc_camera_device *icd = client->dev.platform_data;\r
+       u8 reg_val;\r
+    struct SENSOR *sensor = to_sensor(client);\r
+    \r
+       SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);\r
+    \r
+       /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */\r
+    if (sensor->info_priv.funmodule_state & SENSOR_INIT_IS_OK) {\r
+       sensor_task_lock(client, 1);\r
+       sensor_read(client,0x3017,&reg_val);\r
+        sensor_write(client, 0x3017, reg_val&0x80);\r
+       sensor_read(client,0x3018,&reg_val);\r
+        sensor_write(client, 0x3018, reg_val&0x03);\r
+       sensor_task_lock(client, 0);        \r
+    }\r
+    sensor_ioctrl(icd, Sensor_PowerDown, 1); \r
+       \r
+    msleep(100); \r
+\r
+       /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */\r
+       icd->user_width = SENSOR_INIT_WIDTH;\r
+    icd->user_height = SENSOR_INIT_HEIGHT;\r
+    sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;\r
+       \r
+       return 0;\r
+}\r
+\r
+static  struct reginfo sensor_power_down_sequence[]=\r
+{\r
+    {0x00,0x00}\r
+};\r
+static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)\r
+{\r
+    int ret;\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if (pm_msg.event == PM_EVENT_SUSPEND) {\r
+        SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());\r
+        ret = sensor_write_array(client, sensor_power_down_sequence) ;\r
+        if (ret != 0) {\r
+            SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);\r
+            return ret;\r
+        } else {\r
+            ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);\r
+            if (ret < 0) {\r
+                           SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());\r
+                return -EINVAL;\r
+            }\r
+        }\r
+    } else {\r
+        SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());\r
+        return -EINVAL;\r
+    }\r
+    return 0;\r
+}\r
+\r
+static int sensor_resume(struct soc_camera_device *icd)\r
+{\r
+       int ret;\r
+\r
+    ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);\r
+    if (ret < 0) {\r
+               SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());\r
+        return -EINVAL;\r
+    }\r
+\r
+       SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());\r
+\r
+    return 0;\r
+\r
+}\r
+\r
+static int sensor_set_bus_param(struct soc_camera_device *icd,\r
+                                unsigned long flags)\r
+{\r
+\r
+    return 0;\r
+}\r
+\r
+static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)\r
+{\r
+    struct soc_camera_link *icl = to_soc_camera_link(icd);\r
+    unsigned long flags = SENSOR_BUS_PARAM;\r
+\r
+    return soc_camera_apply_sensor_flags(icl, flags);\r
+}\r
+\r
+static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
+    struct i2c_client *client = v4l2_get_subdevdata(sd);\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    struct SENSOR *sensor = to_sensor(client);\r
+\r
+    mf->width  = icd->user_width;\r
+       mf->height      = icd->user_height;\r
+       mf->code        = sensor->info_priv.fmt.code;\r
+       mf->colorspace  = sensor->info_priv.fmt.colorspace;\r
+       mf->field       = V4L2_FIELD_NONE;\r
+\r
+    return 0;\r
+}\r
+\r
+static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
+    bool ret = false;\r
+\r
+       if ((mf->width == 1024) && (mf->height == 768)) {\r
+               ret = true;\r
+       } else if ((mf->width == 1280) && (mf->height == 1024)) {\r
+               ret = true;\r
+       } else if ((mf->width == 1600) && (mf->height == 1200)) {\r
+               ret = true;\r
+       } else if ((mf->width == 2048) && (mf->height == 1536)) {\r
+               ret = true;\r
+       } else if ((mf->width == 2592) && (mf->height == 1944)) {\r
+               ret = true;\r
+       }\r
+\r
+       if (ret == true)\r
+               SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, mf->width, mf->height);\r
+       return ret;\r
+}\r
+\r
+\r
+static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
+    bool ret = false;\r
+\r
+       if ((mf->width == 1280) && (mf->height == 720)) {\r
+               ret = true;\r
+       } else if ((mf->width == 1920) && (mf->height == 1080)) {\r
+               ret = true;\r
+       }\r
+\r
+       if (ret == true)\r
+               SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, mf->width, mf->height);\r
+       return ret;\r
+}\r
+void button5_Click(struct i2c_client *client,struct reginfo *winseqe_set_addr)\r
+{\r
+    int extra_lines, Preview_Gain, preview_dummy_pixels, Capture_Exposure; \r
+       char temp_reg1, temp_reg2, temp_reg3;\r
+    int Capture_Line_Width,Capture_Banding_Filter,Capture_Gain, shutter, Gain_Exposure;\r
+    //int PV_EXPOSURE_LIMITATION = 782;\r
+    //int FULL_EXPOSURE_LIMITATION = 1640;\r
+    int Capture_Maximum_Shutter = 1564;   \r
+    int Default_Reg0x380c = 8;\r
+    int Default_Reg0x380d = 252;\r
+    int Capture_PCLK_Frequency = 54 ;\r
+    int Capture_Dummy_Pixels =0 ;\r
+    int Capture_Max_Gain = 256 ;\r
+    int extra_exposure_lines =0 ;\r
+       int ret = 0; \r
+\r
+       sensor_read(client, 0x3500, &temp_reg1);\r
+       sensor_read(client, 0x3501, &temp_reg2);\r
+       sensor_read(client, 0x3502, &temp_reg3);\r
+       \r
+    shutter = (temp_reg1 << 16) | (temp_reg2 << 8) | (temp_reg3);\r
+    shutter = shutter / 16;\r
+\r
+       sensor_read(client, 0x350d, &temp_reg1);\r
+       sensor_read(client, 0x350c, &temp_reg2);\r
+    extra_lines = (temp_reg1) | (temp_reg2 << 8);\r
+\r
+       sensor_read(client, 0x350b, &temp_reg1);\r
+        sensor_read(client, 0x350a, &temp_reg2);\r
+    Preview_Gain = (temp_reg2 << 8) | (temp_reg1);\r
+\r
+       sensor_read(client, 0x380d, &temp_reg1);\r
+       sensor_read(client, 0x380c, &temp_reg2);\r
+\r
+    preview_dummy_pixels = (((temp_reg1-Default_Reg0x380c) & 0xf0) << 8 ) + temp_reg2-Default_Reg0x380d ;   \r
+\r
+    //sensor_write(client, 0x3503, 0x00);    \r
+    sensor_write(client, 0x3503, 0x03);                             \r
+                 \r
+    Capture_Line_Width = 2376 + Capture_Dummy_Pixels;\r
+                          \r
+    //Capture_Exposure = (shutter + extra_lines)/2;\r
+    Capture_Exposure = (shutter + extra_lines)*36/27/2;\r
+    Capture_Banding_Filter = Capture_PCLK_Frequency * 1000000 / 100 / (2 * Capture_Line_Width);      //114\r
+    if(Preview_Gain < 16)\r
+    {\r
+        Preview_Gain = 16 ;\r
+    }\r
+    Gain_Exposure = Preview_Gain * Capture_Exposure;\r
+\r
+    if (Gain_Exposure < Capture_Banding_Filter * 16 )  //114\r
+    {\r
+        Capture_Exposure = Gain_Exposure / 16;\r
+\r
+        if(0 == Capture_Exposure)\r
+        {\r
+            Capture_Exposure = 1;\r
+        }\r
+\r
+        Capture_Gain = (Gain_Exposure*2 / Capture_Exposure + 1 ) / 2;\r
+    } else {\r
+        if (Gain_Exposure > Capture_Maximum_Shutter * 16 )    //1564*16\r
+        {\r
+            Capture_Exposure = Capture_Maximum_Shutter;\r
+            Capture_Gain = (Gain_Exposure*2 /Capture_Maximum_Shutter + 1)/2;\r
+     \r
+            if (Capture_Gain > Capture_Max_Gain)       //512\r
+            {\r
+                Capture_Exposure = Gain_Exposure/Capture_Max_Gain/16 + Gain_Exposure/10/Capture_Max_Gain/16;\r
+                if(0 == Capture_Exposure)\r
+                {\r
+                    Capture_Exposure = 1;\r
+                }\r
+\r
+                Capture_Exposure = Capture_Exposure/ Capture_Banding_Filter;\r
+                Capture_Exposure = Capture_Exposure * Capture_Banding_Filter;\r
+                Capture_Gain = (Gain_Exposure *2 / Capture_Exposure + 1) /2;\r
+            }\r
+        } else {\r
+            Capture_Exposure = Gain_Exposure /16/ Capture_Banding_Filter;\r
+            Capture_Exposure = Capture_Exposure * Capture_Banding_Filter;\r
+            if(0 == Capture_Exposure)\r
+            {\r
+                Capture_Exposure = 1;\r
+            }\r
+            Capture_Gain = (Gain_Exposure *2 / Capture_Exposure +1)/2;\r
+        }\r
+\r
+        shutter = Capture_Exposure;\r
+    }\r
+    \r
+    ret |= sensor_write_array(client, winseqe_set_addr);\r
+    if (ret != 0) {\r
+        SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());\r
+    }        \r
+                 \r
+               \r
+    if(shutter <= 1640)\r
+    {\r
+        extra_exposure_lines = 0;\r
+    } else {\r
+        extra_exposure_lines = shutter - 1640;\r
+    }\r
+\r
+    if (shutter > 1640)\r
+    {\r
+        shutter = 1640;\r
+    }\r
+\r
+    shutter = shutter * 16;\r
+\r
+    if(Capture_Gain >= 128)\r
+           sensor_write(client, 0x5000,0x07);  \r
+\r
+    sensor_write(client, 0x350d, (extra_exposure_lines & 0xFF));\r
+    sensor_write(client, 0x350c, ((extra_exposure_lines & 0xFF00) >> 8));\r
+\r
+    sensor_write(client, 0x3502, (shutter & 0xFF));\r
+    sensor_write(client, 0x3501, ((shutter & 0xFF00) >> 8));\r
+    sensor_write(client, 0x3500, ((shutter & 0xFF0000) >> 16));\r
+\r
+    sensor_write(client, 0x350b, (Capture_Gain & 0xFF));\r
+    sensor_write(client, 0x350a, (( Capture_Gain & 0xFF00) >> 8));\r
+}\r
+\r
+static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
+    struct i2c_client *client = v4l2_get_subdevdata(sd);\r
+    const struct sensor_datafmt *fmt;\r
+    struct SENSOR *sensor = to_sensor(client);\r
+       const struct v4l2_queryctrl *qctrl;\r
+       struct soc_camera_device *icd = client->dev.platform_data;\r
+    struct reginfo *winseqe_set_addr=NULL;\r
+    int ret=0, set_w,set_h;\r
+\r
+       fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,\r
+                                  ARRAY_SIZE(sensor_colour_fmts));\r
+       if (!fmt) {\r
+        ret = -EINVAL;\r
+        goto sensor_s_fmt_end;\r
+    }\r
+\r
+       if (sensor->info_priv.fmt.code != mf->code) {\r
+               switch (mf->code)\r
+               {\r
+                       case V4L2_MBUS_FMT_YUYV8_2X8:\r
+                       {\r
+                               winseqe_set_addr = sensor_ClrFmt_YUYV;\r
+                               break;\r
+                       }\r
+                       case V4L2_MBUS_FMT_UYVY8_2X8:\r
+                       {\r
+                               winseqe_set_addr = sensor_ClrFmt_UYVY;\r
+                               break;\r
+                       }\r
+                       default:\r
+                               break;\r
+               }\r
+               if (winseqe_set_addr != NULL) {\r
+            sensor_write_array(client, winseqe_set_addr);\r
+                       sensor->info_priv.fmt.code = mf->code;\r
+            sensor->info_priv.fmt.colorspace= mf->colorspace;            \r
+                       SENSOR_DG("%s v4l2_mbus_code:%d set success!\n", SENSOR_NAME_STRING(),mf->code);\r
+               } else {\r
+                       SENSOR_TR("%s v4l2_mbus_code:%d is invalidate!\n", SENSOR_NAME_STRING(),mf->code);\r
+               }\r
+       }\r
+\r
+    set_w = mf->width;\r
+    set_h = mf->height;\r
+\r
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)\r
+       {\r
+               winseqe_set_addr = sensor_qcif;\r
+        set_w = 176;\r
+        set_h = 144;\r
+       }\r
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_qvga;\r
+        set_w = 320;\r
+        set_h = 240;\r
+    }\r
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_cif;\r
+        set_w = 352;\r
+        set_h = 288;\r
+    }\r
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_vga;\r
+        set_w = 640;\r
+        set_h = 480;\r
+    }\r
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_svga;\r
+        set_w = 800;\r
+        set_h = 600;\r
+    }\r
+    else if (((set_w <= 1280) && (set_h <= 720)) && sensor_720p[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_720p;\r
+        set_w = 1280;\r
+        set_h = 720;\r
+    }\r
+       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_xga;\r
+        set_w = 1024;\r
+        set_h = 768;\r
+    }\r
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_sxga;\r
+        set_w = 1280;\r
+        set_h = 1024;\r
+    }\r
+    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_uxga;\r
+        set_w = 1600;\r
+        set_h = 1200;\r
+    }\r
+    else if (((set_w <= 2048) && (set_h <= 1536)) && sensor_qxga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_qxga;\r
+        set_w = 2048;\r
+        set_h = 1536;\r
+    }\r
+    else\r
+    {\r
+        winseqe_set_addr = SENSOR_INIT_WINSEQADR;               /* ddl@rock-chips.com : Sensor output smallest size if  isn't support app  */\r
+        set_w = SENSOR_INIT_WIDTH;\r
+        set_h = SENSOR_INIT_HEIGHT;\r
+               SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,mf->width,mf->height);\r
+    }\r
+\r
+    if ((int)winseqe_set_addr  != sensor->info_priv.winseqe_cur_addr) {\r
+        #if CONFIG_SENSOR_Flash\r
+        if (sensor_fmt_capturechk(sd,mf) == true) {      /* ddl@rock-chips.com : Capture */\r
+            if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {\r
+                sensor_ioctrl(icd, Sensor_Flash, Flash_On);\r
+                SENSOR_DG("%s flash on in capture!\n", SENSOR_NAME_STRING());\r
+            }           \r
+        } else {                                        /* ddl@rock-chips.com : Video */\r
+            if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {\r
+                sensor_ioctrl(icd, Sensor_Flash, Flash_Off);\r
+                SENSOR_DG("%s flash off in preivew!\n", SENSOR_NAME_STRING());\r
+            }\r
+        }\r
+        #endif\r
+       if (sensor_fmt_capturechk(sd,mf) != true)\r
+       {\r
+        ret |= sensor_write_array(client, winseqe_set_addr);\r
+        if (ret != 0) {\r
+            SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());\r
+            #if CONFIG_SENSOR_Flash\r
+            if (sensor_fmt_capturechk(sd,mf) == true) {\r
+                if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {\r
+                    sensor_ioctrl(icd, Sensor_Flash, Flash_Off);\r
+                    SENSOR_TR("%s Capture format set fail, flash off !\n", SENSOR_NAME_STRING());\r
+                }\r
+            }\r
+            #endif\r
+            goto sensor_s_fmt_end;\r
+        }        \r
+       }\r
+\r
+               sensor->info_priv.winseqe_cur_addr  = (int)winseqe_set_addr;\r
+\r
+               if (sensor_fmt_capturechk(sd,mf) == true) {                                 /* ddl@rock-chips.com : Capture */\r
+\r
+                       button5_Click(client,winseqe_set_addr);\r
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);\r
+                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);\r
+                       if (sensor->info_priv.whiteBalance != 0) {\r
+                               qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);\r
+                               sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);\r
+                       }\r
+                       sensor->info_priv.snap2preview = true;\r
+               } else if (sensor_fmt_videochk(sd,mf) == true) {                        /* ddl@rock-chips.com : Video */\r
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);\r
+                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);\r
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);\r
+                       sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);\r
+                       sensor->info_priv.video2preview = true;\r
+               } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) {\r
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);\r
+                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);\r
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);\r
+                       sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);\r
+            msleep(200);\r
+                       sensor->info_priv.video2preview = false;\r
+                       sensor->info_priv.snap2preview = false;\r
+               }\r
+               else\r
+       {msleep(200);}\r
+\r
+        SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);\r
+    }\r
+    else\r
+    {\r
+        SENSOR_DG("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);\r
+    }\r
+\r
+       mf->width = set_w;\r
+    mf->height = set_h;\r
+\r
+sensor_s_fmt_end:\r
+    return ret;\r
+}\r
+\r
+\r
+static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
+    struct i2c_client *client = v4l2_get_subdevdata(sd);\r
+    struct SENSOR *sensor = to_sensor(client);\r
+    const struct sensor_datafmt *fmt;\r
+    int ret = 0,set_w,set_h;\r
+   \r
+       fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,\r
+                                  ARRAY_SIZE(sensor_colour_fmts));\r
+       if (fmt == NULL) {\r
+               fmt = &sensor->info_priv.fmt;\r
+        mf->code = fmt->code;\r
+       } \r
+\r
+    if (mf->height > SENSOR_MAX_HEIGHT)\r
+        mf->height = SENSOR_MAX_HEIGHT;\r
+    else if (mf->height < SENSOR_MIN_HEIGHT)\r
+        mf->height = SENSOR_MIN_HEIGHT;\r
+\r
+    if (mf->width > SENSOR_MAX_WIDTH)\r
+        mf->width = SENSOR_MAX_WIDTH;\r
+    else if (mf->width < SENSOR_MIN_WIDTH)\r
+        mf->width = SENSOR_MIN_WIDTH;\r
+\r
+    set_w = mf->width;\r
+    set_h = mf->height;\r
+\r
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)\r
+       {\r
+        set_w = 176;\r
+        set_h = 144;\r
+       }\r
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)\r
+    {\r
+        set_w = 320;\r
+        set_h = 240;\r
+    }\r
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)\r
+    {\r
+        set_w = 352;\r
+        set_h = 288;\r
+    }\r
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)\r
+    {\r
+        set_w = 640;\r
+        set_h = 480;\r
+    }\r
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)\r
+    {\r
+        set_w = 800;\r
+        set_h = 600;\r
+    }\r
+    else if (((set_w <= 1280) && (set_h <= 720)) && sensor_720p[0].reg)\r
+    {\r
+        set_w = 1280;\r
+        set_h = 720;\r
+    }\r
+       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)\r
+    {\r
+        set_w = 1024;\r
+        set_h = 768;\r
+    }\r
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)\r
+    {\r
+        set_w = 1280;\r
+        set_h = 1024;\r
+    }\r
+    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)\r
+    {\r
+        set_w = 1600;\r
+        set_h = 1200;\r
+    }\r
+    else if (((set_w <= 2048) && (set_h <= 1536)) && sensor_qxga[0].reg)\r
+    {\r
+        set_w = 2048;\r
+        set_h = 1536;\r
+    }\r
+    else\r
+    {\r
+        set_w = SENSOR_INIT_WIDTH;\r
+        set_h = SENSOR_INIT_HEIGHT;\r
+               SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,mf->width,mf->height);\r
+    }\r
+\r
+    mf->width = set_w;\r
+    mf->height = set_h;\r
+    mf->colorspace = fmt->colorspace;\r
+    \r
+    return ret;\r
+}\r
+\r
+\r
+ static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)\r
+{\r
+    struct i2c_client *client = v4l2_get_subdevdata(sd);\r
+\r
+    if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)\r
+        return -EINVAL;\r
+\r
+    if (id->match.addr != client->addr)\r
+        return -ENODEV;\r
+\r
+    id->ident = SENSOR_V4L2_IDENT;      /* ddl@rock-chips.com :  Return OV2655  identifier */\r
+    id->revision = 0;\r
+\r
+    return 0;\r
+}\r
+#if CONFIG_SENSOR_Brightness\r
+static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Effect\r
+static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Exposure\r
+static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Saturation\r
+static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Contrast\r
+static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Mirror\r
+static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_MirrorSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_MirrorSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Flip\r
+static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_FlipSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_FlipSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Scene\r
+static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_WhiteBalance\r
+static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_DigitalZoom\r
+static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+    struct SENSOR *sensor = to_sensor(client);\r
+       const struct v4l2_queryctrl *qctrl_info;\r
+    int digitalzoom_cur, digitalzoom_total;\r
+\r
+       qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);\r
+       if (qctrl_info)\r
+               return -EINVAL;\r
+\r
+    digitalzoom_cur = sensor->info_priv.digitalzoom;\r
+    digitalzoom_total = qctrl_info->maximum;\r
+\r
+    if ((value > 0) && (digitalzoom_cur >= digitalzoom_total))\r
+    {\r
+        SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);\r
+        return -EINVAL;\r
+    }\r
+\r
+    if  ((value < 0) && (digitalzoom_cur <= qctrl_info->minimum))\r
+    {\r
+        SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);\r
+        return -EINVAL;\r
+    }\r
+\r
+    if ((value > 0) && ((digitalzoom_cur + *value) > digitalzoom_total))\r
+    {\r
+        value = digitalzoom_total - digitalzoom_cur;\r
+    }\r
+\r
+    if ((value < 0) && ((digitalzoom_cur + *value) < 0))\r
+    {\r
+        value = 0 - digitalzoom_cur;\r
+    }\r
+\r
+    digitalzoom_cur += value;\r
+\r
+    if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)\r
+    {\r
+        if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)\r
+        {\r
+            SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+            return -EINVAL;\r
+        }\r
+        SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+        return 0;\r
+    }\r
+\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Flash\r
+static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{    \r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {\r
+        if (value == 3) {       /* ddl@rock-chips.com: torch */\r
+            sensor_ioctrl(icd, Sensor_Flash, Flash_Torch);   /* Flash On */\r
+        } else {\r
+            sensor_ioctrl(icd, Sensor_Flash, Flash_Off);\r
+        }\r
+        SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+        return 0;\r
+    }\r
+    \r
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+\r
+static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)\r
+{\r
+    struct i2c_client *client = v4l2_get_subdevdata(sd);\r
+    struct SENSOR *sensor = to_sensor(client);\r
+    const struct v4l2_queryctrl *qctrl;\r
+\r
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);\r
+//jack+\r
+printk("jack+sensor_g_control\n");\r
+//jack-\r
+    if (!qctrl)\r
+    {\r
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);\r
+        return -EINVAL;\r
+    }\r
+\r
+    switch (ctrl->id)\r
+    {\r
+        case V4L2_CID_BRIGHTNESS:\r
+            {\r
+                ctrl->value = sensor->info_priv.brightness;\r
+                break;\r
+            }\r
+        case V4L2_CID_SATURATION:\r
+            {\r
+                ctrl->value = sensor->info_priv.saturation;\r
+                break;\r
+            }\r
+        case V4L2_CID_CONTRAST:\r
+            {\r
+                ctrl->value = sensor->info_priv.contrast;\r
+                break;\r
+            }\r
+        case V4L2_CID_DO_WHITE_BALANCE:\r
+            {\r
+                ctrl->value = sensor->info_priv.whiteBalance;\r
+                break;\r
+            }\r
+        case V4L2_CID_EXPOSURE:\r
+            {\r
+                ctrl->value = sensor->info_priv.exposure;\r
+                break;\r
+            }\r
+        case V4L2_CID_HFLIP:\r
+            {\r
+                ctrl->value = sensor->info_priv.mirror;\r
+                break;\r
+            }\r
+        case V4L2_CID_VFLIP:\r
+            {\r
+                ctrl->value = sensor->info_priv.flip;\r
+                break;\r
+            }\r
+        default :\r
+                break;\r
+    }\r
+    return 0;\r
+}\r
+\r
+\r
+\r
+static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)\r
+{\r
+    struct i2c_client *client = v4l2_get_subdevdata(sd);\r
+    struct SENSOR *sensor = to_sensor(client);\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    const struct v4l2_queryctrl *qctrl;\r
+\r
+\r
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);\r
+    if (!qctrl)\r
+    {\r
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);\r
+        return -EINVAL;\r
+    }\r
+\r
+    switch (ctrl->id)\r
+    {\r
+#if CONFIG_SENSOR_Brightness\r
+        case V4L2_CID_BRIGHTNESS:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.brightness)\r
+                {\r
+                    if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)\r
+                    {\r
+                        return -EINVAL;\r
+                    }\r
+                    sensor->info_priv.brightness = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Exposure\r
+        case V4L2_CID_EXPOSURE:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.exposure)\r
+                {\r
+                    if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)\r
+                    {\r
+                        return -EINVAL;\r
+                    }\r
+                    sensor->info_priv.exposure = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Saturation\r
+        case V4L2_CID_SATURATION:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.saturation)\r
+                {\r
+                    if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)\r
+                    {\r
+                        return -EINVAL;\r
+                    }\r
+                    sensor->info_priv.saturation = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Contrast\r
+        case V4L2_CID_CONTRAST:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.contrast)\r
+                {\r
+                    if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)\r
+                    {\r
+                        return -EINVAL;\r
+                    }\r
+                    sensor->info_priv.contrast = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_WhiteBalance\r
+        case V4L2_CID_DO_WHITE_BALANCE:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.whiteBalance)\r
+                {\r
+                    if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)\r
+                    {\r
+                        return -EINVAL;\r
+                    }\r
+                    sensor->info_priv.whiteBalance = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Mirror\r
+        case V4L2_CID_HFLIP:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.mirror)\r
+                {\r
+                    if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.mirror = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Flip\r
+        case V4L2_CID_VFLIP:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.flip)\r
+                {\r
+                    if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.flip = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+        default:\r
+            break;\r
+    }\r
+\r
+    return 0;\r
+}\r
+static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)\r
+{\r
+    const struct v4l2_queryctrl *qctrl;\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+    struct SENSOR *sensor = to_sensor(client);\r
+\r
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);\r
+\r
+    if (!qctrl)\r
+    {\r
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);\r
+        return -EINVAL;\r
+    }\r
+\r
+    switch (ext_ctrl->id)\r
+    {\r
+        case V4L2_CID_SCENE:\r
+            {\r
+                ext_ctrl->value = sensor->info_priv.scene;\r
+                break;\r
+            }\r
+        case V4L2_CID_EFFECT:\r
+            {\r
+                ext_ctrl->value = sensor->info_priv.effect;\r
+                break;\r
+            }\r
+        case V4L2_CID_ZOOM_ABSOLUTE:\r
+            {\r
+                ext_ctrl->value = sensor->info_priv.digitalzoom;\r
+                break;\r
+            }\r
+        case V4L2_CID_ZOOM_RELATIVE:\r
+            {\r
+                return -EINVAL;\r
+            }\r
+        case V4L2_CID_FOCUS_ABSOLUTE:\r
+            {\r
+                ext_ctrl->value = sensor->info_priv.focus;\r
+                break;\r
+            }\r
+        case V4L2_CID_FOCUS_RELATIVE:\r
+            {\r
+                return -EINVAL;\r
+            }\r
+        case V4L2_CID_FLASH:\r
+            {\r
+                ext_ctrl->value = sensor->info_priv.flash;\r
+                break;\r
+            }\r
+        default :\r
+            break;\r
+    }\r
+    return 0;\r
+}\r
+static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)\r
+{\r
+    const struct v4l2_queryctrl *qctrl;\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+    struct SENSOR *sensor = to_sensor(client);\r
+    int val_offset;\r
+\r
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);\r
+    \r
+    if (!qctrl)\r
+    {\r
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);\r
+        return -EINVAL;\r
+    }\r
+\r
+       val_offset = 0;\r
+    switch (ext_ctrl->id)\r
+    {\r
+#if CONFIG_SENSOR_Scene\r
+        case V4L2_CID_SCENE:\r
+            {\r
+                if (ext_ctrl->value != sensor->info_priv.scene)\r
+                {\r
+                    if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.scene = ext_ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Effect\r
+        case V4L2_CID_EFFECT:\r
+            {\r
+                if (ext_ctrl->value != sensor->info_priv.effect)\r
+                {\r
+                    if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.effect= ext_ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_DigitalZoom\r
+        case V4L2_CID_ZOOM_ABSOLUTE:\r
+            {\r
+                if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))\r
+                    return -EINVAL;\r
+\r
+                if (ext_ctrl->value != sensor->info_priv.digitalzoom)\r
+                {\r
+                    val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;\r
+\r
+                    if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.digitalzoom += val_offset;\r
+\r
+                    SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(),  sensor->info_priv.digitalzoom);\r
+                }\r
+\r
+                break;\r
+            }\r
+        case V4L2_CID_ZOOM_RELATIVE:\r
+            {\r
+                if (ext_ctrl->value)\r
+                {\r
+                    if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.digitalzoom += ext_ctrl->value;\r
+\r
+                    SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Focus\r
+        case V4L2_CID_FOCUS_ABSOLUTE:\r
+            {\r
+                if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))\r
+                    return -EINVAL;\r
+\r
+                if (ext_ctrl->value != sensor->info_priv.focus)\r
+                {\r
+                    val_offset = ext_ctrl->value -sensor->info_priv.focus;\r
+\r
+                    sensor->info_priv.focus += val_offset;\r
+                }\r
+\r
+                break;\r
+            }\r
+        case V4L2_CID_FOCUS_RELATIVE:\r
+            {\r
+                if (ext_ctrl->value)\r
+                {\r
+                    sensor->info_priv.focus += ext_ctrl->value;\r
+\r
+                    SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Flash\r
+        case V4L2_CID_FLASH:\r
+            {\r
+                if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)\r
+                    return -EINVAL;\r
+                sensor->info_priv.flash = ext_ctrl->value;\r
+\r
+                SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);\r
+                break;\r
+            }\r
+#endif\r
+        default:\r
+            break;\r
+    }\r
+\r
+    return 0;\r
+}\r
+\r
+static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)\r
+{\r
+    struct i2c_client *client = v4l2_get_subdevdata(sd);\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    int i, error_cnt=0, error_idx=-1;\r
+\r
+    for (i=0; i<ext_ctrl->count; i++) {\r
+        if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {\r
+            error_cnt++;\r
+            error_idx = i;\r
+        }\r
+    }\r
+\r
+    if (error_cnt > 1)\r
+        error_idx = ext_ctrl->count;\r
+\r
+    if (error_idx != -1) {\r
+        ext_ctrl->error_idx = error_idx;\r
+        return -EINVAL;\r
+    } else {\r
+        return 0;\r
+    }\r
+}\r
+\r
+static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)\r
+{\r
+   struct i2c_client *client = v4l2_get_subdevdata(sd);\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    int i, error_cnt=0, error_idx=-1;\r
+\r
+    for (i=0; i<ext_ctrl->count; i++) {\r
+        if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {\r
+            error_cnt++;\r
+            error_idx = i;\r
+        }\r
+    }\r
+\r
+    if (error_cnt > 1)\r
+        error_idx = ext_ctrl->count;\r
+\r
+    if (error_idx != -1) {\r
+        ext_ctrl->error_idx = error_idx;\r
+        return -EINVAL;\r
+    } else {\r
+        return 0;\r
+    }\r
+}\r
+\r
+/* Interface active, can use i2c. If it fails, it can indeed mean, that\r
+ * this wasn't our capture interface, so, we wait for the right one */\r
+static int sensor_video_probe(struct soc_camera_device *icd,\r
+                              struct i2c_client *client)\r
+{\r
+unsigned char value;\r
+int ret,pid = 0;\r
+    struct SENSOR *sensor = to_sensor(client);\r
+\r
+    /* We must have a parent by now. And it cannot be a wrong one.\r
+     * So this entire test is completely redundant. */\r
+    if (!icd->dev.parent ||\r
+           to_soc_camera_host(icd->dev.parent)->nr != icd->iface)\r
+               return -ENODEV;\r
+\r
+       if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {\r
+               ret = -ENODEV;\r
+               goto sensor_video_probe_err;\r
+       }\r
+\r
+    /* soft reset */\r
+    mdelay(5);          //delay 5 microseconds\r
+\r
+    /* check if it is an sensor sensor */\r
+    ret = sensor_read(client, 0x300a, &value);\r
+    if (ret != 0) {\r
+        SENSOR_TR("read chip id high byte failed\n");\r
+        ret = -ENODEV;\r
+        goto sensor_video_probe_err;\r
+    }\r
+\r
+    pid |= (value << 8);\r
+\r
+    ret = sensor_read(client, 0x300b, &value);\r
+    if (ret != 0) {\r
+        SENSOR_TR("read chip id low byte failed\n");\r
+        ret = -ENODEV;\r
+        goto sensor_video_probe_err;\r
+    }\r
+\r
+    pid |= (value & 0xff);\r
+    SENSOR_DG("\n %s  pid = 0x%x\n", SENSOR_NAME_STRING(), pid);\r
+    if (pid == SENSOR_ID) {\r
+        sensor->model = SENSOR_V4L2_IDENT;\r
+    } else {\r
+        SENSOR_TR("error: %s mismatched   pid = 0x%x\n", SENSOR_NAME_STRING(), pid);\r
+        ret = -ENODEV;\r
+        goto sensor_video_probe_err;\r
+    }\r
+\r
+    //icd->formats = sensor_colour_formats;\r
+    //icd->num_formats = ARRAY_SIZE(sensor_colour_formats);\r
+\r
+    return 0;\r
+\r
+sensor_video_probe_err:\r
+\r
+    return ret;\r
+}\r
+\r
+static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)\r
+{\r
+       struct i2c_client *client = v4l2_get_subdevdata(sd);\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    struct SENSOR *sensor = to_sensor(client);\r
+    int ret = 0;\r
+       #if CONFIG_SENSOR_Flash \r
+    int i;\r
+#endif\r
+    printk("jack+sensor_ioctl\n");  //jack++\r
+       SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);\r
+       switch (cmd)\r
+       {\r
+               case RK29_CAM_SUBDEV_DEACTIVATE:\r
+               {\r
+                       sensor_deactivate(client);\r
+                       break;\r
+               }\r
+\r
+               case RK29_CAM_SUBDEV_IOREQUEST:\r
+               {\r
+                       sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;           \r
+            if (sensor->sensor_io_request != NULL) { \r
+                if (sensor->sensor_io_request->gpio_res[0].dev_name && \r
+                    (strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {\r
+                    sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];\r
+                } else if (sensor->sensor_io_request->gpio_res[1].dev_name && \r
+                    (strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {\r
+                    sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];\r
+                }\r
+            } else {\r
+                SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);\r
+                ret = -EINVAL;\r
+                goto sensor_ioctl_end;\r
+            }\r
+            /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control \r
+               for this project */\r
+            #if CONFIG_SENSOR_Flash    \r
+               if (sensor->sensor_gpio_res) { \r
+                if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {\r
+                    for (i = 0; i < icd->ops->num_controls; i++) {\r
+                               if (V4L2_CID_FLASH == icd->ops->controls[i].id) {\r
+                               //      memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));                                       \r
+                                               sensor_controls[i].id=0xffff;\r
+                               }\r
+                    }\r
+                    sensor->info_priv.flash = 0xff;\r
+                    SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());\r
+                }else{ //two cameras are the same,need to deal diffrently ,zyc\r
+                    for (i = 0; i < icd->ops->num_controls; i++) {\r
+                           if(0xffff == icd->ops->controls[i].id){\r
+                             sensor_controls[i].id=V4L2_CID_FLASH;\r
+                           }               \r
+                    }\r
+                }\r
+               }\r
+            #endif\r
+                       break;\r
+               }\r
+               default:\r
+               {\r
+                       SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);\r
+                       break;\r
+               }\r
+       }\r
+sensor_ioctl_end:\r
+       return ret;\r
+\r
+}\r
+\r
+static int sensor_enum_fmt(struct v4l2_subdev *sd, unsigned int index,\r
+                           enum v4l2_mbus_pixelcode *code)\r
+{\r
+       if (index >= ARRAY_SIZE(sensor_colour_fmts))\r
+               return -EINVAL;\r
+\r
+       *code = sensor_colour_fmts[index].code;\r
+       return 0;\r
+}\r
+\r
+static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {\r
+       .init           = sensor_init,\r
+       .g_ctrl         = sensor_g_control,\r
+       .s_ctrl         = sensor_s_control,\r
+       .g_ext_ctrls          = sensor_g_ext_controls,\r
+       .s_ext_ctrls          = sensor_s_ext_controls,\r
+       .g_chip_ident   = sensor_g_chip_ident,\r
+       .ioctl = sensor_ioctl,\r
+};\r
+\r
+static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {\r
+       .s_mbus_fmt     = sensor_s_fmt,\r
+       .g_mbus_fmt     = sensor_g_fmt,\r
+       .try_mbus_fmt   = sensor_try_fmt,\r
+       .enum_mbus_fmt  = sensor_enum_fmt,\r
+};\r
+\r
+\r
+static struct v4l2_subdev_ops sensor_subdev_ops = {\r
+       .core   = &sensor_subdev_core_ops,\r
+       .video = &sensor_subdev_video_ops,\r
+};\r
+\r
+static int sensor_probe(struct i2c_client *client,\r
+                        const struct i2c_device_id *did)\r
+{\r
+    struct SENSOR *sensor;\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);\r
+    struct soc_camera_link *icl;\r
+    int ret;\r
+\r
+    SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);\r
+    if (!icd) {\r
+        dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());\r
+        return -EINVAL;\r
+    }\r
+\r
+    icl = to_soc_camera_link(icd);\r
+    if (!icl) {\r
+        dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());\r
+        return -EINVAL;\r
+    }\r
+\r
+    if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {\r
+        dev_warn(&adapter->dev,\r
+                "I2C-Adapter doesn't support I2C_FUNC_I2C\n");\r
+        return -EIO;\r
+    }\r
+\r
+    sensor = kzalloc(sizeof(struct SENSOR), GFP_KERNEL);\r
+    if (!sensor)\r
+        return -ENOMEM;\r
+\r
+    v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);\r
+\r
+    /* Second stage probe - when a capture adapter is there */\r
+    icd->ops           = &sensor_ops;\r
+    sensor->info_priv.fmt = sensor_colour_fmts[0];\r
+       #if CONFIG_SENSOR_I2C_NOSCHED\r
+       atomic_set(&sensor->tasklock_cnt,0);\r
+       #endif\r
+\r
+    ret = sensor_video_probe(icd, client);\r
+    if (ret < 0) {\r
+        icd->ops = NULL;\r
+        i2c_set_clientdata(client, NULL);\r
+        kfree(sensor);\r
+               sensor = NULL;\r
+    }\r
+\r
+    #if CONFIG_SENSOR_Flash\r
+    hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);\r
+       flash_off_timer.timer.function = flash_off_func;\r
+    #endif\r
+    \r
+    SENSOR_DG("\n%s..%s..%d  ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);\r
+    return ret;\r
+}\r
+\r
+static int sensor_remove(struct i2c_client *client)\r
+{\r
+    struct SENSOR *sensor = to_sensor(client);\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+\r
+    icd->ops = NULL;\r
+    i2c_set_clientdata(client, NULL);\r
+    client->driver = NULL;\r
+    kfree(sensor);\r
+       sensor = NULL;\r
+    return 0;\r
+}\r
+\r
+static const struct i2c_device_id sensor_id[] = {\r
+       {SENSOR_NAME_STRING(), 0 },\r
+       { }\r
+};\r
+MODULE_DEVICE_TABLE(i2c, sensor_id);\r
+\r
+static struct i2c_driver sensor_i2c_driver = {\r
+       .driver = {\r
+               .name = SENSOR_NAME_STRING(),\r
+       },\r
+       .probe          = sensor_probe,\r
+       .remove         = sensor_remove,\r
+       .id_table       = sensor_id,\r
+};\r
+\r
+static int __init sensor_mod_init(void)\r
+{\r
+\r
+    SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());\r
+    return i2c_add_driver(&sensor_i2c_driver);\r
+}\r
+\r
+static void __exit sensor_mod_exit(void)\r
+{\r
+    i2c_del_driver(&sensor_i2c_driver);\r
+}\r
+\r
+device_initcall_sync(sensor_mod_init);\r
+module_exit(sensor_mod_exit);\r
+\r
+MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));\r
+MODULE_AUTHOR("ddl <kernel@rock-chips>");\r
+MODULE_LICENSE("GPL");\r
+\r
+\r
+\r