camera rk30:update to v0.x.10,wake up vb when cif have't receive data etc.
authorroot <root@zyc-desktop.(none)>
Tue, 15 May 2012 04:30:32 +0000 (12:30 +0800)
committerroot <root@zyc-desktop.(none)>
Tue, 15 May 2012 04:30:32 +0000 (12:30 +0800)
24 files changed:
drivers/media/video/Kconfig [changed mode: 0644->0755]
drivers/media/video/gc0307.c
drivers/media/video/gc0308.c
drivers/media/video/gc0309.c
drivers/media/video/gc2015.c
drivers/media/video/gt2005.c
drivers/media/video/hi253.c
drivers/media/video/hi704.c
drivers/media/video/mt9d112.c
drivers/media/video/mt9d113.c
drivers/media/video/mt9p111.c [changed mode: 0644->0755]
drivers/media/video/mt9t111.c
drivers/media/video/nt99250.c
drivers/media/video/ov2640_rk.c
drivers/media/video/ov2655.c
drivers/media/video/ov2659.c
drivers/media/video/ov5640.c
drivers/media/video/ov5642.c
drivers/media/video/ov7675.c
drivers/media/video/ov7690.c [changed mode: 0644->0755]
drivers/media/video/rk30_camera_oneframe.c
drivers/media/video/s5k6aa.c [changed mode: 0644->0755]
drivers/media/video/sid130B.c
drivers/media/video/siv120b.c

old mode 100644 (file)
new mode 100755 (executable)
index 59734e6..6849392
@@ -821,29 +821,56 @@ config SOC_CAMERA_MT9T111
        depends on SOC_CAMERA && I2C
        help
          This driver supports MT9T111 cameras from Micron for rockchip.
+
+config MT9T111_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_MT9T111
+       bool "MT9T111 user defined init series"
+       default n
+
 config SOC_CAMERA_MT9P111
        tristate "mt9p111 support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This driver supports MT9P111 cameras from Micron for rockchip.
+         
+config MT9P111_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_MT9P111
+       bool "MT9P111 user defined init series"
+       default n
+
 config SOC_CAMERA_MT9D112
        tristate "mt9d112 support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This driver supports MT9D112 cameras from Micron for rockchip
 
+config MT9D112_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_MT9D112
+       bool "MT9D112 user defined init series"
+       default n
+
 config SOC_CAMERA_MT9D113
        tristate "mt9d113 support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This driver supports MT9D113 cameras from Micron for rockchip
 
+config MT9D113_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_MT9D113
+       bool "MT9D113 user defined init series"
+       default n
+
 config SOC_CAMERA_MT9T112
        tristate "mt9t112 support"
        depends on SOC_CAMERA && I2C
        help
          This driver supports MT9T112 cameras from Aptina.
 
+config MT9T112_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_MT9T112
+       bool "MT9T112 user defined init series"
+       default n
+
 config SOC_CAMERA_MT9V022
        tristate "mt9v022 support"
        depends on SOC_CAMERA && I2C
@@ -851,6 +878,11 @@ config SOC_CAMERA_MT9V022
        help
          This driver supports MT9V022 cameras from Micron
 
+config MT9V022_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_MT9V022
+       bool "MT9V022 user defined init series"
+       default n
+
 config SOC_CAMERA_RJ54N1
        tristate "rj54n1cb0c support"
        depends on SOC_CAMERA && I2C
@@ -874,13 +906,17 @@ config SOC_CAMERA_OV2640
        depends on SOC_CAMERA && I2C
        help
          This is a ov2640 camera driver
-
 config SOC_CAMERA_OV6650
        tristate "ov6650 sensor support"
        depends on SOC_CAMERA && I2C
        ---help---
          This is a V4L2 SoC camera driver for the OmniVision OV6650 sensor
 
+config OV6650_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV6650
+       bool "OV6650 user defined init series"
+       default n
+
 config SOC_CAMERA_OV772X
        tristate "ov772x camera support"
        depends on SOC_CAMERA && I2C
@@ -893,23 +929,43 @@ config SOC_CAMERA_OV7675
        help
          This is a ov7675 camera driver for rockchip
 
+config OV7675_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV7675
+       bool "OV7675 user defined init series"
+       default n
+
 config SOC_CAMERA_OV2655
        tristate "ov2655 camera support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a ov2655 camera driver for rockchip
 
+config OV2655_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV2655
+       bool "OV2655 user defined init series"
+       default n
+
 config SOC_CAMERA_OV2659
        tristate "ov2659 camera support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a ov2659 camera driver for rockchip
          
+config OV2659_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV2659
+       bool "OV2659 user defined init series"
+       default n
+
 config SOC_CAMERA_OV7690
        tristate "ov7690 camera support for rockchip"
        depends on SOC_CAMERA && I2C
        help
-         This is a ov7690 camera driver for rockchip     
+         This is a ov7690 camera driver for rockchip   
+
+config OV7690_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV7690
+       bool "OV7690 user defined init series"
+       default n
 
 config SOC_CAMERA_OV9650
        tristate "ov9650 camera support for rockchip"
@@ -917,17 +973,33 @@ config SOC_CAMERA_OV9650
        help
          This is a ov9650 camera driver for rockchip
 
+config OV9650_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV9650
+       bool "OV9650 user defined init series"
+       default n
+
 config SOC_CAMERA_OV2640_RK
        tristate "ov2640 camera support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a ov2640 camera driver for rockchip
+         
+config OV2640_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV2640_RK
+       bool "OV2640 user defined init series"
+       default n
 
 config SOC_CAMERA_OV3640
        tristate "ov3640 camera support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a ov3640 camera driver for rockchip
+         
+config OV3640_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV3640
+       bool "OV3640 user defined init series"
+       default n
+
 choice
        prompt "OV3640 Module Focus select"
        depends on SOC_CAMERA_OV3640
@@ -946,6 +1018,12 @@ config SOC_CAMERA_OV5642
        depends on SOC_CAMERA && I2C
        help
          This is a ov5642 camera driver for rockchip
+
+config OV5642_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV5642
+       bool "OV5642 user defined init series"
+       default n
+
 choice
        prompt "OV5642 Module Focus select"
        depends on SOC_CAMERA_OV5642
@@ -964,6 +1042,12 @@ config SOC_CAMERA_OV5640
        depends on SOC_CAMERA && I2C
        help
          This is a ov5640 camera driver for rockchip
+
+config OV5640_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV5640
+       bool "OV5640 user defined init series"
+       default n
+
 choice
        prompt "OV5640 Module Focus select"
        depends on SOC_CAMERA_OV5640
@@ -1001,29 +1085,55 @@ config SOC_CAMERA_S5K6AA
        help
          This is a samsung S5K6AA camera driver for rockchip
 
+config S5K6AA_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_S5K6AA
+       bool "S5K6AA user defined init series"
+       default n
+
 config SOC_CAMERA_GT2005
        tristate "GT2005 support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a GT2005 camera driver for rockchip
 
+config GT2005_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_GT2005
+       bool "GT2005 user defined init series"
+       default n
+
 config SOC_CAMERA_GC0307
        tristate "GC0307 support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a GC0307 camera driver for rockchip      
 
+config GC0307_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_GC0307
+       bool "GC0307 user defined init series"
+       default n
+
 config SOC_CAMERA_GC0308
        tristate "GC0308 support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a GC0308 camera driver for rockchip
 
+config GC0308_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_GC0308
+       bool "GC0308 user defined init series"
+       default n
+
 config SOC_CAMERA_GC0309
        tristate "GC0309 support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a GC0309 camera driver for rockchip
+
+config GC0309_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_GC0309
+       bool "GC0309 user defined init series"
+       default n
+
 config SOC_CAMERA_GC0309_FOR_TD8801
        tristate "GC0309 support for td8801"
        depends on SOC_CAMERA && I2C
@@ -1036,48 +1146,88 @@ config SOC_CAMERA_GC2015
        help
          This is a GC2015 camera driver for rockchip
 
+config GC2015_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_GC2015
+       bool "GC2015 user defined init series"
+       default n
+
 config SOC_CAMERA_HI253
        tristate "HI253 support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a HI253 camera driver for rockchip
 
+config HI253_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_HI253
+       bool "HI253 user defined init series"
+       default n
+
 config SOC_CAMERA_HI704
        tristate "HI704 support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a HI704 camera driver for rockchip
 
+config HI704_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_HI704
+       bool "HI704 user defined init series"
+       default n
+
 config SOC_CAMERA_SIV120B
        tristate "siv120b support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a SIV120B camera driver for rockchip
 
+config SIV120B_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_SIV120B
+       bool "SIV120B user defined init series"
+       default n
+
 config SOC_CAMERA_SID130B
        tristate "sid130b support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a SID130B camera driver for rockchip
 
+config SID130B_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_SID130B
+       bool "SID130B user defined init series"
+       default n
+
 config SOC_CAMERA_NT99250
        tristate "NT99250 support for rockchip"
        depends on SOC_CAMERA && I2C
        help
          This is a NT99250 camera driver for rockchip
 
+config NT99250_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_NT99250
+       bool "NT99250 user defined init series"
+       default n
+
 config SOC_CAMERA_OV9640
        tristate "ov9640 camera support"
        depends on SOC_CAMERA && I2C
        help
          This is a ov9640 camera driver
 
+config OV9640_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV9640
+       bool "OV9640 user defined init series"
+       default n
+
 config SOC_CAMERA_OV9740
        tristate "ov9740 camera support"
        depends on SOC_CAMERA && I2C
        help
          This is a ov9740 camera driver
 
+config OV9740_USER_DEFINED_SERIES
+       depends on SOC_CAMERA_OV9740
+       bool "OV9740 user defined init series"
+       default n
+
 config MX1_VIDEO
        bool
 
index bacf9b53e697fd59df2ce0d581c9e2fa3e38bca3..8a62bba1619143c2e75ccf5a395f7bae222aca01 100755 (executable)
@@ -100,6 +100,18 @@ struct reginfo
     u8 val;
 };
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_GC0307_USER_DEFINED_SERIES
+#include "gc0307_user_series.c"
+#else
 /* init 640X480 VGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -628,7 +640,7 @@ static struct reginfo sensor_qcif[] =
        {0xff, 0xff},
 
 };
-
+#endif
 static  struct reginfo sensor_ClrFmt_YUYV[]=
 {
        {0xff, 0xff},
@@ -1099,7 +1111,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1601,6 +1613,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1614,6 +1631,13 @@ sensor_power_end:
        return ret;
 }
 
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);;
@@ -1725,6 +1749,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -2894,11 +2921,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index e4e5ed9d54ad6d0a3892d68985faa8a4b403ade5..4a8067514c85f9e6bf8395aa9fe348f8451da0c9 100755 (executable)
@@ -101,6 +101,18 @@ struct reginfo
     u8 val;
 };
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_GC0308_USER_DEFINED_SERIES
+#include "gc0308_user_series.c"
+#else
 /* init 640X480 VGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -602,7 +614,7 @@ static struct reginfo sensor_qcif[] =
 {
     {0x00,0x00}
 };
-
+#endif
 static  struct reginfo sensor_ClrFmt_YUYV[]=
 {
     {0x00, 0x00}
@@ -1007,7 +1019,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1476,6 +1488,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1489,6 +1506,13 @@ sensor_power_end:
        return ret;
 }
 
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1581,6 +1605,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -2732,11 +2759,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index 36e31aeee78f3155f4439a00be5cde0656b6252f..4c1e6938f0d9e9fbf1faa3aa7682cf27544793dc 100755 (executable)
@@ -99,7 +99,18 @@ struct reginfo
     u8 reg;
     u8 val;
 };
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
 
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_GC0309_USER_DEFINED_SERIES
+#include "gc0309_user_series.c"
+#else
 /* init SVGA preview */
 static struct reginfo sensor_init_data[] =
 {
@@ -462,7 +473,7 @@ static  struct reginfo sensor_qvga[] =
 /* 176X144 QCIF*/
 static struct reginfo sensor_qcif[] =
 {};
-
+#endif
 
 static  struct reginfo sensor_ClrFmt_YUYV[]=
 {
@@ -951,7 +962,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1433,6 +1444,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1445,6 +1461,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1550,6 +1574,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -2674,11 +2701,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index f98bf8e16c45df52531d55400d27a9fdb7128dd2..b388c88e5657ed17c623d76301e39fde71e4d632 100755 (executable)
@@ -100,6 +100,18 @@ struct reginfo
     u8 val;
 };
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_GC2015_USER_DEFINED_SERIES
+#include "gc2015_user_series.c"
+#else
 /* init SVGA preview */
 static struct reginfo sensor_init_data[] =
 
@@ -592,6 +604,7 @@ static  struct reginfo sensor_qvga[] =
 /* 176X144 QCIF*/
 static struct reginfo sensor_qcif[] =
 {};
+#endif
 #if 0
 /* 160X120 QQVGA*/
 static struct reginfo ov2655_qqvga[] =
@@ -1068,7 +1081,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1585,6 +1598,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1597,6 +1615,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1715,6 +1741,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -2906,11 +2935,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index 5eeb8d5a8ffd7cecb6ec2ac75cc6a19cf149388f..9658a4d09adb0d616146e5c50eb491fe36844b2b 100755 (executable)
@@ -100,6 +100,18 @@ struct reginfo
     u8 val;
 };
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_GT2005_USER_DEFINED_SERIES
+#include "gt2005_user_series.c"
+#else
 /* init 352X288 SVGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -1160,6 +1172,7 @@ static struct reginfo sensor_qcif[] =
        
     {0x0, 0x0},
 };
+#endif
 #if 0
 /* 160X120 QQVGA*/
 static struct reginfo gt2005_qqvga[] =
@@ -1760,7 +1773,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -2231,6 +2244,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -2243,7 +2261,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
-
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -2362,6 +2386,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -3541,11 +3568,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index aef2d41b4d733647317f57ffdf13f8d721bb7613..42a6724a748a6134a8ed6afa9c3a1bacf96a77ed 100755 (executable)
@@ -101,6 +101,18 @@ struct reginfo
     u8 val;
 };
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_HI253_USER_DEFINED_SERIES
+#include "hi253_user_series.c"
+#else
 /* init SVGA preview */
 static struct reginfo sensor_init_data[] =
 {
@@ -1242,7 +1254,7 @@ static  struct reginfo sensor_qvga[] =
 static struct reginfo sensor_qcif[] =
 {};
 
-
+#endif
 static  struct reginfo sensor_ClrFmt_YUYV[]=
 {
 
@@ -1682,7 +1694,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -2143,6 +2155,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -2155,6 +2172,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -2264,6 +2289,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -3391,11 +3419,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index b52826dc87fe68a5be3c195e3fd0038fde050be8..5470743c07fb90af091c47f4c19b0f0931431ba4 100755 (executable)
@@ -101,6 +101,18 @@ struct reginfo
     u8 val;
 };
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_HI704_USER_DEFINED_SERIES
+#include "hi704_user_series.c"
+#else
 /* init SVGA preview */
 static struct reginfo sensor_init_data[] =
 {
@@ -665,7 +677,7 @@ static struct reginfo sensor_qcif[] =
        {END_REG, END_REG},
 };
 
-
+#endif
 static  struct reginfo sensor_ClrFmt_YUYV[]=
 {
 
@@ -1139,7 +1151,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1621,6 +1633,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1633,6 +1650,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1742,6 +1767,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -2845,11 +2873,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index 84736231015871158b86b2891372bd15f6b165e8..4cd7ed5414f4408a61261bc3c957785544783693 100755 (executable)
@@ -108,6 +108,21 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define SENSOR_AF_MODE_CLOSE       5
 #endif
 #define SENSOR_CCM_ONLY
+
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_MT9D112_USER_DEFINED_SERIES
+#include "mt9d112_user_series.c"
+#else
+
+
 /* init 640X480 VGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -702,6 +717,8 @@ static struct reginfo sensor_qcif[] =
 {
        {SEQUENCE_END, 0x00}
 };
+
+#endif
 #if 0
 /* 160X120 QQVGA*/
 static struct reginfo ov2655_qqvga[] =
@@ -1184,7 +1201,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1755,6 +1772,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
                        break;
                }
@@ -1768,6 +1790,15 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
+
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1888,6 +1919,10 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
 
@@ -3211,11 +3246,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index 363aacd486e8e2c63410cad3c63fa16fed35b493..fdb34d42015bbb11fc8e7e57facb4eebefe70af2 100755 (executable)
@@ -107,6 +107,19 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define SENSOR_AF_MODE_CLOSE       5
 #endif
 
+
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_MT9D113_USER_DEFINED_SERIES
+#include "mt9d113_user_series.c"
+#else
 /* init 800x600 SVGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -592,6 +605,7 @@ static struct reginfo sensor_qcif[] =
        {SEQUENCE_END, 0x00}
 };
 
+#endif
 static  struct reginfo sensor_Preview2Capture[]=
 {
        //capture2preview
@@ -913,7 +927,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1549,6 +1563,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
                        break;
                }
@@ -1562,6 +1581,15 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
+
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1695,6 +1723,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
 
@@ -2960,11 +2991,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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(&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));                                      
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
old mode 100644 (file)
new mode 100755 (executable)
index 99bfc78..ff5682c
@@ -117,6 +117,19 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define SENSOR_AF_MODE_CLOSE       5
 #endif
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_MT9P111_USER_DEFINED_SERIES
+#include "mt9p111_user_series.c"
+#else
+
 /* init 640X480 VGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -1538,7 +1551,7 @@ static struct reginfo sensor_qcif[] =
 {
        {SEQUENCE_END, 0x00}
 };
-
+#endif
 static  struct reginfo sensor_Preview2Capture[]=
 {
        //capture2preview
@@ -1950,7 +1963,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -2846,6 +2859,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
                        break;
                }
@@ -2859,6 +2877,15 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
+
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -3052,6 +3079,10 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #endif
 #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);
@@ -4667,11 +4698,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index bb59b180e6ea085e6b0665a54d70f5944cd6da87..02c27ab86816faba3c45db4bf2afabe3b641ffed 100755 (executable)
@@ -113,6 +113,19 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define SENSOR_AF_MODE_CLOSE       5
 #endif
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_MT9T111_USER_DEFINED_SERIES
+#include "mt9t111_user_series.c"
+#else
+
 /* init 640X480 VGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -5261,7 +5274,7 @@ static struct reginfo sensor_qcif[] =
 {
        {SEQUENCE_END, 0x00}
 };
-
+#endif
 static  struct reginfo sensor_Preview2Capture[]=
 {
        //capture2preview
@@ -5957,7 +5970,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -6679,6 +6692,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
                        break;
                }
@@ -6692,6 +6710,16 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
+
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -6817,6 +6845,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        {
                sensor->info_priv.flash = qctrl->default_value;
        }
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
  
@@ -8292,10 +8323,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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(&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));                                      
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index 56f80d267d704b53513b5e22de36503ef7a9b951..68a64ce19e7911ce33789258929ae4a058f80db7 100755 (executable)
@@ -100,6 +100,18 @@ struct reginfo
     u8 val;
 };
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_NT99250_USER_DEFINED_SERIES
+#include "NT99250_user_series.c"
+#else
 /* init 352X288 SVGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -592,7 +604,7 @@ static struct reginfo sensor_qcif[] =
 {
     {0x0, 0x0},
 };
-
+#endif
 
 static  struct reginfo sensor_ClrFmt_YUYV[]=
 {
@@ -967,7 +979,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1432,6 +1444,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1444,6 +1461,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1565,6 +1590,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -2733,11 +2761,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index 090ac3e2d81b678c31fc5879f619cf9570c5876f..af72cf5e581dbce8141e19cc8584deb88e828569 100755 (executable)
 #include <linux/videodev2.h>\r
-#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 <linux/slab.h>\r
+#include <linux/i2c.h>\r
+#include <linux/log2.h>\r
+#include <linux/platform_device.h>\r
+#include <linux/delay.h>\r
+#include <linux/circ_buf.h>\r
+#include <linux/miscdevice.h>\r
+#include <media/v4l2-common.h>\r
+#include <media/v4l2-chip-ident.h>\r
+#include <media/soc_camera.h>\r
 #include <plat/rk_camera.h>\r
-
-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_OV2640
-#define SENSOR_V4L2_IDENT V4L2_IDENT_OV2640
-#define SENSOR_ID 0x2642
-#define SENSOR_ID1 0x2641
-#define SENSOR_MIN_WIDTH    640
-#define SENSOR_MIN_HEIGHT   480
-#define SENSOR_MAX_WIDTH    1600
-#define SENSOR_MAX_HEIGHT   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_MBUS_FMT_YUYV8_2X8
-
-#define CONFIG_SENSOR_WhiteBalance     1
-#define CONFIG_SENSOR_Brightness       0
-#define CONFIG_SENSOR_Contrast      0
-#define CONFIG_SENSOR_Saturation    0
-#define CONFIG_SENSOR_Effect        0
-#define CONFIG_SENSOR_Scene         0
-#define CONFIG_SENSOR_DigitalZoom   0
-#define CONFIG_SENSOR_Focus         0
-#define CONFIG_SENSOR_Exposure      0
+\r
+static int debug;\r
+module_param(debug, int, S_IRUGO|S_IWUSR);\r
+\r
+#define dprintk(level, fmt, arg...) do {                       \\r
+       if (debug >= level)                                     \\r
+       printk(KERN_WARNING fmt , ## arg); } while (0)\r
+\r
+#define SENSOR_TR(format, ...) printk(KERN_ERR format, ## __VA_ARGS__)\r
+#define SENSOR_DG(format, ...) dprintk(1, format, ## __VA_ARGS__)\r
+\r
+\r
+#define _CONS(a,b) a##b\r
+#define CONS(a,b) _CONS(a,b)\r
+\r
+#define __STR(x) #x\r
+#define _STR(x) __STR(x)\r
+#define STR(x) _STR(x)\r
+\r
+#define MIN(x,y)   ((x<y) ? x: y)\r
+#define MAX(x,y)    ((x>y) ? x: y)\r
+\r
+/* Sensor Driver Configuration */\r
+#define SENSOR_NAME RK29_CAM_SENSOR_OV2640\r
+#define SENSOR_V4L2_IDENT V4L2_IDENT_OV2640\r
+#define SENSOR_ID 0x2642\r
+#define SENSOR_ID1 0x2641\r
+#define SENSOR_MIN_WIDTH    640\r
+#define SENSOR_MIN_HEIGHT   480\r
+#define SENSOR_MAX_WIDTH    1600\r
+#define SENSOR_MAX_HEIGHT   1200\r
+#define SENSOR_INIT_WIDTH      640                     /* Sensor pixel size for sensor_init_data array */\r
+#define SENSOR_INIT_HEIGHT  480\r
+#define SENSOR_INIT_WINSEQADR sensor_vga\r
+#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8\r
+\r
+#define CONFIG_SENSOR_WhiteBalance     1\r
+#define CONFIG_SENSOR_Brightness       0\r
+#define CONFIG_SENSOR_Contrast      0\r
+#define CONFIG_SENSOR_Saturation    0\r
+#define CONFIG_SENSOR_Effect        0\r
+#define CONFIG_SENSOR_Scene         0\r
+#define CONFIG_SENSOR_DigitalZoom   0\r
+#define CONFIG_SENSOR_Focus         0\r
+#define CONFIG_SENSOR_Exposure      0\r
 #define CONFIG_SENSOR_Flash         1\r
-#define CONFIG_SENSOR_Mirror        0
-#define CONFIG_SENSOR_Flip          0
-
-#define CONFIG_SENSOR_I2C_SPEED     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 CONFIG_SENSOR_Mirror        0\r
+#define CONFIG_SENSOR_Flip          0\r
+\r
+#define CONFIG_SENSOR_I2C_SPEED     250000       /* Hz */\r
+/* Sensor write register continues by preempt_disable/preempt_enable for current process not be scheduled */\r
+#define CONFIG_SENSOR_I2C_NOSCHED   0\r
+#define CONFIG_SENSOR_I2C_RDWRCHK   0\r
+\r
+#define SENSOR_BUS_PARAM  (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |\\r
+                          SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |\\r
+                          SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8  |SOCAM_MCLK_24MHZ)\r
+\r
+#define COLOR_TEMPERATURE_CLOUDY_DN  6500\r
+#define COLOR_TEMPERATURE_CLOUDY_UP    8000\r
+#define COLOR_TEMPERATURE_CLEARDAY_DN  5000\r
+#define COLOR_TEMPERATURE_CLEARDAY_UP    6500\r
+#define COLOR_TEMPERATURE_OFFICE_DN     3500\r
+#define COLOR_TEMPERATURE_OFFICE_UP     5000\r
+#define COLOR_TEMPERATURE_HOME_DN       2500\r
+#define COLOR_TEMPERATURE_HOME_UP       3500\r
+\r
+#define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))\r
+#define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)\r
+\r
 #define SENSOR_AF_IS_ERR    (0x00<<0)\r
 #define SENSOR_AF_IS_OK                (0x01<<0)\r
 #define SENSOR_INIT_IS_ERR   (0x00<<28)\r
 #define SENSOR_INIT_IS_OK    (0x01<<28)\r
-struct reginfo
-{
-    u8 reg;
-    u8 val;
-};
-
-/* init 800*600 SVGA */
-static struct reginfo sensor_init_data[] =
-{
-#if 1
-    {0xff,0x01},
-    {0x12,0x80},
-    {0xff,0x00},
-    {0x2c,0xff},
-    {0x2e,0xdf},
-    {0xff,0x01},
-
-    {0x03,0x4f},// 0x8f peak
-    {0x0f,0x4b},
-
-
-    {0x3c,0x32},
-    {0x11,0x00},
-    {0x09,0x02},
-    {0x04,0x28},//b7,b6 directs
-    {0x13,0xe5},
-    {0x14,0x28}, //0x48 peak
-    {0x2c,0x0c},
-    {0x33,0x78},
-    {0x3a,0x33},
-    {0x3b,0xfB},
-    {0x3e,0x00},
-    {0x43,0x11},
-    {0x16,0x10},
-    {0x39,0x02},
-    {0x35,0x88},
-    {0x22,0x09},
-    {0x37,0x40},
-    {0x23,0x00},
-    {0x34,0xa0},
-    {0x36,0x1a},
-    {0x06,0x02},
-    {0x07,0xc0},
-    {0x0d,0xb7},
-    {0x0e,0x01},
-    {0x4c,0x00},
-    {0x4a,0x81},
-    {0x21,0x99},
-    //aec
-    //{0x24,0x58},
-    //{0x25,0x50},
-    //{0x26,0x92},
-    
+struct reginfo\r
+{\r
+    u8 reg;\r
+    u8 val;\r
+};\r
+\r
+//flash off in fixed time to prevent from too hot , zyc\r
+struct  flash_timer{\r
+    struct soc_camera_device *icd;\r
+       struct hrtimer timer;\r
+};\r
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);\r
+\r
+static struct  flash_timer flash_off_timer;\r
+//for user defined if user want to customize the series , zyc\r
+#if CONFIG_OV2640_USER_DEFINED_SERIES\r
+#include "ov2640_user_series.c"\r
+#else\r
+/* init 800*600 SVGA */\r
+static struct reginfo sensor_init_data[] =\r
+{\r
+#if 1\r
+    {0xff,0x01},\r
+    {0x12,0x80},\r
+    {0xff,0x00},\r
+    {0x2c,0xff},\r
+    {0x2e,0xdf},\r
+    {0xff,0x01},\r
+\r
+    {0x03,0x4f},// 0x8f peak\r
+    {0x0f,0x4b},\r
+\r
+\r
+    {0x3c,0x32},\r
+    {0x11,0x00},\r
+    {0x09,0x02},\r
+    {0x04,0x28},//b7,b6 directs\r
+    {0x13,0xe5},\r
+    {0x14,0x28}, //0x48 peak\r
+    {0x2c,0x0c},\r
+    {0x33,0x78},\r
+    {0x3a,0x33},\r
+    {0x3b,0xfB},\r
+    {0x3e,0x00},\r
+    {0x43,0x11},\r
+    {0x16,0x10},\r
+    {0x39,0x02},\r
+    {0x35,0x88},\r
+    {0x22,0x09},\r
+    {0x37,0x40},\r
+    {0x23,0x00},\r
+    {0x34,0xa0},\r
+    {0x36,0x1a},\r
+    {0x06,0x02},\r
+    {0x07,0xc0},\r
+    {0x0d,0xb7},\r
+    {0x0e,0x01},\r
+    {0x4c,0x00},\r
+    {0x4a,0x81},\r
+    {0x21,0x99},\r
+    //aec\r
+    //{0x24,0x58},\r
+    //{0x25,0x50},\r
+    //{0x26,0x92},\r
+    \r
     //{0x24, 0x70},\r
     //{0x25, 0x60},\r
     //{0x26, 0xa4},    \r
-    {0x24, 0x48},
-    {0x25, 0x38},
-    {0x26, 0x82},//82 
-    
-    {0x5c,0x00},
-    {0x63,0x00},
-    {0x46,0x3f},
-    {0x0c,0x3c},
-    {0x61,0x70},
-    {0x62,0x80},
-    {0x7c,0x05},
-    {0x20,0x80},
-    {0x28,0x30},
-    {0x6c,0x00},
-    {0x6d,0x80},
-    {0x6e,0x00},
-    {0x70,0x02},
-    {0x71,0x94},
-    {0x73,0xc1},
-    {0x3d,0x34},
-    {0x5a,0x57},
-    {0x4f,0xbb},
-    {0x50,0x9c},
-    {0xff,0x00},
-    {0xe5,0x7f},
-    {0xf9,0xc0},
-    {0x41,0x24},
-    {0xe0,0x14},
-    {0x76,0xff},
-    {0x33,0xa0},
-    {0x42,0x20},
-    {0x43,0x18},
-    {0x4c,0x00},
-    {0x87,0xd0},
-    {0x88,0x3f},
-    {0xd7,0x03},
-    {0xd9,0x10},
-    {0xd3,0x82},
-    {0xc8,0x08},
-    {0xc9,0x80},
+    {0x24, 0x48},\r
+    {0x25, 0x38},\r
+    {0x26, 0x82},//82 \r
+    \r
+    {0x5c,0x00},\r
+    {0x63,0x00},\r
+    {0x46,0x3f},\r
+    {0x0c,0x3c},\r
+    {0x61,0x70},\r
+    {0x62,0x80},\r
+    {0x7c,0x05},\r
+    {0x20,0x80},\r
+    {0x28,0x30},\r
+    {0x6c,0x00},\r
+    {0x6d,0x80},\r
+    {0x6e,0x00},\r
+    {0x70,0x02},\r
+    {0x71,0x94},\r
+    {0x73,0xc1},\r
+    {0x3d,0x34},\r
+    {0x5a,0x57},\r
+    {0x4f,0xbb},\r
+    {0x50,0x9c},\r
+    {0xff,0x00},\r
+    {0xe5,0x7f},\r
+    {0xf9,0xc0},\r
+    {0x41,0x24},\r
+    {0xe0,0x14},\r
+    {0x76,0xff},\r
+    {0x33,0xa0},\r
+    {0x42,0x20},\r
+    {0x43,0x18},\r
+    {0x4c,0x00},\r
+    {0x87,0xd0},\r
+    {0x88,0x3f},\r
+    {0xd7,0x03},\r
+    {0xd9,0x10},\r
+    {0xd3,0x82},\r
+    {0xc8,0x08},\r
+    {0xc9,0x80},\r
  //\r
     //{0xff,0x00}, //added by peak on 20120409\r
-    {0x7c,0x00},
-    {0x7d,0x02},//0x00 peak//0x07,È·±£ÔÚ±ðµÄÎļþÀïû±»¸²¸Ç
-    {0x7c,0x03},
-    {0x7d,0x28},//0x48//0x40 Õâ¸öÖµÒѾ­ºÜСÁË,³ý·ÇÄãÔÚ±ðµÄÎļþÀïÓÖдÁË
-    {0x7d,0x28},//0x48 peak//0x40 Õâ¸öÖµÒѾ­ºÜСÁË,³ý·ÇÄãÔÚ±ðµÄÎļþÀïÓÖдÁË
+    {0x7c,0x00},\r
+    {0x7d,0x02},//0x00 peak//0x07,È·±£ÔÚ±ðµÄÎļþÀïû±»¸²¸Ç\r
+    {0x7c,0x03},\r
+    {0x7d,0x28},//0x48//0x40 Õâ¸öÖµÒѾ­ºÜСÁË,³ý·ÇÄãÔÚ±ðµÄÎļþÀïÓÖдÁË\r
+    {0x7d,0x28},//0x48 peak//0x40 Õâ¸öÖµÒѾ­ºÜСÁË,³ý·ÇÄãÔÚ±ðµÄÎļþÀïÓÖдÁË\r
 \r
    // removed by peak on 20120409\r
 \r
-   {0x7c,0x08},  
-    {0x7d,0x20},
-    {0x7d,0x10},//0x10
-    {0x7d,0x0e},//0x0e
+   {0x7c,0x08},  \r
+    {0x7d,0x20},\r
+    {0x7d,0x10},//0x10\r
+    {0x7d,0x0e},//0x0e\r
 \r
 //contrast added by peak on 20120409\r
           // {0x7c,0x00},\r
@@ -227,146 +239,146 @@ static struct reginfo sensor_init_data[] =
 \r
 \r
 \r
-
-    {0x92,0x00},
-    {0x93,0x06},
-    {0x93,0xc8},//e3
-    {0x93,0x05},
-    {0x93,0x05},
-    {0x93,0x00},
-    {0x93,0x04},
-    {0x93,0x00},
-    {0x93,0x00},
-    {0x93,0x00},
-    {0x93,0x00},
-    {0x93,0x00},
-    {0x93,0x00},
-    {0x93,0x00},
-\r
-    {0x96,0x00},
-    {0x97,0x08},
-    {0x97,0x19},
-    {0x97,0x02},
-    {0x97,0x0c},
-    {0x97,0x24},
-    {0x97,0x30},
-    {0x97,0x28},
-    {0x97,0x26},
-    {0x97,0x02},
-    {0x97,0x98},
-    {0x97,0x80},
-    {0x97,0x00},
-    {0x97,0x00},
-    {0xc3,0xef},//ed
-    {0xa4,0x00},
-    {0xa8,0x00},
-
-    {0xbf, 0x00},
-    {0xba, 0xdc},
-    {0xbb, 0x08},
-    {0xb6, 0x20},
-    {0xb8, 0x30},
-    {0xb7, 0x20},
-    {0xb9, 0x30},
-    {0xb3, 0xb4},
-    {0xb4, 0xca},
-    {0xb5, 0x34},
-    {0xb0, 0x46},
-    {0xb1, 0x46},
-    {0xb2, 0x06},
-    {0xc7, 0x00},
-    {0xc6, 0x51},
-    {0xc5, 0x11},
-    {0xc4, 0x9c},
-////
-    {0xc0,0xc8},
-    {0xc1,0x96},
-    {0x86,0x3d},
-    {0x50,0x92},
-    {0x51,0x90},
-    {0x52,0x2c},
-    {0x53,0x00},
-    {0x54,0x00},
-    {0x55,0x88},
-    {0x57,0x00},
-    {0x5a,0x50},
-    {0x5b,0x3c},
-    {0x5c,0x00},
-    {0xc3,0xed},
-    {0x7f,0x00},
-    {0xda,0x01},
-    {0xe5,0x1f},
-    {0xe1,0x67},
-    {0xe0,0x00},
-    {0xdd,0xff},
-    {0x05,0x00},
-
-#endif
-#if 1
-    {0xff, 0x01},
-    {0x5d, 0x55},//0x00
+\r
+    {0x92,0x00},\r
+    {0x93,0x06},\r
+    {0x93,0xc8},//e3\r
+    {0x93,0x05},\r
+    {0x93,0x05},\r
+    {0x93,0x00},\r
+    {0x93,0x04},\r
+    {0x93,0x00},\r
+    {0x93,0x00},\r
+    {0x93,0x00},\r
+    {0x93,0x00},\r
+    {0x93,0x00},\r
+    {0x93,0x00},\r
+    {0x93,0x00},\r
+\r
+    {0x96,0x00},\r
+    {0x97,0x08},\r
+    {0x97,0x19},\r
+    {0x97,0x02},\r
+    {0x97,0x0c},\r
+    {0x97,0x24},\r
+    {0x97,0x30},\r
+    {0x97,0x28},\r
+    {0x97,0x26},\r
+    {0x97,0x02},\r
+    {0x97,0x98},\r
+    {0x97,0x80},\r
+    {0x97,0x00},\r
+    {0x97,0x00},\r
+    {0xc3,0xef},//ed\r
+    {0xa4,0x00},\r
+    {0xa8,0x00},\r
+\r
+    {0xbf, 0x00},\r
+    {0xba, 0xdc},\r
+    {0xbb, 0x08},\r
+    {0xb6, 0x20},\r
+    {0xb8, 0x30},\r
+    {0xb7, 0x20},\r
+    {0xb9, 0x30},\r
+    {0xb3, 0xb4},\r
+    {0xb4, 0xca},\r
+    {0xb5, 0x34},\r
+    {0xb0, 0x46},\r
+    {0xb1, 0x46},\r
+    {0xb2, 0x06},\r
+    {0xc7, 0x00},\r
+    {0xc6, 0x51},\r
+    {0xc5, 0x11},\r
+    {0xc4, 0x9c},\r
+////\r
+    {0xc0,0xc8},\r
+    {0xc1,0x96},\r
+    {0x86,0x3d},\r
+    {0x50,0x92},\r
+    {0x51,0x90},\r
+    {0x52,0x2c},\r
+    {0x53,0x00},\r
+    {0x54,0x00},\r
+    {0x55,0x88},\r
+    {0x57,0x00},\r
+    {0x5a,0x50},\r
+    {0x5b,0x3c},\r
+    {0x5c,0x00},\r
+    {0xc3,0xed},\r
+    {0x7f,0x00},\r
+    {0xda,0x01},\r
+    {0xe5,0x1f},\r
+    {0xe1,0x67},\r
+    {0xe0,0x00},\r
+    {0xdd,0xff},\r
+    {0x05,0x00},\r
+\r
+#endif\r
+#if 1\r
+    {0xff, 0x01},\r
+    {0x5d, 0x55},//0x00\r
     //{0x5e, 0x7d},//0x3c\r
     //{0x5f, 0x7d},//0x28\r
     //{0x60, 0x55},//0x55\r
-       {0x5e, 0x55},//0x3c
-    {0x5f, 0x55},//0x28
-    {0x60, 0x55},//0x55
-
-    {0xff, 0x00},
-    {0xc3, 0xef},
-    {0xa6, 0x00},
-    {0xa7, 0x0f},
-    {0xa7, 0x4e},
-    {0xa7, 0x7a},
-    {0xa7, 0x33},
-    {0xa7, 0x00},
-    {0xa7, 0x23},
-    {0xa7, 0x27},
-    {0xa7, 0x3a},
-    {0xa7, 0x70},
-    {0xa7, 0x33},
-    {0xa7, 0x00},//L
-    {0xa7, 0x23},
-    {0xa7, 0x20},
-    {0xa7, 0x0c},
-    {0xa7, 0x66},
-    {0xa7, 0x33},
-    {0xa7, 0x00},
-    {0xa7, 0x23},
-    {0xc3, 0xef},
-#endif
-
-
-#if 1
-    {0xff,0x00},
-    {0x92,0x00},
-    {0x93,0x06}, //0x06 peak
-    {0x93,0xe3},//e
-    {0x93,0x05},
-    {0x93,0x03},
-    {0x93,0x00},
-    {0x93,0x04},
-#endif
-
-    //{0x03, 0x0f},
+       {0x5e, 0x55},//0x3c\r
+    {0x5f, 0x55},//0x28\r
+    {0x60, 0x55},//0x55\r
+\r
+    {0xff, 0x00},\r
+    {0xc3, 0xef},\r
+    {0xa6, 0x00},\r
+    {0xa7, 0x0f},\r
+    {0xa7, 0x4e},\r
+    {0xa7, 0x7a},\r
+    {0xa7, 0x33},\r
+    {0xa7, 0x00},\r
+    {0xa7, 0x23},\r
+    {0xa7, 0x27},\r
+    {0xa7, 0x3a},\r
+    {0xa7, 0x70},\r
+    {0xa7, 0x33},\r
+    {0xa7, 0x00},//L\r
+    {0xa7, 0x23},\r
+    {0xa7, 0x20},\r
+    {0xa7, 0x0c},\r
+    {0xa7, 0x66},\r
+    {0xa7, 0x33},\r
+    {0xa7, 0x00},\r
+    {0xa7, 0x23},\r
+    {0xc3, 0xef},\r
+#endif\r
+\r
+\r
+#if 1\r
+    {0xff,0x00},\r
+    {0x92,0x00},\r
+    {0x93,0x06}, //0x06 peak\r
+    {0x93,0xe3},//e\r
+    {0x93,0x05},\r
+    {0x93,0x03},\r
+    {0x93,0x00},\r
+    {0x93,0x04},\r
+#endif\r
+\r
+    //{0x03, 0x0f},\r
     \r
-    {0xe0, 0x04},
-    {0xc0, 0xc8},
-    {0xc1, 0x96},
-    {0x86, 0x3d},
-    {0x50, 0x89},
-    {0x51, 0x90},
-    {0x52, 0x2c},
-    {0x53, 0x00},
-    {0x54, 0x00},
-    {0x55, 0x88},
-    {0x57, 0x00},
-    {0x5a, 0xa0},
-    {0x5b, 0x78},
-    {0x5c, 0x00},
-    {0xd3, 0x04},
-    {0xe0, 0x00},
-
+    {0xe0, 0x04},\r
+    {0xc0, 0xc8},\r
+    {0xc1, 0x96},\r
+    {0x86, 0x3d},\r
+    {0x50, 0x89},\r
+    {0x51, 0x90},\r
+    {0x52, 0x2c},\r
+    {0x53, 0x00},\r
+    {0x54, 0x00},\r
+    {0x55, 0x88},\r
+    {0x57, 0x00},\r
+    {0x5a, 0xa0},\r
+    {0x5b, 0x78},\r
+    {0x5c, 0x00},\r
+    {0xd3, 0x04},\r
+    {0xe0, 0x00},\r
+\r
 /*vga*/\r
 /*800*600\r
   {0xff, 0x00},\r
@@ -387,715 +399,717 @@ static struct reginfo sensor_init_data[] =
          {0xd3, 0x02},\r
          {0xe0, 0x00},\r
 */\r
-  {0x0, 0x0}   //end flag
-
-};
-
-/* 1600X1200 UXGA */
-static struct reginfo sensor_uxga[] =
-{
-    {0xff, 0x00},
-    {0xe0, 0x04},
-    {0xc0, 0xc8},
-    {0xc1, 0x96},
-    {0x86, 0x3d},
-    {0x50, 0x00},
-    {0x51, 0x90},
-    {0x52, 0x2c},
-    {0x53, 0x00},
-    {0x54, 0x00},
-    {0x55, 0x88},
-    {0x57, 0x00},
-    {0x5a, 0x90},
-    {0x5b, 0x2c},
-    {0x5c, 0x05},
-    {0xd3, 0x82},
-    {0xe0, 0x00},
-  {0x0, 0x0}   //end flag
-};
-
-/* 1280X1024 SXGA */
-static struct reginfo sensor_sxga[] =
-{
-    {0xff, 0x00},
-    {0xe0, 0x04},
-    {0xc0, 0xc8},
-    {0xc1, 0x96},
-    {0x86, 0x3d},
-    {0x50, 0x00},
-    {0x51, 0x90},
-    {0x52, 0x2c},
-    {0x53, 0x00},
-    {0x54, 0x00},
-    {0x55, 0x88},
-    {0x57, 0x00},
-    {0x5a, 0x40},
-    {0x5b, 0x00},
-    {0x5c, 0x05},
-    {0xd3, 0x82},
-    {0xe0, 0x00},
-  {0x0, 0x0}   //end flag
-};
-
-
-static struct reginfo sensor_xga[] =
-{
-    {0xff, 0x00},
-    {0xe0, 0x04},
-    {0xc0, 0xc8},
-    {0xc1, 0x96},
-    {0x86, 0x3d},
-    {0x50, 0x00},
-    {0x51, 0x90},
-    {0x52, 0x2c},
-    {0x53, 0x00},
-    {0x54, 0x00},
-    {0x55, 0x88},
-    {0x57, 0x00},
-    {0x5a, 0x40},
-    {0x5b, 0x00},
-    {0x5c, 0x05},
-    {0xd3, 0x82},
-    {0xe0, 0x00},
-  {0x0, 0x0}   //end flag
-
-
-};
-
-
-/* 800X600 SVGA*/
-static struct reginfo sensor_svga[] =
-{
-  {0x0, 0x0}   //end flag
-};
-
-/* 640X480 VGA */
-static struct reginfo sensor_vga[] =
-{
-   {0x0, 0x0}   //end flag
- };
-
-/* 352X288 CIF */
-static struct reginfo sensor_cif[] =
-{
-  {0x0, 0x0}   //end flag
-};
-
-/* 320*240 QVGA */
-static  struct reginfo sensor_qvga[] =
-{
-  {0x0, 0x0}   //end flag
-};
-
-/* 176X144 QCIF*/
-static struct reginfo sensor_qcif[] =
-{
-  {0x0, 0x0}   //end flag
-};
-#if 0
-/* 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},
-};
-
-
-
-static  struct reginfo ov2655_Sharpness_auto[] =
-{
-    {0x3306, 0x00},
-};
-
-static  struct reginfo ov2655_Sharpness1[] =
-{
-    {0x3306, 0x08},
-    {0x3371, 0x00},
-};
-
-static  struct reginfo ov2655_Sharpness2[][3] =
-{
-    //Sharpness 2
-    {0x3306, 0x08},
-    {0x3371, 0x01},
-};
-
-static  struct reginfo ov2655_Sharpness3[] =
-{
-    //default
-    {0x3306, 0x08},
-    {0x332d, 0x02},
-};
-static  struct reginfo ov2655_Sharpness4[]=
-{
-    //Sharpness 4
-    {0x3306, 0x08},
-    {0x332d, 0x03},
-};
-
-static  struct reginfo ov2655_Sharpness5[] =
-{
-    //Sharpness 5
-    {0x3306, 0x08},
-    {0x332d, 0x04},
-};
-#endif
-
-static  struct reginfo sensor_ClrFmt_YUYV[]=
-{
-    //{0x4300, 0x30},
-    {0x00, 0x00}
-};
-
-static  struct reginfo sensor_ClrFmt_UYVY[]=
-{
-    //{0x4300, 0x32},
-    {0x00, 0x00}
-};
-
-#if CONFIG_SENSOR_WhiteBalance
-static  struct reginfo sensor_WhiteB_Auto[]=
-{
-\r
-    {0xff, 0x00},  //AWB auto, bit[1]:0,auto
+  {0x0, 0x0}   //end flag\r
+\r
+};\r
+\r
+/* 1600X1200 UXGA */\r
+static struct reginfo sensor_uxga[] =\r
+{\r
+    {0xff, 0x00},\r
+    {0xe0, 0x04},\r
+    {0xc0, 0xc8},\r
+    {0xc1, 0x96},\r
+    {0x86, 0x3d},\r
+    {0x50, 0x00},\r
+    {0x51, 0x90},\r
+    {0x52, 0x2c},\r
+    {0x53, 0x00},\r
+    {0x54, 0x00},\r
+    {0x55, 0x88},\r
+    {0x57, 0x00},\r
+    {0x5a, 0x90},\r
+    {0x5b, 0x2c},\r
+    {0x5c, 0x05},\r
+    {0xd3, 0x82},\r
+    {0xe0, 0x00},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+/* 1280X1024 SXGA */\r
+static struct reginfo sensor_sxga[] =\r
+{\r
+    {0xff, 0x00},\r
+    {0xe0, 0x04},\r
+    {0xc0, 0xc8},\r
+    {0xc1, 0x96},\r
+    {0x86, 0x3d},\r
+    {0x50, 0x00},\r
+    {0x51, 0x90},\r
+    {0x52, 0x2c},\r
+    {0x53, 0x00},\r
+    {0x54, 0x00},\r
+    {0x55, 0x88},\r
+    {0x57, 0x00},\r
+    {0x5a, 0x40},\r
+    {0x5b, 0x00},\r
+    {0x5c, 0x05},\r
+    {0xd3, 0x82},\r
+    {0xe0, 0x00},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+\r
+static struct reginfo sensor_xga[] =\r
+{\r
+    {0xff, 0x00},\r
+    {0xe0, 0x04},\r
+    {0xc0, 0xc8},\r
+    {0xc1, 0x96},\r
+    {0x86, 0x3d},\r
+    {0x50, 0x00},\r
+    {0x51, 0x90},\r
+    {0x52, 0x2c},\r
+    {0x53, 0x00},\r
+    {0x54, 0x00},\r
+    {0x55, 0x88},\r
+    {0x57, 0x00},\r
+    {0x5a, 0x40},\r
+    {0x5b, 0x00},\r
+    {0x5c, 0x05},\r
+    {0xd3, 0x82},\r
+    {0xe0, 0x00},\r
+  {0x0, 0x0}   //end flag\r
+\r
+\r
+};\r
+\r
+\r
+/* 800X600 SVGA*/\r
+static struct reginfo sensor_svga[] =\r
+{\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+/* 640X480 VGA */\r
+static struct reginfo sensor_vga[] =\r
+{\r
+   {0x0, 0x0}   //end flag\r
+ };\r
+\r
+/* 352X288 CIF */\r
+static struct reginfo sensor_cif[] =\r
+{\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+/* 320*240 QVGA */\r
+static  struct reginfo sensor_qvga[] =\r
+{\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+/* 176X144 QCIF*/\r
+static struct reginfo sensor_qcif[] =\r
+{\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+#endif\r
+#if 0\r
+/* 160X120 QQVGA*/\r
+static struct reginfo ov2655_qqvga[] =\r
+{\r
+\r
+    {0x300E, 0x34},\r
+    {0x3011, 0x01},\r
+    {0x3012, 0x10},\r
+    {0x302a, 0x02},\r
+    {0x302b, 0xE6},\r
+    {0x306f, 0x14},\r
+    {0x3362, 0x90},\r
+\r
+    {0x3070, 0x5d},\r
+    {0x3072, 0x5d},\r
+    {0x301c, 0x07},\r
+    {0x301d, 0x07},\r
+\r
+    {0x3020, 0x01},\r
+    {0x3021, 0x18},\r
+    {0x3022, 0x00},\r
+    {0x3023, 0x06},\r
+    {0x3024, 0x06},\r
+    {0x3025, 0x58},\r
+    {0x3026, 0x02},\r
+    {0x3027, 0x61},\r
+    {0x3088, 0x00},\r
+    {0x3089, 0xa0},\r
+    {0x308a, 0x00},\r
+    {0x308b, 0x78},\r
+    {0x3316, 0x64},\r
+    {0x3317, 0x25},\r
+    {0x3318, 0x80},\r
+    {0x3319, 0x08},\r
+    {0x331a, 0x0a},\r
+    {0x331b, 0x07},\r
+    {0x331c, 0x80},\r
+    {0x331d, 0x38},\r
+    {0x3100, 0x00},\r
+    {0x3302, 0x11},\r
+\r
+    {0x0, 0x0},\r
+};\r
+\r
+\r
+\r
+static  struct reginfo ov2655_Sharpness_auto[] =\r
+{\r
+    {0x3306, 0x00},\r
+};\r
+\r
+static  struct reginfo ov2655_Sharpness1[] =\r
+{\r
+    {0x3306, 0x08},\r
+    {0x3371, 0x00},\r
+};\r
+\r
+static  struct reginfo ov2655_Sharpness2[][3] =\r
+{\r
+    //Sharpness 2\r
+    {0x3306, 0x08},\r
+    {0x3371, 0x01},\r
+};\r
+\r
+static  struct reginfo ov2655_Sharpness3[] =\r
+{\r
+    //default\r
+    {0x3306, 0x08},\r
+    {0x332d, 0x02},\r
+};\r
+static  struct reginfo ov2655_Sharpness4[]=\r
+{\r
+    //Sharpness 4\r
+    {0x3306, 0x08},\r
+    {0x332d, 0x03},\r
+};\r
+\r
+static  struct reginfo ov2655_Sharpness5[] =\r
+{\r
+    //Sharpness 5\r
+    {0x3306, 0x08},\r
+    {0x332d, 0x04},\r
+};\r
+#endif\r
+\r
+static  struct reginfo sensor_ClrFmt_YUYV[]=\r
+{\r
+    //{0x4300, 0x30},\r
+    {0x00, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_ClrFmt_UYVY[]=\r
+{\r
+    //{0x4300, 0x32},\r
+    {0x00, 0x00}\r
+};\r
+\r
+#if CONFIG_SENSOR_WhiteBalance\r
+static  struct reginfo sensor_WhiteB_Auto[]=\r
+{\r
+\r
+    {0xff, 0x00},  //AWB auto, bit[1]:0,auto\r
     {0xc7, 0x00},\r
-    {0x00, 0x00}
-};
-/* Cloudy Colour Temperature : 6500K - 8000K  */
-static  struct reginfo sensor_WhiteB_Cloudy[]=
-{
-    {0xff, 0x00},
-    {0xc7, 0x40},
-    {0xcc, 0x65},
-    {0xcd, 0x41},
-    {0xce, 0x4f},
-    {0x00, 0x00}
-};
-/* ClearDay Colour Temperature : 5000K - 6500K  */
-static  struct reginfo sensor_WhiteB_ClearDay[]=
-{
-    //Sunny
-    
-    {0xff, 0x00},
-    {0xc7, 0x40},
-    {0xcc, 0x5e},
-    {0xcd, 0x41},
-    {0xce, 0x54},
-    {0x00, 0x00}
-};
-/* Office Colour Temperature : 3500K - 5000K  */
-static  struct reginfo sensor_WhiteB_TungstenLamp1[]=
-{
-    //Office
-    {0xff, 0x00},
-    {0xc7, 0x40},
-    {0xcc, 0x52},
-    {0xcd, 0x41},
-    {0xce, 0x66},
-    {0x00, 0x00}
-};
-/* Home Colour Temperature : 2500K - 3500K  */
-static  struct reginfo sensor_WhiteB_TungstenLamp2[]=
-{
-    //Home
-    {0xff, 0x00},
-    {0xc7, 0x40},
-    {0xcc, 0x42},
-    {0xcd, 0x3f},
-    {0xce, 0x71},
-    {0x00, 0x00}
-};
-static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_ClearDay,sensor_WhiteB_Cloudy,sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
-    NULL,
-};
-#endif
-
-#if CONFIG_SENSOR_Brightness
-static  struct reginfo sensor_Brightness0[]=
-{
-    // Brightness -2
-    {0xff, 0x01},
-    {0x24, 0x34},
-    {0x25, 0x22},
-    {0x26, 0x70},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Brightness1[]=
-{
-    // Brightness -1
-
-    {0xff, 0x01},
-    {0x24, 0x58},
-    {0x25, 0x50},
-    {0x26, 0x92},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Brightness2[]=
-{
-    //  Brightness 0
-
-       {0xff, 0x01},
-       {0x24, 0xa8},
-       {0x25, 0x90},
-       {0x26, 0xd6},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Brightness3[]=
-{
-    // Brightness +1
-
-    {0xff, 0x01},
-    {0x24, 0x48},
-    {0x25, 0x40},
-    {0x26, 0x81},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Brightness4[]=
-{
-    //  Brightness +2
-
-    {0xff, 0x01},
-    {0x24, 0x58},
-    {0x25, 0x50},
-    {0x26, 0x92},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Brightness5[]=
-{
-    //  Brightness +3
-    {0xff, 0x01},
-    {0x24, 0x70},
-    {0x25, 0x60},
-    {0x26, 0xa4},
-  {0x0, 0x0}   //end flag
-};
-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[] =
-{
-       {0xff,0x00},
-       {0x7c,0x00},
-       {0x7d,0x00},
-       {0x7c,0x05},
-       {0x7d,0x80},
-       {0x7d,0x80},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Effect_WandB[] =
-{
-    {0xff,0x00},
-    {0x7c,0x00},
-    {0x7d,0x18},
-    {0x7c,0x05},
-    {0x7d,0x80},
-    {0x7d,0x80},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Effect_Sepia[] =
-{
-    {0xff,0x00},
-    {0x7c,0x00},
-    {0x7d,0x18},
-    {0x7c,0x05},
-    {0x7d,0x40},
-    {0x7d,0xc0},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Effect_Negative[] =
-{
-    {0xff,0x00},
-    {0x7c,0x00},
-    {0x7d,0x40},
-    {0x7c,0x05},
-    {0x7d,0x80},
-    {0x7d,0x80},
-  {0x0, 0x0}   //end flag
-};
-static  struct reginfo sensor_Effect_Bluish[] =
-{
-    {0Xff, 0X00},
-    {0X7c, 0X00},
-    {0X7d, 0X18},
-    {0X7c, 0X05},
-    {0X7d, 0Xa0},
-    {0X7d, 0X40},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Effect_Green[] =
-{
-    {0Xff, 0X00},
-    {0X7c, 0X00},
-    {0X7d, 0X18},
-    {0X7c, 0X05},
-    {0X7d, 0X40},
-    {0X7d, 0X40},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Effect_Exp_Windows_Half[] =
-{
-       {0xff, 0x01},
-       {0x5d, 0x00},
-       {0x5e, 0x3c},
-       {0x5f, 0x28},
-       {0x60, 0x55},
-  {0x0, 0x0}   //end flag
-};
-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[]=
-{
-       {0x0000, 0x00}
-};
-
-static  struct reginfo sensor_Exposure1[]=
-{
-    {0x0000, 0x00}
-};
-
-static  struct reginfo sensor_Exposure2[]=
-{
-    {0x0000, 0x00}
-};
-
-static  struct reginfo sensor_Exposure3[]=
-{
-    {0x0000, 0x00}
-};
-
-static  struct reginfo sensor_Exposure4[]=
-{
-    {0x0000, 0x00}
-};
-
-static  struct reginfo sensor_Exposure5[]=
-{
-    {0x0000, 0x00}
-};
-
-static  struct reginfo sensor_Exposure6[]=
-{
-    {0x0000, 0x00}
-};
-
-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, 0x00},
-       {0x90, 0x00},
-       {0x91, 0x0e},
-       {0x91, 0x1a},
-       {0x91, 0x31},
-       {0x91, 0x5a},
-       {0x91, 0x69},
-       {0x91, 0x75},
-       {0x91, 0x7e},
-       {0x91, 0x88},
-       {0x91, 0x8f},
-       {0x91, 0x96},
-       {0x91, 0xa3},
-       {0x91, 0xaf},
-       {0x91, 0xc4},
-       {0x91, 0xd7},
-       {0x91, 0xe8},
-       {0x91, 0x20},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Saturation1[]=
-{
-    {0xff, 0x00},
-    {0x90, 0x00},
-    {0x91, 0x03},
-    {0x91, 0x0a},
-    {0x91, 0x1a},
-    {0x91, 0x3f},
-    {0x91, 0x4e},
-    {0x91, 0x5b},
-    {0x91, 0x68},
-    {0x91, 0x75},
-    {0x91, 0x7f},
-    {0x91, 0x89},
-    {0x91, 0x9a},
-    {0x91, 0xa6},
-    {0x91, 0xbd},
-    {0x91, 0xd3},
-    {0x91, 0xe5},
-    {0x91, 0x24},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Saturation2[]=
-{
-    {0xff, 0x00},
-    {0x90, 0x00},
-    {0x91, 0x04},
-    {0x91, 0x07},
-    {0x91, 0x10},
-    {0x91, 0x28},
-    {0x91, 0x36},
-    {0x91, 0x44},
-    {0x91, 0x52},
-    {0x91, 0x60},
-    {0x91, 0x6c},
-    {0x91, 0x78},
-    {0x91, 0x8c},
-    {0x91, 0x9e},
-    {0x91, 0xbb},
-    {0x91, 0xd3},
-    {0x91, 0xe5},
-    {0x91, 0x24},
-  {0x0, 0x0}   //end flag      
-};
-static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
-
-
-#endif
-#if CONFIG_SENSOR_Contrast
-static  struct reginfo sensor_Contrast0[]=
-{
-    {0xff, 0x00},
-    {0x7c, 0x00},
-    {0x7d, 0x04},
-    {0x7c, 0x07},
-    {0x7d, 0x20},
-    {0x7d, 0x10},
-    {0x7d, 0x4a},
-    {0x7d, 0x06},
-  {0x0, 0x0}   //end flag
-
-};
-
-static  struct reginfo sensor_Contrast1[]=
-{
-    {0xff, 0x00},
-    {0x7c, 0x00},
-    {0x7d, 0x04},
-    {0x7c, 0x07},
-    {0x7d, 0x20},
-    {0x7d, 0x14},
-    {0x7d, 0x40},
-    {0x7d, 0x06},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Contrast2[]=
-{
-    {0xff, 0x00},
-    {0x7c, 0x00},
-    {0x7d, 0x04},
-    {0x7c, 0x07},
-    {0x7d, 0x20},
-    {0x7d, 0x18},
-    {0x7d, 0x34},
-    {0x7d, 0x06},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Contrast3[]=
-{
-    {0xff, 0x00},
-    {0x7c, 0x00},
-    {0x7d, 0x04},
-    {0x7c, 0x07},
-    {0x7d, 0x20},
-    {0x7d, 0x1c},
-    {0x7d, 0x2a},
-    {0x7d, 0x06},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Contrast4[]=
-{
-    {0xff,0x00},
-    {0x7c,0x00},
-    {0x7d,0x04},
-    {0x7c,0x07},
-    {0x7d,0x20},
-    {0x7d,0x24},
-    {0x7d,0x16},
-    {0x7d,0x06},
-  {0x0, 0x0}   //end flag
-};
-
-
-static  struct reginfo sensor_Contrast5[]=
-{
-    {0xff, 0x00},
-    {0x7c, 0x00},
-    {0x7d, 0x04},
-    {0x7c, 0x07},
-    {0x7d, 0x20},
-    {0x7d, 0x20},
-    {0x7d, 0x20},
-    {0x7d, 0x06},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Contrast6[]=
-{
-    {0xff, 0x00},
-    {0x7c, 0x00},
-    {0x7d, 0x04},
-    {0x7c, 0x07},
-    {0x7d, 0x20},
-    {0x7d, 0x24},
-    {0x7d, 0x16},
-    {0x7d, 0x06},
-  {0x0, 0x0}   //end flag
-};
-
-
-static  struct reginfo sensor_Contrast7[]=
-{
-    {0xff, 0x00},
-    {0x7c, 0x00},
-    {0x7d, 0x04},
-    {0x7c, 0x07},
-    {0x7d, 0x20},
-    {0x7d, 0x28},
-    {0x7d, 0x0c},
-    {0x7d, 0x06},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Contrast8[]=
-{
-    {0xff, 0x00},
-    {0x7c, 0x00},
-    {0x7d, 0x04},
-    {0x7c, 0x07},
-    {0x7d, 0x20},
-    {0x7d, 0x2c},
-    {0x7d, 0x02},
-    {0x7d, 0x06},
-  {0x0, 0x0}   //end flag
-};
-
-static  struct reginfo sensor_Contrast9[]=
-{
-    {0xff, 0x00},
-    {0x7c, 0x00},
-    {0x7d, 0x04},
-    {0x7c, 0x07},
-    {0x7d, 0x20},
-    {0x7d, 0x30},
-    {0x7d, 0x08},
-    {0x7d, 0x0e},
-  {0x0, 0x0}   //end flag
-};
-
-
-
-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[]=
-{
-    {0x0000, 0x00}
-};
-
-static  struct reginfo sensor_MirrorOff[]=
-{
-    {0x0000, 0x00}
-};
-static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
-#endif
-#if CONFIG_SENSOR_Flip
-static  struct reginfo sensor_FlipOn[]=
-{
-    {0x0000, 0x00}
-};
-
-static  struct reginfo sensor_FlipOff[]=
-{
-    {0x0000, 0x00}
-};
-static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
-
-#endif
-#if CONFIG_SENSOR_Scene
-static  struct reginfo sensor_SceneAuto[] =
-{
+    {0x00, 0x00}\r
+};\r
+/* Cloudy Colour Temperature : 6500K - 8000K  */\r
+static  struct reginfo sensor_WhiteB_Cloudy[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0xc7, 0x40},\r
+    {0xcc, 0x65},\r
+    {0xcd, 0x41},\r
+    {0xce, 0x4f},\r
+    {0x00, 0x00}\r
+};\r
+/* ClearDay Colour Temperature : 5000K - 6500K  */\r
+static  struct reginfo sensor_WhiteB_ClearDay[]=\r
+{\r
+    //Sunny\r
+    \r
+    {0xff, 0x00},\r
+    {0xc7, 0x40},\r
+    {0xcc, 0x5e},\r
+    {0xcd, 0x41},\r
+    {0xce, 0x54},\r
+    {0x00, 0x00}\r
+};\r
+/* Office Colour Temperature : 3500K - 5000K  */\r
+static  struct reginfo sensor_WhiteB_TungstenLamp1[]=\r
+{\r
+    //Office\r
+    {0xff, 0x00},\r
+    {0xc7, 0x40},\r
+    {0xcc, 0x52},\r
+    {0xcd, 0x41},\r
+    {0xce, 0x66},\r
+    {0x00, 0x00}\r
+};\r
+/* Home Colour Temperature : 2500K - 3500K  */\r
+static  struct reginfo sensor_WhiteB_TungstenLamp2[]=\r
+{\r
+    //Home\r
+    {0xff, 0x00},\r
+    {0xc7, 0x40},\r
+    {0xcc, 0x42},\r
+    {0xcd, 0x3f},\r
+    {0xce, 0x71},\r
+    {0x00, 0x00}\r
+};\r
+static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_ClearDay,sensor_WhiteB_Cloudy,sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,\r
+    NULL,\r
+};\r
+#endif\r
+\r
+#if CONFIG_SENSOR_Brightness\r
+static  struct reginfo sensor_Brightness0[]=\r
+{\r
+    // Brightness -2\r
+    {0xff, 0x01},\r
+    {0x24, 0x34},\r
+    {0x25, 0x22},\r
+    {0x26, 0x70},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Brightness1[]=\r
+{\r
+    // Brightness -1\r
+\r
+    {0xff, 0x01},\r
+    {0x24, 0x58},\r
+    {0x25, 0x50},\r
+    {0x26, 0x92},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Brightness2[]=\r
+{\r
+    //  Brightness 0\r
+\r
+       {0xff, 0x01},\r
+       {0x24, 0xa8},\r
+       {0x25, 0x90},\r
+       {0x26, 0xd6},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Brightness3[]=\r
+{\r
+    // Brightness +1\r
+\r
+    {0xff, 0x01},\r
+    {0x24, 0x48},\r
+    {0x25, 0x40},\r
+    {0x26, 0x81},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Brightness4[]=\r
+{\r
+    //  Brightness +2\r
+\r
+    {0xff, 0x01},\r
+    {0x24, 0x58},\r
+    {0x25, 0x50},\r
+    {0x26, 0x92},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Brightness5[]=\r
+{\r
+    //  Brightness +3\r
+    {0xff, 0x01},\r
+    {0x24, 0x70},\r
+    {0x25, 0x60},\r
+    {0x26, 0xa4},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,\r
+    sensor_Brightness4, sensor_Brightness5,NULL,\r
+};\r
+\r
+#endif\r
+\r
+#if CONFIG_SENSOR_Effect\r
+static  struct reginfo sensor_Effect_Normal[] =\r
+{\r
+       {0xff,0x00},\r
+       {0x7c,0x00},\r
+       {0x7d,0x00},\r
+       {0x7c,0x05},\r
+       {0x7d,0x80},\r
+       {0x7d,0x80},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Effect_WandB[] =\r
+{\r
+    {0xff,0x00},\r
+    {0x7c,0x00},\r
+    {0x7d,0x18},\r
+    {0x7c,0x05},\r
+    {0x7d,0x80},\r
+    {0x7d,0x80},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Effect_Sepia[] =\r
+{\r
+    {0xff,0x00},\r
+    {0x7c,0x00},\r
+    {0x7d,0x18},\r
+    {0x7c,0x05},\r
+    {0x7d,0x40},\r
+    {0x7d,0xc0},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Effect_Negative[] =\r
+{\r
+    {0xff,0x00},\r
+    {0x7c,0x00},\r
+    {0x7d,0x40},\r
+    {0x7c,0x05},\r
+    {0x7d,0x80},\r
+    {0x7d,0x80},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+static  struct reginfo sensor_Effect_Bluish[] =\r
+{\r
+    {0Xff, 0X00},\r
+    {0X7c, 0X00},\r
+    {0X7d, 0X18},\r
+    {0X7c, 0X05},\r
+    {0X7d, 0Xa0},\r
+    {0X7d, 0X40},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Effect_Green[] =\r
+{\r
+    {0Xff, 0X00},\r
+    {0X7c, 0X00},\r
+    {0X7d, 0X18},\r
+    {0X7c, 0X05},\r
+    {0X7d, 0X40},\r
+    {0X7d, 0X40},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Effect_Exp_Windows_Half[] =\r
+{\r
+       {0xff, 0x01},\r
+       {0x5d, 0x00},\r
+       {0x5e, 0x3c},\r
+       {0x5f, 0x28},\r
+       {0x60, 0x55},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,\r
+    sensor_Effect_Bluish, sensor_Effect_Green,NULL,\r
+};\r
+#endif\r
+#if CONFIG_SENSOR_Exposure\r
+static  struct reginfo sensor_Exposure0[]=\r
+{\r
+       {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure1[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure2[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure3[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure4[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure5[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_Exposure6[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,\r
+    sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,\r
+};\r
+#endif\r
+#if CONFIG_SENSOR_Saturation\r
+static  struct reginfo sensor_Saturation0[]=\r
+{\r
+       {0xff, 0x00},\r
+       {0x90, 0x00},\r
+       {0x91, 0x0e},\r
+       {0x91, 0x1a},\r
+       {0x91, 0x31},\r
+       {0x91, 0x5a},\r
+       {0x91, 0x69},\r
+       {0x91, 0x75},\r
+       {0x91, 0x7e},\r
+       {0x91, 0x88},\r
+       {0x91, 0x8f},\r
+       {0x91, 0x96},\r
+       {0x91, 0xa3},\r
+       {0x91, 0xaf},\r
+       {0x91, 0xc4},\r
+       {0x91, 0xd7},\r
+       {0x91, 0xe8},\r
+       {0x91, 0x20},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Saturation1[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x90, 0x00},\r
+    {0x91, 0x03},\r
+    {0x91, 0x0a},\r
+    {0x91, 0x1a},\r
+    {0x91, 0x3f},\r
+    {0x91, 0x4e},\r
+    {0x91, 0x5b},\r
+    {0x91, 0x68},\r
+    {0x91, 0x75},\r
+    {0x91, 0x7f},\r
+    {0x91, 0x89},\r
+    {0x91, 0x9a},\r
+    {0x91, 0xa6},\r
+    {0x91, 0xbd},\r
+    {0x91, 0xd3},\r
+    {0x91, 0xe5},\r
+    {0x91, 0x24},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Saturation2[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x90, 0x00},\r
+    {0x91, 0x04},\r
+    {0x91, 0x07},\r
+    {0x91, 0x10},\r
+    {0x91, 0x28},\r
+    {0x91, 0x36},\r
+    {0x91, 0x44},\r
+    {0x91, 0x52},\r
+    {0x91, 0x60},\r
+    {0x91, 0x6c},\r
+    {0x91, 0x78},\r
+    {0x91, 0x8c},\r
+    {0x91, 0x9e},\r
+    {0x91, 0xbb},\r
+    {0x91, 0xd3},\r
+    {0x91, 0xe5},\r
+    {0x91, 0x24},\r
+  {0x0, 0x0}   //end flag      \r
+};\r
+static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};\r
+\r
+\r
+#endif\r
+#if CONFIG_SENSOR_Contrast\r
+static  struct reginfo sensor_Contrast0[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x7c, 0x00},\r
+    {0x7d, 0x04},\r
+    {0x7c, 0x07},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x10},\r
+    {0x7d, 0x4a},\r
+    {0x7d, 0x06},\r
+  {0x0, 0x0}   //end flag\r
+\r
+};\r
+\r
+static  struct reginfo sensor_Contrast1[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x7c, 0x00},\r
+    {0x7d, 0x04},\r
+    {0x7c, 0x07},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x14},\r
+    {0x7d, 0x40},\r
+    {0x7d, 0x06},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Contrast2[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x7c, 0x00},\r
+    {0x7d, 0x04},\r
+    {0x7c, 0x07},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x18},\r
+    {0x7d, 0x34},\r
+    {0x7d, 0x06},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Contrast3[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x7c, 0x00},\r
+    {0x7d, 0x04},\r
+    {0x7c, 0x07},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x1c},\r
+    {0x7d, 0x2a},\r
+    {0x7d, 0x06},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Contrast4[]=\r
+{\r
+    {0xff,0x00},\r
+    {0x7c,0x00},\r
+    {0x7d,0x04},\r
+    {0x7c,0x07},\r
+    {0x7d,0x20},\r
+    {0x7d,0x24},\r
+    {0x7d,0x16},\r
+    {0x7d,0x06},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+\r
+static  struct reginfo sensor_Contrast5[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x7c, 0x00},\r
+    {0x7d, 0x04},\r
+    {0x7c, 0x07},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x06},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Contrast6[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x7c, 0x00},\r
+    {0x7d, 0x04},\r
+    {0x7c, 0x07},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x24},\r
+    {0x7d, 0x16},\r
+    {0x7d, 0x06},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+\r
+static  struct reginfo sensor_Contrast7[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x7c, 0x00},\r
+    {0x7d, 0x04},\r
+    {0x7c, 0x07},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x28},\r
+    {0x7d, 0x0c},\r
+    {0x7d, 0x06},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Contrast8[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x7c, 0x00},\r
+    {0x7d, 0x04},\r
+    {0x7c, 0x07},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x2c},\r
+    {0x7d, 0x02},\r
+    {0x7d, 0x06},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+static  struct reginfo sensor_Contrast9[]=\r
+{\r
+    {0xff, 0x00},\r
+    {0x7c, 0x00},\r
+    {0x7d, 0x04},\r
+    {0x7c, 0x07},\r
+    {0x7d, 0x20},\r
+    {0x7d, 0x30},\r
+    {0x7d, 0x08},\r
+    {0x7d, 0x0e},\r
+  {0x0, 0x0}   //end flag\r
+};\r
+\r
+\r
+\r
+static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,\r
+    sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,\r
+};\r
+\r
+#endif\r
+#if CONFIG_SENSOR_Mirror\r
+static  struct reginfo sensor_MirrorOn[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_MirrorOff[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};\r
+#endif\r
+#if CONFIG_SENSOR_Flip\r
+static  struct reginfo sensor_FlipOn[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+\r
+static  struct reginfo sensor_FlipOff[]=\r
+{\r
+    {0x0000, 0x00}\r
+};\r
+static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};\r
+\r
+#endif\r
+#if CONFIG_SENSOR_Scene\r
+static  struct reginfo sensor_SceneAuto[] =\r
+{\r
 /*\r
     {0xff, 0x00},\r
-    {0xc7, 0x00},
-    {0x00, 0x00}*/
-};
-
-static  struct reginfo sensor_SceneNight[] =
-{
+    {0xc7, 0x00},\r
+    {0x00, 0x00}*/\r
+};\r
+\r
+static  struct reginfo sensor_SceneNight[] =\r
+{\r
        /*\r
-    {0x3003, 0x80},
-       {0x3004, 0x20},
-       {0x3005, 0x18},
-       {0x3006, 0x0d},
-       {0x3a00, 0x7c},
-       {0x3a02 ,0x07},
-       {0x3a03 ,0x38},
-       {0x3a14 ,0x07},
-       {0x3a15 ,0x38},
-    {0x0000, 0x00}
+    {0x3003, 0x80},\r
+       {0x3004, 0x20},\r
+       {0x3005, 0x18},\r
+       {0x3006, 0x0d},\r
+       {0x3a00, 0x7c},\r
+       {0x3a02 ,0x07},\r
+       {0x3a03 ,0x38},\r
+       {0x3a14 ,0x07},\r
+       {0x3a15 ,0x38},\r
+    {0x0000, 0x00}\r
     */\r
     /*\r
         {0xff, 0x01},\r
@@ -1104,1988 +1118,2013 @@ static  struct reginfo sensor_SceneNight[] =
         {0x03, 0xcf},\r
                {0x00, 0x00}\r
 */\r
-};
-static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
-
-#endif
-#if CONFIG_SENSOR_DigitalZoom
-static struct reginfo sensor_Zoom0[] =
-{
-    {0x0, 0x0},
-};
-
-static struct reginfo sensor_Zoom1[] =
-{
-     {0x0, 0x0},
-};
-
-static struct reginfo sensor_Zoom2[] =
-{
-    {0x0, 0x0},
-};
-
-
-static struct reginfo sensor_Zoom3[] =
-{
-    {0x0, 0x0},
-};
-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 = 1,
-    },
-    #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 = 1,
-    },
-    #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);
-#if CONFIG_SENSOR_Effect
-static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
-#endif
-#if CONFIG_SENSOR_WhiteBalance
-static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
-#endif
-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),
-};
-
-/* only one fixed colorspace per pixelcode */
-struct sensor_datafmt {
-       enum v4l2_mbus_pixelcode code;
-       enum v4l2_colorspace colorspace;
-};
-
-/* Find a data format by a pixel code in an array */
-static const struct sensor_datafmt *sensor_find_datafmt(
-       enum v4l2_mbus_pixelcode code, const struct sensor_datafmt *fmt,
-       int n)
-{
-       int i;
-       for (i = 0; i < n; i++)
-               if (fmt[i].code == code)
-                       return fmt + i;
-
-       return NULL;
-}
-
-static const struct sensor_datafmt sensor_colour_fmts[] = {
-    {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
-    {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}    
-};
-
-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;
-    struct sensor_datafmt fmt;
-    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_write(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;
-}
-
-/* sensor register read */
-static int sensor_read(struct i2c_client *client, u8 reg, u8 *val)
-{
-    int err,cnt;
-    u8 buf[1];
-    struct i2c_msg msg[2];
-
-    buf[0] = reg ;//>> 8;
-   // buf[1] = 0;
-
-    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;//0x55;   /* 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 = 3;
-    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  */
-static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
-{
-    int err = 0, cnt;
-    int i = 0;
-#if CONFIG_SENSOR_I2C_RDWRCHK    
-       char valchk;
-#endif
-
-       cnt = 0;
-       if (sensor_task_lock(client, 1) < 0)
-               goto sensor_write_array_end;
-    while (regarray[i].reg != 0)
-    {
-        err = sensor_write(client, regarray[i].reg, regarray[i].val);
-        if (err < 0)
-        {
-            if (cnt-- > 0) {
-                           SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
-                               i = 0;
-                               continue;
-            } else {
-                SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
-                err = -EPERM;
-                               goto sensor_write_array_end;
-            }
-        } else {
-        #if CONFIG_SENSOR_I2C_RDWRCHK
-                       sensor_read(client, regarray[i].reg, &valchk);
-                       if (valchk != regarray[i].val)
-                               SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
-               #endif
-        }
-        i++;
-    }
-
-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;
-    int i = 0;
-       char valchk;
-
-       cnt = 0;
-       valchk = 0;
-    while (regarray[i].reg != 0)
-    {
-               sensor_read(client, regarray[i].reg, &valchk);
-               if (valchk != regarray[i].val)
-                       SENSOR_TR("%s Reg:0x%x read(0x%x, 0x%x) error\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
-
-        i++;
-    }
-    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);
-       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)
-{
+};\r
+static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};\r
+\r
+#endif\r
+#if CONFIG_SENSOR_DigitalZoom\r
+static struct reginfo sensor_Zoom0[] =\r
+{\r
+    {0x0, 0x0},\r
+};\r
+\r
+static struct reginfo sensor_Zoom1[] =\r
+{\r
+     {0x0, 0x0},\r
+};\r
+\r
+static struct reginfo sensor_Zoom2[] =\r
+{\r
+    {0x0, 0x0},\r
+};\r
+\r
+\r
+static struct reginfo sensor_Zoom3[] =\r
+{\r
+    {0x0, 0x0},\r
+};\r
+static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};\r
+#endif\r
+static const struct v4l2_querymenu sensor_menus[] =\r
+{\r
+       #if CONFIG_SENSOR_WhiteBalance\r
+    { .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 0,  .name = "auto",  .reserved = 0, }, {  .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 1, .name = "incandescent",  .reserved = 0,},\r
+    { .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 2,  .name = "fluorescent", .reserved = 0,}, {  .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3,  .name = "daylight", .reserved = 0,},\r
+    { .id = V4L2_CID_DO_WHITE_BALANCE,  .index = 4,  .name = "cloudy-daylight", .reserved = 0,},\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Effect\r
+    { .id = V4L2_CID_EFFECT,  .index = 0,  .name = "none",  .reserved = 0, }, {  .id = V4L2_CID_EFFECT,  .index = 1, .name = "mono",  .reserved = 0,},\r
+    { .id = V4L2_CID_EFFECT,  .index = 2,  .name = "negative", .reserved = 0,}, {  .id = V4L2_CID_EFFECT, .index = 3,  .name = "sepia", .reserved = 0,},\r
+    { .id = V4L2_CID_EFFECT,  .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT,  .index = 5,  .name = "aqua", .reserved = 0,},\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Scene\r
+    { .id = V4L2_CID_SCENE,  .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE,  .index = 1,  .name = "night", .reserved = 0,},\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Flash\r
+    { .id = V4L2_CID_FLASH,  .index = 0,  .name = "off",  .reserved = 0, }, {  .id = V4L2_CID_FLASH,  .index = 1, .name = "auto",  .reserved = 0,},\r
+    { .id = V4L2_CID_FLASH,  .index = 2,  .name = "on", .reserved = 0,}, {  .id = V4L2_CID_FLASH, .index = 3,  .name = "torch", .reserved = 0,},\r
+    #endif\r
+};\r
+\r
+static  struct v4l2_queryctrl sensor_controls[] =\r
+{\r
+       #if CONFIG_SENSOR_WhiteBalance\r
+    {\r
+        .id            = V4L2_CID_DO_WHITE_BALANCE,\r
+        .type          = V4L2_CTRL_TYPE_MENU,\r
+        .name          = "White Balance Control",\r
+        .minimum       = 0,\r
+        .maximum       = 4,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Brightness\r
+       {\r
+        .id            = V4L2_CID_BRIGHTNESS,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Brightness Control",\r
+        .minimum       = -3,\r
+        .maximum       = 2,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Effect\r
+       {\r
+        .id            = V4L2_CID_EFFECT,\r
+        .type          = V4L2_CTRL_TYPE_MENU,\r
+        .name          = "Effect Control",\r
+        .minimum       = 0,\r
+        .maximum       = 5,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+       #endif\r
+\r
+       #if CONFIG_SENSOR_Exposure\r
+       {\r
+        .id            = V4L2_CID_EXPOSURE,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Exposure Control",\r
+        .minimum       = 0,\r
+        .maximum       = 6,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+       #endif\r
+\r
+       #if CONFIG_SENSOR_Saturation\r
+       {\r
+        .id            = V4L2_CID_SATURATION,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Saturation Control",\r
+        .minimum       = 0,\r
+        .maximum       = 2,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Contrast\r
+       {\r
+        .id            = V4L2_CID_CONTRAST,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Contrast Control",\r
+        .minimum       = -3,\r
+        .maximum       = 3,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+       #endif\r
+\r
+       #if CONFIG_SENSOR_Mirror\r
+       {\r
+        .id            = V4L2_CID_HFLIP,\r
+        .type          = V4L2_CTRL_TYPE_BOOLEAN,\r
+        .name          = "Mirror Control",\r
+        .minimum       = 0,\r
+        .maximum       = 1,\r
+        .step          = 1,\r
+        .default_value = 1,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Flip\r
+       {\r
+        .id            = V4L2_CID_VFLIP,\r
+        .type          = V4L2_CTRL_TYPE_BOOLEAN,\r
+        .name          = "Flip Control",\r
+        .minimum       = 0,\r
+        .maximum       = 1,\r
+        .step          = 1,\r
+        .default_value = 1,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Scene\r
+    {\r
+        .id            = V4L2_CID_SCENE,\r
+        .type          = V4L2_CTRL_TYPE_MENU,\r
+        .name          = "Scene Control",\r
+        .minimum       = 0,\r
+        .maximum       = 1,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_DigitalZoom\r
+    {\r
+        .id            = V4L2_CID_ZOOM_RELATIVE,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "DigitalZoom Control",\r
+        .minimum       = -1,\r
+        .maximum       = 1,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    }, {\r
+        .id            = V4L2_CID_ZOOM_ABSOLUTE,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "DigitalZoom Control",\r
+        .minimum       = 0,\r
+        .maximum       = 3,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Focus\r
+       {\r
+        .id            = V4L2_CID_FOCUS_RELATIVE,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Focus Control",\r
+        .minimum       = -1,\r
+        .maximum       = 1,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    }, {\r
+        .id            = V4L2_CID_FOCUS_ABSOLUTE,\r
+        .type          = V4L2_CTRL_TYPE_INTEGER,\r
+        .name          = "Focus Control",\r
+        .minimum       = 0,\r
+        .maximum       = 255,\r
+        .step          = 1,\r
+        .default_value = 125,\r
+    },\r
+    #endif\r
+\r
+       #if CONFIG_SENSOR_Flash\r
+       {\r
+        .id            = V4L2_CID_FLASH,\r
+        .type          = V4L2_CTRL_TYPE_MENU,\r
+        .name          = "Flash Control",\r
+        .minimum       = 0,\r
+        .maximum       = 3,\r
+        .step          = 1,\r
+        .default_value = 0,\r
+    },\r
+       #endif\r
+};\r
+\r
+static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);\r
+static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);\r
+static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);\r
+static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);\r
+static int sensor_g_ext_controls(struct v4l2_subdev *sd,  struct v4l2_ext_controls *ext_ctrl);\r
+static int sensor_s_ext_controls(struct v4l2_subdev *sd,  struct v4l2_ext_controls *ext_ctrl);\r
+static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);\r
+static int sensor_resume(struct soc_camera_device *icd);\r
+static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);\r
+static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);\r
+#if CONFIG_SENSOR_Effect\r
+static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);\r
+#endif\r
+#if CONFIG_SENSOR_WhiteBalance\r
+static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);\r
+#endif\r
+static int sensor_deactivate(struct i2c_client *client);\r
+\r
+static struct soc_camera_ops sensor_ops =\r
+{\r
+    .suspend                     = sensor_suspend,\r
+    .resume                       = sensor_resume,\r
+    .set_bus_param             = sensor_set_bus_param,\r
+    .query_bus_param   = sensor_query_bus_param,\r
+    .controls          = sensor_controls,\r
+    .menus                         = sensor_menus,\r
+    .num_controls              = ARRAY_SIZE(sensor_controls),\r
+    .num_menus         = ARRAY_SIZE(sensor_menus),\r
+};\r
+\r
+/* only one fixed colorspace per pixelcode */\r
+struct sensor_datafmt {\r
+       enum v4l2_mbus_pixelcode code;\r
+       enum v4l2_colorspace colorspace;\r
+};\r
+\r
+/* Find a data format by a pixel code in an array */\r
+static const struct sensor_datafmt *sensor_find_datafmt(\r
+       enum v4l2_mbus_pixelcode code, const struct sensor_datafmt *fmt,\r
+       int n)\r
+{\r
+       int i;\r
+       for (i = 0; i < n; i++)\r
+               if (fmt[i].code == code)\r
+                       return fmt + i;\r
+\r
+       return NULL;\r
+}\r
+\r
+static const struct sensor_datafmt sensor_colour_fmts[] = {\r
+    {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},\r
+    {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}    \r
+};\r
+\r
+typedef struct sensor_info_priv_s\r
+{\r
+    int whiteBalance;\r
+    int brightness;\r
+    int contrast;\r
+    int saturation;\r
+    int effect;\r
+    int scene;\r
+    int digitalzoom;\r
+    int focus;\r
+    int flash;\r
+    int exposure;\r
+       bool snap2preview;\r
+       bool video2preview;\r
+    unsigned char mirror;                                        /* HFLIP */\r
+    unsigned char flip;                                          /* VFLIP */\r
+    unsigned int winseqe_cur_addr;\r
+    struct sensor_datafmt fmt;\r
+    unsigned int funmodule_state;\r
+} sensor_info_priv_t;\r
+\r
+struct sensor\r
+{\r
+    struct v4l2_subdev subdev;\r
+    struct i2c_client *client;\r
+    sensor_info_priv_t info_priv;\r
+    int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */\r
+#if CONFIG_SENSOR_I2C_NOSCHED\r
+       atomic_t tasklock_cnt;\r
+#endif\r
+       struct rk29camera_platform_data *sensor_io_request;\r
+    struct rk29camera_gpio_res *sensor_gpio_res;\r
+};\r
+\r
+static struct sensor* to_sensor(const struct i2c_client *client)\r
+{\r
+    return container_of(i2c_get_clientdata(client), struct sensor, subdev);\r
+}\r
+\r
+static int sensor_task_lock(struct i2c_client *client, int lock)\r
+{\r
+#if CONFIG_SENSOR_I2C_NOSCHED\r
+       int cnt = 3;\r
+    struct sensor *sensor = to_sensor(client);\r
+\r
+       if (lock) {\r
+               if (atomic_read(&sensor->tasklock_cnt) == 0) {\r
+                       while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {\r
+                               SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());\r
+                               msleep(35);\r
+                               cnt--;\r
+                       }\r
+                       if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {\r
+                               SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());\r
+                               goto sensor_task_lock_err;\r
+                       }\r
+                       preempt_disable();\r
+               }\r
+\r
+               atomic_add(1, &sensor->tasklock_cnt);\r
+       } else {\r
+               if (atomic_read(&sensor->tasklock_cnt) > 0) {\r
+                       atomic_sub(1, &sensor->tasklock_cnt);\r
+\r
+                       if (atomic_read(&sensor->tasklock_cnt) == 0)\r
+                               preempt_enable();\r
+               }\r
+       }\r
+       return 0;\r
+sensor_task_lock_err:\r
+       return -1;  \r
+#else\r
+    return 0;\r
+#endif\r
+\r
+}\r
+static int sensor_write(struct i2c_client *client, u8 reg, u8 val)\r
+{\r
+    int err,cnt;\r
+    u8 buf[2];\r
+    struct i2c_msg msg[1];\r
+\r
+    buf[0] = reg & 0xFF;\r
+    buf[1] = val;\r
+\r
+    msg->addr = client->addr;\r
+    msg->flags = client->flags;\r
+    msg->buf = buf;\r
+    msg->len = sizeof(buf);\r
+    msg->scl_rate = CONFIG_SENSOR_I2C_SPEED;                                        /* ddl@rock-chips.com : 100kHz */\r
+    msg->read_type = 0;               /* fpga i2c:0==I2C_NORMAL : direct use number not enum for don't want include spi_fpga.h */\r
+\r
+    cnt = 3;\r
+    err = -EAGAIN;\r
+\r
+    while ((cnt-->0) && (err < 0)) {                       /* ddl@rock-chips.com :  Transfer again if transent is failed   */\r
+        err = i2c_transfer(client->adapter, msg, 1);\r
+\r
+        if (err >= 0) {\r
+            return 0;\r
+        } else {\r
+            SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg, val);\r
+            udelay(10);\r
+        }\r
+    }\r
+\r
+    return err;\r
+}\r
+\r
+/* sensor register read */\r
+static int sensor_read(struct i2c_client *client, u8 reg, u8 *val)\r
+{\r
+    int err,cnt;\r
+    u8 buf[1];\r
+    struct i2c_msg msg[2];\r
+\r
+    buf[0] = reg ;//>> 8;\r
+   // buf[1] = 0;\r
+\r
+    msg[0].addr = client->addr;\r
+    msg[0].flags = client->flags;\r
+    msg[0].buf = buf;\r
+    msg[0].len = sizeof(buf);\r
+    msg[0].scl_rate = CONFIG_SENSOR_I2C_SPEED;       /* ddl@rock-chips.com : 100kHz */\r
+    msg[0].read_type = 2;//0x55;   /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */\r
+\r
+    msg[1].addr = client->addr;\r
+    msg[1].flags = client->flags|I2C_M_RD;\r
+    msg[1].buf = buf;\r
+    msg[1].len = 1;\r
+    msg[1].scl_rate = CONFIG_SENSOR_I2C_SPEED;                       /* ddl@rock-chips.com : 100kHz */\r
+    msg[1].read_type = 2;                             /* fpga i2c:0==I2C_NO_STOP : direct use number not enum for don't want include spi_fpga.h */\r
+\r
+    cnt = 3;\r
+    err = -EAGAIN;\r
+    while ((cnt-->0) && (err < 0)) {                       /* ddl@rock-chips.com :  Transfer again if transent is failed   */\r
+        err = i2c_transfer(client->adapter, msg, 2);\r
+\r
+        if (err >= 0) {\r
+            *val = buf[0];\r
+            return 0;\r
+        } else {\r
+               SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);\r
+            udelay(10);\r
+        }\r
+    }\r
+\r
+    return err;\r
+}\r
+\r
+/* write a array of registers  */\r
+static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)\r
+{\r
+    int err = 0, cnt;\r
+    int i = 0;\r
+#if CONFIG_SENSOR_I2C_RDWRCHK    \r
+       char valchk;\r
+#endif\r
+\r
+       cnt = 0;\r
+       if (sensor_task_lock(client, 1) < 0)\r
+               goto sensor_write_array_end;\r
+    while (regarray[i].reg != 0)\r
+    {\r
+        err = sensor_write(client, regarray[i].reg, regarray[i].val);\r
+        if (err < 0)\r
+        {\r
+            if (cnt-- > 0) {\r
+                           SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);\r
+                               i = 0;\r
+                               continue;\r
+            } else {\r
+                SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());\r
+                err = -EPERM;\r
+                               goto sensor_write_array_end;\r
+            }\r
+        } else {\r
+        #if CONFIG_SENSOR_I2C_RDWRCHK\r
+                       sensor_read(client, regarray[i].reg, &valchk);\r
+                       if (valchk != regarray[i].val)\r
+                               SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);\r
+               #endif\r
+        }\r
+        i++;\r
+    }\r
+\r
+sensor_write_array_end:\r
+       sensor_task_lock(client,0);\r
+       return err;\r
+}\r
+#if CONFIG_SENSOR_I2C_RDWRCHK\r
+static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)\r
+{\r
+    int cnt;\r
+    int i = 0;\r
+       char valchk;\r
+\r
+       cnt = 0;\r
+       valchk = 0;\r
+    while (regarray[i].reg != 0)\r
+    {\r
+               sensor_read(client, regarray[i].reg, &valchk);\r
+               if (valchk != regarray[i].val)\r
+                       SENSOR_TR("%s Reg:0x%x read(0x%x, 0x%x) error\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);\r
+\r
+        i++;\r
+    }\r
+    return 0;\r
+}\r
+#endif\r
+static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)\r
+{\r
+       struct soc_camera_link *icl = to_soc_camera_link(icd);\r
+       int ret = 0;\r
+\r
+    SENSOR_DG("%s %s  cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);\r
+\r
+       switch (cmd)\r
+       {\r
+               case Sensor_PowerDown:\r
+               {\r
+                       if (icl->powerdown) {\r
+                               ret = icl->powerdown(icd->pdev, on);\r
+                               if (ret == RK29_CAM_IO_SUCCESS) {\r
+                                       if (on == 0) {\r
+                                               mdelay(2);\r
+                                               if (icl->reset)\r
+                                                       icl->reset(icd->pdev);\r
+                                       }\r
+                               } else if (ret == RK29_CAM_EIO_REQUESTFAIL) {\r
+                                       ret = -ENODEV;\r
+                                       goto sensor_power_end;\r
+                               }\r
+                       }\r
+                       break;\r
+               }\r
+               case Sensor_Flash:\r
+               {\r
+                       struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+               struct sensor *sensor = to_sensor(client);\r
+\r
+                       if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {\r
+                               sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);\r
+                if(on){\r
+                    //flash off after 2 secs\r
+                       hrtimer_cancel(&(flash_off_timer.timer));\r
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);\r
+                    }\r
+                       }\r
+            break;\r
+               }\r
+               default:\r
+               {\r
+                       SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);\r
+                       break;\r
+               }\r
+       }\r
+sensor_power_end:\r
+       return ret;\r
+}\r
+\r
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){\r
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);\r
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);\r
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);\r
+    return 0;\r
+    \r
+}\r
+\r
+static int sensor_init(struct v4l2_subdev *sd, u32 val)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct soc_camera_device *icd = client->dev.platform_data;
-    struct sensor *sensor = to_sensor(client);
-       const struct v4l2_queryctrl *qctrl;
-    const struct sensor_datafmt *fmt;
-    char value;
-    int ret,pid = 0;
-
-    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, 0xff, 1);
-    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
-       /* check if it is an sensor sensor */
-    ret = sensor_write(client, 0xff, 1);
-    ret |= sensor_read(client, 0x0a, &value);
-    if (ret != 0) {
-        SENSOR_TR("read chip id high byte failed\n");
-        ret = -ENODEV;
-        goto sensor_INIT_ERR;
-    }
-
-    pid = value << 8;
-    ret = sensor_read(client, 0x0b, &value);
-    if (ret != 0) {
-        SENSOR_TR("read chip id low byte failed\n");
-        ret = -ENODEV;
-        goto sensor_INIT_ERR;
-    }
-
-    pid |= (value & 0xff);
-
-    SENSOR_DG("\n %s  pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
-    if ((pid == SENSOR_ID)||(pid == SENSOR_ID1)) {
-        sensor->model = SENSOR_V4L2_IDENT;
-    } else {
-        SENSOR_TR("error: %s mismatched   pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
-        ret = -ENODEV;
-        goto sensor_INIT_ERR;
-    }
-
-    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;
-    }
-       sensor_task_lock(client,0);
-    sensor->info_priv.winseqe_cur_addr  = (int)SENSOR_INIT_WINSEQADR;
-    fmt = sensor_find_datafmt(SENSOR_INIT_PIXFMT,sensor_colour_fmts, ARRAY_SIZE(sensor_colour_fmts));
-    if (!fmt) {
-        SENSOR_TR("error: %s initial array colour fmts is not support!!",SENSOR_NAME_STRING());
-        ret = -EINVAL;
-        goto sensor_INIT_ERR;
-    }
-       sensor->info_priv.fmt = *fmt;
-
-    /* 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:
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    struct sensor *sensor = to_sensor(client);\r
+       const struct v4l2_queryctrl *qctrl;\r
+    const struct sensor_datafmt *fmt;\r
+    char value;\r
+    int ret,pid = 0;\r
+\r
+    SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);\r
+\r
+       if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {\r
+               ret = -ENODEV;\r
+               goto sensor_INIT_ERR;\r
+       }\r
+\r
+    /* soft reset */\r
+       if (sensor_task_lock(client,1)<0)\r
+               goto sensor_INIT_ERR;\r
+    ret = sensor_write(client, 0xff, 1);\r
+    ret |= sensor_write(client, 0x12, 0x80);\r
+    if (ret != 0)\r
+    {\r
+        SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());\r
+        ret = -ENODEV;\r
+               goto sensor_INIT_ERR;\r
+    }\r
+\r
+    mdelay(5);  //delay 5 microseconds\r
+       /* check if it is an sensor sensor */\r
+    ret = sensor_write(client, 0xff, 1);\r
+    ret |= sensor_read(client, 0x0a, &value);\r
+    if (ret != 0) {\r
+        SENSOR_TR("read chip id high byte failed\n");\r
+        ret = -ENODEV;\r
+        goto sensor_INIT_ERR;\r
+    }\r
+\r
+    pid = value << 8;\r
+    ret = sensor_read(client, 0x0b, &value);\r
+    if (ret != 0) {\r
+        SENSOR_TR("read chip id low byte failed\n");\r
+        ret = -ENODEV;\r
+        goto sensor_INIT_ERR;\r
+    }\r
+\r
+    pid |= (value & 0xff);\r
+\r
+    SENSOR_DG("\n %s  pid = 0x%x\n", SENSOR_NAME_STRING(), pid);\r
+    if ((pid == SENSOR_ID)||(pid == SENSOR_ID1)) {\r
+        sensor->model = SENSOR_V4L2_IDENT;\r
+    } else {\r
+        SENSOR_TR("error: %s mismatched   pid = 0x%x\n", SENSOR_NAME_STRING(), pid);\r
+        ret = -ENODEV;\r
+        goto sensor_INIT_ERR;\r
+    }\r
+\r
+    ret = sensor_write_array(client, sensor_init_data);\r
+    if (ret != 0)\r
+    {\r
+        SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());\r
+        goto sensor_INIT_ERR;\r
+    }\r
+       sensor_task_lock(client,0);\r
+    sensor->info_priv.winseqe_cur_addr  = (int)SENSOR_INIT_WINSEQADR;\r
+    fmt = sensor_find_datafmt(SENSOR_INIT_PIXFMT,sensor_colour_fmts, ARRAY_SIZE(sensor_colour_fmts));\r
+    if (!fmt) {\r
+        SENSOR_TR("error: %s initial array colour fmts is not support!!",SENSOR_NAME_STRING());\r
+        ret = -EINVAL;\r
+        goto sensor_INIT_ERR;\r
+    }\r
+       sensor->info_priv.fmt = *fmt;\r
+\r
+    /* sensor sensor information for initialization  */\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);\r
+       if (qctrl)\r
+       sensor->info_priv.whiteBalance = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);\r
+       if (qctrl)\r
+       sensor->info_priv.brightness = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);\r
+       if (qctrl)\r
+       sensor->info_priv.effect = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);\r
+       if (qctrl)\r
+        sensor->info_priv.exposure = qctrl->default_value;\r
+\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);\r
+       if (qctrl)\r
+        sensor->info_priv.saturation = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);\r
+       if (qctrl)\r
+        sensor->info_priv.contrast = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);\r
+       if (qctrl)\r
+        sensor->info_priv.mirror = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);\r
+       if (qctrl)\r
+        sensor->info_priv.flip = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);\r
+       if (qctrl)\r
+        sensor->info_priv.scene = qctrl->default_value;\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);\r
+       if (qctrl)\r
+        sensor->info_priv.digitalzoom = qctrl->default_value;\r
+\r
+    /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code  */\r
+       #if CONFIG_SENSOR_Focus\r
+    sensor_set_focus();\r
+    qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);\r
+       if (qctrl)\r
+        sensor->info_priv.focus = qctrl->default_value;\r
+       #endif\r
+\r
+       #if CONFIG_SENSOR_Flash\r
+       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);\r
+       if (qctrl)\r
+        sensor->info_priv.flash = qctrl->default_value;\r
+\r
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);\r
+    flash_off_timer.icd = icd;\r
+       flash_off_timer.timer.function = flash_off_func;\r
+    #endif\r
+\r
+    SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),((val == 0)?__FUNCTION__:"sensor_reinit"),icd->user_width,icd->user_height);\r
+    sensor->info_priv.funmodule_state |= SENSOR_INIT_IS_OK;\r
+    return 0;\r
+sensor_INIT_ERR:\r
     sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;\r
-       sensor_task_lock(client,0);
-       sensor_deactivate(client);
-    return ret;
-}
-
-static int sensor_deactivate(struct i2c_client *client)
-{
-       struct soc_camera_device *icd = client->dev.platform_data;
-
+       sensor_task_lock(client,0);\r
+       sensor_deactivate(client);\r
+    return ret;\r
+}\r
+\r
+static int sensor_deactivate(struct i2c_client *client)\r
+{\r
+       struct soc_camera_device *icd = client->dev.platform_data;\r
+\r
     struct sensor *sensor = to_sensor(client);\r
-       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 0  
-       sensor_task_lock(client, 1);
-    sensor_write(client, 0x3000, reg_val&0xfc);
-       sensor_write(client, 0x3001, 0x00);
-       sensor_task_lock(client, 0);
-#endif
-       sensor_ioctrl(icd, Sensor_PowerDown, 1);
+       SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);\r
+\r
+       /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */\r
+#if 0  \r
+       sensor_task_lock(client, 1);\r
+    sensor_write(client, 0x3000, reg_val&0xfc);\r
+       sensor_write(client, 0x3001, 0x00);\r
+       sensor_task_lock(client, 0);\r
+#endif\r
+       sensor_ioctrl(icd, Sensor_PowerDown, 1);\r
     msleep(100); \r
-       /* 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;
+       /* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */\r
+       icd->user_width = SENSOR_INIT_WIDTH;\r
+    icd->user_height = SENSOR_INIT_HEIGHT;\r
     sensor->info_priv.funmodule_state &= ~SENSOR_INIT_IS_OK;\r
-       
-       return 0;
-}
-
-static  struct reginfo sensor_power_down_sequence[]=
-{
-    {0x00,0x00}
-};
-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_mbus_framefmt *mf)
-{
+       \r
+       return 0;\r
+}\r
+\r
+static  struct reginfo sensor_power_down_sequence[]=\r
+{\r
+    {0x00,0x00}\r
+};\r
+static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)\r
+{\r
+    int ret;\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if (pm_msg.event == PM_EVENT_SUSPEND) {\r
+        SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());\r
+        ret = sensor_write_array(client, sensor_power_down_sequence) ;\r
+        if (ret != 0) {\r
+            SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);\r
+            return ret;\r
+        } else {\r
+            ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);\r
+            if (ret < 0) {\r
+                           SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());\r
+                return -EINVAL;\r
+            }\r
+        }\r
+    } else {\r
+        SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());\r
+        return -EINVAL;\r
+    }\r
+    return 0;\r
+}\r
+\r
+static int sensor_resume(struct soc_camera_device *icd)\r
+{\r
+       int ret;\r
+\r
+    ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);\r
+    if (ret < 0) {\r
+               SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());\r
+        return -EINVAL;\r
+    }\r
+\r
+       SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());\r
+\r
+    return 0;\r
+\r
+}\r
+\r
+static int sensor_set_bus_param(struct soc_camera_device *icd,\r
+                                unsigned long flags)\r
+{\r
+\r
+    return 0;\r
+}\r
+\r
+static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)\r
+{\r
+    struct soc_camera_link *icl = to_soc_camera_link(icd);\r
+    unsigned long flags = SENSOR_BUS_PARAM;\r
+\r
+    return soc_camera_apply_sensor_flags(icl, flags);\r
+}\r
+\r
+static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct soc_camera_device *icd = client->dev.platform_data;
-    struct sensor *sensor = to_sensor(client);
-
-    mf->width  = icd->user_width;
-       mf->height      = icd->user_height;
-       mf->code        = sensor->info_priv.fmt.code;
-       mf->colorspace  = sensor->info_priv.fmt.colorspace;
-       mf->field       = V4L2_FIELD_NONE;
-
-    return 0;
-}
-static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
-    bool ret = false;
-
-       if ((mf->width == 1024) && (mf->height == 768)) {
-               ret = true;
-       } else if ((mf->width == 1280) && (mf->height == 1024)) {
-               ret = true;
-       } else if ((mf->width == 1600) && (mf->height == 1200)) {
-               ret = true;
-       } else if ((mf->width == 2048) && (mf->height == 1536)) {
-               ret = true;
-       } else if ((mf->width == 2592) && (mf->height == 1944)) {
-               ret = true;
-       }
-
-       if (ret == true)
-               SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, mf->width, mf->height);
-       return ret;
-}
-
-static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
-    bool ret = false;
-
-       if ((mf->width == 1280) && (mf->height == 720)) {
-               ret = true;
-       } else if ((mf->width == 1920) && (mf->height == 1080)) {
-               ret = true;
-       }
-
-       if (ret == true)
-               SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, mf->width, mf->height);
-       return ret;
-}
-static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    struct sensor *sensor = to_sensor(client);\r
+\r
+    mf->width  = icd->user_width;\r
+       mf->height      = icd->user_height;\r
+       mf->code        = sensor->info_priv.fmt.code;\r
+       mf->colorspace  = sensor->info_priv.fmt.colorspace;\r
+       mf->field       = V4L2_FIELD_NONE;\r
+\r
+    return 0;\r
+}\r
+static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
+    bool ret = false;\r
+\r
+       if ((mf->width == 1024) && (mf->height == 768)) {\r
+               ret = true;\r
+       } else if ((mf->width == 1280) && (mf->height == 1024)) {\r
+               ret = true;\r
+       } else if ((mf->width == 1600) && (mf->height == 1200)) {\r
+               ret = true;\r
+       } else if ((mf->width == 2048) && (mf->height == 1536)) {\r
+               ret = true;\r
+       } else if ((mf->width == 2592) && (mf->height == 1944)) {\r
+               ret = true;\r
+       }\r
+\r
+       if (ret == true)\r
+               SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, mf->width, mf->height);\r
+       return ret;\r
+}\r
+\r
+static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
+    bool ret = false;\r
+\r
+       if ((mf->width == 1280) && (mf->height == 720)) {\r
+               ret = true;\r
+       } else if ((mf->width == 1920) && (mf->height == 1080)) {\r
+               ret = true;\r
+       }\r
+\r
+       if (ret == true)\r
+               SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, mf->width, mf->height);\r
+       return ret;\r
+}\r
+static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct sensor *sensor = to_sensor(client);
-    const struct sensor_datafmt *fmt;
-       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;
-
-       fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
-                                  ARRAY_SIZE(sensor_colour_fmts));
-       if (!fmt) {
-        ret = -EINVAL;
-        goto sensor_s_fmt_end;
-    }
-
-       if (sensor->info_priv.fmt.code != mf->code) {
-               switch (mf->code)
-               {
-                       case V4L2_MBUS_FMT_YUYV8_2X8:
-                       {
-                               winseqe_set_addr = sensor_ClrFmt_YUYV;
-                               break;
-                       }
-                       case V4L2_MBUS_FMT_UYVY8_2X8:
-                       {
-                               winseqe_set_addr = sensor_ClrFmt_UYVY;
-                               break;
-                       }
-                       default:
-                               break;
-               }
-               if (winseqe_set_addr != NULL) {
-            sensor_write_array(client, winseqe_set_addr);
-                       sensor->info_priv.fmt.code = mf->code;
-            sensor->info_priv.fmt.colorspace= mf->colorspace;            
-                       SENSOR_DG("%s v4l2_mbus_code:%d set success!\n", SENSOR_NAME_STRING(),mf->code);
-               } else {
-                       SENSOR_TR("%s v4l2_mbus_code:%d is invalidate!\n", SENSOR_NAME_STRING(),mf->code);
-               }
-       }
-
-    set_w = mf->width;
-    set_h = mf->height;
-
-       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
-       {
-               winseqe_set_addr = sensor_qcif;
-        set_w = 176;
-        set_h = 144;
-       }
-       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
-    {
-        winseqe_set_addr = sensor_qvga;
-        set_w = 320;
-        set_h = 240;
-    }
-    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
-    {
-        winseqe_set_addr = sensor_cif;
-        set_w = 352;
-        set_h = 288;
-    }
-    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
-    {
-        winseqe_set_addr = sensor_vga;
-        set_w = 640;
-        set_h = 480;
-    }
-    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
-    {
-        winseqe_set_addr = sensor_svga;
-        set_w = 800;
-        set_h = 600;
-    }
-       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
-    {
-        winseqe_set_addr = sensor_xga;
-        set_w = 1024;
-        set_h = 768;
-    }
-    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
-    {
-        winseqe_set_addr = sensor_sxga;
-        set_w = 1280;
-        set_h = 1024;
-    }
-    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
-    {
-        winseqe_set_addr = sensor_uxga;
-        set_w = 1600;
-        set_h = 1200;
-    }
-    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__,mf->width,mf->height);
-    }
-
-    if ((int)winseqe_set_addr  != sensor->info_priv.winseqe_cur_addr) {
-        #if CONFIG_SENSOR_Flash
-        if (sensor_fmt_capturechk(sd,mf) == 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,mf) == 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,mf) == true) {                                 /* ddl@rock-chips.com : Capture */
-        #if CONFIG_SENSOR_Effect
-                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
-                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
-        #endif
-        #if CONFIG_SENSOR_WhiteBalance
-                       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);
-                       }
-        #endif
-                       sensor->info_priv.snap2preview = true;
-               } else if (sensor_fmt_videochk(sd,mf) == true) {                        /* ddl@rock-chips.com : Video */
-               #if CONFIG_SENSOR_Effect
-                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
-                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
-        #endif
-        #if CONFIG_SENSOR_WhiteBalance
-                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
-                       sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
-        #endif
-                       sensor->info_priv.video2preview = true;
-               } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) {
-               #if CONFIG_SENSOR_Effect
-                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
-                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
-        #endif
-        #if CONFIG_SENSOR_WhiteBalance    
-                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
-                       sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
-        #endif    
-                       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);
-    }
-
-       mf->width = set_w;
-    mf->height = set_h;
-
-sensor_s_fmt_end:
-    return ret;
-}
-
-static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
+    struct sensor *sensor = to_sensor(client);\r
+    const struct sensor_datafmt *fmt;\r
+       const struct v4l2_queryctrl *qctrl;\r
+       struct soc_camera_device *icd = client->dev.platform_data;\r
+    struct reginfo *winseqe_set_addr=NULL;\r
+    int ret=0, set_w,set_h;\r
+\r
+       fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,\r
+                                  ARRAY_SIZE(sensor_colour_fmts));\r
+       if (!fmt) {\r
+        ret = -EINVAL;\r
+        goto sensor_s_fmt_end;\r
+    }\r
+\r
+       if (sensor->info_priv.fmt.code != mf->code) {\r
+               switch (mf->code)\r
+               {\r
+                       case V4L2_MBUS_FMT_YUYV8_2X8:\r
+                       {\r
+                               winseqe_set_addr = sensor_ClrFmt_YUYV;\r
+                               break;\r
+                       }\r
+                       case V4L2_MBUS_FMT_UYVY8_2X8:\r
+                       {\r
+                               winseqe_set_addr = sensor_ClrFmt_UYVY;\r
+                               break;\r
+                       }\r
+                       default:\r
+                               break;\r
+               }\r
+               if (winseqe_set_addr != NULL) {\r
+            sensor_write_array(client, winseqe_set_addr);\r
+                       sensor->info_priv.fmt.code = mf->code;\r
+            sensor->info_priv.fmt.colorspace= mf->colorspace;            \r
+                       SENSOR_DG("%s v4l2_mbus_code:%d set success!\n", SENSOR_NAME_STRING(),mf->code);\r
+               } else {\r
+                       SENSOR_TR("%s v4l2_mbus_code:%d is invalidate!\n", SENSOR_NAME_STRING(),mf->code);\r
+               }\r
+       }\r
+\r
+    set_w = mf->width;\r
+    set_h = mf->height;\r
+\r
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)\r
+       {\r
+               winseqe_set_addr = sensor_qcif;\r
+        set_w = 176;\r
+        set_h = 144;\r
+       }\r
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_qvga;\r
+        set_w = 320;\r
+        set_h = 240;\r
+    }\r
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_cif;\r
+        set_w = 352;\r
+        set_h = 288;\r
+    }\r
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_vga;\r
+        set_w = 640;\r
+        set_h = 480;\r
+    }\r
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_svga;\r
+        set_w = 800;\r
+        set_h = 600;\r
+    }\r
+       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_xga;\r
+        set_w = 1024;\r
+        set_h = 768;\r
+    }\r
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_sxga;\r
+        set_w = 1280;\r
+        set_h = 1024;\r
+    }\r
+    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)\r
+    {\r
+        winseqe_set_addr = sensor_uxga;\r
+        set_w = 1600;\r
+        set_h = 1200;\r
+    }\r
+    else\r
+    {\r
+        winseqe_set_addr = SENSOR_INIT_WINSEQADR;               /* ddl@rock-chips.com : Sensor output smallest size if  isn't support app  */\r
+        set_w = SENSOR_INIT_WIDTH;\r
+        set_h = SENSOR_INIT_HEIGHT;\r
+               SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,mf->width,mf->height);\r
+    }\r
+\r
+    if ((int)winseqe_set_addr  != sensor->info_priv.winseqe_cur_addr) {\r
+        #if CONFIG_SENSOR_Flash\r
+        if (sensor_fmt_capturechk(sd,mf) == true) {      /* ddl@rock-chips.com : Capture */\r
+            if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {\r
+                sensor_ioctrl(icd, Sensor_Flash, Flash_On);\r
+                SENSOR_DG("%s flash on in capture!\n", SENSOR_NAME_STRING());\r
+            }           \r
+        } else {                                        /* ddl@rock-chips.com : Video */\r
+            if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {\r
+                sensor_ioctrl(icd, Sensor_Flash, Flash_Off);\r
+                SENSOR_DG("%s flash off in preivew!\n", SENSOR_NAME_STRING());\r
+            }\r
+        }\r
+        #endif        \r
+        ret |= sensor_write_array(client, winseqe_set_addr);\r
+        if (ret != 0) {\r
+            SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());\r
+            #if CONFIG_SENSOR_Flash\r
+            if (sensor_fmt_capturechk(sd,mf) == true) {\r
+                if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {\r
+                    sensor_ioctrl(icd, Sensor_Flash, Flash_Off);\r
+                    SENSOR_TR("%s Capture format set fail, flash off !\n", SENSOR_NAME_STRING());\r
+                }\r
+            }\r
+            #endif\r
+            goto sensor_s_fmt_end;\r
+        }\r
+\r
+        sensor->info_priv.winseqe_cur_addr  = (int)winseqe_set_addr;\r
+\r
+               if (sensor_fmt_capturechk(sd,mf) == true) {                                 /* ddl@rock-chips.com : Capture */\r
+        #if CONFIG_SENSOR_Effect\r
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);\r
+                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);\r
+        #endif\r
+        #if CONFIG_SENSOR_WhiteBalance\r
+                       if (sensor->info_priv.whiteBalance != 0) {\r
+                               qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);\r
+                               sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);\r
+                       }\r
+        #endif\r
+                       sensor->info_priv.snap2preview = true;\r
+               } else if (sensor_fmt_videochk(sd,mf) == true) {                        /* ddl@rock-chips.com : Video */\r
+               #if CONFIG_SENSOR_Effect\r
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);\r
+                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);\r
+        #endif\r
+        #if CONFIG_SENSOR_WhiteBalance\r
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);\r
+                       sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);\r
+        #endif\r
+                       sensor->info_priv.video2preview = true;\r
+               } else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) {\r
+               #if CONFIG_SENSOR_Effect\r
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);\r
+                       sensor_set_effect(icd, qctrl,sensor->info_priv.effect);\r
+        #endif\r
+        #if CONFIG_SENSOR_WhiteBalance    \r
+                       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);\r
+                       sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);\r
+        #endif    \r
+                       sensor->info_priv.video2preview = false;            \r
+                       sensor->info_priv.snap2preview = false;\r
+               }\r
+        SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);\r
+    }\r
+    else\r
+    {\r
+        SENSOR_DG("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);\r
+    }\r
+\r
+       mf->width = set_w;\r
+    mf->height = set_h;\r
+\r
+sensor_s_fmt_end:\r
+    return ret;\r
+}\r
+\r
+static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct sensor *sensor = to_sensor(client);
-    const struct sensor_datafmt *fmt;
+    struct sensor *sensor = to_sensor(client);\r
+    const struct sensor_datafmt *fmt;\r
     int ret = 0,set_w,set_h;\r
-   
-       fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
-                                  ARRAY_SIZE(sensor_colour_fmts));
-       if (fmt == NULL) {
-               fmt = &sensor->info_priv.fmt;
-        mf->code = fmt->code;
-       } 
-
-    if (mf->height > SENSOR_MAX_HEIGHT)
-        mf->height = SENSOR_MAX_HEIGHT;
-    else if (mf->height < SENSOR_MIN_HEIGHT)
-        mf->height = SENSOR_MIN_HEIGHT;
-
-    if (mf->width > SENSOR_MAX_WIDTH)
-        mf->width = SENSOR_MAX_WIDTH;
-    else if (mf->width < SENSOR_MIN_WIDTH)
-        mf->width = SENSOR_MIN_WIDTH;
-\r
-    set_w = mf->width;
-    set_h = mf->height;
-
-       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
-       {
+   \r
+       fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,\r
+                                  ARRAY_SIZE(sensor_colour_fmts));\r
+       if (fmt == NULL) {\r
+               fmt = &sensor->info_priv.fmt;\r
+        mf->code = fmt->code;\r
+       } \r
+\r
+    if (mf->height > SENSOR_MAX_HEIGHT)\r
+        mf->height = SENSOR_MAX_HEIGHT;\r
+    else if (mf->height < SENSOR_MIN_HEIGHT)\r
+        mf->height = SENSOR_MIN_HEIGHT;\r
+\r
+    if (mf->width > SENSOR_MAX_WIDTH)\r
+        mf->width = SENSOR_MAX_WIDTH;\r
+    else if (mf->width < SENSOR_MIN_WIDTH)\r
+        mf->width = SENSOR_MIN_WIDTH;\r
+\r
+    set_w = mf->width;\r
+    set_h = mf->height;\r
+\r
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)\r
+       {\r
         set_w = 176;\r
-        set_h = 144;
-       }
-       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
-    {
+        set_h = 144;\r
+       }\r
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)\r
+    {\r
         set_w = 320;\r
-        set_h = 240;
-    }
-    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
-    {
+        set_h = 240;\r
+    }\r
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)\r
+    {\r
         set_w = 352;\r
-        set_h = 288;
-    }
-    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
-    {
+        set_h = 288;\r
+    }\r
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)\r
+    {\r
         set_w = 640;\r
-        set_h = 480;
-    }
-    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
-    {
+        set_h = 480;\r
+    }\r
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)\r
+    {\r
         set_w = 800;\r
-        set_h = 600;
-    }
-       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
-    {
+        set_h = 600;\r
+    }\r
+       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)\r
+    {\r
         set_w = 1024;\r
-        set_h = 768;
-    }
-    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
-    {
+        set_h = 768;\r
+    }\r
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)\r
+    {\r
         set_w = 1280;\r
-        set_h = 1024;
-    }
-    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
-    {
+        set_h = 1024;\r
+    }\r
+    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)\r
+    {\r
         set_w = 1600;\r
-        set_h = 1200;
-    }
-    else
-    {
+        set_h = 1200;\r
+    }\r
+    else\r
+    {\r
         set_w = SENSOR_INIT_WIDTH;\r
-        set_h = SENSOR_INIT_HEIGHT;
+        set_h = SENSOR_INIT_HEIGHT;\r
     }\r
-
-    mf->width = set_w;
+\r
+    mf->width = set_w;\r
     mf->height = set_h;\r
 \r
-    mf->colorspace = fmt->colorspace;
-    
-    return ret;
-}
- static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
-{
+    mf->colorspace = fmt->colorspace;\r
+    \r
+    return ret;\r
+}\r
+ static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-
-    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 OV2655  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_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_MirrorSeqe[value - qctrl->minimum] != NULL)
-        {
-            if (sensor_write_array(client, sensor_MirrorSeqe[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_Flip
-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_FlipSeqe[value - qctrl->minimum] != NULL)
-        {
-            if (sensor_write_array(client, sensor_FlipSeqe[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_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)
-{
+\r
+    if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)\r
+        return -EINVAL;\r
+\r
+    if (id->match.addr != client->addr)\r
+        return -ENODEV;\r
+\r
+    id->ident = SENSOR_V4L2_IDENT;      /* ddl@rock-chips.com :  Return OV2655  identifier */\r
+    id->revision = 0;\r
+\r
+    return 0;\r
+}\r
+#if CONFIG_SENSOR_Brightness\r
+static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Effect\r
+static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Exposure\r
+static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Saturation\r
+static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Contrast\r
+static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Mirror\r
+static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_MirrorSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_MirrorSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Flip\r
+static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_FlipSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_FlipSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Scene\r
+static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+    SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_WhiteBalance\r
+static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+\r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum))\r
+    {\r
+        if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)\r
+        {\r
+            if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)\r
+            {\r
+                SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+                return -EINVAL;\r
+            }\r
+            SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+            return 0;\r
+        }\r
+    }\r
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_DigitalZoom\r
+static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)\r
+{\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+    struct sensor *sensor = to_sensor(client);\r
+       const struct v4l2_queryctrl *qctrl_info;\r
+    int digitalzoom_cur, digitalzoom_total;\r
+\r
+       qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);\r
+       if (qctrl_info)\r
+               return -EINVAL;\r
+\r
+    digitalzoom_cur = sensor->info_priv.digitalzoom;\r
+    digitalzoom_total = qctrl_info->maximum;\r
+\r
+    if ((value > 0) && (digitalzoom_cur >= digitalzoom_total))\r
+    {\r
+        SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);\r
+        return -EINVAL;\r
+    }\r
+\r
+    if  ((value < 0) && (digitalzoom_cur <= qctrl_info->minimum))\r
+    {\r
+        SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);\r
+        return -EINVAL;\r
+    }\r
+\r
+    if ((value > 0) && ((digitalzoom_cur + value) > digitalzoom_total))\r
+    {\r
+        value = digitalzoom_total - digitalzoom_cur;\r
+    }\r
+\r
+    if ((value < 0) && ((digitalzoom_cur + value) < 0))\r
+    {\r
+        value = 0 - digitalzoom_cur;\r
+    }\r
+\r
+    digitalzoom_cur += value;\r
+\r
+    if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)\r
+    {\r
+        if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)\r
+        {\r
+            SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);\r
+            return -EINVAL;\r
+        }\r
+        SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+        return 0;\r
+    }\r
+\r
+    return -EINVAL;\r
+}\r
+#endif\r
+#if CONFIG_SENSOR_Flash\r
+static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)\r
+{    \r
+    if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {\r
+        if (value == 3) {       /* ddl@rock-chips.com: torch */\r
+            sensor_ioctrl(icd, Sensor_Flash, Flash_Torch);   /* Flash On */\r
+        } else {\r
+            sensor_ioctrl(icd, Sensor_Flash, Flash_Off);\r
+        }\r
+        SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);\r
+        return 0;\r
+    }\r
+    \r
+       SENSOR_TR("\n %s..%s valure = %d is invalidate..    \n",SENSOR_NAME_STRING(),__FUNCTION__,value);\r
+    return -EINVAL;\r
+}\r
+#endif\r
+\r
+static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct sensor *sensor = to_sensor(client);
-    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 sensor *sensor = to_sensor(client);\r
+    const struct v4l2_queryctrl *qctrl;\r
+\r
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);\r
+\r
+    if (!qctrl)\r
+    {\r
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);\r
+        return -EINVAL;\r
+    }\r
+\r
+    switch (ctrl->id)\r
+    {\r
+        case V4L2_CID_BRIGHTNESS:\r
+            {\r
+                ctrl->value = sensor->info_priv.brightness;\r
+                break;\r
+            }\r
+        case V4L2_CID_SATURATION:\r
+            {\r
+                ctrl->value = sensor->info_priv.saturation;\r
+                break;\r
+            }\r
+        case V4L2_CID_CONTRAST:\r
+            {\r
+                ctrl->value = sensor->info_priv.contrast;\r
+                break;\r
+            }\r
+        case V4L2_CID_DO_WHITE_BALANCE:\r
+            {\r
+                ctrl->value = sensor->info_priv.whiteBalance;\r
+                break;\r
+            }\r
+        case V4L2_CID_EXPOSURE:\r
+            {\r
+                ctrl->value = sensor->info_priv.exposure;\r
+                break;\r
+            }\r
+        case V4L2_CID_HFLIP:\r
+            {\r
+                ctrl->value = sensor->info_priv.mirror;\r
+                break;\r
+            }\r
+        case V4L2_CID_VFLIP:\r
+            {\r
+                ctrl->value = sensor->info_priv.flip;\r
+                break;\r
+            }\r
+        default :\r
+                break;\r
+    }\r
+    return 0;\r
+}\r
+\r
+\r
+\r
+static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct sensor *sensor = to_sensor(client);
-    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 sensor *sensor = to_sensor(client);\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    const struct v4l2_queryctrl *qctrl;\r
+\r
+\r
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);\r
+\r
+    if (!qctrl)\r
+    {\r
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);\r
+        return -EINVAL;\r
+    }\r
+\r
+    switch (ctrl->id)\r
+    {\r
+#if CONFIG_SENSOR_Brightness\r
+        case V4L2_CID_BRIGHTNESS:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.brightness)\r
+                {\r
+                    if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)\r
+                    {\r
+                        return -EINVAL;\r
+                    }\r
+                    sensor->info_priv.brightness = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Exposure\r
+        case V4L2_CID_EXPOSURE:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.exposure)\r
+                {\r
+                    if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)\r
+                    {\r
+                        return -EINVAL;\r
+                    }\r
+                    sensor->info_priv.exposure = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Saturation\r
+        case V4L2_CID_SATURATION:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.saturation)\r
+                {\r
+                    if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)\r
+                    {\r
+                        return -EINVAL;\r
+                    }\r
+                    sensor->info_priv.saturation = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Contrast\r
+        case V4L2_CID_CONTRAST:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.contrast)\r
+                {\r
+                    if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)\r
+                    {\r
+                        return -EINVAL;\r
+                    }\r
+                    sensor->info_priv.contrast = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_WhiteBalance\r
+        case V4L2_CID_DO_WHITE_BALANCE:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.whiteBalance)\r
+                {\r
+                    if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)\r
+                    {\r
+                        return -EINVAL;\r
+                    }\r
+                    sensor->info_priv.whiteBalance = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Mirror\r
+        case V4L2_CID_HFLIP:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.mirror)\r
+                {\r
+                    if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.mirror = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Flip\r
+        case V4L2_CID_VFLIP:\r
+            {\r
+                if (ctrl->value != sensor->info_priv.flip)\r
+                {\r
+                    if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.flip = ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+        default:\r
+            break;\r
+    }\r
+\r
+    return 0;\r
+}\r
+static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)\r
+{\r
+    const struct v4l2_queryctrl *qctrl;\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+    struct sensor *sensor = to_sensor(client);\r
+\r
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);\r
+\r
+    if (!qctrl)\r
+    {\r
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);\r
+        return -EINVAL;\r
+    }\r
+\r
+    switch (ext_ctrl->id)\r
+    {\r
+        case V4L2_CID_SCENE:\r
+            {\r
+                ext_ctrl->value = sensor->info_priv.scene;\r
+                break;\r
+            }\r
+        case V4L2_CID_EFFECT:\r
+            {\r
+                ext_ctrl->value = sensor->info_priv.effect;\r
+                break;\r
+            }\r
+        case V4L2_CID_ZOOM_ABSOLUTE:\r
+            {\r
+                ext_ctrl->value = sensor->info_priv.digitalzoom;\r
+                break;\r
+            }\r
+        case V4L2_CID_ZOOM_RELATIVE:\r
+            {\r
+                return -EINVAL;\r
+            }\r
+        case V4L2_CID_FOCUS_ABSOLUTE:\r
+            {\r
+                ext_ctrl->value = sensor->info_priv.focus;\r
+                break;\r
+            }\r
+        case V4L2_CID_FOCUS_RELATIVE:\r
+            {\r
+                return -EINVAL;\r
+            }\r
+        case V4L2_CID_FLASH:\r
+            {\r
+                ext_ctrl->value = sensor->info_priv.flash;\r
+                break;\r
+            }\r
+        default :\r
+            break;\r
+    }\r
+    return 0;\r
+}\r
+static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)\r
+{\r
+    const struct v4l2_queryctrl *qctrl;\r
+    struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));\r
+    struct sensor *sensor = to_sensor(client);\r
+    int val_offset;\r
+\r
+    qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);\r
+\r
+    if (!qctrl)\r
+    {\r
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);\r
+        return -EINVAL;\r
+    }\r
+\r
+       val_offset = 0;\r
+    switch (ext_ctrl->id)\r
+    {\r
+#if CONFIG_SENSOR_Scene\r
+        case V4L2_CID_SCENE:\r
+            {\r
+                if (ext_ctrl->value != sensor->info_priv.scene)\r
+                {\r
+                    if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.scene = ext_ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Effect\r
+        case V4L2_CID_EFFECT:\r
+            {\r
+                if (ext_ctrl->value != sensor->info_priv.effect)\r
+                {\r
+                    if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.effect= ext_ctrl->value;\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_DigitalZoom\r
+        case V4L2_CID_ZOOM_ABSOLUTE:\r
+            {\r
+                if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))\r
+                    return -EINVAL;\r
+\r
+                if (ext_ctrl->value != sensor->info_priv.digitalzoom)\r
+                {\r
+                    val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;\r
+\r
+                    if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.digitalzoom += val_offset;\r
+\r
+                    SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(),  sensor->info_priv.digitalzoom);\r
+                }\r
+\r
+                break;\r
+            }\r
+        case V4L2_CID_ZOOM_RELATIVE:\r
+            {\r
+                if (ext_ctrl->value)\r
+                {\r
+                    if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)\r
+                        return -EINVAL;\r
+                    sensor->info_priv.digitalzoom += ext_ctrl->value;\r
+\r
+                    SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Focus\r
+        case V4L2_CID_FOCUS_ABSOLUTE:\r
+            {\r
+                if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))\r
+                    return -EINVAL;\r
+\r
+                if (ext_ctrl->value != sensor->info_priv.focus)\r
+                {\r
+                    val_offset = ext_ctrl->value -sensor->info_priv.focus;\r
+\r
+                    sensor->info_priv.focus += val_offset;\r
+                }\r
+\r
+                break;\r
+            }\r
+        case V4L2_CID_FOCUS_RELATIVE:\r
+            {\r
+                if (ext_ctrl->value)\r
+                {\r
+                    sensor->info_priv.focus += ext_ctrl->value;\r
+\r
+                    SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);\r
+                }\r
+                break;\r
+            }\r
+#endif\r
+#if CONFIG_SENSOR_Flash\r
+        case V4L2_CID_FLASH:\r
+            {\r
+                if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)\r
+                    return -EINVAL;\r
+                sensor->info_priv.flash = ext_ctrl->value;\r
+\r
+                SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);\r
+                break;\r
+            }\r
+#endif\r
+        default:\r
+            break;\r
+    }\r
+\r
+    return 0;\r
+}\r
+\r
+static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct soc_camera_device *icd = client->dev.platform_data;
-    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 soc_camera_device *icd = client->dev.platform_data;\r
+    int i, error_cnt=0, error_idx=-1;\r
+\r
+\r
+    for (i=0; i<ext_ctrl->count; i++) {\r
+        if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {\r
+            error_cnt++;\r
+            error_idx = i;\r
+        }\r
+    }\r
+\r
+    if (error_cnt > 1)\r
+        error_idx = ext_ctrl->count;\r
+\r
+    if (error_idx != -1) {\r
+        ext_ctrl->error_idx = error_idx;\r
+        return -EINVAL;\r
+    } else {\r
+        return 0;\r
+    }\r
+}\r
+\r
+static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct soc_camera_device *icd = client->dev.platform_data;
-    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 value;
-    int ret,pid = 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;
-               goto sensor_video_probe_err;
-       }
-
-    /* soft reset */
-    ret = sensor_write(client, 0xff, 0x1);
-    if (ret != 0) {
-        SENSOR_TR("soft reset %s failed\n",SENSOR_NAME_STRING());
-        ret = -ENODEV;
-               goto sensor_video_probe_err;
-    }
-    mdelay(5);          //delay 5 microseconds
-
-    /* check if it is an sensor sensor */
-    ret = sensor_read(client, 0x0a, &value);
-    if (ret != 0) {
-        SENSOR_TR("read chip id high byte failed\n");
-        ret = -ENODEV;
-        goto sensor_video_probe_err;
-    }
-    pid = value << 8;
-
-    ret = sensor_read(client, 0x0b, &value);
-    if (ret != 0) {
-        SENSOR_TR("read chip id low byte failed\n");
-        ret = -ENODEV;
-        goto sensor_video_probe_err;
-    }
-
-    pid |= (value & 0xff);
-    SENSOR_DG("\n %s  pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
-
-    if ((pid == SENSOR_ID)||(pid == SENSOR_ID1)) {
-        sensor->model = SENSOR_V4L2_IDENT;
-    } else {
-        SENSOR_TR("error: %s mismatched   pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
-        ret = -ENODEV;
-        goto sensor_video_probe_err;
-    }
-
-    return 0;
-
-sensor_video_probe_err:
-
-    return ret;
-}
-
-static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
-{
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    int i, error_cnt=0, error_idx=-1;\r
+\r
+\r
+    for (i=0; i<ext_ctrl->count; i++) {\r
+        if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {\r
+            error_cnt++;\r
+            error_idx = i;\r
+        }\r
+    }\r
+\r
+    if (error_cnt > 1)\r
+        error_idx = ext_ctrl->count;\r
+\r
+    if (error_idx != -1) {\r
+        ext_ctrl->error_idx = error_idx;\r
+        return -EINVAL;\r
+    } else {\r
+        return 0;\r
+    }\r
+}\r
+\r
+/* Interface active, can use i2c. If it fails, it can indeed mean, that\r
+ * this wasn't our capture interface, so, we wait for the right one */\r
+static int sensor_video_probe(struct soc_camera_device *icd,\r
+                              struct i2c_client *client)\r
+{\r
+    char value;\r
+    int ret,pid = 0;\r
+    struct sensor *sensor = to_sensor(client);\r
+\r
+    /* We must have a parent by now. And it cannot be a wrong one.\r
+     * So this entire test is completely redundant. */\r
+    if (!icd->dev.parent ||\r
+           to_soc_camera_host(icd->dev.parent)->nr != icd->iface)\r
+               return -ENODEV;\r
+\r
+       if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {\r
+               ret = -ENODEV;\r
+               goto sensor_video_probe_err;\r
+       }\r
+\r
+    /* soft reset */\r
+    ret = sensor_write(client, 0xff, 0x1);\r
+    if (ret != 0) {\r
+        SENSOR_TR("soft reset %s failed\n",SENSOR_NAME_STRING());\r
+        ret = -ENODEV;\r
+               goto sensor_video_probe_err;\r
+    }\r
+    mdelay(5);          //delay 5 microseconds\r
+\r
+    /* check if it is an sensor sensor */\r
+    ret = sensor_read(client, 0x0a, &value);\r
+    if (ret != 0) {\r
+        SENSOR_TR("read chip id high byte failed\n");\r
+        ret = -ENODEV;\r
+        goto sensor_video_probe_err;\r
+    }\r
+    pid = value << 8;\r
+\r
+    ret = sensor_read(client, 0x0b, &value);\r
+    if (ret != 0) {\r
+        SENSOR_TR("read chip id low byte failed\n");\r
+        ret = -ENODEV;\r
+        goto sensor_video_probe_err;\r
+    }\r
+\r
+    pid |= (value & 0xff);\r
+    SENSOR_DG("\n %s  pid = 0x%x\n", SENSOR_NAME_STRING(), pid);\r
+\r
+    if ((pid == SENSOR_ID)||(pid == SENSOR_ID1)) {\r
+        sensor->model = SENSOR_V4L2_IDENT;\r
+    } else {\r
+        SENSOR_TR("error: %s mismatched   pid = 0x%x\n", SENSOR_NAME_STRING(), pid);\r
+        ret = -ENODEV;\r
+        goto sensor_video_probe_err;\r
+    }\r
+\r
+    return 0;\r
+\r
+sensor_video_probe_err:\r
+\r
+    return ret;\r
+}\r
+\r
+static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)\r
+{\r
        struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct soc_camera_device *icd = client->dev.platform_data;  
-    struct sensor *sensor = to_sensor(client);
+    struct soc_camera_device *icd = client->dev.platform_data;  \r
+    struct sensor *sensor = to_sensor(client);\r
     int ret = 0,i;\r
-    
-       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:
-               {
+    \r
+       SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);\r
+       switch (cmd)\r
+       {\r
+               case RK29_CAM_SUBDEV_DEACTIVATE:\r
+               {\r
+                       sensor_deactivate(client);\r
+                       break;\r
+               }\r
+\r
+               case RK29_CAM_SUBDEV_IOREQUEST:\r
+               {\r
                        sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;           \r
-            if (sensor->sensor_io_request != NULL) { 
-                sensor->sensor_gpio_res = NULL;
-                for (i=0; i<RK29_CAM_SUPPORT_NUMS;i++) {
-                    if (sensor->sensor_io_request->gpio_res[i].dev_name && 
-                        (strcmp(sensor->sensor_io_request->gpio_res[i].dev_name, dev_name(icd->pdev)) == 0)) {
-                        sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[i];
-                    }
-                }
-                if (sensor->sensor_gpio_res == NULL) {
-                    SENSOR_TR("%s %s obtain gpio resource failed when RK29_CAM_SUBDEV_IOREQUEST \n",SENSOR_NAME_STRING(),__FUNCTION__);
-                    ret = -EINVAL;
-                    goto sensor_ioctl_end;
-                }
-            } else {
-                SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
-                ret = -EINVAL;
-                goto sensor_ioctl_end;
+            if (sensor->sensor_io_request != NULL) { \r
+                sensor->sensor_gpio_res = NULL;\r
+                for (i=0; i<RK29_CAM_SUPPORT_NUMS;i++) {\r
+                    if (sensor->sensor_io_request->gpio_res[i].dev_name && \r
+                        (strcmp(sensor->sensor_io_request->gpio_res[i].dev_name, dev_name(icd->pdev)) == 0)) {\r
+                        sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[i];\r
+                    }\r
+                }\r
+                if (sensor->sensor_gpio_res == NULL) {\r
+                    SENSOR_TR("%s %s obtain gpio resource failed when RK29_CAM_SUBDEV_IOREQUEST \n",SENSOR_NAME_STRING(),__FUNCTION__);\r
+                    ret = -EINVAL;\r
+                    goto sensor_ioctl_end;\r
+                }\r
+            } else {\r
+                SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);\r
+                ret = -EINVAL;\r
+                goto sensor_ioctl_end;\r
             }\r
-            /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control 
-               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 int sensor_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-                           enum v4l2_mbus_pixelcode *code)
-{
-       if (index >= ARRAY_SIZE(sensor_colour_fmts))
-               return -EINVAL;
-
-       *code = sensor_colour_fmts[index].code;
-       return 0;
-}
-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_mbus_fmt     = sensor_s_fmt,
-       .g_mbus_fmt     = sensor_g_fmt,
-       .try_mbus_fmt   = sensor_try_fmt,
-       .enum_mbus_fmt  = sensor_enum_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;
-    sensor->info_priv.fmt = sensor_colour_fmts[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>");
+            /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control \r
+               for this project */\r
+            #if CONFIG_SENSOR_Flash    \r
+               if (sensor->sensor_gpio_res) { \r
+                if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {\r
+                    for (i = 0; i < icd->ops->num_controls; i++) {\r
+                               if (V4L2_CID_FLASH == icd->ops->controls[i].id) {\r
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  \r
+                              sensor_controls[i].id=0xffff;                            \r
+                               }\r
+                    }\r
+                    sensor->info_priv.flash = 0xff;\r
+                    SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());\r
+                }else{ //two cameras are the same,need to deal diffrently ,zyc\r
+                    for (i = 0; i < icd->ops->num_controls; i++) {\r
+                           if(0xffff == icd->ops->controls[i].id){\r
+                              sensor_controls[i].id=V4L2_CID_FLASH;\r
+                           }               \r
+                    }\r
+                }\r
+               }\r
+            #endif\r
+                       break;\r
+               }\r
+               default:\r
+               {\r
+                       SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);\r
+                       break;\r
+               }\r
+       }\r
+\r
+sensor_ioctl_end:\r
+       return ret;\r
+\r
+}\r
+static int sensor_enum_fmt(struct v4l2_subdev *sd, unsigned int index,\r
+                           enum v4l2_mbus_pixelcode *code)\r
+{\r
+       if (index >= ARRAY_SIZE(sensor_colour_fmts))\r
+               return -EINVAL;\r
+\r
+       *code = sensor_colour_fmts[index].code;\r
+       return 0;\r
+}\r
+static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {\r
+       .init           = sensor_init,\r
+       .g_ctrl         = sensor_g_control,\r
+       .s_ctrl         = sensor_s_control,\r
+       .g_ext_ctrls          = sensor_g_ext_controls,\r
+       .s_ext_ctrls          = sensor_s_ext_controls,\r
+       .g_chip_ident   = sensor_g_chip_ident,\r
+       .ioctl = sensor_ioctl,\r
+};\r
+\r
+static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {\r
+       .s_mbus_fmt     = sensor_s_fmt,\r
+       .g_mbus_fmt     = sensor_g_fmt,\r
+       .try_mbus_fmt   = sensor_try_fmt,\r
+       .enum_mbus_fmt  = sensor_enum_fmt,\r
+};\r
+\r
+static struct v4l2_subdev_ops sensor_subdev_ops = {\r
+       .core   = &sensor_subdev_core_ops,\r
+       .video = &sensor_subdev_video_ops,\r
+};\r
+\r
+static int sensor_probe(struct i2c_client *client,\r
+                        const struct i2c_device_id *did)\r
+{\r
+    struct sensor *sensor;\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);\r
+    struct soc_camera_link *icl;\r
+    int ret;\r
+\r
+    SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);\r
+    if (!icd) {\r
+        dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());\r
+        return -EINVAL;\r
+    }\r
+\r
+    icl = to_soc_camera_link(icd);\r
+    if (!icl) {\r
+        dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());\r
+        return -EINVAL;\r
+    }\r
+\r
+    if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {\r
+        dev_warn(&adapter->dev,\r
+                "I2C-Adapter doesn't support I2C_FUNC_I2C\n");\r
+        return -EIO;\r
+    }\r
+\r
+    sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);\r
+    if (!sensor)\r
+        return -ENOMEM;\r
+\r
+    v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);\r
+\r
+    /* Second stage probe - when a capture adapter is there */\r
+    icd->ops           = &sensor_ops;\r
+    sensor->info_priv.fmt = sensor_colour_fmts[0];\r
+       #if CONFIG_SENSOR_I2C_NOSCHED\r
+       atomic_set(&sensor->tasklock_cnt,0);\r
+       #endif\r
+\r
+    ret = sensor_video_probe(icd, client);\r
+    if (ret < 0) {\r
+        icd->ops = NULL;\r
+        i2c_set_clientdata(client, NULL);\r
+        kfree(sensor);\r
+               sensor = NULL;\r
+    }\r
+    SENSOR_DG("\n%s..%s..%d  ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);\r
+    return ret;\r
+}\r
+\r
+static int sensor_remove(struct i2c_client *client)\r
+{\r
+    struct sensor *sensor = to_sensor(client);\r
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+\r
+    icd->ops = NULL;\r
+    i2c_set_clientdata(client, NULL);\r
+    client->driver = NULL;\r
+    kfree(sensor);\r
+       sensor = NULL;\r
+    return 0;\r
+}\r
+\r
+static const struct i2c_device_id sensor_id[] = {\r
+       {SENSOR_NAME_STRING(), 0 },\r
+       { }\r
+};\r
+MODULE_DEVICE_TABLE(i2c, sensor_id);\r
+\r
+static struct i2c_driver sensor_i2c_driver = {\r
+       .driver = {\r
+               .name = SENSOR_NAME_STRING(),\r
+       },\r
+       .probe          = sensor_probe,\r
+       .remove         = sensor_remove,\r
+       .id_table       = sensor_id,\r
+};\r
+\r
+static int __init sensor_mod_init(void)\r
+{\r
+    SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());\r
+    return i2c_add_driver(&sensor_i2c_driver);\r
+}\r
+\r
+static void __exit sensor_mod_exit(void)\r
+{\r
+    i2c_del_driver(&sensor_i2c_driver);\r
+}\r
+\r
+device_initcall_sync(sensor_mod_init);\r
+module_exit(sensor_mod_exit);\r
+\r
+MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));\r
+MODULE_AUTHOR("ddl <kernel@rock-chips>");\r
 MODULE_LICENSE("GPL");\r
index cb059264591dd72490c6b2cf56e4e55b2938f5a2..f31b005777dee6668e2c1d5b0093e367c7cafd08 100755 (executable)
@@ -21,12 +21,12 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
 #include <media/soc_camera.h>
 #include <plat/rk_camera.h>
 #include <linux/vmalloc.h>
-static int debug;
+static int debug ;
 module_param(debug, int, S_IRUGO|S_IWUSR);
 
 #define dprintk(level, fmt, arg...) do {                       \
        if (debug >= level)                                     \
-       printk(KERN_DEBUG fmt , ## arg); } while (0)
+       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__)
@@ -90,13 +90,26 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define SENSOR_AF_IS_OK                (0x01<<0)
 #define SENSOR_INIT_IS_ERR   (0x00<<28)
 #define SENSOR_INIT_IS_OK    (0x01<<28)
-
 struct reginfo
 {
     u16 reg;
     u8 val;
 };
 
+
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_OV2655_USER_DEFINED_SERIES
+#include "ov2655_user_series.c"
+#else
+
 /* init 352X288 SVGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -105,14 +118,14 @@ static struct reginfo sensor_init_data[] =
     {0x360b, 0x00},
     {0x30b0, 0xff},
     {0x30b1, 0xff},
-    {0x30b2, 0x24},
+    {0x30b2, 0x26},
 
     {0x300e, 0x34},
     {0x300f, 0xa6},
     {0x3010, 0x81},
     {0x3082, 0x01},
     {0x30f4, 0x01},
-    {0x3090, 0x33},//0x3b},
+    {0x3090, 0x3b},//0x33},
     {0x3091, 0xc0},
     {0x30ac, 0x42},
 
@@ -304,7 +317,7 @@ static struct reginfo sensor_init_data[] =
     {0x3379, 0x80},
 
     {0x3069, 0x84},
-    {0x307c, 0x10},//0x13},
+    {0x307c, 0x13},//0x10},
     {0x3087, 0x02},
 
     {0x3300, 0xfc},
@@ -321,6 +334,22 @@ static struct reginfo sensor_init_data[] =
 
     {0x3086, 0x0f},
     {0x3086, 0x00},
+#if 0
+    //night mode
+    {0x300e, 0x34},
+    {0x3011, 0x00},
+    {0x302c, 0x00},
+    {0x3071, 0x00},
+    {0x3070, 0xb9},
+    {0x301c, 0x02},
+    {0x3073, 0x00},
+    {0x3072, 0x9a},
+    {0x301d, 0x03},
+    {0x3014, 0x0c},
+    {0x3015, 0x50},//add 5 dummy frame
+    {0x302e, 0x00},
+    {0x302d, 0x00},
+#endif
 
     {0x0, 0x0}   //end flag
 
@@ -332,9 +361,10 @@ static struct reginfo sensor_720p[]=
 /* 1600X1200 UXGA */
 static struct reginfo sensor_uxga[] =
 {
-
+#if 1
+  //  {0x3086,0x01},  //sleep off
     {0x300E, 0x34},
-    {0x3011, 0x01},
+    {0x3011, 0x00},
     {0x3012, 0x00},
     {0x302a, 0x05},
     {0x302b, 0xCB},
@@ -367,7 +397,19 @@ static struct reginfo sensor_uxga[] =
     {0x331C, 0x00},
     {0x331D, 0x6C},
     {0x3302, 0x01},
+  //  {0x3086,0x00}, //sleep on
+#else
+    {0x300e, 0x38},
+    {0x3011, 0x00},
+    {0x302c, 0x00},
+    {0x3071, 0x00},
+    {0x3070, 0x5d},
+    {0x301c, 0x0d},
+    {0x3073, 0x00},
+    {0x3072, 0x4e},
+    {0x301d, 0x0f},
 
+#endif
     {0x0, 0x0},
 };
 
@@ -375,6 +417,7 @@ static struct reginfo sensor_uxga[] =
 static struct reginfo sensor_sxga[] =
 {
 #if 1
+   // {0x3086,0x01},  //sleep on
     {0x300E, 0x34},
     {0x3011, 0x00},
     {0x3012, 0x00},
@@ -409,6 +452,7 @@ static struct reginfo sensor_sxga[] =
     {0x331C, 0x00},
     {0x331D, 0x6C},
     {0x3302, 0x11},
+ //   {0x3086,0x00}, //sleep off
 #endif
     {0x0, 0x0},
 };
@@ -419,6 +463,7 @@ static struct reginfo sensor_xga[] =
 /* 800X600 SVGA*/
 static struct reginfo sensor_svga[] =
 {
+    {0x3086,0x01},  //sleep on
     {0x300E, 0x34},
     {0x3011, 0x01},
     {0x3012, 0x10},
@@ -453,15 +498,16 @@ static struct reginfo sensor_svga[] =
     {0x331C, 0x00},
     {0x331D, 0x38},
     {0x3302, 0x11},
-
+    {0x3086,0x00}, //sleep off
     {0x0, 0x0},
 };
 
 /* 640X480 VGA */
 static struct reginfo sensor_vga[] =
 {
+ //   {0x3086,0x00},  //sleep off
     {0x300E, 0x34},
-    {0x3011, 0x01},
+    {0x3011, 0x00},
     {0x3012, 0x10},
     {0x302a, 0x02},
     {0x302b, 0xE6},
@@ -494,7 +540,7 @@ static struct reginfo sensor_vga[] =
     {0x331C, 0x08},
     {0x331D, 0x38},
     {0x3302, 0x11},
-
+//    {0x3086,0x01}, //sleep on
     {0x0, 0x0},
 };
 
@@ -618,6 +664,7 @@ static struct reginfo sensor_qcif[] =
 
     {0x0, 0x0},
 };
+#endif
 #if 0
 /* 160X120 QQVGA*/
 static struct reginfo ov2655_qqvga[] =
@@ -1124,7 +1171,7 @@ static  struct reginfo sensor_SceneAuto[] =
     {0x302e, 0x00},
     {0x302d, 0x00},
     {0x0000, 0x00}
-#else
+#else 
     {0x3014, 0x84},
     {0x3015, 0x02},
     {0x302e, 0x00},
@@ -1135,7 +1182,7 @@ static  struct reginfo sensor_SceneAuto[] =
 
 static  struct reginfo sensor_SceneNight[] =
 {
-#if 1
+#if 0
     //30fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,36Mzh pclk
     {0x300e, 0x34},
     {0x3011, 0x00},
@@ -1151,7 +1198,7 @@ static  struct reginfo sensor_SceneNight[] =
     {0x302e, 0x00},
     {0x302d, 0x00},
     {0x0000, 0x00}
-#else
+#elif 0
     //15fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,18Mhz pclk
     {0x300e, 0x34},
     {0x3011, 0x01},
@@ -1166,6 +1213,18 @@ static  struct reginfo sensor_SceneNight[] =
     {0x3015, 0x50},
     {0x302e, 0x00},
     {0x302d, 0x00},
+#elif 1 
+// the fixed fps, RK30 CIF can't receive data correctly when taking pic frequently in scene night mode of 
+// auto fps . Now use this series temporarily until fix the cif bug,zyc
+    {0x300e, 0x34},
+    {0x3011, 0x05},
+    {0x302c, 0x00},
+    {0x3071, 0x00},
+    {0x3070, 0x31},
+    {0x301c, 0x13},
+    {0x3073, 0x00},
+    {0x3072, 0x1a},
+    {0x301d, 0x17},
 #endif
 };
 static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
@@ -1218,7 +1277,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1647,6 +1706,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);
@@ -1680,6 +1740,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1692,6 +1757,15 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
+
 static s32 sensor_init_width = 640;
 static s32 sensor_init_height = 480;
 static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8  |SOCAM_MCLK_24MHZ);
@@ -1888,6 +1962,10 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -1916,7 +1994,6 @@ static int sensor_deactivate(struct i2c_client *client)
     }
     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;
@@ -3086,11 +3163,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index 7d656eaa038eded318dc26ea6c6f2512732724b4..943ffd824b1c2ba029cbdfa9ab9f8dbe7fdadf5c 100755 (executable)
@@ -96,6 +96,18 @@ struct reginfo
     u16 reg;
     u8 val;
 };
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_OV2659_USER_DEFINED_SERIES
+#include "ov2659_user_series.c"
+#else
 /* init 800*600 SVGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -573,6 +585,7 @@ static struct reginfo sensor_qcif[] =
 {
        {0x0, 0x0}
 };
+#endif
 #if 0
 /* 160X120 QQVGA*/
 static struct reginfo ov2655_qqvga[] =
@@ -1022,7 +1035,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1486,6 +1499,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1498,6 +1516,15 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
+
 static s32 sensor_init_width = 800;
 static s32 sensor_init_height = 600;
 static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH| SOCAM_VSYNC_ACTIVE_LOW|SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8  |SOCAM_MCLK_24MHZ);
@@ -1693,6 +1720,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #endif
     msleep(800);
     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);
@@ -1724,7 +1754,6 @@ static int sensor_deactivate(struct i2c_client *client)
     }
     sensor_ioctrl(icd, Sensor_PowerDown, 1); 
     msleep(10); 
-
        /* 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;
@@ -2928,11 +2957,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index 1591af0b3d487ad7257510048cb5cafa6def40a2..8bc9c96aceb95fa7aed11aa33b526a151adc234f 100755 (executable)
@@ -177,6 +177,19 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define StepFocus_Spec_Tag       0x10
 #endif
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_OV5640_USER_DEFINED_SERIES
+#include "ov5640_user_series.c"
+#else
+
 /* init 800X600 SVGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -791,7 +804,7 @@ static struct reginfo sensor_qcif[] =
 
        {SEQUENCE_END, 0x00}
 };
-
+#endif
 static  struct reginfo sensor_ClrFmt_YUYV[]=
 {
        {0x4300,0x30},
@@ -1174,7 +1187,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -2361,6 +2374,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
                        break;
                }
@@ -2374,6 +2392,15 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
+
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -2487,6 +2514,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
 
@@ -3896,11 +3926,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index f07a2ec4f4f4747321cf5a3ea2e044e59e1e8323..2749671bd8adc51da1a4f1f3f60e111c13cfb83e 100755 (executable)
@@ -162,6 +162,19 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define StepFocus_Spec_Tag       0x10
 #endif
 
+
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_OV5642_USER_DEFINED_SERIES
+#include "ov5642_user_series.c"
+#else
 /* init 800X600 SVGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -2593,6 +2606,7 @@ static struct reginfo sensor_qcif[] =
        {0x5687 ,0xc0},
        {0x0000,0x00}
 };
+#endif
 #if 0
 /* 160X120 QQVGA*/
 static struct reginfo ov2655_qqvga[] =
@@ -3065,7 +3079,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -4236,6 +4250,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
                        break;
                }
@@ -4250,6 +4269,14 @@ sensor_power_end:
        return ret;
 }
 
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
+
 static s32 sensor_init_width = 800;
 static s32 sensor_init_height = 600;
 static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8  |SOCAM_MCLK_24MHZ);
@@ -4436,6 +4463,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
 
@@ -4465,7 +4495,6 @@ static int sensor_deactivate(struct i2c_client *client)
     } 
     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;
@@ -5881,11 +5910,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zycc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index e4a80fec0789d9f2e6b346d0ae2eb506d6aa9d00..9734410c90141e8619e34db7b92f14392e48c6d1 100755 (executable)
@@ -96,6 +96,18 @@ struct reginfo
     u8 val;
 };
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_OV7675_USER_DEFINED_SERIES
+#include "ov7675_user_series.c"
+#else
 /* init 640X480 VGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -313,7 +325,7 @@ static struct reginfo sensor_qcif[] =
 {
     {0x00,0x00}
 };
-
+#endif
 static  struct reginfo sensor_ClrFmt_YUYV[]=
 {
     {0x00, 0x00}
@@ -909,7 +921,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1371,6 +1383,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1383,6 +1400,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1473,6 +1498,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -1493,7 +1521,6 @@ static int sensor_deactivate(struct i2c_client *client)
 
        /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
        sensor_ioctrl(icd, Sensor_PowerDown, 1);
-
        /* 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;
@@ -2636,11 +2663,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
old mode 100644 (file)
new mode 100755 (executable)
index f50d8b1..c4f567f
@@ -94,6 +94,21 @@ struct reginfo
     u8 reg;
     u8 val;
 };
+
+
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_OV7690_USER_DEFINED_SERIES
+#include "ov7690_user_series.c"
+#else
+
 /* init 640X480 VGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -315,6 +330,7 @@ static struct reginfo sensor_qcif[] =
                {0xcf,0x90},
     {0x00,0x00}
 };
+#endif
 #if 0
 /* 160X120 QQVGA*/
 static struct reginfo ov2655_qqvga[] =
@@ -703,7 +719,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1167,6 +1183,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1179,6 +1200,15 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:
        return ret;
 }
+
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
+
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1269,6 +1299,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -1289,7 +1322,6 @@ static int sensor_deactivate(struct i2c_client *client)
 
        /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
        sensor_ioctrl(icd, Sensor_PowerDown, 1);
-
        /* 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;
@@ -2407,11 +2439,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index 3cd75681492500625c9eb117a7022a533cda3bb2..5429c123cee71f8ef8e059fa5a518e19b07b03a1 100755 (executable)
@@ -38,6 +38,9 @@
 #include <mach/io.h>
 #include <plat/ipp.h>
 #include <mach/rk30_camera.h>
+#include <linux/regulator/machine.h>
+#include <mach/cru.h>
+#include <mach/pmu.h>
 
 static int debug ;
 module_param(debug, int, S_IRUGO|S_IWUSR);
@@ -198,8 +201,13 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 *v0.x.8 : temp version,reinit capture list when setup video buf.
 *v0.x.9 : 1. add the case of IPP unsupportted ,just cropped by CIF(not do the scale) this version. 
           2. flush workqueue when releas buffer
+*v0.x.10: 1. reset cif and wake up vb when cif have't receive data in a fixed time(now setted as 2 secs) so that app can
+             be quitted
+          2. when the flash is on ,flash off in a fixed time to prevent from flash light too hot.
+          3. when front and back camera are the same sensor,and one has the flash ,other is not,flash can't work corrrectly ,fix it
+          4. add  menu configs for convineuent to customize sensor series
 */
-#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 2, 9)
+#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 2, 10)
 
 /* limit to rk29 hardware capabilities */
 #define RK_CAM_BUS_PARAM   (SOCAM_MASTER |\
@@ -348,6 +356,34 @@ static const char *rk_cam_driver_description = "RK_Camera";
 
 static int rk_camera_s_stream(struct soc_camera_device *icd, int enable);
 
+static void rk_cif_poweroff(struct rk_camera_dev *pcdev)
+{
+    struct regulator *ldo_18,*ldo_28;
+       ldo_28 = regulator_get(NULL, "ldo7");   // vcc28_cif
+       ldo_18 = regulator_get(NULL, "ldo1");   // vcc18_cif
+       
+       regulator_disable(ldo_28);
+       regulator_put(ldo_28);
+       regulator_disable(ldo_18);
+       regulator_put(ldo_18);
+       mdelay(500);
+}
+static void rk_cif_poweron(struct rk_camera_dev *pcdev)
+{
+    struct regulator *ldo_18,*ldo_28;
+       ldo_28 = regulator_get(NULL, "ldo7");   // vcc28_cif
+       ldo_18 = regulator_get(NULL, "ldo1");   // vcc18_cif
+       regulator_set_voltage(ldo_28, 2800000, 2800000);
+       regulator_enable(ldo_28);
+//     printk("%s set ldo7 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo));
+       regulator_put(ldo_28);
+
+       regulator_set_voltage(ldo_18, 1800000, 1800000);
+//     regulator_set_suspend_voltage(ldo, 1800000);
+       regulator_enable(ldo_18);
+//     printk("%s set ldo1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo));
+       regulator_put(ldo_18);
+}
 
 /*
  *  Videobuf operations
@@ -1674,7 +1710,7 @@ static int rk_camera_suspend(struct soc_camera_device *icd, pm_message_t state)
                     to_soc_camera_host(icd->dev.parent);
     struct rk_camera_dev *pcdev = ici->priv;
        struct v4l2_subdev *sd;
-    int ret = 0,tmp;
+    int ret = 0;
 
        mutex_lock(&camera_lock);
        if ((pcdev->icd == icd) && (icd->ops->suspend)) {
@@ -1757,6 +1793,8 @@ static void rk_camera_reinit_work(struct work_struct *work)
        int ret;
        struct rk_camera_work *camera_work = container_of(work, struct rk_camera_work, work);
        struct rk_camera_dev *pcdev = camera_work->pcdev;
+    struct videobuf_buffer     *tmp_vb;
+               sd = soc_camera_to_subdev(pcdev->icd);
        //dump regs
        {
                RKCAMERA_DG("CIF_CIF_CTRL = 0x%x\n",read_cif_reg(pcdev->base,CIF_CIF_CTRL));
@@ -1776,7 +1814,43 @@ static void rk_camera_reinit_work(struct work_struct *work)
        RKCAMERA_DG("CIF_CIF_FRM0_ADDR_UV = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_FRM0_ADDR_UV));
        RKCAMERA_DG("CIF_CIF_FRAME_STATUS = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_FRAME_STATUS));
        }
+    while (!list_empty(&pcdev->capture)) {
+        printk("wake up video buffer!!!\n");
+        tmp_vb = list_entry(pcdev->capture.next, struct videobuf_buffer, queue);
+       if (tmp_vb && (tmp_vb->state == VIDEOBUF_QUEUED)) 
+         {
+               list_del_init(&(tmp_vb->queue));
+            tmp_vb->state = VIDEOBUF_ERROR;
+
+           wake_up_all(&tmp_vb->done);
+       }
+    }
        write_cif_reg(pcdev->base,CIF_CIF_CTRL, (read_cif_reg(pcdev->base,CIF_CIF_CTRL)&(~ENABLE_CAPTURE)));
+    rk_cif_poweroff(pcdev);
+    if(IS_CIF0()){
+       //      write_cru_reg(CRU_CIF_RST_REG30,(read_cru_reg(CRU_CIF_RST_REG30)|MASK_RST_CIF0|RQUEST_RST_CIF0 ));
+        
+       //      write_cru_reg(CRU_CIF_RST_REG30,(read_cru_reg(CRU_CIF_RST_REG30)&(~RQUEST_RST_CIF0)) | MASK_RST_CIF0);
+
+               pmu_set_idle_request(IDLE_REQ_VIO, true);
+               cru_set_soft_reset(SOFT_RST_CIF0, true);
+               udelay(300);
+               cru_set_soft_reset(SOFT_RST_CIF0, false);
+               pmu_set_idle_request(IDLE_REQ_VIO, false);
+
+           printk("clean cru register reset cif0 0x%x\n",read_cru_reg(CRU_CIF_RST_REG30));
+
+    }else{
+       // write_cru_reg(CRU_CIF_RST_REG30,MASK_RST_CIF1|RQUEST_RST_CIF1 | (read_cru_reg(CRU_CIF_RST_REG30)));
+       // write_cru_reg(CRU_CIF_RST_REG30,(read_cru_reg(CRU_CIF_RST_REG30)&(~RQUEST_RST_CIF1)) | MASK_RST_CIF1);
+               pmu_set_idle_request(IDLE_REQ_VIO, true);
+               cru_set_soft_reset(SOFT_RST_CIF1, true);
+               udelay(300);
+               cru_set_soft_reset(SOFT_RST_CIF1, false);
+               pmu_set_idle_request(IDLE_REQ_VIO, false);  
+   
+    }
+    rk_cif_poweron(pcdev);
 
        control = to_soc_camera_control(pcdev->icd);
        sd = dev_get_drvdata(control);
@@ -1791,6 +1865,8 @@ static void rk_camera_reinit_work(struct work_struct *work)
 
        write_cif_reg(pcdev->base,CIF_CIF_CTRL, (read_cif_reg(pcdev->base,CIF_CIF_CTRL)|ENABLE_CAPTURE));
 
+
+
        RKCAMERA_TR("Camera host haven't recevie data from sensor,Reinit sensor now! ret:0x%x\n",ret);
 }
 static enum hrtimer_restart rk_camera_fps_func(struct hrtimer *timer)
@@ -1883,15 +1959,17 @@ static int rk_camera_s_stream(struct soc_camera_device *icd, int enable)
                pcdev->fps = 0;
                hrtimer_cancel(&(pcdev->fps_timer.timer));
                pcdev->fps_timer.pcdev = pcdev;
-               hrtimer_start(&(pcdev->fps_timer.timer),ktime_set(5, 0),HRTIMER_MODE_REL);
+//             hrtimer_start(&(pcdev->fps_timer.timer),ktime_set(3, 0),HRTIMER_MODE_REL);
                cif_ctrl_val |= ENABLE_CAPTURE;
+               write_cif_reg(pcdev->base,CIF_CIF_CTRL, cif_ctrl_val);
+               hrtimer_start(&(pcdev->fps_timer.timer),ktime_set(2, 0),HRTIMER_MODE_REL);
        } else {
         cif_ctrl_val &= ~ENABLE_CAPTURE;
+       write_cif_reg(pcdev->base,CIF_CIF_CTRL, cif_ctrl_val);
                ret = hrtimer_cancel(&pcdev->fps_timer.timer);
-               ret |= flush_work(&(pcdev->camera_reinit_work.work));
+               flush_workqueue((pcdev->camera_wq));
                RKCAMERA_DG("STREAM_OFF cancel timer and flush work:0x%x \n", ret);
        }
-       write_cif_reg(pcdev->base,CIF_CIF_CTRL, cif_ctrl_val);
     //must be reinit,or will be somthing wrong in irq process.
     if(enable == false){
         pcdev->active = NULL;
@@ -1999,10 +2077,10 @@ static int rk_camera_set_digit_zoom(struct soc_camera_device *icd,
        struct v4l2_crop a;
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct rk_camera_dev *pcdev = ici->priv;
-       unsigned int cif_fs = 0,cif_crop = 0;
-    int work_index =0,stream_on = 0;
     
        #if 0
+       unsigned int cif_fs = 0,cif_crop = 0;
+    int work_index =0,stream_on = 0;
 /* ddl@rock-chips.com : The largest resolution is 2047x1088, so larger resolution must be operated some times
    (Assume operate times is 4),but resolution which ipp can operate ,it is width and height must be even. */
        a.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
old mode 100644 (file)
new mode 100755 (executable)
index 3d42340..e8beae9
@@ -110,6 +110,19 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define SENSOR_AF_MODE_CLOSE       5
 #endif
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_S5K6AA_USER_DEFINED_SERIES
+#include "s5k6aa_user_series.c"
+#else
+
 /* init 640X480 SVGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -2364,6 +2377,7 @@ static struct reginfo sensor_qcif[] =
 {
     {SEQUENCE_END, 0x0},
 };
+#endif
 #if 0
 /* 160X120 QQVGA*/
 static struct reginfo s5k6aa_qqvga[] =
@@ -2743,7 +2757,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -3297,6 +3311,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
                {
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
                        break;
                }
@@ -3311,6 +3330,14 @@ sensor_power_end:
        return ret;
 }
 
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
+
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -3426,6 +3453,11 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
+
     #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;
@@ -4626,11 +4658,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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(&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));                                      
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif
index 5bfbb0add50668a63dd0cbf18029035379d0408d..a3a9d62c4ec89f5b2bfedd9b45a9973b69b15466 100755 (executable)
@@ -89,9 +89,9 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 #define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))\r
 #define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)\r
 \r
-#define SENSOR_AF_IS_ERR    (0x00<<0)
-#define SENSOR_AF_IS_OK                (0x01<<0)
-#define SENSOR_INIT_IS_ERR   (0x00<<28)
+#define SENSOR_AF_IS_ERR    (0x00<<0)\r
+#define SENSOR_AF_IS_OK                (0x01<<0)\r
+#define SENSOR_INIT_IS_ERR   (0x00<<28)\r
 #define SENSOR_INIT_IS_OK    (0x01<<28)\r
 \r
 struct reginfo\r
@@ -100,6 +100,18 @@ struct reginfo
     u8 val;\r
 };\r
 \r
+//flash off in fixed time to prevent from too hot , zyc\r
+struct  flash_timer{\r
+    struct soc_camera_device *icd;\r
+       struct hrtimer timer;\r
+};\r
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);\r
+\r
+static struct  flash_timer flash_off_timer;\r
+//for user defined if user want to customize the series , zyc\r
+#if CONFIG_SID130B_USER_DEFINED_SERIES\r
+#include "sid130B_user_series.c"\r
+#else\r
 /* init 352X288 SVGA */\r
 static struct reginfo sensor_init_data[] =\r
 {\r
@@ -830,7 +842,7 @@ static struct reginfo sensor_qcif[] =
        {0x97,0x90}, \r
        {0xff, 0xff},\r
 };\r
-\r
+#endif\r
 static  struct reginfo sensor_ClrFmt_YUYV[]=\r
 {\r
     {0xff, 0xff}\r
@@ -1200,7 +1212,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif\r
 };\r
 \r
-static const struct v4l2_queryctrl sensor_controls[] =\r
+static  struct v4l2_queryctrl sensor_controls[] =\r
 {\r
        #if CONFIG_SENSOR_WhiteBalance\r
     {\r
@@ -1393,28 +1405,28 @@ static struct soc_camera_ops sensor_ops =
     .num_menus         = ARRAY_SIZE(sensor_menus),\r
 };\r
 \r
-/* only one fixed colorspace per pixelcode */
-struct sensor_datafmt {
-       enum v4l2_mbus_pixelcode code;
-       enum v4l2_colorspace colorspace;
-};
-
-/* Find a data format by a pixel code in an array */
-static const struct sensor_datafmt *sensor_find_datafmt(
-       enum v4l2_mbus_pixelcode code, const struct sensor_datafmt *fmt,
-       int n)
-{
-       int i;
-       for (i = 0; i < n; i++)
-               if (fmt[i].code == code)
-                       return fmt + i;
-
-       return NULL;
-}
-
-static const struct sensor_datafmt sensor_colour_fmts[] = {
-    {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},
-    {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}    
+/* only one fixed colorspace per pixelcode */\r
+struct sensor_datafmt {\r
+       enum v4l2_mbus_pixelcode code;\r
+       enum v4l2_colorspace colorspace;\r
+};\r
+\r
+/* Find a data format by a pixel code in an array */\r
+static const struct sensor_datafmt *sensor_find_datafmt(\r
+       enum v4l2_mbus_pixelcode code, const struct sensor_datafmt *fmt,\r
+       int n)\r
+{\r
+       int i;\r
+       for (i = 0; i < n; i++)\r
+               if (fmt[i].code == code)\r
+                       return fmt + i;\r
+\r
+       return NULL;\r
+}\r
+\r
+static const struct sensor_datafmt sensor_colour_fmts[] = {\r
+    {V4L2_MBUS_FMT_UYVY8_2X8, V4L2_COLORSPACE_JPEG},\r
+    {V4L2_MBUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG}    \r
 };\r
 \r
 typedef struct sensor_info_priv_s\r
@@ -1662,6 +1674,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 \r
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {\r
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);\r
+                if(on){\r
+                    //flash off after 2 secs\r
+                       hrtimer_cancel(&(flash_off_timer.timer));\r
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);\r
+                    }\r
                        }\r
             break;\r
                }\r
@@ -1674,6 +1691,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 sensor_power_end:\r
        return ret;\r
 }\r
+\r
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){\r
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);\r
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);\r
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);\r
+    return 0;\r
+    \r
+}\r
 static int sensor_init(struct v4l2_subdev *sd, u32 val)\r
 {\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
@@ -1751,11 +1776,11 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
     sensor_task_lock(client,0);\r
     sensor->info_priv.winseqe_cur_addr  = (int)SENSOR_INIT_WINSEQADR;\r
     fmt = sensor_find_datafmt(SENSOR_INIT_PIXFMT,sensor_colour_fmts, ARRAY_SIZE(sensor_colour_fmts));\r
-    if (!fmt) {
-        SENSOR_TR("error: %s initial array colour fmts is not support!!",SENSOR_NAME_STRING());
-        ret = -EINVAL;
-        goto sensor_INIT_ERR;
-    }
+    if (!fmt) {\r
+        SENSOR_TR("error: %s initial array colour fmts is not support!!",SENSOR_NAME_STRING());\r
+        ret = -EINVAL;\r
+        goto sensor_INIT_ERR;\r
+    }\r
        sensor->info_priv.fmt = *fmt;\r
 \r
     /* sensor sensor information for initialization  */\r
@@ -1803,6 +1828,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);\r
        if (qctrl)\r
         sensor->info_priv.flash = qctrl->default_value;\r
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);\r
+    flash_off_timer.icd = icd;\r
+       flash_off_timer.timer.function = flash_off_func;\r
     #endif\r
 \r
     SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),((val == 0)?__FUNCTION__:"sensor_reinit"),icd->user_width,icd->user_height);\r
@@ -1895,55 +1923,55 @@ static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
     return soc_camera_apply_sensor_flags(icl, flags);\r
 }\r
 \r
-static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
+static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct soc_camera_device *icd = client->dev.platform_data;
-    struct sensor *sensor = to_sensor(client);
-
-    mf->width  = icd->user_width;
-       mf->height      = icd->user_height;
-       mf->code        = sensor->info_priv.fmt.code;
-       mf->colorspace  = sensor->info_priv.fmt.colorspace;
-       mf->field       = V4L2_FIELD_NONE;
-
-    return 0;
-}
-static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
-    bool ret = false;
-
-       if ((mf->width == 1024) && (mf->height == 768)) {
-               ret = true;
-       } else if ((mf->width == 1280) && (mf->height == 1024)) {
-               ret = true;
-       } else if ((mf->width == 1600) && (mf->height == 1200)) {
-               ret = true;
-       } else if ((mf->width == 2048) && (mf->height == 1536)) {
-               ret = true;
-       } else if ((mf->width == 2592) && (mf->height == 1944)) {
-               ret = true;
-       }
-
-       if (ret == true)
-               SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, mf->width, mf->height);
-       return ret;
-}
-
-static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
-    bool ret = false;
-
-       if ((mf->width == 1280) && (mf->height == 720)) {
-               ret = true;
-       } else if ((mf->width == 1920) && (mf->height == 1080)) {
-               ret = true;
-       }
-
-       if (ret == true)
-               SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, mf->width, mf->height);
-       return ret;
-}
+    struct soc_camera_device *icd = client->dev.platform_data;\r
+    struct sensor *sensor = to_sensor(client);\r
+\r
+    mf->width  = icd->user_width;\r
+       mf->height      = icd->user_height;\r
+       mf->code        = sensor->info_priv.fmt.code;\r
+       mf->colorspace  = sensor->info_priv.fmt.colorspace;\r
+       mf->field       = V4L2_FIELD_NONE;\r
+\r
+    return 0;\r
+}\r
+static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
+    bool ret = false;\r
+\r
+       if ((mf->width == 1024) && (mf->height == 768)) {\r
+               ret = true;\r
+       } else if ((mf->width == 1280) && (mf->height == 1024)) {\r
+               ret = true;\r
+       } else if ((mf->width == 1600) && (mf->height == 1200)) {\r
+               ret = true;\r
+       } else if ((mf->width == 2048) && (mf->height == 1536)) {\r
+               ret = true;\r
+       } else if ((mf->width == 2592) && (mf->height == 1944)) {\r
+               ret = true;\r
+       }\r
+\r
+       if (ret == true)\r
+               SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, mf->width, mf->height);\r
+       return ret;\r
+}\r
+\r
+static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
+    bool ret = false;\r
+\r
+       if ((mf->width == 1280) && (mf->height == 720)) {\r
+               ret = true;\r
+       } else if ((mf->width == 1920) && (mf->height == 1080)) {\r
+               ret = true;\r
+       }\r
+\r
+       if (ret == true)\r
+               SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, mf->width, mf->height);\r
+       return ret;\r
+}\r
 static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
 {\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
@@ -1954,40 +1982,40 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct reginfo *winseqe_set_addr=NULL;\r
     int ret=0, set_w,set_h;\r
 \r
-       fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
-                                  ARRAY_SIZE(sensor_colour_fmts));
-       if (!fmt) {
-        ret = -EINVAL;
-        goto sensor_s_fmt_end;
-    }
-
-       if (sensor->info_priv.fmt.code != mf->code) {
-               switch (mf->code)
-               {
-                       case V4L2_MBUS_FMT_YUYV8_2X8:
-                       {
-                               winseqe_set_addr = sensor_ClrFmt_YUYV;
-                               break;
-                       }
-                       case V4L2_MBUS_FMT_UYVY8_2X8:
-                       {
-                               winseqe_set_addr = sensor_ClrFmt_UYVY;
-                               break;
-                       }
-                       default:
-                               break;
-               }
-               if (winseqe_set_addr != NULL) {
-            sensor_write_array(client, winseqe_set_addr);
-                       sensor->info_priv.fmt.code = mf->code;
-            sensor->info_priv.fmt.colorspace= mf->colorspace;            
-                       SENSOR_DG("%s v4l2_mbus_code:%d set success!\n", SENSOR_NAME_STRING(),mf->code);
-               } else {
-                       SENSOR_TR("%s v4l2_mbus_code:%d is invalidate!\n", SENSOR_NAME_STRING(),mf->code);
-               }
-       }
-
-    set_w = mf->width;
+       fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,\r
+                                  ARRAY_SIZE(sensor_colour_fmts));\r
+       if (!fmt) {\r
+        ret = -EINVAL;\r
+        goto sensor_s_fmt_end;\r
+    }\r
+\r
+       if (sensor->info_priv.fmt.code != mf->code) {\r
+               switch (mf->code)\r
+               {\r
+                       case V4L2_MBUS_FMT_YUYV8_2X8:\r
+                       {\r
+                               winseqe_set_addr = sensor_ClrFmt_YUYV;\r
+                               break;\r
+                       }\r
+                       case V4L2_MBUS_FMT_UYVY8_2X8:\r
+                       {\r
+                               winseqe_set_addr = sensor_ClrFmt_UYVY;\r
+                               break;\r
+                       }\r
+                       default:\r
+                               break;\r
+               }\r
+               if (winseqe_set_addr != NULL) {\r
+            sensor_write_array(client, winseqe_set_addr);\r
+                       sensor->info_priv.fmt.code = mf->code;\r
+            sensor->info_priv.fmt.colorspace= mf->colorspace;            \r
+                       SENSOR_DG("%s v4l2_mbus_code:%d set success!\n", SENSOR_NAME_STRING(),mf->code);\r
+               } else {\r
+                       SENSOR_TR("%s v4l2_mbus_code:%d is invalidate!\n", SENSOR_NAME_STRING(),mf->code);\r
+               }\r
+       }\r
+\r
+    set_w = mf->width;\r
     set_h = mf->height;\r
 \r
        if (((set_w <= 176) && (set_h <= 144)) &&( sensor_qcif[0].reg!=0xff))\r
@@ -2124,32 +2152,32 @@ sensor_s_fmt_end:
     return ret;\r
 }\r
 \r
-static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
+static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)\r
+{\r
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
-    struct sensor *sensor = to_sensor(client);
-    const struct sensor_datafmt *fmt;
+    struct sensor *sensor = to_sensor(client);\r
+    const struct sensor_datafmt *fmt;\r
     int ret = 0,set_w,set_h;\r
-   
-       fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
-                                  ARRAY_SIZE(sensor_colour_fmts));
-       if (fmt == NULL) {
-               fmt = &sensor->info_priv.fmt;
-        mf->code = fmt->code;
-       } 
-
-    if (mf->height > SENSOR_MAX_HEIGHT)
-        mf->height = SENSOR_MAX_HEIGHT;
-    else if (mf->height < SENSOR_MIN_HEIGHT)
-        mf->height = SENSOR_MIN_HEIGHT;
-
-    if (mf->width > SENSOR_MAX_WIDTH)
-        mf->width = SENSOR_MAX_WIDTH;
-    else if (mf->width < SENSOR_MIN_WIDTH)
-        mf->width = SENSOR_MIN_WIDTH;
-\r
-    set_w = mf->width;
-    set_h = mf->height;
+   \r
+       fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,\r
+                                  ARRAY_SIZE(sensor_colour_fmts));\r
+       if (fmt == NULL) {\r
+               fmt = &sensor->info_priv.fmt;\r
+        mf->code = fmt->code;\r
+       } \r
+\r
+    if (mf->height > SENSOR_MAX_HEIGHT)\r
+        mf->height = SENSOR_MAX_HEIGHT;\r
+    else if (mf->height < SENSOR_MIN_HEIGHT)\r
+        mf->height = SENSOR_MIN_HEIGHT;\r
+\r
+    if (mf->width > SENSOR_MAX_WIDTH)\r
+        mf->width = SENSOR_MAX_WIDTH;\r
+    else if (mf->width < SENSOR_MIN_WIDTH)\r
+        mf->width = SENSOR_MIN_WIDTH;\r
+\r
+    set_w = mf->width;\r
+    set_h = mf->height;\r
 \r
        if (((set_w <= 176) && (set_h <= 144)) &&( sensor_qcif[0].reg!=0xff))\r
        {\r
@@ -2196,11 +2224,11 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
         set_w = SENSOR_INIT_WIDTH;\r
         set_h = SENSOR_INIT_HEIGHT;            \r
     }\r
-    mf->width = set_w;
+    mf->width = set_w;\r
     mf->height = set_h;  \r
-    mf->colorspace = fmt->colorspace;
-    
-    return ret;
+    mf->colorspace = fmt->colorspace;\r
+    \r
+    return ret;\r
 }\r
 \r
  static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)\r
@@ -2969,23 +2997,23 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                case RK29_CAM_SUBDEV_IOREQUEST:\r
                {\r
                        sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;           \r
-            if (sensor->sensor_io_request != NULL) { 
-                sensor->sensor_gpio_res = NULL;
-                for (i=0; i<RK29_CAM_SUPPORT_NUMS;i++) {
-                    if (sensor->sensor_io_request->gpio_res[i].dev_name && 
-                        (strcmp(sensor->sensor_io_request->gpio_res[i].dev_name, dev_name(icd->pdev)) == 0)) {
-                        sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[i];
-                    }
-                }
-                if (sensor->sensor_gpio_res == NULL) {
-                    SENSOR_TR("%s %s obtain gpio resource failed when RK29_CAM_SUBDEV_IOREQUEST \n",SENSOR_NAME_STRING(),__FUNCTION__);
-                    ret = -EINVAL;
-                    goto sensor_ioctl_end;
-                }
-            } else {
-                SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
-                ret = -EINVAL;
-                goto sensor_ioctl_end;
+            if (sensor->sensor_io_request != NULL) { \r
+                sensor->sensor_gpio_res = NULL;\r
+                for (i=0; i<RK29_CAM_SUPPORT_NUMS;i++) {\r
+                    if (sensor->sensor_io_request->gpio_res[i].dev_name && \r
+                        (strcmp(sensor->sensor_io_request->gpio_res[i].dev_name, dev_name(icd->pdev)) == 0)) {\r
+                        sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[i];\r
+                    }\r
+                }\r
+                if (sensor->sensor_gpio_res == NULL) {\r
+                    SENSOR_TR("%s %s obtain gpio resource failed when RK29_CAM_SUBDEV_IOREQUEST \n",SENSOR_NAME_STRING(),__FUNCTION__);\r
+                    ret = -EINVAL;\r
+                    goto sensor_ioctl_end;\r
+                }\r
+            } else {\r
+                SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);\r
+                ret = -EINVAL;\r
+                goto sensor_ioctl_end;\r
             }\r
             /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control \r
                for this project */\r
@@ -2994,11 +3022,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {\r
                     for (i = 0; i < icd->ops->num_controls; i++) {\r
                                if (V4L2_CID_FLASH == icd->ops->controls[i].id) {\r
-                                       memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));                                       \r
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  \r
+                              sensor_controls[i].id=0xffff;                            \r
                                }\r
                     }\r
                     sensor->info_priv.flash = 0xff;\r
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());\r
+                }else{ //two cameras are the same,need to deal diffrently ,zyc\r
+                    for (i = 0; i < icd->ops->num_controls; i++) {\r
+                           if(0xffff == icd->ops->controls[i].id){\r
+                              sensor_controls[i].id=V4L2_CID_FLASH;\r
+                           }               \r
+                    }\r
                 }\r
                }\r
             #endif\r
@@ -3014,14 +3049,14 @@ sensor_ioctl_end:
        return ret;\r
 \r
 }\r
-static int sensor_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-                           enum v4l2_mbus_pixelcode *code)
-{
-       if (index >= ARRAY_SIZE(sensor_colour_fmts))
-               return -EINVAL;
-
-       *code = sensor_colour_fmts[index].code;
-       return 0;
+static int sensor_enum_fmt(struct v4l2_subdev *sd, unsigned int index,\r
+                           enum v4l2_mbus_pixelcode *code)\r
+{\r
+       if (index >= ARRAY_SIZE(sensor_colour_fmts))\r
+               return -EINVAL;\r
+\r
+       *code = sensor_colour_fmts[index].code;\r
+       return 0;\r
 }\r
 static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {\r
        .init           = sensor_init,\r
@@ -3033,11 +3068,11 @@ static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
        .ioctl = sensor_ioctl,\r
 };\r
 \r
-static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
-       .s_mbus_fmt     = sensor_s_fmt,
-       .g_mbus_fmt     = sensor_g_fmt,
-       .try_mbus_fmt   = sensor_try_fmt,
-       .enum_mbus_fmt  = sensor_enum_fmt,
+static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {\r
+       .s_mbus_fmt     = sensor_s_fmt,\r
+       .g_mbus_fmt     = sensor_g_fmt,\r
+       .try_mbus_fmt   = sensor_try_fmt,\r
+       .enum_mbus_fmt  = sensor_enum_fmt,\r
 };\r
 \r
 static struct v4l2_subdev_ops sensor_subdev_ops = {\r
index 4b204e1ac08495c1bd19781f7bdeb3e262450a99..854442006f2bc68b653830de382a32f2ace2cfba 100755 (executable)
@@ -100,6 +100,18 @@ struct reginfo
     u8 val;
 };
 
+//flash off in fixed time to prevent from too hot , zyc
+struct  flash_timer{
+    struct soc_camera_device *icd;
+       struct hrtimer timer;
+};
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+
+static struct  flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#if CONFIG_SIV120B_USER_DEFINED_SERIES
+#include "siv120b_user_series.c"
+#else
 /* init 640X480 VGA */
 static struct reginfo sensor_init_data[] =
 {
@@ -395,7 +407,7 @@ static struct reginfo sensor_qcif[] =
 {
     {0x00,0x00}
 };
-
+#endif
 static  struct reginfo sensor_ClrFmt_YUYV[]=
 {
     {0x00,0x00}
@@ -1001,7 +1013,7 @@ static const struct v4l2_querymenu sensor_menus[] =
     #endif
 };
 
-static const struct v4l2_queryctrl sensor_controls[] =
+static  struct v4l2_queryctrl sensor_controls[] =
 {
        #if CONFIG_SENSOR_WhiteBalance
     {
@@ -1445,6 +1457,11 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
 
                        if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
                                sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+                if(on){
+                    //flash off after 2 secs
+                       hrtimer_cancel(&(flash_off_timer.timer));
+                       hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+                    }
                        }
             break;
                }
@@ -1458,6 +1475,13 @@ sensor_power_end:
        return ret;
 }
 
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+       struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+    sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+       SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+    return 0;
+    
+}
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
     struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1557,6 +1581,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
        qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
        if (qctrl)
         sensor->info_priv.flash = qctrl->default_value;
+       hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+    flash_off_timer.icd = icd;
+       flash_off_timer.timer.function = flash_off_func;
     #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);
@@ -2663,11 +2690,18 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                 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));                                       
+                                       //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));  
+                              sensor_controls[i].id=0xffff;                            
                                }
                     }
                     sensor->info_priv.flash = 0xff;
                     SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }else{ //two cameras are the same,need to deal diffrently ,zyc
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                           if(0xffff == icd->ops->controls[i].id){
+                              sensor_controls[i].id=V4L2_CID_FLASH;
+                           }               
+                    }
                 }
                }
             #endif