From: root <root@lw.(none)>
Date: Fri, 29 Jul 2011 04:17:44 +0000 (+0800)
Subject: A22:XBL modify camera gc0309
X-Git-Tag: firefly_0821_release~9772^2~18^2~5
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cd2dc2921da5673bf74bc1a37d1f05f5be237eeb;p=firefly-linux-kernel-4.4.55.git

A22:XBL modify camera gc0309
---

diff --git a/arch/arm/mach-rk29/board-rk29-a22.c b/arch/arm/mach-rk29/board-rk29-a22.c
index 6a03246fb45a..7528c4733671 100644
--- a/arch/arm/mach-rk29/board-rk29-a22.c
+++ b/arch/arm/mach-rk29/board-rk29-a22.c
@@ -99,11 +99,11 @@
 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_GC0309  /* front camera sensor */
 #define CONFIG_SENSOR_IIC_ADDR_1 	    0x42
 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    1
-#define CONFIG_SENSOR_POWER_PIN_1         INVALID_GPIO
+#define CONFIG_SENSOR_POWER_PIN_1        RK29_PIN5_PA0 //INVALID_GPIO
 #define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
 #define CONFIG_SENSOR_POWERDN_PIN_1       RK29_PIN5_PD7
 #define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
-#define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
+#define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_H
 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
diff --git a/drivers/media/video/gc0309.c b/drivers/media/video/gc0309.c
old mode 100755
new mode 100644
index 8d5b12bf9686..404628c9f9fe
--- a/drivers/media/video/gc0309.c
+++ b/drivers/media/video/gc0309.c
@@ -1421,10 +1421,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
     char value;
     int ret;
 
-    SENSOR_DG("\n-------------%s..%s.. %d,val = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__,val);
-
 	if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
-		 SENSOR_DG("\n-------------%s..%s.. %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
 		ret = -ENODEV;
 		goto sensor_INIT_ERR;
 	}
@@ -1439,7 +1436,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
         ret = -ENODEV;
 		goto sensor_INIT_ERR;
     }
-SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
+
     mdelay(5);  //delay 5 microseconds
 	/* check if it is an sensor sensor */
     ret = sensor_read(client, 0x00, &value);
@@ -1448,7 +1445,7 @@ SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION
         ret = -ENODEV;
         goto sensor_INIT_ERR;
     }
-	SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
+
     if (value == SENSOR_ID) {
         sensor->model = SENSOR_V4L2_IDENT;
     } else {
@@ -1456,7 +1453,7 @@ SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION
         ret = -ENODEV;
         goto sensor_INIT_ERR;
     }
-SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
+
     ret = sensor_write_array(client, sensor_init_data);
     if (ret != 0)
     {
@@ -1468,7 +1465,7 @@ SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION
     //icd->user_height = SENSOR_INIT_HEIGHT;
     sensor->info_priv.winseqe_cur_addr  = (int)SENSOR_INIT_WINSEQADR;
 	sensor->info_priv.pixfmt = SENSOR_INIT_PIXFMT;
-SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
+
     /* sensor sensor information for initialization  */
 	qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
 	if (qctrl)
@@ -1509,7 +1506,7 @@ SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION
 	if (qctrl)
         sensor->info_priv.focus = qctrl->default_value;
 	#endif
-SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
+
 	#if CONFIG_SENSOR_Flash	
 	qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
 	if (qctrl)
@@ -1528,7 +1525,6 @@ sensor_INIT_ERR:
 static int sensor_deactivate(struct i2c_client *client)
 {
 	struct soc_camera_device *icd = client->dev.platform_data;
-	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 */
 	sensor_ioctrl(icd, Sensor_PowerDown, 1);
@@ -1726,7 +1722,7 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
         set_h = SENSOR_INIT_HEIGHT;
 		SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,pix->width,pix->height);
     }
-	SENSOR_TR("------------------------------%s,    %s   ,%d,\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
+	
     	if ((int)winseqe_set_addr  != sensor->info_priv.winseqe_cur_addr) {
         	ret |= sensor_write_array(client, winseqe_set_addr);
         	if (ret != 0) {
@@ -2492,8 +2488,6 @@ static int sensor_video_probe(struct soc_camera_device *icd,
     int ret;
     struct sensor *sensor = to_sensor(client);
 
-	SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
-
     /* 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 ||
@@ -2504,7 +2498,7 @@ static int sensor_video_probe(struct soc_camera_device *icd,
 		ret = -ENODEV;
 		goto sensor_video_probe_err;
 	}
-	SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
+	
     /* soft reset */
     ret = sensor_write(client, 0xfe, 0x80);
     if (ret != 0)
@@ -2513,7 +2507,7 @@ static int sensor_video_probe(struct soc_camera_device *icd,
         return -ENODEV;
     }
     mdelay(5);          //delay 5 microseconds
-SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
+
     /* check if it is an sensor sensor */
     ret = sensor_read(client, 0x00, &value);
     if (ret != 0) {
@@ -2521,7 +2515,7 @@ SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION
         ret = -ENODEV;
         goto sensor_video_probe_err;
     }
-SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
+
     if (value == SENSOR_ID) {
         sensor->model = SENSOR_V4L2_IDENT;
 		SENSOR_TR("chip id:0x%x\n",value);
@@ -2533,7 +2527,6 @@ SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION
 	
     icd->formats = sensor_colour_formats;
     icd->num_formats = ARRAY_SIZE(sensor_colour_formats);
-SENSOR_DG("--------------------%s  ,  %s,  %d\n",SENSOR_NAME_STRING(),__FUNCTION__,__LINE__);
     return 0;
 
 sensor_video_probe_err:
diff --git a/drivers/media/video/rk29_camera.c b/drivers/media/video/rk29_camera.c
old mode 100755
new mode 100644
index 3e19731fe08c..543b0728473e
--- a/drivers/media/video/rk29_camera.c
+++ b/drivers/media/video/rk29_camera.c
@@ -3,47 +3,47 @@
 #ifndef PMEM_CAM_SIZE
 #ifdef CONFIG_VIDEO_RK29 
 /*---------------- Camera Sensor Fixed Macro Begin  ------------------------*/
-// Below Macro is fixed, programer don't change it!!!!!!
-#define _CONS(a,b) a##b
+// Below Macro is fixed, programer don't change it!!!!!!
+#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) #x
+#define _STR(x) __STR(x)
 #define STR(x) _STR(x)
 
-#if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
-#define PMEM_SENSOR_FULL_RESOLUTION_0  CONS(CONFIG_SENSOR_0,_FULL_RESOLUTION)
-#if !(PMEM_SENSOR_FULL_RESOLUTION_0)
-#undef PMEM_SENSOR_FULL_RESOLUTION_0
-#define PMEM_SENSOR_FULL_RESOLUTION_0  0x500000
-#endif
-#else
-#define PMEM_SENSOR_FULL_RESOLUTION_0  0x00
-#endif
- 
-#if (CONFIG_SENSOR_IIC_ADDR_1 != 0x00)
-#define PMEM_SENSOR_FULL_RESOLUTION_1  CONS(CONFIG_SENSOR_1,_FULL_RESOLUTION)
-#if !(PMEM_SENSOR_FULL_RESOLUTION_1)
-#undef PMEM_SENSOR_FULL_RESOLUTION_1
-#define PMEM_SENSOR_FULL_RESOLUTION_1  0x500000
-#endif
-#else
-#define PMEM_SENSOR_FULL_RESOLUTION_1  0x00
-#endif
-
-#if (PMEM_SENSOR_FULL_RESOLUTION_0 > PMEM_SENSOR_FULL_RESOLUTION_1)
-#define PMEM_CAM_FULL_RESOLUTION   PMEM_SENSOR_FULL_RESOLUTION_0
-#else
-#define PMEM_CAM_FULL_RESOLUTION   PMEM_SENSOR_FULL_RESOLUTION_1
-#endif
-
-#if (PMEM_CAM_FULL_RESOLUTION == 0x500000)
+#if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
+#define PMEM_SENSOR_FULL_RESOLUTION_0  CONS(CONFIG_SENSOR_0,_FULL_RESOLUTION)
+#if !(PMEM_SENSOR_FULL_RESOLUTION_0)
+#undef PMEM_SENSOR_FULL_RESOLUTION_0
+#define PMEM_SENSOR_FULL_RESOLUTION_0  0x500000
+#endif
+#else
+#define PMEM_SENSOR_FULL_RESOLUTION_0  0x00
+#endif
+ 
+#if (CONFIG_SENSOR_IIC_ADDR_1 != 0x00)
+#define PMEM_SENSOR_FULL_RESOLUTION_1  CONS(CONFIG_SENSOR_1,_FULL_RESOLUTION)
+#if !(PMEM_SENSOR_FULL_RESOLUTION_1)
+#undef PMEM_SENSOR_FULL_RESOLUTION_1
+#define PMEM_SENSOR_FULL_RESOLUTION_1  0x500000
+#endif
+#else
+#define PMEM_SENSOR_FULL_RESOLUTION_1  0x00
+#endif
+
+#if (PMEM_SENSOR_FULL_RESOLUTION_0 > PMEM_SENSOR_FULL_RESOLUTION_1)
+#define PMEM_CAM_FULL_RESOLUTION   PMEM_SENSOR_FULL_RESOLUTION_0
+#else
+#define PMEM_CAM_FULL_RESOLUTION   PMEM_SENSOR_FULL_RESOLUTION_1
+#endif
+
+#if (PMEM_CAM_FULL_RESOLUTION == 0x500000)
 #define PMEM_CAM_NECESSARY   0x1200000       /* 1280*720*1.5*4(preview) + 7.5M(capture raw) + 4M(jpeg encode output) */
-#elif (PMEM_CAM_FULL_RESOLUTION == 0x300000)
+#elif (PMEM_CAM_FULL_RESOLUTION == 0x300000)
 #define PMEM_CAM_NECESSARY   0xe00000        /* 1280*720*1.5*4(preview) + 4.5M(capture raw) + 3M(jpeg encode output) */
 #elif (PMEM_CAM_FULL_RESOLUTION == 0x200000) /* 1280*720*1.5*4(preview) + 3M(capture raw) + 3M(jpeg encode output) */
 #define PMEM_CAM_NECESSARY   0xc00000
-#elif ((PMEM_CAM_FULL_RESOLUTION == 0x100000) || (PMEM_CAM_FULL_RESOLUTION == 0x130000))
+#elif ((PMEM_CAM_FULL_RESOLUTION == 0x100000) || (PMEM_CAM_FULL_RESOLUTION == 0x130000))
 #define PMEM_CAM_NECESSARY   0x800000        /* 800*600*1.5*4(preview) + 2M(capture raw) + 2M(jpeg encode output) */
 #elif (PMEM_CAM_FULL_RESOLUTION == 0x30000)
 #define PMEM_CAM_NECESSARY   0x400000        /* 640*480*1.5*4(preview) + 1M(capture raw) + 1M(jpeg encode output) */
@@ -56,62 +56,62 @@
 #endif
 #else   // #ifdef PMEM_CAM_SIZE
 
-/*****************************************************************************************
- * camera  devices
- * author: ddl@rock-chips.com
+/*****************************************************************************************
+ * camera  devices
+ * author: ddl@rock-chips.com
  *****************************************************************************************/
 #ifdef CONFIG_VIDEO_RK29 
 static int camera_debug;
 module_param(camera_debug, int, S_IRUGO|S_IWUSR);
-
+
 #define ddprintk(level, fmt, arg...) do {			\
 	if (camera_debug >= level) 					\
 	    printk(KERN_WARNING"rk29_cam_io: " fmt , ## arg); } while (0)
 
 #define dprintk(format, ...) ddprintk(1, format, ## __VA_ARGS__)    
 
-#define SENSOR_NAME_0 STR(CONFIG_SENSOR_0)			/* back camera sensor */
-#define SENSOR_NAME_1 STR(CONFIG_SENSOR_1)			/* front camera sensor */
-#define SENSOR_DEVICE_NAME_0  STR(CONS(CONFIG_SENSOR_0, _back))
-#define SENSOR_DEVICE_NAME_1  STR(CONS(CONFIG_SENSOR_1, _front))
-
-static int rk29_sensor_io_init(void);
-static int rk29_sensor_io_deinit(int sensor);
-static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
-
+#define SENSOR_NAME_0 STR(CONFIG_SENSOR_0)			/* back camera sensor */
+#define SENSOR_NAME_1 STR(CONFIG_SENSOR_1)			/* front camera sensor */
+#define SENSOR_DEVICE_NAME_0  STR(CONS(CONFIG_SENSOR_0, _back))
+#define SENSOR_DEVICE_NAME_1  STR(CONS(CONFIG_SENSOR_1, _front))
+
+static int rk29_sensor_io_init(void);
+static int rk29_sensor_io_deinit(int sensor);
+static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
+
 static struct rk29camera_platform_data rk29_camera_platform_data = {
-    .io_init = rk29_sensor_io_init,
-    .io_deinit = rk29_sensor_io_deinit,
-    .sensor_ioctrl = rk29_sensor_ioctrl,
-    .gpio_res = {
-        {
-            .gpio_reset = CONFIG_SENSOR_RESET_PIN_0,
-            .gpio_power = CONFIG_SENSOR_POWER_PIN_0,
-            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_0,
-            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_0,
-            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_0|CONFIG_SENSOR_RESETACTIVE_LEVEL_0|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0|CONFIG_SENSOR_FLASHACTIVE_LEVEL_0),
-            .gpio_init = 0,
-            .dev_name = SENSOR_DEVICE_NAME_0,
-        }, {
-            .gpio_reset = CONFIG_SENSOR_RESET_PIN_1,
-            .gpio_power = CONFIG_SENSOR_POWER_PIN_1,
-            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_1,
-            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_1,
-            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_1|CONFIG_SENSOR_RESETACTIVE_LEVEL_1|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1|CONFIG_SENSOR_FLASHACTIVE_LEVEL_1),
-            .gpio_init = 0,
-            .dev_name = SENSOR_DEVICE_NAME_1,
-        }
-    },
-	#ifdef CONFIG_VIDEO_RK29_WORK_IPP
-	.meminfo = {
-	    .name  = "camera_ipp_mem",
-		.start = MEM_CAMIPP_BASE,
-		.size   = MEM_CAMIPP_SIZE,
-	}
-	#endif
+    .io_init = rk29_sensor_io_init,
+    .io_deinit = rk29_sensor_io_deinit,
+    .sensor_ioctrl = rk29_sensor_ioctrl,
+    .gpio_res = {
+        {
+            .gpio_reset = CONFIG_SENSOR_RESET_PIN_0,
+            .gpio_power = CONFIG_SENSOR_POWER_PIN_0,
+            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_0,
+            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_0,
+            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_0|CONFIG_SENSOR_RESETACTIVE_LEVEL_0|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0|CONFIG_SENSOR_FLASHACTIVE_LEVEL_0),
+            .gpio_init = 0,
+            .dev_name = SENSOR_DEVICE_NAME_0,
+        }, {
+            .gpio_reset = CONFIG_SENSOR_RESET_PIN_1,
+            .gpio_power = CONFIG_SENSOR_POWER_PIN_1,
+            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_1,
+            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_1,
+            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_1|CONFIG_SENSOR_RESETACTIVE_LEVEL_1|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1|CONFIG_SENSOR_FLASHACTIVE_LEVEL_1),
+            .gpio_init = 0,
+            .dev_name = SENSOR_DEVICE_NAME_1,
+        }
+    },
+	#ifdef CONFIG_VIDEO_RK29_WORK_IPP
+	.meminfo = {
+	    .name  = "camera_ipp_mem",
+		.start = MEM_CAMIPP_BASE,
+		.size   = MEM_CAMIPP_SIZE,
+	}
+	#endif
 };
 
-
+
 
 static int sensor_power_default_cb (struct rk29camera_gpio_res *res, int on)
 {
@@ -121,7 +121,7 @@ static int sensor_power_default_cb (struct rk29camera_gpio_res *res, int on)
     int ret = 0;
     
     if (camera_power != INVALID_GPIO)  {
-        if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
+		     if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
             if (on) {
             	gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
     			dprintk("\n%s..%s..PowerPin=%d ..PinLevel = %x   \n",__FUNCTION__,res->dev_name, camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
@@ -142,7 +142,7 @@ static int sensor_power_default_cb (struct rk29camera_gpio_res *res, int on)
 }
 
 static int sensor_reset_default_cb (struct rk29camera_gpio_res *res, int on)
-{
+{
     int camera_reset = res->gpio_reset;
     int camera_ioflag = res->gpio_flag;
     int camera_io_init = res->gpio_init;  
@@ -166,10 +166,10 @@ static int sensor_reset_default_cb (struct rk29camera_gpio_res *res, int on)
     }
 
     return ret;
-}
+}
 
 static int sensor_powerdown_default_cb (struct rk29camera_gpio_res *res, int on)
-{
+{
     int camera_powerdown = res->gpio_powerdown;
     int camera_ioflag = res->gpio_flag;
     int camera_io_init = res->gpio_init;  
@@ -192,9 +192,9 @@ static int sensor_powerdown_default_cb (struct rk29camera_gpio_res *res, int on)
 		ret = RK29_CAM_EIO_INVALID;
     }
     return ret;
-}
+}
+
 
-
 static int sensor_flash_default_cb (struct rk29camera_gpio_res *res, int on)
 {
     int camera_flash = res->gpio_flash;
@@ -243,13 +243,13 @@ static int sensor_flash_default_cb (struct rk29camera_gpio_res *res, int on)
     return ret;
 }
 
-
-static int rk29_sensor_io_init(void)
-{
-    int ret = 0, i;
-    unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
-	unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
-	unsigned int camera_ioflag;
+
+static int rk29_sensor_io_init(void)
+{
+    int ret = 0, i;
+    unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
+	unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
+	unsigned int camera_ioflag;
 
     if (sensor_ioctl_cb.sensor_power_cb == NULL)
         sensor_ioctl_cb.sensor_power_cb = sensor_power_default_cb;
@@ -260,297 +260,298 @@ static int rk29_sensor_io_init(void)
     if (sensor_ioctl_cb.sensor_flash_cb == NULL)
         sensor_ioctl_cb.sensor_flash_cb = sensor_flash_default_cb;
     
-    for (i=0; i<2; i++) {
-        camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
-        camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
-		camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
-        camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
-		camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
-		rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
-
-        if (camera_power != INVALID_GPIO) {
-            ret = gpio_request(camera_power, "camera power");
-            if (ret) {
+    for (i=0; i<2; i++) {
+        camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
+        camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
+		camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
+        camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
+		camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
+		rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
+
+        if (camera_power != INVALID_GPIO) {
+            ret = gpio_request(camera_power, "camera power");
+            if (ret) {
                 if (i == 0) {
-				    goto sensor_io_int_loop_end;
+				    goto sensor_io_int_loop_end;
                 } else {
                     if (camera_power != rk29_camera_platform_data.gpio_res[0].gpio_power)
                         goto sensor_io_int_loop_end;
                 }
             }
-			rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
-            gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
-            gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
-
-			dprintk("\n%s....power pin(%d) init success(0x%x)  \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
-
-        }
-
-        if (camera_reset != INVALID_GPIO) {
-            ret = gpio_request(camera_reset, "camera reset");
-            if (ret)
-				goto sensor_io_int_loop_end;
-			rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
-            gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
-            gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
-
+
+			rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
+            gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
+            gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
+
+			printk("\n%s....power pin(%d) init success(0x%x)  \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
+
+        }
+
+        if (camera_reset != INVALID_GPIO) {
+            ret = gpio_request(camera_reset, "camera reset");
+            if (ret)
+				goto sensor_io_int_loop_end;
+			rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
+            gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
+            gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
+
 			dprintk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
-
-        }
-
-		if (camera_powerdown != INVALID_GPIO) {
-            ret = gpio_request(camera_powerdown, "camera powerdown");
-            if (ret)
-				goto sensor_io_int_loop_end;
-			rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
-            gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
-            gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
-
-			dprintk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
-
-        }
-
-		if (camera_flash != INVALID_GPIO) {
-            ret = gpio_request(camera_flash, "camera flash");
-            if (ret)
-				goto sensor_io_int_loop_end;
-			rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
+
+        }
+
+		if (camera_powerdown != INVALID_GPIO) {
+            ret = gpio_request(camera_powerdown, "camera powerdown");
+            if (ret)
+				goto sensor_io_int_loop_end;
+			rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
+            gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
+            gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
+
+			printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
+
+        }
+
+		if (camera_flash != INVALID_GPIO) {
+            ret = gpio_request(camera_flash, "camera flash");
+            if (ret)
+				goto sensor_io_int_loop_end;
+			rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
             gpio_set_value(camera_flash, ((~camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));    /* falsh off */
             gpio_direction_output(camera_flash, ((~camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
-
+
 			dprintk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
-
-        }
-		continue;
-sensor_io_int_loop_end:
-		rk29_sensor_io_deinit(i);
-		continue;
-    }
-
-    return 0;
-}
-
-static int rk29_sensor_io_deinit(int sensor)
-{
-    unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
-	unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
-
-    camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
-    camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
-	camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
-    camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
-
-	if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
-	    if (camera_power != INVALID_GPIO) {
-	        gpio_direction_input(camera_power);
-	        gpio_free(camera_power);
-	    }
-	}
-
-	if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
-	    if (camera_reset != INVALID_GPIO)  {
-	        gpio_direction_input(camera_reset);
-	        gpio_free(camera_reset);
-	    }
-	}
-
-	if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
-	    if (camera_powerdown != INVALID_GPIO)  {
-	        gpio_direction_input(camera_powerdown);
-	        gpio_free(camera_powerdown);
-	    }
-	}
-
-	if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
-	    if (camera_flash != INVALID_GPIO)  {
-	        gpio_direction_input(camera_flash);
-	        gpio_free(camera_flash);
-	    }
-	}
-
-	rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
-    return 0;
-}
-static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
-{
+
+        }
+		continue;
+sensor_io_int_loop_end:
+		rk29_sensor_io_deinit(i);
+		continue;
+    }
+
+    return 0;
+}
+
+static int rk29_sensor_io_deinit(int sensor)
+{
+    unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
+	unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
+
+    camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
+    camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
+	camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
+    camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
+
+	if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
+	    if (camera_power != INVALID_GPIO) {
+	        gpio_direction_input(camera_power);
+	        gpio_free(camera_power);
+	    }
+	}
+
+	if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
+	    if (camera_reset != INVALID_GPIO)  {
+	        gpio_direction_input(camera_reset);
+	        gpio_free(camera_reset);
+	    }
+	}
+
+	if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
+	    if (camera_powerdown != INVALID_GPIO)  {
+	        gpio_direction_input(camera_powerdown);
+	        gpio_free(camera_powerdown);
+	    }
+	}
+
+	if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
+	    if (camera_flash != INVALID_GPIO)  {
+	        gpio_direction_input(camera_flash);
+	        gpio_free(camera_flash);
+	    }
+	}
+
+	rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
+    return 0;
+}
+static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
+{
     struct rk29camera_gpio_res *res = NULL;    
-	int ret = RK29_CAM_IO_SUCCESS;
-
-    if(rk29_camera_platform_data.gpio_res[0].dev_name &&  (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
+	int ret = RK29_CAM_IO_SUCCESS;
+
+    if(rk29_camera_platform_data.gpio_res[0].dev_name &&  (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
 		res = (struct rk29camera_gpio_res *)&rk29_camera_platform_data.gpio_res[0];
-    } else if (rk29_camera_platform_data.gpio_res[1].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[1].dev_name, dev_name(dev)) == 0)) {
+    } else if (rk29_camera_platform_data.gpio_res[1].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[1].dev_name, dev_name(dev)) == 0)) {
     	res = (struct rk29camera_gpio_res *)&rk29_camera_platform_data.gpio_res[1];
     } else {
         printk(KERN_ERR "%s is not regisiterd in rk29_camera_platform_data!!\n",dev_name(dev));
         ret = RK29_CAM_EIO_INVALID;
         goto rk29_sensor_ioctrl_end;
     }
-
- 	switch (cmd)
- 	{
- 		case Cam_Power:
-		{
+
+ 	switch (cmd)
+ 	{
+ 		case Cam_Power:
+		{
 			if (sensor_ioctl_cb.sensor_power_cb) {
                 ret = sensor_ioctl_cb.sensor_power_cb(res, on);
 			} else {
                 printk(KERN_ERR "sensor_ioctl_cb.sensor_power_cb is NULL");
                 WARN_ON(1);
 			}
-			break;
-		}
-		case Cam_Reset:
-		{
+			break;
+		}
+		case Cam_Reset:
+		{
 			if (sensor_ioctl_cb.sensor_reset_cb) {
                 ret = sensor_ioctl_cb.sensor_reset_cb(res, on);
 			} else {
                 printk(KERN_ERR "sensor_ioctl_cb.sensor_reset_cb is NULL");
                 WARN_ON(1);
 			}
-			break;
-		}
-
-		case Cam_PowerDown:
-		{
+			break;
+		}
+
+		case Cam_PowerDown:
+		{
 			if (sensor_ioctl_cb.sensor_powerdown_cb) {
                 ret = sensor_ioctl_cb.sensor_powerdown_cb(res, on);
 			} else {
                 printk(KERN_ERR "sensor_ioctl_cb.sensor_powerdown_cb is NULL");
                 WARN_ON(1);
 			}
-			break;
-		}
-
-		case Cam_Flash:
-		{
+			break;
+		}
+
+		case Cam_Flash:
+		{
 			if (sensor_ioctl_cb.sensor_flash_cb) {
                 ret = sensor_ioctl_cb.sensor_flash_cb(res, on);
 			} else {
                 printk(KERN_ERR "sensor_ioctl_cb.sensor_flash_cb is NULL!");
                 WARN_ON(1);
 			}
-			break;
-		}
-
-		default:
-		{
-			printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
-			break;
-		}
+			break;
+		}
+
+		default:
+		{
+			printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
+			break;
+		}
  	}
 rk29_sensor_ioctrl_end:
-    return ret;
-}
-static int rk29_sensor_power(struct device *dev, int on)
-{
-	rk29_sensor_ioctrl(dev,Cam_Power,on);
-    return 0;
+    return ret;
+}
+static int rk29_sensor_power(struct device *dev, int on)
+{
+	rk29_sensor_ioctrl(dev,Cam_Power,on);
+    return 0;
 }
 #if 0
-static int rk29_sensor_reset(struct device *dev)
-{
-	rk29_sensor_ioctrl(dev,Cam_Reset,1);
-	msleep(2);
-	rk29_sensor_ioctrl(dev,Cam_Reset,0);
-	return 0;
+static int rk29_sensor_reset(struct device *dev)
+{
+	rk29_sensor_ioctrl(dev,Cam_Reset,1);
+	msleep(2);
+	rk29_sensor_ioctrl(dev,Cam_Reset,0);
+	return 0;
 }
 #endif
-static int rk29_sensor_powerdown(struct device *dev, int on)
-{
-	return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
-}
-#if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
-static struct i2c_board_info rk29_i2c_cam_info_0[] = {
-	{
-		I2C_BOARD_INFO(SENSOR_NAME_0, CONFIG_SENSOR_IIC_ADDR_0>>1)
-	},
-};
-
-static struct soc_camera_link rk29_iclink_0 = {
-	.bus_id		= RK29_CAM_PLATFORM_DEV_ID,
-	.power		= rk29_sensor_power,
-	.powerdown  = rk29_sensor_powerdown,
-	.board_info	= &rk29_i2c_cam_info_0[0],
-	.i2c_adapter_id	= CONFIG_SENSOR_IIC_ADAPTER_ID_0,
-	.module_name	= SENSOR_NAME_0,
-};
-
-/*platform_device : soc-camera need  */
-static struct platform_device rk29_soc_camera_pdrv_0 = {
-	.name	= "soc-camera-pdrv",
-	.id	= 0,
-	.dev	= {
-		.init_name = SENSOR_DEVICE_NAME_0,
-		.platform_data = &rk29_iclink_0,
-	},
-};
-#endif
-static struct i2c_board_info rk29_i2c_cam_info_1[] = {
-	{
-		I2C_BOARD_INFO(SENSOR_NAME_1, CONFIG_SENSOR_IIC_ADDR_1>>1)
-	},
-};
-
-static struct soc_camera_link rk29_iclink_1 = {
-	.bus_id		= RK29_CAM_PLATFORM_DEV_ID,
-	.power		= rk29_sensor_power,
-	.powerdown  = rk29_sensor_powerdown,
-	.board_info	= &rk29_i2c_cam_info_1[0],
-	.i2c_adapter_id	= CONFIG_SENSOR_IIC_ADAPTER_ID_1,
-	.module_name	= SENSOR_NAME_1,
-};
-
-/*platform_device : soc-camera need  */
-static struct platform_device rk29_soc_camera_pdrv_1 = {
-	.name	= "soc-camera-pdrv",
-	.id	= 1,
-	.dev	= {
-		.init_name = SENSOR_DEVICE_NAME_1,
-		.platform_data = &rk29_iclink_1,
-	},
-};
-
-
-static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
-static struct resource rk29_camera_resource[] = {
-	[0] = {
-		.start = RK29_VIP_PHYS,
-		.end   = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
-		.flags = IORESOURCE_MEM,
-	},
-	[1] = {
-		.start = IRQ_VIP,
-		.end   = IRQ_VIP,
-		.flags = IORESOURCE_IRQ,
-	}
-};
-
-/*platform_device : */
-static struct platform_device rk29_device_camera = {
-	.name		  = RK29_CAM_DRV_NAME,
-	.id		  = RK29_CAM_PLATFORM_DEV_ID,               /* This is used to put cameras on this interface */
-	.num_resources	  = ARRAY_SIZE(rk29_camera_resource),
-	.resource	  = rk29_camera_resource,
-	.dev            = {
-		.dma_mask = &rockchip_device_camera_dmamask,
-		.coherent_dma_mask = 0xffffffffUL,
-		.platform_data  = &rk29_camera_platform_data,
-	}
-};
-
-static struct android_pmem_platform_data android_pmem_cam_pdata = {
-	.name		= "pmem_cam",
-	.start		= PMEM_CAM_BASE,
-	.size		= PMEM_CAM_SIZE,
-	.no_allocator	= 1,
-	.cached		= 1,
-};
-
-static struct platform_device android_pmem_cam_device = {
-	.name		= "android_pmem",
-	.id		= 1,
-	.dev		= {
-		.platform_data = &android_pmem_cam_pdata,
-	},
+static int rk29_sensor_powerdown(struct device *dev, int on)
+{
+	return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
+}
+#if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
+static struct i2c_board_info rk29_i2c_cam_info_0[] = {
+	{
+		I2C_BOARD_INFO(SENSOR_NAME_0, CONFIG_SENSOR_IIC_ADDR_0>>1)
+	},
+};
+
+static struct soc_camera_link rk29_iclink_0 = {
+	.bus_id		= RK29_CAM_PLATFORM_DEV_ID,
+	.power		= rk29_sensor_power,
+	.powerdown  = rk29_sensor_powerdown,
+	.board_info	= &rk29_i2c_cam_info_0[0],
+	.i2c_adapter_id	= CONFIG_SENSOR_IIC_ADAPTER_ID_0,
+	.module_name	= SENSOR_NAME_0,
+};
+
+/*platform_device : soc-camera need  */
+static struct platform_device rk29_soc_camera_pdrv_0 = {
+	.name	= "soc-camera-pdrv",
+	.id	= 0,
+	.dev	= {
+		.init_name = SENSOR_DEVICE_NAME_0,
+		.platform_data = &rk29_iclink_0,
+	},
+};
+#endif
+static struct i2c_board_info rk29_i2c_cam_info_1[] = {
+	{
+		I2C_BOARD_INFO(SENSOR_NAME_1, CONFIG_SENSOR_IIC_ADDR_1>>1)
+	},
+};
+
+static struct soc_camera_link rk29_iclink_1 = {
+	.bus_id		= RK29_CAM_PLATFORM_DEV_ID,
+	.power		= rk29_sensor_power,
+	.powerdown  = rk29_sensor_powerdown,
+	.board_info	= &rk29_i2c_cam_info_1[0],
+	.i2c_adapter_id	= CONFIG_SENSOR_IIC_ADAPTER_ID_1,
+	.module_name	= SENSOR_NAME_1,
+};
+
+/*platform_device : soc-camera need  */
+static struct platform_device rk29_soc_camera_pdrv_1 = {
+	.name	= "soc-camera-pdrv",
+	.id	= 1,
+	.dev	= {
+		.init_name = SENSOR_DEVICE_NAME_1,
+		.platform_data = &rk29_iclink_1,
+	},
+};
+
+
+static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
+static struct resource rk29_camera_resource[] = {
+	[0] = {
+		.start = RK29_VIP_PHYS,
+		.end   = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
+		.flags = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start = IRQ_VIP,
+		.end   = IRQ_VIP,
+		.flags = IORESOURCE_IRQ,
+	}
+};
+
+/*platform_device : */
+static struct platform_device rk29_device_camera = {
+	.name		  = RK29_CAM_DRV_NAME,
+	.id		  = RK29_CAM_PLATFORM_DEV_ID,               /* This is used to put cameras on this interface */
+	.num_resources	  = ARRAY_SIZE(rk29_camera_resource),
+	.resource	  = rk29_camera_resource,
+	.dev            = {
+		.dma_mask = &rockchip_device_camera_dmamask,
+		.coherent_dma_mask = 0xffffffffUL,
+		.platform_data  = &rk29_camera_platform_data,
+	}
+};
+
+static struct android_pmem_platform_data android_pmem_cam_pdata = {
+	.name		= "pmem_cam",
+	.start		= PMEM_CAM_BASE,
+	.size		= PMEM_CAM_SIZE,
+	.no_allocator	= 1,
+	.cached		= 1,
+};
+
+static struct platform_device android_pmem_cam_device = {
+	.name		= "android_pmem",
+	.id		= 1,
+	.dev		= {
+		.platform_data = &android_pmem_cam_pdata,
+	},
 };
 
 #endif