📄 isp_device_if.c
字号:
{
return avglum;
}
/*************************************************
* AF Interface
**************************************************/
/* AF Calibration finction : Search AF Best Pos */
kal_uint8 isp_device_af_calibration(kal_uint32 *pos, kal_uint32 *atf_value)
{
#if (defined(AF_SUPPORT)&&(!defined(YUV_SENSOR_SUPPORT)))
kal_uint32 event_group;
kal_uint32 p, start_p, end_p;
kal_uint32 curr_atf=0, best_atf=0, best_pos;
kal_uint32 grab_x_start,grab_x_end,grab_y_start,grab_y_end;
kal_uint16 offsetX,offsetY;
DISABLE_VIEW_FINDER_MODE;
/* config AF window */
grab_x_start=((REG_ISP_TG_GRAB_RANGE_PIXEL_CONFIG)&0xFFFF0000)>>16;
grab_x_end=((REG_ISP_TG_GRAB_RANGE_PIXEL_CONFIG)&0x0000FFFF);
grab_y_start=((REG_ISP_TG_GRAB_RANGE_LINE_CONFIG)&0xFFFF0000)>>16;
grab_y_end=((REG_ISP_TG_GRAB_RANGE_LINE_CONFIG)&0x0000FFFF);
offsetX=((grab_x_end-grab_x_start)>>1) - AF_WINDOW_W;
offsetY=((grab_y_end-grab_y_start)>>1) - AF_WINDOW_H;
af_window_config(1,AF_WINDOW_W,AF_WINDOW_H,offsetX,offsetY);
/* init pos */
start_p = camera_lens.INFO.af_me_home_pos;
end_p = camera_lens.INFO.af_me_macro_pos;
if(camera_lens.INFO.af_me_home_pos > camera_lens.INFO.af_me_macro_pos)
{
start_p = camera_lens.INFO.af_me_macro_pos;
end_p = camera_lens.INFO.af_me_home_pos;
}
lens_func->lens_af_move_to(start_p);
best_pos = start_p;
/* init isp */
ENABLE_CMOS_SESNOR;
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);
/* start search best ATF value */
for(p=start_p;p<=end_p;p++)
{
/* Move AF pos */
lens_func->lens_af_move_to(p);
/* Wait Stable */
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);
/* Get ATF value */
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);
DISABLE_VIEW_FINDER_MODE;
curr_atf = AF_Result0;
if(best_atf < curr_atf)
{
best_atf = curr_atf;
best_pos = p;
}
}
*pos = best_pos;
*atf_value = best_atf;
lens_func->lens_af_move_to(best_pos);
return KAL_TRUE;
#else
return KAL_FALSE;
#endif
}
/* AF Verify finction : Move AF to idx pos */
kal_uint8 isp_device_set_af_idx(kal_uint8 idx)
{
#if (defined(AF_SUPPORT)&&(!defined(YUV_SENSOR_SUPPORT)))
if(lens_func!=NULL)
lens_func->lens_af_move_to(camera_lens.AF[idx].pos);
return KAL_TRUE;
#else
return KAL_FALSE;
#endif
}
/* AF Verify finction : Move AF to pos */
kal_uint8 isp_device_set_af_pos(kal_uint32 pos)
{
#if (defined(AF_SUPPORT)&&(!defined(YUV_SENSOR_SUPPORT)))
if(lens_func!=NULL)
lens_func->lens_af_move_to(pos);
return KAL_TRUE;
#else
return KAL_FALSE;
#endif
}
/*********************************************************************
* Flash Light Interface
* call by tool when user press "gen" flash light
* keep capture from tool and Stop capture by tool when:
* 1. target_lum == curr_lum
* 2. user stop process
* 3. camera_strobe_capture_cct return KAL_FALSE (flash light limit)
**********************************************************************/
kal_uint8 adjust_flashlight_param(kal_uint32 curr_lum, kal_uint32 target_lum)
{
kal_uint8 ret_code=KAL_TRUE;
kal_uint16 isp_capture_pregain = BASEGAIN;
if( (curr_lum>0xFF) || (target_lum==0) ) /* Init Flash light Capture */
return KAL_TRUE;
if( curr_lum == 0 )
curr_lum = 1;
if((device_support_info.autoflash.sensorgain!=sensor_pregain)||(device_support_info.autoflash.ispgain!=isp_pregain))
{
sensor_pregain=device_support_info.autoflash.sensorgain;
isp_pregain=device_support_info.autoflash.ispgain;
image_sensor_func->set_sensor_gain(sensor_pregain);
ae_set_isp_pregain();
isp_capture_pregain=sensor_pregain*isp_pregain/0x40;
}
/* FlashLight Shutter Config */
if(curr_lum < target_lum)
{
/* increase shutter */
if(device_support_info.autoflash.shutter < device_support_info.autoflash.max_shutter)
{
device_support_info.autoflash.shutter = (device_support_info.autoflash.shutter*target_lum)/curr_lum;
if(device_support_info.autoflash.shutter>device_support_info.autoflash.max_shutter)
device_support_info.autoflash.shutter = device_support_info.autoflash.max_shutter;
}
/* increase gain */
else if(isp_capture_pregain < camera_oper_data.pregain_max)
{
isp_capture_pregain=isp_capture_pregain*target_lum/curr_lum;
if(isp_capture_pregain>camera_oper_data.pregain_max)
isp_capture_pregain=camera_oper_data.pregain_max;
ae_set_pregain(isp_capture_pregain);
device_support_info.autoflash.sensorgain=sensor_pregain;
device_support_info.autoflash.ispgain=isp_pregain;
}
else
ret_code = KAL_FALSE;
}
else
{
/* decrease gain first */
if(isp_capture_pregain > camera_oper_data.pregain_min)
{
isp_capture_pregain=isp_capture_pregain*target_lum/curr_lum;
if(isp_capture_pregain<camera_oper_data.pregain_min)
isp_capture_pregain=camera_oper_data.pregain_min;
ae_set_pregain(isp_capture_pregain);
device_support_info.autoflash.sensorgain=sensor_pregain;
device_support_info.autoflash.ispgain=isp_pregain;
}
/* decrease shutter */
else if(device_support_info.autoflash.shutter > device_support_info.autoflash.min_shutter)
{
device_support_info.autoflash.shutter = device_support_info.autoflash.shutter*target_lum/curr_lum;
if(device_support_info.autoflash.shutter<device_support_info.autoflash.min_shutter)
device_support_info.autoflash.shutter = device_support_info.autoflash.min_shutter;
}
/* decrease duty */
else if(device_support_info.autoflash.duty > 0)
{
device_support_info.autoflash.duty = device_support_info.autoflash.duty*target_lum/curr_lum;
if(device_support_info.autoflash.duty == 0)
device_support_info.autoflash.duty = 1;
}
else
ret_code = KAL_FALSE;
}
return ret_code;
}
/*************************************************
* Defect Table Interface
**************************************************/
extern kal_bool switch_cap_en;
/* Input Data */
defectpixel_para_struct defectpixel_data;
defectpixel_para_struct defectpixel_cap_data;
defectpixel_para_struct defectpixel_pv_data;
kal_uint8 defect_current_mode;
kal_uint8 defect_operation_state = DEFECT_INIT_STATE;
kal_uint8 defect_operation_pv_state = DEFECT_INIT_STATE;
kal_uint16 defect_curr_search_num=0, defect_area1_search_num=0;
kal_uint16 defect_curr_cap_search_num=0, defect_area1_cap_search_num=0;
kal_uint16 defect_curr_pv_search_num=0, defect_area1_pv_search_num=0;
kal_uint16 defect_curr_min_diff=0xFF, defect_area1_min_diff=0xFF;
kal_uint16 defect_curr_cap_min_diff=0xFF, defect_area1_cap_min_diff=0xFF;
kal_uint16 defect_curr_pv_min_diff=0xFF, defect_area1_pv_min_diff=0xFF;
kal_uint32 cap_search1_idx, pv_search1_idx;
#define DEFECT_WHITEPIXEL_OFFSET (32) // to force white pixel select
/* Result Data */
defectpixel_result_struct defectpixel_result;
defectpixel_result_struct defectpixel_pv_result;
defectpixel_pixel_struct search_pixel[DEFECT_MAX_SEARCH_NUM];
defectpixel_pixel_struct search_cap_pixel[DEFECT_MAX_SEARCH_NUM];
defectpixel_pixel_struct search_pv_pixel[DEFECT_MAX_SEARCH_NUM];
kal_uint32 diffValue[MAX_DEFECT_NUM], diffArea1Value[MAX_DEFECT_NUM];
kal_uint32 diffValue_pv[MAX_DEFECT_NUM], diffArea1Value_pv[MAX_DEFECT_NUM];
/* Parameters */
kal_uint16 block_pixel_count;
kal_uint16 grap_width, grap_height;
kal_uint16 area1_min_x=0, area1_max_x=0xFFFF, area1_min_y=0, area1_max_y=0xFFFF;
kal_uint16 area_id;
void clear_defect_para(kal_uint8 defect_mode)
{
register kal_int32 i = MAX_DEFECT_NUM;
register kal_uint32 *p_diffValue = diffValue;
register kal_uint32 *p_diffArea1Value = diffArea1Value;
register kal_uint32 *p_diffValue_pv = diffValue_pv;
register kal_uint32 *p_diffArea1Value_pv = diffArea1Value_pv;
if((defect_mode==DEFECT_MODE_CAPTURE)||(defect_mode==DEFECT_MODE_BOTH))
{
defect_curr_cap_search_num = defect_area1_cap_search_num = 0;
defect_curr_cap_min_diff = defect_area1_cap_min_diff=0xFF;
cap_search1_idx = 0;
while (--i >=0)
{
*p_diffValue++ = 0;
*p_diffArea1Value++ = 0;
}
i = DEFECT_MAX_SEARCH_NUM;
while (--i>=0)
{
search_pixel[i].pixel_diff = 0;
search_cap_pixel[i].pixel_diff = 0;
}
}
if((defect_mode==DEFECT_MODE_PREVIEW)||(defect_mode==DEFECT_MODE_BOTH))
{
defect_curr_pv_search_num = defect_area1_pv_search_num = 0;
defect_curr_pv_min_diff = defect_area1_pv_min_diff=0xFF;
pv_search1_idx = 0;
while (--i >=0)
{
*p_diffValue_pv++ = 0;
*p_diffArea1Value_pv++ = 0;
}
i = DEFECT_MAX_SEARCH_NUM;
while (--i>=0)
{
search_pixel[i].pixel_diff = 0;
search_pv_pixel[i].pixel_diff = 0;
}
}
if(defect_mode==DEFECT_MODE_BOTH)
{
defect_curr_search_num = defect_area1_search_num = 0;
defect_curr_min_diff = defect_area1_min_diff=0xFF;
}
}
void camera_defect_raw_capture( kal_uint16 grab_start_x,kal_uint16 grab_start_y,
kal_uint16 grab_width,kal_uint16 grab_height,
kal_uint32 isp_debug_buffer)
{
kal_uint32 event_group;
kal_uint16 isp_grab_start_x,isp_grab_start_y;
kal_uint32 i;
if (isp_operation_state!=ISP_STANDBY_STATE)
ASSERT(0);
ENABLE_CMOS_SESNOR;
if(switch_cap_en == KAL_TRUE)
{
exposure_window.image_target_width=grab_width;
exposure_window.image_target_height=grab_height;
exposure_window.digital_zoom_factor=10;
sensor_config_data.enable_shutter_tansfer=KAL_FALSE;
sensor_config_data.meta_mode = CAPTURE_MODE_META_EXT; // for meta mode capture
image_sensor_func->sensor_capture_setting(&exposure_window,&sensor_config_data);
}
isp_grab_start_x=exposure_window.grab_start_x;
isp_grab_start_y=exposure_window.grab_start_y;
/* Bayer output */
SET_TG_GRAB_PIXEL(isp_grab_start_x+grab_start_x,grab_width-GRAB_INTERPO_WIDTH_PIXEL);
SET_TG_GRAB_LINE(isp_grab_start_y+grab_start_y,grab_height-GRAB_INTERPO_HEIGHT_PIXEL);
#if (defined(MT6219))
SET_SUB_SAMPLE_MODE(0);
SET_GMC_RAW_RGB_MODE;
REG_ISP_DEBUG_WRITE_OUT_ADDR=(kal_uint32) isp_debug_buffer;
#elif (defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6228)||defined(MT6229)||defined(MT6230))
ENABLE_REZ_DISCONN;
DISABLE_REZ_LPF;
SET_OUTPUT_PATH_TYPE(0); /* 0:bayer, 1:ISP output, 2:RGB888, 3:RGB565 */
REG_ISP_OUTPUT_ADDR=(kal_uint32)isp_debug_buffer;
#endif
// skip unstable frames
ENABLE_CAMERA_IDLE_INT;
SET_CAMERA_CAPTURE_MODE;
if(switch_cap_en == KAL_TRUE)
{
SET_CAMERA_FRAME_RATE(0);
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);
}
}
DISABLE_VIEW_FINDER_MODE;
kal_set_eg_events(camera_isp_event_id,0,KAL_AND);
// start capture
#if (defined(MT6219))
ENABLE_GMC_DEBUG_OUTPUT;
#else
ENABLE_CAMERA_OUTPUT_TO_MEM;
#endif
ENABLE_VIEW_FINDER_MODE;
isp_operation_state=ISP_CAPTURE_JPEG_STATE;
kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_IDLE_EVENT,KAL_OR_CONSUME,
&event_group,KAL_SUSPEND);
//DISABLE_CMOS_SESNOR;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -