camera: fix sensor driver compolite warning
authorddl <ddl@rockchip.com>
Wed, 27 Apr 2011 04:02:07 +0000 (12:02 +0800)
committerddl <ddl@rockchip.com>
Wed, 27 Apr 2011 04:04:06 +0000 (12:04 +0800)
drivers/media/video/mt9d112.c
drivers/media/video/mt9d113.c
drivers/media/video/mt9p111.c
drivers/media/video/ov2655.c
drivers/media/video/ov2659.c
drivers/media/video/ov5640.c
drivers/media/video/ov5642.c
drivers/media/video/s5k6aa.c

index 9ebdb4ba0da8593fab29d1be021a8488e2cc2f41..58d6ba39aba15431ebb2bc33aded37a164e6afcf 100755 (executable)
@@ -1466,6 +1466,7 @@ struct sensor
        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)
@@ -1502,10 +1503,13 @@ static int sensor_task_lock(struct i2c_client *client, int lock)
                                preempt_enable();
                }
        }
-#endif
        return 0;
 sensor_task_lock_err:
-       return -1;
+       return -1;  
+#else
+    return 0;
+#endif
+
 }
 
 /* sensor register write */
@@ -1708,7 +1712,7 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
        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:
@@ -1740,7 +1744,7 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
                }
                default:
                {
-                       SENSOR_TR("%s power cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),cmd);
+                       SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
                        break;
                }
        }
@@ -1754,7 +1758,10 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
     struct soc_camera_device *icd = client->dev.platform_data;
     struct sensor *sensor = to_sensor(client);
        const struct v4l2_queryctrl *qctrl;
-    int ret,pid = 0;
+    int ret;
+#if (SENSOR_ID_REG != SEQUENCE_END)    
+    u16 pid = 0;
+#endif
 
     SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
 
@@ -1847,9 +1854,12 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
         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  */
-       qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
+       #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);
@@ -1872,11 +1882,12 @@ static int sensor_deactivate(struct i2c_client *client)
 
        /* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
        sensor_task_lock(client, 1);
+       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;
-
+       msleep(100);
        return 0;
 }
 static  struct reginfo sensor_power_down_sequence[]=
@@ -2436,6 +2447,23 @@ static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4
     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
 #if CONFIG_SENSOR_Focus
 static int sensor_set_focus_absolute(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
 {
@@ -2551,7 +2579,7 @@ static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 
     if (!qctrl)
     {
-        SENSOR_TR("\n %s ioctrl id = 0x%x  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
         return -EINVAL;
     }
 
@@ -2612,7 +2640,7 @@ static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 
     if (!qctrl)
     {
-        SENSOR_TR("\n %s ioctrl id = 0x%x  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
         return -EINVAL;
     }
 
@@ -2728,7 +2756,7 @@ static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_
 
     if (!qctrl)
     {
-        SENSOR_TR("\n %s ioctrl id = 0x%x  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
         return -EINVAL;
     }
 
@@ -2755,7 +2783,8 @@ static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_
             }
         case V4L2_CID_FOCUS_ABSOLUTE:
             {
-                return -EINVAL;
+                ext_ctrl->value = sensor->info_priv.focus;
+                break;
             }
         case V4L2_CID_FOCUS_RELATIVE:
             {
@@ -2782,7 +2811,7 @@ static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_c
 
     if (!qctrl)
     {
-        SENSOR_TR("\n %s ioctrl id = 0x%x  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
         return -EINVAL;
     }
 
@@ -2901,6 +2930,8 @@ static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_c
 #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);
@@ -2973,8 +3004,7 @@ static int sensor_s_stream(struct v4l2_subdev *sd, int enable)
        } else if (enable == 0) {
                sensor->info_priv.enable = 0;
        }
-
-sensor_s_stream_end:
+    
        return 0;
 }
 
@@ -2983,7 +3013,11 @@ sensor_s_stream_end:
 static int sensor_video_probe(struct soc_camera_device *icd,
                               struct i2c_client *client)
 {
-    int ret,pid = 0;
+    int ret;
+#if (SENSOR_ID_REG != SEQUENCE_END)
+    u16 pid = 0;
+#endif
+
     struct sensor *sensor = to_sensor(client);
 
     /* We must have a parent by now. And it cannot be a wrong one.
@@ -3042,8 +3076,13 @@ sensor_video_probe_err:
 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
 {
        struct i2c_client *client = sd->priv;
+    struct soc_camera_device *icd = client->dev.platform_data;
     struct sensor *sensor = to_sensor(client);
-
+    int ret = 0;
+#if CONFIG_SENSOR_Flash        
+    int i;
+#endif
+    
        SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
        switch (cmd)
        {
@@ -3055,6 +3094,34 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                case RK29_CAM_SUBDEV_IOREQUEST:
                {
                        sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
+            if (sensor->sensor_io_request != NULL) { 
+                if (sensor->sensor_io_request->gpio_res[0].dev_name && 
+                    (strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
+                    sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
+                } else if (sensor->sensor_io_request->gpio_res[1].dev_name && 
+                    (strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
+                    sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
+                }
+            } else {
+                SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
+                ret = -EINVAL;
+                goto sensor_ioctl_end;
+            }
+            /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control 
+               for this project */
+            #if CONFIG_SENSOR_Flash    
+               if (sensor->sensor_gpio_res) { 
+                if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                               if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
+                                       memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));                                       
+                               }
+                    }
+                    sensor->info_priv.flash = 0xff;
+                    SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }
+               }
+            #endif
                        break;
                }
                default:
@@ -3063,8 +3130,8 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                        break;
                }
        }
-
-       return 0;
+sensor_ioctl_end:
+       return ret;
 
 }
 
index e95f77449ed7306776dfa3ff96f0f3eaa0be35a6..258212e310d973b3bd0c5fb2ef47fb3a2dca041b 100755 (executable)
@@ -1234,10 +1234,13 @@ static int sensor_task_lock(struct i2c_client *client, int lock)
                                preempt_enable();
                }
        }
-#endif
+    
        return 0;
 sensor_task_lock_err:
-       return -1;
+       return -1;    
+#else
+    return 0;
+#endif
 }
 
 static int sensor_read(struct i2c_client *client, u16 reg, u16 *val);
@@ -2445,11 +2448,9 @@ 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)
 {
     struct i2c_client *client = sd->priv;
+    const struct v4l2_queryctrl *qctrl;   
     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)
@@ -2618,7 +2619,7 @@ static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_c
     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;
+    int val_offset;      
 
     qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
 
@@ -2818,7 +2819,6 @@ static int sensor_s_stream(struct v4l2_subdev *sd, int enable)
                sensor->info_priv.enable = 0;
        }
 
-sensor_s_stream_end:
        return 0;
 }
 
@@ -2829,6 +2829,9 @@ static int sensor_video_probe(struct soc_camera_device *icd,
 {
     int ret=0;
     struct sensor *sensor = to_sensor(client);
+#if (SENSOR_ID_REG != SEQUENCE_END)
+    u16 pid;
+#endif
 
     /* We must have a parent by now. And it cannot be a wrong one.
      * So this entire test is completely redundant. */
@@ -2859,7 +2862,6 @@ static int sensor_video_probe(struct soc_camera_device *icd,
 
        /* check if it is an sensor sensor */
 #if (SENSOR_ID_REG != SEQUENCE_END)
-    u16 pid;
     ret = sensor_read(client, SENSOR_ID_REG, &pid);
     if (ret != 0) {
         SENSOR_TR("read chip id failed\n");
index 9beb04630f81e3b99cdc761e315a3f8473c6b2c5..c23878fbb26d6619be1c6ce4dde97423e5bdec65 100755 (executable)
@@ -2221,6 +2221,7 @@ struct sensor
        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)
@@ -2257,10 +2258,13 @@ static int sensor_task_lock(struct i2c_client *client, int lock)
                                preempt_enable();
                }
        }
-#endif
        return 0;
 sensor_task_lock_err:
        return -1;
+#else
+    return 0;
+#endif
+
 }
 
 /* sensor register write */
@@ -2568,7 +2572,7 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
        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:
@@ -2600,7 +2604,7 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
                }
                default:
                {
-                       SENSOR_TR("%s power cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),cmd);
+                       SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
                        break;
                }
        }
@@ -2615,6 +2619,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
     struct sensor *sensor = to_sensor(client);
        const struct v4l2_queryctrl *qctrl;
     int ret,pid = 0;
+#if (SENSOR_RESET_REG != SEQUENCE_END)
+    struct reginfo reg_info;
+#endif
 
     SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
 
@@ -2628,7 +2635,6 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
                goto sensor_INIT_ERR;
 
 #if (SENSOR_RESET_REG != SEQUENCE_END)
-    struct reginfo reg_info;
        reg_info.reg = SENSOR_RESET_REG;
        reg_info.val = SENSOR_RESET_VAL;
        reg_info.reg_len = SENSOR_RESET_REG_LEN;
@@ -2749,7 +2755,7 @@ static int sensor_deactivate(struct i2c_client *client)
        /* 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;
-
+       msleep(100);
        return 0;
 }
 static  struct reginfo sensor_power_down_sequence[]=
@@ -3303,6 +3309,23 @@ static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4
     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
 #if CONFIG_SENSOR_Focus
 static int sensor_set_focus_absolute(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
 {
@@ -3418,7 +3441,7 @@ static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 
     if (!qctrl)
     {
-        SENSOR_TR("\n %s ioctrl id = 0x%x  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
         return -EINVAL;
     }
 
@@ -3479,7 +3502,7 @@ static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 
     if (!qctrl)
     {
-        SENSOR_TR("\n %s ioctrl id = 0x%x  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
         return -EINVAL;
     }
 
@@ -3595,7 +3618,7 @@ static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_
 
     if (!qctrl)
     {
-        SENSOR_TR("\n %s ioctrl id = 0x%x  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
         return -EINVAL;
     }
 
@@ -3622,7 +3645,8 @@ static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_
             }
         case V4L2_CID_FOCUS_ABSOLUTE:
             {
-                return -EINVAL;
+                ext_ctrl->value = sensor->info_priv.focus;
+                break;
             }
         case V4L2_CID_FOCUS_RELATIVE:
             {
@@ -3649,7 +3673,7 @@ static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_c
 
     if (!qctrl)
     {
-        SENSOR_TR("\n %s ioctrl id = 0x%x  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
+        SENSOR_TR("\n %s ioctrl id = %d  is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
         return -EINVAL;
     }
 
@@ -3768,6 +3792,8 @@ static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_c
 #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);
@@ -3840,8 +3866,6 @@ static int sensor_s_stream(struct v4l2_subdev *sd, int enable)
        } else if (enable == 0) {
                sensor->info_priv.enable = 0;
        }
-
-sensor_s_stream_end:
        return 0;
 }
 
@@ -3852,6 +3876,9 @@ static int sensor_video_probe(struct soc_camera_device *icd,
 {
     int ret,pid = 0;
     struct sensor *sensor = to_sensor(client);
+#if (SENSOR_RESET_REG != SEQUENCE_END)
+    struct reginfo reg_info;
+#endif
 
     /* We must have a parent by now. And it cannot be a wrong one.
      * So this entire test is completely redundant. */
@@ -3866,7 +3893,6 @@ static int sensor_video_probe(struct soc_camera_device *icd,
 
     /* soft reset */
 #if (SENSOR_RESET_REG != SEQUENCE_END)
-    struct reginfo reg_info;
        reg_info.reg = SENSOR_RESET_REG;
        reg_info.val = SENSOR_RESET_VAL;
        reg_info.reg_len = SENSOR_RESET_REG_LEN;
@@ -3914,7 +3940,12 @@ sensor_video_probe_err:
 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
 {
        struct i2c_client *client = sd->priv;
+    struct soc_camera_device *icd = client->dev.platform_data;
     struct sensor *sensor = to_sensor(client);
+    int ret = 0;
+#if CONFIG_SENSOR_Flash        
+    int i;
+#endif
 
        SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
        switch (cmd)
@@ -3926,7 +3957,35 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                }
                case RK29_CAM_SUBDEV_IOREQUEST:
                {
-                       sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
+                       sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;           
+            if (sensor->sensor_io_request != NULL) { 
+                if (sensor->sensor_io_request->gpio_res[0].dev_name && 
+                    (strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
+                    sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
+                } else if (sensor->sensor_io_request->gpio_res[1].dev_name && 
+                    (strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
+                    sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
+                }
+            } else {
+                SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
+                ret = -EINVAL;
+                goto sensor_ioctl_end;
+            }
+            /* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control 
+               for this project */
+            #if CONFIG_SENSOR_Flash    
+               if (sensor->sensor_gpio_res) { 
+                if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
+                    for (i = 0; i < icd->ops->num_controls; i++) {
+                               if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
+                                       memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));                                       
+                               }
+                    }
+                    sensor->info_priv.flash = 0xff;
+                    SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+                }
+               }
+            #endif
                        break;
                }
                default:
@@ -3935,8 +3994,8 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                        break;
                }
        }
-
-       return 0;
+sensor_ioctl_end:
+       return ret;
 
 }
 
index 27cba5dd00f1af522740af81505833c6be236d0b..44e24fa298f8a5ca133de0274f046d695fecaea4 100755 (executable)
@@ -1481,10 +1481,13 @@ static int sensor_task_lock(struct i2c_client *client, int lock)
                                preempt_enable();
                }
        }
-#endif
        return 0;
 sensor_task_lock_err:
        return -1;
+#else
+    return 0;
+#endif
+
 }
 
 /* sensor register write */
@@ -1568,7 +1571,9 @@ static int sensor_write_array(struct i2c_client *client, struct reginfo *regarra
 {
     int err = 0, cnt;
     int i = 0;
+#if CONFIG_SENSOR_I2C_RDWRCHK    
        char valchk;
+#endif
 
        cnt = 0;
        if (sensor_task_lock(client, 1) < 0)
@@ -2377,12 +2382,8 @@ static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4
 }
 #endif
 #if CONFIG_SENSOR_Flash
-static int sensor_set_flash(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;
-    
+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 */
index 8a17e2395dc4e12edf648bfccc734efe57a69a12..54b6a1b9bc4c7c0106fba95c4ede32b19d50374f 100755 (executable)
@@ -1290,10 +1290,13 @@ static int sensor_task_lock(struct i2c_client *client, int lock)
                                preempt_enable();
                }
        }
-#endif
        return 0;
 sensor_task_lock_err:
-       return -1;
+       return -1;  
+#else
+    return 0;
+#endif
+
 }
 
 /* sensor register write */
@@ -1377,7 +1380,9 @@ static int sensor_write_array(struct i2c_client *client, struct reginfo *regarra
 {
     int err = 0, cnt;
     int i = 0;
+#if CONFIG_SENSOR_I2C_RDWRCHK    
        char valchk;
+#endif
 
        cnt = 0;
        if (sensor_task_lock(client, 1) < 0)
@@ -1411,6 +1416,7 @@ sensor_write_array_end:
        sensor_task_lock(client,0);
        return err;
 }
+#if CONFIG_SENSOR_I2C_RDWRCHK
 static int sensor_readchk_array(struct i2c_client *client, struct reginfo *regarray)
 {
     int cnt;
@@ -1429,6 +1435,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);
@@ -2195,12 +2202,8 @@ static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4
 }
 #endif
 #if CONFIG_SENSOR_Flash
-static int sensor_set_flash(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;
-    
+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 */
@@ -2716,11 +2719,11 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
             /* 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) { 
                 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->info_priv.flash = 0xff;
@@ -2803,10 +2806,11 @@ static int sensor_probe(struct i2c_client *client,
        #endif
 
     ret = sensor_video_probe(icd, client);
-    if (ret) {
+    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;
@@ -2821,7 +2825,7 @@ static int sensor_remove(struct i2c_client *client)
     i2c_set_clientdata(client, NULL);
     client->driver = NULL;
     kfree(sensor);
-
+       sensor = NULL;
     return 0;
 }
 
index e35300284e51313615b6b4c1d57a55a7bb0f5424..ad833df714ceb462696283d93e36de41c59012ed 100755 (executable)
@@ -1419,10 +1419,13 @@ static int sensor_task_lock(struct i2c_client *client, int lock)
                                preempt_enable();
                }
        }
-#endif
        return 0;
 sensor_task_lock_err:
-       return -1;
+       return -1;   
+#else
+    return 0;
+#endif
+
 }
 
 /* sensor register write */
@@ -1858,7 +1861,10 @@ static int sensor_af_wq_function(struct i2c_client *client)
                                break;
                        }
                        default:
+            {
                                SENSOR_DG("%s focus mode(0x%x) is unkonwn\n",SENSOR_NAME_STRING(),sensor->info_priv.auto_focus);
+                goto sensor_af_wq_function_end;
+                       }
                }
 
                SENSOR_DG("%s sensor_af_wq_function set focus mode(0x%x) ret:0x%x\n",SENSOR_NAME_STRING(), sensor->info_priv.auto_focus,ret);
@@ -1873,7 +1879,6 @@ static void sensor_af_workqueue(struct work_struct *work)
 {
        struct sensor_work *sensor_work = container_of(work, struct sensor_work, dwork.work);
        struct i2c_client *client = sensor_work->client;
-       struct sensor *sensor = to_sensor(client);
 
        if (sensor_af_wq_function(client) < 0) {
                SENSOR_TR("%s af workqueue return false\n",SENSOR_NAME_STRING());
@@ -2951,19 +2956,15 @@ static int sensor_set_focus_mode(struct soc_camera_device *icd, const struct v4l
 }
 #endif
 #if CONFIG_SENSOR_Flash
-static int sensor_set_flash(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;
-    
+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);
+        SENSOR_DG("%s..%s : %d\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
         return 0;
     }
     
@@ -3541,10 +3542,11 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                for this project */
             #if CONFIG_SENSOR_Flash    
                if (sensor->sensor_gpio_res) {
+                printk("flash io:%d\n",sensor->sensor_gpio_res->gpio_flash);
                 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->info_priv.flash = 0xff;
@@ -3629,7 +3631,7 @@ static int sensor_probe(struct i2c_client *client,
        #endif
 
     ret = sensor_video_probe(icd, client);
-    if (ret) {
+    if (ret < 0) {
         icd->ops = NULL;
         i2c_set_clientdata(client, NULL);
         kfree(sensor);
index f0c78e9b195d8d0fe28a630a4b876006a733d093..7217f4c4c526bae48088ec502092e73bc442aa13 100755 (executable)
@@ -3328,7 +3328,7 @@ struct sensor
        struct mutex wq_lock;
     int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
 #if CONFIG_SENSOR_I2C_NOSCHED
-       atomic_t tasklock_cnt;
+       atomic_t tasklock_cnt; 
 #endif
        struct rk29camera_platform_data *sensor_io_request;
     struct rk29camera_gpio_res *sensor_gpio_res;
@@ -3368,10 +3368,13 @@ static int sensor_task_lock(struct i2c_client *client, int lock)
                                preempt_enable();
                }
        }
-#endif
        return 0;
 sensor_task_lock_err:
-       return -1;
+       return -1;   
+#else
+    return 0;
+#endif
+
 }
 
 /* sensor register write */
@@ -3807,7 +3810,10 @@ static int sensor_af_wq_function(struct i2c_client *client)
                                break;
                        }
                        default:
+            {
                                SENSOR_DG("%s focus mode(0x%x) is unkonwn\n",SENSOR_NAME_STRING(),sensor->info_priv.auto_focus);
+                goto sensor_af_wq_function_end;
+                       }
                }
 
                SENSOR_DG("%s sensor_af_wq_function set focus mode(0x%x) ret:0x%x\n",SENSOR_NAME_STRING(), sensor->info_priv.auto_focus,ret);
@@ -4893,19 +4899,15 @@ static int sensor_set_focus_mode(struct soc_camera_device *icd, const struct v4l
 #endif
 
 #if CONFIG_SENSOR_Flash
-static int sensor_set_flash(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;
-    
+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);
+        SENSOR_DG("%s..%s : %d\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
         return 0;
     }
     
@@ -5497,7 +5499,7 @@ 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->info_priv.flash = 0xff;
index 8aa7aff1710a34e797fb9be92e062578a6334550..c0f06ecac961c2044652128375551b1810503ee1 100755 (executable)
@@ -45,7 +45,7 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 
 /* Sensor Driver Configuration */
 #define SENSOR_NAME RK29_CAM_SENSOR_S5K6AA
-#define SENSOR_V4L2_IDENT V4L2_IDENT_S5K66A
+#define SENSOR_V4L2_IDENT V4L2_IDENT_S5K66A 
 #define SENSOR_ID 0x06aa
 #define SENSOR_ID_REG SEQUENCE_END//0x015a
 #define SENSOR_RESET_REG SEQUENCE_END
@@ -3021,10 +3021,13 @@ static int sensor_task_lock(struct i2c_client *client, int lock)
                                preempt_enable();
                }
        }
-#endif
        return 0;
 sensor_task_lock_err:
        return -1;
+#else
+    return 0;
+#endif
+
 }
 
 /* sensor register write */
@@ -3276,7 +3279,8 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
     struct soc_camera_device *icd = client->dev.platform_data;
     struct sensor *sensor = to_sensor(client);
        const struct v4l2_queryctrl *qctrl;
-    int ret,pid = 0;
+    int ret;
+    u16 pid = 0;
 
     SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
 
@@ -4021,7 +4025,7 @@ static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4
 }
 #endif
 #if CONFIG_SENSOR_Flash
-static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)
+static int sensor_set_flash(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);
@@ -4450,7 +4454,6 @@ static int sensor_s_stream(struct v4l2_subdev *sd, int enable)
                sensor->info_priv.enable = 0;
        }
 
-sensor_s_stream_end:
        return 0;
 }
 /* Interface active, can use i2c. If it fails, it can indeed mean, that
@@ -4520,7 +4523,10 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
        struct i2c_client *client = sd->priv;
     struct soc_camera_device *icd = client->dev.platform_data;
     struct sensor *sensor = to_sensor(client);
-    int ret = 0,i;
+    int ret = 0;
+#if CONFIG_SENSOR_Flash        
+    int i;
+#endif
 
        SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
        switch (cmd)