📄 image_sensor.c
字号:
write_cmos_sensor(0x1e, 0x01);
write_cmos_sensor(0x21, 0x00);
write_cmos_sensor(0x22, 0x10);
write_cmos_sensor(0x23, 0x00);
write_cmos_sensor(0x24, 0x0d);
write_cmos_sensor(0x25, 0x00);
write_cmos_sensor(0x26, 0x00);
write_cmos_sensor(0x27, 0x21);
write_cmos_sensor(0x28, 0x10);
write_cmos_sensor(0x29, 0x00);
write_cmos_sensor(0x2a, 0x00);
write_cmos_sensor(0x2b, 0x2d);
write_cmos_sensor(0x2c, 0x82);
write_cmos_sensor(0x2d, 0x01);
write_cmos_sensor(0x2e, 0x28);
write_cmos_sensor(0x2f, 0x2d);
write_cmos_sensor(0x30, 0x64);
write_cmos_sensor(0x31, 0x00);
write_cmos_sensor(0x32, 0x00);
write_cmos_sensor(0x33, 0x0a);
write_cmos_sensor(0x34, 0x87);
write_cmos_sensor(0x35, 0x05);
write_cmos_sensor(0x36, 0x05);
write_cmos_sensor(0x37, 0x05);
write_cmos_sensor(0x38, 0x05);
write_cmos_sensor(0x39, 0x28);
write_cmos_sensor(0x40, 0x00);
write_cmos_sensor(0x41, 0x88);
write_cmos_sensor(0x42, 0x14);
write_cmos_sensor(0x43, 0xa2);
write_cmos_sensor(0x44, 0x1f);
write_cmos_sensor(0x45, 0x02);
write_cmos_sensor(0x46, 0x02);
write_cmos_sensor(0x47, 0x02);
write_cmos_sensor(0x48, 0x20);
write_cmos_sensor(0x49, 0x04);
write_cmos_sensor(0x4a, 0x00);
write_cmos_sensor(0x4b, 0x42);
write_cmos_sensor(0x4c, 0xc2);
write_cmos_sensor(0x4d, 0x40);
write_cmos_sensor(0x50, 0x0c);
write_cmos_sensor(0x51, 0x20);
write_cmos_sensor(0x52, 0x1c);
write_cmos_sensor(0x58, 0x00);
write_cmos_sensor(0x59, 0x00);
write_cmos_sensor(0x5a, 0xff);
write_cmos_sensor(0x5b, 0x03);
write_cmos_sensor(0x5c, 0x19);
write_cmos_sensor(0x60, 0x04);
write_cmos_sensor(0x61, 0x01);
write_cmos_sensor(0x62, 0x44);
write_cmos_sensor(0x63, 0x00);
write_cmos_sensor(0x64, 0xf4);
write_cmos_sensor(0x65, 0x64);
write_cmos_sensor(0x66, 0x64);
write_cmos_sensor(0x67, 0x64);
write_cmos_sensor(0x68, 0x64);
write_cmos_sensor(0x69, 0x64);
write_cmos_sensor(0x6a, 0x64);
write_cmos_sensor(0x6b, 0x64);
write_cmos_sensor(0x6c, 0x64);
write_cmos_sensor(0x6d, 0xc8);
write_cmos_sensor(0x6e, 0xc8);
write_cmos_sensor(0x6f, 0xc8);
write_cmos_sensor(0x70, 0xc8);
write_cmos_sensor(0x71, 0x00);
write_cmos_sensor(0x72, 0x80);
write_cmos_sensor(0x73, 0x40);
write_cmos_sensor(0x76, 0x40);
write_cmos_sensor(0x77, 0x00);
write_cmos_sensor(0x78, 0x00);
write_cmos_sensor(0x79, 0x00);
write_cmos_sensor(0x7a, 0x00);
write_cmos_sensor(0x7b, 0x00);
write_cmos_sensor(0x7c, 0x00);
write_cmos_sensor(0x7d, 0x00);
write_cmos_sensor(0x7e, 0x00);
write_cmos_sensor(0x7f, 0x60);
write_cmos_sensor(0x11, 0x01);
}
// update camera_para from sensor register
void sensor_to_camera_para(void)
{
#if 0
kal_uint32 i;
for(i=0; 0xFFFFFFFF!=camera_para.SENSOR.reg[i].addr; i++)
{
camera_para.SENSOR.reg[i].para = read_PAS6311_reg(camera_para.SENSOR.reg[i].addr);
}
for(i=FACTORY_START_ADDR; 0xFFFFFFFF!=camera_para.SENSOR.reg[i].addr; i++)
{
camera_para.SENSOR.reg[i].para = read_PAS6311_reg(camera_para.SENSOR.reg[i].addr);
}
#endif
}
//------------------------Engineer mode---------------------------------
void get_sensor_group_count(kal_int32* sensor_count_ptr)
{
*sensor_count_ptr=GROUP_TOTAL_NUMS;
return;
}
void get_sensor_group_info(kal_uint16 group_idx, kal_int8* group_name_ptr, kal_int32* item_count_ptr)
{
switch (group_idx)
{
case PRE_GAIN:
sprintf(group_name_ptr, "CCT");
*item_count_ptr = 5;
break;
case SENSOR_DBLC:
sprintf(group_name_ptr, "DBLC");
*item_count_ptr = 1;
break;
case CMMCLK_CURRENT:
sprintf(group_name_ptr, "CMMCLK Current");
*item_count_ptr = 1;
break;
case FRAME_RATE_LIMITATION:
sprintf(group_name_ptr, "Frame Rate Limitation");
*item_count_ptr = 2;
break;
case REGISTER_EDITOR:
sprintf(group_name_ptr, "Register Editor");
*item_count_ptr = 2;
break;
default:
ASSERT(0);
}
}
void get_sensor_item_info(kal_uint16 group_idx,kal_uint16 item_idx, ENG_sensor_info* info_ptr)
{
kal_uint8 temp_reg;
kal_uint16 temp_gain;
switch (group_idx)
{
case PRE_GAIN:
switch (item_idx)
{
case 0:
sprintf(info_ptr->item_name_ptr,"Pregain-R");
temp_reg = read_PAS6311_reg(camera_para.SENSOR.cct[PRE_GAIN_R_INDEX].addr);
temp_gain = 1000*(1+temp_reg)/16;
info_ptr->item_value=temp_gain;
info_ptr->is_true_false=KAL_FALSE;
info_ptr->is_read_only=KAL_FALSE;
info_ptr->is_need_restart=KAL_FALSE;
info_ptr->min=1000;
info_ptr->max=2000;
break;
case 1:
sprintf(info_ptr->item_name_ptr,"Pregain-Gr");
temp_reg = read_PAS6311_reg(camera_para.SENSOR.cct[PRE_GAIN_Gr_INDEX].addr);
temp_gain = 1000*(1+temp_reg)/16;
info_ptr->item_value=temp_gain;
info_ptr->is_true_false=KAL_FALSE;
info_ptr->is_read_only=KAL_FALSE;
info_ptr->is_need_restart=KAL_FALSE;
info_ptr->min=1000;
info_ptr->max=2000;
break;
case 2:
sprintf(info_ptr->item_name_ptr,"Pregain-Gb");
temp_reg = read_PAS6311_reg(camera_para.SENSOR.cct[PRE_GAIN_Gb_INDEX].addr);
temp_gain = 1000*(1+temp_reg)/16;
info_ptr->item_value=temp_gain;
info_ptr->is_true_false=KAL_FALSE;
info_ptr->is_read_only=KAL_FALSE;
info_ptr->is_need_restart=KAL_FALSE;
info_ptr->min=1000;
info_ptr->max=2000;
break;
case 3:
sprintf(info_ptr->item_name_ptr,"Pregain-B");
temp_reg = read_PAS6311_reg(camera_para.SENSOR.cct[PRE_GAIN_B_INDEX].addr);
temp_gain = 1000*(1+temp_reg)/16;
info_ptr->item_value=temp_gain;
info_ptr->is_true_false=KAL_FALSE;
info_ptr->is_read_only=KAL_FALSE;
info_ptr->is_need_restart=KAL_FALSE;
info_ptr->min=1000;
info_ptr->max=2000;
break;
case 4:
sprintf(info_ptr->item_name_ptr,"SENSOR_BASEGAIN");
temp_reg = read_PAS6311_reg(camera_para.SENSOR.cct[SENSOR_BASEGAIN].addr);
temp_reg &= 0x18;
if(temp_reg == 0)
info_ptr->item_value=1000;
else if(temp_reg == 0x08)
info_ptr->item_value=1333;
else if(temp_reg == 0x10)
info_ptr->item_value=2000;
else if(temp_reg == 0x18)
info_ptr->item_value=4000;
info_ptr->is_true_false=KAL_FALSE;
info_ptr->is_read_only=KAL_FALSE;
info_ptr->is_need_restart=KAL_FALSE;
info_ptr->min=1000;
info_ptr->max=4000;
break;
default:
ASSERT(0);
}
break;
case SENSOR_DBLC:
switch (item_idx)
{
case 0:
sprintf(info_ptr->item_name_ptr,"DBLC Enable");
temp_reg = read_PAS6311_reg(camera_para.SENSOR.reg[SENSOR_DBLC_INDEX].addr);
if(temp_reg&0x80)
{
info_ptr->item_value=1;
}
else
{
info_ptr->item_value=0;
}
info_ptr->is_true_false=KAL_TRUE;
info_ptr->is_read_only=KAL_FALSE;
info_ptr->is_need_restart=KAL_FALSE;
info_ptr->min=0;
info_ptr->max=1;
break;
default:
ASSERT(0);
}
break;
case CMMCLK_CURRENT:
switch (item_idx)
{
case 0:
sprintf(info_ptr->item_name_ptr,"Drv Cur[2,4,6,8]mA");
temp_reg=camera_para.SENSOR.reg[CMMCLK_CURRENT_INDEX].para;
if(temp_reg==ISP_DRIVING_2MA)
{
info_ptr->item_value=2;
}
else if(temp_reg==ISP_DRIVING_4MA)
{
info_ptr->item_value=4;
}
else if(temp_reg==ISP_DRIVING_6MA)
{
info_ptr->item_value=6;
}
else if(temp_reg==ISP_DRIVING_8MA)
{
info_ptr->item_value=8;
}
info_ptr->is_true_false=KAL_FALSE;
info_ptr->is_read_only=KAL_FALSE;
info_ptr->is_need_restart=KAL_TRUE;
info_ptr->min=2;
info_ptr->max=8;
break;
default:
ASSERT(0);
}
break;
case FRAME_RATE_LIMITATION:
switch (item_idx)
{
case 0:
sprintf(info_ptr->item_name_ptr,"Max Exposure Lines");
info_ptr->item_value=MAX_EXPOSURE_LINES;
info_ptr->is_true_false=KAL_FALSE;
info_ptr->is_read_only=KAL_TRUE;
info_ptr->is_need_restart=KAL_FALSE;
info_ptr->min=0;
info_ptr->max=0;
break;
case 1:
sprintf(info_ptr->item_name_ptr,"Min Frame Rate");
info_ptr->item_value=MIN_FRAME_RATE;
info_ptr->is_true_false=KAL_FALSE;
info_ptr->is_read_only=KAL_TRUE;
info_ptr->is_need_restart=KAL_FALSE;
info_ptr->min=0;
info_ptr->max=0;
break;
default:
ASSERT(0);
}
break;
case REGISTER_EDITOR:
switch (item_idx)
{
case 0:
sprintf(info_ptr->item_name_ptr,"REG Addr.");
info_ptr->item_value=0;
info_ptr->is_true_false=KAL_FALSE;
info_ptr->is_read_only=KAL_FALSE;
info_ptr->is_need_restart=KAL_FALSE;
info_ptr->min=0;
info_ptr->max=0xFF;
break;
case 1:
sprintf(info_ptr->item_name_ptr,"REG Value");
info_ptr->item_value=0;
info_ptr->is_true_false=KAL_FALSE;
info_ptr->is_read_only=KAL_FALSE;
info_ptr->is_need_restart=KAL_FALSE;
info_ptr->min=0;
info_ptr->max=0xFF;
break;
default:
ASSERT(0);
}
break;
default:
ASSERT(0);
}
}
kal_bool set_sensor_item_info(kal_uint16 group_idx, kal_uint16 item_idx, kal_int32 item_value)
{
kal_uint8 temp_reg;
kal_uint16 temp_gain;
switch (group_idx)
{
case PRE_GAIN:
switch (item_idx)
{
case 0:
temp_gain = (item_value*BASEGAIN+500)/1000;
if (temp_gain >= 1*BASEGAIN && temp_gain < 2*BASEGAIN)
{
temp_reg = 16*temp_gain/BASEGAIN-1;
}
else if (temp_gain >= 2*BASEGAIN)
{
temp_reg = 16*2-1;
}
camera_para.SENSOR.cct[PRE_GAIN_R_INDEX].para = temp_reg;
write_PAS6311_reg(camera_para.SENSOR.cct[PRE_GAIN_R_INDEX].addr,temp_reg);
break;
case 1:
temp_gain = (item_value*BASEGAIN+500)/1000;
if (temp_gain >= 1*BASEGAIN && temp_gain < 2*BASEGAIN)
{
temp_reg = 16*temp_gain/BASEGAIN-1;
}
else if (temp_gain >= 2*BASEGAIN)
{
temp_reg = 16*2-1;
}
camera_para.SENSOR.cct[PRE_GAIN_Gr_INDEX].para = temp_reg;
write_PAS6311_reg(camera_para.SENSOR.cct[PRE_GAIN_Gr_INDEX].addr,temp_reg);
break;
case 2:
temp_gain = (item_value*BASEGAIN+500)/1000;
if (temp_gain >= 1*BASEGAIN && temp_gain < 2*BASEGAIN)
{
temp_reg = 16*temp_gain/BASEGAIN-1;
}
else if (temp_gain >= 2*BASEGAIN)
{
temp_reg = 16*2-1;
}
camera_para.SENSOR.cct[PRE_GAIN_Gb_INDEX].para = temp_reg;
write_PAS6311_reg(camera_para.SENSOR.cct[PRE_GAIN_Gb_INDEX].addr,temp_reg);
break;
case 3:
temp_gain = (item_value*BASEGAIN+500)/1000;
if (temp_gain >= 1*BASEGAIN && temp_gain < 2*BASEGAIN)
{
temp_reg = 16*temp_gain/BASEGAIN-1;
}
else if (temp_gain >= 2*BASEGAIN)
{
temp_reg = 16*2-1;
}
camera_para.SENSOR.cct[PRE_GAIN_B_INDEX].para = temp_reg;
write_PAS6311_reg(camera_para.SENSOR.cct[PRE_GAIN_B_INDEX].addr,temp_reg);
break;
case 4:
temp_reg = read_PAS6311_reg(camera_para.SENSOR.cct[SENSOR_BASEGAIN].addr);
temp_reg &= ~0x18;
if(item_value>=1000 && item_value<1333)
temp_reg |= 0x00;
else if(item_value>=1333 && item_value<2000)
temp_reg |= 0x08;
else if(item_value>=2000 && item_value<4000)
temp_reg |= 0x10;
else if(item_value>=4000)
temp_reg |= 0x18;
else
return KAL_FALSE;
camera_para.SENSOR.cct[SENSOR_BASEGAIN].para = temp_reg;
write_PAS6311_reg(camera_para.SENSOR.cct[SENSOR_BASEGAIN].addr,temp_reg);
break;
default:
ASSERT(0);
}
break;
case SENSOR_DBLC:
switch (item_idx)
{
case 0:
if(item_value==1)
{
temp_reg = read_PAS6311_reg(camera_para.SENSOR.reg[SENSOR_DBLC_INDEX].addr);
temp_reg |= 0x80;
camera_para.SENSOR.reg[SENSOR_DBLC_INDEX].para = temp_reg;
write_PAS6311_reg(camera_para.SENSOR.reg[SENSOR_DBLC_INDEX].addr,temp_reg);
}
else
{
temp_reg = read_PAS6311_reg(camera_para.SENSOR.reg[SENSOR_DBLC_INDEX].addr);
temp_reg &= ~0x80;
camera_para.SENSOR.reg[SENSOR_DBLC_INDEX].para = temp_reg;
write_PAS6311_reg(camera_para.SENSOR.reg[SENSOR_DBLC_INDEX].addr,temp_reg);
}
break;
default:
ASSERT(0);
}
break;
case CMMCLK_CURRENT:
switch (item_idx)
{
case 0:
if(item_value==2)
{
camera_para.SENSOR.reg[CMMCLK_CURRENT_INDEX].para = ISP_DRIVING_2MA;
set_isp_driving_current(ISP_DRIVING_2MA);
}
else if(item_value==3 || item_value==4)
{
camera_para.SENSOR.reg[CMMCLK_CURRENT_INDEX].para = ISP_DRIVING_4MA;
set_isp_driving_current(ISP_DRIVING_4MA);
}
else if(item_value==5 || item_value==6)
{
camera_para.SENSOR.reg[CMMCLK_CURRENT_INDEX].para = ISP_DRIVING_6MA;
set_isp_driving_current(ISP_DRIVING_6MA);
}
else
{
camera_para.SENSOR.reg[CMMCLK_CURRENT_INDEX].para = ISP_DRIVING_8MA;
set_isp_driving_current(ISP_DRIVING_8MA);
}
break;
default:
ASSERT(0);
}
break;
case FRAME_RATE_LIMITATION:
switch (item_idx)
{
ASSERT(0);
}
break;
case REGISTER_EDITOR:
switch (item_idx)
{
case 0:
FAC_SENSOR_REG=item_value;
break;
case 1:
write_PAS6311_reg(FAC_SENSOR_REG,item_value);
break;
default:
ASSERT(0);
}
break;
default:
ASSERT(0);
}
return KAL_TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -