1 #include "rk_camera.h"
\r
2 #include "rk30_camera.h"
\r
3 #include <linux/gpio.h>
\r
4 #include <linux/delay.h>
\r
5 #include <linux/version.h>
\r
6 #include <linux/moduleparam.h>
\r
7 #include <linux/of_gpio.h>
\r
8 /**********yzm***********/
\r
9 #include <linux/of.h>
\r
10 #include <linux/of_irq.h>
\r
11 #include <linux/kernel.h>
\r
12 #include <linux/of_address.h>
\r
13 #include <linux/of_platform.h>
\r
14 #include <linux/of_fdt.h>
\r
15 #include <linux/module.h>
\r
16 /**********yzm***********/
\r
18 //#define PMEM_CAM_NECESSARY 0x00000000 /*yzm*/
\r
20 static int camio_version = KERNEL_VERSION(0,1,9);/*yzm camio_version*/
\r
21 module_param(camio_version, int, S_IRUGO);
\r
23 static int camera_debug = 0;/*yzm*/
\r
24 module_param(camera_debug, int, S_IRUGO|S_IWUSR);
\r
26 #undef CAMMODULE_NAME
\r
27 #define CAMMODULE_NAME "rk_cam_io"
\r
29 #define ddprintk(level, fmt, arg...) do { \
\r
30 if (camera_debug >= level) \
\r
31 printk(KERN_WARNING"%s(%d):" fmt"\n", CAMMODULE_NAME,__LINE__,## arg); } while (0)
\r
33 #define dprintk(format, ...) ddprintk(1, format, ## __VA_ARGS__)
\r
34 #define eprintk(format, ...) printk(KERN_ERR "%s(%d):" format"\n",CAMMODULE_NAME,__LINE__,## __VA_ARGS__)
\r
35 #define debug_printk(format, ...) ddprintk(3, format, ## __VA_ARGS__)
\r
37 static int rk_sensor_io_init(void);
\r
38 static int rk_sensor_io_deinit(int sensor);
\r
39 static int rk_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on);
\r
40 static int rk_sensor_power(struct device *dev, int on);
\r
41 static int rk_sensor_register(void);
\r
42 /*static int rk_sensor_reset(struct device *dev);*/
\r
44 static int rk_dts_sensor_probe(struct platform_device *pdev);
\r
45 static int rk_dts_sensor_remove(struct platform_device *pdev);
\r
46 static int rk_dts_cif_probe(struct platform_device *pdev);
\r
47 static int rk_dts_cif_remove(struct platform_device *pdev);
\r
49 static int rk_sensor_powerdown(struct device *dev, int on);
\r
51 static struct rkcamera_platform_data *new_camera_head;
\r
53 static struct rk29camera_platform_data rk_camera_platform_data = {
\r
54 .io_init = rk_sensor_io_init,
\r
55 .io_deinit = rk_sensor_io_deinit,
\r
56 .sensor_ioctrl = rk_sensor_ioctrl,
\r
57 .sensor_register = rk_sensor_register,
\r
61 struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
\r
62 .sensor_power_cb = NULL,
\r
63 .sensor_reset_cb = NULL,
\r
64 .sensor_powerdown_cb = NULL,
\r
65 .sensor_flash_cb = NULL,
\r
66 .sensor_af_cb = NULL,
\r
70 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
\r
72 static struct resource rk_camera_resource_host_0[2] = {};
\r
75 static struct resource rk_camera_resource_host_1[2] = {};
\r
79 struct platform_device rk_device_camera_host_0 = {
\r
80 .name = RK29_CAM_DRV_NAME,
\r
81 .id = RK_CAM_PLATFORM_DEV_ID_0, /* This is used to put cameras on this interface*/
\r
83 .resource = rk_camera_resource_host_0,/*yzm*/
\r
85 .dma_mask = &rockchip_device_camera_dmamask,
\r
86 .coherent_dma_mask = 0xffffffffUL,
\r
87 .platform_data = &rk_camera_platform_data,
\r
93 struct platform_device rk_device_camera_host_1 = {
\r
94 .name = RK29_CAM_DRV_NAME,
\r
95 .id = RK_CAM_PLATFORM_DEV_ID_1, /* This is used to put cameras on this interface */
\r
96 .num_resources = ARRAY_SIZE(rk_camera_resource_host_1),
\r
97 .resource = rk_camera_resource_host_1,/*yzm*/
\r
99 .dma_mask = &rockchip_device_camera_dmamask,
\r
100 .coherent_dma_mask = 0xffffffffUL,
\r
101 .platform_data = &rk_camera_platform_data,
\r
108 static const struct of_device_id of_match_cif[] = {
\r
109 { .compatible = "rockchip,cif" },
\r
113 MODULE_DEVICE_TABLE(of,of_match_cif);
\r
114 static struct platform_driver rk_cif_driver =
\r
117 .name = RK3288_CIF_NAME,
\r
118 .owner = THIS_MODULE,
\r
119 .of_match_table = of_match_ptr(of_match_cif),
\r
121 .probe = rk_dts_cif_probe,
\r
122 .remove = rk_dts_cif_remove,
\r
125 static const struct of_device_id of_match_sensor[] = {
\r
126 { .compatible = "rockchip,sensor" },
\r
128 MODULE_DEVICE_TABLE(of,of_match_sensor);
\r
129 static struct platform_driver rk_sensor_driver =
\r
132 .name = RK3288_SENSOR_NAME,
\r
133 .owner = THIS_MODULE,
\r
134 .of_match_table = of_match_ptr(of_match_sensor),
\r
136 .probe = rk_dts_sensor_probe,
\r
137 .remove = rk_dts_sensor_remove,
\r
141 static int rk_dts_sensor_remove(struct platform_device *pdev)
\r
145 static int rk_dts_sensor_probe(struct platform_device *pdev)
\r
147 struct device_node *np, *cp;
\r
148 int sensor_num = 0;
\r
149 struct device *dev = &pdev->dev;
\r
150 struct rkcamera_platform_data *new_camera_list;
\r
153 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
\r
158 for_each_child_of_node(np, cp) {
\r
159 u32 flash_attach,mir,i2c_rata,i2c_chl,i2c_add,cif_chl,mclk_rate,is_front;
\r
160 u32 resolution,pwdn_info,powerup_sequence,orientation;
\r
162 u32 powerdown = INVALID_GPIO,power = INVALID_GPIO,reset = INVALID_GPIO;
\r
163 u32 af = INVALID_GPIO,flash = INVALID_GPIO;
\r
165 int pwr_active = INVALID_VALUE, rst_active = INVALID_VALUE, pwdn_active = INVALID_VALUE;
\r
166 struct rkcamera_platform_data *new_camera;
\r
167 new_camera = kzalloc(sizeof(struct rkcamera_platform_data),GFP_KERNEL);
\r
170 new_camera_head = new_camera;
\r
171 rk_camera_platform_data.register_dev_new = new_camera_head;
\r
172 new_camera_list = new_camera;
\r
175 new_camera_list->next_camera = new_camera;
\r
176 new_camera_list = new_camera;
\r
178 if (of_property_read_u32(cp, "flash_attach", &flash_attach)) {
\r
179 dprintk("%s:Get %s rockchip,flash_attach failed!\n",__func__, cp->name);
\r
181 if (of_property_read_u32(cp, "mir", &mir)) {
\r
182 dprintk("%s:Get %s rockchip,mir failed!\n",__func__, cp->name);
\r
184 if (of_property_read_u32(cp, "i2c_rata", &i2c_rata)) {
\r
185 dprintk("%s:Get %s rockchip,i2c_rata failed!\n",__func__, cp->name);
\r
187 if (of_property_read_u32(cp, "i2c_chl", &i2c_chl)) {
\r
188 dprintk("%s:Get %s rockchip,i2c_chl failed!\n",__func__, cp->name);
\r
190 if (of_property_read_u32(cp, "cif_chl", &cif_chl)) {
\r
191 dprintk("%s:Get %s rockchip,cif_chl failed!\n",__func__, cp->name);
\r
193 if (of_property_read_u32(cp, "mclk_rate", &mclk_rate)) {
\r
194 dprintk("%s:Get %s rockchip,mclk_rate failed!\n",__func__, cp->name);
\r
196 if (of_property_read_u32(cp, "is_front", &is_front)) {
\r
197 dprintk("%s:Get %s rockchip,is_front failed!\n",__func__, cp->name);
\r
199 if (of_property_read_u32(cp, "rockchip,powerdown", &powerdown)) {
\r
200 printk("%s:Get %s rockchip,powerdown failed!\n",__func__, cp->name);
\r
202 if (of_property_read_u32(cp, "pwdn_active", &pwdn_active)) {
\r
203 dprintk("%s:Get %s pwdn_active failed!\n",__func__, cp->name);
\r
205 if (of_property_read_u32(cp, "rockchip,power", &power)) {
\r
206 printk("%s:Get %s rockchip,power failed!\n",__func__, cp->name);
\r
208 if (of_property_read_u32(cp, "pwr_active", &pwr_active)) {
\r
209 dprintk("%s:Get %s pwr_active failed!\n",__func__, cp->name);
\r
211 if (of_property_read_u32(cp, "rockchip,reset", &reset)) {
\r
212 printk("%s:Get %s rockchip,reset failed!\n",__func__, cp->name);
\r
214 if (of_property_read_u32(cp, "rst_active", &rst_active)) {
\r
215 dprintk("%s:Get %s rst_active failed!\n",__func__, cp->name);
\r
217 if (of_property_read_u32(cp, "rockchip,af", &af)) {
\r
218 printk("%s:Get %s rockchip,af failed!\n",__func__, cp->name);
\r
220 if (of_property_read_u32(cp, "rockchip,flash", &flash)) {
\r
221 printk("%s:Get %s rockchip,flash failed!\n",__func__, cp->name);
\r
223 if (of_property_read_u32(cp, "i2c_add", &i2c_add)) {
\r
224 printk("%s:Get %s rockchip,i2c_add failed!\n",__func__, cp->name);
\r
226 if (of_property_read_u32(cp, "resolution", &resolution)) {
\r
227 printk("%s:Get %s rockchip,resolution failed!\n",__func__, cp->name);
\r
229 if (of_property_read_u32(cp, "pwdn_info", &pwdn_info)) {
\r
230 printk("%s:Get %s rockchip,pwdn_info failed!\n",__func__, cp->name);
\r
232 if (of_property_read_u32(cp, "powerup_sequence", &powerup_sequence)) {
\r
233 printk("%s:Get %s rockchip,powerup_sequence failed!\n",__func__, cp->name);
\r
235 if (of_property_read_u32(cp, "orientation", &orientation)) {
\r
236 printk("%s:Get %s rockchip,orientation failed!\n",__func__, cp->name);
\r
239 strcpy(new_camera->dev.i2c_cam_info.type, cp->name);
\r
240 new_camera->dev.i2c_cam_info.addr = i2c_add>>1;
\r
241 new_camera->dev.desc_info.host_desc.bus_id = RK29_CAM_PLATFORM_DEV_ID+cif_chl;/*yzm*/
\r
242 new_camera->dev.desc_info.host_desc.i2c_adapter_id = i2c_chl;/*yzm*/
\r
243 new_camera->dev.desc_info.host_desc.module_name = cp->name;/*const*/
\r
244 new_camera->dev.device_info.name = "soc-camera-pdrv";
\r
246 sprintf(new_camera->dev_name,"%s_%s",cp->name,"front");
\r
248 sprintf(new_camera->dev_name,"%s_%s",cp->name,"back");
\r
249 new_camera->dev.device_info.dev.init_name =(const char*)&new_camera->dev_name[0];
\r
250 new_camera->io.gpio_reset = reset;
\r
251 new_camera->io.gpio_powerdown = powerdown;
\r
252 new_camera->io.gpio_power = power;
\r
253 new_camera->io.gpio_af = af;
\r
254 new_camera->io.gpio_flash = flash;
\r
255 new_camera->io.gpio_flag = ((pwr_active&0x01)<<RK29_CAM_POWERACTIVE_BITPOS)|((rst_active&0x01)<<RK29_CAM_RESETACTIVE_BITPOS)|((pwdn_active&0x01)<<RK29_CAM_POWERDNACTIVE_BITPOS);
\r
256 new_camera->orientation = orientation;
\r
257 new_camera->resolution = resolution;
\r
258 new_camera->mirror = mir;
\r
259 new_camera->i2c_rate = i2c_rata;
\r
260 new_camera->flash = flash_attach;
\r
261 new_camera->pwdn_info = ((pwdn_info&0x10)|0x01);
\r
262 new_camera->powerup_sequence = powerup_sequence;
\r
263 new_camera->mclk_rate = mclk_rate;
\r
264 new_camera->of_node = cp;
\r
266 debug_printk( "******************* /n power = %x\n", power);
\r
267 debug_printk( "******************* /n powerdown = %x\n", powerdown);
\r
268 debug_printk( "******************* /n i2c_add = %x\n", new_camera->dev.i2c_cam_info.addr << 1);
\r
269 debug_printk( "******************* /n i2c_chl = %d\n", new_camera->dev.desc_info.host_desc.i2c_adapter_id);
\r
270 debug_printk( "******************* /n init_name = %s\n", new_camera->dev.device_info.dev.init_name);
\r
271 debug_printk( "******************* /n dev_name = %s\n", new_camera->dev_name);
\r
272 debug_printk( "******************* /n module_name = %s\n", new_camera->dev.desc_info.host_desc.module_name);
\r
274 new_camera_list->next_camera = NULL;
\r
278 static int rk_dts_cif_remove(struct platform_device *pdev)
\r
283 static int rk_dts_cif_probe(struct platform_device *pdev) /*yzm*/
\r
286 struct device *dev = &pdev->dev;
\r
288 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
\r
290 rk_camera_platform_data.cif_dev = &pdev->dev;
\r
292 err = of_address_to_resource(dev->of_node, 0, &rk_camera_resource_host_0[0]);
\r
294 printk(KERN_EMERG "Get register resource from %s platform device failed!",pdev->name);
\r
297 rk_camera_resource_host_0[0].flags = IORESOURCE_MEM;
\r
299 irq = irq_of_parse_and_map(dev->of_node, 0);
\r
301 printk(KERN_EMERG "Get irq resource from %s platform device failed!",pdev->name);
\r
304 rk_camera_resource_host_0[1].start = irq;
\r
305 rk_camera_resource_host_0[1].end = irq;
\r
306 rk_camera_resource_host_0[1].flags = IORESOURCE_IRQ;
\r
310 static int rk_cif_sensor_init(void)
\r
313 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
\r
314 platform_driver_register(&rk_cif_driver);
\r
316 platform_driver_register(&rk_sensor_driver);
\r
321 /************yzm**************end*/
\r
323 static int sensor_power_default_cb (struct rk29camera_gpio_res *res, int on)
\r
325 int camera_power = res->gpio_power;
\r
326 int camera_ioflag = res->gpio_flag;
\r
327 int camera_io_init = res->gpio_init;
\r
330 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
\r
333 if (camera_power != INVALID_GPIO) {
\r
334 if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
\r
336 /*gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));*/
\r
337 gpio_direction_output(camera_power,1);
\r
338 dprintk("%s PowerPin=%d ..PinLevel = %x",res->dev_name, camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
\r
341 /*gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));*/
\r
342 gpio_direction_output(camera_power,0);
\r
343 dprintk("%s PowerPin=%d ..PinLevel = %x",res->dev_name, camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
\r
346 ret = RK29_CAM_EIO_REQUESTFAIL;
\r
347 eprintk("%s PowerPin=%d request failed!", res->dev_name,camera_power);
\r
350 ret = RK29_CAM_EIO_INVALID;
\r
356 static int sensor_reset_default_cb (struct rk29camera_gpio_res *res, int on)
\r
358 int camera_reset = res->gpio_reset;
\r
359 int camera_ioflag = res->gpio_flag;
\r
360 int camera_io_init = res->gpio_init;
\r
363 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
\r
366 if (camera_reset != INVALID_GPIO) {
\r
367 if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
\r
369 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
\r
370 dprintk("%s ResetPin=%d ..PinLevel = %x",res->dev_name,camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
\r
372 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
\r
373 dprintk("%s ResetPin= %d..PinLevel = %x",res->dev_name, camera_reset, (((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
\r
376 ret = RK29_CAM_EIO_REQUESTFAIL;
\r
377 eprintk("%s ResetPin=%d request failed!", res->dev_name,camera_reset);
\r
380 ret = RK29_CAM_EIO_INVALID;
\r
386 static int sensor_powerdown_default_cb (struct rk29camera_gpio_res *res, int on)
\r
388 int camera_powerdown = res->gpio_powerdown;
\r
389 int camera_ioflag = res->gpio_flag;
\r
390 int camera_io_init = res->gpio_init;
\r
393 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
\r
396 if (camera_powerdown != INVALID_GPIO) {
\r
397 if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
\r
399 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
\r
400 dprintk("%s PowerDownPin=%d ..PinLevel = %x" ,res->dev_name,camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
\r
402 gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
\r
403 dprintk("%s PowerDownPin= %d..PinLevel = %x" ,res->dev_name, camera_powerdown, (((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
\r
406 ret = RK29_CAM_EIO_REQUESTFAIL;
\r
407 dprintk("%s PowerDownPin=%d request failed!", res->dev_name,camera_powerdown);
\r
410 ret = RK29_CAM_EIO_INVALID;
\r
416 static int sensor_flash_default_cb (struct rk29camera_gpio_res *res, int on)
\r
418 int camera_flash = res->gpio_flash;
\r
419 int camera_ioflag = res->gpio_flag;
\r
420 int camera_io_init = res->gpio_init;
\r
423 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
\r
426 if (camera_flash != INVALID_GPIO) {
\r
427 if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
\r
432 gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
\r
433 dprintk("%s FlashPin= %d..PinLevel = %x", res->dev_name, camera_flash, (((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
\r
439 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
\r
440 dprintk("%s FlashPin=%d ..PinLevel = %x", res->dev_name,camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
\r
446 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
\r
447 dprintk("%s FlashPin=%d ..PinLevel = %x", res->dev_name,camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
\r
453 eprintk("%s Flash command(%d) is invalidate", res->dev_name,on);
\r
458 ret = RK29_CAM_EIO_REQUESTFAIL;
\r
459 eprintk("%s FlashPin=%d request failed!", res->dev_name,camera_flash);
\r
462 ret = RK29_CAM_EIO_INVALID;
\r
467 static int sensor_afpower_default_cb (struct rk29camera_gpio_res *res, int on)
\r
470 int camera_af = res->gpio_af;
\r
472 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
\r
475 if (camera_af != INVALID_GPIO) {
\r
476 gpio_set_value(camera_af, on);
\r
482 static int _rk_sensor_io_init_(struct rk29camera_gpio_res *gpio_res,struct device_node *of_node)
\r
485 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
\r
486 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
\r
487 unsigned int camera_af = INVALID_GPIO,camera_ioflag;
\r
488 struct rk29camera_gpio_res *io_res;
\r
489 bool io_requested_in_camera;
\r
490 enum of_gpio_flags flags;
\r
492 struct rkcamera_platform_data *new_camera;/*yzm*/
\r
493 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
\r
496 camera_reset = gpio_res->gpio_reset;
\r
497 camera_power = gpio_res->gpio_power;
\r
498 camera_powerdown = gpio_res->gpio_powerdown;
\r
499 camera_flash = gpio_res->gpio_flash;
\r
500 camera_af = gpio_res->gpio_af;
\r
501 camera_ioflag = gpio_res->gpio_flag;
\r
502 gpio_res->gpio_init = 0;
\r
504 if (camera_power != INVALID_GPIO) {
\r
505 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$/ camera_power = %x\n", camera_power );
\r
507 camera_power = of_get_named_gpio_flags(of_node,"rockchip,power",0,&flags);/*yzm*/
\r
508 gpio_res->gpio_power = camera_power;/*yzm information back to the IO*/
\r
510 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$/ camera_power = %x\n", camera_power );
\r
512 ret = gpio_request(camera_power, "camera power");
\r
515 io_requested_in_camera = false;
\r
517 if (io_requested_in_camera==false) {
\r
519 new_camera = new_camera_head;
\r
520 while (new_camera != NULL) {
\r
521 io_res = &new_camera->io;
\r
522 if (io_res->gpio_init & RK29_CAM_POWERACTIVE_MASK) {
\r
523 if (io_res->gpio_power == camera_power)
\r
524 io_requested_in_camera = true;
\r
526 new_camera = new_camera->next_camera;
\r
531 if (io_requested_in_camera==false) {
\r
532 printk( "%s power pin(%d) init failed\n", gpio_res->dev_name,camera_power);
\r
533 goto _rk_sensor_io_init_end_;
\r
539 gpio_res->gpio_init |= RK29_CAM_POWERACTIVE_MASK;
\r
540 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
\r
541 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
\r
543 dprintk("%s power pin(%d) init success(0x%x)" ,gpio_res->dev_name,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
\r
547 if (camera_reset != INVALID_GPIO) {
\r
548 ret = gpio_request(camera_reset, "camera reset");
\r
550 io_requested_in_camera = false;
\r
551 for (i=0; i<RK_CAM_NUM; i++) {
\r
552 io_res = &rk_camera_platform_data.gpio_res[i];
\r
553 if (io_res->gpio_init & RK29_CAM_RESETACTIVE_MASK) {
\r
554 if (io_res->gpio_reset == camera_reset)
\r
555 io_requested_in_camera = true;
\r
559 if (io_requested_in_camera==false) {
\r
561 while (strstr(new_camera[i].dev_name,"end")==NULL) {
\r
562 io_res = &new_camera[i].io;
\r
563 if (io_res->gpio_init & RK29_CAM_RESETACTIVE_MASK) {
\r
564 if (io_res->gpio_reset == camera_reset)
\r
565 io_requested_in_camera = true;
\r
571 if (io_requested_in_camera==false) {
\r
572 eprintk("%s reset pin(%d) init failed" ,gpio_res->dev_name,camera_reset);
\r
573 goto _rk_sensor_io_init_end_;
\r
579 if (rk_camera_platform_data.iomux(camera_reset,dev) < 0) {
\r
581 eprintk("%s reset pin(%d) iomux init failed", gpio_res->dev_name,camera_reset);
\r
582 goto _rk_sensor_io_init_end_;
\r
585 gpio_res->gpio_init |= RK29_CAM_RESETACTIVE_MASK;
\r
586 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
\r
587 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
\r
589 dprintk("%s reset pin(%d) init success(0x%x)" ,gpio_res->dev_name,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
\r
593 if (camera_powerdown != INVALID_GPIO) {
\r
594 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$/ camera_powerdown = %x\n", camera_powerdown );
\r
596 camera_powerdown = of_get_named_gpio_flags(of_node,"rockchip,powerdown",0,&flags);/*yzm*/
\r
597 gpio_res->gpio_powerdown = camera_powerdown;/*yzm information back to the IO*/
\r
599 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$/ camera_powerdown = %x\n", camera_powerdown );
\r
600 ret = gpio_request(camera_powerdown, "camera powerdown");
\r
602 io_requested_in_camera = false;
\r
604 if (io_requested_in_camera==false) {
\r
606 new_camera = new_camera_head;
\r
607 while (new_camera != NULL) {
\r
608 io_res = &new_camera->io;
\r
609 if (io_res->gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
\r
610 if (io_res->gpio_powerdown == camera_powerdown)
\r
611 io_requested_in_camera = true;
\r
613 new_camera = new_camera->next_camera;
\r
617 if (io_requested_in_camera==false) {
\r
618 eprintk("%s powerdown pin(%d) init failed",gpio_res->dev_name,camera_powerdown);
\r
619 goto _rk_sensor_io_init_end_;
\r
624 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s(),iomux is ok\n", __FILE__, __LINE__,__FUNCTION__);
\r
626 gpio_res->gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
\r
627 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
\r
628 gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
\r
630 dprintk("%s powerdown pin(%d) init success(0x%x)" ,gpio_res->dev_name,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
\r
634 if (camera_flash != INVALID_GPIO) {
\r
635 ret = gpio_request(camera_flash, "camera flash");
\r
637 io_requested_in_camera = false;
\r
638 for (i=0; i<RK_CAM_NUM; i++) {
\r
639 io_res = &rk_camera_platform_data.gpio_res[i];
\r
640 if (io_res->gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
\r
641 if (io_res->gpio_powerdown == camera_powerdown)
\r
642 io_requested_in_camera = true;
\r
646 if (io_requested_in_camera==false) {
\r
648 while (strstr(new_camera[i].dev_name,"end")==NULL) {
\r
649 io_res = &new_camera[i].io;
\r
650 if (io_res->gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
\r
651 if (io_res->gpio_powerdown == camera_powerdown)
\r
652 io_requested_in_camera = true;
\r
658 ret = 0; //ddl@rock-chips.com : flash is only a function, sensor is also run;
\r
659 if (io_requested_in_camera==false) {
\r
660 eprintk("%s flash pin(%d) init failed",gpio_res->dev_name,camera_flash);
\r
661 goto _rk_sensor_io_init_end_;
\r
666 if (rk_camera_platform_data.iomux(camera_flash,dev) < 0) {
\r
667 printk("%s flash pin(%d) iomux init failed\n",gpio_res->dev_name,camera_flash);
\r
670 gpio_res->gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
\r
671 gpio_set_value(camera_flash, ((~camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS)); // falsh off
\r
672 gpio_direction_output(camera_flash, ((~camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
\r
674 dprintk("%s flash pin(%d) init success(0x%x)",gpio_res->dev_name, camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
\r
679 if (camera_af != INVALID_GPIO) {
\r
680 ret = gpio_request(camera_af, "camera af");
\r
682 io_requested_in_camera = false;
\r
683 for (i=0; i<RK_CAM_NUM; i++) {
\r
684 io_res = &rk_camera_platform_data.gpio_res[i];
\r
685 if (io_res->gpio_init & RK29_CAM_AFACTIVE_MASK) {
\r
686 if (io_res->gpio_af == camera_af)
\r
687 io_requested_in_camera = true;
\r
691 if (io_requested_in_camera==false) {
\r
693 while (strstr(new_camera[i].dev_name,"end")==NULL) {
\r
694 io_res = &new_camera[i].io;
\r
695 if (io_res->gpio_init & RK29_CAM_AFACTIVE_MASK) {
\r
696 if (io_res->gpio_af == camera_af)
\r
697 io_requested_in_camera = true;
\r
703 if (io_requested_in_camera==false) {
\r
704 eprintk("%s af pin(%d) init failed",gpio_res->dev_name,camera_af);
\r
705 goto _rk_sensor_io_init_end_;
\r
713 if (rk_camera_platform_data.iomux(camera_af,dev) < 0) {
\r
715 eprintk("%s af pin(%d) iomux init failed\n",gpio_res->dev_name,camera_af);
\r
716 goto _rk_sensor_io_init_end_;
\r
719 gpio_res->gpio_init |= RK29_CAM_AFACTIVE_MASK;
\r
720 //gpio_direction_output(camera_af, ((camera_ioflag&RK29_CAM_AFACTIVE_MASK)>>RK29_CAM_AFACTIVE_BITPOS));
\r
721 dprintk("%s af pin(%d) init success",gpio_res->dev_name, camera_af);
\r
727 _rk_sensor_io_init_end_:
\r
732 static int _rk_sensor_io_deinit_(struct rk29camera_gpio_res *gpio_res)
\r
734 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
\r
735 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO,camera_af = INVALID_GPIO;
\r
737 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
\r
740 camera_reset = gpio_res->gpio_reset;
\r
741 camera_power = gpio_res->gpio_power;
\r
742 camera_powerdown = gpio_res->gpio_powerdown;
\r
743 camera_flash = gpio_res->gpio_flash;
\r
744 camera_af = gpio_res->gpio_af;
\r
746 if (gpio_res->gpio_init & RK29_CAM_POWERACTIVE_MASK) {
\r
747 if (camera_power != INVALID_GPIO) {
\r
748 gpio_direction_input(camera_power);
\r
749 gpio_free(camera_power);
\r
753 if (gpio_res->gpio_init & RK29_CAM_RESETACTIVE_MASK) {
\r
754 if (camera_reset != INVALID_GPIO) {
\r
755 gpio_direction_input(camera_reset);
\r
756 gpio_free(camera_reset);
\r
760 if (gpio_res->gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
\r
761 if (camera_powerdown != INVALID_GPIO) {
\r
762 gpio_direction_input(camera_powerdown);
\r
763 gpio_free(camera_powerdown);
\r
767 if (gpio_res->gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
\r
768 if (camera_flash != INVALID_GPIO) {
\r
769 gpio_direction_input(camera_flash);
\r
770 gpio_free(camera_flash);
\r
773 if (gpio_res->gpio_init & RK29_CAM_AFACTIVE_MASK) {
\r
774 if (camera_af != INVALID_GPIO) {
\r
775 /* gpio_direction_input(camera_af);*/
\r
776 gpio_free(camera_af);
\r
779 gpio_res->gpio_init = 0;
\r
784 static int rk_sensor_io_init(void)
\r
786 static bool is_init = false;
\r
788 struct rkcamera_platform_data *new_camera;
\r
789 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
\r
797 if (sensor_ioctl_cb.sensor_power_cb == NULL)
\r
798 sensor_ioctl_cb.sensor_power_cb = sensor_power_default_cb;
\r
799 if (sensor_ioctl_cb.sensor_reset_cb == NULL)
\r
800 sensor_ioctl_cb.sensor_reset_cb = sensor_reset_default_cb;
\r
801 if (sensor_ioctl_cb.sensor_powerdown_cb == NULL)
\r
802 sensor_ioctl_cb.sensor_powerdown_cb = sensor_powerdown_default_cb;
\r
803 if (sensor_ioctl_cb.sensor_flash_cb == NULL)
\r
804 sensor_ioctl_cb.sensor_flash_cb = sensor_flash_default_cb;
\r
805 if (sensor_ioctl_cb.sensor_af_cb == NULL)
\r
806 sensor_ioctl_cb.sensor_af_cb = sensor_afpower_default_cb;
\r
808 /**********yzm*********/
\r
809 new_camera = new_camera_head;
\r
810 while(new_camera != NULL)
\r
812 if (_rk_sensor_io_init_(&new_camera->io,new_camera->of_node)<0)
\r
813 _rk_sensor_io_deinit_(&new_camera->io);
\r
814 new_camera = new_camera->next_camera;
\r
819 static int rk_sensor_io_deinit(int sensor)
\r
821 struct rkcamera_platform_data *new_camera;
\r
823 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
\r
825 new_camera = new_camera_head;
\r
826 while(new_camera != NULL)
\r
828 _rk_sensor_io_deinit_(&new_camera->io);
\r
829 new_camera = new_camera->next_camera;
\r
834 static int rk_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
\r
836 struct rk29camera_gpio_res *res = NULL;
\r
837 struct rkcamera_platform_data *new_cam_dev = NULL;
\r
838 struct rk29camera_platform_data* plat_data = &rk_camera_platform_data;
\r
839 int ret = RK29_CAM_IO_SUCCESS,i = 0;
\r
840 struct soc_camera_desc *dev_icl = NULL;/*yzm*/
\r
841 struct rkcamera_platform_data *new_camera;
\r
842 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
\r
845 new_camera = new_camera_head;
\r
846 while(new_camera != NULL)
\r
848 if (strcmp(new_camera->dev_name, dev_name(dev)) == 0) {
\r
849 res = (struct rk29camera_gpio_res *)&new_camera->io;
\r
850 new_cam_dev = &new_camera[i];
\r
851 dev_icl = &new_camera->dev.desc_info;/*yzm*/
\r
854 new_camera = new_camera->next_camera;;
\r
859 eprintk("%s is not regisiterd in rk29_camera_platform_data!!",dev_name(dev));
\r
860 ret = RK29_CAM_EIO_INVALID;
\r
861 goto rk_sensor_ioctrl_end;
\r
868 if (sensor_ioctl_cb.sensor_power_cb) {
\r
869 ret = sensor_ioctl_cb.sensor_power_cb(res, on);
\r
870 ret = (ret != RK29_CAM_EIO_INVALID)?ret:0; /* ddl@rock-chips.com: v0.1.1 */
\r
872 eprintk("sensor_ioctl_cb.sensor_power_cb is NULL");
\r
876 printk("ret: %d\n",ret);
\r
881 if (sensor_ioctl_cb.sensor_reset_cb) {
\r
882 ret = sensor_ioctl_cb.sensor_reset_cb(res, on);
\r
884 ret = (ret != RK29_CAM_EIO_INVALID)?ret:0;
\r
886 eprintk( "sensor_ioctl_cb.sensor_reset_cb is NULL");
\r
892 case Cam_PowerDown:
\r
894 if (sensor_ioctl_cb.sensor_powerdown_cb) {
\r
895 ret = sensor_ioctl_cb.sensor_powerdown_cb(res, on);
\r
897 eprintk( "sensor_ioctl_cb.sensor_powerdown_cb is NULL");
\r
905 if (sensor_ioctl_cb.sensor_flash_cb) {
\r
906 ret = sensor_ioctl_cb.sensor_flash_cb(res, on);
\r
908 eprintk( "sensor_ioctl_cb.sensor_flash_cb is NULL!");
\r
916 if (sensor_ioctl_cb.sensor_af_cb) {
\r
917 ret = sensor_ioctl_cb.sensor_af_cb(res, on);
\r
919 eprintk( "sensor_ioctl_cb.sensor_af_cb is NULL!");
\r
927 if (plat_data->sensor_mclk && dev_icl) {
\r
928 plat_data->sensor_mclk(dev_icl->host_desc.bus_id,(on!=0)?1:0,on);/*yzm*/
\r
930 eprintk( "%s(%d): sensor_mclk(%p) or dev_icl(%p) is NULL",
\r
931 __FUNCTION__,__LINE__,plat_data->sensor_mclk,dev_icl);
\r
938 eprintk("%s cmd(0x%x) is unknown!",__FUNCTION__, cmd);
\r
942 rk_sensor_ioctrl_end:
\r
946 static int rk_sensor_pwrseq(struct device *dev,int powerup_sequence, int on, int mclk_rate)
\r
949 int i,powerup_type;
\r
951 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
\r
954 for (i=0; i<8; i++) {
\r
957 powerup_type = SENSOR_PWRSEQ_GET(powerup_sequence,i);
\r
959 powerup_type = SENSOR_PWRSEQ_GET(powerup_sequence,(7-i));
\r
961 switch (powerup_type)
\r
963 case SENSOR_PWRSEQ_AVDD:
\r
964 case SENSOR_PWRSEQ_DOVDD:
\r
965 case SENSOR_PWRSEQ_DVDD:
\r
966 case SENSOR_PWRSEQ_PWR:
\r
968 ret = rk_sensor_ioctrl(dev,Cam_Power, on);
\r
970 eprintk("SENSOR_PWRSEQ_PWR failed");
\r
973 dprintk("SensorPwrSeq-power: %d",on);
\r
978 case SENSOR_PWRSEQ_HWRST:
\r
981 rk_sensor_ioctrl(dev,Cam_Reset, 1);
\r
983 ret = rk_sensor_ioctrl(dev,Cam_Reset, 1);
\r
985 ret |= rk_sensor_ioctrl(dev,Cam_Reset, 0);
\r
988 eprintk("SENSOR_PWRSEQ_HWRST failed");
\r
990 dprintk("SensorPwrSeq-reset: %d",on);
\r
995 case SENSOR_PWRSEQ_PWRDN:
\r
997 ret = rk_sensor_ioctrl(dev,Cam_PowerDown, !on);
\r
999 eprintk("SENSOR_PWRSEQ_PWRDN failed");
\r
1001 dprintk("SensorPwrSeq-power down: %d",!on);
\r
1006 case SENSOR_PWRSEQ_CLKIN:
\r
1008 ret = rk_sensor_ioctrl(dev,Cam_Mclk, (on?mclk_rate:on));
\r
1010 eprintk("SENSOR_PWRSEQ_CLKIN failed");
\r
1012 dprintk("SensorPwrSeq-clock: %d",on);
\r
1026 static int rk_sensor_power(struct device *dev, int on) /*icd->pdev*/
\r
1028 int powerup_sequence,mclk_rate;
\r
1030 struct rk29camera_platform_data* plat_data = &rk_camera_platform_data;
\r
1031 struct rk29camera_gpio_res *dev_io = NULL;
\r
1032 struct rkcamera_platform_data *new_camera=NULL, *new_device=NULL;
\r
1033 bool real_pwroff = true;
\r
1036 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
\r
1038 new_camera = plat_data->register_dev_new; /*new_camera[]*/
\r
1040 while (new_camera != NULL) {
\r
1042 if (new_camera->io.gpio_powerdown != INVALID_GPIO) {
\r
1043 gpio_direction_output(new_camera->io.gpio_powerdown,
\r
1044 ((new_camera->io.gpio_flag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
\r
1047 debug_printk( "new_camera->dev_name= %s \n", new_camera->dev_name); /*yzm*/
\r
1048 debug_printk( "dev_name(dev)= %s \n", dev_name(dev)); /*yzm*/
\r
1050 if (strcmp(new_camera->dev_name,dev_name(dev))) {
\r
1051 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i\n", __FILE__, __LINE__);
\r
1052 if (sensor_ioctl_cb.sensor_powerdown_cb && on)
\r
1054 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i\n", __FILE__, __LINE__);
\r
1055 sensor_ioctl_cb.sensor_powerdown_cb(&new_camera->io,1);
\r
1058 new_device = new_camera;
\r
1059 dev_io = &new_camera->io;
\r
1060 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i\n", __FILE__, __LINE__);/*yzm*/
\r
1061 if (!Sensor_Support_DirectResume(new_camera->pwdn_info))
\r
1062 real_pwroff = true;
\r
1064 real_pwroff = false;
\r
1066 new_camera = new_camera->next_camera;
\r
1069 if (new_device != NULL) {
\r
1070 powerup_sequence = new_device->powerup_sequence;
\r
1071 if ((new_device->mclk_rate == 24) || (new_device->mclk_rate == 48))
\r
1072 mclk_rate = new_device->mclk_rate*1000000;
\r
1074 mclk_rate = 24000000;
\r
1076 powerup_sequence = sensor_PWRSEQ_DEFAULT;
\r
1077 mclk_rate = 24000000;
\r
1081 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i\n", __FILE__, __LINE__);
\r
1082 rk_sensor_pwrseq(dev, powerup_sequence, on,mclk_rate);
\r
1084 if (real_pwroff) {
\r
1085 if (rk_sensor_pwrseq(dev, powerup_sequence, on,mclk_rate)<0) /* ddl@rock-chips.com: v0.1.5 */
\r
1088 /*ddl@rock-chips.com: all power down switch to Hi-Z after power off*/
\r
1089 new_camera = plat_data->register_dev_new;
\r
1090 while (new_camera != NULL) {
\r
1091 if (new_camera->io.gpio_powerdown != INVALID_GPIO) {
\r
1092 gpio_direction_input(new_camera->io.gpio_powerdown);
\r
1094 new_camera->pwdn_info |= 0x01;
\r
1095 new_camera = new_camera->next_camera;
\r
1099 rk_sensor_ioctrl(dev,Cam_PowerDown, !on);
\r
1101 rk_sensor_ioctrl(dev,Cam_Mclk, 0);
\r
1104 mdelay(10);/* ddl@rock-chips.com: v0.1.3 */
\r
1109 static int rk_sensor_reset(struct device *dev)
\r
1112 rk_sensor_ioctrl(dev,Cam_Reset,1);
\r
1114 rk_sensor_ioctrl(dev,Cam_Reset,0);
\r
1117 *ddl@rock-chips.com : the rest function invalidate, because this operate is put together in rk_sensor_power;
\r
1123 static int rk_sensor_powerdown(struct device *dev, int on)
\r
1126 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
\r
1128 return rk_sensor_ioctrl(dev,Cam_PowerDown,on);
\r
1131 int rk_sensor_register(void)
\r
1134 struct rkcamera_platform_data *new_camera;
\r
1137 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
\r
1139 new_camera = new_camera_head;
\r
1141 while (new_camera != NULL) {
\r
1142 if (new_camera->dev.i2c_cam_info.addr == INVALID_VALUE) {
\r
1144 KERN_ERR "%s(%d): new_camera[%d] i2c addr is invalidate!",
\r
1145 __FUNCTION__,__LINE__,i);
\r
1148 sprintf(new_camera->dev_name,"%s_%d",new_camera->dev.device_info.dev.init_name,i+3);
\r
1149 new_camera->dev.device_info.dev.init_name =(const char*)&new_camera->dev_name[0];
\r
1150 new_camera->io.dev_name =(const char*)&new_camera->dev_name[0];
\r
1151 if (new_camera->orientation == INVALID_VALUE) {
\r
1152 if (strstr(new_camera->dev_name,"back")) {
\r
1153 new_camera->orientation = 90;
\r
1155 new_camera->orientation = 270;
\r
1158 /* ddl@rock-chips.com: v0.1.3 */
\r
1159 if ((new_camera->fov_h <= 0) || (new_camera->fov_h>360))
\r
1160 new_camera->fov_h = 100;
\r
1162 if ((new_camera->fov_v <= 0) || (new_camera->fov_v>360))
\r
1163 new_camera->fov_v = 100;
\r
1165 new_camera->dev.desc_info.subdev_desc.power = rk_sensor_power;
\r
1166 new_camera->dev.desc_info.subdev_desc.powerdown = rk_sensor_powerdown;
\r
1167 new_camera->dev.desc_info.host_desc.board_info =&new_camera->dev.i2c_cam_info;
\r
1169 new_camera->dev.device_info.id = i+6;
\r
1170 new_camera->dev.device_info.dev.platform_data = &new_camera->dev.desc_info;
\r
1171 new_camera->dev.desc_info.subdev_desc.drv_priv = &rk_camera_platform_data;
\r
1173 platform_device_register(&(new_camera->dev.device_info));
\r
1175 new_camera = new_camera->next_camera;
\r
1180 #include "../../../drivers/media/video/rk30_camera.c"
\r