camera: fix ipp scale error, add support upto 6 sensor detect, version update to...
authorddl <ddl@rock-chips.com>
Wed, 21 Mar 2012 10:34:32 +0000 (18:34 +0800)
committerddl <ddl@rock-chips.com>
Sat, 24 Mar 2012 09:55:41 +0000 (17:55 +0800)
24 files changed:
arch/arm/mach-rk29/board-rk29-ddr3sdk.c
arch/arm/mach-rk29/board-rk29-k97.c
arch/arm/mach-rk29/include/mach/rk29_camera.h
drivers/media/video/Kconfig
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/mt9d112.c
drivers/media/video/mt9d113.c
drivers/media/video/mt9p111.c
drivers/media/video/mt9t111.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/rk29_camera.c
drivers/media/video/rk29_camera_oneframe.c
drivers/media/video/sid130B.c
drivers/media/video/siv120b.c
drivers/media/video/soc_camera.c

index 1efc7f82f460fe4a0e7e21af18b9ff5cf8439fed..e2aa684824d9bca77799b1c3be41bb4a20f585c4 100755 (executable)
@@ -69,7 +69,7 @@
 #ifdef CONFIG_VIDEO_RK29
 /*---------------- Camera Sensor Macro Define Begin  ------------------------*/
 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
-#define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642                      /* back camera sensor */
+#define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642                      /* back camera sensor */
 #define CONFIG_SENSOR_IIC_ADDR_0           0x78
 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0    1
 #define CONFIG_SENSOR_ORIENTATION_0       90
@@ -83,6 +83,7 @@
 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
 
 #define CONFIG_SENSOR_QCIF_FPS_FIXED_0      15000
+#define CONFIG_SENSOR_240X160_FPS_FIXED_0   15000
 #define CONFIG_SENSOR_QVGA_FPS_FIXED_0      15000
 #define CONFIG_SENSOR_CIF_FPS_FIXED_0       15000
 #define CONFIG_SENSOR_VGA_FPS_FIXED_0       15000
 #define CONFIG_SENSOR_SVGA_FPS_FIXED_0      15000
 #define CONFIG_SENSOR_720P_FPS_FIXED_0      30000
 
-#define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659                      /* front camera sensor */
+#define CONFIG_SENSOR_01  RK29_CAM_SENSOR_OV5642                   /* back camera sensor 1 */
+#define CONFIG_SENSOR_IIC_ADDR_01          0x00
+#define CONFIG_SENSOR_IIC_ADAPTER_ID_01    1
+#define CONFIG_SENSOR_ORIENTATION_01       90
+#define CONFIG_SENSOR_POWER_PIN_01         INVALID_GPIO
+#define CONFIG_SENSOR_RESET_PIN_01         INVALID_GPIO
+#define CONFIG_SENSOR_POWERDN_PIN_01       RK29_PIN6_PB7
+#define CONFIG_SENSOR_FALSH_PIN_01         INVALID_GPIO
+#define CONFIG_SENSOR_POWERACTIVE_LEVEL_01 RK29_CAM_POWERACTIVE_L
+#define CONFIG_SENSOR_RESETACTIVE_LEVEL_01 RK29_CAM_RESETACTIVE_L
+#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_01 RK29_CAM_POWERDNACTIVE_H
+#define CONFIG_SENSOR_FLASHACTIVE_LEVEL_01 RK29_CAM_FLASHACTIVE_L
+
+#define CONFIG_SENSOR_QCIF_FPS_FIXED_01      15000
+#define CONFIG_SENSOR_240X160_FPS_FIXED_01   15000
+#define CONFIG_SENSOR_QVGA_FPS_FIXED_01      15000
+#define CONFIG_SENSOR_CIF_FPS_FIXED_01       15000
+#define CONFIG_SENSOR_VGA_FPS_FIXED_01       15000
+#define CONFIG_SENSOR_480P_FPS_FIXED_01      15000
+#define CONFIG_SENSOR_SVGA_FPS_FIXED_01      15000
+#define CONFIG_SENSOR_720P_FPS_FIXED_01     30000
+
+#define CONFIG_SENSOR_02 RK29_CAM_SENSOR_OV5640                      /* back camera sensor 2 */
+#define CONFIG_SENSOR_IIC_ADDR_02          0x00
+#define CONFIG_SENSOR_IIC_ADAPTER_ID_02    1
+#define CONFIG_SENSOR_ORIENTATION_02       90
+#define CONFIG_SENSOR_POWER_PIN_02         INVALID_GPIO
+#define CONFIG_SENSOR_RESET_PIN_02         INVALID_GPIO
+#define CONFIG_SENSOR_POWERDN_PIN_02       RK29_PIN6_PB7
+#define CONFIG_SENSOR_FALSH_PIN_02         INVALID_GPIO
+#define CONFIG_SENSOR_POWERACTIVE_LEVEL_02 RK29_CAM_POWERACTIVE_L
+#define CONFIG_SENSOR_RESETACTIVE_LEVEL_02 RK29_CAM_RESETACTIVE_L
+#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_02 RK29_CAM_POWERDNACTIVE_H
+#define CONFIG_SENSOR_FLASHACTIVE_LEVEL_02 RK29_CAM_FLASHACTIVE_L
+
+#define CONFIG_SENSOR_QCIF_FPS_FIXED_02      15000
+#define CONFIG_SENSOR_240X160_FPS_FIXED_02   15000
+#define CONFIG_SENSOR_QVGA_FPS_FIXED_02      15000
+#define CONFIG_SENSOR_CIF_FPS_FIXED_02       15000
+#define CONFIG_SENSOR_VGA_FPS_FIXED_02       15000
+#define CONFIG_SENSOR_480P_FPS_FIXED_02      15000
+#define CONFIG_SENSOR_SVGA_FPS_FIXED_02      15000
+#define CONFIG_SENSOR_720P_FPS_FIXED_02      30000
+
+#define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659                      /* front camera sensor 0 */
 #define CONFIG_SENSOR_IIC_ADDR_1           0x60
 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    1
 #define CONFIG_SENSOR_ORIENTATION_1       270
 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
 
 #define CONFIG_SENSOR_QCIF_FPS_FIXED_1      15000
+#define CONFIG_SENSOR_240X160_FPS_FIXED_1   15000
 #define CONFIG_SENSOR_QVGA_FPS_FIXED_1      15000
 #define CONFIG_SENSOR_CIF_FPS_FIXED_1       15000
 #define CONFIG_SENSOR_VGA_FPS_FIXED_1       15000
 #define CONFIG_SENSOR_SVGA_FPS_FIXED_1      15000
 #define CONFIG_SENSOR_720P_FPS_FIXED_1      30000
 
+#define CONFIG_SENSOR_11 RK29_CAM_SENSOR_OV2659                      /* front camera sensor 1 */
+#define CONFIG_SENSOR_IIC_ADDR_11          0x00
+#define CONFIG_SENSOR_IIC_ADAPTER_ID_11    1
+#define CONFIG_SENSOR_ORIENTATION_11       270
+#define CONFIG_SENSOR_POWER_PIN_11         INVALID_GPIO
+#define CONFIG_SENSOR_RESET_PIN_11         INVALID_GPIO
+#define CONFIG_SENSOR_POWERDN_PIN_11       RK29_PIN5_PD7
+#define CONFIG_SENSOR_FALSH_PIN_11         INVALID_GPIO
+#define CONFIG_SENSOR_POWERACTIVE_LEVEL_11 RK29_CAM_POWERACTIVE_L
+#define CONFIG_SENSOR_RESETACTIVE_LEVEL_11 RK29_CAM_RESETACTIVE_L
+#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_11 RK29_CAM_POWERDNACTIVE_H
+#define CONFIG_SENSOR_FLASHACTIVE_LEVEL_11 RK29_CAM_FLASHACTIVE_L
+
+#define CONFIG_SENSOR_QCIF_FPS_FIXED_11      15000
+#define CONFIG_SENSOR_240X160_FPS_FIXED_11   15000
+#define CONFIG_SENSOR_QVGA_FPS_FIXED_11      15000
+#define CONFIG_SENSOR_CIF_FPS_FIXED_11       15000
+#define CONFIG_SENSOR_VGA_FPS_FIXED_11       15000
+#define CONFIG_SENSOR_480P_FPS_FIXED_11      15000
+#define CONFIG_SENSOR_SVGA_FPS_FIXED_11      15000
+#define CONFIG_SENSOR_720P_FPS_FIXED_11      30000
+
+#define CONFIG_SENSOR_12 RK29_CAM_SENSOR_OV2655                      /* front camera sensor 2 */
+#define CONFIG_SENSOR_IIC_ADDR_12          0x00
+#define CONFIG_SENSOR_IIC_ADAPTER_ID_12    1
+#define CONFIG_SENSOR_ORIENTATION_12       270
+#define CONFIG_SENSOR_POWER_PIN_12         INVALID_GPIO
+#define CONFIG_SENSOR_RESET_PIN_12         INVALID_GPIO
+#define CONFIG_SENSOR_POWERDN_PIN_12       RK29_PIN5_PD7
+#define CONFIG_SENSOR_FALSH_PIN_12         INVALID_GPIO
+#define CONFIG_SENSOR_POWERACTIVE_LEVEL_12 RK29_CAM_POWERACTIVE_L
+#define CONFIG_SENSOR_RESETACTIVE_LEVEL_12 RK29_CAM_RESETACTIVE_L
+#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_12 RK29_CAM_POWERDNACTIVE_H
+#define CONFIG_SENSOR_FLASHACTIVE_LEVEL_12 RK29_CAM_FLASHACTIVE_L
+
+#define CONFIG_SENSOR_QCIF_FPS_FIXED_12      15000
+#define CONFIG_SENSOR_240X160_FPS_FIXED_12   15000
+#define CONFIG_SENSOR_QVGA_FPS_FIXED_12      15000
+#define CONFIG_SENSOR_CIF_FPS_FIXED_12       15000
+#define CONFIG_SENSOR_VGA_FPS_FIXED_12       15000
+#define CONFIG_SENSOR_480P_FPS_FIXED_12      15000
+#define CONFIG_SENSOR_SVGA_FPS_FIXED_12      15000
+#define CONFIG_SENSOR_720P_FPS_FIXED_12      30000
+
+
 #endif  //#ifdef CONFIG_VIDEO_RK29
 /*---------------- Camera Sensor Configuration Macro End------------------------*/
 #include "../../../drivers/media/video/rk29_camera.c"
@@ -2724,8 +2815,34 @@ static struct platform_device *devices[] __initdata = {
        #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
        &rk29_soc_camera_pdrv_0,
        #endif
+    #if (CONFIG_SENSOR_IIC_ADDR_1 != 0x00)
        &rk29_soc_camera_pdrv_1,
+       #endif
+    #ifdef CONFIG_SENSOR_01
+    #if (CONFIG_SENSOR_IIC_ADDR_01 != 0x00)
+       &rk29_soc_camera_pdrv_01,
+       #endif
+    #endif
+    #ifdef CONFIG_SENSOR_02
+    #if (CONFIG_SENSOR_IIC_ADDR_02 != 0x00)
+       &rk29_soc_camera_pdrv_02,
+       #endif
+    #endif
+    #ifdef CONFIG_SENSOR_11
+    #if (CONFIG_SENSOR_IIC_ADDR_11 != 0x00)
+       &rk29_soc_camera_pdrv_11,
+       #endif
+    #endif
+    #ifdef CONFIG_SENSOR_12
+    #if (CONFIG_SENSOR_IIC_ADDR_12 != 0x00)
+       &rk29_soc_camera_pdrv_12,
+       #endif
+    #endif
+
+    #if (PMEM_CAM_SIZE > 0)
        &android_pmem_cam_device,
+       #endif
+    
 #endif
 #if PMEM_SKYPE_SIZE > 0
        &android_pmem_skype_device,
index bfcc8592346e2f331f8c31c1501f639cedbb2301..619d810b8fcbac267ad513cb88ca1e0b81f9eaa5 100755 (executable)
@@ -85,6 +85,7 @@
 #endif
 
 #define CONFIG_SENSOR_QCIF_FPS_FIXED_0      12504
+#define CONFIG_SENSOR_240X160_FPS_FIXED_0      12504
 #define CONFIG_SENSOR_QVGA_FPS_FIXED_0      12504
 #define CONFIG_SENSOR_CIF_FPS_FIXED_0       12504
 #define CONFIG_SENSOR_VGA_FPS_FIXED_0       12504
 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
 
 #define CONFIG_SENSOR_QCIF_FPS_FIXED_1      12504
+#define CONFIG_SENSOR_240X160_FPS_FIXED_1      12504
 #define CONFIG_SENSOR_QVGA_FPS_FIXED_1      12504
 #define CONFIG_SENSOR_CIF_FPS_FIXED_1       12504
 #define CONFIG_SENSOR_VGA_FPS_FIXED_1       12504
@@ -2781,8 +2783,33 @@ static struct platform_device *devices[] __initdata = {
        #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
        &rk29_soc_camera_pdrv_0,
        #endif
+    #if (CONFIG_SENSOR_IIC_ADDR_1 != 0x00)
        &rk29_soc_camera_pdrv_1,
+       #endif
+    #ifdef CONFIG_SENSOR_01
+    #if (CONFIG_SENSOR_IIC_ADDR_01 != 0x00)
+       &rk29_soc_camera_pdrv_01,
+       #endif
+    #endif
+    #ifdef CONFIG_SENSOR_02
+    #if (CONFIG_SENSOR_IIC_ADDR_02 != 0x00)
+       &rk29_soc_camera_pdrv_02,
+       #endif
+    #endif
+    #ifdef CONFIG_SENSOR_11
+    #if (CONFIG_SENSOR_IIC_ADDR_11 != 0x00)
+       &rk29_soc_camera_pdrv_11,
+       #endif
+    #endif
+    #ifdef CONFIG_SENSOR_12
+    #if (CONFIG_SENSOR_IIC_ADDR_12 != 0x00)
+       &rk29_soc_camera_pdrv_12,
+       #endif
+    #endif
+
+    #if (PMEM_CAM_SIZE > 0)
        &android_pmem_cam_device,
+       #endif
 #endif
 #if PMEM_SKYPE_SIZE > 0
        &android_pmem_skype_device,
index 2d78c35cda2b07528f0395129ed88bc65a7bf587..c1cbc3289921e3989192f5f394a778f0a8363ba9 100755 (executable)
@@ -33,6 +33,8 @@
 #define RK29_CAM_EIO_INVALID -1
 #define RK29_CAM_EIO_REQUESTFAIL -2
 
+#define RK29_CAM_SUPPORT_NUMS   6
+
 /*---------------- Camera Sensor Must Define Macro Begin  ------------------------*/
 #define RK29_CAM_SENSOR_OV7675 ov7675
 #define RK29_CAM_SENSOR_OV9650 ov9650
@@ -183,9 +185,9 @@ struct rk29camera_platform_data {
     int (*io_init)(void);
     int (*io_deinit)(int sensor);
        int (*sensor_ioctrl)(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
-    struct rk29camera_gpio_res gpio_res[2];
+    struct rk29camera_gpio_res gpio_res[RK29_CAM_SUPPORT_NUMS];
        struct rk29camera_mem_res meminfo;
-    struct rk29camera_info info[2];
+    struct rk29camera_info info[RK29_CAM_SUPPORT_NUMS];
 };
 
 struct rk29camera_platform_ioctl_cb {
index 609f968c4039b9e34d89e2cb6ae89afd7a26061b..e4e036d0f9059585092c18e32a086b61f6cfd2d4 100755 (executable)
@@ -1185,6 +1185,19 @@ config VIDEO_RK29_DIGITALZOOM_IPP_OFF
        bool "Digital zoom with IPP off"
 endchoice
 
+choice
+       prompt "RK29XX camera memory "
+       depends on VIDEO_RK29 
+       default VIDEO_RK29_CAMMEM_PMEM
+       ---help---
+               where camera memory which is used for preview/raw/jpeg in android camera hal is alloced 
+config VIDEO_RK29_CAMMEM_PMEM
+       bool "Camera memory from pmem"
+
+config VIDEO_RK29_CAMMEM_ION
+       bool "Camera memory from ion"
+endchoice
+
 config VIDEO_MX2_HOSTSUPPORT
        bool
 
index 38f120d99f4cde2b5db1d806e97ca761b5657d6c..baff822d39d79120bc68893dd3eca9a6cbfdb398 100755 (executable)
@@ -2036,7 +2036,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -2055,6 +2055,52 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
 
+    set_w = mf->width;
+    set_h = mf->height;
+
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg!=0xff)
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg!=0xff)
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg!=0xff)
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg!=0xff)
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg!=0xff)
+    {
+        set_w = 800;
+        set_h = 600;
+    }
+    else if (((set_w <= 1280) && (set_h <= 720)) && sensor_720p[0].reg!=0xff)
+    {
+        set_w = 1280;
+        set_h = 720;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg!=0xff)
+    {
+        set_w = 1280;
+        set_h = 1024;
+    }
+    else
+    {
+        set_w = SENSOR_INIT_WIDTH;
+        set_h = SENSOR_INIT_HEIGHT;
+    }    
+
+    mf->width = set_w;
+    mf->height = set_h;    
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -2824,12 +2870,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index 67669ac38f73fc07cd35cbb57c38a1e82992e298..033f533780dce659c6e126a9ad0fcbaf6aea26da 100755 (executable)
@@ -1883,7 +1883,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -1902,6 +1902,48 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
 
+    set_w = mf->width;
+    set_h = mf->height;
+
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
+    {
+        set_w = 800;
+        set_h = 600;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
+    {
+        set_w = 1280;
+        set_h = 1024;
+    }
+    else
+    {
+        set_w = SENSOR_INIT_WIDTH;
+        set_h = SENSOR_INIT_HEIGHT;            
+    }
+
+    mf->width = set_w;
+    mf->height = set_h; 
+    
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -2666,12 +2708,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index dff2a47c92be31c3a20eb8d31e7fdf53e8b3ed51..0ee641e8c7cf4354f54c8deff4487f5e5ef6ba3e 100755 (executable)
@@ -1837,7 +1837,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -1856,6 +1856,37 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
 
+    set_w = mf->width;
+    set_h = mf->height;
+
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    
+    else
+    {
+        set_w = SENSOR_INIT_WIDTH;
+        set_h = SENSOR_INIT_HEIGHT;
+    }    
+    mf->width = set_w;
+    mf->height = set_h; 
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -2619,12 +2650,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index 4f9e18f7a1b8acf406aec1f51e016fa607bdb25b..b31ed13207be8e77ddb3eead0c1affca6306d630 100755 (executable)
@@ -2040,7 +2040,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -2059,6 +2059,56 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
 
+    set_w = mf->width;
+    set_h = mf->height;
+
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
+    {
+        set_w = 800-32;
+        set_h = 600;
+    }
+       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
+    {          
+        set_w = 1024;
+        set_h = 768;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
+    {    
+        set_w = 1280;
+        set_h = 1024;
+    }
+    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
+    {
+        set_w = 1600-32;
+        set_h = 1200;
+    }
+    else
+    {
+        set_w = SENSOR_INIT_WIDTH;
+        set_h = SENSOR_INIT_HEIGHT;    
+    }
+    mf->width = set_w;
+    mf->height = set_h;     
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -2832,12 +2882,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index 607be6ed8a7408da4e04cda24c1406e1c1678714..6ecc115b6b1fba579aaf24559842fd1efeab3a60 100755 (executable)
@@ -2679,7 +2679,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -2698,6 +2698,52 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
 
+    set_w = mf->width;
+    set_h = mf->height;
+
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
+    {
+        set_w = 800;
+        set_h = 600;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
+    {
+        set_w = 1280;
+        set_h = 1024;
+    }
+    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
+    {
+        set_w = 1600;
+        set_h = 1200;
+    }
+    else
+    {
+        set_w = SENSOR_INIT_WIDTH;
+        set_h = SENSOR_INIT_HEIGHT;
+    }
+
+       mf->width = set_w;
+    mf->height = set_h;
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -3471,12 +3517,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index ce7e3b709e59d6d2f3823a0d94f68476370886e2..997657e0d71e26dfba3d36fdb4cd34608995f235 100755 (executable)
@@ -2185,7 +2185,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -2204,6 +2204,72 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
 
+    set_w = mf->width;
+    set_h = mf->height;
+       if (((set_w <= 176) && (set_h <= 144)) && (sensor_qcif[0].reg!=SEQUENCE_END))
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && (sensor_qvga[0].reg!=SEQUENCE_END))
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && (sensor_cif[0].reg!=SEQUENCE_END))
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && (sensor_vga[0].reg!=SEQUENCE_END))
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && (sensor_svga[0].reg!=SEQUENCE_END))
+    {
+        set_w = 800;
+        set_h = 600;
+    }
+       else if (((set_w <= 1024) && (set_h <= 768)) && (sensor_xga[0].reg!=SEQUENCE_END))
+    {
+        set_w = 1024;
+        set_h = 768;
+    }
+       else if (((set_w <= 1280) && (set_h <= 720)) && (sensor_720p[0].reg!=SEQUENCE_END))
+    {
+        set_w = 1280;
+        set_h = 720;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && (sensor_sxga[0].reg!=SEQUENCE_END))
+    {
+        set_w = 1280;
+        set_h = 1024;
+    }
+    else if (((set_w <= 1600) && (set_h <= 1200)) && (sensor_uxga[0].reg!=SEQUENCE_END))
+    {
+        set_w = 1600;
+        set_h = 1200;
+    }
+    else if (((set_w <= 1920) && (set_h <= 1080)) && (sensor_1080p[0].reg!=SEQUENCE_END))
+    {
+        set_w = 1920;
+        set_h = 1080;
+    }
+       else if (((set_w <= 2048) && (set_h <= 1536)) && (sensor_qxga[0].reg!=SEQUENCE_END))
+    {
+        set_w = 2048;
+        set_h = 1536;
+    }
+       else if (((set_w <= 2592) && (set_h <= 1944)) && (sensor_qsxga[0].reg!=SEQUENCE_END))
+    {
+        set_w = 2592;
+        set_h = 1944;
+    }
+
+       mf->width = set_w;
+       mf->height = set_h;
+    
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -3119,14 +3185,19 @@ 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];
+                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__);
index 66f9c8ff8f37065d6e4b39320556ac0e2ee32908..191482da4d28609012dd7b7ee26ef02de312faf6 100755 (executable)
@@ -2935,12 +2935,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index d651882943793139a0c297fcad428b56458291d3..b5bf570adf797343c93987d16bec09f6d1d4265c 100644 (file)
@@ -3702,7 +3702,10 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
         mf->width = SENSOR_MAX_WIDTH;
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
-
+    if (sensor_fmt_catch(mf->width, mf->height, &mf->width, &mf->height) == NULL) {
+               mf->width = 0;
+               mf->height = 0;
+       }
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -4640,12 +4643,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index 63cfb5fb4378065adab3ad9e08d7eac545e6eebb..ce2575e0f327ebb9e805090bab00699d6555a074 100755 (executable)
@@ -8268,12 +8268,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index d6b1e385668afb520540d717ddcef61c890811f8..d964b6d0e4aa6c7e2a7413503edab59b149a4cff 100755 (executable)
@@ -1998,7 +1998,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;\r
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -2016,7 +2016,59 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
         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)
+       {
+        set_w = 176;\r
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+    {
+        set_w = 320;\r
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+    {
+        set_w = 352;\r
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+    {
+        set_w = 640;\r
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
+    {
+        set_w = 800;\r
+        set_h = 600;
+    }
+       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
+    {
+        set_w = 1024;\r
+        set_h = 768;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
+    {
+        set_w = 1280;\r
+        set_h = 1024;
+    }
+    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
+    {
+        set_w = 1600;\r
+        set_h = 1200;
+    }
+    else
+    {
+        set_w = SENSOR_INIT_WIDTH;\r
+        set_h = SENSOR_INIT_HEIGHT;
+    }\r
 
+    mf->width = set_w;
+    mf->height = set_h;\r
+\r
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -2785,20 +2837,25 @@ 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;           \r
             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];
+                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;
-            }
+            }\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    
index 7f7434f52f4377a58c508eaf880f38f7420be0aa..bca088c1c4ac39e4b51aeff9746ecacb2e22ee36 100755 (executable)
@@ -2129,7 +2129,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -2148,6 +2148,52 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
 
+    set_w = mf->width;
+    set_h = mf->height;
+
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
+    {
+        set_w = 800;
+        set_h = 600;
+    }
+       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
+    {
+        set_w = 1024;
+        set_h = 768;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
+    {
+        set_w = 1280;
+        set_h = 1024;
+    }
+    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
+    {
+        set_w = 1600;
+        set_h = 1200;
+    }
+
+    mf->width = set_w;
+    mf->height = set_h;
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -2915,14 +2961,19 @@ 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];
+                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__);
index 85f5c20e7b8f7b6df49ca9232de3e3f1601c839a..b1830bb9fe684507d01fe993dd6203a284e8ea89 100755 (executable)
@@ -1950,7 +1950,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -1969,6 +1969,62 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
 
+    set_w = mf->width;
+    set_h = mf->height;
+
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
+    {
+        set_w = 800;
+        set_h = 600;
+    }
+    else if (((set_w <= 1280) && (set_h <= 720)) && sensor_720p[0].reg)
+    {
+        set_w = 1280;
+        set_h = 720;
+    }
+       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
+    {
+        set_w = 1024;
+        set_h = 768;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
+    {
+        set_w = 1280;
+        set_h = 1024;
+    }
+    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
+    {
+        set_w = 1600;
+        set_h = 1200;
+    }
+    else
+    {              /* ddl@rock-chips.com : Sensor output smallest size if  isn't support app  */
+        set_w = SENSOR_INIT_WIDTH;
+        set_h = SENSOR_INIT_HEIGHT;            
+    }
+
+    mf->width = set_w;
+    mf->height = set_h;
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -2775,12 +2831,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index 055ab274d045aa503cca05530efce7d35f8ee703..f1cf415c6fe86b01595e508daf50db9d98313453 100755 (executable)
@@ -3786,14 +3786,19 @@ 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];
+                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__);
index 98816754ee17943f901d815ff6b3baa6d064d3bf..bfb407176b81850738fa064fee645f3877970506 100755 (executable)
@@ -4742,7 +4742,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -4761,6 +4761,78 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
 
+    set_w = mf->width;
+    set_h = mf->height;
+
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
+    {
+        set_w = 800;
+        set_h = 600;
+    }
+       else if (((set_w <= 1024) && (set_h <= 768)) && sensor_xga[0].reg)
+    {
+        set_w = 1024;
+        set_h = 768;
+    }
+       else if (((set_w <= 1280) && (set_h <= 720)) && sensor_720p[0].reg)
+    {
+        set_w = 1280;
+        set_h = 720;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
+    {
+        set_w = 1280;
+        set_h = 1024;
+    }
+    else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
+    {
+        set_w = 1600;
+        set_h = 1200;
+    }
+    else if (((set_w <= 1920) && (set_h <= 1080)) && sensor_1080p[0].reg)
+    {
+        set_w = 1920;
+        set_h = 1080;
+    }
+       else if (((set_w <= 2048) && (set_h <= 1536)) && sensor_qxga[0].reg)
+    {
+        set_w = 2048;
+        set_h = 1536;
+    }
+       else if (((set_w <= 2592) && (set_h <= 1944)) && sensor_qsxga[0].reg)
+    {
+        set_w = 2592;
+        set_h = 1944;
+    }
+    else
+    {
+        set_w = SENSOR_INIT_WIDTH;
+        set_h = SENSOR_INIT_HEIGHT;
+    }
+
+    mf->width = set_w;
+    mf->height = set_h;
+    
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -5702,16 +5774,20 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
                        break;
                }
                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];          
+                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__);
index 03d19f88929f40de48bccb94fbcde3a71b144484..a94b2d1f8da45f11d6b5eb867e841242c914ad9c 100755 (executable)
@@ -1792,7 +1792,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -1810,7 +1810,48 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
         mf->width = SENSOR_MAX_WIDTH;
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
+    
+    set_w = mf->width;
+    set_h = mf->height;
 
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
+    {
+        set_w = 800;
+        set_h = 600;
+    }
+    else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
+    {
+        set_w = 1280;
+        set_h = 1024;
+    }
+    else
+    {
+        set_w = SENSOR_INIT_WIDTH;
+        set_h = SENSOR_INIT_HEIGHT;            
+    }
+
+    mf->width = set_w;
+    mf->height = set_h;
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -2571,12 +2612,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index 13ee3a968c8cfaae3a03965f063bb5472a2bd5bd..91ff7836ebc8243c568439ca5880d0e67667b075 100755 (executable)
 #define PMEM_CAM_NECESSARY   0x1200000\r
 #define PMEM_CAMIPP_NECESSARY    0x800000\r
 #endif\r
+\r
+#if CONFIG_VIDEO_RK29_CAMMEM_ION\r
+#undef PMEM_CAM_NECESSARY\r
+#define PMEM_CAM_NECESSARY   0x00000000\r
+#endif\r
+\r
 /*---------------- Camera Sensor Fixed Macro End  ------------------------*/\r
 #else   //#ifdef CONFIG_VIDEO_RK29 \r
 #define PMEM_CAM_NECESSARY   0x00000000\r
@@ -68,7 +74,7 @@
  *****************************************************************************************/\r
 #ifdef CONFIG_VIDEO_RK29 \r
 static int camera_debug;\r
-module_param(camera_debug, int, S_IRUGO|S_IWUSR);\r
+module_param(camera_debug, int, S_IRUGO|S_IWUSR|S_IWGRP);\r
 \r
 #define ddprintk(level, fmt, arg...) do {                      \\r
        if (camera_debug >= level)                                      \\r
@@ -76,10 +82,27 @@ module_param(camera_debug, int, S_IRUGO|S_IWUSR);
 \r
 #define dprintk(format, ...) ddprintk(1, format, ## __VA_ARGS__)    \r
 \r
-#define SENSOR_NAME_0 STR(CONFIG_SENSOR_0)                     /* back camera sensor */\r
-#define SENSOR_NAME_1 STR(CONFIG_SENSOR_1)                     /* front camera sensor */\r
+#define SENSOR_NAME_0 STR(CONFIG_SENSOR_0)                     /* back camera sensor 0 */\r
 #define SENSOR_DEVICE_NAME_0  STR(CONS(CONFIG_SENSOR_0, _back))\r
+#ifdef CONFIG_SENSOR_01\r
+#define SENSOR_NAME_01 STR(CONFIG_SENSOR_01)                   /* back camera sensor 1 */\r
+#define SENSOR_DEVICE_NAME_01  STR(CONS(CONFIG_SENSOR_01, _back_1))\r
+#endif\r
+#ifdef CONFIG_SENSOR_02\r
+#define SENSOR_NAME_02 STR(CONFIG_SENSOR_02)                   /* back camera sensor 2 */\r
+#define SENSOR_DEVICE_NAME_02  STR(CONS(CONFIG_SENSOR_02, _back_2))\r
+#endif\r
+#define SENSOR_NAME_1 STR(CONFIG_SENSOR_1)                     /* front camera sensor 0 */\r
 #define SENSOR_DEVICE_NAME_1  STR(CONS(CONFIG_SENSOR_1, _front))\r
+#ifdef CONFIG_SENSOR_11\r
+#define SENSOR_NAME_11 STR(CONFIG_SENSOR_11)                   /* front camera sensor 1 */\r
+#define SENSOR_DEVICE_NAME_11  STR(CONS(CONFIG_SENSOR_11, _front_1))\r
+#endif\r
+#ifdef CONFIG_SENSOR_12\r
+#define SENSOR_NAME_12 STR(CONFIG_SENSOR_12)                   /* front camera sensor 2 */\r
+#define SENSOR_DEVICE_NAME_12  STR(CONS(CONFIG_SENSOR_12, _front_2))\r
+#endif\r
+\r
 \r
 static int rk29_sensor_io_init(void);\r
 static int rk29_sensor_io_deinit(int sensor);\r
@@ -97,7 +120,43 @@ static struct rk29camera_platform_data rk29_camera_platform_data = {
             .gpio_flash = CONFIG_SENSOR_FALSH_PIN_0,\r
             .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_0|CONFIG_SENSOR_RESETACTIVE_LEVEL_0|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0|CONFIG_SENSOR_FLASHACTIVE_LEVEL_0),\r
             .gpio_init = 0,            \r
-            .dev_name = SENSOR_DEVICE_NAME_0,\r
+            .dev_name = SENSOR_DEVICE_NAME_0,        \r
+        }, {\r
+        #ifdef CONFIG_SENSOR_01\r
+            .gpio_reset = CONFIG_SENSOR_RESET_PIN_01,\r
+            .gpio_power = CONFIG_SENSOR_POWER_PIN_01,\r
+            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_01,\r
+            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_01,\r
+            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_01|CONFIG_SENSOR_RESETACTIVE_LEVEL_01|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_01|CONFIG_SENSOR_FLASHACTIVE_LEVEL_01),\r
+            .gpio_init = 0,            \r
+            .dev_name = SENSOR_DEVICE_NAME_01,\r
+        #else\r
+            .gpio_reset = INVALID_GPIO,\r
+            .gpio_power = INVALID_GPIO,\r
+            .gpio_powerdown = INVALID_GPIO,\r
+            .gpio_flash = INVALID_GPIO,\r
+            .gpio_flag = 0,\r
+            .gpio_init = 0,            \r
+            .dev_name = NULL,\r
+        #endif\r
+        }, {\r
+        #ifdef CONFIG_SENSOR_02\r
+            .gpio_reset = CONFIG_SENSOR_RESET_PIN_02,\r
+            .gpio_power = CONFIG_SENSOR_POWER_PIN_02,\r
+            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_02,\r
+            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_02,\r
+            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_02|CONFIG_SENSOR_RESETACTIVE_LEVEL_02|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_02|CONFIG_SENSOR_FLASHACTIVE_LEVEL_02),\r
+            .gpio_init = 0,            \r
+            .dev_name = SENSOR_DEVICE_NAME_02, \r
+        #else\r
+            .gpio_reset = INVALID_GPIO,\r
+            .gpio_power = INVALID_GPIO,\r
+            .gpio_powerdown = INVALID_GPIO,\r
+            .gpio_flash = INVALID_GPIO,\r
+            .gpio_flag = 0,\r
+            .gpio_init = 0,            \r
+            .dev_name = NULL,\r
+        #endif\r
         }, {\r
             .gpio_reset = CONFIG_SENSOR_RESET_PIN_1,\r
             .gpio_power = CONFIG_SENSOR_POWER_PIN_1,\r
@@ -106,6 +165,42 @@ static struct rk29camera_platform_data rk29_camera_platform_data = {
             .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_1|CONFIG_SENSOR_RESETACTIVE_LEVEL_1|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1|CONFIG_SENSOR_FLASHACTIVE_LEVEL_1),\r
             .gpio_init = 0,\r
             .dev_name = SENSOR_DEVICE_NAME_1,\r
+        },{\r
+        #ifdef CONFIG_SENSOR_11\r
+            .gpio_reset = CONFIG_SENSOR_RESET_PIN_11,\r
+            .gpio_power = CONFIG_SENSOR_POWER_PIN_11,\r
+            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_11,\r
+            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_11,\r
+            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_11|CONFIG_SENSOR_RESETACTIVE_LEVEL_11|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_11|CONFIG_SENSOR_FLASHACTIVE_LEVEL_11),\r
+            .gpio_init = 0,\r
+            .dev_name = SENSOR_DEVICE_NAME_11,\r
+        #else\r
+            .gpio_reset = INVALID_GPIO,\r
+            .gpio_power = INVALID_GPIO,\r
+            .gpio_powerdown = INVALID_GPIO,\r
+            .gpio_flash = INVALID_GPIO,\r
+            .gpio_flag = 0,\r
+            .gpio_init = 0,            \r
+            .dev_name = NULL,\r
+        #endif        \r
+        }, {\r
+        #ifdef CONFIG_SENSOR_12\r
+            .gpio_reset = CONFIG_SENSOR_RESET_PIN_12,\r
+            .gpio_power = CONFIG_SENSOR_POWER_PIN_12,\r
+            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_12,\r
+            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_12,\r
+            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_12|CONFIG_SENSOR_RESETACTIVE_LEVEL_12|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_12|CONFIG_SENSOR_FLASHACTIVE_LEVEL_12),\r
+            .gpio_init = 0,\r
+            .dev_name = SENSOR_DEVICE_NAME_12,\r
+        #else\r
+            .gpio_reset = INVALID_GPIO,\r
+            .gpio_power = INVALID_GPIO,\r
+            .gpio_powerdown = INVALID_GPIO,\r
+            .gpio_flash = INVALID_GPIO,\r
+            .gpio_flag = 0,\r
+            .gpio_init = 0,            \r
+            .dev_name = NULL,\r
+        #endif\r
         }\r
     },\r
        #ifdef CONFIG_VIDEO_RK29_WORK_IPP\r
@@ -118,11 +213,47 @@ static struct rk29camera_platform_data rk29_camera_platform_data = {
     .info = {\r
         {\r
             .dev_name = SENSOR_DEVICE_NAME_0,\r
-            .orientation = CONFIG_SENSOR_ORIENTATION_0, \r
+            .orientation = CONFIG_SENSOR_ORIENTATION_0,  \r
+        #ifdef CONFIG_SENSOR_01\r
+           },{\r
+               .dev_name = SENSOR_DEVICE_NAME_01,\r
+            .orientation = CONFIG_SENSOR_ORIENTATION_01, \r
+        #else\r
+        },{\r
+               .dev_name = NULL,\r
+            .orientation = 0x00, \r
+        #endif\r
+        #ifdef CONFIG_SENSOR_02\r
            },{\r
+               .dev_name = SENSOR_DEVICE_NAME_02,\r
+            .orientation = CONFIG_SENSOR_ORIENTATION_02, \r
+        #else\r
+        },{\r
+               .dev_name = NULL,\r
+            .orientation = 0x00, \r
+        #endif\r
+        },{\r
             .dev_name = SENSOR_DEVICE_NAME_1,\r
             .orientation = CONFIG_SENSOR_ORIENTATION_1,\r
-        }\r
+        #ifdef CONFIG_SENSOR_11 \r
+        },{\r
+            .dev_name = SENSOR_DEVICE_NAME_11,\r
+            .orientation = CONFIG_SENSOR_ORIENTATION_11, \r
+        #else\r
+        },{\r
+               .dev_name = NULL,\r
+            .orientation = 0x00, \r
+        #endif\r
+        #ifdef CONFIG_SENSOR_12\r
+           },{\r
+               .dev_name = SENSOR_DEVICE_NAME_12,\r
+            .orientation = CONFIG_SENSOR_ORIENTATION_12, \r
+        #else\r
+        },{\r
+               .dev_name = NULL,\r
+            .orientation = 0x00, \r
+        #endif\r
+           }\r
        }\r
 };\r
 \r
@@ -1099,7 +1230,7 @@ static int sensor_power_default_cb (struct rk29camera_gpio_res *res, int on)
     int ret = 0;\r
     \r
     if (camera_power != INVALID_GPIO)  {\r
-                    if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {\r
+               if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {\r
             if (on) {\r
                gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
                        dprintk("%s..%s..PowerPin=%d ..PinLevel = %x   \n",__FUNCTION__,res->dev_name, camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
@@ -1221,7 +1352,149 @@ static int sensor_flash_default_cb (struct rk29camera_gpio_res *res, int on)
     return ret;\r
 }\r
 \r
-\r
+static void rk29_sensor_fps_get(int idx, unsigned int *val, int w, int h)\r
+{\r
+    switch (idx)\r
+    {\r
+        case 0:\r
+        {\r
+            if ((w==176) && (h==144)) {\r
+                *val = CONFIG_SENSOR_QCIF_FPS_FIXED_0;\r
+            #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_0\r
+            } else if ((w==240) && (h==160)) {\r
+                *val = CONFIG_SENSOR_240X160_FPS_FIXED_0;\r
+            #endif\r
+            } else if ((w==320) && (h==240)) {\r
+                *val = CONFIG_SENSOR_QVGA_FPS_FIXED_0;\r
+            } else if ((w==352) && (h==288)) {\r
+                *val = CONFIG_SENSOR_CIF_FPS_FIXED_0;\r
+            } else if ((w==640) && (h==480)) {\r
+                *val = CONFIG_SENSOR_VGA_FPS_FIXED_0;\r
+            } else if ((w==720) && (h==480)) {\r
+                *val = CONFIG_SENSOR_480P_FPS_FIXED_0;\r
+            } else if ((w==1280) && (h==720)) {\r
+                *val = CONFIG_SENSOR_720P_FPS_FIXED_0;\r
+            }\r
+            break;\r
+        }\r
+        #ifdef CONFIG_SENSOR_01\r
+        case 1:\r
+        {\r
+            if ((w==176) && (h==144)) {\r
+                *val = CONFIG_SENSOR_QCIF_FPS_FIXED_01;\r
+            #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_01\r
+            } else if ((w==240) && (h==160)) {\r
+                *val = CONFIG_SENSOR_240X160_FPS_FIXED_01;\r
+            #endif\r
+            } else if ((w==320) && (h==240)) {\r
+                *val = CONFIG_SENSOR_QVGA_FPS_FIXED_01;\r
+            } else if ((w==352) && (h==288)) {\r
+                *val = CONFIG_SENSOR_CIF_FPS_FIXED_01;\r
+            } else if ((w==640) && (h==480)) {\r
+                *val = CONFIG_SENSOR_VGA_FPS_FIXED_01;\r
+            } else if ((w==720) && (h==480)) {\r
+                *val = CONFIG_SENSOR_480P_FPS_FIXED_01;\r
+            } else if ((w==1280) && (h==720)) {\r
+                *val = CONFIG_SENSOR_720P_FPS_FIXED_01;\r
+            }\r
+            break;\r
+        }\r
+        #endif\r
+        #ifdef CONFIG_SENSOR_02\r
+        case 2:\r
+        {\r
+            if ((w==176) && (h==144)) {\r
+                *val = CONFIG_SENSOR_QCIF_FPS_FIXED_02;\r
+            #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_02\r
+            } else if ((w==240) && (h==160)) {\r
+                *val = CONFIG_SENSOR_240X160_FPS_FIXED_02;\r
+            #endif\r
+            } else if ((w==320) && (h==240)) {\r
+                *val = CONFIG_SENSOR_QVGA_FPS_FIXED_02;\r
+            } else if ((w==352) && (h==288)) {\r
+                *val = CONFIG_SENSOR_CIF_FPS_FIXED_02;\r
+            } else if ((w==640) && (h==480)) {\r
+                *val = CONFIG_SENSOR_VGA_FPS_FIXED_02;\r
+            } else if ((w==720) && (h==480)) {\r
+                *val = CONFIG_SENSOR_480P_FPS_FIXED_02;\r
+            } else if ((w==1280) && (h==720)) {\r
+                *val = CONFIG_SENSOR_720P_FPS_FIXED_02;\r
+            }\r
+            break;\r
+        }\r
+        #endif\r
+        \r
+        case 3:\r
+        {\r
+            if ((w==176) && (h==144)) {\r
+                *val = CONFIG_SENSOR_QCIF_FPS_FIXED_1;\r
+            #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_1\r
+            } else if ((w==240) && (h==160)) {\r
+                *val = CONFIG_SENSOR_240X160_FPS_FIXED_1;\r
+            #endif\r
+            } else if ((w==320) && (h==240)) {\r
+                *val = CONFIG_SENSOR_QVGA_FPS_FIXED_1;\r
+            } else if ((w==352) && (h==288)) {\r
+                *val = CONFIG_SENSOR_CIF_FPS_FIXED_1;\r
+            } else if ((w==640) && (h==480)) {\r
+                *val = CONFIG_SENSOR_VGA_FPS_FIXED_1;\r
+            } else if ((w==720) && (h==480)) {\r
+                *val = CONFIG_SENSOR_480P_FPS_FIXED_1;\r
+            } else if ((w==1280) && (h==720)) {\r
+                *val = CONFIG_SENSOR_720P_FPS_FIXED_1;\r
+            }\r
+            break;\r
+        }\r
+        #ifdef CONFIG_SENSOR_11\r
+        case 4:\r
+        {\r
+            if ((w==176) && (h==144)) {\r
+                *val = CONFIG_SENSOR_QCIF_FPS_FIXED_11;\r
+            #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_11\r
+            } else if ((w==240) && (h==160)) {\r
+                *val = CONFIG_SENSOR_240X160_FPS_FIXED_11;\r
+            #endif\r
+            } else if ((w==320) && (h==240)) {\r
+                *val = CONFIG_SENSOR_QVGA_FPS_FIXED_11;\r
+            } else if ((w==352) && (h==288)) {\r
+                *val = CONFIG_SENSOR_CIF_FPS_FIXED_11;\r
+            } else if ((w==640) && (h==480)) {\r
+                *val = CONFIG_SENSOR_VGA_FPS_FIXED_11;\r
+            } else if ((w==720) && (h==480)) {\r
+                *val = CONFIG_SENSOR_480P_FPS_FIXED_11;\r
+            } else if ((w==1280) && (h==720)) {\r
+                *val = CONFIG_SENSOR_720P_FPS_FIXED_11;\r
+            }\r
+            break;\r
+        }\r
+        #endif\r
+        #ifdef CONFIG_SENSOR_12\r
+        case 5:\r
+        {\r
+            if ((w==176) && (h==144)) {\r
+                *val = CONFIG_SENSOR_QCIF_FPS_FIXED_12;\r
+            #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_12\r
+            } else if ((w==240) && (h==160)) {\r
+                *val = CONFIG_SENSOR_240X160_FPS_FIXED_12;\r
+            #endif\r
+            } else if ((w==320) && (h==240)) {\r
+                *val = CONFIG_SENSOR_QVGA_FPS_FIXED_12;\r
+            } else if ((w==352) && (h==288)) {\r
+                *val = CONFIG_SENSOR_CIF_FPS_FIXED_12;\r
+            } else if ((w==640) && (h==480)) {\r
+                *val = CONFIG_SENSOR_VGA_FPS_FIXED_12;\r
+            } else if ((w==720) && (h==480)) {\r
+                *val = CONFIG_SENSOR_480P_FPS_FIXED_12;\r
+            } else if ((w==1280) && (h==720)) {\r
+                *val = CONFIG_SENSOR_720P_FPS_FIXED_12;\r
+            }\r
+            break;\r
+        }\r
+        #endif\r
+        default:\r
+            printk(KERN_ERR"rk29_cam_io: sensor-%d have not been define in board file!",idx);\r
+    }\r
+}\r
 static int rk29_sensor_io_init(void)\r
 {\r
     int ret = 0, i,j;\r
@@ -1238,7 +1511,10 @@ static int rk29_sensor_io_init(void)
     if (sensor_ioctl_cb.sensor_flash_cb == NULL)\r
         sensor_ioctl_cb.sensor_flash_cb = sensor_flash_default_cb;\r
     \r
-    for (i=0; i<2; i++) {\r
+    for (i=0; i<RK29_CAM_SUPPORT_NUMS; i++) {\r
+        if (rk29_camera_platform_data.gpio_res[i].dev_name == NULL)\r
+            continue;\r
+        \r
         camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;\r
         camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;\r
                camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;\r
@@ -1253,7 +1529,11 @@ static int rk29_sensor_io_init(void)
                     printk("%s..%s..power pin(%d) init failed\n",__FUNCTION__,rk29_camera_platform_data.gpio_res[i].dev_name,camera_power);\r
                                    goto sensor_io_int_loop_end;\r
                 } else {\r
-                    if (camera_power != rk29_camera_platform_data.gpio_res[0].gpio_power) {\r
+                    for (j=0; j<i; j++) {\r
+                        if (camera_power == rk29_camera_platform_data.gpio_res[j].gpio_power)\r
+                            break;\r
+                    }\r
+                    if (i==j) {\r
                         printk("%s..%s..power pin(%d) init failed\n",__FUNCTION__,rk29_camera_platform_data.gpio_res[i].dev_name,camera_power);\r
                         goto sensor_io_int_loop_end;\r
                     }\r
@@ -1276,8 +1556,34 @@ static int rk29_sensor_io_init(void)
         if (camera_reset != INVALID_GPIO) {\r
             ret = gpio_request(camera_reset, "camera reset");\r
             if (ret) {\r
-                printk("%s..%s..reset pin(%d) init failed\n",__FUNCTION__,rk29_camera_platform_data.gpio_res[i].dev_name,camera_reset);\r
-                goto sensor_io_int_loop_end;\r
+                if (i==1) {\r
+                    if ((camera_reset == rk29_camera_platform_data.gpio_res[0].gpio_reset) \r
+                        || (camera_reset == rk29_camera_platform_data.gpio_res[2].gpio_reset)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (i==2) {\r
+                    if ((camera_reset == rk29_camera_platform_data.gpio_res[0].gpio_reset) \r
+                        || (camera_reset == rk29_camera_platform_data.gpio_res[1].gpio_reset)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (i==4) {\r
+                    if ((camera_reset == rk29_camera_platform_data.gpio_res[3].gpio_reset) \r
+                        || (camera_reset == rk29_camera_platform_data.gpio_res[5].gpio_reset)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (i==5) {\r
+                    if ((camera_reset == rk29_camera_platform_data.gpio_res[3].gpio_reset) \r
+                        || (camera_reset == rk29_camera_platform_data.gpio_res[4].gpio_reset)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (ret) {\r
+                    printk("%s..%s..reset pin(%d) init failed\n",__FUNCTION__,rk29_camera_platform_data.gpio_res[i].dev_name,camera_reset);\r
+                    goto sensor_io_int_loop_end;\r
+                }\r
             }\r
 \r
             if (rk29_sensor_iomux(camera_reset) < 0) {\r
@@ -1296,8 +1602,34 @@ static int rk29_sensor_io_init(void)
                if (camera_powerdown != INVALID_GPIO) {\r
             ret = gpio_request(camera_powerdown, "camera powerdown");\r
             if (ret) {\r
-                printk("%s..%s..powerdown pin(%d) init failed\n",__FUNCTION__,rk29_camera_platform_data.gpio_res[i].dev_name,camera_powerdown);\r
-                goto sensor_io_int_loop_end;\r
+                if (i==1) {\r
+                    if ((camera_powerdown == rk29_camera_platform_data.gpio_res[0].gpio_powerdown) \r
+                        || (camera_powerdown == rk29_camera_platform_data.gpio_res[2].gpio_powerdown)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (i==2) {\r
+                    if ((camera_powerdown == rk29_camera_platform_data.gpio_res[0].gpio_powerdown) \r
+                        || (camera_powerdown == rk29_camera_platform_data.gpio_res[1].gpio_powerdown)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (i==4) {\r
+                    if ((camera_powerdown == rk29_camera_platform_data.gpio_res[3].gpio_powerdown) \r
+                        || (camera_powerdown == rk29_camera_platform_data.gpio_res[5].gpio_powerdown)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (i==5) {\r
+                    if ((camera_powerdown == rk29_camera_platform_data.gpio_res[3].gpio_powerdown) \r
+                        || (camera_powerdown == rk29_camera_platform_data.gpio_res[4].gpio_powerdown)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (ret) {\r
+                    printk("%s..%s..powerdown pin(%d) init failed\n",__FUNCTION__,rk29_camera_platform_data.gpio_res[i].dev_name,camera_powerdown);\r
+                    goto sensor_io_int_loop_end;\r
+                }\r
             }\r
 \r
             if (rk29_sensor_iomux(camera_powerdown) < 0) {\r
@@ -1316,8 +1648,34 @@ static int rk29_sensor_io_init(void)
                if (camera_flash != INVALID_GPIO) {\r
             ret = gpio_request(camera_flash, "camera flash");\r
             if (ret) {\r
-                printk("%s..%s..flash pin(%d) init failed\n",__FUNCTION__,rk29_camera_platform_data.gpio_res[i].dev_name,camera_flash);\r
-                               goto sensor_io_int_loop_end;\r
+                if (i==1) {\r
+                    if ((camera_flash == rk29_camera_platform_data.gpio_res[0].gpio_flash) \r
+                        || (camera_flash == rk29_camera_platform_data.gpio_res[2].gpio_flash)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (i==2) {\r
+                    if ((camera_flash == rk29_camera_platform_data.gpio_res[0].gpio_flash) \r
+                        || (camera_flash == rk29_camera_platform_data.gpio_res[1].gpio_flash)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (i==4) {\r
+                    if ((camera_flash == rk29_camera_platform_data.gpio_res[3].gpio_flash) \r
+                        || (camera_flash == rk29_camera_platform_data.gpio_res[5].gpio_flash)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (i==5) {\r
+                    if ((camera_flash == rk29_camera_platform_data.gpio_res[3].gpio_flash) \r
+                        || (camera_flash == rk29_camera_platform_data.gpio_res[4].gpio_flash)) {\r
+                        ret = 0;\r
+                    }\r
+                }\r
+                if (ret) {\r
+                    printk("%s..%s..flash pin(%d) init failed\n",__FUNCTION__,rk29_camera_platform_data.gpio_res[i].dev_name,camera_flash);\r
+                               goto sensor_io_int_loop_end;\r
+                }\r
             }\r
 \r
             if (rk29_sensor_iomux(camera_flash) < 0) {\r
@@ -1335,164 +1693,37 @@ static int rk29_sensor_io_init(void)
         \r
         for (j=0; j<10; j++) {\r
             memset(&rk29_camera_platform_data.info[i].fival[j],0x00,sizeof(struct v4l2_frmivalenum));\r
-        }\r
-        j=0;\r
-        if (strstr(rk29_camera_platform_data.info[i].dev_name,"_back")) {\r
-            \r
-            #if CONFIG_SENSOR_QCIF_FPS_FIXED_0\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_QCIF_FPS_FIXED_0;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 176;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 144;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
-\r
-            #if CONFIG_SENSOR_QVGA_FPS_FIXED_0\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_QVGA_FPS_FIXED_0;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 320;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 240;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
-\r
-            #if CONFIG_SENSOR_CIF_FPS_FIXED_0\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_CIF_FPS_FIXED_0;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 352;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 288;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
-\r
-            #if CONFIG_SENSOR_VGA_FPS_FIXED_0\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_VGA_FPS_FIXED_0;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 640;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 480;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
-\r
-            #if CONFIG_SENSOR_480P_FPS_FIXED_0\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_480P_FPS_FIXED_0;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 720;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 480;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif            \r
-\r
-            #if CONFIG_SENSOR_SVGA_FPS_FIXED_0\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_SVGA_FPS_FIXED_0;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 800;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 600;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
 \r
-            #if CONFIG_SENSOR_720P_FPS_FIXED_0\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_720P_FPS_FIXED_0;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 1280;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 720;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
-\r
-        } else {\r
-            #if CONFIG_SENSOR_QCIF_FPS_FIXED_1\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_QCIF_FPS_FIXED_1;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 176;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 144;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
-\r
-            #if CONFIG_SENSOR_QVGA_FPS_FIXED_1\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_QVGA_FPS_FIXED_1;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 320;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 240;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
-\r
-            #if CONFIG_SENSOR_CIF_FPS_FIXED_1\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_CIF_FPS_FIXED_1;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 352;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 288;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
-\r
-            #if CONFIG_SENSOR_VGA_FPS_FIXED_1\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_VGA_FPS_FIXED_1;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 640;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 480;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
-\r
-            #if CONFIG_SENSOR_480P_FPS_FIXED_1\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_480P_FPS_FIXED_1;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 720;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 480;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif \r
-\r
-            #if CONFIG_SENSOR_SVGA_FPS_FIXED_1\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_SVGA_FPS_FIXED_1;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 800;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 600;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
-\r
-            #if CONFIG_SENSOR_720P_FPS_FIXED_1\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.denominator = CONFIG_SENSOR_720P_FPS_FIXED_1;\r
-            rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
-            rk29_camera_platform_data.info[i].fival[j].index = 0;\r
-            rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
-            rk29_camera_platform_data.info[i].fival[j].width = 1280;\r
-            rk29_camera_platform_data.info[i].fival[j].height = 720;\r
-            rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
-            j++;\r
-            #endif\r
+            if (j==0) {\r
+                rk29_camera_platform_data.info[i].fival[j].width = 176;\r
+                rk29_camera_platform_data.info[i].fival[j].height = 144;\r
+            } else if (j==1) {\r
+                rk29_camera_platform_data.info[i].fival[j].width = 320;\r
+                rk29_camera_platform_data.info[i].fival[j].height = 240;\r
+            } else if (j==2) {\r
+                rk29_camera_platform_data.info[i].fival[j].width = 352;\r
+                rk29_camera_platform_data.info[i].fival[j].height = 288;\r
+            } else if (j==3) {\r
+                rk29_camera_platform_data.info[i].fival[j].width = 640;\r
+                rk29_camera_platform_data.info[i].fival[j].height = 480;\r
+            } else if (j==4) {\r
+                rk29_camera_platform_data.info[i].fival[j].width = 720;\r
+                rk29_camera_platform_data.info[i].fival[j].height = 480;\r
+            } else if (j==5) {\r
+                rk29_camera_platform_data.info[i].fival[j].width = 1280;\r
+                rk29_camera_platform_data.info[i].fival[j].height = 720;\r
+            } else if (j==6) {\r
+                rk29_camera_platform_data.info[i].fival[j].width = 240;\r
+                rk29_camera_platform_data.info[i].fival[j].height = 160;\r
+            }\r
+            if (rk29_camera_platform_data.info[i].fival[j].width && rk29_camera_platform_data.info[i].fival[j].height) {\r
+                rk29_sensor_fps_get(i,&rk29_camera_platform_data.info[i].fival[j].discrete.denominator,\r
+                    rk29_camera_platform_data.info[i].fival[j].width,rk29_camera_platform_data.info[i].fival[j].height);\r
+                rk29_camera_platform_data.info[i].fival[j].discrete.numerator= 1000;\r
+                rk29_camera_platform_data.info[i].fival[j].index = 0;\r
+                rk29_camera_platform_data.info[i].fival[j].pixel_format = V4L2_PIX_FMT_NV12;\r
+                rk29_camera_platform_data.info[i].fival[j].type = V4L2_FRMIVAL_TYPE_DISCRETE;\r
+            }\r
         }\r
         \r
                continue;\r
@@ -1550,13 +1781,14 @@ static int rk29_sensor_io_deinit(int sensor)
 static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)\r
 {\r
     struct rk29camera_gpio_res *res = NULL;    \r
-       int ret = RK29_CAM_IO_SUCCESS;\r
+       int ret = RK29_CAM_IO_SUCCESS,i;\r
 \r
-    if(rk29_camera_platform_data.gpio_res[0].dev_name &&  (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {\r
-               res = (struct rk29camera_gpio_res *)&rk29_camera_platform_data.gpio_res[0];\r
-    } 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)) {\r
-       res = (struct rk29camera_gpio_res *)&rk29_camera_platform_data.gpio_res[1];\r
-    } else {\r
+    for (i=0; i<RK29_CAM_SUPPORT_NUMS; i++) {\r
+        if(rk29_camera_platform_data.gpio_res[i].dev_name &&  (strcmp(rk29_camera_platform_data.gpio_res[i].dev_name, dev_name(dev)) == 0)) {\r
+               res = (struct rk29camera_gpio_res *)&rk29_camera_platform_data.gpio_res[i];\r
+        } \r
+    }\r
+    if (res == NULL) {\r
         printk(KERN_ERR "%s is not regisiterd in rk29_camera_platform_data!!\n",dev_name(dev));\r
         ret = RK29_CAM_EIO_INVALID;\r
         goto rk29_sensor_ioctrl_end;\r
@@ -1615,12 +1847,18 @@ static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,
 rk29_sensor_ioctrl_end:\r
     return ret;\r
 }\r
+\r
+static int rk29_sensor_powerdown(struct device *dev, int on)\r
+{\r
+       return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);\r
+}\r
 static int rk29_sensor_power(struct device *dev, int on)\r
 {\r
-       rk29_sensor_ioctrl(dev,Cam_Power,on);\r
+    if (!on)                        /* ddl@rock-chips.com : Ensure sensor enter standby or power off */\r
+        rk29_sensor_powerdown(dev,1);\r
+       rk29_sensor_ioctrl(dev,Cam_Power,on);    \r
     return 0;\r
 }\r
-#if (CONFIG_SENSOR_RESET_PIN_0 != INVALID_GPIO) || (CONFIG_SENSOR_RESET_PIN_1 != INVALID_GPIO)\r
 static int rk29_sensor_reset(struct device *dev)\r
 {\r
        rk29_sensor_ioctrl(dev,Cam_Reset,1);\r
@@ -1628,11 +1866,7 @@ static int rk29_sensor_reset(struct device *dev)
        rk29_sensor_ioctrl(dev,Cam_Reset,0);\r
        return 0;\r
 }\r
-#endif\r
-static int rk29_sensor_powerdown(struct device *dev, int on)\r
-{\r
-       return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);\r
-}\r
+\r
 #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)\r
 static struct i2c_board_info rk29_i2c_cam_info_0[] = {\r
        {\r
@@ -1691,6 +1925,130 @@ static struct platform_device rk29_soc_camera_pdrv_1 = {
        },\r
 };\r
 #endif\r
+#ifdef CONFIG_SENSOR_01\r
+#if (CONFIG_SENSOR_IIC_ADDR_01 != 0x00)\r
+static struct i2c_board_info rk29_i2c_cam_info_01[] = {\r
+       {\r
+               I2C_BOARD_INFO(SENSOR_NAME_01, CONFIG_SENSOR_IIC_ADDR_01>>1)\r
+       },\r
+};\r
+\r
+static struct soc_camera_link rk29_iclink_01 = {\r
+       .bus_id         = RK29_CAM_PLATFORM_DEV_ID,\r
+       .power          = rk29_sensor_power,\r
+#if (CONFIG_SENSOR_RESET_PIN_01 != INVALID_GPIO)\r
+    .reset      = rk29_sensor_reset,\r
+#endif    \r
+       .powerdown  = rk29_sensor_powerdown,\r
+       .board_info     = &rk29_i2c_cam_info_01[0],\r
+       .i2c_adapter_id = CONFIG_SENSOR_IIC_ADAPTER_ID_01,\r
+       .module_name    = SENSOR_NAME_01,\r
+};\r
+\r
+/*platform_device : soc-camera need  */\r
+static struct platform_device rk29_soc_camera_pdrv_01 = {\r
+       .name   = "soc-camera-pdrv",\r
+       .id     = 8,\r
+       .dev    = {\r
+               .init_name = SENSOR_DEVICE_NAME_01,\r
+               .platform_data = &rk29_iclink_01,\r
+       },\r
+};\r
+#endif\r
+#endif\r
+#ifdef CONFIG_SENSOR_02\r
+#if (CONFIG_SENSOR_IIC_ADDR_02 != 0x00)\r
+static struct i2c_board_info rk29_i2c_cam_info_02[] = {\r
+       {\r
+               I2C_BOARD_INFO(SENSOR_NAME_02, CONFIG_SENSOR_IIC_ADDR_02>>1)\r
+       },\r
+};\r
+\r
+static struct soc_camera_link rk29_iclink_02 = {\r
+       .bus_id         = RK29_CAM_PLATFORM_DEV_ID,\r
+       .power          = rk29_sensor_power,\r
+#if (CONFIG_SENSOR_RESET_PIN_02 != INVALID_GPIO)\r
+    .reset      = rk29_sensor_reset,\r
+#endif    \r
+       .powerdown  = rk29_sensor_powerdown,\r
+       .board_info     = &rk29_i2c_cam_info_02[0],\r
+       .i2c_adapter_id = CONFIG_SENSOR_IIC_ADAPTER_ID_02,\r
+       .module_name    = SENSOR_NAME_02,\r
+};\r
+\r
+/*platform_device : soc-camera need  */\r
+static struct platform_device rk29_soc_camera_pdrv_02 = {\r
+       .name   = "soc-camera-pdrv",\r
+       .id     = 3,\r
+       .dev    = {\r
+               .init_name = SENSOR_DEVICE_NAME_02,\r
+               .platform_data = &rk29_iclink_02,\r
+       },\r
+};\r
+#endif\r
+#endif\r
+#ifdef CONFIG_SENSOR_11\r
+#if (CONFIG_SENSOR_IIC_ADDR_11 != 0x00)\r
+static struct i2c_board_info rk29_i2c_cam_info_11[] = {\r
+       {\r
+               I2C_BOARD_INFO(SENSOR_NAME_11, CONFIG_SENSOR_IIC_ADDR_11>>1)\r
+       },\r
+};\r
+\r
+static struct soc_camera_link rk29_iclink_11 = {\r
+       .bus_id         = RK29_CAM_PLATFORM_DEV_ID,\r
+       .power          = rk29_sensor_power,\r
+#if (CONFIG_SENSOR_RESET_PIN_11 != INVALID_GPIO)\r
+    .reset      = rk29_sensor_reset,\r
+#endif         \r
+       .powerdown  = rk29_sensor_powerdown,\r
+       .board_info     = &rk29_i2c_cam_info_11[0],\r
+       .i2c_adapter_id = CONFIG_SENSOR_IIC_ADAPTER_ID_11,\r
+       .module_name    = SENSOR_NAME_11,\r
+};\r
+\r
+/*platform_device : soc-camera need  */\r
+static struct platform_device rk29_soc_camera_pdrv_11 = {\r
+       .name   = "soc-camera-pdrv",\r
+       .id     = 4,\r
+       .dev    = {\r
+               .init_name = SENSOR_DEVICE_NAME_11,\r
+               .platform_data = &rk29_iclink_11,\r
+       },\r
+};\r
+#endif\r
+#endif\r
+#ifdef CONFIG_SENSOR_12\r
+#if (CONFIG_SENSOR_IIC_ADDR_12 != 0x00)\r
+static struct i2c_board_info rk29_i2c_cam_info_12[] = {\r
+       {\r
+               I2C_BOARD_INFO(SENSOR_NAME_12, CONFIG_SENSOR_IIC_ADDR_12>>1)\r
+       },\r
+};\r
+\r
+static struct soc_camera_link rk29_iclink_12 = {\r
+       .bus_id         = RK29_CAM_PLATFORM_DEV_ID,\r
+       .power          = rk29_sensor_power,\r
+#if (CONFIG_SENSOR_RESET_PIN_12 != INVALID_GPIO)\r
+    .reset      = rk29_sensor_reset,\r
+#endif         \r
+       .powerdown  = rk29_sensor_powerdown,\r
+       .board_info     = &rk29_i2c_cam_info_12[0],\r
+       .i2c_adapter_id = CONFIG_SENSOR_IIC_ADAPTER_ID_12,\r
+       .module_name    = SENSOR_NAME_12,\r
+};\r
+\r
+/*platform_device : soc-camera need  */\r
+static struct platform_device rk29_soc_camera_pdrv_12 = {\r
+       .name   = "soc-camera-pdrv",\r
+       .id     = 5,\r
+       .dev    = {\r
+               .init_name = SENSOR_DEVICE_NAME_12,\r
+               .platform_data = &rk29_iclink_12,\r
+       },\r
+};\r
+#endif\r
+#endif\r
 \r
 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;\r
 static struct resource rk29_camera_resource[] = {\r
@@ -1718,7 +2076,7 @@ static struct platform_device rk29_device_camera = {
                .platform_data  = &rk29_camera_platform_data,\r
        }\r
 };\r
-\r
+#if (PMEM_CAM_SIZE > 0)\r
 static struct android_pmem_platform_data android_pmem_cam_pdata = {\r
        .name           = "pmem_cam",\r
        .start          = PMEM_CAM_BASE,\r
@@ -1734,7 +2092,7 @@ static struct platform_device android_pmem_cam_device = {
                .platform_data = &android_pmem_cam_pdata,\r
        },\r
 };\r
-\r
+#endif\r
 #endif\r
 \r
 #endif //#ifdef CONFIG_VIDEO_RK29\r
index 53232ef559e1d6babf8098deb8a8deedaf71377f..dd7cd4534bd8020313c77e7a53be232714c750e0 100755 (executable)
@@ -41,7 +41,7 @@
 
 
 static int debug;
-module_param(debug, int, S_IRUGO|S_IWUSR);
+module_param(debug, int, S_IRUGO|S_IWUSR|S_IWGRP);
 
 #define dprintk(level, fmt, arg...) do {                       \
        if (debug >= level)                                     \
@@ -148,8 +148,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
 *v0.x.4 : this driver support digital zoom;
 *v0.x.5 : this driver support test framerate and query framerate from board file configuration;
 *v0.x.6 : this driver improve test framerate method;
+*v0.x.7 : this driver product resolution by IPP crop and scale, which user request but sensor can't support;
+*         note: this version is only provide yifang client, which is not official version;
+*v0.x.8 : this driver and rk29_camera.c support upto 3 back-sensors and upto 3 front-sensors;
 */
-#define RK29_CAM_VERSION_CODE KERNEL_VERSION(0, 1, 6)
+#define RK29_CAM_VERSION_CODE KERNEL_VERSION(0, 1, 8)
 
 /* limit to rk29 hardware capabilities */
 #define RK29_CAM_BUS_PARAM   (SOCAM_MASTER |\
@@ -316,6 +319,8 @@ static int rk29_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
     struct rk29_camera_dev *pcdev = ici->priv;
     int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
                                                icd->current_fmt->host_fmt);
+    int bytes_per_line_host = soc_mbus_bytes_per_line(pcdev->host_width,
+                                               icd->current_fmt->host_fmt);
 
     dev_dbg(&icd->dev, "count=%d, size=%d\n", *count, *size);
 
@@ -324,7 +329,7 @@ static int rk29_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
 
        /* planar capture requires Y, U and V buffers to be page aligned */
        *size = PAGE_ALIGN(bytes_per_line*icd->user_height);       /* Y pages UV pages, yuv422*/
-       pcdev->vipmem_bsize = PAGE_ALIGN(bytes_per_line * pcdev->host_height);
+       pcdev->vipmem_bsize = PAGE_ALIGN(bytes_per_line_host * pcdev->host_height);
 
 
        if (CAM_WORKQUEUE_IS_EN()) {
@@ -860,9 +865,8 @@ static int rk29_camera_add_device(struct soc_camera_device *icd)
         goto ebusy;
     }
 
-    dev_info(&icd->dev, "RK29 Camera driver attached to camera%d(%s)\n",
-             icd->devnum,dev_name(icd->pdev));
-
+    RK29CAMERA_DG("RK29 Camera driver attached to %s\n",dev_name(icd->pdev));
+    
        pcdev->frame_inval = RK29_CAM_FRAME_INVAL_INIT;
     pcdev->active = NULL;
     pcdev->icd = NULL;
@@ -928,8 +932,7 @@ static void rk29_camera_remove_device(struct soc_camera_device *icd)
        mutex_lock(&camera_lock);
     BUG_ON(icd != pcdev->icd);
 
-    dev_info(&icd->dev, "RK29 Camera driver detached from camera%d(%s)\n",
-             icd->devnum,dev_name(icd->pdev));
+    RK29CAMERA_DG("RK29 Camera driver detached from %s\n",dev_name(icd->pdev));
 
        /* ddl@rock-chips.com: Application will call VIDIOC_STREAMOFF before close device, but
           stream may be turn on again before close device, if suspend and resume happened. */
@@ -1317,25 +1320,50 @@ static int rk29_camera_set_fmt(struct soc_camera_device *icd,
                ret = -EINVAL;
             goto RK29_CAMERA_SET_FMT_END;
        }
-               mf.width = usr_w;
-               mf.height = usr_h;
        }
        #endif
     icd->sense = NULL;
 
     if (!ret) {
-        rect.left = 0;
-        rect.top = 0;
-        rect.width = mf.width;
-        rect.height = mf.height;
+
+        if (mf.width*usr_h == mf.height*usr_w) {
+            rect.width = mf.width;
+            rect.height = mf.height;
+        } else {
+            int ratio;
+            if (usr_w > usr_h) {
+                if (mf.width > usr_w) {
+                    ratio = mf.width*10/usr_w;
+                    rect.width = usr_w*ratio/10;
+                    rect.height = usr_h*ratio/10;                    
+                } else {
+                    ratio = usr_w*10/mf.width + 1;
+                    rect.width = usr_w*10/ratio;
+                    rect.height = usr_h*10/ratio;
+                }                
+            } else {
+                if (mf.height > usr_h) {
+                    ratio = mf.height*10/usr_h;
+                    rect.width = usr_w*ratio/10;
+                    rect.height = usr_h*ratio/10;                    
+                } else {
+                    ratio = usr_h*10/mf.height + 1;
+                    rect.width = usr_w*10/ratio;
+                    rect.height = usr_h*10/ratio;
+                }
+            }
+        }
+
+        rect.left = (mf.width - rect.width)/2;
+        rect.top = (mf.height - rect.height)/2;
 
         down(&pcdev->zoominfo.sem);        
         pcdev->zoominfo.a.c.width = rect.width*100/pcdev->zoominfo.zoom_rate;
                pcdev->zoominfo.a.c.width &= ~0x03;
                pcdev->zoominfo.a.c.height = rect.height*100/pcdev->zoominfo.zoom_rate;
                pcdev->zoominfo.a.c.height &= ~0x03;
-               pcdev->zoominfo.a.c.left = ((rect.width - pcdev->zoominfo.a.c.width)>>1)&(~0x01);
-               pcdev->zoominfo.a.c.top = ((rect.height - pcdev->zoominfo.a.c.height)>>1)&(~0x01);
+               pcdev->zoominfo.a.c.left = ((rect.width - pcdev->zoominfo.a.c.width)/2 + rect.left)&(~0x01);
+               pcdev->zoominfo.a.c.top = ((rect.height - pcdev->zoominfo.a.c.height)/2 + rect.top)&(~0x01);
         up(&pcdev->zoominfo.sem);
 
         /* ddl@rock-chips.com: IPP work limit check */
@@ -1355,9 +1383,17 @@ static int rk29_camera_set_fmt(struct soc_camera_device *icd,
             }
         }
         
-        RK29CAMERA_DG("%s..%s icd width:%d  host width:%d (zoom: %dx%d@(%d,%d)->%dx%d)\n",__FUNCTION__,xlate->host_fmt->name,
-                                  rect.width, pix->width, pcdev->zoominfo.a.c.width,pcdev->zoominfo.a.c.height, pcdev->zoominfo.a.c.left,pcdev->zoominfo.a.c.top,
+        /* ddl@rock-chips.com: Crop is doing by IPP, not by VIP in rk2918 */
+        rect.left = 0;
+        rect.top = 0;
+        rect.width = mf.width;
+        rect.height = mf.height;
+        
+        RK29CAMERA_DG("%s..%s Sensor output:%dx%d  VIP output:%dx%d (zoom: %dx%d@(%d,%d)->%dx%d)\n",__FUNCTION__,xlate->host_fmt->name,
+                                  mf.width, mf.height,rect.width,rect.height, pcdev->zoominfo.a.c.width,pcdev->zoominfo.a.c.height, pcdev->zoominfo.a.c.left,pcdev->zoominfo.a.c.top,
                                   pix->width, pix->height);
+
+                
         rk29_camera_setup_format(icd, pix->pixelformat, mf.code, &rect); 
         
                if (CAM_IPPWORK_IS_EN()) {
@@ -1366,8 +1402,8 @@ static int rk29_camera_set_fmt(struct soc_camera_device *icd,
         pcdev->icd_width = icd_width;
         pcdev->icd_height = icd_height;
 
-        pix->width = mf.width;
-       pix->height = mf.height;
+        pix->width = usr_w;
+       pix->height = usr_h;
        pix->field = mf.field;
        pix->colorspace = mf.colorspace;
        icd->current_fmt = xlate;        
@@ -1377,7 +1413,7 @@ RK29_CAMERA_SET_FMT_END:
     if (stream_on & ENABLE_CAPTURE)
         write_vip_reg(RK29_VIP_CTRL, (read_vip_reg(RK29_VIP_CTRL) | ENABLE_CAPTURE));
        if (ret)
-       RK29CAMERA_TR("\n%s..%d.. ret = %d  \n",__FUNCTION__,__LINE__, ret);
+       RK29CAMERA_TR("\n%s: Driver isn't support %dx%d resolution which user request!\n",__FUNCTION__,usr_w,usr_h);
     return ret;
 }
 static bool rk29_camera_fmt_capturechk(struct v4l2_format *f)
@@ -1413,7 +1449,8 @@ static int rk29_camera_try_fmt(struct soc_camera_device *icd,
        bool is_capture = rk29_camera_fmt_capturechk(f);
        bool vipmem_is_overflow = false;
     struct v4l2_mbus_framefmt mf;
-
+    int bytes_per_line_host;
+    
        usr_w = pix->width;
        usr_h = pix->height;
        RK29CAMERA_DG("%s enter width:%d  height:%d\n",__FUNCTION__,usr_w,usr_h);
@@ -1454,13 +1491,14 @@ static int rk29_camera_try_fmt(struct soc_camera_device *icd,
                goto RK29_CAMERA_TRY_FMT_END;
     RK29CAMERA_DG("%s mf.width:%d  mf.height:%d\n",__FUNCTION__,mf.width,mf.height);
        #ifdef CONFIG_VIDEO_RK29_WORK_IPP       
-       if ((mf.width > usr_w) && (mf.height > usr_h)) {
+       if ((mf.width != usr_w) || (mf.height != usr_h)) {
+        bytes_per_line_host = soc_mbus_bytes_per_line(mf.width,icd->current_fmt->host_fmt); 
                if (is_capture) {
-                       vipmem_is_overflow = (PAGE_ALIGN(pix->bytesperline*pix->height) > pcdev->vipmem_size);
+                       vipmem_is_overflow = (PAGE_ALIGN(bytes_per_line_host*mf.height) > pcdev->vipmem_size);
                } else {
                        /* Assume preview buffer minimum is 4 */
-                       vipmem_is_overflow = (PAGE_ALIGN(pix->bytesperline*pix->height)*4 > pcdev->vipmem_size);
-               }
+                       vipmem_is_overflow = (PAGE_ALIGN(bytes_per_line_host*mf.height)*4 > pcdev->vipmem_size);
+               }        
                if (vipmem_is_overflow == false) {
                        pix->width = usr_w;
                        pix->height = usr_h;
@@ -1469,26 +1507,14 @@ static int rk29_camera_try_fmt(struct soc_camera_device *icd,
             pix->width = mf.width;
             pix->height = mf.height;            
                }
-       } else if ((mf.width < usr_w) && (mf.height < usr_h)) {
-               if (((usr_w>>1) < mf.width) && ((usr_h>>1) < mf.height)) {
-                       if (is_capture) {
-                               vipmem_is_overflow = (PAGE_ALIGN(pix->bytesperline*pix->height) > pcdev->vipmem_size);
-                       } else {
-                               vipmem_is_overflow = (PAGE_ALIGN(pix->bytesperline*pix->height)*4 > pcdev->vipmem_size);
-                       }
-                       if (vipmem_is_overflow == false) {
-                               pix->width = usr_w;
-                               pix->height = usr_h;
-                       } else {
-                               RK29CAMERA_TR("vipmem for IPP is overflow, This resolution(%dx%d -> %dx%d) is invalidate!\n",mf.width,mf.height,usr_w,usr_h);
+        
+        if ((mf.width < usr_w) || (mf.height < usr_h)) {
+            if (((usr_w>>1) > mf.width) || ((usr_h>>1) > mf.height)) {
+                RK29CAMERA_TR("The aspect ratio(%dx%d/%dx%d) is bigger than 2 !\n",mf.width,mf.height,usr_w,usr_h);
                 pix->width = mf.width;
                 pix->height = mf.height;
-                       }
-               } else {
-                       RK29CAMERA_TR("The aspect ratio(%dx%d/%dx%d) is bigger than 2 !\n",mf.width,mf.height,usr_w,usr_h);
-            pix->width = mf.width;
-            pix->height = mf.height;
-               }
+            }
+        }        
        }
        #else
     pix->width = mf.width;
@@ -1497,15 +1523,15 @@ static int rk29_camera_try_fmt(struct soc_camera_device *icd,
     pix->colorspace    = mf.colorspace;    
 
     switch (mf.field) {
-       case V4L2_FIELD_ANY:
-       case V4L2_FIELD_NONE:
-               pix->field      = V4L2_FIELD_NONE;
-               break;
-       default:
-               /* TODO: support interlaced at least in pass-through mode */
-               dev_err(icd->dev.parent, "Field type %d unsupported.\n",
-                       mf.field);
-               goto RK29_CAMERA_TRY_FMT_END;
+       case V4L2_FIELD_ANY:
+       case V4L2_FIELD_NONE:
+               pix->field      = V4L2_FIELD_NONE;
+               break;
+       default:
+               /* TODO: support interlaced at least in pass-through mode */
+               dev_err(icd->dev.parent, "Field type %d unsupported.\n",
+                       mf.field);
+               goto RK29_CAMERA_TRY_FMT_END;
        }
 
 RK29_CAMERA_TRY_FMT_END:
@@ -1555,14 +1581,27 @@ static int rk29_camera_querycap(struct soc_camera_host *ici,
 {
     struct rk29_camera_dev *pcdev = ici->priv;
     char orientation[5];
+    int i;
 
-    strlcpy(cap->card, dev_name(pcdev->icd->pdev), sizeof(cap->card));    
-    if (strcmp(dev_name(pcdev->icd->pdev), pcdev->pdata->info[0].dev_name) == 0) {
-        sprintf(orientation,"-%d",pcdev->pdata->info[0].orientation);
+    strlcpy(cap->card, dev_name(pcdev->icd->pdev), sizeof(cap->card));
+
+    memset(orientation,0x00,sizeof(orientation));
+    for (i=0; i<RK29_CAM_SUPPORT_NUMS;i++) {
+        if ((pcdev->pdata->info[i].dev_name!=NULL) && (strcmp(dev_name(pcdev->icd->pdev), pcdev->pdata->info[i].dev_name) == 0)) {
+            sprintf(orientation,"-%d",pcdev->pdata->info[i].orientation);
+        }
+    }
+    
+    if (orientation[0] != '-') {
+        RK29CAMERA_TR("%s: %s is not registered in rk29_camera_platform_data, orientation apply default value",__FUNCTION__,dev_name(pcdev->icd->pdev));
+        if (strstr(dev_name(pcdev->icd->pdev),"front")) 
+            strcat(cap->card,"-270");
+        else 
+            strcat(cap->card,"-90");
     } else {
-        sprintf(orientation,"-%d",pcdev->pdata->info[1].orientation);
+        strcat(cap->card,orientation); 
     }
-    strcat(cap->card,orientation); 
+    
     cap->version = RK29_CAM_VERSION_CODE;
     cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
 
@@ -1773,7 +1812,7 @@ int rk29_camera_enum_frameintervals(struct soc_camera_device *icd, struct v4l2_f
     struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
     struct rk29_camera_dev *pcdev = ici->priv;
     struct rk29_camera_frmivalenum *fival_list = NULL;
-    struct v4l2_frmivalenum *fival_head;
+    struct v4l2_frmivalenum *fival_head=NULL;
     int i,ret = 0,index;
     
     index = fival->index & 0x00ffffff;
@@ -1806,12 +1845,20 @@ int rk29_camera_enum_frameintervals(struct soc_camera_device *icd, struct v4l2_f
             RK29CAMERA_TR("%s: fival_list is NULL\n",__FUNCTION__);
             ret = -EINVAL;
         }
-    } else {
-        if (strcmp(dev_name(pcdev->icd->pdev),pcdev->pdata->info[0].dev_name) == 0) {
-            fival_head = pcdev->pdata->info[0].fival;
-        } else {
-            fival_head = pcdev->pdata->info[1].fival;
+    } else {  
+
+        for (i=0; i<RK29_CAM_SUPPORT_NUMS; i++) {
+            if (pcdev->pdata->info[i].dev_name && (strcmp(dev_name(pcdev->icd->pdev),pcdev->pdata->info[i].dev_name) == 0)) {
+                fival_head = pcdev->pdata->info[i].fival;
+            }
         }
+        
+        if (fival_head == NULL) {
+            RK29CAMERA_TR("%s: %s is not registered in rk29_camera_platform_data!!",__FUNCTION__,dev_name(pcdev->icd->pdev));
+            ret = -EINVAL;
+            goto rk29_camera_enum_frameintervals_end;
+        }
+        
         i = 0;
         while (fival_head->width && fival_head->height) {
             if ((fival->pixel_format == fival_head->pixel_format)
@@ -1827,20 +1874,20 @@ int rk29_camera_enum_frameintervals(struct soc_camera_device *icd, struct v4l2_f
 
         if ((i == index) && (fival->height == fival_head->height) && (fival->width == fival_head->width)) {
             memcpy(fival, fival_head, sizeof(struct v4l2_frmivalenum));
-            RK29CAMERA_DG("%s %dx%d@%c%c%c%c framerate : %d/%d\n", dev_name(&rk29_camdev_info_ptr->icd->dev),
+            RK29CAMERA_DG("%s %dx%d@%c%c%c%c framerate : %d/%d\n", dev_name(rk29_camdev_info_ptr->icd->pdev),
                 fival->width, fival->height,
                 fival->pixel_format & 0xFF, (fival->pixel_format >> 8) & 0xFF,
                            (fival->pixel_format >> 16) & 0xFF, (fival->pixel_format >> 24),
                             fival->discrete.denominator,fival->discrete.numerator);                        
         } else {
             if (index == 0)
-                RK29CAMERA_TR("%s have not catch %d%d@%c%c%c%c index(%d) framerate\n",dev_name(&rk29_camdev_info_ptr->icd->dev),
+                RK29CAMERA_TR("%s have not catch %d%d@%c%c%c%c index(%d) framerate\n",dev_name(rk29_camdev_info_ptr->icd->pdev),
                     fival->width,fival->height, 
                     fival->pixel_format & 0xFF, (fival->pixel_format >> 8) & 0xFF,
                            (fival->pixel_format >> 16) & 0xFF, (fival->pixel_format >> 24),
                            index);
             else
-                RK29CAMERA_DG("%s have not catch %d%d@%c%c%c%c index(%d) framerate\n",dev_name(&rk29_camdev_info_ptr->icd->dev),
+                RK29CAMERA_DG("%s have not catch %d%d@%c%c%c%c index(%d) framerate\n",dev_name(rk29_camdev_info_ptr->icd->pdev),
                     fival->width,fival->height, 
                     fival->pixel_format & 0xFF, (fival->pixel_format >> 8) & 0xFF,
                            (fival->pixel_format >> 16) & 0xFF, (fival->pixel_format >> 24),
@@ -1848,7 +1895,7 @@ int rk29_camera_enum_frameintervals(struct soc_camera_device *icd, struct v4l2_f
             ret = -EINVAL;
         }
     }
-
+rk29_camera_enum_frameintervals_end:
     return ret;
 }
 
@@ -1969,7 +2016,9 @@ static int rk29_camera_probe(struct platform_device *pdev)
     int irq,i;
     int err = 0;
 
-    RK29CAMERA_DG("%s..%s..%d  \n",__FUNCTION__,__FILE__,__LINE__);
+    RK29CAMERA_TR("RK29 Camera driver version: v%d.%d.%d\n",(RK29_CAM_VERSION_CODE&0xff0000)>>16,
+        (RK29_CAM_VERSION_CODE&0xff00)>>8,RK29_CAM_VERSION_CODE&0xff);
+    
     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
     irq = platform_get_irq(pdev, 0);
     if (!res || irq < 0) {
index ef1f427615a28d8c43503f54ae504fa09c77d51b..0827afef9d8dab89a3d3308529594908437e0c50 100755 (executable)
@@ -2130,7 +2130,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);\r
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;\r
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -2148,7 +2148,57 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
         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
+       if (((set_w <= 176) && (set_h <= 144)) &&( sensor_qcif[0].reg!=0xff))\r
+       {\r
+        set_w = 176;\r
+        set_h = 144;\r
+       }\r
+       else if (((set_w <= 320) && (set_h <= 240)) && (sensor_qvga[0].reg!=0xff))\r
+    {\r
+        set_w = 320;\r
+        set_h = 240;\r
+    }\r
+    else if (((set_w <= 352) && (set_h<= 288)) && (sensor_cif[0].reg!=0xff))\r
+    {\r
+        set_w = 352;\r
+        set_h = 288;\r
+    }\r
+    else if (((set_w <= 640) && (set_h <= 480)) &&( sensor_vga[0].reg!=0xff))\r
+    {\r
+        set_w =640;\r
+        set_h = 480;\r
+    }\r
+    else if (((set_w <= 800) && (set_h <= 600)) && (sensor_svga[0].reg!=0xff))\r
+    {\r
+        set_w = 800;\r
+        set_h = 600;\r
+    }\r
+       else if (((set_w <= 1024) && (set_h <= 768)) &&( sensor_xga[0].reg!=0xff))\r
+    {\r
+        set_w = 1024;\r
+        set_h = 768;\r
+    }\r
+    else if (((set_w <= 1280) && (set_h <= 1024)) && (sensor_sxga[0].reg!=0xff))\r
+    {\r
+        set_w = 1280;\r
+        set_h = 1024;\r
+    }\r
+    else if (((set_w <= 1600) && (set_h <= 1200)) && (sensor_uxga[0].reg!=0xff))\r
+    {\r
+        set_w = 1600;\r
+        set_h = 1200;\r
+    }\r
+    else\r
+    {\r
+        set_w = SENSOR_INIT_WIDTH;\r
+        set_h = SENSOR_INIT_HEIGHT;            \r
+    }\r
+    mf->width = set_w;
+    mf->height = set_h;  \r
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -2920,18 +2970,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) { \r
-                if (sensor->sensor_io_request->gpio_res[0].dev_name && \r
-                    (strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {\r
-                    sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];\r
-                } else if (sensor->sensor_io_request->gpio_res[1].dev_name && \r
-                    (strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {\r
-                    sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];\r
-                }\r
-            } else {\r
-                SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);\r
-                ret = -EINVAL;\r
-                goto sensor_ioctl_end;\r
+            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;
             }\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
@@ -3086,4 +3141,4 @@ module_exit(sensor_mod_exit);
 \r
 MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));\r
 MODULE_AUTHOR("ddl <kernel@rock-chips>");\r
-MODULE_LICENSE("GPL");
\ No newline at end of file
+MODULE_LICENSE("GPL");\r
index a300398eaad4f43422c32ea4e12e43b63bddaa9c..bfea1e0d6827bddf747f09872a71fadbb682acb7 100755 (executable)
@@ -1814,7 +1814,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
     struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
-    int ret = 0;
+    int ret = 0,set_w,set_h;
    
        fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
                                   ARRAY_SIZE(sensor_colour_fmts));
@@ -1832,7 +1832,37 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
         mf->width = SENSOR_MAX_WIDTH;
     else if (mf->width < SENSOR_MIN_WIDTH)
         mf->width = SENSOR_MIN_WIDTH;
+    
+    set_w = mf->width;
+    set_h = mf->height;
 
+       if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+       {
+        set_w = 176;
+        set_h = 144;
+       }
+       else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+    {
+        set_w = 320;
+        set_h = 240;
+    }
+    else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+    {
+        set_w = 352;
+        set_h = 288;
+    }
+    else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+    {
+        set_w = 640;
+        set_h = 480;
+    }
+    else
+    {
+        set_w = SENSOR_INIT_WIDTH;
+        set_h = SENSOR_INIT_HEIGHT;            
+    }
+    mf->width = set_w;
+    mf->height = set_h;  
     mf->colorspace = fmt->colorspace;
     
     return ret;
@@ -2609,12 +2639,17 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *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];
+                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__);
index 86ab89524d0609437370e19b3332bb702b0e49a2..8e7219337450f67f97a3e4e75ae960713d2c4866 100755 (executable)
@@ -1109,8 +1109,8 @@ static void scan_add_host(struct soc_camera_host *ici)
                if (icd->iface == ici->nr) {
                        int ret;
                        icd->dev.parent = ici->v4l2_dev.dev;
-                       dev_set_name(&icd->dev, "%u-%u", icd->iface,
-                                    icd->devnum);
+                       dev_set_name(&icd->dev, "%u-%u-%s", icd->iface,
+                                    icd->devnum,dev_name(icd->pdev));
                        ret = device_register(&icd->dev);
                        if (ret < 0) {
                                icd->dev.parent = NULL;
@@ -1185,8 +1185,6 @@ static int soc_camera_probe(struct device *dev)
        struct v4l2_mbus_framefmt mf;
        int ret;
 
-       dev_info(dev, "Probing %s\n", dev_name(dev));
-
        ret = regulator_bulk_get(icd->pdev, icl->num_regulators,
                                 icl->regulators);
        if (ret < 0)
@@ -1278,7 +1276,7 @@ static int soc_camera_probe(struct device *dev)
        soc_camera_power_set(icd, icl, 0);
 
        mutex_unlock(&icd->video_lock);
-
+    dev_info(dev, "Probe %s success\n", dev_name(icd->pdev));
        return 0;
 
 evidstart:
@@ -1301,6 +1299,7 @@ eadd:
 epower:
        regulator_bulk_free(icl->num_regulators, icl->regulators);
 ereg:
+    dev_err(dev, "Probe %s failed\n", dev_name(icd->pdev));
        return ret;
 }