📄 l2_cdsp.c
字号:
0x02 - parameter error
others - error
*/
UCHAR L2_SetYUVAvg(UCHAR Mode) USING_0
{
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L2_SetYUVAvg: Enter\n");
//Y average
XBYTE[0x21A5] = Mode;
//UV average
XBYTE[0x21AB] = Mode>>2;
// return
PRINT_L2(" L2_SetYUVAvg: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_SetBriCont
//-----------------------------------------------------------------------------
/*
routine description:
Adjust the bright and contract of the CDSP output image.
arguments:
Bright: The parameter to adjust brightness. The range of the parameter is from
-256 to 254 (1 sign+7 bit, unit 2).
Contrast: The parameter to adjust contrast. The precise of the parameter is
three integer bits and five fraction bits.
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_SetBriCont(UCHAR Bright, UCHAR Contrast) USING_0
{
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L2_SetBriCont: Enter\n");
XBYTE[0x21A7] = Bright;
XBYTE[0x21A8] = Contrast;
XBYTE[0x21A6] = 0x01; //enable bright and contrast adjustment
// return
PRINT_L2(" L2_SetBriCont: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_SetHueSat
//-----------------------------------------------------------------------------
/*
routine description:
Adjust the hue and saturation of the CDSP output image.
arguments:
Hue: the parameter to adjust hue. The range is the whole 360 degrees.
The unit is 0.5 degrees.
Sat: the parameter to adjust saturation. The precise of the parameter is
three integers and five fractions.
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_SetHueSat(USHORT Hue, UCHAR Sat) USING_0
{
UCHAR tmp0;
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L2_SetHueSat: Enter\n");
XBYTE[0x21AE] = Sat;
XBYTE[0x21AD] = M_LoByteOfWord(Hue);
//enable hue and saturation adjustment and high byte of hue
tmp0 = M_HiByteOfWord(Hue);
XBYTE[0x21AC] = 0x01|(tmp0<<6);
// return
PRINT_L2(" L2_SetHueSat: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_ConfigWindow
//-----------------------------------------------------------------------------
/*
routine description:
Define the AE/AWB window (5X5).
arguments:
WinHoff: the horizontal offset of AE/AWB window
WinVoff: the vertical offset of AE/AWB window
WinHsize: the horizontal size of AE/AWB window
WinVsize: the vertical size of AE/AWB window
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_ConfigWindow(UCHAR WinHoff, UCHAR WinVoff, UCHAR WinHsize,
USHORT WinVsize) USING_0
{
UCHAR tmp0,tmp1;
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L2_ConfigWindow: Enter\n");
//offset
XBYTE[0x2200] = WinHoff+11; //pipe line delay
XBYTE[0x2201] = WinVoff+5; //pipe line delay
//size
XBYTE[0x2202] = WinHsize;
XBYTE[0x2203] = M_LoByteOfWord(WinVsize);
XBYTE[0x2204] = M_HiByteOfWord(WinVsize);
//pseudo window size
if(((WinHsize>>6)!=0) && (WinHsize!=64)) tmp0 = 0x04;
else if(((WinHsize>>5)!=0) && (WinHsize!=32)) tmp0 = 0x03;
else if(((WinHsize>>4)!=0) && (WinHsize!=16)) tmp0 = 0x02;
else if(((WinHsize>>3)!=0) && (WinHsize!= 8)) tmp0 = 0x01;
else tmp0 = 0x00;
if(((WinVsize>>9)!=0) && (WinVsize!=512)) tmp1 = 0x70;
else if(((WinVsize>>8)!=0) && (WinVsize!=256)) tmp1 = 0x60;
else if(((WinVsize>>7)!=0) && (WinVsize!=128)) tmp1 = 0x50;
else if(((WinVsize>>6)!=0) && (WinVsize!= 64)) tmp1 = 0x40;
else if(((WinVsize>>5)!=0) && (WinVsize!= 32)) tmp1 = 0x30;
else if(((WinVsize>>4)!=0) && (WinVsize!= 16)) tmp1 = 0x20;
else if(((WinVsize>>3)!=0) && (WinVsize!= 8)) tmp1 = 0x10;
else tmp1 = 0x00;
XBYTE[0x2205] = tmp0|tmp1;
// return
PRINT_L2(" L2_ConfigWindow: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_ReadAEWindow
//-----------------------------------------------------------------------------
/*
routine description:
Read the average of luminance (Y) of AE window.
arguments:
WinNum: the window number:
0: The whole window (5x5)
1~5: The first row
6~10: The second row
11~15: The third row
16~20: The forth row
21~25: The last row
*AEvalPt: The average of luminance on the AE window
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L3_GetWindowSize(PUCHAR HwdSizePt, PUCHAR PseudoHwdSizePt,
PUSHORT VwdSizePt, PUSHORT PseudoVwdSizePt) USING_0
{
UCHAR tmp0, tmp1, PseudoHwdSize;
USHORT VwdSize, PseudoVwdSize;
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L3_GetWindowSize: Enter\n");
*HwdSizePt = XBYTE[0x2202]; //AE/AWB horizontal window size
tmp0 = XBYTE[0x2203];
VwdSize = XBYTE[0x2204];
VwdSize = (VwdSize<<8)|tmp0;
*VwdSizePt = VwdSize; //AE/AWB vertical window size
tmp0 = XBYTE[0x2205];
tmp1 = tmp0&0x0F;
PseudoHwdSize = 8;
PseudoHwdSize = PseudoHwdSize<<tmp1;
*PseudoHwdSizePt = PseudoHwdSize; //AE/AWB pseudo horizontal window size
tmp1 = tmp0>>4;
PseudoVwdSize = 8;
PseudoVwdSize = PseudoVwdSize<<tmp1;
*PseudoVwdSizePt = PseudoVwdSize; //AE/AWB pseudo vertical window size
// return
PRINT_L2(" L3_GetWindowSize: Exit\n");
return(status);
}
UCHAR L2_ReadAEWindow(UCHAR WinNum, PUCHAR AEValPt) USING_0
{
UCHAR HwdSize, PseudoHwdSize;
USHORT VwdSize, PseudoVwdSize, addr;
ULONG WinVal;
UCHAR status;
//body
PRINT_L2(" L2_ReadAEWindow: Enter\n");
if(WinNum>25)
{
status = L2K_ERROR_PARAMETER;
}
else
{
if(WinNum==0) addr = 0x2299; //the register of AE window average value
else addr = 0x227F+WinNum; //the register of each AE window value
WinVal = XBYTE[addr];
status = L3_GetWindowSize(&HwdSize, &PseudoHwdSize, &VwdSize, &PseudoVwdSize);
if(WinNum==0) //AE window value
WinVal = ((WinVal*PseudoHwdSize*PseudoVwdSize)<<5)/((ULONG)HwdSize*VwdSize*25);
else
WinVal = (WinVal*PseudoHwdSize*PseudoVwdSize)/((ULONG)HwdSize*VwdSize);
*AEValPt = WinVal;
// PRINT_CDSP(" L2_ReadAEWindow: WinNum = %bu, AEVal = %bu\n", WinNum, *AEValPt);
}
// return
PRINT_L2(" L2_ReadAEWindow: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_ReadRYWindow
//-----------------------------------------------------------------------------
/*
routine description:
Read the R-Y value of AWB window.
arguments:
WinNum: the window number:
0: The whole window (5x5)
1~5: The first row
6~10: The second row
11~15: The third row
16~20: The forth row
21~25: The last row
*RYValPt: the average of R-Y value on the AWB window
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_ReadRYWindow(UCHAR WinNum, PSHORT RYValPt) USING_0
{
UCHAR tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, HwdSize, PseudoHwdSize;
USHORT VwdSize, PseudoVwdSize, addr;
SHORT RegVal;
LONG WinVal;
UCHAR status, status0, status1;
//body
PRINT_L2(" L2_ReadRYWindow: Enter\n");
if(WinNum>25)
{
status = L2K_ERROR_PARAMETER;
}
else
{
if(WinNum==0) addr = 0x22BD;
else addr = 0x229F+WinNum;
tmp0 = XBYTE[addr];
//get high byte
tmp2 = XBYTE[0x22B9];
tmp3 = XBYTE[0x22BA];
tmp4 = XBYTE[0x22BB];
tmp5 = XBYTE[0x22BC];
tmp6 = XBYTE[0x22BE];
status0 = L3_GetBYRYHigh(WinNum, &tmp1, tmp2, tmp3, tmp4, tmp5, tmp6);
if((tmp1&0x01)==0x00) RegVal = (SHORT)tmp0;
else RegVal = (SHORT)tmp0-256;
status1 = L3_GetWindowSize(&HwdSize, &PseudoHwdSize, &VwdSize, &PseudoVwdSize);
//get low byte
if(WinNum==0) //BY window value
WinVal = (((LONG)RegVal*PseudoHwdSize*PseudoVwdSize)<<5)/((LONG)HwdSize*VwdSize*25);
else
WinVal = ((LONG)RegVal*PseudoHwdSize*PseudoVwdSize)/((LONG)HwdSize*VwdSize);
*RYValPt = WinVal;
if((status0!=0) || (status1!=0)) status = 0x01;
// PRINT_CDSP(" L2_ReadRYWindow: WinNum = %bu, RYVal = %d\n", WinNum, *RYValPt);
}
// return
PRINT_L2(" L2_ReadRYWindow: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_ReadBYWindow
//-----------------------------------------------------------------------------
/*
routine description:
Read the B-Y value of AWB window.
arguments:
WinNum: the window number:
0: The whole window (5x5)
1~5: The first row
6~10: The second row
11~15: The third row
16~20: The forth row
21~25: The last row
*BYValPt: the average of B-Y value on the AWB window
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L3_GetBYRYHigh(UCHAR WinNum, PUCHAR tmp1Pt, UCHAR tmp2, UCHAR tmp3,
UCHAR tmp4, UCHAR tmp5, UCHAR tmp6) USING_0
{
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L3_GetBYRYHigh: Enter\n");
switch(WinNum)
{
case 0: *tmp1Pt = tmp6; break;
case 1: *tmp1Pt = tmp2; break;
case 2: *tmp1Pt = tmp2>>1; break;
case 3: *tmp1Pt = tmp2>>2; break;
case 4: *tmp1Pt = tmp2>>3; break;
case 5: *tmp1Pt = tmp2>>4; break;
case 6: *tmp1Pt = tmp2>>5; break;
case 7: *tmp1Pt = tmp2>>6; break;
case 8: *tmp1Pt = tmp2>>7; break;
case 9: *tmp1Pt = tmp3; break;
case 10: *tmp1Pt = tmp3>>1; break;
case 11: *tmp1Pt = tmp3>>2; break;
case 12: *tmp1Pt = tmp3>>3; break;
case 13: *tmp1Pt = tmp3>>4; break;
case 14: *tmp1Pt = tmp3>>5; break;
case 15: *tmp1Pt = tmp3>>6; break;
case 16: *tmp1Pt = tmp3>>7; break;
case 17: *tmp1Pt = tmp4; break;
case 18: *tmp1Pt = tmp4>>1; break;
case 19: *tmp1Pt = tmp4>>2; break;
case 20: *tmp1Pt = tmp4>>3; break;
case 21: *tmp1Pt = tmp4>>4; break;
case 22: *tmp1Pt = tmp4>>5; break;
case 23: *tmp1Pt = tmp4>>6; break;
case 24: *tmp1Pt = tmp4>>7; break;
case 25: *tmp1Pt = tmp5; break;
default: *tmp1Pt = 0x00; break;
}
// return
PRINT_L2(" L3_GetBYRYHigh: Exit\n");
return(status);
}
UCHAR L2_ReadBYWindow(UCHAR WinNum, PSHORT BYValPt) USING_0
{
UCHAR tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, HwdSize, PseudoHwdSize;
USHORT VwdSize, PseudoVwdSize, addr;
SHORT RegVal;
LONG WinVal;
UCHAR status, status0, status1;
//body
PRINT_L2(" L2_ReadBYWindow: Enter\n");
if(WinNum>25)
{
status = L2K_ERROR_PARAMETER;
}
else
{
if(WinNum==0) addr = 0x22DD;
else addr = 0x22BF+WinNum;
tmp0 = XBYTE[addr];
//get high byte
tmp2 = XBYTE[0x22D9];
tmp3 = XBYTE[0x22DA];
tmp4 = XBYTE[0x22DB];
tmp5 = XBYTE[0x22DC];
tmp6 = XBYTE[0x22DE];
status0 = L3_GetBYRYHigh(WinNum, &tmp1, tmp2, tmp3, tmp4, tmp5, tmp6);
if((tmp1&0x01)==0x00) RegVal = (SHORT)tmp0;
else RegVal = (SHORT)tmp0-256;
status1 = L3_GetWindowSize(&HwdSize, &PseudoHwdSize, &VwdSize, &PseudoVwdSize);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -