RK29 Camare 마이그레이션 - 코어 섹션

일.먼저 프로세스의 로드를 초기화합니다.
static struct platform_device *devices[] __initdata = {
#ifdef CONFIG_VIDEO_RK29
 	&rk29_device_camera,      /* [email protected] : camera support  */
 	#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
	#if (PMEM_CAM_SIZE > 0)
 	&android_pmem_cam_device,
	#endif
#endif
}

1.1 전면 3개, 후면 3개, 후면 각각 6개의 카메라를 지원합니다.00,01,02.앞면은 다음과 같이 1, 11, 12입니다.
#ifdef CONFIG_VIDEO_RK29
/*---------------- Camera Sensor Macro Define Begin  ------------------------*/
/*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
#define CONFIG_SENSOR_0 RK29_CAM_SENSOR_GC2015                      /* back camera sensor */ // 0 
#define CONFIG_SENSOR_IIC_ADDR_0 	    0x60
#define CONFIG_SENSOR_IIC_ADAPTER_ID_0    1
#define CONFIG_SENSOR_ORIENTATION_0       90
#define CONFIG_SENSOR_POWER_PIN_0         RK29_PIN5_PC3
#define CONFIG_SENSOR_RESET_PIN_0         RK29_PIN6_PA5
#define CONFIG_SENSOR_POWERDN_PIN_0       RK29_PIN0_PB2
#define CONFIG_SENSOR_FALSH_PIN_0         INVALID_GPIO
#define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_H
#define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
#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_480P_FPS_FIXED_0      15000
#define CONFIG_SENSOR_SVGA_FPS_FIXED_0      15000
#define CONFIG_SENSOR_720P_FPS_FIXED_0      30000

#define CONFIG_SENSOR_01  RK29_CAM_SENSOR_OV5642                   /* back camera sensor 1 */ // 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 */  // 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_GC0309                      /* front camera sensor */  // 0 
#define CONFIG_SENSOR_IIC_ADDR_1            0x42
#define CONFIG_SENSOR_IIC_ADAPTER_ID_1    1
#define CONFIG_SENSOR_ORIENTATION_1       270
#define CONFIG_SENSOR_POWER_PIN_1         RK29_PIN5_PC3	//IOMUX
#define CONFIG_SENSOR_RESET_PIN_1         RK29_PIN6_PA5  	//IOMUX
#define CONFIG_SENSOR_POWERDN_PIN_1       RK29_PIN0_PB4 	//IOMUX
#define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
#define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_H
#define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
#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_480P_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 */  // 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 */  // 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 

2, 초기화 작업:
static int rk29_sensor_io_init(void);
static int rk29_sensor_io_deinit(int sensor);
static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);

static struct rk29camera_platform_data rk29_camera_platform_data = {
    .io_init = rk29_sensor_io_init,
    .io_deinit = rk29_sensor_io_deinit,
    .sensor_ioctrl = rk29_sensor_ioctrl,
    .gpio_res = {
        {
            .gpio_reset = CONFIG_SENSOR_RESET_PIN_0,
            .gpio_power = CONFIG_SENSOR_POWER_PIN_0,
            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_0,
            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_0,
            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_0|CONFIG_SENSOR_RESETACTIVE_LEVEL_0|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0|CONFIG_SENSOR_FLASHACTIVE_LEVEL_0),
            .gpio_init = 0,            
            .dev_name = SENSOR_DEVICE_NAME_0,        
        }, {
        #ifdef CONFIG_SENSOR_01
            .gpio_reset = CONFIG_SENSOR_RESET_PIN_01,
            .gpio_power = CONFIG_SENSOR_POWER_PIN_01,
            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_01,
            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_01,
            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_01|CONFIG_SENSOR_RESETACTIVE_LEVEL_01|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_01|CONFIG_SENSOR_FLASHACTIVE_LEVEL_01),
            .gpio_init = 0,            
            .dev_name = SENSOR_DEVICE_NAME_01,
        #else
            .gpio_reset = INVALID_GPIO,
            .gpio_power = INVALID_GPIO,
            .gpio_powerdown = INVALID_GPIO,
            .gpio_flash = INVALID_GPIO,
            .gpio_flag = 0,
            .gpio_init = 0,            
            .dev_name = NULL,
        #endif
        }, {
        #ifdef CONFIG_SENSOR_02
            .gpio_reset = CONFIG_SENSOR_RESET_PIN_02,
            .gpio_power = CONFIG_SENSOR_POWER_PIN_02,
            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_02,
            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_02,
            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_02|CONFIG_SENSOR_RESETACTIVE_LEVEL_02|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_02|CONFIG_SENSOR_FLASHACTIVE_LEVEL_02),
            .gpio_init = 0,            
            .dev_name = SENSOR_DEVICE_NAME_02, 
        #else
            .gpio_reset = INVALID_GPIO,
            .gpio_power = INVALID_GPIO,
            .gpio_powerdown = INVALID_GPIO,
            .gpio_flash = INVALID_GPIO,
            .gpio_flag = 0,
            .gpio_init = 0,            
            .dev_name = NULL,
        #endif
        }, {
            .gpio_reset = CONFIG_SENSOR_RESET_PIN_1,
            .gpio_power = CONFIG_SENSOR_POWER_PIN_1,
            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_1,
            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_1,
            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_1|CONFIG_SENSOR_RESETACTIVE_LEVEL_1|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1|CONFIG_SENSOR_FLASHACTIVE_LEVEL_1),
            .gpio_init = 0,
            .dev_name = SENSOR_DEVICE_NAME_1,
        },{
        #ifdef CONFIG_SENSOR_11
            .gpio_reset = CONFIG_SENSOR_RESET_PIN_11,
            .gpio_power = CONFIG_SENSOR_POWER_PIN_11,
            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_11,
            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_11,
            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_11|CONFIG_SENSOR_RESETACTIVE_LEVEL_11|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_11|CONFIG_SENSOR_FLASHACTIVE_LEVEL_11),
            .gpio_init = 0,
            .dev_name = SENSOR_DEVICE_NAME_11,
        #else
            .gpio_reset = INVALID_GPIO,
            .gpio_power = INVALID_GPIO,
            .gpio_powerdown = INVALID_GPIO,
            .gpio_flash = INVALID_GPIO,
            .gpio_flag = 0,
            .gpio_init = 0,            
            .dev_name = NULL,
        #endif        
        }, {
        #ifdef CONFIG_SENSOR_12
            .gpio_reset = CONFIG_SENSOR_RESET_PIN_12,
            .gpio_power = CONFIG_SENSOR_POWER_PIN_12,
            .gpio_powerdown = CONFIG_SENSOR_POWERDN_PIN_12,
            .gpio_flash = CONFIG_SENSOR_FALSH_PIN_12,
            .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_12|CONFIG_SENSOR_RESETACTIVE_LEVEL_12|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_12|CONFIG_SENSOR_FLASHACTIVE_LEVEL_12),
            .gpio_init = 0,
            .dev_name = SENSOR_DEVICE_NAME_12,
        #else
            .gpio_reset = INVALID_GPIO,
            .gpio_power = INVALID_GPIO,
            .gpio_powerdown = INVALID_GPIO,
            .gpio_flash = INVALID_GPIO,
            .gpio_flag = 0,
            .gpio_init = 0,            
            .dev_name = NULL,
        #endif
        }
    },
	#ifdef CONFIG_VIDEO_RK29_WORK_IPP
	.meminfo = {
	    .name  = "camera_ipp_mem",
		.start = MEM_CAMIPP_BASE,
		.size   = MEM_CAMIPP_SIZE,
	},
	#endif
    .info = {
        {
            .dev_name = SENSOR_DEVICE_NAME_0,
            .orientation = CONFIG_SENSOR_ORIENTATION_0,  
        #ifdef CONFIG_SENSOR_01
	    },{
	        .dev_name = SENSOR_DEVICE_NAME_01,
            .orientation = CONFIG_SENSOR_ORIENTATION_01, 
        #else
        },{
	        .dev_name = NULL,
            .orientation = 0x00, 
        #endif
        #ifdef CONFIG_SENSOR_02
	    },{
	        .dev_name = SENSOR_DEVICE_NAME_02,
            .orientation = CONFIG_SENSOR_ORIENTATION_02, 
        #else
        },{
	        .dev_name = NULL,
            .orientation = 0x00, 
        #endif
        },{
            .dev_name = SENSOR_DEVICE_NAME_1,
            .orientation = CONFIG_SENSOR_ORIENTATION_1,
        #ifdef CONFIG_SENSOR_11 
        },{
            .dev_name = SENSOR_DEVICE_NAME_11,
            .orientation = CONFIG_SENSOR_ORIENTATION_11, 
        #else
        },{
	        .dev_name = NULL,
            .orientation = 0x00, 
        #endif
        #ifdef CONFIG_SENSOR_12
	    },{
	        .dev_name = SENSOR_DEVICE_NAME_12,
            .orientation = CONFIG_SENSOR_ORIENTATION_12, 
        #else
        },{
	        .dev_name = NULL,
            .orientation = 0x00, 
        #endif
	    }
	}
};

static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
static struct resource rk29_camera_resource[] = {
	[0] = {
		.start = RK29_VIP_PHYS,
		.end   = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
		.flags = IORESOURCE_MEM,
	},
	[1] = {
		.start = IRQ_VIP,
		.end   = IRQ_VIP,
		.flags = IORESOURCE_IRQ,
	}
};

/*platform_device : */
static struct platform_device rk29_device_camera = {
	.name		  = RK29_CAM_DRV_NAME,
	.id		  = RK29_CAM_PLATFORM_DEV_ID,               /* This is used to put cameras on this interface */
	.num_resources	  = ARRAY_SIZE(rk29_camera_resource),
	.resource	  = rk29_camera_resource,
	.dev            = {
		.dma_mask = &rockchip_device_camera_dmamask,
		.coherent_dma_mask = 0xffffffffUL,
		.platform_data  = &rk29_camera_platform_data,
	}
};

후면 카메라 로드 매개 변수:
static int rk29_sensor_powerdown(struct device *dev, int on)
{
	return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
}
static int rk29_sensor_power(struct device *dev, int on)
{
    if (!on)                        /* [email protected] : Ensure sensor enter standby or power off */
        rk29_sensor_powerdown(dev,1);
	rk29_sensor_ioctrl(dev,Cam_Power,on);    
    return 0;
}
static int rk29_sensor_reset(struct device *dev)
{
	rk29_sensor_ioctrl(dev,Cam_Reset,1);
	msleep(2);
	rk29_sensor_ioctrl(dev,Cam_Reset,0);
	return 0;
}

#if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
static struct i2c_board_info rk29_i2c_cam_info_0[] = {
	{
		I2C_BOARD_INFO(SENSOR_NAME_0, CONFIG_SENSOR_IIC_ADDR_0>>1)
	},
};

static struct soc_camera_link rk29_iclink_0 = {
	.bus_id		= RK29_CAM_PLATFORM_DEV_ID,
	.power		= rk29_sensor_power,
#if (CONFIG_SENSOR_RESET_PIN_0 != INVALID_GPIO)
    .reset      = rk29_sensor_reset,
#endif    
	.powerdown  = rk29_sensor_powerdown,
	.board_info	= &rk29_i2c_cam_info_0[0],
	.i2c_adapter_id	= CONFIG_SENSOR_IIC_ADAPTER_ID_0,
	.module_name	= SENSOR_NAME_0,
};

/*platform_device : soc-camera need  */
static struct platform_device rk29_soc_camera_pdrv_0 = {
	.name	= "soc-camera-pdrv",
	.id	= 0,
	.dev	= {
		.init_name = SENSOR_DEVICE_NAME_0,
		.platform_data = &rk29_iclink_0,
	},
};

선행 로드:
#if (CONFIG_SENSOR_IIC_ADDR_1 != 0x00)
static struct i2c_board_info rk29_i2c_cam_info_1[] = {
	{
		I2C_BOARD_INFO(SENSOR_NAME_1, CONFIG_SENSOR_IIC_ADDR_1>>1)
	},
};

static struct soc_camera_link rk29_iclink_1 = {
	.bus_id		= RK29_CAM_PLATFORM_DEV_ID,
	.power		= rk29_sensor_power,
#if (CONFIG_SENSOR_RESET_PIN_1 != INVALID_GPIO)
    .reset      = rk29_sensor_reset,
#endif  	
	.powerdown  = rk29_sensor_powerdown,
	.board_info	= &rk29_i2c_cam_info_1[0],
	.i2c_adapter_id	= CONFIG_SENSOR_IIC_ADAPTER_ID_1,
	.module_name	= SENSOR_NAME_1,
};

/*platform_device : soc-camera need  */
static struct platform_device rk29_soc_camera_pdrv_1 = {
	.name	= "soc-camera-pdrv",
	.id	= 1,
	.dev	= {
		.init_name = SENSOR_DEVICE_NAME_1,
		.platform_data = &rk29_iclink_1,
	},
};
#endif

진정한 인풋 초기화 작업은 실제 수요에 따라 인풋을 조작할 수 있다.
static int rk29_sensor_io_init(void);
static int rk29_sensor_io_deinit(int sensor);
static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
3.카메라 관련 기본 매개변수 구성:

static int sensor_power_default_cb (struct rk29camera_gpio_res *res, int on)
{
    int camera_power = res->gpio_power;
    int camera_ioflag = res->gpio_flag;
    int camera_io_init = res->gpio_init;
    int ret = 0;
    
    if (camera_power != INVALID_GPIO)  {
		if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
            if (on) {
            	gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
    			dprintk("%s..%s..PowerPin=%d ..PinLevel = %x   
",__FUNCTION__,res->dev_name, camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS)); msleep(10); } else { gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS)); dprintk("%s..%s..PowerPin=%d ..PinLevel = %x
",__FUNCTION__,res->dev_name, camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS)); } } else { ret = RK29_CAM_EIO_REQUESTFAIL; printk("%s..%s..PowerPin=%d request failed!
",__FUNCTION__,res->dev_name,camera_power); } } else { ret = RK29_CAM_EIO_INVALID; } return ret; } static int sensor_reset_default_cb (struct rk29camera_gpio_res *res, int on) { int camera_reset = res->gpio_reset; int camera_ioflag = res->gpio_flag; int camera_io_init = res->gpio_init; int ret = 0; if (camera_reset != INVALID_GPIO) { if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) { if (on) { gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS)); dprintk("%s..%s..ResetPin=%d ..PinLevel = %x
",__FUNCTION__,res->dev_name,camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS)); } else { gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS)); dprintk("%s..%s..ResetPin= %d..PinLevel = %x
",__FUNCTION__,res->dev_name, camera_reset, (((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS)); } } else { ret = RK29_CAM_EIO_REQUESTFAIL; printk("%s..%s..ResetPin=%d request failed!
",__FUNCTION__,res->dev_name,camera_reset); } } else { ret = RK29_CAM_EIO_INVALID; } return ret; } static int sensor_powerdown_default_cb (struct rk29camera_gpio_res *res, int on) { int camera_powerdown = res->gpio_powerdown; int camera_ioflag = res->gpio_flag; int camera_io_init = res->gpio_init; int ret = 0; if (camera_powerdown != INVALID_GPIO) { if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) { if (on) { gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS)); dprintk("%s..%s..PowerDownPin=%d ..PinLevel = %x
",__FUNCTION__,res->dev_name,camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS)); } else { gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS)); dprintk("%s..%s..PowerDownPin= %d..PinLevel = %x
",__FUNCTION__,res->dev_name, camera_powerdown, (((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS)); } } else { ret = RK29_CAM_EIO_REQUESTFAIL; dprintk("%s..%s..PowerDownPin=%d request failed!
",__FUNCTION__,res->dev_name,camera_powerdown); } } else { ret = RK29_CAM_EIO_INVALID; } return ret; } static int sensor_flash_default_cb (struct rk29camera_gpio_res *res, int on) { int camera_flash = res->gpio_flash; int camera_ioflag = res->gpio_flag; int camera_io_init = res->gpio_init; int ret = 0; if (camera_flash != INVALID_GPIO) { if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) { switch (on) { case Flash_Off: { gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS)); dprintk("
%s..%s..FlashPin= %d..PinLevel = %x
",__FUNCTION__,res->dev_name, camera_flash, (((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS)); break; } case Flash_On: { gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS)); dprintk("%s..%s..FlashPin=%d ..PinLevel = %x
",__FUNCTION__,res->dev_name,camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS)); break; } case Flash_Torch: { gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS)); dprintk("%s..%s..FlashPin=%d ..PinLevel = %x
",__FUNCTION__,res->dev_name,camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS)); break; } default: { printk("%s..%s..Flash command(%d) is invalidate
",__FUNCTION__,res->dev_name,on); break; } } } else { ret = RK29_CAM_EIO_REQUESTFAIL; printk("%s..%s..FlashPin=%d request failed!
",__FUNCTION__,res->dev_name,camera_flash); } } else { ret = RK29_CAM_EIO_INVALID; } return ret; } static void rk29_sensor_fps_get(int idx, unsigned int *val, int w, int h) { switch (idx) { case 0: { if ((w==176) && (h==144)) { *val = CONFIG_SENSOR_QCIF_FPS_FIXED_0; #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_0 } else if ((w==240) && (h==160)) { *val = CONFIG_SENSOR_240X160_FPS_FIXED_0; #endif } else if ((w==320) && (h==240)) { *val = CONFIG_SENSOR_QVGA_FPS_FIXED_0; } else if ((w==352) && (h==288)) { *val = CONFIG_SENSOR_CIF_FPS_FIXED_0; } else if ((w==640) && (h==480)) { *val = CONFIG_SENSOR_VGA_FPS_FIXED_0; } else if ((w==720) && (h==480)) { *val = CONFIG_SENSOR_480P_FPS_FIXED_0; } else if ((w==1280) && (h==720)) { *val = CONFIG_SENSOR_720P_FPS_FIXED_0; } break; } #ifdef CONFIG_SENSOR_01 case 1: { if ((w==176) && (h==144)) { *val = CONFIG_SENSOR_QCIF_FPS_FIXED_01; #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_01 } else if ((w==240) && (h==160)) { *val = CONFIG_SENSOR_240X160_FPS_FIXED_01; #endif } else if ((w==320) && (h==240)) { *val = CONFIG_SENSOR_QVGA_FPS_FIXED_01; } else if ((w==352) && (h==288)) { *val = CONFIG_SENSOR_CIF_FPS_FIXED_01; } else if ((w==640) && (h==480)) { *val = CONFIG_SENSOR_VGA_FPS_FIXED_01; } else if ((w==720) && (h==480)) { *val = CONFIG_SENSOR_480P_FPS_FIXED_01; } else if ((w==1280) && (h==720)) { *val = CONFIG_SENSOR_720P_FPS_FIXED_01; } break; } #endif #ifdef CONFIG_SENSOR_02 case 2: { if ((w==176) && (h==144)) { *val = CONFIG_SENSOR_QCIF_FPS_FIXED_02; #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_02 } else if ((w==240) && (h==160)) { *val = CONFIG_SENSOR_240X160_FPS_FIXED_02; #endif } else if ((w==320) && (h==240)) { *val = CONFIG_SENSOR_QVGA_FPS_FIXED_02; } else if ((w==352) && (h==288)) { *val = CONFIG_SENSOR_CIF_FPS_FIXED_02; } else if ((w==640) && (h==480)) { *val = CONFIG_SENSOR_VGA_FPS_FIXED_02; } else if ((w==720) && (h==480)) { *val = CONFIG_SENSOR_480P_FPS_FIXED_02; } else if ((w==1280) && (h==720)) { *val = CONFIG_SENSOR_720P_FPS_FIXED_02; } break; } #endif case 3: { if ((w==176) && (h==144)) { *val = CONFIG_SENSOR_QCIF_FPS_FIXED_1; #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_1 } else if ((w==240) && (h==160)) { *val = CONFIG_SENSOR_240X160_FPS_FIXED_1; #endif } else if ((w==320) && (h==240)) { *val = CONFIG_SENSOR_QVGA_FPS_FIXED_1; } else if ((w==352) && (h==288)) { *val = CONFIG_SENSOR_CIF_FPS_FIXED_1; } else if ((w==640) && (h==480)) { *val = CONFIG_SENSOR_VGA_FPS_FIXED_1; } else if ((w==720) && (h==480)) { *val = CONFIG_SENSOR_480P_FPS_FIXED_1; } else if ((w==1280) && (h==720)) { *val = CONFIG_SENSOR_720P_FPS_FIXED_1; } break; } #ifdef CONFIG_SENSOR_11 case 4: { if ((w==176) && (h==144)) { *val = CONFIG_SENSOR_QCIF_FPS_FIXED_11; #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_11 } else if ((w==240) && (h==160)) { *val = CONFIG_SENSOR_240X160_FPS_FIXED_11; #endif } else if ((w==320) && (h==240)) { *val = CONFIG_SENSOR_QVGA_FPS_FIXED_11; } else if ((w==352) && (h==288)) { *val = CONFIG_SENSOR_CIF_FPS_FIXED_11; } else if ((w==640) && (h==480)) { *val = CONFIG_SENSOR_VGA_FPS_FIXED_11; } else if ((w==720) && (h==480)) { *val = CONFIG_SENSOR_480P_FPS_FIXED_11; } else if ((w==1280) && (h==720)) { *val = CONFIG_SENSOR_720P_FPS_FIXED_11; } break; } #endif #ifdef CONFIG_SENSOR_12 case 5: { if ((w==176) && (h==144)) { *val = CONFIG_SENSOR_QCIF_FPS_FIXED_12; #ifdef CONFIG_SENSOR_240X160_FPS_FIXED_12 } else if ((w==240) && (h==160)) { *val = CONFIG_SENSOR_240X160_FPS_FIXED_12; #endif } else if ((w==320) && (h==240)) { *val = CONFIG_SENSOR_QVGA_FPS_FIXED_12; } else if ((w==352) && (h==288)) { *val = CONFIG_SENSOR_CIF_FPS_FIXED_12; } else if ((w==640) && (h==480)) { *val = CONFIG_SENSOR_VGA_FPS_FIXED_12; } else if ((w==720) && (h==480)) { *val = CONFIG_SENSOR_480P_FPS_FIXED_12; } else if ((w==1280) && (h==720)) { *val = CONFIG_SENSOR_720P_FPS_FIXED_12; } break; } #endif default: printk(KERN_ERR"rk29_cam_io: sensor-%d have not been define in board file!",idx); } }
이 안에는 그림 사이즈, 해상도 등 설정이 포함되어 있다.
4. 구체적인 카메라 레지스터 구성:
우선: make menuconfig
           Device Drivers------>
Multimedia support ----->
Video capture adapters ----->
GC0309와 같은 적절한 Camera 드라이브 선택
그리고 구체적인 수요에 따라 gc0309까지.c 안에 수첩에 따라 레지스터를 설정합니다.
주로 1.1 안의 전치와 후치 카메라의 인덱스, 주소, 이름, 그리고 일부 파라미터를 수정한다.
2와 3에서 초기화된 설정

좋은 웹페이지 즐겨찾기