📄 camera_process.c
字号:
if((isp_cct_data->debug_mode == CAPTRUE_MODE_YUV)|| // YUV Capture
(isp_cct_data->debug_mode == CAPTRUE_MODE_EXT_YUV))
{
/* YUV ouput */
SET_OUTPUT_PATH_TYPE(1); /* 0:bayer, 1:ISP output, 2:RGB888, 3:RGB565 */
}
else if((isp_cct_data->debug_mode == CAPTRUE_MODE_RAW_8BIT)|| // RAW/RGB output
(isp_cct_data->debug_mode == CAPTRUE_MODE_EXT_RAW_8BIT)||
(isp_cct_data->debug_mode == CAPTRUE_MODE_RAW_10BIT)||
(isp_cct_data->debug_mode == CAPTRUE_MODE_EXT_RAW_10BIT))
{
/* Bayer output */
SET_OUTPUT_PATH_TYPE(0); /* 0:bayer, 1:ISP output, 2:RGB888, 3:RGB565 */
#if (defined(DRV_ISP_6227_SERIES)||defined(DRV_ISP_6229_SERIES))
if( (isp_cct_data->debug_mode == CAPTRUE_MODE_RAW_10BIT)||
(isp_cct_data->debug_mode == CAPTRUE_MODE_EXT_RAW_10BIT))
{
ENABLE_BAYER10_OUT; /* Bayer 10bit output */
}
else
{
DISABLE_BAYER10_OUT;
}
#endif
}
else if((isp_cct_data->debug_mode == CAPTRUE_MODE_RGB888)||
(isp_cct_data->debug_mode == CAPTRUE_MODE_EXT_RGB888))
{
SET_OUTPUT_PATH_TYPE(2); /* 0:bayer, 1:ISP output, 2:RGB888, 3:RGB565 */
}
else if((isp_cct_data->debug_mode == CAPTRUE_MODE_RGB565)||
(isp_cct_data->debug_mode == CAPTRUE_MODE_EXT_RGB565))
{
SET_OUTPUT_PATH_TYPE(3); /* 0:bayer, 1:ISP output, 2:RGB888, 3:RGB565 */
}
REG_ISP_OUTPUT_ADDR = (kal_uint32)(isp_cct_data->isp_debug_buffer);
if( (isp_cct_data->debug_mode != CAPTRUE_MODE_RAW_8BIT)&& // RAW/RGB output
(isp_cct_data->debug_mode != CAPTRUE_MODE_EXT_RAW_8BIT)&&
(isp_cct_data->debug_mode != CAPTRUE_MODE_RAW_10BIT)&&
(isp_cct_data->debug_mode != CAPTRUE_MODE_EXT_RAW_10BIT))
{
if(isp_cct_data->sub_sample_mode==4)
sub_sample=3;
else
sub_sample=isp_cct_data->sub_sample_mode;
}
// skip unstable frames
ENABLE_CAMERA_IDLE_INT;
SET_CAMERA_CAPTURE_MODE;
SET_CAMERA_FRAME_RATE(0);
// start capture
ENABLE_CAMERA_OUTPUT_TO_MEM;
ENABLE_VIEW_FINDER_MODE;
isp_operation_state=ISP_CAPTURE_JPEG_STATE;
/* add read auto defect count */
#if (defined(DRV_ISP_6227_SERIES)||defined(DRV_ISP_6229_SERIES))
cct_auto_defect_count = REG_ISP_HISTOGRAM_BOUNDARY_CTRL5&0x0000FFFF;
#endif
//for get whole jpg file problem
kal_sleep_task(kal_milli_secs_to_ticks(200)); //2300 good 2000 //2290 //2240
while( (CAM_CheckLine()<1500) );
intmem_deinit();
extmem_deinit();
//for play back problem.
DISABLE_CMOS_SESNOR;
DISABLE_VIEW_FINDER_MODE;
//BB break down after save photo.
DISABLE_CAMERA_OUTPUT_TO_MEM;
ENABLE_REZ_LPF;
DISABLE_REZ_DISCONN;
DISABLE_CAMERA_OUTPUT_TO_MEM;
isp_operation_state=ISP_STANDBY_STATE;
/* disable gamma 1024 */
#if (defined(DRV_ISP_6227_SERIES)||defined(DRV_ISP_6229_SERIES))
DISABLE_1024_GAMMA_TABLE
#endif
#if (!defined(DRV_ISP_6219_SERIES))
if(isp_cct_data->flash_mode == CAM_FLASH_ON)
{
//isp_device_flashligh_enable(KAL_FALSE);
}
#endif
/* Restore pregain of preview mode */
if(sensor_config_data.enable_shutter_tansfer==KAL_TRUE)
{
#if (defined(DRV_ISP_6219_SERIES))
ae_set_pregain(pregain);
#else
//ae_set_lut_gain();
#endif
}
return ret_code;
}
#endif
/*************************************************************************
* FUNCTION
* camera_capture_jpeg_process
*
* DESCRIPTION
* This function capture one picture and encode it as jpeg file
*
* PARAMETERS
* isp_data : the parameters for camera capture and jpeg encode process
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 camera_capture_jpeg_process(camera_capture_jpeg_struct *isp_data)
{
#if (defined(ISP_SUPPORT))
#if (defined(EXIF_SUPPORT))
exif_cam_para_struct* exif_cam_para_ptr;
exif_MTK_para_struct* exif_MTK_para_ptr;
#if (defined(DRV_ISP_6219_SERIES)||defined(DRV_ISP_6227_SERIES))
kal_uint16 exif_header_length;
kal_uint16 exif_padding_length=0;
#endif
#endif
kal_uint32 jpeg_file_size=1;
kal_uint32 event_group;
MMDI_SCENERIO_ID scene_id=SCENARIO_CAMERA_CAPTURE_JPEG_ID;
kal_uint16 temp_grab_size;
volatile kal_uint8 i;
kal_uint8 capture_retry_flag=0;
kal_uint32 isp_capture_shutter;
kal_uint16 isp_capture_pregain;
#if (!defined(DRV_ISP_6219_SERIES))
kal_uint32 defect_reg_backup = REG_ISP_DEFECT_PIXEL_CONFIG;
#endif
#if (defined(DRV_ISP_6228_SERIES)||defined(DRV_ISP_6229_SERIES))
lcd_frame_update_struct lcd_data;
memset(&lcd_data, 0, sizeof(lcd_frame_update_struct)); //initial lcd_data
#endif
#if (!defined(YUV_SENSOR_SUPPORT))
ae_count=0;
hist_idx=0;
ENABLE_CMOS_SESNOR;
#if (!defined(DRV_ISP_6219_SERIES))
#if (defined(DRV_ISP_6228_SERIES)||defined(DRV_ISP_6229_SERIES))
// If Burst Capture, do not enable flash LED
if(isp_data->snapshot_number<=1)
#endif
flashlight_pre_process();
#endif
DISABLE_AE_COUNT;
#endif /* YUV_SENSOR_SUPPORT */
isp_capture_jpeg_data.intmem_start_address=isp_data->intmem_start_address;
isp_capture_jpeg_data.intmem_size=isp_data->intmem_size;
isp_capture_jpeg_data.extmem_start_address=isp_data->extmem_start_address;
isp_capture_jpeg_data.extmem_size=isp_data->extmem_size;
isp_capture_jpeg_data.target_width=isp_data->target_width;
isp_capture_jpeg_data.target_height=isp_data->target_height;
exif_isp_target_width=isp_data->target_width;
exif_isp_target_height=isp_data->target_height;
isp_capture_jpeg_data.image_quality=isp_data->image_quality;
isp_capture_jpeg_data.jpeg_gray_mode=isp_data->jpeg_gray_mode;
isp_capture_jpeg_data.target_buffer_start_address=isp_data->target_buffer_start_address;
isp_capture_jpeg_data.target_buffer_size=isp_data->target_buffer_size;
#if (defined(DRV_ISP_6225_SERIES))
isp_capture_jpeg_data.y_address=isp_data->y_address;
isp_capture_jpeg_data.u_address=isp_data->u_address;
isp_capture_jpeg_data.v_address=isp_data->v_address;
isp_capture_jpeg_data.y_size=isp_data->y_size;
isp_capture_jpeg_data.u_size=isp_data->u_size;
isp_capture_jpeg_data.v_size=isp_data->v_size;
#endif
#ifdef DRV_JPG_ENC_DIRECT_COUPLE_SUPPORT
isp_capture_jpeg_data.memory_output = isp_data->memory_output; /* output another image for LCD output */
isp_capture_jpeg_data.memory_output_type = isp_data->memory_output_type;
isp_capture_jpeg_data.memory_output_width = isp_data->memory_output_width; /* image width for LCD output */
isp_capture_jpeg_data.memory_output_height = isp_data->memory_output_height; /* image height for LCD output */
isp_capture_jpeg_data.memory_output_buffer_address = isp_data->memory_output_buffer_address;
isp_capture_jpeg_data.memory_output_buffer_size = isp_data->memory_output_buffer_size;
#endif
#if (!defined(YUV_SENSOR_SUPPORT))
#if (defined(DRV_ISP_6219_SERIES)||defined(DRV_ISP_6227_SERIES))
intmem_init((kal_uint32 *) isp_capture_jpeg_data.intmem_start_address,
isp_capture_jpeg_data.intmem_size);
extmem_init((kal_uint32 *) isp_capture_jpeg_data.extmem_start_address,
isp_capture_jpeg_data.extmem_size);
#endif
#endif /* YUV_SENSOR_SUPPORT */
#if (!defined(DRV_ISP_6225_SERIES))
jpeg_encode_config_data.image_width=isp_data->target_width;
jpeg_encode_config_data.image_height=isp_data->target_height;
jpeg_encode_config_data.image_quality=isp_data->image_quality;
jpeg_encode_config_data.jpeg_gray_mode=isp_data->jpeg_gray_mode;
jpeg_encode_config_data.jpeg_file_start_address=isp_data->target_buffer_start_address;
jpeg_encode_config_data.jpeg_file_buffer_size=isp_data->target_buffer_size;
#endif
#if (!defined(YUV_SENSOR_SUPPORT))
/* accoring the zoom factor to calculate the grab window area */
exposure_window.image_target_width=isp_data->target_width;
exposure_window.image_target_height=isp_data->target_height;
exposure_window.digital_zoom_factor=isp_digital_zoom_factor;
kal_set_eg_events(camera_isp_event_id,0,KAL_AND);
ENABLE_CAMERA_IDLE_INT;
SET_CAMERA_CAPTURE_MODE;
SET_CAMERA_FRAME_RATE(0);
ENABLE_VIEW_FINDER_MODE;
kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_IDLE_EVENT,KAL_OR_CONSUME,
&event_group,KAL_SUSPEND);
if((camera_oper_data.enable_cap_shutter_compensate==KAL_TRUE)&&
#if (!defined(DRV_ISP_6219_SERIES))
(device_support_info.ae.sensor_basegain==BASEGAIN)&&
#endif
(camera_system_operation_mode==CAMERA_SYSTEM_NORMAL_MODE))
{
#if (!defined(DRV_ISP_6219_SERIES))
if(CAM_ISO_MODE != dsc_status.dscmode)
{
#endif
if((pregain>=camera_oper_data.shutter_compensate_max)&&
(eShutter<MAX_EXPOSURE_LINES))
{
sensor_config_data.enable_shutter_tansfer=KAL_TRUE;
isp_capture_shutter=eShutter*pregain/camera_oper_data.shutter_compensate_max;
if(isp_capture_shutter>MAX_EXPOSURE_LINES)
isp_capture_shutter=MAX_EXPOSURE_LINES;
if(isp_capture_shutter>BaseShutter)
isp_capture_shutter=(isp_capture_shutter/BaseShutter)*BaseShutter;
isp_capture_pregain=eShutter*pregain/isp_capture_shutter;
if(isp_capture_pregain>camera_oper_data.pregain_max)
isp_capture_pregain=camera_oper_data.pregain_max;
ae_set_pregain(isp_capture_pregain);
sensor_config_data.capture_shutter=isp_capture_shutter;
}
else
sensor_config_data.enable_shutter_tansfer=KAL_FALSE;
#if (!defined(DRV_ISP_6219_SERIES))
}
else
{
sensor_config_data.enable_shutter_tansfer=KAL_FALSE;
}
#endif
}
else
sensor_config_data.enable_shutter_tansfer=KAL_FALSE;
if(camera_system_operation_mode==CAMERA_SYSTEM_NORMAL_MODE)
sensor_config_data.meta_mode = CAPTURE_MODE_NORMAL; // for normal mode capture
else
sensor_config_data.meta_mode = CAPTURE_MODE_META; // for meta mode capture
image_sensor_func->sensor_capture_setting(&exposure_window,&sensor_config_data);
#if (!defined(DRV_ISP_6219_SERIES))
flashlight_post_process();
#endif
/* accoring the zoom factor to calculate the grab window area */
isp_horizontal_subsample=exposure_window.isp_hsub_factor;
isp_vertical_subsample=exposure_window.isp_vsub_factor;
isp_grab_width= ((exposure_window.exposure_window_width * ISP_MIN_DIGITAL_ZOOM_FACTOR) / isp_digital_zoom_factor)&0xFFFE ;
isp_grab_height=((exposure_window.exposure_window_height * ISP_MIN_DIGITAL_ZOOM_FACTOR) / isp_digital_zoom_factor)&0xFFFE ;
isp_grab_start_x=exposure_window.grab_start_x+ (((exposure_window.exposure_window_width-isp_grab_width)>>1)&0xFFFE);
isp_grab_start_y=exposure_window.grab_start_y+ (((exposure_window.exposure_window_height-isp_grab_height)>>1)&0xFFFE);
if ((isp_data->target_width * exposure_window.exposure_window_height) >=
(isp_data->target_height * exposure_window.exposure_window_width))
{ /* x limit */
temp_grab_size=isp_grab_height;
isp_grab_height=(isp_grab_width * isp_data->target_height/isp_data->target_width)&0xFFFE;
isp_grab_start_y+=(((temp_grab_size-isp_grab_height)>>1)&0xFFFE);
}
else
{ /* y limit */
temp_grab_size=isp_grab_width;
isp_grab_width=(isp_grab_height * isp_data->target_width/isp_data->target_height)&0xFFFE;
isp_grab_start_x+=(((temp_grab_size-isp_grab_width)>>1)&0xFFFE);
}
isp_grab_start_x-=(((isp_grab_width*(isp_horizontal_subsample-1))>>1)&0xFFFE);
isp_grab_start_y-=((isp_grab_height*(isp_vertical_subsample-1))>>1);
align_center_point();
SET_TG_GRAB_PIXEL(isp_grab_start_x,(isp_grab_width*isp_horizontal_subsample));
SET_TG_GRAB_LINE(isp_grab_start_y,(isp_grab_height*isp_vertical_subsample));
isp_capture_jpeg_data.source_width=isp_grab_width;
isp_capture_jpeg_data.source_height=isp_grab_height;
/* set gamma 1024 */
#if (defined(DRV_ISP_6227_SERIES)||defined(DRV_ISP_6229_SERIES))
apply_take_image_with_gamma_1024_by_flag();
#endif
#if(defined(DRV_ISP_6219_SERIES))
SET_SUB_SAMPLE_MODE(CAMERA_SUB_SAMPLE_1_1);
jpeg_codec_power_up();
#else
ENABLE_VERTICAL_SUB_SAMPLE;
ENABLE_HORIZONTAL_SUB_SAMPLE;
SET_HSUB_SRC_SIZE((isp_grab_width*isp_horizontal_subsample));
SET_VSUB_SRC_SIZE((isp_grab_height*isp_vertical_subsample));
SET_HSUB_DST_SIZE(isp_grab_width);
SET_VSUB_DST_SIZE(isp_grab_height);
#if (defined(DRV_ISP_6227_SERIES))
jpeg_codec_power_up();
#endif
// Disable Defect Table
DISABLE_DEFECT_CORRECTION;
#endif
#if (defined(LED_FLASHLIGHT_SUPPORT)||defined(XENON_FLASHLIGHT_ANTI_RED_EYE)||defined(XENON_FLASHLIGHT))
if(flashlight_redeye_process(camera_oper_data.capture_delay_frame)==KAL_FALSE)
{
for(i=0;i<camera_oper_data.capture_delay_frame;i++)
{
DISABLE_VIEW_FINDER_MODE;
kal_set_eg_events(camera_isp_event_id,0,KAL_AND);
ENABLE_VIEW_FINDER_MODE;
kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_IDLE_EVENT,KAL_OR_CONSUME,
&event_group,KAL_SUSPEND);
}
}
// Enable flash trigger before image data path open.
flashlight_trigger_process();
#else
for(i=0;i<camera_oper_data.capture_delay_frame;i++)
{
DISABLE_VIEW_FINDER_MODE;
kal_set_eg_events(camera_isp_event_id,0,KAL_AND);
ENABLE_VIEW_FINDER_MODE;
kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_IDLE_EVENT,KAL_OR_CONSUME,
&event_group,KAL_SUSPEND);
}
#endif
DISABLE_VIEW_FINDER_MODE;
DISABLE_CAMERA_IDLE_INT;
#if (!(defined(DRV_ISP_6219_SERIES)||defined(DRV_ISP_6225_SERIES)))
/* Restore Defect Table Setting */
REG_ISP_DEFECT_PIXEL_CONFIG = defect_reg_backup;
/* Update shading and defect offset */
if(camera_system_operation_mode==CAMERA_SYSTEM_NORMAL_MODE)
{
apply_camera_shading_to_reg(CAMERA_COMP_CAPTURE_NORMAL_SET);
if(camera_oper_data.ca
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -