📄 image_sensor.c
字号:
break;
}
#endif
image_window->grab_start_x=8;////IMAGE_SENSOR_VGA_INSERTED_PIXELS;
image_window->grab_start_y=4;//IMAGE_SENSOR_VGA_INSERTED_LINES+dummy_lines;
#if 0
image_window->exposure_window_width=IMAGE_SENSOR_VGA_WIDTH;
image_window->exposure_window_height=IMAGE_SENSOR_VGA_HEIGHT-4;
#else
image_window->exposure_window_width=IMAGE_SENSOR_VGA_WIDTH-w_blank;
image_window->exposure_window_height=IMAGE_SENSOR_VGA_HEIGHT-h_blank;
#endif
kal_sleep_task(10);
} /* GC0316_preview */
void GC0316_capture(image_sensor_exposure_window_struct *image_window, image_sensor_config_struct *sensor_config_data)
{
volatile kal_uint32 shutter=exposure_lines;
kal_uint8 temp_reg;
sensor_cap_state=KAL_TRUE;
if(MPEG4_encode_mode)
ASSERT(0);
//if(sensor_config_data->enable_shutter_tansfer==KAL_TRUE)
//shutter=sensor_config_data->capture_shutter;
#ifdef OUTPUT_DEBUG_INFO
sprintf(temp_buffer, "Begin of GC0316_capture");
rmmi_write_to_uart((kal_uint8*) temp_buffer, strlen(temp_buffer), KAL_TRUE);
sprintf(temp_buffer, "cap_shutter:%d, pre_shut:%d", shutter, exposure_lines);
rmmi_write_to_uart((kal_uint8*) temp_buffer, strlen(temp_buffer), KAL_TRUE);
#endif
if(!(sensor_config_data->frame_rate==0xF0)) // If not WEBCAM mode.
{
// turn off night mode
}
if ((image_window->image_target_width<=IMAGE_SENSOR_1M_WIDTH)&&
(image_window->image_target_height<=IMAGE_SENSOR_1M_HEIGHT))
{ /* Less than VGA Mode */
if (image_window->digital_zoom_factor>=(ISP_DIGITAL_ZOOM_INTERVAL<<1))
{
SET_TG_PIXEL_CLK_DIVIDER(7);
SET_CMOS_DATA_LATCH(4);
if ((image_window->image_target_width==IMAGE_SENSOR_1M_WIDTH)&&
(image_window->image_target_height==IMAGE_SENSOR_1M_HEIGHT))
// dummy_pixels=2000;
dummy_pixels=0;
else
dummy_pixels=VGA_PERIOD_PIXEL_NUMS/4;
dummy_lines=0;
}
else
{
if(sensor_config_data->frame_rate==0xF0) // That means WEBCAM mode.
{
write_cmos_sensor(0x01,0xe7);
write_cmos_sensor(0x02,0x98);
write_cmos_sensor(0xd6,0x50);
write_cmos_sensor(0x28, 0x01); //
write_cmos_sensor(0x29, 0x90);
write_cmos_sensor(0x2a, 0x01); //exp_level_1, 14fps
write_cmos_sensor(0x2b, 0x90);
write_cmos_sensor(0x2c, 0x04); //exp_level_2 , 7c4~7FPS, 58c~10FPS, 6a8~8.2FPS
write_cmos_sensor(0x2d, 0xb0);
write_cmos_sensor(0x2e, 0x09); //exp_level_3
write_cmos_sensor(0x2f, 0x60);
/* config TG of ISP to match the setting of image sensor*/
SET_TG_OUTPUT_CLK_DIVIDER(5);
SET_CMOS_RISING_EDGE(0);
SET_CMOS_FALLING_EDGE(3);
ENABLE_CAMERA_PIXEL_CLKIN_ENABLE;
//DISABLE_CAMERA_PIXEL_CLKIN_ENABLE;
SET_TG_PIXEL_CLK_DIVIDER(5);
SET_CMOS_DATA_LATCH(3);
w_blank=80;
h_blank=60;
dummy_pixels=0;
dummy_lines=20;
}
else
{
if ((image_window->image_target_width==IMAGE_SENSOR_1M_WIDTH)&&
(image_window->image_target_height==IMAGE_SENSOR_1M_HEIGHT))
{
SET_TG_OUTPUT_CLK_DIVIDER(7);
SET_CMOS_RISING_EDGE(0);
SET_CMOS_FALLING_EDGE(5);
ENABLE_CAMERA_PIXEL_CLKIN_ENABLE;
SET_TG_PIXEL_CLK_DIVIDER(7);
SET_CMOS_DATA_LATCH(5);
shutter=read_GC0316_shutter();
shutter = shutter/4;
write_GC0316_shutter(shutter);
}
else
{
SET_TG_OUTPUT_CLK_DIVIDER(2);
SET_CMOS_RISING_EDGE(0);
SET_CMOS_FALLING_EDGE(1);
ENABLE_CAMERA_PIXEL_CLKIN_ENABLE;
SET_TG_PIXEL_CLK_DIVIDER(2);
SET_CMOS_DATA_LATCH(1);
shutter=read_GC0316_shutter();
//shutter = shutter/2;
kal_prompt_trace(MOD_MMI,"third, shutter=%d " ,shutter);
write_GC0316_shutter(shutter);
}
dummy_lines=0;
}
}
capture_pclk_division=((DRV_Reg32(ISP_TG_PHASE_COUNTER_REG)&0xF0)>>4)+1;
//shutter=read_GC0316_shutter(); //william 20070613
//shutter=(shutter*preview_pclk_division)/capture_pclk_division;
//shutter=(shutter*VGA_PERIOD_PIXEL_NUMS)/(VGA_PERIOD_PIXEL_NUMS+dummy_pixels);
image_window->grab_start_x=8; //IMAGE_SENSOR_VGA_INSERTED_PIXELS;
image_window->grab_start_y=4; //IMAGE_SENSOR_VGA_INSERTED_LINES+dummy_lines;
image_window->exposure_window_width=IMAGE_SENSOR_VGA_WIDTH;
image_window->exposure_window_height=IMAGE_SENSOR_VGA_HEIGHT-4 ; // minus 1 to avoid the last black line
}
} /* GC0316_capture() */
/*************************************************************************
* FUNCTION
* write_GC0316_reg
*
* DESCRIPTION
* This function set the register of GC0316.
*
* PARAMETERS
* addr : the register index of GC0316
* para : setting parameter of the specified register of GC0316
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void write_GC0316_reg(kal_uint32 addr, kal_uint32 para)
{
//write_cmos_sensor(addr,para);
} /* write_GC0316_reg() */
/*************************************************************************
* FUNCTION
* read_cmos_sensor
*
* DESCRIPTION
* This function read parameter of specified register from GC0316.
*
* PARAMETERS
* addr : the register index of GC0316
*
* RETURNS
* the data that read from GC0316
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 read_GC0316_reg(kal_uint32 addr)
{
return (read_cmos_sensor(addr));
} /* read_GC0316_reg() */
/*************************************************************************
* FUNCTION
* set_GC0316_shutter
*
* DESCRIPTION
* This function set e-shutter of GC0316 to change exposure time.
*
* PARAMETERS
* shutter : exposured lines
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void set_GC0316_shutter(kal_uint16 shutter)
{
exposure_lines=shutter;
//write_GC0316_shutter(shutter);
} /* set_GC0316_shutter */
/*************************************************************************
* FUNCTION
* set_GC0316_gain
*
* DESCRIPTION
* This function is to set global gain to sensor.
*
* PARAMETERS
* gain : sensor global gain(base: 0x40)
*
* RETURNS
* the actually gain set to sensor.
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint16 set_GC0316_gain(kal_uint16 gain)
{
}
/*************************************************************************
* FUNCTION
* GC0316_night_mode
*
* DESCRIPTION
* This function night mode of GC0316.
*
* PARAMETERS
* none
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void GC0316_night_mode(kal_bool enable)
{
kal_uint8 temp_reg;
Delayms_GC(100); //daemon 2008-3-27
temp_reg=read_cmos_sensor(0x41);
if(enable)
{
MAX_EXPOSURE_LINES=2*(PIXEL_CLK/MIN_FRAME_RATE)/VGA_PERIOD_PIXEL_NUMS;
sensor_night_mode=KAL_TRUE;
write_cmos_sensor( 0x19 , 0x33 );
write_cmos_sensor( 0x1a , 0x33 );
write_cmos_sensor( 0x8d , 0x13 );
write_cmos_sensor( 0xdd , 0x30 );
// write_cmos_sensor( 0x41 , temp_reg & 0xdf); // CLOSE ABS
// Delayms_GC(100);
// write_cmos_sensor( 0xb0 , 0xf0 );
write_cmos_sensor( 0x82 , 0x11 );
write_cmos_sensor( 0x87 , 0x91 );
write_cmos_sensor( 0x88 , 0x10 );
write_cmos_sensor( 0x89 , 0x08 );
}
else
{
MAX_EXPOSURE_LINES=(PIXEL_CLK/MIN_FRAME_RATE)/VGA_PERIOD_PIXEL_NUMS;
sensor_night_mode=KAL_FALSE;
/* if(gc_EnterCarvingEffect)
{
write_cmos_sensor( 0x8d , 0xff );
write_cmos_sensor( 0x41 , 0x00); // CLOSE ABS
}
else
{
write_cmos_sensor( 0x8d , 0x23 );
write_cmos_sensor( 0x41 , temp_reg | 0x20); // Enable ABS
}*/
write_cmos_sensor( 0x19 , 0x00 );
write_cmos_sensor( 0x1a , 0x00 );
write_cmos_sensor( 0xdd , 0x10 );
write_cmos_sensor( 0x82 , 0x34 );
write_cmos_sensor( 0x87 , 0x93 );
write_cmos_sensor( 0x88 , 0x0a );
write_cmos_sensor( 0x89 , 0x4 );
}
Delayms_GC(100);
if(camera_oper_data.pregain_mode==ISP_ONLY)
sensor_gain_base=BASEGAIN;
}
/*************************************************************************
* FUNCTION
* set_GC0316_flashlight
*
* DESCRIPTION
* turn on/off GC0316 flashlight .
*
* PARAMETERS
* none
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void set_GC0316_flashlight(kal_bool enable)
{
// Todo
}
/*************************************************************************
* FUNCTION
* set_GC0316_param_zoom
*
* DESCRIPTION
* GC0316 zoom setting.
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -