📄 l2_fadjust.c
字号:
ULONG pixclk;
USHORT linetotal, frametotal, espline;
float temp;
//XBYTE[0X203A] = XBYTE[0X203A] | 0x20; //GPIO21 Output enable
//XBYTE[0X2032] = XBYTE[0X2032] | 0x20; //GPIO21 = 1
//XBYTE[0X2032] = XBYTE[0X2032] & 0xDF; //GPIO21 = 0
//PRINT_FRONT (" Enter L2_SetExposureTime \n");
//PRINT_FRONT (" Number = %d \n", Number);
option1 = Option & 0x01;
//Caculate the linetotal, frametotal, pixel clock /////////////////////////////////////////////
temp1 = XBYTE[0X2A41];
temp2 = XBYTE[0X2A42];
linetotal = (USHORT)(temp2 << 8) + (USHORT)temp1;
temp1 = XBYTE[0X2A50];
temp2 = XBYTE[0X2A51];
frametotal = (USHORT)(temp2 << 8) + (USHORT)temp1;
temp1 = XBYTE[0x2A81];
temp2 = XBYTE[0x2A82];
tgpll = XBYTE[0x2080] & 0x01;
temp = (float)(((XBYTE[0x2082] & 0x07) + 1) * (((XBYTE[0x2082] >> 4) & 0x07) + 1));
if (tgpll)
pixclk = (6000000 * temp) / ((ULONG)(temp1 + 1) * (ULONG)(temp2 + 1) * (ULONG)(XBYTE[0x2081] + 1));
else
pixclk = 96000000 / ((ULONG)(temp1 + 1) * (ULONG)(temp2 + 1));
//////////////////////////////////////////////////////////////////////////////////////////////
//Caculate the Exposure time to Exposure Line number ////////////////////////////////////////
temp = (pixclk * 10) / ((ULONG)linetotal * (ULONG)Number);
espline = (USHORT) temp;
//PRINT_FRONT (" Frametotal = %d \n", (USHORT)frametotal);
//PRINT_FRONT (" espline = %x \n", (USHORT)espline);
//PRINT_FRONT (" pixclk = %ld \n", pixclk);
/*
if (espline > frametotal)
{
//PRINT_FRONT (" Espline > Frametotal \n");
//PRINT_FRONT (" Exit L2_SetExposureTime \n");
//return 1;
}*/
/////////////////////////////////////////////////////////////////////////////////////////////
#ifdef OV13 // Ov9620 1.3M CMOS Sensor
{
UCHAR i, j;
UCHAR reg_addr[1], reg_data[1];
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
reg_addr[0] = 0x04;
reg_data[0] = (UCHAR)(espline & 0x07);
L2_WriteSSC(reg_addr, reg_data, 1, option1);
//for (i=0; i<40;i++) //Delay
//for (j=0; j<255; j++);
reg_addr[0] = 0x10;
reg_data[0] = (UCHAR)(espline >> 3);
L2_WriteSSC(reg_addr, reg_data, 1, 0);
//for (i=0; i<40;i++) //Delay
//for (j=0; j<255; j++);
//L2_ReadSSC(0x04, reg_data, 0x01, 0x01);
//PRINT_FRONT ("Reg 0x04 = %x \n", (USHORT)reg_data[0]);
//L2_ReadSSC(0x10, reg_data, 0x01, 0x01);
//PRINT_FRONT ("Reg 0x10 = %x \n", (USHORT)reg_data[0]);
}
#endif
#ifdef OV2610 // Ov 2.0M CMOS Sensor
{
UCHAR i, j;
UCHAR reg_addr[1], reg_data[1];
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
reg_addr[0] = 0x04;
reg_data[0] = (UCHAR)(espline & 0x07);
L2_WriteSSC(reg_addr, reg_data, 1, option1);
reg_addr[0] = 0x10;
reg_data[0] = (UCHAR)(espline >> 3);
L2_WriteSSC(reg_addr, reg_data, 1, 0);
}
#endif
#ifdef OV3610 // Ov 3.2M CMOS Sensor //patch5.2.1@jhyu@OV3610
{
// UCHAR i, j;
UCHAR reg_addr[1], reg_data[1];
reg_addr[0] = 0x04;
reg_data[0] = (UCHAR)(espline & 0x07);
L2_WriteSSC(reg_addr, reg_data, 1, option1);
reg_addr[0] = 0x10;
reg_data[0] = (UCHAR)(espline >> 3);
L2_WriteSSC(reg_addr, reg_data, 1, 0);
//UI_PrintOSDNumber(Tidx, 2, 2, 4);
}
#endif
//-------------------Davis:patch4.0.0.0_2005/Jun/07 begin
#ifdef OV3620
{
UCHAR i, j;
UCHAR reg_addr[1], reg_data[1];
reg_addr[0] = 0x04;
reg_data[0] = (UCHAR)(espline & 0x07);
L2_WriteSSC(reg_addr, reg_data, 1, option1);
reg_addr[0] = 0x10;
reg_data[0] = (UCHAR)(espline >> 3);
L2_WriteSSC(reg_addr, reg_data, 1, 0);
}
#endif
//-------------------Davis:patch4.0.0.0_2005/Jun/07 end
#ifdef ICM107B //IC-Media 1.0M CMOS Sensor
{
UCHAR i, j;
UCHAR reg_addr[1], reg_data[1];
espline = espline >> 2; //Do this because exposure should = 4n + 2
espline = espline << 2;
espline = espline - 2;
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
reg_addr[0] = 0x00; //Set to single frame VGA mode
reg_data[0] = 0x89;
L2_WSSC107(reg_addr, reg_data, 0x01, 0x00);
L3_WaitUpdate107();
for (i = 0; i < 75; i++)
for (j = 0; j < 255; j++);
reg_addr[0] = 0x1C; //Set Exposure time LOW
reg_data[0] = (UCHAR)espline;
L2_WSSC107(reg_addr, reg_data, 0x01, 0x00);
reg_addr[0] = 0x1D; //Set Exposure time High
reg_data[0] = (UCHAR)(espline >> 8);
L2_WSSC107(reg_addr, reg_data, 0x01, 0x00);
reg_addr[0] = 0x00; //Update Exposure time
reg_data[0] = 0x88;
L2_WSSC107(reg_addr, reg_data, 0x01, 0x00);
}
#endif
#ifdef ICM108 //IC-Media 1.3M CMOS Sensor
{
UCHAR i, j;
UCHAR reg_addr[1], reg_data[1];
espline = espline >> 2; //Do this because exposure should = 4n + 2
espline = espline << 2;
espline = espline - 2;
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
reg_addr[0] = 0x00; //Set to single frame VGA mode
reg_data[0] = 0x89;
L2_WSSC108(reg_addr, reg_data, 0x01, 0x00);
L3_WaitUpdate108();
for (i = 0; i < 75; i++)
for (j = 0; j < 255; j++);
reg_addr[0] = 0x1C; //Set Exposure time LOW
reg_data[0] = (UCHAR)espline;
L2_WSSC108(reg_addr, reg_data, 0x01, 0x00);
reg_addr[0] = 0x1D; //Set Exposure time High
reg_data[0] = (UCHAR)(espline >> 8);
L2_WSSC108(reg_addr, reg_data, 0x01, 0x00);
reg_addr[0] = 0x00; //Update Exposure time
reg_data[0] = 0x88;
L2_WSSC108(reg_addr, reg_data, 0x01, 0x00);
}
#endif
//patch4.4@andrew@ICM109
#ifdef ICM109 //IC-Media 2M CMOS Sensor
{
UCHAR i, j;
UCHAR reg_addr[1], reg_data[1];
espline = espline >> 2; //Do this because exposure should = 4n + 2
espline = espline << 2;
espline = espline - 2;
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
reg_addr[0] = 0x00; //Set to single frame VGA mode
reg_data[0] = 0x89;
L2_WSSC109(reg_addr, reg_data, 0x01, 0x00);
L3_WaitUpdate109();
for (i = 0; i < 75; i++)
for (j = 0; j < 255; j++);
DbgPrint("**********\n\nICM 109 exp line=%x\n\n *********\n",espline);
reg_addr[0] = 0x1C; //Set Exposure time LOW
reg_data[0] = (UCHAR)espline;
L2_WSSC109(reg_addr, reg_data, 0x01, 0x00);
reg_addr[0] = 0x1D; //Set Exposure time High
reg_data[0] = (UCHAR)(espline >> 8);
L2_WSSC109(reg_addr, reg_data, 0x01, 0x00);
reg_addr[0] = 0x00; //Update Exposure time
reg_data[0] = 0x88;
L2_WSSC109(reg_addr, reg_data, 0x01, 0x00);
}
#endif
#ifdef MCM20027 // Motorola 1.3M CMOS Sensor
{
UCHAR reg_addr[2], reg_data[2], option1, update[1];
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
if (espline > 0x3FFF)
return 1;
L2_ReadSSC(0x4E, update, 0x01, 0x01);
update[0] = update[0] & 0x40;
reg_addr[0] = 0x4F;
reg_addr[1] = 0x4E;
reg_data[0] = (UCHAR)(espline-1);//patch4.3@jhyu@0612
if (update[0])
reg_data[1] = ((UCHAR)((espline-1) >> 8) & 0x3F);//patch4.3@jhyu@0612
else
reg_data[1] = ((UCHAR)((espline-1) >> 8) & 0x3F) | 0x40; //patch4.3@jhyu@0612
option1 = option1 | 0x02; //Always in Burst mode
L2_WriteSSC(reg_addr, reg_data, 0x02, option1);
}
#endif
#ifdef ICM105 //IC-Media VGA CMOS Sensor
{
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
reg_addr[0] = 0x1C;
reg_addr[1] = 0x1D;
reg_data[0] = (UCHAR)espline;
reg_data[1] = (UCHAR)(espline >> 8);
option1 = option1 | 0x02; //Always in Burst mode
L2_WriteSSC(reg_addr, reg_data, 0x02, 0x02);
reg_addr[0] = 0x00; //Update Value
reg_data[0] = 0x84;
L2_WriteSSC(reg_addr, reg_data, 0x01, option1);
}
#endif
#ifdef TASC5130 // TASC VGA sensor
espline = espline - 1; //Because Read use 1 line
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
#endif
#ifdef TASC5160
{
// TASC VGA sensor
unsigned char reg_data[2];
// printf("L2_SetExposureTime: Number = 0x%x\n", Number);
// printf (" L2_SetExposureTime for TASC_5160\n");
espline = frametotal-espline + 1; //Because Read use 1 line
// espline = espline - 1; //Because Read use 1 line
// printf (" Espline = %d \n", (USHORT)espline);
if(espline>0x0fff)return 1;
printf("L2_SetExposureTime: espline = 0x%x\n", espline);
reg_data[0] =(UCHAR)((espline<<4)&0x00f0); //Set Exposure time;
reg_data[1] = (UCHAR)(espline>>4); //Set Exposure time;
printf("L2_SetExposureTime: reg_data[0] = 0x%bx\n", reg_data[0]);
printf("L2_SetExposureTime: reg_data[1] = 0x%bx\n", reg_data[1]);
L2_WriteSI(reg_data, 1);
}
#endif
#ifdef YM3170 // IC-Media 3M CMOS Sensor
{
UCHAR reg_addr[1], reg_data[1], option1;
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
XBYTE[0X2032] = XBYTE[0X2032] & 0xDF; //GPIO21 = 0
reg_addr[0] = 0xB9; //Set Exposure time LOW
reg_data[0] = (UCHAR)(espline >> 8);
L2_WriteSSC(reg_addr, reg_data, 0x01, option1);
XBYTE[0X2032] = XBYTE[0X2032] | 0x20; //GPIO21 = 1
//PRINT_FRONT (" espline low = %bx \n", (UCHAR)espline);
XBYTE[0X2032] = XBYTE[0X2032] & 0xDF; //GPIO21 = 0
reg_addr[0] = 0xB8; //Set Exposure time High
reg_data[0] = (UCHAR)(espline);
L2_WriteSSC(reg_addr, reg_data, 0x01, option1);
XBYTE[0X2032] = XBYTE[0X2032] | 0x20; //GPIO21 = 1
//PRINT_FRONT (" espline high = %bx \n", (UCHAR)(espline >> 8));
}
#endif
#ifdef RJ23N3 // Sharp 2.0M CCD Sensor
{
espline = espline -2; //Because Read use 2 line
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
#ifdef RJ23P3AA // Sharp 3.0M CCD Sensor
{
espline = espline -2; //Because Read use 2 line
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
#ifdef SONY432 // SONY 3.0M CCD Sensor
{
espline = espline -2; //Because Read use 2 line
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
#ifdef SONY406 // SONY 4.0M CCD Sensor
{
espline = espline -2; //Because Read use 2 line
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
#ifdef SONY262 // SONY 262 3M interlace CCDSENSOR
{
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
espline = espline -1; //Because Read use 1 line
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
#ifdef SONY232 // SONY 232 1.3M interlace CCDSENSOR
{
espline = espline -1; //Because Read use 1 line
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
#ifdef SONY442 // SONY 442 1.3M Progressive CCDSENSOR
{
espline = espline -2; //Because Read use 2 line
//PRINT_FRONT (" Espline = %d \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
#ifdef SONY224 // SONY 224 2.0M Interlace CCDSENSOR
{
espline = espline -1; //Because Read use 1 line
//PRINT_FRONT (" Espline = %x \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
#ifdef MN39472 // PANASONIC 39472 2.0M Interlace CCDSENSOR
{
espline = espline -2; //Because Read use 2 line
//PRINT_FRONT (" Espline = %x \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
#ifdef MN39470 // PANASONIC 39470 2.0M Interlace CCDSENSOR
{
espline = espline -2; //Because Read use 2 line
// PRINT_FRONT (" Espline = %x \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
//patch4.4@andrew@SHARP_LZ24
#ifdef SHARP_LZ24BP
{
espline = espline -1; //Because Read use 1 line
// PRINT_FRONT (" Espline = %x \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
// patch4.5@andrew@MN39592
#ifdef MN39592
{
espline = espline -2; //Because Read use 2 line
// PRINT_FRONT (" Espline = %x \n", (USHORT)espline);
XBYTE[0X2B0A] = (UCHAR)espline; //Set Exposure time
XBYTE[0X2B0B] = (UCHAR)(espline >> 8);
}
#endif
//PRINT_FRONT (" Exit L2_SetExposureTime \n");
return 0;
}
//////////////////////////////////////////////////////////////////////////////////////////////
UCHAR L2_AdjustGain(USHORT Value, UCHAR Option) USING_0
{
UCHAR option1;
//XBYTE[0X203A] = XBYTE[0X203A] | 0x20; //GPIO21 Output enable
//XBYTE[0X2032] = XBYTE[0X2032] | 0x20; //GPIO21 = 1
//XBYTE[0X2032] = XBYTE[0X2032] & 0xDF; //GPIO21 = 0
#ifdef OV13 //Ov9620 1.3M CMOS Sensor
{
UCHAR reg_addr[1], reg_data[1], i, j;
PRINT_FRONT (" Enter L2_AdjustGain \n");
option1 = Option & 0x01; //Sequential mode, Sync VD ?
if (Value >= 0x40) return 1;
reg_addr[0] = 0x00;
reg_data[0] = (UCHAR)Value;
L2_WriteSSC(reg_addr, reg_data, 1, option1);
//for (i=0; i<40;i++) //Delay
//for (j=0; j<255; j++);
}
#endif
#ifdef OV2610 //Ov 2.0M CMOS Sensor
{
UCHAR reg_addr[1], reg_data[1], i, j;
PRINT_FRONT (" Enter L2_AdjustGain \n");
option1 = Option & 0x01; //Sequential mode, Sync VD ?
if (Value >= 0x40) return 1;
reg_addr[0] = 0x00;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -