📄 camera_para.c
字号:
,{ 0xA1, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } // 32~35
,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 }
,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 }
,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 }
,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 }
,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 }
,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 }
,{ 0xFFFFFFFF, 0x00 } ,{ 0xFFFFFFFF, 0x00 } // 68~69
//------------------------Engineer mode---------------------------------
,{ 0x02, 0x80 } ,{ 0x01, 0x80 } ,{ 0x3A, 0x04 } ,{ 0x3D, 0x19 }
,{ 0xFFFFFFFF, ISP_DRIVING_8MA }
//------------------------Engineer mode---------------------------------
},
//------------------------CCT mode---------------------------------
{
{ 0x00, 0x00 } ,{ 0x69, 0x80 } ,{ 0x69, 0x80 }
}
//------------------------CCT mode---------------------------------
}
};
nvram_camera_para_struct camera_para;
// apply camera_para to ISP, AE&AWB and SENSOR
void apply_camera_para_to_reg(void)
{
// write camera_para to isp register
camera_para_to_isp();
// write camera_para to ae
camera_para_to_ae();
// write camera_para to sensor register
camera_para_to_sensor();
}
// update camera_para from ISP, AE&AWB and SENSOR
void update_camera_para_from_reg(void)
{
// update camera_para from isp register
isp_to_camera_para();
// update camera_para from ae
// no function call to update camera_para from ae, because ae firmware already update it automatically
// update camera_para from sensor register
sensor_to_camera_para();
}
// interface to apply camera_para to ISP, AE&AWB
void load_camera_para(void)
{
// write camera_para to isp register
camera_para_to_isp();
// write camera_para to ae
camera_para_to_ae();
}
void camera_para_to_isp(void)
{
kal_uint32 i;
*((volatile unsigned int *) (CAMERA_base + 20))=camera_para.ISP.reg[5];
for(i=13;i<53;i++)
{
*((volatile unsigned int *) (CAMERA_base + i*4))=camera_para.ISP.reg[i];
}
if(camera_para.PREDGAMMA.gamma_select!=0)
{
SET_GAMMA_B1(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][0]);
SET_GAMMA_B2(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][1]);
SET_GAMMA_B3(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][2]);
SET_GAMMA_B4(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][3]);
SET_GAMMA_B5(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][4]);
SET_GAMMA_B6(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][5]);
SET_GAMMA_B7(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][6]);
SET_GAMMA_B8(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][7]);
SET_GAMMA_B9(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][8]);
SET_GAMMA_B10(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][9]);
SET_GAMMA_B11(camera_para.PREDGAMMA.gamma[camera_para.PREDGAMMA.gamma_select-1][10]);
}
}
void isp_to_camera_para(void)
{
kal_uint32 i;
camera_para.ISP.reg[5] = *((volatile unsigned int *)(CAMERA_base+20));
for(i=13;i<53;i++)
{
camera_para.ISP.reg[i] = *((volatile unsigned int *)(CAMERA_base + i*4));
}
}
void camera_para_to_ae(void)
{
ae_set_expovalue(camera_para.AE.TargetLum);
ae_select_stepperev(camera_para.AE.StepperEV);
eShutter=camera_para.AE.iniShutter;
image_sensor_func->set_sensor_eshutter(eShutter);
}
nvram_camera_para_struct *get_camera_para(void)
{
return &camera_para;
}
void set_camera_para(const nvram_camera_para_struct *p_cam_para)
{
if( NULL != p_cam_para ) {
camera_para = *p_cam_para;
}
}
const nvram_camera_para_struct *get_default_camera_para(void)
{
return &CAMERA_PARA_DEFAULT_VALUE;
}
void init_camera_operation_para(camera_operation_para_struct *oper_data)
{
#ifdef HW_SCCB
SCCB_FREQ_STRUCT freq;
freq.TBUF = 0x3F;
freq.THDSTA = 0x3F;
freq.THDDTA = 0x3F;
freq.TLOW = 0x7F;
freq.THIGH = 0x7F;
freq.TSUSTO = 0x3F;
sccb_config(SCCB_HW_8BIT, OV7660_WRITE_ID, OV7660_READ_ID, &freq); // Default 300KHz
#else
sccb_config(SCCB_SW_8BIT, 0x42, 0x43, NULL);
#endif
oper_data->ae_mode=QUALITY_PRIORITY; /* QUALITY_PRIORITY, FRAME_RATE_PRIORITY */
oper_data->pregain_mode=ISP_SENSOR_BOTH; /* ISP_ONLY, c, ISP_SENSOR_BOTH */
oper_data->gain_priority=SENSOR_GAIN_PRIORITY ; /* ISP_GAIN_PRIORITY, SENSOR_GAIN_PRIORITY */
oper_data->enable_cap_shutter_compensate=KAL_TRUE; /* KAL_TRUE, KAL_FALSE */
oper_data->shutter_compensate_max=2*BASEGAIN;
oper_data->isp_pregain_max=2*BASEGAIN;
oper_data->sensor_pregain_max=4*BASEGAIN;
oper_data->pregain_compensate_max=2*BASEGAIN;
oper_data->preview_display_wait_frame=4;
oper_data->ae_smooth_upper_bound=140;
oper_data->ae_smooth_lower_bound=60;
oper_data->ae_awb_cal_period=4;
oper_data->ae_setting_gain_delay_frame=3;
oper_data->ae_setting_shut_delay_frame=1;
oper_data->ae_setting_cal_delay_frame=0;
oper_data->capture_delay_frame=1; /* Switch Preview to Capture */
oper_data->preview_delay_frame=1; /* Switch Capture to Preview */
oper_data->ae_lowlight_threshold=10; /* low light threshold of luminance for camera */
oper_data->ae_lowlight_off_threshold=15; /* low light turn off threshold of luminance for camera */
oper_data->ae_video_lowlight_threshold=10; /* low light threshold of luminance for video */
oper_data->ae_video_lowlight_off_threshold=15; /* low light turn off threshold of luminance for video */
}
void set_camera_mode_para(kal_uint8 mode)
{
kal_uint16 sensor_width,sensor_height;
image_sensor_func->get_sensor_size(&sensor_width,&sensor_height);
switch(mode)
{
case CAMERA_PARA_PREVIEW_MODE:
#if 0
DISABLE_Y_EDGE;
DISABLE_RGB_EDGE_GAIN;
#else
DISABLE_RGB_EDGE_GAIN;
DISABLE_Y_EDGE;
ENABLE_Y_LPF;
SET_Y_LPF_TYPE(2);
#endif
break;
case CAMERA_PARA_CAPTURE_MODE:
/* isp capture parameter */
#if 0
if(exposure_window.exposure_window_width<=(sensor_width>>2) && exposure_window.exposure_window_height <= (sensor_height>>2))
{
ENABLE_Y_EDGE;
DISABLE_RGB_EDGE_GAIN;
}
else if(exposure_window.exposure_window_width<=(sensor_width>>1) && exposure_window.exposure_window_height <= (sensor_height>>1))
{
DISABLE_Y_EDGE;
ENABLE_RGB_EDGE_GAIN;
}
else if(exposure_window.exposure_window_width<=sensor_width && exposure_window.exposure_window_height <=sensor_height)
{
ENABLE_Y_EDGE;
DISABLE_RGB_EDGE_GAIN;
}
#else
ENABLE_RGB_EDGE_GAIN;
ENABLE_Y_EDGE;
DISABLE_Y_LPF;
#endif
break;
case CAMERA_PARA_NIGHT_MODE:
/* isp night mode parameter */
#if 0
DISABLE_Y_EDGE;
ENABLE_RGB_EDGE_GAIN;
#endif
break;
case CAMERA_PARA_AUTO_LOWLIGHT_MODE:
/* isp auto lowlight parameter */
break;
case CAMERA_PARA_VIDEO_MODE:
/* parameter for video */
break;
case CAMERA_PARA_VIDEO_AUTO_LOWLIGHT_MODE:
/* parameter for video lowlight */
break;
}
}
// Power PIN Assignment
#define MODULE_POWER_PIN 3 // GPIO NO.
// Compact Image Sensor Module Power ON/OFF
void cis_module_power_on(kal_bool on)
{
if(on==KAL_TRUE)
{
GPIO_InitIO(1, MODULE_POWER_PIN);
GPIO_ModeSetup(MODULE_POWER_PIN, 0);
GPIO_WriteIO(1, MODULE_POWER_PIN);
}
else
{
GPIO_InitIO(1, MODULE_POWER_PIN);
GPIO_ModeSetup(MODULE_POWER_PIN, 0);
GPIO_WriteIO(0, MODULE_POWER_PIN);
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -