rk312x : cif : cif driver v0.0x1.8
authorzyc <zyc@rock-chips.com>
Mon, 29 Sep 2014 06:12:33 +0000 (14:12 +0800)
committerzyc <zyc@rock-chips.com>
Mon, 29 Sep 2014 06:12:33 +0000 (14:12 +0800)
arch/arm/mach-rockchip/rk_camera.c
drivers/i2c/i2c-core.c
drivers/media/video/rk30_camera_oneframe.c

index f496b27207713e0cc1228e3c2c85270b6db090a3..3407b1cea6c9ad4705020bd4b0fda5a1e7c56c10 100644 (file)
@@ -149,7 +149,6 @@ static int  rk_dts_sensor_probe(struct platform_device *pdev)
        int sensor_num = 0,err;
        struct device *dev = &pdev->dev;
        struct rkcamera_platform_data *new_camera_list;
-       
 
        debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
        
@@ -167,6 +166,16 @@ static int rk_dts_sensor_probe(struct platform_device *pdev)
                int pwr_active = 0, rst_active = 0, pwdn_active = 0;
                int orientation = 0;
                struct rkcamera_platform_data *new_camera; 
+               
+               char sensor_name[20] = {0};
+               char *name = NULL;
+               
+               strcpy(sensor_name,cp->name);
+               name = sensor_name;
+               if(strstr(sensor_name,"_") != NULL){                    
+                       name = strsep(&name,"_");
+               }
+
                new_camera = kzalloc(sizeof(struct rkcamera_platform_data),GFP_KERNEL);
                if(!sensor_num)
                {                       
@@ -177,7 +186,7 @@ static int  rk_dts_sensor_probe(struct platform_device *pdev)
                sensor_num ++;
                new_camera_list->next_camera = new_camera;
                new_camera_list = new_camera;
-       
+
                if (of_property_read_u32(cp, "flash_attach", &flash_attach)) {
                        dprintk("%s:Get %s rockchip,flash_attach failed!\n",__func__, cp->name);                                
                }
@@ -236,16 +245,16 @@ static int        rk_dts_sensor_probe(struct platform_device *pdev)
                        printk("%s:Get %s rockchip,orientation failed!\n",__func__, cp->name);                          
                }
                
-               strcpy(new_camera->dev.i2c_cam_info.type, cp->name);
+               strcpy(new_camera->dev.i2c_cam_info.type, name);
                new_camera->dev.i2c_cam_info.addr = i2c_add>>1;
                new_camera->dev.desc_info.host_desc.bus_id = RK29_CAM_PLATFORM_DEV_ID+cif_chl;/*yzm*/
                new_camera->dev.desc_info.host_desc.i2c_adapter_id = i2c_chl;/*yzm*/
-               new_camera->dev.desc_info.host_desc.module_name = cp->name;/*const*/
+               new_camera->dev.desc_info.host_desc.module_name = name;/*const*/
                new_camera->dev.device_info.name = "soc-camera-pdrv";
                if(is_front)
-                       sprintf(new_camera->dev_name,"%s_%s",cp->name,"front");
+                       sprintf(new_camera->dev_name,"%s_%s",name,"front");
                else
-                       sprintf(new_camera->dev_name,"%s_%s",cp->name,"back");
+                       sprintf(new_camera->dev_name,"%s_%s",name,"back");
                new_camera->dev.device_info.dev.init_name =(const char*)&new_camera->dev_name[0];
                new_camera->io.gpio_reset = reset;
                new_camera->io.gpio_powerdown = powerdown;
index 4aea35713aa18c0b81772f84bdfb0f81ef8eecc4..c604ce8661b50899a37ddb9e4641fb4de668f9fd 100755 (executable)
@@ -54,6 +54,7 @@ static DEFINE_MUTEX(core_lock);
 static DEFINE_IDR(i2c_adapter_idr);
 
 static struct device_type i2c_client_type;
+static int i2c_check_addr_ex(struct i2c_adapter *adapter, int addr);
 static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
 
 /* ------------------------------------------------------------------------- */
@@ -657,9 +658,18 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
        }
 
        /* Check for address business */
+       #if 0   
        status = i2c_check_addr_busy(adap, client->addr);
        if (status)
                goto out_err;
+       #else
+       /* ddl@rock-chips.com : Devices which have some i2c addr can work in same i2c bus, 
+          if devices havn't work at the same time.*/
+       status = i2c_check_addr_ex(adap, client->addr);
+       if (status != 0)
+               dev_err(&adap->dev, "%d i2c clients have been registered at 0x%02x",
+                       status, client->addr);   
+       #endif
 
        client->dev.parent = &client->adapter->dev;
        client->dev.bus = &i2c_bus_type;
@@ -668,9 +678,22 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
        ACPI_HANDLE_SET(&client->dev, info->acpi_node.handle);
 
        /* For 10-bit clients, add an arbitrary offset to avoid collisions */
+       
+    /* ddl@rock-chips.com : Devices which have some i2c addr can work in same i2c bus, 
+      if devices havn't work at the same time.*/
+       #if 0
        dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap),
                     client->addr | ((client->flags & I2C_CLIENT_TEN)
                                     ? 0xa000 : 0));
+       #else
+    if (status == 0)
+       dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap),
+                    client->addr);
+    else 
+        dev_set_name(&client->dev, "%d-%04x-%01x", i2c_adapter_id(adap),
+                    client->addr,status);
+       #endif
+
        status = device_register(&client->dev);
        if (status)
                goto out_err;
@@ -1368,6 +1391,33 @@ void i2c_del_driver(struct i2c_driver *driver)
 EXPORT_SYMBOL(i2c_del_driver);
 
 /* ------------------------------------------------------------------------- */
+/* ddl@rock-chips.com : Devices which have some i2c addr can work in same i2c bus, 
+      if devices havn't work at the same time.*/
+struct i2c_addr_cnt
+{
+    int addr;
+    int cnt;
+};
+static int __i2c_check_addr_ex(struct device *dev, void *addrp)
+{
+       struct i2c_client       *client = i2c_verify_client(dev);
+       struct i2c_addr_cnt *addrinfo = (struct i2c_addr_cnt *)addrp;
+    int addr = addrinfo->addr;
+
+       if (client && client->addr == addr) {
+               addrinfo->cnt++;
+       }
+       return 0;
+}
+static int i2c_check_addr_ex(struct i2c_adapter *adapter, int addr)
+{
+    struct i2c_addr_cnt addrinfo;
+
+    addrinfo.addr = addr;
+    addrinfo.cnt = 0;
+    device_for_each_child(&adapter->dev, &addrinfo, __i2c_check_addr_ex);
+    return addrinfo.cnt;
+}
 
 /**
  * i2c_use_client - increments the reference count of the i2c client structure
index 7e74d72d5152f152380b91b64ae57d2f02e6d541..bb6ca97866f93b17c11d3ce11adec14201dacb03 100755 (executable)
@@ -270,8 +270,10 @@ static u32 DISABLE_INVERT_PCLK_CIF1;
                 1. Delete SOCAM_DATAWIDTH_8 in SENSOR_BUS_PARAM parameters,it conflict with V4L2_MBUS_PCLK_SAMPLE_FALLING.
 *v0.1.7:
                 1. Add  power and powerdown controled by PMU.
+*v0.1.8:
+                1. Support front and rear camera support are the same.
 */
-#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 1, 0x7)
+#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 1, 0x8)
 static int version = RK_CAM_VERSION_CODE;
 module_param(version, int, S_IRUGO);