From cd1c7927990e942d049bc55a9624455057948c40 Mon Sep 17 00:00:00 2001 From: zyc Date: Mon, 29 Sep 2014 14:12:33 +0800 Subject: [PATCH] rk312x : cif : cif driver v0.0x1.8 --- arch/arm/mach-rockchip/rk_camera.c | 21 ++++++--- drivers/i2c/i2c-core.c | 50 ++++++++++++++++++++++ drivers/media/video/rk30_camera_oneframe.c | 4 +- 3 files changed, 68 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-rockchip/rk_camera.c b/arch/arm/mach-rockchip/rk_camera.c index f496b2720771..3407b1cea6c9 100644 --- a/arch/arm/mach-rockchip/rk_camera.c +++ b/arch/arm/mach-rockchip/rk_camera.c @@ -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; diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 4aea35713aa1..c604ce8661b5 100755 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -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 diff --git a/drivers/media/video/rk30_camera_oneframe.c b/drivers/media/video/rk30_camera_oneframe.c index 7e74d72d5152..bb6ca97866f9 100755 --- a/drivers/media/video/rk30_camera_oneframe.c +++ b/drivers/media/video/rk30_camera_oneframe.c @@ -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); -- 2.34.1