camera: update gc2015 sensor driver and add gc0307 sensor driver
authorddl <ddl@rockchip.com>
Mon, 22 Aug 2011 06:32:56 +0000 (14:32 +0800)
committerddl <ddl@rockchip.com>
Mon, 22 Aug 2011 06:48:37 +0000 (14:48 +0800)
arch/arm/mach-rk29/include/mach/rk29_camera.h
drivers/media/video/Kconfig
drivers/media/video/Makefile
drivers/media/video/gc0307.c [new file with mode: 0755]
drivers/media/video/gc2015.c
include/media/v4l2-chip-ident.h

index 599b54cfc542ee6ac8f076fcc7b6e3bdcaa2eb85..b921507ff684f56798e152ec876cafa6fc0f4e99 100755 (executable)
@@ -46,6 +46,7 @@
 #define RK29_CAM_SENSOR_MT9P111 mt9p111
 #define RK29_CAM_SENSOR_MT9T111 mt9t111
 #define RK29_CAM_SENSOR_GT2005  gt2005
+#define RK29_CAM_SENSOR_GC0307  gc0307
 #define RK29_CAM_SENSOR_GC0308  gc0308
 #define RK29_CAM_SENSOR_GC0309  gc0309
 #define RK29_CAM_SENSOR_GC2015  gc2015
@@ -69,6 +70,7 @@
 #define RK29_CAM_SENSOR_NAME_MT9P111 "mt9p111"
 #define RK29_CAM_SENSOR_NAME_MT9T111 "mt9t111"
 #define RK29_CAM_SENSOR_NAME_GT2005  "gt2005"
+#define RK29_CAM_SENSOR_NAME_GC0307  "gc0307"
 #define RK29_CAM_SENSOR_NAME_GC0308  "gc0308"
 #define RK29_CAM_SENSOR_NAME_GC0309  "gc0309"
 #define RK29_CAM_SENSOR_NAME_GC2015  "gc2015"
index b63c26c508d4281d2c26371149bd96ccd18e2e1c..59219546784d1a4eaf36b3a887b4872b89aea5a2 100755 (executable)
@@ -981,7 +981,12 @@ config SOC_CAMERA_GT2005
        tristate "GT2005 support"
        depends on SOC_CAMERA && I2C
        help
-         This is a GT2005 camera driver          
+         This is a GT2005 camera driver         
+config SOC_CAMERA_GC0307
+       tristate "GC0307 support"
+       depends on SOC_CAMERA && I2C
+       help
+         This is a GC0307 camera driver           
 config SOC_CAMERA_GC0308
        tristate "GC0308 support"
        depends on SOC_CAMERA && I2C
index 9d3c5674e53563befee3b6c39660c971676b07c1..a15fb2f75acc4e330ab0787c0f32109917738c65 100755 (executable)
@@ -93,6 +93,7 @@ obj-$(CONFIG_SOC_CAMERA_OV5640)               += ov5640.o
 obj-$(CONFIG_SOC_CAMERA_OV5642)                += ov5642.o
 obj-$(CONFIG_SOC_CAMERA_S5K6AA)                += s5k6aa.o
 obj-$(CONFIG_SOC_CAMERA_GT2005)                += gt2005.o
+obj-$(CONFIG_SOC_CAMERA_GC0307)                += gc0307.o
 obj-$(CONFIG_SOC_CAMERA_GC0308)                += gc0308.o
 obj-$(CONFIG_SOC_CAMERA_GC0309)                += gc0309.o
 obj-$(CONFIG_SOC_CAMERA_GC2015)                += gc2015.o
diff --git a/drivers/media/video/gc0307.c b/drivers/media/video/gc0307.c
new file mode 100755 (executable)
index 0000000..2ee8abe
--- /dev/null
@@ -0,0 +1,2960 @@
+
+/*
+o* Driver for MT9M001 CMOS Image Sensor from Micron
+ *
+ * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/videodev2.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/log2.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/circ_buf.h>
+#include <linux/miscdevice.h>
+#include <media/v4l2-common.h>
+#include <media/v4l2-chip-ident.h>
+#include <media/soc_camera.h>
+#include <mach/rk29_camera.h>
+
+static int debug;
+module_param(debug, int, S_IRUGO|S_IWUSR);
+
+#define dprintk(level, fmt, arg...) do {                       \
+       if (debug >= level)                                     \
+       printk(KERN_WARNING fmt , ## arg); } while (0)
+
+#define SENSOR_TR(format, ...) printk(KERN_ERR format, ## __VA_ARGS__)
+#define SENSOR_DG(format, ...) dprintk(1, format, ## __VA_ARGS__)
+
+
+#define _CONS(a,b) a##b
+#define CONS(a,b) _CONS(a,b)
+
+#define __STR(x) #x
+#define _STR(x) __STR(x)
+#define STR(x) _STR(x)
+
+#define MIN(x,y)   ((x<y) ? x: y)
+#define MAX(x,y)    ((x>y) ? x: y)
+
+/* Sensor Driver Configuration */
+#define SENSOR_NAME RK29_CAM_SENSOR_GC0307
+#define SENSOR_V4L2_IDENT V4L2_IDENT_GC0307
+#define SENSOR_ID 0x99
+#define SENSOR_MIN_WIDTH    640//176
+#define SENSOR_MIN_HEIGHT   480//144
+#define SENSOR_MAX_WIDTH    800//1600
+#define SENSOR_MAX_HEIGHT   600//1200
+#define SENSOR_INIT_WIDTH      640                     /* Sensor pixel size for sensor_init_data array */
+#define SENSOR_INIT_HEIGHT  480
+#define SENSOR_INIT_WINSEQADR sensor_vga
+#define SENSOR_INIT_PIXFMT V4L2_PIX_FMT_YUYV
+
+#define CONFIG_SENSOR_WhiteBalance     1
+#define CONFIG_SENSOR_Brightness       0
+#define CONFIG_SENSOR_Contrast      0
+#define CONFIG_SENSOR_Saturation    0
+#define CONFIG_SENSOR_Effect        1
+#define CONFIG_SENSOR_Scene         0
+#define CONFIG_SENSOR_DigitalZoom   0
+#define CONFIG_SENSOR_Focus         0
+#define CONFIG_SENSOR_Exposure      0
+#define CONFIG_SENSOR_Flash         0
+#define CONFIG_SENSOR_Mirror        0
+#define CONFIG_SENSOR_Flip          0
+
+#define CONFIG_SENSOR_I2C_SPEED     100000//250000       /* Hz */
+/* Sensor write register continues by preempt_disable/preempt_enable for current process not be scheduled */
+#define CONFIG_SENSOR_I2C_NOSCHED   0
+#define CONFIG_SENSOR_I2C_RDWRCHK   0
+
+#define SENSOR_BUS_PARAM  (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |\
+                          SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |\
+                          SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8  |SOCAM_MCLK_24MHZ)
+
+#define COLOR_TEMPERATURE_CLOUDY_DN  6500
+#define COLOR_TEMPERATURE_CLOUDY_UP    8000
+#define COLOR_TEMPERATURE_CLEARDAY_DN  5000
+#define COLOR_TEMPERATURE_CLEARDAY_UP    6500
+#define COLOR_TEMPERATURE_OFFICE_DN     3500
+#define COLOR_TEMPERATURE_OFFICE_UP     5000
+#define COLOR_TEMPERATURE_HOME_DN       2500
+#define COLOR_TEMPERATURE_HOME_UP       3500
+
+#define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))
+#define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)
+
+#define SENSOR_AF_IS_ERR    (0x00<<0)
+#define SENSOR_AF_IS_OK                (0x01<<0)
+#define SENSOR_INIT_IS_ERR   (0x00<<28)
+#define SENSOR_INIT_IS_OK    (0x01<<28)
+struct reginfo
+{
+    u8 reg;
+    u8 val;
+};
+
+/* init 640X480 VGA */
+static struct reginfo sensor_init_data[] =
+{
+//========= close output
+       {0x43  ,0x00}, 
+       {0x44  ,0xa2}, 
+       
+       //========= close some functions
+       // open them after configure their parmameters
+       {0x40  ,0x10}, 
+       {0x41  ,0x00},                  
+       {0x42  ,0x10},                                          
+       {0x47  ,0x00}, //mode1,                                 
+       {0x48  ,0xc3}, //mode2,         
+       {0x49  ,0x00}, //dither_mode            
+       {0x4a  ,0x00}, //clock_gating_en
+       {0x4b  ,0x00}, //mode_reg3
+       {0x4E  ,0x22},//0x23}, //sync mode yaowei
+       {0x4F  ,0x01}, //AWB, AEC, every N frame        
+       
+       //========= frame timing
+       {0x01  ,0x6a}, //HB
+       {0x02  ,0x70}, //VB
+       {0x1C  ,0x00}, //Vs_st
+       {0x1D  ,0x00}, //Vs_et
+       {0x10  ,0x00}, //high 4 bits of VB, HB
+       {0x11  ,0x05}, //row_tail,  AD_pipe_number
+
+
+                
+       
+       
+       //========= windowing
+       {0x05  ,0x00}, //row_start
+       {0x06  ,0x00},
+       {0x07  ,0x00}, //col start
+       {0x08  ,0x00}, 
+       {0x09  ,0x01}, //win height
+       {0x0A  ,0xE8},
+       {0x0B  ,0x02}, //win width, pixel array only 640
+       {0x0C  ,0x80},
+       
+       //========= analog
+       {0x0D  ,0x22}, //rsh_width
+                                         
+       {0x0E  ,0x02}, //CISCTL mode2,  
+
+                         
+       {0x12  ,0x70}, //7 hrst, 6_4 darsg,
+       {0x13  ,0x00}, //7 CISCTL_restart, 0 apwd
+       {0x14  ,0x00}, //NA
+       {0x15  ,0xba}, //7_4 vref
+       {0x16  ,0x13}, //5to4 _coln_r,  __1to0__da18
+       {0x17  ,0x52}, //opa_r, ref_r, sRef_r
+       //{0x18  ,0xc0}, //analog_mode, best case for left band.
+       
+       {0x1E  ,0x0d}, //tsp_width                 
+       {0x1F  ,0x32}, //sh_delay
+       
+       //========= offset
+       {0x47  ,0x00},  //7__test_image, __6__fixed_pga, __5__auto_DN, __4__CbCr_fix, 
+                               //__3to2__dark_sequence, __1__allow_pclk_vcync, __0__LSC_test_image
+       {0x19  ,0x06},  //pga_o                  
+       {0x1a  ,0x06},  //pga_e                  
+       
+       {0x31  ,0x00},  //4     //pga_oFFset ,   high 8bits of 11bits
+       {0x3B  ,0x00},  //global_oFFset, low 8bits of 11bits
+       
+       {0x59  ,0x0f},  //offset_mode   
+       {0x58  ,0x88},  //DARK_VALUE_RATIO_G,  DARK_VALUE_RATIO_RB
+       {0x57  ,0x08},  //DARK_CURRENT_RATE
+       {0x56  ,0x77},  //PGA_OFFSET_EVEN_RATIO, PGA_OFFSET_ODD_RATIO
+       
+       //========= blk
+       {0x35  ,0xd8},  //blk_mode
+
+       {0x36  ,0x40},  
+       
+       {0x3C  ,0x00}, 
+       {0x3D  ,0x00}, 
+       {0x3E  ,0x00}, 
+       {0x3F  ,0x00}, 
+       
+       {0xb5  ,0x70}, 
+       {0xb6  ,0x40}, 
+       {0xb7  ,0x00}, 
+       {0xb8  ,0x38}, 
+       {0xb9  ,0xc3},            
+       {0xba  ,0x0f}, 
+       
+       {0x7e  ,0x50},//0x45 ylz++ 
+       {0x7f  ,0x76},   //0x66
+       
+       {0x5c  ,0x48}, //78
+       {0x5d  ,0x58}, //88
+       
+       
+       //========= manual_gain 
+       {0x61  ,0x80}, //manual_gain_g1 
+       {0x63  ,0x80}, //manual_gain_r
+       {0x65  ,0x98}, //manual_gai_b, 0xa0=1.25, 0x98=1.1875
+       {0x67  ,0x80}, //manual_gain_g2
+       {0x68  ,0x18}, //global_manual_gain      2.4bits
+       
+       //=========CC _R
+       {0x69  ,0x58},  //54
+       {0x6A  ,0xf6},  //ff
+       {0x6B  ,0xfb},  //fe
+       {0x6C  ,0xf4},  //ff
+       {0x6D  ,0x5a},  //5f
+       {0x6E  ,0xe6},  //e1
+
+       {0x6f  ,0x00},  
+       
+       //=========lsc                                                    
+       {0x70  ,0x14}, 
+       {0x71  ,0x1c}, 
+       {0x72  ,0x20}, 
+       
+       {0x73  ,0x10},  
+       {0x74  ,0x3c}, 
+       {0x75  ,0x52}, 
+       
+       //=========dn                                                                                                                                                    
+       {0x7d  ,0x2f},  //dn_mode       
+       {0x80  ,0x0c}, //when auto_dn, check 7e,7f
+       {0x81  ,0x0c},
+       {0x82  ,0x44},
+                                                                                                                                                                               
+       //dd                                                                                                                                               
+       {0x83  ,0x18},  //DD_TH1                                          
+       {0x84  ,0x18},  //DD_TH2                                          
+       {0x85  ,0x04},  //DD_TH3                                                                                                                                                                                          
+       {0x87  ,0x34},  //32 b DNDD_low_range X16,  DNDD_low_range_C_weight_center                                      
+       
+          
+       //=========intp-ee                                                                                                                                                 
+       {0x88  ,0x04},                                                                                                             
+       {0x89  ,0x01},                                                                                    
+       {0x8a  ,0x50},//60                                                                                 
+       {0x8b  ,0x50},//60                                                                                 
+       {0x8c  ,0x07},                                                                                                                                    
+                                                                                                                                                                         
+       {0x50  ,0x0c},                                                                  
+       {0x5f  ,0x3c},                                                                                                                                                                   
+                                                                                                                                                                        
+       {0x8e  ,0x02},                                                                                                                            
+       {0x86  ,0x02},                                                                                                                                    
+                                                                                                                                                                       
+       {0x51  ,0x20},                                                                                                                                  
+       {0x52  ,0x08},  
+       {0x53  ,0x00}, 
+       
+       
+       //========= YCP 
+       //contrast_center                                                                                                                                                         
+       {0x77  ,0x80}, //contrast_center                                                                                                                                  
+       {0x78  ,0x00}, //fixed_Cb                                                                                                                                                 
+       {0x79  ,0x00}, //fixed_Cr                                                                                                                                                 
+       {0x7a  ,0x00}, //luma_offset                                                                                                                                                                                                                                                                                                                    
+       {0x7b  ,0x40}, //hue_cos                                                                                                                                                  
+       {0x7c  ,0x00}, //hue_sin                                                                                                                                                  
+                                                                                                                                                                                        
+       //saturation                                                                                                                                                              
+       {0xa0  ,0x40}, //global_saturation
+       {0xa1  ,0x42}, //luma_contrast                                                                                                                                    
+       {0xa2  ,0x40}, //saturation_Cb          //ylz  34                                                                                                                         
+       {0xa3  ,0x34}, //saturation_Cr
+                                                                                                                                                               
+       {0xa4  ,0xc8},                                                                                                                            
+       {0xa5  ,0x02}, 
+       {0xa6  ,0x28},                                                                                                                                                    
+       {0xa7  ,0x02}, 
+       
+       //skin                                                                                                                                                                                            
+       {0xa8  ,0xee},                                                                                                                    
+       {0xa9  ,0x12},                                                                                                                    
+       {0xaa  ,0x01},                                                                                                            
+       {0xab  ,0x20},                                                                                                    
+       {0xac  ,0xf0},                                                                                                            
+       {0xad  ,0x10},                                                                                                                    
+               
+       //========= ABS
+       {0xae  ,0x18}, 
+       {0xaf  ,0x74}, 
+       {0xb0  ,0xe0},    
+       {0xb1  ,0x20}, 
+       {0xb2  ,0x6c}, 
+       {0xb3  ,0x40}, 
+       {0xb4  ,0x04}, 
+               
+       //========= AWB 
+       {0xbb  ,0x42}, 
+       {0xbc  ,0x60},
+       {0xbd  ,0x50},
+       {0xbe  ,0x50},
+       
+       {0xbf  ,0x0c}, 
+       {0xc0  ,0x06}, 
+       {0xc1  ,0x60}, 
+       {0xc2  ,0xf1},  //f1
+       {0xc3  ,0x40},
+       {0xc4  ,0x1c}, //18//20
+       {0xc5  ,0x56},  //33
+       {0xc6  ,0x1d}, 
+
+       {0xca  ,0x70}, 
+       {0xcb  ,0x70}, 
+       {0xcc  ,0x78},
+       
+       {0xcd  ,0x80}, //R_ratio                                                                         
+       {0xce  ,0x80}, //G_ratio  , cold_white white                                                               
+       {0xcf  ,0x80}, //B_ratio        
+       
+       //=========  aecT  
+       {0x20  ,0x06},//0x02 
+       {0x21  ,0xc0}, 
+       {0x22  ,0x40},    
+       {0x23  ,0x88}, 
+       {0x24  ,0x96}, 
+       {0x25  ,0x30}, 
+       {0x26  ,0xd0}, 
+       {0x27  ,0x00}, 
+       
+       {0x28  ,0x02}, //AEC_exp_level_1bit11to8   
+       {0x29  ,0x58}, //AEC_exp_level_1bit7to0   
+       {0x2a  ,0x03}, //AEC_exp_level_2bit11to8   
+       {0x2b  ,0x84}, //AEC_exp_level_2bit7to0                  
+       {0x2c  ,0x09}, //AEC_exp_level_3bit11to8   659 - 8FPS,  8ca - 6FPS  //   
+       {0x2d  ,0x60}, //AEC_exp_level_3bit7to0                  
+       {0x2e  ,0x0a}, //AEC_exp_level_4bit11to8   4FPS 
+       {0x2f  ,0x8c}, //AEC_exp_level_4bit7to0  
+       
+       {0x30  ,0x20},                                            
+       {0x31  ,0x00},                                     
+       {0x32  ,0x1c}, 
+       {0x33  ,0x90},                    
+       {0x34  ,0x10},  
+       
+       {0xd0  ,0x34}, 
+                          
+       {0xd1  ,0x40}, //AEC_target_Y                                              
+       {0xd2  ,0x61},//0xf2      
+       {0xd4  ,0x96}, 
+       {0xd5  ,0x01}, // william 0318
+       {0xd6  ,0x96}, //antiflicker_step                                          
+       {0xd7  ,0x03}, //AEC_exp_time_min ,william 20090312                        
+       {0xd8  ,0x02}, 
+                          
+       {0xdd  ,0x12},//0x12 
+                                                                                                                               
+       //========= measure window                                                                              
+       {0xe0  ,0x03},                                           
+       {0xe1  ,0x02},                                                   
+       {0xe2  ,0x27},                                                           
+       {0xe3  ,0x1e},                           
+       {0xe8  ,0x3b},                                   
+       {0xe9  ,0x6e},                                           
+       {0xea  ,0x2c},                                   
+       {0xeb  ,0x50},                                   
+       {0xec  ,0x73},           
+       
+       //========= close_frame                                                                                                 
+       {0xed  ,0x00}, //close_frame_num1 ,can be use to reduce FPS                              
+       {0xee  ,0x00}, //close_frame_num2  
+       {0xef  ,0x00}, //close_frame_num
+       
+       // page1
+       {0xf0  ,0x01}, //select page1 
+       
+       {0x00  ,0x20},                                                    
+       {0x01  ,0x20},                                                    
+       {0x02  ,0x20},                                                                  
+       {0x03  ,0x20},                                                  
+       {0x04  ,0x78}, 
+       {0x05  ,0x78},                                   
+       {0x06  ,0x78},                                                            
+       {0x07  ,0x78},                                                                   
+       
+       
+       
+       {0x10  ,0x04},                                            
+       {0x11  ,0x04},                                                    
+       {0x12  ,0x04},                                            
+       {0x13  ,0x04},                                                    
+       {0x14  ,0x01},                                                    
+       {0x15  ,0x01},                                                    
+       {0x16  ,0x01},                                           
+       {0x17  ,0x01},                                           
+                 
+                                                                                                        
+       {0x20  ,0x00},                                    
+       {0x21  ,0x00},                                    
+       {0x22  ,0x00},                                            
+       {0x23  ,0x00},                                            
+       {0x24  ,0x00},                                    
+       {0x25  ,0x00},                                            
+       {0x26  ,0x00},                                    
+       {0x27  ,0x00},                                                    
+       
+       {0x40  ,0x11}, 
+       
+       //=============================lscP 
+       {0x45  ,0x06},   
+       {0x46  ,0x06},                   
+       {0x47  ,0x05}, 
+       
+       {0x48  ,0x04},  
+       {0x49  ,0x03},           
+       {0x4a  ,0x03}, 
+       
+
+       {0x62  ,0xd8}, 
+       {0x63  ,0x24}, 
+       {0x64  ,0x24},
+       {0x65  ,0x24}, 
+       {0x66  ,0xd8}, 
+       {0x67  ,0x24},
+       
+       {0x5a  ,0x00}, 
+       {0x5b  ,0x00}, 
+       {0x5c  ,0x00}, 
+       {0x5d  ,0x00}, 
+       {0x5e  ,0x00}, 
+       {0x5f  ,0x00}, 
+       
+       
+       //============================= ccP 
+       
+       {0x69  ,0x03}, //cc_mode
+                 
+       //CC_G
+       {0x70  ,0x5d}, 
+       {0x71  ,0xed}, 
+       {0x72  ,0xff}, 
+       {0x73  ,0xe5}, 
+       {0x74  ,0x5f}, 
+       {0x75  ,0xe6}, 
+       
+      //CC_B
+       {0x76  ,0x41}, 
+       {0x77  ,0xef}, 
+       {0x78  ,0xff}, 
+       {0x79  ,0xff}, 
+       {0x7a  ,0x5f}, 
+       {0x7b  ,0xfa},   
+       
+       
+       //============================= AGP
+       
+       {0x7e  ,0x00},  
+       {0x7f  ,0x20},  //x040
+       {0x80  ,0x48},  
+       {0x81  ,0x06},  
+       {0x82  ,0x08},  
+       
+       {0x83  ,0x23},  
+       {0x84  ,0x38},  
+       {0x85  ,0x4F},  
+       {0x86  ,0x61},  
+       {0x87  ,0x72},  
+       {0x88  ,0x80},  
+       {0x89  ,0x8D},  
+       {0x8a  ,0xA2},  
+       {0x8b  ,0xB2},  
+       {0x8c  ,0xC0},  
+       {0x8d  ,0xCA},  
+       {0x8e  ,0xD3},  
+       {0x8f  ,0xDB},  
+       {0x90  ,0xE2},  
+       {0x91  ,0xED},  
+       {0x92  ,0xF6},  
+       {0x93  ,0xFD},  
+       
+       //about gamma1 is hex r oct
+       {0x94  ,0x04},  
+       {0x95  ,0x0E},  
+       {0x96  ,0x1B},  
+       {0x97  ,0x28},  
+       {0x98  ,0x35},  
+       {0x99  ,0x41},  
+       {0x9a  ,0x4E},  
+       {0x9b  ,0x67},  
+       {0x9c  ,0x7E},  
+       {0x9d  ,0x94},  
+       {0x9e  ,0xA7},  
+       {0x9f  ,0xBA},  
+       {0xa0  ,0xC8},  
+       {0xa1  ,0xD4},  
+       {0xa2  ,0xE7},  
+       {0xa3  ,0xF4},  
+       {0xa4  ,0xFA}, 
+       
+       //========= open functions      
+       {0xf0  ,0x00}, //set back to page0      
+       {0x40  ,0x7e}, 
+       {0x41  ,0x2F},
+
+/////  Çë×¢Ò⣬µ÷ÕûGC0307µÄ¾µÏñºÍ·­×ª£¬ÐèҪͬʱÐÞ¸ÄÈý¸ö¼Ä´æÆ÷£¬ÈçÏÂ:
+
+       {0x0f, 0x92},
+       {0x45, 0x25},
+       {0x47, 0x24},   
+///banding setting   
+        {  0x01  ,0xfa}, // 24M  
+        {  0x02  ,0x70}, 
+        {  0x10  ,0x01},   
+        {  0xd6  ,0x64}, 
+        {  0x28  ,0x02}, 
+        {  0x29  ,0x58}, 
+        {  0x2a  ,0x02}, 
+        {  0x2b  ,0x58}, 
+        {  0x2c  ,0x02}, 
+        {  0x2d  ,0x58}, 
+        {  0x2e  ,0x06}, 
+        {  0x2f  ,0x40}, 
+       
+       /************
+       {0x0f, 0x02},//82
+       {0x45, 0x24},
+       {0x47, 0x20},   
+       **************/
+/////  ËÄÖÖ²»Í¬µÄ·­×ªºÍ¾µÏñÉ趨£¬¿Í»§¿ÉÖ±½Ó¸´ÖÆ!!!!!!
+
+
+#if 0
+//  IMAGE_NORMAL:
+       {0x0f, 0xb2},
+       {0x45, 0x27},
+       {0x47, 0x2c},                   
+
+// IMAGE_H_MIRROR:
+       {0x0f, 0xa2},
+       {0x45, 0x26},
+       {0x47, 0x28},   
+       
+// IMAGE_V_MIRROR:                     
+       {0x0f, 0x92},
+       {0x45, 0x25},
+       {0x47, 0x24},                   
+
+// IMAGE_HV_MIRROR:       // 180
+       {0x0f, 0x82},
+       {0x45, 0x24},
+       {0x47, 0x20},           
+#endif
+{0x43, 0x40},
+       {0x44, 0xe2},   
+{0xff, 0xff},
+};
+
+static struct reginfo sensor_720p[]=
+{
+       {0xff, 0xff},
+};
+
+/* 1280X1024 SXGA */
+static struct reginfo sensor_sxga[] =
+{
+       {0xff, 0xff},
+
+};
+
+/* 800X600 SVGA*/
+static struct reginfo sensor_svga[] =
+{
+       {0xff, 0xff},
+
+};
+
+/* 640X480 VGA */
+
+static struct reginfo sensor_vga[] =
+{
+#if 1
+{      0x05 ,  0x00},
+{      0x06 ,  0x00},
+{      0x07 ,  0x00},
+{      0x08 ,  0x00},//0x10  james 20100715
+{      0x09 ,  0x01},
+{      0x0a ,  0xe8},
+{      0x0b ,  0x02},
+{      0x0c ,  0x88},//0x80   james 20100715
+{      0x45 ,  0x24},          // bit[7:2]=001001
+{      0x48 ,  0x84},          // bit[7]=1
+{      0xe0 ,  0x03},
+{      0xe1 ,  0x02},
+{      0xe2 ,  0x27},
+{      0xe3 ,  0x1e},
+{      0xe8 ,  0x3b},
+{      0xe9 ,  0x6e},
+{      0xea ,  0x2c},
+{      0xeb ,  0x50},
+{      0xec ,  0x73},
+#else
+{0x17, 0x13},
+{0x18, 0x01},
+{0x32, 0xbf},
+{0x19, 0x03},
+{0x1a, 0x7b},
+{0x03, 0x0a},
+
+#endif
+       {0xff, 0xff},
+
+
+};
+
+/* 352X288 CIF */
+static struct reginfo sensor_cif[] =
+{
+       {0xff, 0xff},
+
+};
+
+/* 320*240 QVGA */
+static  struct reginfo sensor_qvga[] =
+{
+       {0xff, 0xff},
+
+};
+
+/* 176X144 QCIF*/
+static struct reginfo sensor_qcif[] =
+{
+       {0xff, 0xff},
+
+};
+
+static  struct reginfo sensor_ClrFmt_YUYV[]=
+{
+       {0xff, 0xff},
+
+};
+
+static  struct reginfo sensor_ClrFmt_UYVY[]=
+{
+       {0xff, 0xff},
+
+};
+
+#if CONFIG_SENSOR_WhiteBalance
+static  struct reginfo sensor_WhiteB_Auto[]=
+{
+       {0xc7,0x4c}, //for AWB can adjust back
+       {0xc8,0x40},
+       {0xc9,0x4a},                    
+       {0x41,0x2f},
+       {0xff, 0xff},
+
+
+
+};
+/* Cloudy Colour Temperature : 6500K - 8000K  */
+static  struct reginfo sensor_WhiteB_Cloudy[]=
+{
+               {0x41,0x2b},   // Enable AWB 
+               {0xc7,0x5a}, //WB_manual_gain
+               {0xc8,0x42},
+               {0xc9,0x40},
+               {0xff, 0xff},
+
+
+};
+/* ClearDay Colour Temperature : 5000K - 6500K  */
+static  struct reginfo sensor_WhiteB_ClearDay[]=
+{
+    //Sunny
+               {0x41,0x2b},   // Enable AWB 
+               {0xc7,0x50},
+               {0xc8,0x45},
+               {0xc9,0x40},
+               {0xff, 0xff},
+
+
+};
+/* Office Colour Temperature : 3500K - 5000K  */
+static  struct reginfo sensor_WhiteB_TungstenLamp1[]=
+{
+    //Office
+               {0x41,0x2b},   // Enable AWB 
+               {0xc7,0x48},
+               {0xc8,0x40},
+               {0xc9,0x5c},
+               {0xff, 0xff},
+
+
+
+
+};
+/* Home Colour Temperature : 2500K - 3500K  */
+static  struct reginfo sensor_WhiteB_TungstenLamp2[]=
+{
+    //Home
+               {0x41,0x2b},   // Enable AWB 
+               {0xc7,0x40},
+               {0xc8,0x42},
+               {0xc9,0x50},
+               {0xff, 0xff},
+
+
+};
+static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
+    sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
+};
+#endif
+
+#if CONFIG_SENSOR_Brightness
+static  struct reginfo sensor_Brightness0[]=
+{
+    // Brightness -2
+    {0x7a, 0xe0},
+           {0xff, 0xff},
+
+};
+
+static  struct reginfo sensor_Brightness1[]=
+{
+    // Brightness -1
+    {0x7a, 0xf0},
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Brightness2[]=
+{
+    //  Brightness 0
+    {0x7a, 0x00},
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Brightness3[]=
+{
+    // Brightness +1
+    {0x7a, 0x10},
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Brightness4[]=
+{
+    //  Brightness +2
+    {0x7a, 0x20},
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Brightness5[]=
+{
+    //  Brightness +3
+    {0x7a, 0x30},
+    {0xff, 0xff},
+};
+static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
+    sensor_Brightness4, sensor_Brightness5,NULL,
+};
+
+#endif
+
+#if CONFIG_SENSOR_Effect
+static  struct reginfo sensor_Effect_Normal[] =
+{
+                     {0x41,0x2f},                      //  1
+                       {0x40,0x7e},
+                       {0x42,0x10},
+                       {0x47,0x24},//20
+                       {0x48,0xc3},
+                       {0x8a,0x50},//60
+                       {0x8b,0x50},
+                       {0x8c,0x07},
+                       {0x50,0x0c},
+                       {0x77,0x80},
+                       {0xa1,0x40},
+                       {0x7a,0x00},
+                       {0x78,0x00},
+                       {0x79,0x00},
+                       {0x7b,0x40},
+                       {0x7c,0x00},
+                       {0xff, 0xff},
+
+};
+
+static  struct reginfo sensor_Effect_WandB[] =
+{
+                      {0x41,0x2f},             // danse        
+                       {0x40,0x7e},
+                       {0x42,0x10},
+                       {0x47,0x3c},
+                       {0x48,0xc3},
+                       {0x8a,0x60},
+                       {0x8b,0x60},
+                       {0x8c,0x07},
+                       {0x50,0x0c},
+                       {0x77,0x80},
+                       {0xa1,0x40},
+                       {0x7a,0x00},
+                       {0x78,0x00},
+                       {0x79,0x00},
+                       {0x7b,0x40},
+                       {0x7c,0x00},    
+                      {0xff,0xff},
+};
+
+static  struct reginfo sensor_Effect_Sepia[] =
+{
+               {0x41,0x2f},                    
+                       {0x40,0x7e},
+                       {0x42,0x10},
+                       {0x47,0x3c},
+                       {0x48,0xc3},
+                       {0x8a,0x60},
+                       {0x8b,0x60},
+                       {0x8c,0x07},
+                       {0x50,0x0c},
+                       {0x77,0x80},
+                       {0xa1,0x40},
+                       {0x7a,0x00},
+                       {0x78,0xc0},
+                       {0x79,0x20},
+                       {0x7b,0x40},
+                       {0x7c,0x00},
+               {0xff,0xff},
+       
+  
+
+};
+
+static  struct reginfo sensor_Effect_Negative[] =
+{
+    //Negative
+         {0x41,0x6f},                  // 4
+                       {0x40,0x7e},
+                       {0x42,0x10},
+                       {0x47,0x20},
+                       {0x48,0xc3},
+                       {0x8a,0x60},
+                       {0x8b,0x60},
+                       {0x8c,0x07},
+                       {0x50,0x0c},
+                       {0x77,0x80},
+                       {0xa1,0x40},
+                       {0x7a,0x00},
+                       {0x78,0x00},
+                       {0x79,0x00},
+                       {0x7b,0x40},
+                       {0x7c,0x00},
+                           {0xff, 0xff},
+
+};
+static  struct reginfo sensor_Effect_Bluish[] =
+{
+    // Bluish
+                     {0x41,0x2f},              // 5
+                       {0x40,0x7e},
+                       {0x42,0x10},
+                       {0x47,0x2c},
+                       {0x48,0xc3},
+                       {0x8a,0x60},
+                       {0x8b,0x60},
+                       {0x8c,0x07},
+                       {0x50,0x0c},
+                       {0x77,0x80},
+                       {0xa1,0x40},
+                       {0x7a,0x00},
+                       {0x78,0x70},
+                       {0x79,0x00},
+                       {0x7b,0x3f},
+                       {0x7c,0xf5},
+                           {0xff, 0xff},
+
+};
+
+static  struct reginfo sensor_Effect_Green[] =
+{
+    //  Greenish   6
+               {0x41,0x2f},                    
+                       {0x40,0x7e},
+                       {0x42,0x10},
+                       {0x47,0x3c},
+                       {0x48,0xc3},
+                       {0x8a,0x60},
+                       {0x8b,0x60},
+                       {0x8c,0x07},
+                       {0x50,0x0c},
+                       {0x77,0x80},
+                       {0xa1,0x40},
+                       {0x7a,0x00},
+                       {0x78,0xc0},
+                       {0x79,0xc0},
+                       {0x7b,0x40},
+                       {0x7c,0x00},
+               {0xff,0xff},
+
+};
+static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
+    sensor_Effect_Bluish, sensor_Effect_Green,NULL,
+};
+#endif
+#if CONFIG_SENSOR_Exposure
+static  struct reginfo sensor_Exposure0[]=
+{
+       {0xd1, 0x38},
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Exposure1[]=
+{
+       {0xd1, 0x40},
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Exposure2[]=
+{
+       {0xd1, 0x48},
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Exposure3[]=
+{
+       {0xd1, 0x50},
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Exposure4[]=
+{
+       {0xd1, 0x58},
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Exposure5[]=
+{
+       {0xd1, 0x60},
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Exposure6[]=
+{
+       {0xd1, 0x68},
+    {0xff, 0xff},
+};
+
+static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
+    sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
+};
+#endif
+#if CONFIG_SENSOR_Saturation
+static  struct reginfo sensor_Saturation0[]=
+{
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Saturation1[]=
+{
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Saturation2[]=
+{
+    {0xff, 0xff},
+};
+static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
+
+#endif
+#if CONFIG_SENSOR_Contrast
+static  struct reginfo sensor_Contrast0[]=
+{
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Contrast1[]=
+{
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Contrast2[]=
+{
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Contrast3[]=
+{
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Contrast4[]=
+{
+    {0xff, 0xff},
+};
+
+
+static  struct reginfo sensor_Contrast5[]=
+{
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_Contrast6[]=
+{
+    {0xff, 0xff},
+};
+static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
+    sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
+};
+
+#endif
+#if CONFIG_SENSOR_Mirror
+static  struct reginfo sensor_MirrorOn[]=
+{
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_MirrorOff[]=
+{
+    {0xff, 0xff},
+};
+static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
+#endif
+#if CONFIG_SENSOR_Flip
+static  struct reginfo sensor_FlipOn[]=
+{
+    {0xff, 0xff},
+};
+
+static  struct reginfo sensor_FlipOff[]=
+{
+    {0xff, 0xff},
+};
+static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
+
+#endif
+#if CONFIG_SENSOR_Scene
+static  struct reginfo sensor_SceneAuto[] =
+{
+       {       0xdd  ,0x22},  //0x12
+               {       0x41  ,0x2f}, 
+               {       0x21  ,0xc0},
+               {       0xd2  ,0x02},
+       {0xff, 0xff},
+};
+
+static  struct reginfo sensor_SceneNight[] =
+{
+       {       0xdd  ,0x32},
+               {       0x41  ,0x0f},
+               {       0xb0  ,0x10},
+               {       0x21  ,0xf0},
+
+       {0xff, 0xff},
+};
+static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
+
+#endif
+#if CONFIG_SENSOR_DigitalZoom
+static struct reginfo sensor_Zoom0[] =
+{
+       {0xff, 0xff},
+
+};
+
+static struct reginfo sensor_Zoom1[] =
+{
+       {0xff, 0xff},
+
+};
+
+static struct reginfo sensor_Zoom2[] =
+{
+       {0xff, 0xff},
+
+};
+
+
+static struct reginfo sensor_Zoom3[] =
+{
+       {0xff, 0xff},
+
+};
+static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};
+#endif
+static const struct v4l2_querymenu sensor_menus[] =
+{
+       #if CONFIG_SENSOR_WhiteBalance
+    { .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 0,  .name = "auto",  .reserved = 0, }, {  .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 1, .name = "incandescent",  .reserved = 0,},
+    { .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 2,  .name = "fluorescent", .reserved = 0,}, {  .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3,  .name = "daylight", .reserved = 0,},
+    { .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 4,  .name = "cloudy-daylight", .reserved = 0,},
+    #endif
+
+       #if CONFIG_SENSOR_Effect
+    { .id = V4L2_CID_EFFECT,  .index = 0,  .name = "none",  .reserved = 0, }, {  .id = V4L2_CID_EFFECT,  .index = 1, .name = "mono",  .reserved = 0,},
+    { .id = V4L2_CID_EFFECT,  .index = 2,  .name = "negative", .reserved = 0,}, {  .id = V4L2_CID_EFFECT, .index = 3,  .name = "sepia", .reserved = 0,},
+    { .id = V4L2_CID_EFFECT,  .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT,  .index = 5,  .name = "aqua", .reserved = 0,},
+    #endif
+
+       #if CONFIG_SENSOR_Scene
+    { .id = V4L2_CID_SCENE,  .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE,  .index = 1,  .name = "night", .reserved = 0,},
+    #endif
+
+       #if CONFIG_SENSOR_Flash
+    { .id = V4L2_CID_FLASH,  .index = 0,  .name = "off",  .reserved = 0, }, {  .id = V4L2_CID_FLASH,  .index = 1, .name = "auto",  .reserved = 0,},
+    { .id = V4L2_CID_FLASH,  .index = 2,  .name = "on", .reserved = 0,}, {  .id = V4L2_CID_FLASH, .index = 3,  .name = "torch", .reserved = 0,},
+    #endif
+};
+
+static const struct v4l2_queryctrl sensor_controls[] =
+{
+       #if CONFIG_SENSOR_WhiteBalance
+    {
+        .id            = V4L2_CID_DO_WHITE_BALANCE,
+        .type          = V4L2_CTRL_TYPE_MENU,
+        .name          = "White Balance Control",
+        .minimum       = 0,
+        .maximum       = 4,
+        .step          = 1,
+        .default_value = 0,
+    },
+    #endif
+
+       #if CONFIG_SENSOR_Brightness
+       {
+        .id            = V4L2_CID_BRIGHTNESS,
+        .type          = V4L2_CTRL_TYPE_INTEGER,
+        .name          = "Brightness Control",
+        .minimum       = -3,
+        .maximum       = 2,
+        .step          = 1,
+        .default_value = 0,
+    },
+    #endif
+
+       #if CONFIG_SENSOR_Effect
+       {
+        .id            = V4L2_CID_EFFECT,
+        .type          = V4L2_CTRL_TYPE_MENU,
+        .name          = "Effect Control",
+        .minimum       = 0,
+        .maximum       = 5,
+        .step          = 1,
+        .default_value = 0,
+    },
+       #endif
+
+       #if CONFIG_SENSOR_Exposure
+       {
+        .id            = V4L2_CID_EXPOSURE,
+        .type          = V4L2_CTRL_TYPE_INTEGER,
+        .name          = "Exposure Control",
+        .minimum       = 0,
+        .maximum       = 6,
+        .step          = 1,
+        .default_value = 0,
+    },
+       #endif
+
+       #if CONFIG_SENSOR_Saturation
+       {
+        .id            = V4L2_CID_SATURATION,
+        .type          = V4L2_CTRL_TYPE_INTEGER,
+        .name          = "Saturation Control",
+        .minimum       = 0,
+        .maximum       = 2,
+        .step          = 1,
+        .default_value = 0,
+    },
+    #endif
+
+       #if CONFIG_SENSOR_Contrast
+       {
+        .id            = V4L2_CID_CONTRAST,
+        .type          = V4L2_CTRL_TYPE_INTEGER,
+        .name          = "Contrast Control",
+        .minimum       = -3,
+        .maximum       = 3,
+        .step          = 1,
+        .default_value = 0,
+    },
+       #endif
+
+       #if CONFIG_SENSOR_Mirror
+       {
+        .id            = V4L2_CID_HFLIP,
+        .type          = V4L2_CTRL_TYPE_BOOLEAN,
+        .name          = "Mirror Control",
+        .minimum       = 0,
+        .maximum       = 1,
+        .step          = 1,
+        .default_value = 0,
+    },
+    #endif
+
+       #if CONFIG_SENSOR_Flip
+       {
+        .id            = V4L2_CID_VFLIP,
+        .type          = V4L2_CTRL_TYPE_BOOLEAN,
+        .name          = "Flip Control",
+        .minimum       = 0,
+        .maximum       = 1,
+        .step          = 1,
+        .default_value = 0,
+    },
+    #endif
+
+       #if CONFIG_SENSOR_Scene
+    {
+        .id            = V4L2_CID_SCENE,
+        .type          = V4L2_CTRL_TYPE_MENU,
+        .name          = "Scene Control",
+        .minimum       = 0,
+        .maximum       = 1,
+        .step          = 1,
+        .default_value = 0,
+    },
+    #endif
+
+       #if CONFIG_SENSOR_DigitalZoom
+    {
+        .id            = V4L2_CID_ZOOM_RELATIVE,
+        .type          = V4L2_CTRL_TYPE_INTEGER,
+        .name          = "DigitalZoom Control",
+        .minimum       = -1,
+        .maximum       = 1,
+        .step          = 1,
+        .default_value = 0,
+    }, {
+        .id            = V4L2_CID_ZOOM_ABSOLUTE,
+        .type          = V4L2_CTRL_TYPE_INTEGER,
+        .name          = "DigitalZoom Control",
+        .minimum       = 0,
+        .maximum       = 3,
+        .step          = 1,
+        .default_value = 0,
+    },
+    #endif
+
+       #if CONFIG_SENSOR_Focus
+       {
+        .id            = V4L2_CID_FOCUS_RELATIVE,
+        .type          = V4L2_CTRL_TYPE_INTEGER,
+        .name          = "Focus Control",
+        .minimum       = -1,
+        .maximum       = 1,
+        .step          = 1,
+        .default_value = 0,
+    }, {
+        .id            = V4L2_CID_FOCUS_ABSOLUTE,
+        .type          = V4L2_CTRL_TYPE_INTEGER,
+        .name          = "Focus Control",
+        .minimum       = 0,
+        .maximum       = 255,
+        .step          = 1,
+        .default_value = 125,
+    },
+    #endif
+
+       #if CONFIG_SENSOR_Flash
+       {
+        .id            = V4L2_CID_FLASH,
+        .type          = V4L2_CTRL_TYPE_MENU,
+        .name          = "Flash Control",
+        .minimum       = 0,
+        .maximum       = 3,
+        .step          = 1,
+        .default_value = 0,
+    },
+       #endif
+};
+
+static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);
+static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
+static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
+static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
+static int sensor_g_ext_controls(struct v4l2_subdev *sd,  struct v4l2_ext_controls *ext_ctrl);
+static int sensor_s_ext_controls(struct v4l2_subdev *sd,  struct v4l2_ext_controls *ext_ctrl);
+static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
+static int sensor_resume(struct soc_camera_device *icd);
+static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
+static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
+static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
+static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
+static int sensor_deactivate(struct i2c_client *client);
+
+static struct soc_camera_ops sensor_ops =
+{
+    .suspend                     = sensor_suspend,
+    .resume                       = sensor_resume,
+    .set_bus_param             = sensor_set_bus_param,
+    .query_bus_param   = sensor_query_bus_param,
+    .controls          = sensor_controls,
+    .menus                         = sensor_menus,
+    .num_controls              = ARRAY_SIZE(sensor_controls),
+    .num_menus         = ARRAY_SIZE(sensor_menus),
+};
+
+#define COL_FMT(_name, _depth, _fourcc, _colorspace) \
+       { .name = _name, .depth = _depth, .fourcc = _fourcc, \
+       .colorspace = _colorspace }
+
+#define JPG_FMT(_name, _depth, _fourcc) \
+       COL_FMT(_name, _depth, _fourcc, V4L2_COLORSPACE_JPEG)
+
+static const struct soc_camera_data_format sensor_colour_formats[] = {
+       JPG_FMT(SENSOR_NAME_STRING(YUYV), 16, V4L2_PIX_FMT_YUYV),
+       //JPG_FMT(SENSOR_NAME_STRING(UYVY), 16, V4L2_PIX_FMT_UYVY),
+};
+
+typedef struct sensor_info_priv_s
+{
+    int whiteBalance;
+    int brightness;
+    int contrast;
+    int saturation;
+    int effect;
+    int scene;
+    int digitalzoom;
+    int focus;
+    int flash;
+    int exposure;
+       bool snap2preview;
+       bool video2preview;
+    unsigned char mirror;                                        /* HFLIP */
+    unsigned char flip;                                          /* VFLIP */
+    unsigned int winseqe_cur_addr;
+       unsigned int pixfmt;
+    unsigned int funmodule_state;
+} sensor_info_priv_t;
+
+struct sensor
+{
+    struct v4l2_subdev subdev;
+    struct i2c_client *client;
+    sensor_info_priv_t info_priv;
+    int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
+#if CONFIG_SENSOR_I2C_NOSCHED
+       atomic_t tasklock_cnt;
+#endif
+       struct rk29camera_platform_data *sensor_io_request;
+    struct rk29camera_gpio_res *sensor_gpio_res;
+};
+
+static struct sensor* to_sensor(const struct i2c_client *client)
+{
+    return container_of(i2c_get_clientdata(client), struct sensor, subdev);
+}
+
+static int sensor_task_lock(struct i2c_client *client, int lock)
+{
+#if CONFIG_SENSOR_I2C_NOSCHED
+       int cnt = 3;
+    struct sensor *sensor = to_sensor(client);
+
+       if (lock) {
+               if (atomic_read(&sensor->tasklock_cnt) == 0) {
+                       while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {
+                               SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());
+                               msleep(35);
+                               cnt--;
+                       }
+                       if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {
+                               SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());
+                               goto sensor_task_lock_err;
+                       }
+                       preempt_disable();
+               }
+
+               atomic_add(1, &sensor->tasklock_cnt);
+       } else {
+               if (atomic_read(&sensor->tasklock_cnt) > 0) {
+                       atomic_sub(1, &sensor->tasklock_cnt);
+
+                       if (atomic_read(&sensor->tasklock_cnt) == 0)
+                               preempt_enable();
+               }
+       }
+       return 0;
+sensor_task_lock_err:
+       return -1;  
+#else
+    return 0;
+#endif
+
+}
+
+static int sensor_read(struct i2c_client *client, u8 reg, u8 *val);
+
+/* sensor register write */
+static int sensor_write_internal(struct i2c_client *client, u8 reg, u8 val)
+{
+    int err,cnt;
+    u8 buf[2];
+    struct i2c_msg msg[1];
+    
+    buf[0] = reg & 0xFF;
+    buf[1] = val;
+
+    msg->addr = client->addr;
+    msg->flags = client->flags;
+    msg->buf = buf;
+    msg->len = sizeof(buf);
+    msg->scl_rate = CONFIG_SENSOR_I2C_SPEED;                                        /* ddl@rock-chips.com : 100kHz */
+    msg->read_type = 0;               /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */
+
+    cnt = 3;
+    err = -EAGAIN;
+
+    while ((cnt-- > 0) && (err < 0)) {                       /* ddl@rock-chips.com :  Transfer again if transent is failed   */
+        err = i2c_transfer(client->adapter, msg, 1);
+
+        if (err >= 0) {
+            return 0;
+        } else {
+               SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg, val);
+            udelay(10);
+        }
+    }
+
+
+    return err;
+}
+
+static int sensor_write(struct i2c_client *client, u8 reg, u8 val)
+{
+#if 1
+       int ret, cnt;
+       for(cnt=0; cnt<1; cnt++)
+       {
+               mdelay(1);
+               ret=sensor_write_internal(client, reg, val);
+       }
+       return ret;
+#else
+       u8 val_tmp;
+
+       do
+       {
+               printk("sensor_write() : reg %02x 0x%02x\n", reg, val);
+               sensor_write_internal(client, reg, val);
+               mdelay(1);
+               sensor_read(client, reg, &val_tmp);
+               if(val_tmp != val)                      
+               {
+                       printk("sensor_write() error: reg %02x 0x%02x != 0x%02x \n", reg, val, val_tmp);
+               }
+               mdelay(1);
+       }
+       while(val_tmp != val);
+       return 0;
+#endif 
+}
+
+/* sensor register read */
+static int sensor_read(struct i2c_client *client, u8 reg, u8 *val)
+{
+    int err,cnt;
+    //u8 buf[2];
+    u8 buf[1];
+    struct i2c_msg msg[2];
+
+    //buf[0] = reg >> 8;
+    buf[0] = reg;
+//    buf[1] = reg & 0xFF;
+
+    msg[0].addr = client->addr;
+    msg[0].flags = client->flags;
+    msg[0].buf = buf;
+    msg[0].len = sizeof(buf);
+    msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED;       /* ddl@rock-chips.com : 100kHz */
+    msg[0].read_type = 2;   /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
+
+    msg[1].addr = client->addr;
+    msg[1].flags = client->flags|I2C_M_RD;
+    msg[1].buf = buf;
+    msg[1].len = 1;
+    msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED;                       /* ddl@rock-chips.com : 100kHz */
+    msg[1].read_type = 2;                             /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */
+
+    cnt = 1;
+    err = -EAGAIN;
+    while ((cnt-- > 0) && (err < 0)) {                       /* ddl@rock-chips.com :  Transfer again if transent is failed   */
+        err = i2c_transfer(client->adapter, msg, 2);
+
+        if (err >= 0) {
+            *val = buf[0];
+            return 0;
+        } else {
+               SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);
+            udelay(10);
+        }
+    }
+
+    return err;
+}
+
+/* write a array of registers  */
+#if 1
+static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
+{
+    int err;
+    int i = 0;
+
+    for(i=0; regarray[i].reg!=0xff;i++)
+    {
+        err = sensor_write(client, regarray[i].reg, regarray[i].val);
+        if (err != 0)
+        {
+            SENSOR_TR("%s..write failed current i = %d\n", SENSOR_NAME_STRING(),i);
+            return err;
+        }
+    }
+    return 0;
+}
+#else
+static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
+{
+    int err;
+    int i = 0;
+       u8 val_read;
+    while (regarray[i].reg != 0)
+    {
+        err = sensor_write(client, regarray[i].reg, regarray[i].val);
+        if (err != 0)
+        {
+            SENSOR_TR("%s..write failed current i = %d\n", SENSOR_NAME_STRING(),i);
+            return err;
+        }
+               err = sensor_read(client, regarray[i].reg, &val_read);
+               SENSOR_TR("%s..reg[0x%x]=0x%x,0x%x\n", SENSOR_NAME_STRING(),regarray[i].reg, val_read, regarray[i].val);
+        i++;
+    }
+    return 0;
+}
+#endif
+
+
+static int sensor_check_array(struct i2c_client *client, struct reginfo *regarray)
+{
+  int ret;
+  int i = 0;
+  
+  u8 value;
+  
+  SENSOR_DG("%s >>>>>>>>>>>>>>>>>>>>>>\n",__FUNCTION__);
+  for(i=0;i<sizeof(sensor_init_data) / 2;i++)
+       {
+     ret = sensor_read(client,regarray[i].reg,&value);
+        if(ret !=0)
+        {
+         SENSOR_TR("read value failed\n");
+
+        }
+        if(regarray[i].val != value)
+        {
+         SENSOR_DG("%s reg[0x%x] check err,writte :0x%x  read:0x%x\n",__FUNCTION__,regarray[i].reg,regarray[i].val,value);
+        }
+        
+  }
+  
+       
+  return 0;
+}
+static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)
+{
+       struct soc_camera_link *icl = to_soc_camera_link(icd);
+       int ret = 0;
+
+    SENSOR_DG("%s %s  cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);
+       switch (cmd)
+       {
+               case Sensor_PowerDown:
+               {
+                       if (icl->powerdown) {
+                               ret = icl->powerdown(icd->pdev, on);
+                               if (ret == RK29_CAM_IO_SUCCESS) {
+                                       if (on == 0) {
+                                               mdelay(2);
+                                               if (icl->reset)
+                                                       icl->reset(icd->pdev);
+                                       }
+                               } else if (ret == RK29_CAM_EIO_REQUESTFAIL) {
+                                       ret = -ENODEV;
+                                       goto sensor_power_end;
+                               }
+                       }
+                       break;
+               }
+               case Sensor_Flash:
+               {
+                       struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+               struct sensor *sensor = to_sensor(client);
+
+                       if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
+                               sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                       }
+            break;
+               }
+               default:
+               {
+                       SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
+                       break;
+               }
+       }
+sensor_power_end:
+       return ret;
+}
+
+static int sensor_init(struct v4l2_subdev *sd, u32 val)
+{
+    struct i2c_client *client = sd->priv;
+    struct soc_camera_device *icd = client->dev.platform_data;
+    struct sensor *sensor = to_sensor(client);
+       const struct v4l2_queryctrl *qctrl;
+    int ret;
+
+
+    SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
+
+       if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
+               ret = -ENODEV;
+               goto sensor_INIT_ERR;
+       }
+
+    /* soft reset */
+       if (sensor_task_lock(client,1)<0)
+               goto sensor_INIT_ERR;
+   /* ret = sensor_write(client, 0x12, 0x80);
+    if (ret != 0)
+    {
+        SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
+        ret = -ENODEV;
+               goto sensor_INIT_ERR;
+    }
+
+    mdelay(5); */ //delay 5 microseconds
+
+    ret = sensor_write_array(client, sensor_init_data);
+    if (ret != 0)
+    {
+        SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
+        goto sensor_INIT_ERR;
+    }
+#if 0
+{
+       int i;
+       u8 val;
+       printk("****************** check init data\n");
+       for(i=0; sensor_init_data[i].reg!=0xff; i++)
+       {
+               sensor_read(client, sensor_init_data[i].reg, &val);
+               printk("reg 0x%02x: org=0x%02x, val=0x%02x, %s\n", 
+                       sensor_init_data[i].reg,
+                       sensor_init_data[i].val,
+                       val,
+                       sensor_init_data[i].val==val?"O":"X");
+       }
+       printk("**********************************\n");
+
+}
+#endif
+       sensor_task_lock(client,0);
+    //icd->user_width = SENSOR_INIT_WIDTH;
+    //icd->user_height = SENSOR_INIT_HEIGHT;
+    sensor->info_priv.winseqe_cur_addr  = (int)SENSOR_INIT_WINSEQADR;
+       sensor->info_priv.pixfmt = SENSOR_INIT_PIXFMT;
+
+    /* sensor sensor information for initialization  */
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
+       if (qctrl)
+       sensor->info_priv.whiteBalance = qctrl->default_value;
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);
+       if (qctrl)
+       sensor->info_priv.brightness = qctrl->default_value;
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
+       if (qctrl)
+       sensor->info_priv.effect = qctrl->default_value;
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);
+       if (qctrl)
+        sensor->info_priv.exposure = qctrl->default_value;
+
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);
+       if (qctrl)
+        sensor->info_priv.saturation = qctrl->default_value;
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);
+       if (qctrl)
+        sensor->info_priv.contrast = qctrl->default_value;
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);
+       if (qctrl)
+        sensor->info_priv.mirror = qctrl->default_value;
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);
+       if (qctrl)
+        sensor->info_priv.flip = qctrl->default_value;
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);
+       if (qctrl)
+        sensor->info_priv.scene = qctrl->default_value;
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
+       if (qctrl)
+        sensor->info_priv.digitalzoom = qctrl->default_value;
+
+    /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code  */
+       #if CONFIG_SENSOR_Focus
+    sensor_set_focus();
+    qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
+       if (qctrl)
+        sensor->info_priv.focus = qctrl->default_value;
+       #endif
+
+       #if CONFIG_SENSOR_Flash
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
+       if (qctrl)
+        sensor->info_priv.flash = qctrl->default_value;
+    #endif
+
+    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);
+    sensor->info_priv.funmodule_state |= SENSOR_INIT_IS_OK;
+    return 0;
+sensor_INIT_ERR:
+    sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
+       sensor_task_lock(client,0);
+       sensor_deactivate(client);
+    return ret;
+}
+
+static int sensor_deactivate(struct i2c_client *client)
+{
+       struct soc_camera_device *icd = client->dev.platform_data;
+       //u8 reg_val;
+    struct sensor *sensor = to_sensor(client);
+       SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);
+
+       /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
+    if (sensor->info_priv.funmodule_state & SENSOR_INIT_IS_OK) {
+       sensor_task_lock(client, 1);
+       sensor_task_lock(client, 0);        
+    }
+       sensor_ioctrl(icd, Sensor_PowerDown, 1);
+    msleep(100); 
+
+       /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */
+       icd->user_width = SENSOR_INIT_WIDTH;
+    icd->user_height = SENSOR_INIT_HEIGHT;
+    sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;
+       
+       return 0;
+}
+static  struct reginfo sensor_power_down_sequence[]=
+{
+    {0xff, 0xff},
+};
+static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
+{
+    int ret;
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+
+    if (pm_msg.event == PM_EVENT_SUSPEND) {
+        SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());
+        ret = sensor_write_array(client, sensor_power_down_sequence) ;
+        if (ret != 0) {
+            SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
+            return ret;
+        } else {
+            ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);
+                if (ret < 0) {
+                                   SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());
+                    return -EINVAL;
+                }
+            }
+    } else {
+        SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
+        return -EINVAL;
+    }
+    return 0;
+}
+
+static int sensor_resume(struct soc_camera_device *icd)
+{
+       int ret;
+
+    ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);
+        if (ret < 0) {
+                       SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());
+            return -EINVAL;
+        }
+
+       SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());
+
+    return 0;
+
+}
+
+static int sensor_set_bus_param(struct soc_camera_device *icd,
+                                unsigned long flags)
+{
+
+    return 0;
+}
+
+static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
+{
+    struct soc_camera_link *icl = to_soc_camera_link(icd);
+    unsigned long flags = SENSOR_BUS_PARAM;
+
+    return soc_camera_apply_sensor_flags(icl, flags);
+}
+
+static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+{
+    struct i2c_client *client = sd->priv;
+    struct soc_camera_device *icd = client->dev.platform_data;
+    struct sensor *sensor = to_sensor(client);
+    struct v4l2_pix_format *pix = &f->fmt.pix;
+
+    pix->width         = icd->user_width;
+    pix->height                = icd->user_height;
+    pix->pixelformat   = sensor->info_priv.pixfmt;
+    pix->field         = V4L2_FIELD_NONE;
+    pix->colorspace            = V4L2_COLORSPACE_JPEG;
+
+    return 0;
+}
+static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_format *f)
+{
+    bool ret = false;
+
+       if ((f->fmt.pix.width == 1024) && (f->fmt.pix.height == 768)) {
+               ret = true;
+       } else if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 720)) {
+               ret = true;
+       } else if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 1024)) {
+               ret = true;
+       } else if ((f->fmt.pix.width == 1600) && (f->fmt.pix.height == 1200)) {
+               ret = true;
+       } else if ((f->fmt.pix.width == 2048) && (f->fmt.pix.height == 1536)) {
+               ret = true;
+       } else if ((f->fmt.pix.width == 2592) && (f->fmt.pix.height == 1944)) {
+               ret = true;
+       }
+
+       if (ret == true)
+               SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height);
+       return ret;
+}
+
+static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_format *f)
+{
+    bool ret = false;
+
+       if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 720)) {
+               ret = true;
+       } else if ((f->fmt.pix.width == 1920) && (f->fmt.pix.height == 1080)) {
+               ret = true;
+       }
+
+       if (ret == true)
+               SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height);
+       return ret;
+}
+
+static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+{
+    struct i2c_client *client = sd->priv;
+    struct sensor *sensor = to_sensor(client);
+    struct v4l2_pix_format *pix = &f->fmt.pix;
+    const struct v4l2_queryctrl *qctrl;
+    struct soc_camera_device *icd = client->dev.platform_data;
+    struct reginfo *winseqe_set_addr=NULL;
+    int ret=0, set_w,set_h;
+
+       if (sensor->info_priv.pixfmt != pix->pixelformat) {
+               switch (pix->pixelformat)
+               {
+                       case V4L2_PIX_FMT_YUYV:
+                       {
+                               winseqe_set_addr = sensor_ClrFmt_YUYV;
+                               break;
+                       }
+                       case V4L2_PIX_FMT_UYVY:
+                       {
+                               winseqe_set_addr = sensor_ClrFmt_UYVY;
+                               break;
+                       }
+                       default:
+                               break;
+               }
+               if (winseqe_set_addr != NULL) {
+            sensor_write_array(client, winseqe_set_addr);
+                       sensor->info_priv.pixfmt = pix->pixelformat;
+
+                       SENSOR_DG("%s Pixelformat(0x%x) set success!\n", SENSOR_NAME_STRING(),pix->pixelformat);
+               } else {
+                       SENSOR_TR("%s Pixelformat(0x%x) is invalidate!\n", SENSOR_NAME_STRING(),pix->pixelformat);
+               }
+       }
+
+    set_w = pix->width;
+    set_h = pix->height;
+
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg!=0xff)
+       {
+               winseqe_set_addr = sensor_qcif;
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg!=0xff)
+    {
+        winseqe_set_addr = sensor_qvga;
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg!=0xff)
+    {
+        winseqe_set_addr = sensor_cif;
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg!=0xff)
+    {
+        winseqe_set_addr = sensor_vga;
+        set_w = 640;
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg!=0xff)
+    {
+        winseqe_set_addr = sensor_svga;
+        set_w = 800;
+        set_h = 600;
+    }
+    else if (((set_w <= 1280) && (set_h <= 720)) && sensor_720p[0].reg!=0xff)
+    {
+        winseqe_set_addr = sensor_720p;
+        set_w = 1280;
+        set_h = 720;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg!=0xff)
+    {
+        winseqe_set_addr = sensor_sxga;
+        set_w = 1280;
+        set_h = 1024;
+    }
+    else
+    {
+        winseqe_set_addr = SENSOR_INIT_WINSEQADR;               /* ddl@rock-chips.com : Sensor output smallest size if  isn't support app  */
+        set_w = SENSOR_INIT_WIDTH;
+        set_h = SENSOR_INIT_HEIGHT;
+               SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,pix->width,pix->height);
+    }
+
+    if ((int)winseqe_set_addr  != sensor->info_priv.winseqe_cur_addr) {
+        #if CONFIG_SENSOR_Flash
+        if (sensor_fmt_capturechk(sd,f) == true) {      /* ddl@rock-chips.com : Capture */
+            if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
+                sensor_ioctrl(icd, Sensor_Flash, Flash_On);
+                SENSOR_DG("%s flash on in capture!\n", SENSOR_NAME_STRING());
+            }           
+        } else {                                        /* ddl@rock-chips.com : Video */
+            if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
+                sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
+                SENSOR_DG("%s flash off in preivew!\n", SENSOR_NAME_STRING());
+            }
+        }
+        #endif
+        ret |= sensor_write_array(client, winseqe_set_addr);
+        if (ret != 0) {
+            SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
+            #if CONFIG_SENSOR_Flash
+            if (sensor_fmt_capturechk(sd,f) == true) {
+                if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
+                    sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
+                    SENSOR_TR("%s Capture format set fail, flash off !\n", SENSOR_NAME_STRING());
+                }
+            }
+            #endif
+            goto sensor_s_fmt_end;
+        }
+
+        sensor->info_priv.winseqe_cur_addr  = (int)winseqe_set_addr;
+
+               if (sensor_fmt_capturechk(sd,f) == true) {                                  /* ddl@rock-chips.com : Capture */
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
+                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
+                       if (sensor->info_priv.whiteBalance != 0) {
+                               qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
+                               sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
+                       }
+                       sensor->info_priv.snap2preview = true;
+               } else if (sensor_fmt_videochk(sd,f) == true) {                 /* ddl@rock-chips.com : Video */
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
+                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
+                       sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
+                       sensor->info_priv.video2preview = true;
+               } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) {
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
+                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
+                       sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
+                       sensor->info_priv.video2preview = false;
+                       sensor->info_priv.snap2preview = false;
+               }
+
+        SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
+    }
+    else
+    {
+        SENSOR_DG("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);
+    }
+
+       pix->width = set_w;
+    pix->height = set_h;
+
+sensor_s_fmt_end:
+    return ret;
+}
+
+static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+{
+    struct v4l2_pix_format *pix = &f->fmt.pix;
+    bool bayer = pix->pixelformat == V4L2_PIX_FMT_UYVY ||
+        pix->pixelformat == V4L2_PIX_FMT_YUYV;
+
+    /*
+    * With Bayer format enforce even side lengths, but let the user play
+    * with the starting pixel
+    */
+
+    if (pix->height > SENSOR_MAX_HEIGHT)
+        pix->height = SENSOR_MAX_HEIGHT;
+    else if (pix->height < SENSOR_MIN_HEIGHT)
+        pix->height = SENSOR_MIN_HEIGHT;
+    else if (bayer)
+        pix->height = ALIGN(pix->height, 2);
+
+    if (pix->width > SENSOR_MAX_WIDTH)
+        pix->width = SENSOR_MAX_WIDTH;
+    else if (pix->width < SENSOR_MIN_WIDTH)
+        pix->width = SENSOR_MIN_WIDTH;
+    else if (bayer)
+        pix->width = ALIGN(pix->width, 2);
+
+    return 0;
+}
+
+ static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
+{
+    struct i2c_client *client = sd->priv;
+
+    if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
+        return -EINVAL;
+
+    if (id->match.addr != client->addr)
+        return -ENODEV;
+
+    id->ident = SENSOR_V4L2_IDENT;      /* ddl@rock-chips.com :  Return OV9650  identifier */
+    id->revision = 0;
+
+    return 0;
+}
+#if CONFIG_SENSOR_Brightness
+static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+{
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
+    {
+        if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)
+        {
+            if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)
+            {
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
+                return -EINVAL;
+            }
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
+            return 0;
+        }
+    }
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
+    return -EINVAL;
+}
+#endif
+#if CONFIG_SENSOR_Effect
+static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+{
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
+    {
+        if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)
+        {
+            if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)
+            {
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
+                return -EINVAL;
+            }
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
+            return 0;
+        }
+    }
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
+    return -EINVAL;
+}
+#endif
+#if CONFIG_SENSOR_Exposure
+static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+{
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
+    {
+        if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)
+        {
+            if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)
+            {
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
+                return -EINVAL;
+            }
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
+            return 0;
+        }
+    }
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
+    return -EINVAL;
+}
+#endif
+#if CONFIG_SENSOR_Saturation
+static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+{
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
+    {
+        if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)
+        {
+            if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)
+            {
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
+                return -EINVAL;
+            }
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
+            return 0;
+        }
+    }
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
+    return -EINVAL;
+}
+#endif
+#if CONFIG_SENSOR_Contrast
+static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+{
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
+    {
+        if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)
+        {
+            if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)
+            {
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
+                return -EINVAL;
+            }
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
+            return 0;
+        }
+    }
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
+    return -EINVAL;
+}
+#endif
+#if CONFIG_SENSOR_Mirror
+static int sensor_mirror(struct i2c_client *client, int on)
+{
+    int err = 0;    
+    return err;    
+}
+static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+{
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
+    {
+        if (sensor_mirror(client,value) != 0)
+            SENSOR_TR("%s(%d): sensor_mirror failed, value:0x%x",__FUNCTION__, __LINE__,value);
+        
+        SENSOR_DG("%s(%d): sensor_mirror success, value:0x%x",__FUNCTION__, __LINE__,value);
+        return 0;
+    }
+    SENSOR_TR("\n %s..%s value = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
+    return -EINVAL;
+}
+#endif
+#if CONFIG_SENSOR_Flip
+static int sensor_flip(struct i2c_client *client, int on)
+{
+    int err = 0;    
+    return err;    
+}
+static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+{
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
+    {
+        if (sensor_flip(client,value) != 0)
+            SENSOR_TR("%s(%d): sensor_flip failed, value:0x%x",__FUNCTION__, __LINE__,value);
+        
+        SENSOR_DG("%s(%d): sensor_flip success, value:0x%x",__FUNCTION__, __LINE__,value);
+        return 0;
+    }
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
+    return -EINVAL;
+}
+#endif
+#if CONFIG_SENSOR_Scene
+static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+{
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
+    {
+        if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)
+        {
+            if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)
+            {
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
+                return -EINVAL;
+            }
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
+            return 0;
+        }
+    }
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
+    return -EINVAL;
+}
+#endif
+#if CONFIG_SENSOR_WhiteBalance
+static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+{
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
+    {
+        if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
+        {
+            if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
+            {
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
+                return -EINVAL;
+            }
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
+            return 0;
+        }
+    }
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
+    return -EINVAL;
+}
+#endif
+#if CONFIG_SENSOR_DigitalZoom
+static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)
+{
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+    struct sensor *sensor = to_sensor(client);
+       const struct v4l2_queryctrl *qctrl_info;
+    int digitalzoom_cur, digitalzoom_total;
+
+       qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
+       if (qctrl_info)
+               return -EINVAL;
+
+    digitalzoom_cur = sensor->info_priv.digitalzoom;
+    digitalzoom_total = qctrl_info->maximum;
+
+    if ((*value > 0) && (digitalzoom_cur >= digitalzoom_total))
+    {
+        SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
+        return -EINVAL;
+    }
+
+    if  ((*value < 0) && (digitalzoom_cur <= qctrl_info->minimum))
+    {
+        SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
+        return -EINVAL;
+    }
+
+    if ((*value > 0) && ((digitalzoom_cur + *value) > digitalzoom_total))
+    {
+        *value = digitalzoom_total - digitalzoom_cur;
+    }
+
+    if ((*value < 0) && ((digitalzoom_cur + *value) < 0))
+    {
+        *value = 0 - digitalzoom_cur;
+    }
+
+    digitalzoom_cur += *value;
+
+    if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)
+    {
+        if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)
+        {
+            SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
+            return -EINVAL;
+        }
+        SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, *value);
+        return 0;
+    }
+
+    return -EINVAL;
+}
+#endif
+#if CONFIG_SENSOR_Flash
+static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+{    
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {
+        if (value == 3) {       /* ddl@rock-chips.com: torch */
+            sensor_ioctrl(icd, Sensor_Flash, Flash_Torch);   /* Flash On */
+        } else {
+            sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
+        }
+        SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
+        return 0;
+    }
+    
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
+    return -EINVAL;
+}
+#endif
+
+static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+    struct i2c_client *client = sd->priv;
+    struct sensor *sensor = to_sensor(client);
+    const struct v4l2_queryctrl *qctrl;
+
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
+
+    if (!qctrl)
+    {
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
+        return -EINVAL;
+    }
+
+    switch (ctrl->id)
+    {
+        case V4L2_CID_BRIGHTNESS:
+            {
+                ctrl->value = sensor->info_priv.brightness;
+                break;
+            }
+        case V4L2_CID_SATURATION:
+            {
+                ctrl->value = sensor->info_priv.saturation;
+                break;
+            }
+        case V4L2_CID_CONTRAST:
+            {
+                ctrl->value = sensor->info_priv.contrast;
+                break;
+            }
+        case V4L2_CID_DO_WHITE_BALANCE:
+            {
+                ctrl->value = sensor->info_priv.whiteBalance;
+                break;
+            }
+        case V4L2_CID_EXPOSURE:
+            {
+                ctrl->value = sensor->info_priv.exposure;
+                break;
+            }
+        case V4L2_CID_HFLIP:
+            {
+                ctrl->value = sensor->info_priv.mirror;
+                break;
+            }
+        case V4L2_CID_VFLIP:
+            {
+                ctrl->value = sensor->info_priv.flip;
+                break;
+            }
+        default :
+                break;
+    }
+    return 0;
+}
+
+
+
+static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+    struct i2c_client *client = sd->priv;
+    struct sensor *sensor = to_sensor(client);
+    struct soc_camera_device *icd = client->dev.platform_data;
+    const struct v4l2_queryctrl *qctrl;
+
+
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
+
+    if (!qctrl)
+    {
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
+        return -EINVAL;
+    }
+
+    switch (ctrl->id)
+    {
+#if CONFIG_SENSOR_Brightness
+        case V4L2_CID_BRIGHTNESS:
+            {
+                if (ctrl->value != sensor->info_priv.brightness)
+                {
+                    if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)
+                    {
+                        return -EINVAL;
+                    }
+                    sensor->info_priv.brightness = ctrl->value;
+                }
+                break;
+            }
+#endif
+#if CONFIG_SENSOR_Exposure
+        case V4L2_CID_EXPOSURE:
+            {
+                if (ctrl->value != sensor->info_priv.exposure)
+                {
+                    if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)
+                    {
+                        return -EINVAL;
+                    }
+                    sensor->info_priv.exposure = ctrl->value;
+                }
+                break;
+            }
+#endif
+#if CONFIG_SENSOR_Saturation
+        case V4L2_CID_SATURATION:
+            {
+                if (ctrl->value != sensor->info_priv.saturation)
+                {
+                    if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)
+                    {
+                        return -EINVAL;
+                    }
+                    sensor->info_priv.saturation = ctrl->value;
+                }
+                break;
+            }
+#endif
+#if CONFIG_SENSOR_Contrast
+        case V4L2_CID_CONTRAST:
+            {
+                if (ctrl->value != sensor->info_priv.contrast)
+                {
+                    if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)
+                    {
+                        return -EINVAL;
+                    }
+                    sensor->info_priv.contrast = ctrl->value;
+                }
+                break;
+            }
+#endif
+#if CONFIG_SENSOR_WhiteBalance
+        case V4L2_CID_DO_WHITE_BALANCE:
+            {
+                if (ctrl->value != sensor->info_priv.whiteBalance)
+                {
+                    if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
+                    {
+                        return -EINVAL;
+                    }
+                    sensor->info_priv.whiteBalance = ctrl->value;
+                }
+                break;
+            }
+#endif
+#if CONFIG_SENSOR_Mirror
+        case V4L2_CID_HFLIP:
+            {
+                if (ctrl->value != sensor->info_priv.mirror)
+                {
+                    if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)
+                        return -EINVAL;
+                    sensor->info_priv.mirror = ctrl->value;
+                }
+                break;
+            }
+#endif
+#if CONFIG_SENSOR_Flip
+        case V4L2_CID_VFLIP:
+            {
+                if (ctrl->value != sensor->info_priv.flip)
+                {
+                    if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)
+                        return -EINVAL;
+                    sensor->info_priv.flip = ctrl->value;
+                }
+                break;
+            }
+#endif
+        default:
+            break;
+    }
+
+    return 0;
+}
+static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
+{
+    const struct v4l2_queryctrl *qctrl;
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+    struct sensor *sensor = to_sensor(client);
+
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
+
+    if (!qctrl)
+    {
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
+        return -EINVAL;
+    }
+
+    switch (ext_ctrl->id)
+    {
+        case V4L2_CID_SCENE:
+            {
+                ext_ctrl->value = sensor->info_priv.scene;
+                break;
+            }
+        case V4L2_CID_EFFECT:
+            {
+                ext_ctrl->value = sensor->info_priv.effect;
+                break;
+            }
+        case V4L2_CID_ZOOM_ABSOLUTE:
+            {
+                ext_ctrl->value = sensor->info_priv.digitalzoom;
+                break;
+            }
+        case V4L2_CID_ZOOM_RELATIVE:
+            {
+                return -EINVAL;
+            }
+        case V4L2_CID_FOCUS_ABSOLUTE:
+            {
+                ext_ctrl->value = sensor->info_priv.focus;
+                break;
+            }
+        case V4L2_CID_FOCUS_RELATIVE:
+            {
+                return -EINVAL;
+            }
+        case V4L2_CID_FLASH:
+            {
+                ext_ctrl->value = sensor->info_priv.flash;
+                break;
+            }
+        default :
+            break;
+    }
+    return 0;
+}
+static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
+{
+    const struct v4l2_queryctrl *qctrl;
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+    struct sensor *sensor = to_sensor(client);
+    int val_offset;
+
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
+
+    if (!qctrl)
+    {
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
+        return -EINVAL;
+    }
+
+       val_offset = 0;
+    switch (ext_ctrl->id)
+    {
+#if CONFIG_SENSOR_Scene
+        case V4L2_CID_SCENE:
+            {
+                if (ext_ctrl->value != sensor->info_priv.scene)
+                {
+                    if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)
+                        return -EINVAL;
+                    sensor->info_priv.scene = ext_ctrl->value;
+                }
+                break;
+            }
+#endif
+#if CONFIG_SENSOR_Effect
+        case V4L2_CID_EFFECT:
+            {
+                if (ext_ctrl->value != sensor->info_priv.effect)
+                {
+                    if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)
+                        return -EINVAL;
+                    sensor->info_priv.effect= ext_ctrl->value;
+                }
+                break;
+            }
+#endif
+#if CONFIG_SENSOR_DigitalZoom
+        case V4L2_CID_ZOOM_ABSOLUTE:
+            {
+                if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
+                    return -EINVAL;
+
+                if (ext_ctrl->value != sensor->info_priv.digitalzoom)
+                {
+                    val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;
+
+                    if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)
+                        return -EINVAL;
+                    sensor->info_priv.digitalzoom += val_offset;
+
+                    SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(),  sensor->info_priv.digitalzoom);
+                }
+
+                break;
+            }
+        case V4L2_CID_ZOOM_RELATIVE:
+            {
+                if (ext_ctrl->value)
+                {
+                    if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
+                        return -EINVAL;
+                    sensor->info_priv.digitalzoom += ext_ctrl->value;
+
+                    SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
+                }
+                break;
+            }
+#endif
+#if CONFIG_SENSOR_Focus
+        case V4L2_CID_FOCUS_ABSOLUTE:
+            {
+                if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
+                    return -EINVAL;
+
+                if (ext_ctrl->value != sensor->info_priv.focus)
+                {
+                    val_offset = ext_ctrl->value -sensor->info_priv.focus;
+
+                    sensor->info_priv.focus += val_offset;
+                }
+
+                break;
+            }
+        case V4L2_CID_FOCUS_RELATIVE:
+            {
+                if (ext_ctrl->value)
+                {
+                    sensor->info_priv.focus += ext_ctrl->value;
+
+                    SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);
+                }
+                break;
+            }
+#endif
+#if CONFIG_SENSOR_Flash
+        case V4L2_CID_FLASH:
+            {
+                if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)
+                    return -EINVAL;
+                sensor->info_priv.flash = ext_ctrl->value;
+
+                SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
+                break;
+            }
+#endif
+        default:
+            break;
+    }
+
+    return 0;
+}
+
+static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
+{
+    struct i2c_client *client = sd->priv;
+    struct soc_camera_device *icd = client->dev.platform_data;
+    int i, error_cnt=0, error_idx=-1;
+
+
+    for (i=0; i<ext_ctrl->count; i++) {
+        if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
+            error_cnt++;
+            error_idx = i;
+        }
+    }
+
+    if (error_cnt > 1)
+        error_idx = ext_ctrl->count;
+
+    if (error_idx != -1) {
+        ext_ctrl->error_idx = error_idx;
+        return -EINVAL;
+    } else {
+        return 0;
+    }
+}
+
+static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
+{
+    struct i2c_client *client = sd->priv;
+    struct soc_camera_device *icd = client->dev.platform_data;
+    int i, error_cnt=0, error_idx=-1;
+
+
+    for (i=0; i<ext_ctrl->count; i++) {
+        if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
+            error_cnt++;
+            error_idx = i;
+        }
+    }
+
+    if (error_cnt > 1)
+        error_idx = ext_ctrl->count;
+
+    if (error_idx != -1) {
+        ext_ctrl->error_idx = error_idx;
+        return -EINVAL;
+    } else {
+        return 0;
+    }
+}
+
+/* Interface active, can use i2c. If it fails, it can indeed mean, that
+ * this wasn't our capture interface, so, we wait for the right one */
+static int sensor_video_probe(struct soc_camera_device *icd,
+                              struct i2c_client *client)
+{
+    char pid = 0;
+    int ret, i=0;
+    struct sensor *sensor = to_sensor(client);
+
+    /* We must have a parent by now. And it cannot be a wrong one.
+     * So this entire test is completely redundant. */
+    if (!icd->dev.parent ||
+           to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
+               return -ENODEV;
+
+       if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
+               ret = -ENODEV;
+               printk("%s(): set powerdn failed\n", __FUNCTION__);
+               goto sensor_video_probe_err;
+       }
+
+    /* soft reset */
+   /* ret = sensor_write(client, 0x12, 0x80);
+    if (ret != 0)
+    {
+        SENSOR_TR("soft reset %s failed\n",SENSOR_NAME_STRING());
+        return -ENODEV;
+    }
+    mdelay(50);          *///delay 5 microseconds
+re:
+    /* check if it is an sensor sensor */
+    ret = sensor_read(client, 0x00, &pid);
+    if (ret != 0) {
+        SENSOR_TR("%s read chip id high byte failed\n",SENSOR_NAME_STRING());
+       if(++i<100)
+               goto re;
+        ret = -ENODEV;
+        goto sensor_video_probe_err;
+    }
+
+    SENSOR_DG("\n %s  pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
+    if (pid == SENSOR_ID) {
+        sensor->model = SENSOR_V4L2_IDENT;
+    } else {
+        SENSOR_TR("error: %s mismatched   pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
+       goto re;
+        ret = -ENODEV;
+        goto sensor_video_probe_err;
+    }
+
+    icd->formats = sensor_colour_formats;
+    icd->num_formats = ARRAY_SIZE(sensor_colour_formats);
+
+    return 0;
+
+sensor_video_probe_err:
+
+    return ret;
+}
+
+static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
+{
+       struct i2c_client *client = sd->priv;
+    struct soc_camera_device *icd = client->dev.platform_data;
+    struct sensor *sensor = to_sensor(client);
+    int ret = 0;
+#if CONFIG_SENSOR_Flash        
+    int i;
+#endif
+    
+       SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
+       switch (cmd)
+       {
+               case RK29_CAM_SUBDEV_DEACTIVATE:
+               {
+                       sensor_deactivate(client);
+                       break;
+               }
+
+               case RK29_CAM_SUBDEV_IOREQUEST:
+               {
+                       sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;           
+            if (sensor->sensor_io_request != NULL) { 
+                if (sensor->sensor_io_request->gpio_res[0].dev_name && 
+                    (strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
+                    sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
+                } else if (sensor->sensor_io_request->gpio_res[1].dev_name && 
+                    (strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
+                    sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
+                }
+            } else {
+                SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
+                ret = -EINVAL;
+                goto sensor_ioctl_end;
+            }
+            /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control 
+               for this project */
+            #if CONFIG_SENSOR_Flash    
+               if (sensor->sensor_gpio_res) { 
+                if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                               if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
+                                       memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));                                       
+                               }
+                    }
+                    sensor->info_priv.flash = 0xff;
+                    SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }
+               }
+            #endif
+                       break;
+               }
+               default:
+               {
+                       SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
+                       break;
+               }
+       }
+sensor_ioctl_end:
+       return ret;
+
+}
+static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
+       .init           = sensor_init,
+       .g_ctrl         = sensor_g_control,
+       .s_ctrl         = sensor_s_control,
+       .g_ext_ctrls          = sensor_g_ext_controls,
+       .s_ext_ctrls          = sensor_s_ext_controls,
+       .g_chip_ident   = sensor_g_chip_ident,
+       .ioctl = sensor_ioctl,
+};
+
+static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
+       .s_fmt          = sensor_s_fmt,
+       .g_fmt          = sensor_g_fmt,
+       .try_fmt        = sensor_try_fmt,
+};
+
+static struct v4l2_subdev_ops sensor_subdev_ops = {
+       .core   = &sensor_subdev_core_ops,
+       .video = &sensor_subdev_video_ops,
+};
+
+static int sensor_probe(struct i2c_client *client,
+                        const struct i2c_device_id *did)
+{
+    struct sensor *sensor;
+    struct soc_camera_device *icd = client->dev.platform_data;
+    struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
+    struct soc_camera_link *icl;
+    int ret;
+
+    SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);
+    if (!icd) {
+        dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());
+        return -EINVAL;
+    }
+
+    icl = to_soc_camera_link(icd);
+    if (!icl) {
+        dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());
+        return -EINVAL;
+    }
+
+    if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
+        dev_warn(&adapter->dev,
+                "I2C-Adapter doesn't support I2C_FUNC_I2C\n");
+        return -EIO;
+    }
+
+    sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);
+    if (!sensor)
+        return -ENOMEM;
+
+    v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);
+
+    /* Second stage probe - when a capture adapter is there */
+    icd->ops           = &sensor_ops;
+    icd->y_skip_top            = 0;
+       #if CONFIG_SENSOR_I2C_NOSCHED
+       atomic_set(&sensor->tasklock_cnt,0);
+       #endif
+
+    ret = sensor_video_probe(icd, client);
+    if (ret < 0) {
+        icd->ops = NULL;
+        i2c_set_clientdata(client, NULL);
+        kfree(sensor);
+               sensor = NULL;
+    }
+    SENSOR_DG("\n%s..%s..%d  ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
+    return ret;
+}
+
+static int sensor_remove(struct i2c_client *client)
+{
+    struct sensor *sensor = to_sensor(client);
+    struct soc_camera_device *icd = client->dev.platform_data;
+
+    icd->ops = NULL;
+    i2c_set_clientdata(client, NULL);
+    client->driver = NULL;
+    kfree(sensor);
+       sensor = NULL;
+    return 0;
+}
+
+static const struct i2c_device_id sensor_id[] = {
+       {SENSOR_NAME_STRING(), 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, sensor_id);
+
+static struct i2c_driver sensor_i2c_driver = {
+       .driver = {
+               .name = SENSOR_NAME_STRING(),
+       },
+       .probe          = sensor_probe,
+       .remove         = sensor_remove,
+       .id_table       = sensor_id,
+};
+
+static int __init sensor_mod_init(void)
+{
+    SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
+    return i2c_add_driver(&sensor_i2c_driver);
+}
+
+static void __exit sensor_mod_exit(void)
+{
+    i2c_del_driver(&sensor_i2c_driver);
+}
+
+device_initcall_sync(sensor_mod_init);
+module_exit(sensor_mod_exit);
+
+MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
+MODULE_AUTHOR("ddl <kernel@rock-chips>");
+MODULE_LICENSE("GPL");
+
+
index 0a47fc97e5e39a4fa3ecff5c8955de9beb7f200b..a73c7dc07f2837d06ce6374469c3a2e084ce7864 100755 (executable)
@@ -46,12 +46,12 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define SENSOR_NAME RK29_CAM_SENSOR_GC2015
 #define SENSOR_V4L2_IDENT V4L2_IDENT_GC2015
 #define SENSOR_ID 0x2005
-#define SENSOR_MIN_WIDTH    176
-#define SENSOR_MIN_HEIGHT   144
+#define SENSOR_MIN_WIDTH    640
+#define SENSOR_MIN_HEIGHT   480
 #define SENSOR_MAX_WIDTH    1600
 #define SENSOR_MAX_HEIGHT   1200
-#define SENSOR_INIT_WIDTH      1024                    /* Sensor pixel size for sensor_init_data array */
-#define SENSOR_INIT_HEIGHT  768
+#define SENSOR_INIT_WIDTH      800//1024                       /* Sensor pixel size for sensor_init_data array */
+#define SENSOR_INIT_HEIGHT  600//768
 #define SENSOR_INIT_WINSEQADR sensor_svga
 #define SENSOR_INIT_PIXFMT V4L2_PIX_FMT_UYVY
 
@@ -98,232 +98,483 @@ struct reginfo
 
 /* init SVGA preview */
 static struct reginfo sensor_init_data[] =
+
 {
-//{0xfe , 0x80}, //soft reset
-{0x45 , 0x00}, //output_enable
+       {0xfe, 0x80}, //soft reset
+       {0xfe, 0x80}, //soft reset
+       {0xfe, 0x80}, //soft reset
+
+       {0xfe, 0x00}, //page0
+       {0x45, 0x00}, //output_disable
+
        //////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////preview capture switch /////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////
        //preview
-{0x02 , 0x01}, //preview mode
-{0x2a , 0xca}, //[7]col_binning , 0x[6]even skip
-{0x48 , 0x40}, //manual_gain
+       {0x02, 0x01}, //preview mode
+       {0x2a, 0xca}, //[7]col_binning, 0x[6]even skip
+       {0x48, 0x40}, //manual_gain
 
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////// preview LSC /////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
-       
-{0xb0 , 0x13}, //[4]Y_LSC_en [3]lsc_compensate [2]signed_b4 [1:0]pixel array select
-{0xb1 , 0x20}, //P_LSC_red_b2
-{0xb2 , 0x20}, //P_LSC_green_b2
-{0xb3 , 0x20}, //P_LSC_blue_b2
-{0xb4 , 0x20}, //P_LSC_red_b4
-{0xb5 , 0x20}, //P_LSC_green_b4
-{0xb6 , 0x20}, //P_LSC_blue_b4
-{0xb7 , 0x00}, //P_LSC_compensate_b2
-{0xb8 , 0x80}, //P_LSC_row_center , 0x344 , 0x (0x600/2-100)/2=100
-{0xb9 , 0x80}, //P_LSC_col_center , 0x544 , 0x (0x800/2-200)/2=100
+       {0xfe, 0x01}, //page1
+       {0xb0, 0x03}, //[4]Y_LSC_en [3]lsc_compensate [2]signed_b4 [1:0]pixel array select
+       {0xb1, 0x46}, //P_LSC_red_b2
+       {0xb2, 0x40}, //P_LSC_green_b2
+       {0xb3, 0x40}, //P_LSC_blue_b2
+       {0xb4, 0x24}, //P_LSC_red_b4
+       {0xb5, 0x20}, //P_LSC_green_b4
+       {0xb6, 0x22}, //P_LSC_blue_b4
+       {0xb7, 0x00}, //P_LSC_compensate_b2
+       {0xb8, 0x80}, //P_LSC_row_center, 0x344, 0x (1200/2-344)/2=128, 0x, 0x
+       {0xb9, 0x80}, //P_LSC_col_center, 0x544, 0x (1600/2-544)/2=128
+
 
        ////////////////////////////////////////////////////////////////////////
-       ////////////////////////// capture LSC ///////////////////////////
+       ////////////////////////// capture LSC /////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
-{0xba , 0x13}, //[4]Y_LSC_en [3]lsc_compensate [2]signed_b4 [1:0]pixel array select
-{0xbb , 0x20}, //C_LSC_red_b2
-{0xbc , 0x20}, //C_LSC_green_b2
-{0xbd , 0x20}, //C_LSC_blue_b2
-{0xbe , 0x20}, //C_LSC_red_b4
-{0xbf , 0x20}, //C_LSC_green_b4
-{0xc0 , 0x20}, //C_LSC_blue_b4
-{0xc1 , 0x00}, //C_Lsc_compensate_b2
-{0xc2 , 0x80}, //C_LSC_row_center , 0x344 , 0x (0x1200/2-344)/2=128
-{0xc3 , 0x80}, //C_LSC_col_center , 0x544 , 0x (0x1600/2-544)/2=128
-
-       //GC2015_SET_PAGE0; //page0
+       {0xba, 0x03}, //[4]Y_LSC_en [3]lsc_compensate [2]signed_b4 [1:0]pixel array select
+       {0xbb, 0x46}, //C_LSC_red_b2
+       {0xbc, 0x40}, //C_LSC_green_b2
+       {0xbd, 0x40}, //C_LSC_blue_b2
+       {0xbe, 0x24}, //C_LSC_red_b4
+       {0xbf, 0x20}, //C_LSC_green_b4
+       {0xc0, 0x22}, //C_LSC_blue_b4
+       {0xc1, 0x00}, //C_Lsc_compensate_b2
+       {0xc2, 0x80}, //C_LSC_row_center, 0x344, 0x (1200/2-344)/2=128
+       {0xc3, 0x80}, //C_LSC_col_center, 0x544, 0x (1600/2-544)/2=128
+       {0xfe, 0x00}, //page0
 
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////// analog configure ///////////////////////////
        ////////////////////////////////////////////////////////////////////////
-{0x29 , 0x00}, //cisctl mode 1
-{0x2b , 0x06}, //cisctl mode 3 
-{0x32 , 0x0c}, //analog mode 1
-{0x33 , 0x0f}, //analog mode 2
-{0x34 , 0x00}, //[6:4]da_rsg
-       
-{0x35 , 0x88}, //Vref_A25
-{0x37 , 0x16}, //Drive Current
+       {0xfe, 0x00}, //page0
+       {0x29, 0x00}, //cisctl mode 1
+       {0x2b, 0x06}, //cisctl mode 3   
+       {0x32, 0x1c}, //analog mode 1
+       {0x33, 0x0f}, //analog mode 2
+       {0x34, 0x30}, //[6:4]da_rsg
+
+       {0x35, 0x88}, //Vref_A25
+       {0x37, 0x16}, //Drive Current
 
        /////////////////////////////////////////////////////////////////////
-       ///////////////////////////ISP Related//////////////////////////////
+       /////////////////////////// ISP Related /////////////////////////////
        /////////////////////////////////////////////////////////////////////
-{0x40 , 0xff}, 
-{0x41 , 0x24}, //[5]skin_detectionenable[2]auto_gray , 0x[1]y_gamma
-{0x42 , 0x76}, //[7]auto_sa[6]auto_ee[5]auto_dndd[4]auto_lsc[3]na[2]abs , 0x[1]awb
-{0x4b , 0xea}, //[1]AWB_gain_mode , 0x1:atpregain0:atpostgain
-{0x4d , 0x03}, //[1]inbf_en
-{0x4f , 0x01}, //AEC enable
+       {0x40, 0xff}, 
+       {0x41, 0x20}, //[5]skin_detectionenable[2]auto_gray, 0x[1]y_gamma
+       {0x42, 0xf6}, //[7]auto_sa[6]auto_ee[5]auto_dndd[4]auto_lsc[3]na[2]abs, 0x[1]awb
+       {0x4b, 0xe8}, //[1]AWB_gain_mode, 0x1:atpregain0:atpostgain
+       {0x4d, 0x03}, //[1]inbf_en
+       {0x4f, 0x01}, //AEC enable
 
        ////////////////////////////////////////////////////////////////////
-       /////////////////////////// BLK  ///////////////////////////////////
+       ///////////////////////////  BLK  //////////////////////////////////
        ////////////////////////////////////////////////////////////////////
-{0x63 , 0x77}, //BLK mode 1
-{0x66 , 0x00}, //BLK global offset
-{0x6d , 0x04}, 
-{0x6e , 0x18}, //BLK offset submode,offset R
-{0x6f , 0x10},
-{0x70 , 0x18},
-{0x71 , 0x10},
-{0x73 , 0x03}, 
-
+       {0x63, 0x77}, //BLK mode 1
+       {0x66, 0x00}, //BLK global offset
+       {0x6d, 0x00},
+       {0x6e, 0x1a}, //BLK offset submode,offset R
+       {0x6f, 0x20},
+       {0x70, 0x1a},
+       {0x71, 0x20},
+       {0x73, 0x00},
+       {0x77, 0x80},
+       {0x78, 0x80},
+       {0x79, 0x90},
 
        ////////////////////////////////////////////////////////////////////
-       /////////////////////////// DNDD ////////////////////////////////
+       /////////////////////////// DNDD ///////////////////////////////////
        ////////////////////////////////////////////////////////////////////
-{0x80 , 0x07}, //[7]dn_inc_or_dec [4]zero_weight_mode[3]share [2]c_weight_adap [1]dn_lsc_mode [0]dn_b
-{0x82 , 0x08}, //DN lilat b base
+       {0x80, 0x07}, //[7]dn_inc_or_dec [4]zero_weight_mode[3]share [2]c_weight_adap [1]dn_lsc_mode [0]dn_b
+       {0x82, 0x0c}, //DN lilat b base
+       {0x83, 0x03},
 
        ////////////////////////////////////////////////////////////////////
        /////////////////////////// EEINTP ////////////////////////////////
        ////////////////////////////////////////////////////////////////////
-{0x8a , 0x7c},
-{0x8c , 0x02},
-{0x8e , 0x02},
-{0x8f , 0x48},
+       {0x8a, 0x7c},
+       {0x8c, 0x02},
+       {0x8e, 0x02},
+       {0x8f, 0x45},
+
 
        /////////////////////////////////////////////////////////////////////
-       /////////////////////////// CC_t ///////////////////////////////
+       /////////////////////////// CC_t ////////////////////////////////////
        /////////////////////////////////////////////////////////////////////
-{0xb0 , 0x44},
-{0xb1 , 0xfe},
-{0xb2 , 0x00},
-{0xb3 , 0xf8},
-{0xb4 , 0x48},
-{0xb5 , 0xf8},
-{0xb6 , 0x00},
-{0xb7 , 0x04},
-{0xb8 , 0x00},
+       {0xb0, 0x40},   // 0x48
+       {0xb1, 0xfe},
+       {0xb2, 0x00},
+       {0xb3, 0xf0},
+       {0xb4, 0x50},
+       {0xb5, 0xf8},
+       {0xb6, 0x00},
+       {0xb7, 0x00},
+       {0xb8, 0x00},
+
 
        /////////////////////////////////////////////////////////////////////
        /////////////////////////// GAMMA ///////////////////////////////////
        /////////////////////////////////////////////////////////////////////
        //RGB_GAMMA
-{0xbf , 0x0e},
-{0xc0 , 0x1c},
-{0xc1 , 0x34},
-{0xc2 , 0x48},
-{0xc3 , 0x5a},
-{0xc4 , 0x6b},
-{0xc5 , 0x7b},
-{0xc6 , 0x95},
-{0xc7 , 0xab},
-{0xc8 , 0xbf},
-{0xc9 , 0xce},
-{0xca , 0xd9},
-{0xcb , 0xe4},
-{0xcc , 0xec},
-{0xcd , 0xf7},
-{0xce , 0xfd},
-{0xcf , 0xff},
+       {0xbf, 0x08}, 
+       {0xc0, 0x1e},
+       {0xc1, 0x33},
+       {0xc2, 0x47},
+       {0xc3, 0x59},
+       {0xc4, 0x68},
+       {0xc5, 0x74},
+       {0xc6, 0x86},
+       {0xc7, 0x97},
+       {0xc8, 0xA5},
+       {0xc9, 0xB1},
+       {0xca, 0xBd},
+       {0xcb, 0xC8},
+       {0xcc, 0xD3},
+       {0xcd, 0xE4},
+       {0xce, 0xF4},
+       {0xcf, 0xff},
+       
+       /*{0xbf, 0x06},
+       {0xc0, 0x1f},
+       {0xc1, 0x38},
+       {0xc2, 0x4c},
+       {0xc3, 0x5b},
+       {0xc4, 0x6b},
+       {0xc5, 0x76},
+       {0xc6, 0x8b},
+       {0xc7, 0x9b},
+       {0xc8, 0xac},
+       {0xc9, 0xbb},
+       {0xca, 0xc7},
+       {0xcb, 0xd2},
+       {0xcc, 0xdb},
+       {0xcd, 0xea},
+       {0xce, 0xf5},
+       {0xcf, 0xff},   */
 
        /////////////////////////////////////////////////////////////////////
-       /////////////////////////// YCP_t  ///////////////////////////////
+       /////////////////////////// YCP_t ///////////////////////////////////
        /////////////////////////////////////////////////////////////////////
-{0xd1 , 0x38}, //saturation
-{0xd2 , 0x38}, //saturation
-{0xde , 0x21}, //auto_gray
+       {0xd1, 0x40}, //saturation   38
+       {0xd2, 0x40}, //saturation   38
+       
+       {0xd3, 0x46},  // 2011-08-11 kim add
+       
+       {0xde, 0x21}, //auto_gray
 
        ////////////////////////////////////////////////////////////////////
-       /////////////////////////// ASDE ////////////////////////////////
+       /////////////////////////// ASDE ///////////////////////////////////
        ////////////////////////////////////////////////////////////////////
-{0x98 , 0x30},
-{0x99 , 0xf0},
-{0x9b , 0x00},
+       {0x98, 0x3a}, 
+       {0x99, 0x60}, 
+       {0x9b, 0x00}, 
+       {0x9f, 0x12}, 
+       {0xa1, 0x80}, 
+       {0xa2, 0x21}, 
+       
+       {0xfe, 0x01}, //page1
+       {0xc5, 0x10}, 
+       {0xc6, 0xff}, 
+       {0xc7, 0xff}, 
+       {0xc8, 0xff}, 
 
-       //GC2015_SET_PAGE1; //page1
        ////////////////////////////////////////////////////////////////////
-       /////////////////////////// AEC  ////////////////////////////////
+       /////////////////////////// AEC ////////////////////////////////////
        ////////////////////////////////////////////////////////////////////
-{0x10 , 0x45}, //AEC mode 1
-{0x11 , 0x32}, //[7]fix target
-{0x13 , 0x60},
-{0x17 , 0x00},
-{0x1c , 0x96},
-{0x1e , 0x11},
-{0x21 , 0xc0}, //max_post_gain
-{0x22 , 0x40}, //max_pre_gain
-{0x2d , 0x06}, //P_N_AEC_exp_level_1[12:8]
-{0x2e , 0x00}, //P_N_AEC_exp_level_1[7:0]
-{0x1e , 0x32},
-{0x33 , 0x00}, //[6:5]max_exp_level [4:0]min_exp_level
+       {0x10, 0x09}, //AEC mode 1
+       {0x11, 0x92}, //[7]fix target  // 0xb2  2011-08-11 kim 
+       {0x12, 0x20}, 
+       {0x13, 0x78},   // 0x78  2011-08-11 kim 
+       {0x17, 0x00}, 
+       {0x1c, 0x96}, 
+       {0x1d, 0x04}, // sunlight step 
+       {0x1e, 0x11}, 
+       {0x21, 0xc0}, //max_post_gain
+       {0x22, 0x40}, //max_pre_gain   // 0x60  2011-08-11 kim 
+       {0x2d, 0x06}, //P_N_AEC_exp_level_1[12:8]
+       {0x2e, 0x00}, //P_N_AEC_exp_level_1[7:0]
+       {0x1e, 0x32}, 
+       {0x33, 0x00}, //[6:5]max_exp_level [4:0]min_exp_level
+       {0x34, 0x04}, // min exp
 
        ////////////////////////////////////////////////////////////////////
-       ///////////////////////////  AWB  ////////////////////////////////
+       /////////////////////////// Measure Window /////////////////////////
        ////////////////////////////////////////////////////////////////////
-{0x57 , 0x40}, //number limit
-{0x5d , 0x44}, //
-{0x5c , 0x35}, //show mode,close dark_mode
-{0x5e , 0x29}, //close color temp
-{0x5f , 0x50},
-{0x60 , 0x50}, 
-{0x65 , 0xc0},
+       {0x06, 0x07},
+       {0x07, 0x03},
+       {0x08, 0x64},
+       {0x09, 0x4a},
 
        ////////////////////////////////////////////////////////////////////
-       ///////////////////////////  ABS  ////////////////////////////////
+       /////////////////////////// AWB ////////////////////////////////////
        ////////////////////////////////////////////////////////////////////
-{0x80 , 0x82},
-{0x81 , 0x00},
-{0x83 , 0x00}, //ABS Y stretch limit
-
-       //GC2015_SET_PAGE0;
-
-       //////////////////////////////////////////////////////////////////////////////////////
-       ///////////////////////////// Crop //////////////////////////////////////////////////
-       //////////////////////////////////////////////////////////////////////////////////////
-{0x50 , 0x01},//out window
-{0x51 , 0x00},
-{0x52 , 0x00},
-{0x53 , 0x00},
-{0x54 , 0x00},
-{0x55 , 0x02},
-{0x56 , 0x58},
-{0x57 , 0x03},
-{0x58 , 0x20},
-
+       {0x57, 0x40}, //number limit
+       {0x5d, 0x44}, //
+       {0x5c, 0x35}, //show mode,close dark_mode
+       {0x5e, 0x29}, //close color temp
+       {0x5f, 0x50},
+       {0x60, 0x50}, 
+       {0x65, 0xc0},
+       ////////////////////////////////////////////////////////////////////
+       /////////////////////////// ABS ////////////////////////////////////
+       ////////////////////////////////////////////////////////////////////
+       {0x80, 0x82},
+       {0x81, 0x00},
+       
+       {0x82, 0x03},  /// 
+       
+       {0x83, 0x10}, //ABS Y stretch limit
+       {0xfe, 0x00},
        ////////////////////////////////////////////////////////////////////
-       ///////////////////////////  OUT  ////////////////////////////////
+       /////////////////////////// OUT ////////////////////////////////////
        ////////////////////////////////////////////////////////////////////
-{0x44 , 0xa0}, //YUV sequence
-{0x45 , 0x0f}, //output enable
-{0x46 , 0x02}, //sync mode
+       {0xfe, 0x00},
+       //crop 
+       {0x50, 0x01},
+       {0x51, 0x00},
+       {0x52, 0x00},
+       {0x53, 0x00},
+       {0x54, 0x00},
+       {0x55, 0x02},
+       {0x56, 0x58},
+       {0x57, 0x03},
+       {0x58, 0x20},
+
+       {0x44, 0xa0}, //YUV sequence
+       {0x45, 0x0f}, //output enable
+       {0x46, 0x02}, //sync mode
+       
+/*     {0xbF, 0x0B}, 
+       {0xc0, 0x16}, 
+       {0xc1, 0x29}, 
+       {0xc2, 0x3C}, 
+       {0xc3, 0x4F}, 
+       {0xc4, 0x5F}, 
+       {0xc5, 0x6F}, 
+       {0xc6, 0x8A}, 
+       {0xc7, 0x9F}, 
+       {0xc8, 0xB4}, 
+       {0xc9, 0xC6}, 
+       {0xcA, 0xD3}, 
+       {0xcB, 0xDD},  
+       {0xcC, 0xE5},  
+       {0xcD, 0xF1}, 
+       {0xcE, 0xFA}, 
+       {0xcF, 0xFF},*/
+       
+       {0x05, 0x01},//HB
+       {0x06, 0xc1},
+       {0x07, 0x00},//VB
+       {0x08, 0x40},
+       
+       {0xfe, 0x01},
+       {0x29, 0x00},//Anti Step 128
+       {0x2a, 0x80},
+       
+       {0x2b, 0x05},//Level_0  10.00fps
+       {0x2c, 0x00},
+       {0x2d, 0x06},//Level_1   8.33fps
+       {0x2e, 0x00},
+       {0x2f, 0x08},//Level_2   6.25fps
+       {0x30, 0x00},
+       {0x31, 0x09},//Level_3   5.55fps
+       {0x32, 0x00},
+       {0x33, 0x20},
+       {0xfe, 0x00},
+       
+//--------------------Updated By Mormo 2011/08/08 Start --------------------//
+       {0xfe, 0x00},
+       {0x32, 0x34},
+       {0x34, 0x00},
+//--------------------Updated By Mormo 2011/08/08 End ---------------------//  
+       {0x7d, 0x80}, //
+       {0x7e, 0x80},
+       {0x7f, 0x84},
+
+       {0x0,0x0}
+
 };
 
 /* 1600X1200 UXGA capture */
 static struct reginfo sensor_uxga[] =
 {
-{0x45 , 0x0f}, //output enable
- {0x0,0x0}
+       {0xfe, 0x00},
+
+       {0x48, 0x80},  // 68
+       
+       {0x4f, 0x00},   // aec off
+       
+       {0x02, 0x00},
+       {0x2a, 0x0a},
+
+       //subsample 1/1
+       {0x59,  0x11},
+       {0x5a,  0x06},
+       {0x5b,  0x00},
+       {0x5c,  0x00},
+       {0x5d,  0x00},
+       {0x5e , 0x00},
+       {0x5f,  0x00},
+       {0x60,  0x00},
+       {0x61,  0x00},
+       {0x62,  0x00},
+
+       //crop 
+       {0x50,  0x01},
+       {0x51,  0x00},
+       {0x52,  0x00},
+       {0x53,  0x00},
+       {0x54,  0x00},
+       {0x55,  0x04},
+       {0x56,  0xb0},
+       {0x57,  0x06},
+       {0x58,  0x40},
+       {0x0,0x0}
 };
 
 /* 1280X1024 SXGA */
 static struct reginfo sensor_sxga[] =
 {
-  {0x0, 0x0}
+       {0xfe, 0x00},
+
+       {0x48, 0x80},  // 68
+       
+       {0x4f, 0x00},   // aec off
+       
+       {0x02, 0x00},
+       {0x2a, 0x0a},
+
+       //subsample 1/1
+       {0x59,  0x11},
+       {0x5a,  0x06},
+       {0x5b,  0x00},
+       {0x5c,  0x00},
+       {0x5d,  0x00},
+       {0x5e , 0x00},
+       {0x5f,  0x00},
+       {0x60,  0x00},
+       {0x61,  0x00},
+       {0x62,  0x00},
+
+       //crop 
+       {0x50,  0x01},
+       {0x51,  0x00},
+       {0x52,  0x00},
+       {0x53,  0x00},
+       {0x54,  0x00},
+       {0x55,  0x04},
+       {0x56,  0x00},
+       {0x57,  0x05},
+       {0x58,  0x00},
+       {0x0, 0x0}
 };
+/*1024*768*/
 static struct reginfo sensor_xga[] =
 {
+       {0xfe, 0x00},
+
+       {0x48, 0x80},  // 68
+       
+       {0x4f, 0x00},   // aec off
+       
+       {0x02, 0x00},
+       {0x2a, 0x0a},
+       //subsample 1600x1200 to 1066x800
+       {0x59 , 0x33},//out window
+       {0x5a , 0x06},
+       {0x5b , 0x00},
+       {0x5c , 0x00},
+       {0x5d , 0x00},
+       {0x5e , 0x01},
+       {0x5f , 0x00}, 
+       {0x60 , 0x00},
+       {0x61 , 0x00},
+       {0x62 , 0x01},
+
+       {0x50 , 0x01},//out window
+       {0x51 , 0x00},
+       {0x52 , 0x10},
+       {0x53 , 0x00},
+       {0x54 , 0x14},
+       {0x55 , 0x03},
+       {0x56 , 0x00},// 768
+       {0x57 , 0x04},
+       {0x58 , 0x00},//1024
        {0x0, 0x0}
 };
 /* 800X600 SVGA,30fps*/
 static struct reginfo sensor_svga[] =
 {
-{0x45 , 0x0f}, //output enable
- {0x0,0x0}
+       {0xfe, 0x00},
+
+       {0x48, 0x40},
+       {0x4f, 0x01},   // aec on
+
+       {0x02, 0x01},
+       {0x2a, 0xca},
+
+       //subsample 1/1
+       {0x59,  0x11},
+       {0x5a,  0x06},
+       {0x5b,  0x00},
+       {0x5c,  0x00},
+       {0x5d,  0x00},
+       {0x5e , 0x00},
+       {0x5f,  0x00},
+       {0x60,  0x00},
+       {0x61,  0x00},
+       {0x62,  0x00},
+
+       {0x50 , 0x01},//out window
+       {0x51 , 0x00},
+       {0x52 , 0x00},
+       {0x53 , 0x00},
+       {0x54 , 0x00},
+       {0x55 , 0x02},
+       {0x56 , 0x58},// 600
+       {0x57 , 0x03},
+       {0x58 , 0x20},//800
+       {0x0,0x0}
 };
 
 /* 640X480 VGA */
 static struct reginfo sensor_vga[] =
 {
-{0x45 , 0x0f}, //output enable
- {0x0,0x0}
+
+
+       {0xfe, 0x00},
+
+       {0x48, 0x40},
+       {0x4f, 0x01},   // aec on
+
+       {0x02, 0x01},
+       {0x2a, 0xca},
+       //subsample 4/5
+
+       {0x59 , 0x55},//out window
+       {0x5a , 0x06},
+       {0x5b , 0x00},
+       {0x5c , 0x00},
+       {0x5d , 0x01},
+       {0x5e , 0x23},
+       {0x5f , 0x00}, 
+       {0x60 , 0x00},
+       {0x61 , 0x01},
+       {0x62 , 0x23},
+
+       {0x50 , 0x01},//out window
+       {0x51 , 0x00},
+       {0x52 , 0x00},
+       {0x53 , 0x00},
+       {0x54 , 0x00},
+       {0x55 , 0x01},
+       {0x56 , 0xe0},// 480
+       {0x57 , 0x02},
+       {0x58 , 0x80},//640 
+       {0x45 , 0x0f}, //output enable
+       {0x0,0x0}
 };
 
 /* 352X288 CIF */
@@ -341,84 +592,48 @@ static struct reginfo sensor_qcif[] =
 /* 160X120 QQVGA*/
 static struct reginfo ov2655_qqvga[] =
 {
-
-    {0x300E, 0x34},
-    {0x3011, 0x01},
-    {0x3012, 0x10},
-    {0x302a, 0x02},
-    {0x302b, 0xE6},
-    {0x306f, 0x14},
-    {0x3362, 0x90},
-
-    {0x3070, 0x5d},
-    {0x3072, 0x5d},
-    {0x301c, 0x07},
-    {0x301d, 0x07},
-
-    {0x3020, 0x01},
-    {0x3021, 0x18},
-    {0x3022, 0x00},
-    {0x3023, 0x06},
-    {0x3024, 0x06},
-    {0x3025, 0x58},
-    {0x3026, 0x02},
-    {0x3027, 0x61},
-    {0x3088, 0x00},
-    {0x3089, 0xa0},
-    {0x308a, 0x00},
-    {0x308b, 0x78},
-    {0x3316, 0x64},
-    {0x3317, 0x25},
-    {0x3318, 0x80},
-    {0x3319, 0x08},
-    {0x331a, 0x0a},
-    {0x331b, 0x07},
-    {0x331c, 0x80},
-    {0x331d, 0x38},
-    {0x3100, 0x00},
-    {0x3302, 0x11},
-
-    {0x0, 0x0},
+    {0x00, 0x00},
 };
 
 
 
 static  struct reginfo ov2655_Sharpness_auto[] =
 {
-    {0x3306, 0x00},
+    {0x00, 0x00},
 };
 
 static  struct reginfo ov2655_Sharpness1[] =
 {
-    {0x3306, 0x08},
-    {0x3371, 0x00},
+    {0x00, 0x00},
 };
 
 static  struct reginfo ov2655_Sharpness2[][3] =
 {
     //Sharpness 2
-    {0x3306, 0x08},
-    {0x3371, 0x01},
+    {0x00, 0x00},
 };
 
 static  struct reginfo ov2655_Sharpness3[] =
 {
     //default
-    {0x3306, 0x08},
-    {0x332d, 0x02},
+    {0x00, 0x00},
 };
 static  struct reginfo ov2655_Sharpness4[]=
 {
     //Sharpness 4
-    {0x3306, 0x08},
-    {0x332d, 0x03},
+    {0x00, 0x00},
 };
 
 static  struct reginfo ov2655_Sharpness5[] =
 {
     //Sharpness 5
-    {0x3306, 0x08},
-    {0x332d, 0x04},
+    {0x00, 0x00},
 };
 #endif
 
@@ -437,27 +652,37 @@ static  struct reginfo sensor_ClrFmt_UYVY[]=
 #if CONFIG_SENSOR_WhiteBalance
 static  struct reginfo sensor_WhiteB_Auto[]=
 {
-
+    {0x42,0x76},
     {0x00, 0x00}
 };
 /* Cloudy Colour Temperature : 6500K - 8000K  */
 static  struct reginfo sensor_WhiteB_Cloudy[]=
 {
-
+        
+       {0x42 , 0x74},// [1] AWB enable  ¹¦ÄÜ¿ª¹ØAWB OFF  
+       {0x7a , 0x8c},  //AWB_R_gain
+       {0x7b , 0x50},  //AWB_G_gain
+       {0x7c , 0x40}, //AWB_B_gain
     {0x00, 0x00}
 };
 /* ClearDay Colour Temperature : 5000K - 6500K  */
 static  struct reginfo sensor_WhiteB_ClearDay[]=
 {
-    //Sunny
-
+    //Sunny 
+       {0x42 , 0x74},// [1] AWB enable  ¹¦ÄÜ¿ª¹ØAWB OFF  
+       {0x7a , 0x74},  //AWB_R_gain
+       {0x7b , 0x52},  //AWB_G_gain
+       {0x7c , 0x40}, //AWB_B_gain
     {0x00, 0x00}
 };
 /* Office Colour Temperature : 3500K - 5000K  */
 static  struct reginfo sensor_WhiteB_TungstenLamp1[]=
 {
     //Office
-  
+       {0x42 , 0x74},// [1] AWB enable  ¹¦ÄÜ¿ª¹ØAWB OFF  
+       {0x7a , 0x48},  //AWB_R_gain
+       {0x7b , 0x40},  //AWB_G_gain
+       {0x7c , 0x5c}, //AWB_B_gain  
     {0x00, 0x00}
 
 };
@@ -465,7 +690,10 @@ static  struct reginfo sensor_WhiteB_TungstenLamp1[]=
 static  struct reginfo sensor_WhiteB_TungstenLamp2[]=
 {
     //Home
-
+       {0x42 , 0x74},// [1] AWB enable  ¹¦ÄÜ¿ª¹ØAWB OFF  
+       {0x7a , 0x40},  //AWB_R_gain
+       {0x7b , 0x54},  //AWB_G_gain
+       {0x7c , 0x70}, //AWB_B_gain
     {0x00, 0x00}
 };
 static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
@@ -477,13 +705,21 @@ static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_W
 static  struct reginfo sensor_Brightness0[]=
 {
     // Brightness -2
+
+       {0xfe, 0x01},
+       {0x13, 0x68}, //AEC_target_Y  
+       {0xfe, 0x00},
+       {0xd5, 0xe0},// Luma_offset  
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Brightness1[]=
 {
     // Brightness -1
+       {0xfe, 0x01},
+       {0x13, 0x70}, //AEC_target_Y  
+       {0xfe, 0x00},
+       {0xd5, 0xf0},// Luma_offset 
 
     {0x00, 0x00}
 };
@@ -491,13 +727,22 @@ static  struct reginfo sensor_Brightness1[]=
 static  struct reginfo sensor_Brightness2[]=
 {
     //  Brightness 0
+                               
+       {0xfe, 0x01},
+       {0x13, 0x78}, //AEC_target_Y  48
+       {0xfe, 0x00},
+       {0xd5, 0x00},// Luma_offset  c0
 
-    {0x00, 0x00}
+       {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Brightness3[]=
 {
     // Brightness +1
+       {0xfe, 0x01},
+       {0x13, 0x80}, //AEC_target_Y  
+       {0xfe, 0x00},
+       {0xd5, 0x10},// Luma_offset  
 
     {0x00, 0x00}
 };
@@ -505,6 +750,10 @@ static  struct reginfo sensor_Brightness3[]=
 static  struct reginfo sensor_Brightness4[]=
 {
     //  Brightness +2
+        {0xfe, 0x01},
+       {0x13, 0x88}, //AEC_target_Y  
+       {0xfe, 0x00},
+       {0xd5, 0x20},// Luma_offset 
 
     {0x00, 0x00}
 };
@@ -512,8 +761,11 @@ static  struct reginfo sensor_Brightness4[]=
 static  struct reginfo sensor_Brightness5[]=
 {
     //  Brightness +3
-
-    {0x00, 0x00}
+      {0xfe, 0x01},
+       {0x13, 0x90}, //AEC_target_Y  
+       {0xfe, 0x00},
+       {0xd5, 0x30},// Luma_offset 
+       {0x00, 0x00}
 };
 static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
     sensor_Brightness4, sensor_Brightness5,NULL,
@@ -525,38 +777,50 @@ static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Bri
 static  struct reginfo sensor_Effect_Normal[] =
 {
 
+    {0x43, 0x00},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Effect_WandB[] =
 {
-
+       {0x43, 0x02},
+       {0xda, 0x50},
+       {0xdb, 0xe0},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Effect_Sepia[] =
 {
-
+       {0x43, 0x02},
+       {0xda, 0xd0},
+       {0xdb, 0x28},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Effect_Negative[] =
 {
     //Negative
-
+       {0x43, 0x01},
+       //{0xda, 0xc0},
+       //{0xdb, 0xc0},
     {0x00, 0x00}
 };
 static  struct reginfo sensor_Effect_Bluish[] =
 {
     // Bluish
+       {0x43, 0x02},
+       {0xda, 0x00},
+       {0xdb, 0x00},
 
-    {0x00, 0x00}
+       {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Effect_Green[] =
 {
     //  Greenish
-
+       {0x43, 0x02},
+       {0xda, 0xc0},
+       {0xdb, 0xc0},
     {0x00, 0x00}
 };
 static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
@@ -641,35 +905,40 @@ static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Sat
 static  struct reginfo sensor_Contrast0[]=
 {
     //Contrast -3
-  
+    {0xfe, 0x00},    
+    {0xd3, 0x2c}, 
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Contrast1[]=
 {
     //Contrast -2
-
+    {0xfe, 0x00},    
+    {0xd3, 0x30},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Contrast2[]=
 {
     // Contrast -1
-
+    {0xfe, 0x00},        
+    {0xd3, 0x38},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Contrast3[]=
 {
     //Contrast 0
-
+    {0xfe, 0x00},    
+    {0xd3, 0x40},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Contrast4[]=
 {
     //Contrast +1
-
+    {0xfe, 0x00},        
+    {0xd3, 0x48},
     {0x00, 0x00}
 };
 
@@ -677,14 +946,16 @@ static  struct reginfo sensor_Contrast4[]=
 static  struct reginfo sensor_Contrast5[]=
 {
     //Contrast +2
-
+    {0xfe, 0x00},    
+    {0xd3, 0x50},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_Contrast6[]=
 {
     //Contrast +3
-
+    {0xfe, 0x00},    
+    {0xd3, 0x58},
     {0x00, 0x00}
 };
 static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
@@ -695,13 +966,13 @@ static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contras
 #if CONFIG_SENSOR_Mirror
 static  struct reginfo sensor_MirrorOn[]=
 {
-
+    {0x29 , 0x01},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_MirrorOff[]=
 {
-
+    {0x29 , 0x01},
     {0x00, 0x00}
 };
 static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
@@ -709,13 +980,13 @@ static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,
 #if CONFIG_SENSOR_Flip
 static  struct reginfo sensor_FlipOn[]=
 {
-
+    {0x29 , 0x02},
     {0x00, 0x00}
 };
 
 static  struct reginfo sensor_FlipOff[]=
 {
-
+    {0x29 , 0x00},
     {0x00, 0x00}
 };
 static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
@@ -724,40 +995,24 @@ static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,}
 #if CONFIG_SENSOR_Scene
 static  struct reginfo sensor_SceneAuto[] =
 {
-#if 0                           /* ddl@rock-chips.com : */
-    {0x3014, 0x04},
-    {0x3015, 0x00},
-    {0x302e, 0x00},
-    {0x302d, 0x00},
-    {0x00, 0x00}
-#else
+                          /* ddl@rock-chips.com : */
+    {0xfe, 0x01},
+    {0x33, 0x00},
+    {0xfe, 0x00},
 
     {0x00, 0x00}
-#endif
+
 };
 
 static  struct reginfo sensor_SceneNight[] =
 {
-#if 1
-    //30fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,36Mzh pclk
 
+    //30fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,36Mzh pclk
+    {0xfe, 0x01},
+    {0x33, 0x20},
+    {0xfe, 0x00},
     {0x00, 0x00}
-#else
-    //15fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,18Mhz pclk
-    {0x300e, 0x34},
-    {0x3011, 0x01},
-    {0x302c, 0x00},
-    {0x3071, 0x00},
-    {0x3070, 0x5d},
-    {0x301c, 0x05},
-    {0x3073, 0x00},
-    {0x3072, 0x4d},
-    {0x301d, 0x07},
-    {0x3014, 0x0c},
-    {0x3015, 0x50},
-    {0x302e, 0x00},
-    {0x302d, 0x00},
-#endif
+
 };
 static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
 
@@ -985,6 +1240,42 @@ static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
 static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
 static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
 static int sensor_deactivate(struct i2c_client *client);
+static int sensor_write(struct i2c_client *client, u8 reg, u8 val);
+static int sensor_read(struct i2c_client *client, u8 reg, u8 *val);
+
+
+static u16 GC2015_read_shutter(struct i2c_client *client);  // add 2011-08-11 kim
+static void GC2015_set_shutter(struct i2c_client *client, u16 shutter);  // add 2011-08-11 kim
+
+
+////// add 2011-08-11 kim
+static u16 GC2015_read_shutter(struct i2c_client *client)
+{
+       u8 temp_reg1, temp_reg2;
+       u16 shutter;
+       
+       /* Backup the preview mode last shutter & sensor gain. */
+       sensor_read(client, 0x03, &temp_reg1);
+       sensor_read(client, 0x04, &temp_reg2);
+       
+       shutter = (temp_reg1 << 8) | (temp_reg2 & 0xFF);
+               
+       return shutter;
+}    /* GC2015_read_shutter */
+
+static void GC2015_set_shutter(struct i2c_client *client, u16 shutter)
+{
+       u16 temp_reg;
+
+       temp_reg = shutter * 10 / 20;   //// 
+
+       /*Set Shutter start*/
+       if(temp_reg < 1) temp_reg = 1;
+       sensor_write(client ,0x03 , (temp_reg>>8)&0xff);           
+       sensor_write(client ,0x04 , temp_reg&0xff); 
+       /*Set Shutter end*/
+}   
+//////// end add kim 
 
 static struct soc_camera_ops sensor_ops =
 {
@@ -1078,10 +1369,13 @@ static int sensor_task_lock(struct i2c_client *client, int lock)
                                preempt_enable();
                }
        }
-#endif
        return 0;
 sensor_task_lock_err:
-       return -1;
+       return -1;  
+#else
+    return 0;
+#endif
+
 }
 
 #if 0
@@ -1187,8 +1481,9 @@ static int sensor_write_array(struct i2c_client *client, struct reginfo *regarra
 {
     int err = 0, cnt;
     int i = 0;
-       int j = 0;
+    #if CONFIG_SENSOR_I2C_RDWRCHK
        char valchk;
+    #endif
 
        cnt = 0;
        if (sensor_task_lock(client, 1) < 0)
@@ -1222,6 +1517,7 @@ sensor_write_array_end:
        sensor_task_lock(client,0);
        return err;
 }
+#if CONFIG_SENSOR_I2C_RDWRCHK
 static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)
 {
     int cnt;
@@ -1240,6 +1536,7 @@ static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regar
     }
     return 0;
 }
+#endif
 static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)
 {
        struct soc_camera_link *icl = to_soc_camera_link(icd);
@@ -1542,6 +1839,8 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
        struct soc_camera_device *icd = client->dev.platform_data;
     struct reginfo *winseqe_set_addr=NULL;
     int ret=0, set_w,set_h;
+       
+       u32 gc2015_shutter;
 
        SENSOR_TR("sensor_s_fmt\n");
        if (sensor->info_priv.pixfmt != pix->pixelformat) {
@@ -1600,25 +1899,32 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
     else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
     {
         winseqe_set_addr = sensor_svga;
-        set_w = 800;
+        set_w = 800-32;
         set_h = 600;
     }
        else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
     {
+               gc2015_shutter = GC2015_read_shutter(client);  // add 2011-08-11 kim
+               
         winseqe_set_addr = sensor_xga;
         set_w = 1024;
         set_h = 768;
     }
     else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
     {
+               gc2015_shutter = GC2015_read_shutter(client);  // add 2011-08-11 kim
+    
         winseqe_set_addr = sensor_sxga;
         set_w = 1280;
         set_h = 1024;
     }
     else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
     {
+
+               gc2015_shutter = GC2015_read_shutter(client); // add 2011-08-11 kim 
+               
         winseqe_set_addr = sensor_uxga;
-        set_w = 1600;
+        set_w = 1600-32;
         set_h = 1200;
     }
     else
@@ -1644,6 +1950,9 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
         }
         #endif
         ret |= sensor_write_array(client, winseqe_set_addr);
+
+               if(set_w >= 1024) GC2015_set_shutter(client, gc2015_shutter); // add 2011-08-11 kim
+                       
         if (ret != 0) {
             SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
             #if CONFIG_SENSOR_Flash
index f0607236595c973e28b5af344e21a92f0d9080f6..a1a3c140e5103230b3ed647418f72efb22943edf 100755 (executable)
@@ -280,7 +280,8 @@ enum {
        V4L2_IDENT_M52790 = 52790,
 
 
-    V4L2_IDENT_GT2005 = 64100,       /* ddl@rock-chips.com : GT2005 support */
+    V4L2_IDENT_GT2005 = 64099,       /* ddl@rock-chips.com : GT2005 support */
+    V4L2_IDENT_GC0307 = 64100,      /* ddl@rock-chips.com : GC0308 support */
     V4L2_IDENT_GC0308 = 64101,      /* ddl@rock-chips.com : GC0308 support */
     V4L2_IDENT_GC0309 = 64102,      /* ddl@rock-chips.com : GC0309 support */
     V4L2_IDENT_SIV120B = 64103,      /* ddl@rock-chips.com : siv120b support */