static __s32 camera_same_i2c_id_detect(__camera_detector_t *camera_detector, 
                                                  __camera_list_t *camera_list,
                                                  __u32 camera_list_size)
{	
        __u32 i, j;
	 __u32 camera_detected = 0;
        __s32 ret = 0;

        detect_print("camera_same_i2c_id_detect!!\n");

        for (i = 0; i < camera_detector->num; i++) {
                for (j = 0; j < camera_list_size; j++) {
                    if (camera_list[j].need_detect) {
						
			    camera_stby_on_sensor(j,&camera_detector->camera[0]);
			    camera_stby_on_sensor(j,&camera_detector->camera[1]);
                        camera_list[j].pwr_on(j, &camera_detector->camera[i]);
                        ret = camera_list[j].detect(j, camera_detector->camera[i].i2c_adap);
                        if (ret == 0) {
				//camera_list[j].need_detect=false;
				camera_detected++;
				camera_list[j].pwr_off(j, &camera_detector->camera[i]);
				strcpy(camera_detector->camera[i].name, camera_list[j].name);
				camera_detector->camera[i].i2c_addr = camera_list[j].i2c_addr;
				 break;

				
                        }
                    }
                }
        }
        if (camera_detector->num != camera_detected)  {
                camera_err("detect camera fail in func: camera_same_i2c_id_detect !!\n");
        
                return -EDETECTFAIL;
        }
    detect_print("camera_detector->camera[0].name=%s,camera_detector->camera[1].name=%s\n",camera_detector->camera[0].name,camera_detector->camera[1].name);
    return 0;
}
Example #2
0
static __s32 camera_same_i2c_id_detect(__camera_detector_t *camera_detector, 
                                                  __camera_list_t *camera_list,
                                                  __u32 camera_list_size)
{	
    __u32 i, j;
	__u32 camera_detected = 0;
    __s32 ret = 0;

    detect_print("camera_same_i2c_id_detect!!\n");
    detect_print("camera_detector->num = %d,camera_list_size = %d!!\n",camera_detector->num,camera_list_size);

    for (i = 0; i < camera_detector->num; i++) {
        for (j = 0; j < camera_list_size; j++) {
	        if (camera_list[j].need_detect) {
			    camera_stby_on_sensor(j,&camera_detector->camera[0]);
			    camera_stby_on_sensor(j,&camera_detector->camera[1]);
                camera_list[j].pwr_on(j, &camera_detector->camera[i]);
                ret = camera_list[j].detect(j, camera_detector->camera[i].i2c_adap);
                if (ret == 0) {
					//camera_list[j].need_detect=false;
					camera_detected++;
                	//camera_list[j].pwr_off(j, &camera_detector->camera[i]);
					strcpy(camera_detector->camera[i].name, camera_list[j].name);
					camera_detector->camera[i].i2c_addr = camera_list[j].i2c_addr;
					if(strcmp(camera_detector->camera[i].name,"gc2035") == 0 )
					camera_detector->camera[i].i2c_addr=0x88;
					break;
				}
	        }
        }
    }
	
	for (i = 0; i < camera_detector->num; i++) {
		unsigned int a,b,c;
		a=b=c=0;
		if(camera_detector->camera[i].iovdd) {
			while(regulator_is_enabled(camera_detector->camera[i].iovdd))
			{
				a++;
				regulator_disable(camera_detector->camera[i].iovdd);
				//printk("cam[%d]iovdd count=%d\n",i,a);
				if(a>100)
					break;
			}
			regulator_put(camera_detector->camera[i].iovdd);
		}
		if(camera_detector->camera[i].avdd) {
			while(regulator_is_enabled(camera_detector->camera[i].avdd))
			{
				b++;
				regulator_disable(camera_detector->camera[i].avdd);
				//printk("cam[%d]avdd count=%d\n",i,b);
				if(b>100)
					break;
			}
			regulator_put(camera_detector->camera[i].avdd);
		}
		if(camera_detector->camera[i].dvdd) {
			while(regulator_is_enabled(camera_detector->camera[i].dvdd))
			{
				c++;
				regulator_disable(camera_detector->camera[i].dvdd);
				//printk("cam[%d]dvdd count=%d\n",i,c);
				if(c>100)
					break;
			}
			regulator_put(camera_detector->camera[i].dvdd);
		}
	}
    
    if (camera_detector->num != camera_detected)  {
        camera_err("detect camera fail in func: camera_same_i2c_id_detect !!\n");
        return -EDETECTFAIL;
    }
	
	detect_print("camera_detector->camera[0].name=%s,camera_detector->camera[1].name=%s\n",camera_detector->camera[0].name,camera_detector->camera[1].name);

	return 0;
}