📄 image_sensor.c
字号:
//shutter=(shutter*PV_PERIOD_PIXEL_NUMS)/(PV_PERIOD_PIXEL_NUMS+dummy_pixels);
// shutter=shutter*2;
#if 0
if(temp_reg_banding)
{
if (shutter>=0x9d && shutter<= 3*0x9d )
shutter = shutter + 0x9d/2;//shutter=shutter+(0x9e - 0x1)/2;
}
else
{
if (shutter>=0x83 && shutter<= 3*0x83 )
shutter=shutter+0x83/2;
}
#endif
image_window->grab_start_x=IMAGE_SENSOR_PV_INSERTED_PIXELS+start_grab_x_offset;
image_window->grab_start_y=IMAGE_SENSOR_PV_INSERTED_LINES+dummy_lines+start_grab_x_offset;
image_window->exposure_window_width=IMAGE_SENSOR_PV_WIDTH+start_grab_x_offset-8;
image_window->exposure_window_height=IMAGE_SENSOR_PV_HEIGHT+start_grab_x_offset-4; //fot porting test now
}
else
if ((image_window->image_target_width<=IMAGE_SENSOR_FULL_WIDTH)&&
(image_window->image_target_height<=IMAGE_SENSOR_FULL_HEIGHT))
{ /* 1.3M FULL Mode */
write_cmos_sensor(0x12,0x00);
gPVmode=KAL_FALSE;
// Configure SXGA Window of Interest
/*
write_cmos_sensor(0x03,0x1B);
write_cmos_sensor(0x17,0x1D);
write_cmos_sensor(0x18,0xBD);
write_cmos_sensor(0x32,0xFF);
*/
//1280*1024
write_cmos_sensor(0x63, 0x01); //
//this two important
write_cmos_sensor(0x4d, 0x11);
write_cmos_sensor(0x17,0x0d);
write_cmos_sensor(0x18,0x5d);
write_cmos_sensor(0x19,0x01);
write_cmos_sensor(0x1A,0x82);
write_cmos_sensor(0x03, 0x03);
write_cmos_sensor(0x32, 0x24);
write_cmos_sensor(0x2b, 0x00);
write_cmos_sensor(0x64, 0x24);
write_cmos_sensor(0xab, 0xe7);
write_cmos_sensor(0xb9, 0xa0);
write_cmos_sensor(0xba, 0x80);
write_cmos_sensor(0xbb, 0xa0);
write_cmos_sensor(0xbc, 0x80);
write_cmos_sensor(0x0d, 0x82);
write_cmos_sensor(0x0d, 0x80);
// config_OV9660_window(235,15,(IMAGE_SENSOR_FULL_WIDTH+4),(IMAGE_SENSOR_FULL_HEIGHT+4));
if (image_window->digital_zoom_factor>=(ISP_DIGITAL_ZOOM_INTERVAL<<1))
{ /* digital zoom factor >=2 */
/* degrade the main clk to increase the itnerval of pixel clock to
increase the processing time of resizer for every pixel. that cause
exposure time double*/
write_cmos_sensor(0x11,0x87);
SET_TG_PIXEL_CLK_DIVIDER(3);
SET_CMOS_DATA_LATCH(1);
dummy_pixels=(PV_PERIOD_PIXEL_NUMS/10+PV_PERIOD_PIXEL_NUMS);
dummy_lines=0;
}
else
{
write_cmos_sensor(0x11,0x83);
//default SXGA PLL PCLK * 2
SET_TG_PIXEL_CLK_DIVIDER(1);
SET_CMOS_DATA_LATCH(0);
dummy_pixels=0x4d;
dummy_lines=0;
//dummy_pixels=PV_PERIOD_PIXEL_NUMS/10;
//dummy_lines=0;
}
capture_pclk_division=((DRV_Reg32(ISP_TG_PHASE_COUNTER_REG)&0xF0)>>4)+1;
#if 0
shutter=(shutter*preview_pclk_division) *2 /capture_pclk_division;
shutter=(shutter*PV_PERIOD_PIXEL_NUMS)/(FULL_PERIOD_PIXEL_NUMS+dummy_pixels*2);
if(temp_reg_banding)
{
if (shutter>=0x9d && shutter<= 6*0x9d )
shutter = shutter + 0x9d;//shutter=shutter+(0x9e - 0x1)/2;
}
else
{
if (shutter>=0x83 && shutter<= 6*0x83 )
shutter=shutter+0x83;
}
#endif
shutter=(shutter*preview_pclk_division)/capture_pclk_division;
shutter=shutter/2;
//shutter=(shutter*PV_PERIOD_PIXEL_NUMS)/(FULL_PERIOD_PIXEL_NUMS+dummy_pixels*2);
//shutter=shutter*2;
#if 0
if (shutter < FULL_EXPOSURE_LIMITATION / 2) { // convert gain to exposure
if (sensor_global_gain > 2 * BASEGAIN) {
sensor_global_gain = sensor_global_gain / 2;
shutter = shutter * 2;
}
}
#endif
image_window->grab_start_x=IMAGE_SENSOR_FULL_INSERTED_PIXELS;
image_window->grab_start_y=IMAGE_SENSOR_FULL_INSERTED_LINES+dummy_lines;
image_window->exposure_window_width=IMAGE_SENSOR_FULL_WIDTH-4;
image_window->exposure_window_height=IMAGE_SENSOR_FULL_HEIGHT-4;
}
else
{
write_cmos_sensor(0x12,0x00);
gPVmode=KAL_FALSE;
// Configure SXGA Window of Interest
/*
write_cmos_sensor(0x03,0x1B);
write_cmos_sensor(0x17,0x1D);
write_cmos_sensor(0x18,0xBD);
write_cmos_sensor(0x32,0xFF);
*/
//1280*1024
write_cmos_sensor(0x63, 0x01); //
//this two important
write_cmos_sensor(0x4d, 0x11);
write_cmos_sensor(0x17,0x0d);
write_cmos_sensor(0x18,0x5d);
write_cmos_sensor(0x19,0x01);
write_cmos_sensor(0x1A,0x82);
write_cmos_sensor(0x03, 0x03);
write_cmos_sensor(0x32, 0x24);
write_cmos_sensor(0x2b, 0x00);
write_cmos_sensor(0x64, 0x24);
write_cmos_sensor(0xab, 0xe7);
write_cmos_sensor(0xb9, 0xa0);
write_cmos_sensor(0xba, 0x80);
write_cmos_sensor(0xbb, 0xa0);
write_cmos_sensor(0xbc, 0x80);
write_cmos_sensor(0x0d, 0x82);
write_cmos_sensor(0x0d, 0x80);
if (image_window->digital_zoom_factor>=(ISP_DIGITAL_ZOOM_INTERVAL<<1))
{ /* digital zoom factor >=2 */
/* degrade the main clk to increase the itnerval of pixel clock to
increase the processing time of resizer for every pixel. that cause
exposure time double*/
write_cmos_sensor(0x11,0x87);
SET_TG_PIXEL_CLK_DIVIDER(3);
SET_CMOS_DATA_LATCH(1);
dummy_pixels=(PV_PERIOD_PIXEL_NUMS/10+PV_PERIOD_PIXEL_NUMS);
dummy_lines=0;
}
else
{
write_cmos_sensor(0x11,0x87);
//default SXGA PLL PCLK * 2
SET_TG_PIXEL_CLK_DIVIDER(3);
SET_CMOS_DATA_LATCH(1);
dummy_pixels=0x4d;
dummy_lines=0;
//dummy_pixels=PV_PERIOD_PIXEL_NUMS/10;
//dummy_lines=0;
}
capture_pclk_division=((DRV_Reg32(ISP_TG_PHASE_COUNTER_REG)&0xF0)>>4)+1;
#if 0
shutter=(shutter*preview_pclk_division) *2 /capture_pclk_division;
shutter=(shutter*PV_PERIOD_PIXEL_NUMS)/(FULL_PERIOD_PIXEL_NUMS+dummy_pixels*2);
if(temp_reg_banding)
{
if (shutter>=0x9d && shutter<= 6*0x9d )
shutter = shutter + 0x9d;//shutter=shutter+(0x9e - 0x1)/2;
}
else
{
if (shutter>=0x83 && shutter<= 6*0x83 )
shutter=shutter+0x83;
}
#endif
shutter=(shutter*preview_pclk_division) /capture_pclk_division;
shutter=shutter/2;
//shutter=(shutter*PV_PERIOD_PIXEL_NUMS)/(FULL_PERIOD_PIXEL_NUMS+dummy_pixels*2);
//shutter=shutter*2;
#if 0
if (shutter < FULL_EXPOSURE_LIMITATION / 2) { // convert gain to exposure
if (sensor_global_gain > 2 * BASEGAIN) {
sensor_global_gain = sensor_global_gain / 2;
shutter = shutter * 2;
}
}
#endif
image_window->grab_start_x=IMAGE_SENSOR_FULL_INSERTED_PIXELS;
image_window->grab_start_y=IMAGE_SENSOR_FULL_INSERTED_LINES+dummy_lines;
image_window->exposure_window_width=IMAGE_SENSOR_FULL_WIDTH-4;
image_window->exposure_window_height=IMAGE_SENSOR_FULL_HEIGHT-4;
}
if(shutter<1)
shutter=1;
set_OV9660_dummy(dummy_pixels,dummy_lines);
write_OV9660_shutter(shutter);
#if 0
write_OV9660_gain(sensor_global_gain);
#endif
#if 0 //def OUTPUT_DEBUG_INFO
kal_prompt_trace(MOD_MED,"shutter=%d, sensor_global_gain=%d",read_OV9660_shutter(),read_OV9660_gain());
#endif
#ifdef OUTPUT_DEBUG_INFO
sprintf(temp_buffer, "cap_shut:%d, pre_shut:%d, pre_pclk_div=%d, cap_pclk_div=%d, dummy_p=%d, dummy_l=%d", shutter, exposure_lines, preview_pclk_division, capture_pclk_division, dummy_pixels, dummy_lines);
rmmi_write_to_uart((kal_uint8*) temp_buffer, strlen(temp_buffer), KAL_TRUE);
sprintf(temp_buffer, "End of OV9660_capture");
rmmi_write_to_uart((kal_uint8*) temp_buffer, strlen(temp_buffer), KAL_TRUE);
#endif
} /* OV9660_capture() */
/*************************************************************************
* FUNCTION
* write_OV9660_reg
*
* DESCRIPTION
* This function set the register of OV9660.
*
* PARAMETERS
* addr : the register index of OV9660
* para : setting parameter of the specified register of OV9660
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void write_OV9660_reg(kal_uint32 addr, kal_uint32 para)
{
write_cmos_sensor(addr,para);
} /* write_OV9660_reg() */
/*************************************************************************
* FUNCTION
* read_cmos_sensor
*
* DESCRIPTION
* This function read parameter of specified register from OV9660.
*
* PARAMETERS
* addr : the register index of OV9660
*
* RETURNS
* the data that read from OV9660
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 read_OV9660_reg(kal_uint32 addr)
{
return (read_cmos_sensor(addr));
} /* read_OV9660_reg() */
/*************************************************************************
* FUNCTION
* set_OV9660_shutter
*
* DESCRIPTION
* This function set e-shutter of OV9660 to change exposure time.
*
* PARAMETERS
* shutter : exposured lines
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void set_OV9660_shutter(kal_uint16 shutter)
{
} /* set_OV9660_shutter */
/*************************************************************************
* FUNCTION
* set_OV9660_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_OV9660_gain(kal_uint16 gain)
{
return gain;
}
/*************************************************************************
* FUNCTION
* OV9660_night_mode
*
* DESCRIPTION
* This function night mode of OV9660.
*
* PARAMETERS
* none
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void OV9660_night_mode(kal_bool enable)
{
kal_uint32 reg_data=read_cmos_sensor(0x03);
kal_uint32 reg_data1=read_cmos_sensor(0x0f);
if(!sensor_cap_state)
{
if(enable)
{
write_cmos_sensor(0x0f,reg_data1|0x08);//04
write_cmos_sensor(0x03,reg_data|0x80);//c0降低贞率
/* set Max gain to 16X */
write_cmos_sensor(0x14,0x48);//68 //亮度亮,躁声大
}
else
{
write_cmos_sensor(0x0f,(reg_data1&(~0x08)));//04
write_cmos_sensor(0x03,reg_data&0x03);
/* set Max gain to 8X */
write_cmos_sensor(0x14,0x38);//48
write_cmos_sensor(0x2D,0x00);
write_cmos_sensor(0x2E,0x00);
}
}
} /* OV9660_night_mode */
/*************************************************************************
* FUNCTION
* set_OV9660_flashlight
*
* DESCRIPTION
* turn on/off OV9660 flashlight .
*
* PARAMETERS
* none
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void set_OV9660_flashlight(kal_bool enable)
{
// Todo
}
/*************************************************************************
* FUNCTION
* set_OV9660_param_zoom
*
* DESCRIPTION
* OV9660 zoom setting.
*
* PARAMETERS
* none
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 set_OV9660_param_zoom(kal_uint32 para)
{
return KAL_FALSE;
}
/*************************************************************************
* FUNCTION
* set_OV9660_param_contrast
*
* DESCRIPTION
* OV9660 contrast setting.
*
* PARAMETERS
* none
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 set_OV9660_param_contrast(kal_uint32 para)
{
// Not Support
return KAL_FALSE;
}
/*************************************************************************
* FUNCTION
* set_OV9660_param_brightness
*
* DESCRIPTION
* OV9660 brightness setting.
*
* PARAMETERS
* none
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 set_OV9660_param_brightness(kal_uint32 para)
{
// Not Support
return KAL_FALSE;
}
/*************************************************************************
* FUNCTION
* set_OV9660_param_hue
*
* DESCRIPTION
* OV9660 hue setting.
*
* PARAMETERS
* none
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint32 set_OV9660_param_hue(kal_uint32 para)
{
// Not Support
return KAL_FALSE;
}
/*************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -