|
/*************************************************************************
* FUNCTION
* camera_preview_process
*
* DESCRIPTION
* This function starts camera preview
*
* PARAMETERS
* isp_data : the parameters for camera preview process
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint8 camera_preview_process(camera_preview_process_struct *isp_data)
{
#if (defined(ISP_SUPPORT))
volatile kal_uint32 *resizer_buf_ptr;
kal_uint32 event_group;
MMDI_SCENERIO_ID scene_id=SCENARIO_CAMERA_PREVIEW_ID;
lcd_frame_update_struct lcd_data;
kal_uint16 temp_grab_size;
volatile kal_uint16 i=0,j=0;
volatile kal_uint8 sensor_check_count;
kal_uint8 sensor_fail_count;
#if (!defined(YUV_SENSOR_SUPPORT))
if (sensor_err_check<0)
return KAL_FALSE;
if (isp_operation_state!=ISP_STANDBY_STATE)
ASSERT(0);
/* the preview image size is great than frame buffer size */
if ((((isp_data->target_width) * (isp_data->target_height))<<1) > isp_data->frame_buffer_size)
ASSERT(0);
#if (defined(AF_SUPPORT))
if(isp_data->continue_capture==0)
{
if (af_operation_state != AF_STANDBY_STATE)//prevent scenario error
{
camera_operation_setting(CAM_AF_KEY, CAM_AF_RELEASE);
}
else
{
lens_func->lens_af_move_to((kal_int32)camera_lens.INFO.af_hyper_pos);
dsc_status.af.index=0xFF;
}
}
#endif
#if (!defined(MT6219))
lut_info.videomode=KAL_FALSE;
#endif
ae_on_off(KAL_TRUE);
awb_on_off(KAL_TRUE);
awb_set_gain();
DISABLE_CAMERA_IDLE_INT;
ENABLE_AE_COUNT;
ENABLE_CMOS_SESNOR;
DISABLE_VIEW_FINDER_MODE;
#if (defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6229))
// Disable AE Count before Start Preview
DISABLE_AE_COUNT;
REG_ISP_PREPROCESS_CTRL2 |= REG_PREPROCESS2_AE_COUNT_CLEAR_BIT;
#endif
#if (defined(MT6228)||defined(MT6229))
DISABLE_CMOS_SESNOR;
#endif
sensor_config_data.image_mirror=isp_data->image_mirror;
// sensor_config_data.frame_rate=isp_data->frame_rate;
sensor_config_data.frame_rate=camera_preview_frame_rate(isp_data->target_width,isp_data->target_height);
exposure_window.image_target_width=isp_data->target_width;
exposure_window.image_target_height=isp_data->target_height;
exposure_window.current_exposure_pixel=exposure_window.exposure_pixel=1;
image_sensor_func->sensor_preview_setting(&exposure_window,&sensor_config_data);
image_sensor_preview_width=sensor_config_data.preview_width;
image_sensor_preview_height=sensor_config_data.preview_height;
/* accorind the zoom factor to calculate the grab window area */
isp_digital_zoom_factor=isp_data->zoom_factor;
isp_grab_width= ((exposure_window.exposure_window_width * ISP_MIN_DIGITAL_ZOOM_FACTOR) / isp_digital_zoom_factor)&0xFFFC ;
isp_grab_height=((exposure_window.exposure_window_height * ISP_MIN_DIGITAL_ZOOM_FACTOR) / isp_digital_zoom_factor)&0xFFFC ;
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;
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;
isp_grab_start_x+=(((temp_grab_size-isp_grab_width)>>1)&0xFFFE);
}
SET_TG_GRAB_PIXEL(isp_grab_start_x,isp_grab_width);
SET_TG_GRAB_LINE(isp_grab_start_y,isp_grab_height);
ae_config(isp_grab_width,isp_grab_height);
#if (!(defined(MT6219)||defined(MT6228)))
DISABLE_1024_GAMMA_TABLE;
#endif
#if (!defined(MT6219))
apply_camera_shading_to_reg(CAMERA_COMP_PREVIEW_NORMAL_SET);
if(camera_oper_data.preview_defect_table_enable==KAL_TRUE)
{
load_defect_table_para(DEFECT_MODE_PREVIEW);
ENABLE_DEFECT_CORRECTION;
}
else
DISABLE_DEFECT_CORRECTION;
#endif
#if (defined(MT6219))
/* according the maximum size of resizer input we define to calculate the the image size
of resizer input */
if ((isp_grab_width<=MAX_RESIZER_INPUT_WIDTH) && (isp_grab_height<=MAX_RESIZER_INPUT_HEIGHT))
{
isp_sub_sample_mode=CAMERA_SUB_SAMPLE_1_1;
isp_preview_config_data.source_width=isp_grab_width;
isp_preview_config_data.source_height=isp_grab_height;
}
else if ((isp_grab_width<=(MAX_RESIZER_INPUT_WIDTH<<1)) && (isp_grab_height<=(MAX_RESIZER_INPUT_HEIGHT<<1)))
{
isp_sub_sample_mode=CAMERA_SUB_SAMPLE_1_2;
isp_preview_config_data.source_width=isp_grab_width>>1;
isp_preview_config_data.source_height=isp_grab_height>>1;
}
else if ((isp_grab_width<=(MAX_RESIZER_INPUT_WIDTH<<2)) && (isp_grab_height<=(MAX_RESIZER_INPUT_HEIGHT<<2)))
{
isp_sub_sample_mode=CAMERA_SUB_SAMPLE_1_4;
isp_preview_config_data.source_width=isp_grab_width>>2;
isp_preview_config_data.source_height=isp_grab_height>>2;
}
else if ((isp_grab_width<=(MAX_RESIZER_INPUT_WIDTH<<3)) && (isp_grab_height<=(MAX_RESIZER_INPUT_HEIGHT<<3)))
{
isp_sub_sample_mode=CAMERA_SUB_SAMPLE_1_8;
isp_preview_config_data.source_width=isp_grab_width>>3;
isp_preview_config_data.source_height=isp_grab_height>>3;
}
SET_SUB_SAMPLE_MODE(isp_sub_sample_mode);
#elif (defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229))
ENABLE_VERTICAL_SUB_SAMPLE;
ENABLE_HORIZONTAL_SUB_SAMPLE;
SET_HSUB_SRC_SIZE(isp_grab_width);
SET_VSUB_SRC_SIZE(isp_grab_height);
if((isp_grab_width>(isp_data->target_width<<2)) || (isp_grab_height>(isp_data->target_height<<2)))
{ /* grab size > taget size *4 => ISP subsample 4x */
SET_HSUB_DST_SIZE(isp_grab_width>>2);
SET_VSUB_DST_SIZE(isp_grab_height>>2);
isp_preview_config_data.source_width=isp_grab_width>>2;
isp_preview_config_data.source_height=isp_grab_height>>2;
}
else if((isp_grab_width>(isp_data->target_width<<1)) || (isp_grab_height>(isp_data->target_height<<1)))
{ /* grab size > taget size *2 => ISP subsample 2x */
SET_HSUB_DST_SIZE(isp_grab_width>>1);
SET_VSUB_DST_SIZE(isp_grab_height>>1);
isp_preview_config_data.source_width=isp_grab_width>>1;
isp_preview_config_data.source_height=isp_grab_height>>1;
}
else
{
if((isp_grab_width>=((isp_data->target_width)+2)) && (isp_grab_height>=((isp_data->target_height)+2)))
{
SET_HSUB_DST_SIZE(isp_data->target_width+2);
SET_VSUB_DST_SIZE(isp_data->target_height+2);
isp_preview_config_data.source_width=isp_data->target_width+2;
isp_preview_config_data.source_height=isp_data->target_height+2;
}
else
{
if((isp_grab_width==(isp_data->target_width)) && (isp_grab_height==(isp_data->target_height)))
{
SET_HSUB_DST_SIZE(isp_grab_width-2);
SET_VSUB_DST_SIZE(isp_grab_height-2);
isp_preview_config_data.source_width=isp_grab_width-2;
isp_preview_config_data.source_height=isp_grab_height-2;
}
else
{
SET_HSUB_DST_SIZE(isp_grab_width);
SET_VSUB_DST_SIZE(isp_grab_height);
isp_preview_config_data.source_width=isp_grab_width;
isp_preview_config_data.source_height=isp_grab_height;
}
}
}
#endif
#endif /* YUV_SENSOR_SUPPORT */
isp_preview_config_data.image_mirror=isp_data->image_mirror;
isp_preview_config_data.frame_rate=isp_data->frame_rate;
isp_preview_config_data.target_width=isp_data->target_width;
isp_preview_config_data.target_height=isp_data->target_height;
isp_preview_config_data.lcd_id=isp_data->lcd_id;
isp_preview_config_data.lcm_start_x=isp_data->lcm_start_x;
isp_preview_config_data.lcm_start_y=isp_data->lcm_start_y;
isp_preview_config_data.lcm_end_x=isp_data->lcm_end_x;
isp_preview_config_data.lcm_end_y=isp_data->lcm_end_y;
isp_preview_config_data.roi_offset_x=isp_data->roi_offset_x;
isp_preview_config_data.roi_offset_y=isp_data->roi_offset_y;
isp_preview_config_data.update_layer=isp_data->update_layer;
isp_preview_config_data.hw_update_layer=isp_data->hw_update_layer;
isp_preview_config_data.rotate_value=isp_data->rotate_value;
isp_preview_config_data.continue_capture=isp_data->continue_capture;
isp_preview_config_data.intmem_start_address=isp_data->intmem_start_address;
isp_preview_config_data.intmem_size=isp_data->intmem_size;
isp_preview_config_data.extmem_start_address=isp_data->extmem_start_address;
isp_preview_config_data.extmem_size=isp_data->extmem_size;
isp_preview_config_data.zoom_factor=isp_data->zoom_factor;
isp_preview_config_data.target_width=isp_data->target_width;
isp_preview_config_data.target_height=isp_data->target_height;
isp_preview_config_data.preview_offset_x=isp_data->preview_offset_x;
isp_preview_config_data.preview_offset_y=isp_data->preview_offset_y;
isp_preview_config_data.camera_offset_x=isp_data->camera_offset_x;
isp_preview_config_data.camera_offset_y=isp_data->camera_offset_y;
isp_preview_config_data.frame_buffer_address=isp_data->frame_buffer_address;
isp_preview_config_data.frame_buffer_size=isp_data->frame_buffer_size;
isp_preview_config_data.frame_buffer_address1=isp_data->frame_buffer_address1;
isp_preview_config_data.frame_buffer_size1=isp_data->frame_buffer_size1;
isp_preview_config_data.roi_background_color=isp_data->roi_background_color;
isp_preview_config_data.cam_preview_cb=isp_data->cam_preview_cb;
#if (!defined(YUV_SENSOR_SUPPORT))
#if (defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227))
intmem_init((kal_uint32 *) isp_preview_config_data.intmem_start_address,
isp_preview_config_data.intmem_size);
extmem_init((kal_uint32 *) isp_preview_config_data.extmem_start_address,
isp_preview_config_data.extmem_size);
#endif
lcd_data.module_id=LCD_UPDATE_MODULE_MEDIA;
lcd_data.lcd_id=isp_preview_config_data.lcd_id;
lcd_data.fb_update_mode=LCD_HW_TRIGGER_MODE;
lcd_data.lcm_start_x=isp_preview_config_data.lcm_start_x;
lcd_data.lcm_start_y=isp_preview_config_data.lcm_start_y;
lcd_data.lcm_end_x=isp_preview_config_data.lcm_end_x;
lcd_data.lcm_end_y=isp_preview_config_data.lcm_end_y;
lcd_data.roi_offset_x=isp_preview_config_data.roi_offset_x;
lcd_data.roi_offset_y=isp_preview_config_data.roi_offset_y;
lcd_data.update_layer=isp_preview_config_data.update_layer;
lcd_data.hw_update_layer=isp_preview_config_data.hw_update_layer;
lcd_data.block_mode_flag=KAL_TRUE;
lcd_data.lcd_block_mode_cb=NULL;
#if (!defined(MT6219))
lcd_data.roi_background_color=isp_data->roi_background_color;
#endif
#if (defined(MT6226)||defined(MT6226M)||defined(MT6227))
lcd_data.memory_output=KAL_FALSE;
#endif
#endif /* YUV_SENSOR_SUPPORT */
isp_preview_config_data.contrast_level=isp_data->contrast_level;
isp_preview_config_data.brightness_level=isp_data->brightness_level;
isp_preview_config_data.hue_value=isp_data->hue_value;
isp_preview_config_data.saturation_value=isp_data->saturation_value;
isp_preview_config_data.wb_mode=isp_data->wb_mode;
isp_preview_config_data.ev_value=isp_data->ev_value;
isp_preview_config_data.banding_freq=isp_data->banding_freq;
isp_preview_config_data.image_effect=isp_data->image_effect;
isp_preview_config_data.night_mode=isp_data->night_mode;
#if (!defined(MT6219))
/* ISP Setting */
isp_preview_config_data.dsc_mode = isp_data->dsc_mode;
isp_preview_config_data.ae_metering_mode = isp_data->ae_metering_mode;
isp_preview_config_data.af_mode = isp_data->af_mode;
isp_preview_config_data.af_metering_mode = isp_data->af_metering_mode;
isp_preview_config_data.tv_setting = isp_data->tv_setting;
isp_preview_config_data.av_setting = isp_data->av_setting;
isp_preview_config_data.iso_setting = isp_data->iso_setting;
isp_preview_config_data.flash_mode = isp_data->flash_mode;
isp_preview_config_data.af_zone0_x = isp_data->af_zone0_x;
isp_preview_config_data.af_zone0_y = isp_data->af_zone0_y;
isp_preview_config_data.af_zone1_x = isp_data->af_zone1_x;
isp_preview_config_data.af_zone1_y = isp_data->af_zone1_y;
isp_preview_config_data.af_zone2_x = isp_data->af_zone2_x;
isp_preview_config_data.af_zone2_y = isp_data->af_zone2_y;
isp_preview_config_data.af_zone3_x = isp_data->af_zone3_x;
isp_preview_config_data.af_zone3_y = isp_data->af_zone3_y;
isp_preview_config_data.af_zone4_x = isp_data->af_zone4_x;
isp_preview_config_data.af_zone4_y = isp_data->af_zone4_y;
isp_preview_config_data.cam_focus_cb = isp_data->cam_focus_cb;
#endif
#if (defined(MT6228)||defined(MT6229))
/* Prepare IPP Data */
ipp_preview_data.intmem_start_address = isp_data->intmem_start_address;
ipp_preview_data.intmem_size = isp_data->intmem_size;
ipp_preview_data.extmem_start_address = isp_data->extmem_start_address;
ipp_preview_data.extmem_size = isp_data->extmem_size;
ipp_preview_data.image_src_width = isp_preview_config_data.source_width;
ipp_preview_data.image_src_height = isp_preview_config_data.source_height;
ipp_preview_data.preview_width = isp_preview_config_data.target_width;
ipp_preview_data.preview_height = isp_preview_config_data.target_height;
ipp_preview_data.image_pitch_mode = isp_data->image_pitch_mode;
ipp_preview_data.image_data_format = isp_data->image_data_format;
ipp_preview_data.image_pitch_bytes = isp_data->image_pitch_bytes;
ipp_preview_data.overlay_frame_mode = isp_data->overlay_frame_mode;
ipp_preview_data.overlay_color_depth = isp_data->overlay_color_depth;
ipp_preview_data.overlay_frame_source_key = isp_data->overlay_frame_source_key;
ipp_preview_data.overlay_frame_width = isp_data->overlay_frame_width;
ipp_preview_data.overlay_frame_height = isp_data->overlay_frame_height;
ipp_preview_data.overlay_frame_buffer_address = isp_data->overlay_frame_buffer_address;
ipp_preview_data.frame_buffer_address = isp_data->frame_buffer_address;
ipp_preview_data.frame_buffer_size = isp_data->frame_buffer_size;
ipp_preview_data.frame_buffer_address1 = isp_data->frame_buffer_address1;
ipp_preview_data.frame_buffer_size1 = isp_data->frame_buffer_size1;
ipp_preview_data.tv_output = isp_data->tv_output;
ipp_preview_data.tv_output_width = isp_data->tv_output_width;
ipp_preview_data.tv_output_height = isp_data->tv_output_height;
ipp_preview_data.tv_output_offset_x = isp_data->tv_output_offset_x;
ipp_preview_data.tv_output_offset_y = isp_data->tv_output_offset_y;
ipp_preview_data.tv_output_buffer1_address = isp_data->tv_output_buffer1_address;
ipp_preview_data.tv_output_buffer2_address = isp_data->tv_output_buffer2_address;
ipp_preview_data.tv_rotate_buffer1_address = isp_data->tv_rotate_buffer1_address;
ipp_preview_data.tv_rotate_buffer2_address = isp_data->tv_rotate_buffer2_address;
ipp_preview_data.tv_output_buffer_size = isp_data->tv_output_buffer_size;
#if (!defined(YUV_SENSOR_SUPPORT))
/* Prepare LCD Data */
lcd_data.hw_trigger_src = LCD_HW_TRIGGER_IBW2;
lcd_data.memory_output=KAL_FALSE;
if ((isp_data->tv_output==KAL_TRUE)&&
((tv_output_config_data.tv_output_mode==TV_OUTPUT_MODE1)||
(tv_output_config_data.tv_output_mode==TV_OUTPUT_MODE4)))
{
lcd_data.tv_output=KAL_TRUE;
lcd_data.tv_output_width=isp_data->tv_output_width;
lcd_data.tv_output_height=isp_data->tv_output_height;
lcd_data.tv_output_offset_x=isp_data->tv_output_offset_x;
lcd_data.tv_output_offset_y=isp_data->tv_output_offset_y;
lcd_data.tv_output_frame_buffer1_address=isp_data->tv_output_buffer1_address;
lcd_data.tv_output_frame_buffer2_address=isp_data->tv_output_buffer2_address;
lcd_data.tv_output_frame_buffer_size=isp_data->tv_output_buffer_size;
ipp_preview_data.tv_output=KAL_FALSE;
}
else
{
lcd_data.tv_output=KAL_FALSE;
}
#endif /* YUV_SENSOR_SUPPORT */
#endif
#if (!defined(YUV_SENSOR_SUPPORT))
#if (defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227))
config_image_dma(scene_id,isp_data->target_width,isp_data->target_height);
config_image_processor(scene_id);
config_pixel_resizer(scene_id);
#elif (defined(MT6228)||defined(MT6229))
open_image_data_path(scene_id);
config_camera_preview_data_path(scene_id,&ipp_preview_data);
#endif
#if (defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227))
resizer_buf_ptr=(kal_uint32 *) (*((volatile unsigned int *)0x8061005C)); /* resizer working memory */
*resizer_buf_ptr=0x55AAAA55;
#endif
isp_operation_state=ISP_PREVIEW_STATE;
#if (!defined(MT6219))
/* camera operation setting */
if(isp_preview_config_data.continue_capture==0)
{
camera_operation_setting(CAM_DSC_MODE,isp_preview_config_data.dsc_mode);
camera_operation_setting(CAM_AE_METERING,isp_preview_config_data.ae_metering_mode);
camera_operation_setting(CAM_AF_MODE,isp_preview_config_data.af_mode);
camera_operation_setting(CAM_AF_METERING,isp_preview_config_data.af_metering_mode);
camera_operation_setting(CAM_SHUTTER_PRIORITY,isp_preview_config_data.tv_setting);
camera_operation_setting(CAM_APERTURE_PRIORITY,isp_preview_config_data.av_setting);
camera_operation_setting(CAM_ISO,isp_preview_config_data.iso_setting);
camera_operation_setting(CAM_FLASH_MODE,isp_preview_config_data.flash_mode);
}
#endif
camera_image_setting(CAM_PARAM_EFFECT,isp_preview_config_data.image_effect);
set_camera_mode_para(CAMERA_PARA_PREVIEW_MODE);
if(isp_preview_config_data.image_effect==CAM_EFFECT_ENC_NORMAL)
{
camera_image_setting(CAM_PARAM_CONTRAST,isp_preview_config_data.contrast_level);
camera_image_setting(CAM_PARAM_BRIGHTNESS,isp_preview_config_data.brightness_level);
camera_image_setting(CAM_PARAM_HUE,isp_preview_config_data.hue_value);
camera_image_setting(CAM_PARAM_SATURATION,isp_preview_config_data.saturation_value);
}
camera_image_setting(CAM_PARAM_WB,isp_preview_config_data.wb_mode);
camera_image_setting(CAM_PARAM_EXPOSURE,isp_preview_config_data.ev_value);
camera_image_setting(CAM_PARAM_BANDING,isp_preview_config_data.banding_freq);
camera_image_setting(CAM_PARAM_NIGHT_MODE,(kal_uint16)isp_preview_config_data.night_mode);
if((isp_preview_config_data.image_effect==CAM_EFFECT_ENC_NORMAL) && (isp_preview_config_data.night_mode))
set_camera_mode_para(CAMERA_PARA_NIGHT_MODE);
#if (!defined(MT6219))
if(isp_preview_config_data.image_effect==CAM_EFFECT_ENC_NORMAL)
set_anti_low_light_para(AE_INDEX);
#endif
kal_set_eg_events(camera_isp_event_id,0,KAL_AND);
wait_first_frame_flag=KAL_TRUE;
isp_preview_frame=0;
SET_CAMERA_PREVIEW_MODE;
SET_CAMERA_FRAME_RATE(0);
#if (defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6229))
// Enable AE Count before Start Preview
REG_ISP_PREPROCESS_CTRL2 &= ~REG_PREPROCESS2_AE_COUNT_CLEAR_BIT;
ENABLE_AE_COUNT;
#endif
#if (defined(MT6228))
RESET_ISP;
CLEAR_RESET_ISP;
#endif
#if (defined(MT6228)||defined(MT6229))
ENABLE_CMOS_SESNOR;
#endif
ENABLE_VIEW_FINDER_MODE;
ae_awb_cal_complete=1;
isp_preview_2a_enable=0;
ae_count=0;
hist_idx=0;
#if (defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227))
sensor_check_count=0;
sensor_fail_count=0;
kal_sleep_task(10);
while (sensor_check_count<=25)
{
kal_sleep_task(10);
if ((*resizer_buf_ptr==0x55AAAA55) && (ae_count==0))
{
if (sensor_check_count==25)
{
sensor_fail_count++;
if(sensor_fail_count>2)
return KAL_FALSE;
ae_on_off(KAL_TRUE);
awb_on_off(KAL_TRUE);
awb_set_gain();
DISABLE_VIEW_FINDER_MODE;
RESZ_Stop(scene_id);
RESZ_Close(scene_id);
clean_imgprc_coefficient(scene_id);
IMGPROC_Stop(scene_id);
IMGPROC_Close(scene_id);
stop_image_dma(scene_id);
IMGDMA_Close(scene_id);
intmem_deinit();
extmem_deinit();
kal_set_eg_events(camera_isp_event_id,0,KAL_AND);
ENABLE_CMOS_SESNOR;
REG_ISP_CMOS_SENSOR_MODE_CONFIG |= REG_CMOS_SENSOR_RESET_BIT; /* reset CMOS senosr */
for (i=0;i<0x1000;i++);
REG_ISP_CMOS_SENSOR_MODE_CONFIG &= ~REG_CMOS_SENSOR_RESET_BIT;
image_sensor_func->sensor_init();
for (i=0;i<0x1000;i++);
image_sensor_func->sensor_preview_setting(&exposure_window,&sensor_config_data);
intmem_init((kal_uint32 *) isp_preview_config_data.intmem_start_address,
isp_preview_config_data.intmem_size);
extmem_init((kal_uint32 *) isp_preview_config_data.extmem_start_address,
isp_preview_config_data.extmem_size);
config_image_dma(scene_id,isp_data->target_width,isp_data->target_height);
config_image_processor(scene_id);
config_pixel_resizer(scene_id);
camera_image_setting(CAM_PARAM_EFFECT,isp_preview_config_data.image_effect);
set_camera_mode_para(CAMERA_PARA_PREVIEW_MODE);
if(isp_preview_config_data.image_effect==0)
{
camera_image_setting(CAM_PARAM_CONTRAST,isp_preview_config_data.contrast_level);
camera_image_setting(CAM_PARAM_BRIGHTNESS,isp_preview_config_data.brightness_level);
camera_image_setting(CAM_PARAM_HUE,isp_preview_config_data.hue_value);
camera_image_setting(CAM_PARAM_SATURATION,isp_preview_config_data.saturation_value);
}
camera_image_setting(CAM_PARAM_WB,isp_preview_config_data.wb_mode);
camera_image_setting(CAM_PARAM_EXPOSURE,isp_preview_config_data.ev_value);
camera_image_setting(CAM_PARAM_BANDING,isp_preview_config_data.banding_freq);
camera_image_setting(CAM_PARAM_NIGHT_MODE,(kal_uint16)isp_preview_config_data.night_mode);
if((isp_preview_config_data.image_effect==0) && (isp_preview_config_data.night_mode))
set_camera_mode_para(CAMERA_PARA_NIGHT_MODE);
isp_preview_2a_enable=0;
ae_count=0;
hist_idx=0;
sensor_check_count=0;
resizer_buf_ptr=(kal_uint32 *) (*((volatile unsigned int *)0x8061005C)); /* resizer working memory */
*resizer_buf_ptr=0x55AAAA55;
ENABLE_VIEW_FINDER_MODE;
}
else
sensor_check_count++;
}
else
sensor_check_count=26;
};
#endif
/* wait sensor first frame coming */
#if (defined(MT6219))
kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_FRAME_READY_EVENT,KAL_OR_CONSUME,
&event_group,KAL_SUSPEND);
#else
kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_VD_READY_EVENT,KAL_OR_CONSUME,
&event_group,KAL_SUSPEND);
#endif
/* Wait AE AWB Stable */
if(isp_first_preview_frame==KAL_TRUE)
{
for(i=0;i<camera_oper_data.preview_display_wait_frame;i++)
{
j=0;
while(j<9*camera_oper_data.ae_awb_cal_period)
{
if(isp_preview_2a_enable==1)
{
ae_awb_main();
isp_preview_2a_enable=0;
break;
}
else
{
kal_sleep_task(2);
j++;
}
}
}
isp_first_preview_frame=KAL_FALSE;
}
lcd_fb_update(&lcd_data); /* wait first frame ready */
kal_set_eg_events(camera_isp_event_id,0,KAL_AND);
#if (defined(MT6219))
kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_FRAME_READY_EVENT,KAL_OR_CONSUME,
&event_group,KAL_SUSPEND);
#else
kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_VD_READY_EVENT,KAL_OR_CONSUME,
&event_group,KAL_SUSPEND);
#endif
#endif /* YUV_SENSOR_SUPPORT */
#if (defined(YUV_SENSOR_SUPPORT))
return camera_yuv_preview_process();
#else
return KAL_TRUE;
#endif /* YUV_SENSOR_SUPPORT */
#endif
} /* camera_preview_process() */ |
|