📄 isp_if.c
字号:
isp_preview_config_data.cam_focus_cb(0xFF);
af_operation_state=AF_FREEZE_STATE;
}
}
}
#endif
if ((image_setting_index!=0)&&(isp_operation_state!=ISP_STANDBY_STATE)&&(stack_query_boot_mode()!=FACTORY_BOOT))
background_image_setting();
if(wait_first_frame_flag==KAL_TRUE)
{
isp_preview_frame++;
if(isp_preview_frame==camera_oper_data.preview_delay_frame)
{
kal_set_eg_events(camera_isp_event_id,CAMERA_ISP_VD_READY_EVENT,KAL_OR);
wait_first_frame_flag=KAL_FALSE;
}
}
else
kal_set_eg_events(camera_isp_event_id,CAMERA_ISP_VD_READY_EVENT,KAL_OR);
}
IRQUnmask(IRQ_CAMERA_CODE);
#else /* !(YUV_SENSOR_SUPPORT) */
#if (defined(MT6219))
if (isp_int_status & ISP_INT_FRAME_READY)
{
if (isp_operation_state==ISP_PREVIEW_STATE)
{
if (isp_preview_config_data.cam_preview_cb!=0)
{
if ((ae_count==camera_oper_data.ae_setting_shut_delay_frame)&&
(ae_enable_flag==ISP_ON)&&(ae_awb_cal_complete==1))
image_sensor_func->set_sensor_eshutter((kal_uint16)eShutter);
if ((ae_count==camera_oper_data.ae_setting_gain_delay_frame)&&(ae_awb_cal_complete==1))
{
if(ae_enable_flag==ISP_ON)
ae_set_pregain(pregain);
if(awb_enable_flag==ISP_ON)
awb_set_gain();
#if (defined(MT6219))
/* Flare */
if((camera_oper_data.flare_camera_enable==KAL_TRUE)&&(isp_preview_config_data.image_effect==0))
{
SET_AWB_R_GAIN(flare_gain);
SET_AWB_G_GAIN(flare_gain);
SET_AWB_B_GAIN(flare_gain);
SET_GAMMA_RGB_FLARE_R(flare_offset);
SET_GAMMA_RGB_FLARE_G(flare_offset);
SET_GAMMA_RGB_FLARE_B(flare_offset);
SET_GAMMA_RGB_FLARE_SIGN_R_HIGH;
SET_GAMMA_RGB_FLARE_SIGN_G_HIGH;
SET_GAMMA_RGB_FLARE_SIGN_B_HIGH;
}
#endif
}
if ((ae_count==camera_oper_data.ae_setting_cal_delay_frame)&&(ae_awb_cal_complete==1))
{
if (isp_first_preview_frame==KAL_TRUE)
isp_preview_2a_enable=1;
else if(wait_first_frame_flag==KAL_FALSE)
{
#if (defined(MT6219))
if((camera_oper_data.flare_camera_enable==KAL_TRUE)&&(isp_preview_config_data.image_effect==0))
{
get_histogram_info(hist_idx);
hist_idx++;
hist_idx%=3;
}
#endif
ae_awb_cal_complete=0;
isp_preview_config_data.cam_preview_cb(0);
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
}
if(ae_awb_cal_complete==1)
{
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
}
/* Auto Low Light Swith */
if((isp_preview_config_data.image_effect==0) &&(isp_preview_config_data.night_mode==KAL_FALSE)
&&(ae_enable_flag==ISP_ON)&&(stack_query_boot_mode()!=FACTORY_BOOT))
{ /* FACTORY_BOOT for CCT */
if(avglum<camera_oper_data.ae_lowlight_threshold)
set_camera_mode_para(CAMERA_PARA_AUTO_LOWLIGHT_MODE);
else if(avglum>camera_oper_data.ae_lowlight_off_threshold)
set_camera_mode_para(CAMERA_PARA_PREVIEW_MODE);
}
}
else if (isp_operation_state==ISP_MPEG4_ENCODE_STATE)
{
if (mpeg4_encode_data.cam_encode_cb!=0)
{
if ((ae_count==camera_oper_data.ae_setting_shut_delay_frame)&&
(ae_enable_flag==ISP_ON)&&(ae_awb_cal_complete==1))
image_sensor_func->set_sensor_eshutter((kal_uint16)eShutter);
if ((ae_count==camera_oper_data.ae_setting_gain_delay_frame)&&(ae_awb_cal_complete==1))
{
if(ae_enable_flag==ISP_ON)
ae_set_pregain(pregain);
if(awb_enable_flag==ISP_ON)
awb_set_gain();
#if (defined(MT6219))
/* Flare */
if((camera_oper_data.flare_video_enable==KAL_TRUE)&&(isp_preview_config_data.image_effect==0))
{
SET_AWB_R_GAIN(flare_gain);
SET_AWB_G_GAIN(flare_gain);
SET_AWB_B_GAIN(flare_gain);
SET_GAMMA_RGB_FLARE_R(flare_offset);
SET_GAMMA_RGB_FLARE_G(flare_offset);
SET_GAMMA_RGB_FLARE_B(flare_offset);
SET_GAMMA_RGB_FLARE_SIGN_R_HIGH;
SET_GAMMA_RGB_FLARE_SIGN_G_HIGH;
SET_GAMMA_RGB_FLARE_SIGN_B_HIGH;
}
#endif
}
if ((ae_count==camera_oper_data.ae_setting_cal_delay_frame)&&(ae_awb_cal_complete==1))
{
if (isp_first_preview_frame==KAL_TRUE)
isp_preview_2a_enable=1;
else if(wait_first_frame_flag==KAL_FALSE)
{
#if (defined(MT6219))
if((camera_oper_data.flare_video_enable==KAL_TRUE)&&(isp_preview_config_data.image_effect==0))
{
get_histogram_info(hist_idx);
hist_idx++;
hist_idx%=3;
}
#endif
ae_awb_cal_complete=0;
mpeg4_encode_data.cam_encode_cb(0);
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
}
if(ae_awb_cal_complete==1)
{
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
}
/* Auto Low Light Switch */
if((isp_preview_config_data.image_effect==0) &&(isp_preview_config_data.night_mode==KAL_FALSE)
&&(ae_enable_flag==ISP_ON))
{
if(avglum<camera_oper_data.ae_video_lowlight_threshold)
set_camera_mode_para(CAMERA_PARA_VIDEO_AUTO_LOWLIGHT_MODE);
else if(avglum>camera_oper_data.ae_video_lowlight_off_threshold)
set_camera_mode_para(CAMERA_PARA_VIDEO_MODE);
}
}
#if (defined(WEBCAM_SUPPORT))
else if(usbvideo_cam_operation_state==USBVIDEO_CAM_PREVIEW_CHECK_STATE)
{ // Webcam AE/AWB
if (g_usbvideo_camera_data.usbvideo_cam_preview_cb!=0)
{
if ((ae_count==camera_oper_data.ae_setting_shut_delay_frame)&&
(ae_enable_flag==ISP_ON)&&(ae_awb_cal_complete==1))
image_sensor_func->set_sensor_eshutter((kal_uint16)eShutter);
if ((ae_count==camera_oper_data.ae_setting_gain_delay_frame)&&(ae_awb_cal_complete==1))
{
if(ae_enable_flag==ISP_ON)
ae_set_pregain(pregain);
if(awb_enable_flag==ISP_ON)
awb_set_gain();
}
if ((ae_count==camera_oper_data.ae_setting_cal_delay_frame)&&(ae_awb_cal_complete==1))
{
if(wait_first_frame_flag==KAL_FALSE)
{
ae_awb_cal_complete=0;
g_usbvideo_camera_data.usbvideo_cam_preview_cb(0);
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
}
if(ae_awb_cal_complete==1)
{
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
}
if(usbvideo_attr_setting_PU_index!=0)
usbvideo_camera_effect_background_setting_attr();
}
#endif //END_OF_WEBCAM_SUPPORT
if(wait_first_frame_flag==KAL_TRUE)
{
isp_preview_frame++;
if(isp_preview_frame==camera_oper_data.preview_delay_frame)
{
kal_set_eg_events(camera_isp_event_id,CAMERA_ISP_FRAME_READY_EVENT,KAL_OR);
wait_first_frame_flag=KAL_FALSE;
}
}
else
kal_set_eg_events(camera_isp_event_id,CAMERA_ISP_FRAME_READY_EVENT,KAL_OR);
if ((image_setting_index!=0)&&(isp_operation_state!=ISP_STANDBY_STATE)&&(stack_query_boot_mode()!=FACTORY_BOOT))
background_image_setting();
IRQUnmask(IRQ_CAMERA_CODE);
}
#else /* !(defined(MT6219)) */
if (isp_int_status & ISP_INT_FRAME_READY)
{
if ((image_setting_index!=0)&&(isp_operation_state!=ISP_STANDBY_STATE)&&(stack_query_boot_mode()!=FACTORY_BOOT))
background_image_setting();
IRQUnmask(IRQ_CAMERA_CODE);
}
if ((isp_int_status & ISP_INT_VD_DONE)||(isp_int_status & ISP_INT_TG_DONE))
{
if ((isp_operation_state==ISP_PREVIEW_STATE)||(isp_operation_state==ISP_CAPTURE_BARCODE_STATE))
{
if (cam_preview_cb!=0)
{
if ((ae_count==camera_oper_data.ae_setting_shut_delay_frame)&&(ae_awb_cal_complete==1)
&&(ae_enable_flag==ISP_ON))
image_sensor_func->set_sensor_eshutter((kal_uint16)eShutter);
if ((ae_count==camera_oper_data.ae_setting_sensor_gain_delay_frame)&&(ae_awb_cal_complete==1))
{
if(ae_enable_flag==ISP_ON)
image_sensor_func->set_sensor_gain(sensor_pregain);
}
if ((ae_count==camera_oper_data.ae_setting_gain_delay_frame)&&(ae_awb_cal_complete==1))
{
if(ae_enable_flag==ISP_ON)
ae_set_isp_pregain();
if(awb_enable_flag==ISP_ON)
awb_set_gain();
if((isp_preview_config_data.image_effect==CAM_EFFECT_ENC_NORMAL)&&(stack_query_boot_mode()!=FACTORY_BOOT))
set_anti_low_light_para(AE_INDEX);
}
if ((ae_count==camera_oper_data.ae_setting_cal_delay_frame)&&(ae_awb_cal_complete==1))
{
#if (defined(MT6226)||defined(MT6226M)||defined(MT6227))
if(ae_counting_flag==KAL_TRUE) //Avoid ae get accumulation frame
#else // MT6228||MT6229
if(AE_FRAME_COUNT==1) //Avoid ae get accumulation frame
#endif
{
if (isp_first_preview_frame==KAL_TRUE)
isp_preview_2a_enable=1;
else if(wait_first_frame_flag==KAL_FALSE)
{
ae_awb_cal_complete=0;
cam_preview_cb(0);
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
ae_counting_flag=KAL_TRUE;
}
else
ae_counting_flag=KAL_FALSE;
}
if((ae_awb_cal_complete==1)&&
(!((ae_count==camera_oper_data.ae_setting_cal_delay_frame)&&(ae_counting_flag==KAL_FALSE))) )
{ /* cal complete && not wait hw ae count */
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
}
#if (defined(AF_SUPPORT))
if((dsc_status.af.trigger==CAM_AF_ONE_TIME)||(dsc_status.af.trigger==CAM_AF_CONTINUE))
{
if(avglum<camera_oper_data.ae_lowlight_threshold)
{
if(stack_query_boot_mode()!=FACTORY_BOOT)
set_camera_mode_para(CAMERA_PARA_AF_LOWLIGHT_MODE);
set_af_proc_para(dsc_status.af.mode,KAL_TRUE);
}
else if(avglum>camera_oper_data.ae_lowlight_off_threshold)
{
if(stack_query_boot_mode()!=FACTORY_BOOT)
set_camera_mode_para(CAMERA_PARA_AF_NORMAL_MODE);
set_af_proc_para(dsc_status.af.mode,KAL_FALSE);
}
}
#endif
#if (defined(AF_SUPPORT))
if(dsc_status.af.mode==CAM_AF_MANUAL_MODE) /* Manual Focus */
{
if(dsc_status.af.mfdir == CAM_FOCUS_FORWARD_CONTINUE)
lens_func->lens_af_step_cw(af_oper_data.manual_focus_step);
else if(dsc_status.af.mfdir == CAM_FOCUS_BACKWARD_CONTINUE)
lens_func->lens_af_step_ccw(af_oper_data.manual_focus_step);
}
else /* Auto Focus */
{
if (AF_release_delay<af_oper_data.AF_count_release)//delay check for AF release before AF press
{
AF_release_delay++;
}
else//AF_release_delay>=AF_count_release
{
if ((dsc_status.af.trigger==CAM_AF_ONE_TIME)||(dsc_status.af.trigger==CAM_AF_CONTINUE))//AF key press
{
if(ae_enable_flag==ISP_ON)
{
/* if AE stable & AE, AWB callback end, then w/o needing to wait for set gain frame */
if ((AE_INDEX_C==AE_INDEX)&&(ae_awb_cal_complete==1))//stable AE & AE callback end
{
if (af_operation_state==AF_COLLECT_STATE)//first AF state
{
ae_enable_flag=ISP_OFF;
awb_enable_flag=ISP_OFF;
}
}
}
else if ((ae_enable_flag==ISP_OFF)&&(awb_enable_flag==ISP_OFF))//AE, AWB disable
{
if (af_operation_state==AF_FREEZE_STATE)//AF freeze state return from AF callback
{
af_count = af_oper_data.AF_count_max;
ae_enable_flag=ae_enable_flag_backup;
awb_enable_flag=awb_enable_flag_backup;
}
}
if((ae_enable_flag==ISP_OFF)&&(awb_enable_flag==ISP_OFF))//AE, AWB disable
{
/* prevent AF window shift for 6228 */
if (af_oper_data.AF_wind_y_delay < af_oper_data.AF_wind_y_delay_count)
{
if (af_oper_data.AF_wind_y_delay == 0)
af_zone_setting(dsc_status.af.metering);
af_oper_data.AF_wind_y_delay++;
}
else
{
if((af_operation_state==AF_COLLECT_STATE) && (af_count<af_oper_data.AF_count_max))
{
af_count++;
if(af_detail_search==KAL_FALSE)
{
if((af_count==af_oper_data.AF_count_max) || (AF_check_AF_count(af_count)==KAL_TRUE))
{
af_count = af_oper_data.AF_count_max;
#if(defined(AF_Debug_Function))
if(af_debug_flag==0)
{
#endif
get_af_info(dsc_status.af.index);
af_next_step_idx=get_af_table_index(dsc_status.af.index);
if(af_next_step_idx != dsc_status.af.index)
{
lens_func->lens_af_move_to((kal_int32)camera_lens_step.AF[af_next_step_idx].pos);
AF_step_move_log((kal_int16)camera_lens_step.AF[af_next_step_idx].pos);
dsc_status.af.index=af_next_step_idx;
af_count=0;
}
else
{
AF_small_check_count = 0;//reset small check count
af_check_FV = 0;//reset stable back count
}
#if(defined(AF_Debug_Function))
}
else
{
AF_debug_scan();
}
#endif
}
}
else
{
if((af_detail_idx<AF_Check_Count_d) && (af_check_FV>0))
{
if((af_count==af_oper_data.AF_count_max) || (AF_check_AF_count(af_count)==KAL_TRUE))
{
af_count = af_oper_data.AF_count_max;
get_af_detail_info(af_detail_idx);
af_next_detail_pos=get_af_detail_pos(af_detail_idx);
if (af_operation_state==AF_COLLECT_STATE)
{
lens_func->lens_af_move_to((kal_int32)af_next_detail_pos);
AF_step_move_log((kal_int16)af_next_detail_pos);
}
af_detail_idx = AF_af_detail_idx_update(af_detail_idx);
if (af_detail_idx == 0)
{
af_check_FV = 0;//reset AF slow count
}
if (af_operation_state==AF_COLLECT_STATE)//continue to collect
{
af_count=0;
}
}
}
if ((af_detail_idx==0) && (af_check_FV == 0))//stablize step back to detail search pos
{
af_check_FV = AF_slow_back_check(af_check_FV);
af_count = 0;
}
}
}
}
if((af_operation_state==AF_SEARCH_STATE)&&(af_cal_complete==KAL_TRUE))
{
af_cal_complete=KAL_FALSE;
cam_focus_cb(0);
}
}
}
}
}
#endif
}
else if (isp_operation_state==ISP_MPEG4_ENCODE_STATE)
{
if (mpeg4_encode_data.cam_encode_cb!=0)
{
if ((ae_count==camera_oper_data.ae_setting_shut_delay_frame)&&
(ae_enable_flag==ISP_ON)&&(ae_awb_cal_complete==1))
image_sensor_func->set_sensor_eshutter((kal_uint16)eShutter);
if ((ae_count==camera_oper_data.ae_setting_sensor_gain_delay_frame)&&(ae_awb_cal_complete==1))
{
if(ae_enable_flag==ISP_ON)
image_sensor_func->set_sensor_gain(sensor_pregain);
}
if ((ae_count==camera_oper_data.ae_setting_gain_delay_frame)&&(ae_awb_cal_complete==1))
{
if(ae_enable_flag==ISP_ON)
ae_set_isp_pregain();
if(awb_enable_flag==ISP_ON)
awb_set_gain();
if(isp_preview_config_data.image_effect==CAM_EFFECT_ENC_NORMAL)
set_anti_low_light_para(AE_INDEX);
}
if ((ae_count==camera_oper_data.ae_setting_cal_delay_frame)&&(ae_awb_cal_complete==1))
{
#if (defined(MT6226)||defined(MT6226M)||defined(MT6227))
if(ae_counting_flag==KAL_TRUE) //Avoid ae get accumulation frame
#else // MT6228||MT6229
if(AE_FRAME_COUNT==1) //Avoid ae get accumulation frame
#endif
{
if (isp_first_preview_frame==KAL_TRUE)
isp_preview_2a_enable=1;
else if(wait_first_frame_flag==KAL_FALSE)
{
ae_awb_cal_complete=0;
mpeg4_encode_data.cam_encode_cb(0);
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
ae_counting_flag=KAL_TRUE;
}
else
ae_counting_flag=KAL_FALSE;
}
if((ae_awb_cal_complete==1)&&
(!((ae_count==camera_oper_data.ae_setting_cal_delay_frame)&&(ae_counting_flag==KAL_FALSE))) )
{ /* cal complete && not wait hw ae count */
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
}
}
#if (defined(WEBCAM_SUPPORT)) // !MT6219
else if(usbvideo_cam_operation_state==USBVIDEO_CAM_PREVIEW_CHECK_STATE)
{ // Webcam AE/AWB
if (g_usbvideo_camera_data.usbvideo_cam_preview_cb!=0)
{
// For use VD interrupt sensor modules, Enable AE Counter
if( ae_count==(camera_oper_data.ae_awb_cal_period-3) )
ENABLE_AE_COUNT;
if ((ae_count==camera_oper_data.ae_setting_shut_delay_frame)&&
(ae_enable_flag==ISP_ON)&&(ae_awb_cal_complete==1))
image_sensor_func->set_sensor_eshutter((kal_uint16)eShutter);
if ((ae_count==camera_oper_data.ae_setting_sensor_gain_delay_frame)&&(ae_awb_cal_complete==1))
{
image_sensor_func->set_sensor_gain(sensor_pregain);
}
if ((ae_count==camera_oper_data.ae_setting_gain_delay_frame)&&(ae_awb_cal_complete==1))
{
if(ae_enable_flag==ISP_ON)
ae_set_isp_pregain();
if(awb_enable_flag==ISP_ON)
awb_set_gain();
if(isp_preview_config_data.image_effect==CAM_EFFECT_ENC_NORMAL)
set_anti_low_light_para(AE_INDEX);
}
if ((ae_count==camera_oper_data.ae_setting_cal_delay_frame)&&(ae_awb_cal_complete==1))
{
if(wait_first_frame_flag==KAL_FALSE)
{
// For use VD interrupt sensor modules, Disable AE Counter
DISABLE_AE_COUNT;
ae_awb_cal_complete=0;
g_usbvideo_camera_data.usbvideo_cam_preview_cb(0);
ae_count++;
ae_count%=camera_oper_data.ae_awb_cal_period;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -