📄 l2_cdsp.c
字号:
/*++
Copyright (c) 2001 Sunplus Technology Co., Ltd.
Module Name:
L2_cdsp.c
Abstract:
Module related to L2 GLOBAL functions
Environment:
Keil C51 Compiler
Revision History:
11/12/2001 CMLin created
--*/
//=============================================================================
//Header file
//=============================================================================
#include "general.h"
#include "unistd.h"
//=============================================================================
//Symbol
//=============================================================================
//-----------------------------------------------------------------------------
//Constant
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//Variable
//-----------------------------------------------------------------------------
//=============================================================================
//Program
//=============================================================================
//-----------------------------------------------------------------------------
//L2_SetCDSPBadPixelMode
//-----------------------------------------------------------------------------
/*
routine description:
Set the operation mode of the SRAM of CDSP bad pixel.
arguments:
Mode: the operation mode of the SRAM of CDSP bad pixel
Bit 0: bad pixel compensation enable
Bit 1: bad pixel programming enable
Bit 2: bad pixel read enable
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_SetCDSPBadPixelMode(UCHAR Mode) USING_0
{
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L2_SetCDSPBadPixelMode: Enter\n");
XBYTE[0x2110] = Mode;
// return
PRINT_L2(" L2_SetCDSPBadPixelMode: Exit\"\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_WriteCDSPBadPixel
//-----------------------------------------------------------------------------
/*
routine description:
Write the coordinate of a bad pixel to the SRAM.
arguments:
BpAddr: the address of SRAM
BpX: the X-coordinate of the bad pixel
BpY: the Y-coordinate of the bad pixel
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_WriteCDSPBadPixel(UCHAR BpAddr, USHORT BpX, USHORT BpY) USING_0
{
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L2_WriteCDSPBadPixel: Enter\n");
//bad pixel coordination
XBYTE[0x2111] = M_LoByteOfWord(BpX);
XBYTE[0x2112] = M_HiByteOfWord(BpX);
XBYTE[0x2113] = M_LoByteOfWord(BpY);
XBYTE[0x2114] = M_HiByteOfWord(BpY);
//address
XBYTE[0x2115] = BpAddr;
// return
PRINT_L2(" L2_WriteCDSPBadPixel: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_ReadCDSPBadPixel
//-----------------------------------------------------------------------------
/*
routine description:
Read the coordinate of a bad pixel from the SRAM.
arguments:
BpAddr: the address of SRAM
*BpXPt: the X-coordinate of the bad pixel
*BpYPt: the Y-coordinate of the bad pixel
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_ReadCDSPBadPixel(UCHAR BpAddr, PUSHORT BpXPt, PUSHORT BpYPt) USING_0
{
USHORT tmp0;
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L2_ReadCDSPBadPixel: Enter\n");
//address
XBYTE[0x2115] = BpAddr;
//bad pixel coordination
tmp0 = XBYTE[0x2117];
*BpXPt = (tmp0<<8)|XBYTE[0x2116];
tmp0 = XBYTE[0x2119];
*BpYPt = (tmp0<<8)|XBYTE[0x2118];
// PRINT_CDSP(" BpAddr = %bx, BpX = %x, BpY = %x\n",BpAddr,*BpXPt,*BpYPt);
// return
PRINT_L2(" L2_ReadCDSPBadPixel: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_SetCDSPScale
//-----------------------------------------------------------------------------
/*
routine description:
Set CDSP horizontal scale down factor. The scale down ratio is the horizontal
size of source image to that of destination image.
arguments:
SrcHsize: the horizontal size of source image
DstHsize: the horizontal size of destination image
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_SetCDSPScale(USHORT SrcHsize, USHORT DstHsize) USING_0
{
ULONG tmp0;
USHORT ScaleFactor;
UCHAR status = L2K_SUCCESS;
//body
PRINT_L2(" L2_SetCDSPScale: Enter\n");
if((SrcHsize==0) || (DstHsize==0))
{
status = L2K_ERROR_PARAMETER;
// PRINT_GLOBAL(" L2_SetCDSPScale: Error Code = %bx\n", status);
}
else
{
if(SrcHsize==DstHsize)
{
XBYTE[0x211A] = 0x00; //horizontal scale down enable
}
else
{
DstHsize=DstHsize+16; //CDSP need more 16 pixels
tmp0 = (ULONG)DstHsize<<16;
ScaleFactor = tmp0/SrcHsize+1;
XBYTE[0x211B] = M_LoByteOfWord(ScaleFactor);
XBYTE[0x211C] = M_HiByteOfWord(ScaleFactor);
XBYTE[0x211A] = 0x03; //horizontal scale down filer mode enable
}
status = L2K_SUCCESS;
}
// return
PRINT_L2(" L2_SetCDSPScale: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_SetWB
//-----------------------------------------------------------------------------
/*
routine description:
Set the offset and gain of R, Gr, B and Gb raw data.
arguments:
ROffset: The offset of R raw data
GrOffset: The offset of Gr raw data
BOffset: The offset of Gr raw data
GbOffset: The offset of Gb raw data
RGain: The gain of R raw data
GrGain: The gain of Gr raw data
BGain: The gain of B raw data
GbGain: The gain of Gb raw data
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_SetWB(UCHAR ROffset, UCHAR GrOffset, UCHAR BOffset, UCHAR GbOffset,
USHORT RGain, USHORT GrGain, USHORT BGain, USHORT GbGain) USING_0
{
UCHAR tmp0, tmp1, tmp2, tmp3;
UCHAR status;
status = L2K_SUCCESS;
#if DEBUG_COLOR
//add for debug
if(GrGain !=GbGain)
{
GrGain=GbGain;
}
//--------------
#endif
//body
PRINT_L2(" L2_SetWB: Enter\n");
//offset
XBYTE[0x2120] = ROffset;
XBYTE[0x2121] = GrOffset;
XBYTE[0x2122] = BOffset;
XBYTE[0x2123] = GbOffset;
//gain
XBYTE[0x2124] = M_LoByteOfWord(RGain);
XBYTE[0x2125] = M_LoByteOfWord(GrGain);
XBYTE[0x2126] = M_LoByteOfWord(BGain);
XBYTE[0x2127] = M_LoByteOfWord(GbGain);
tmp0 = M_HiByteOfWord(GbGain);
tmp1 = M_HiByteOfWord(BGain);
tmp2 = M_HiByteOfWord(GrGain);
tmp3 = M_HiByteOfWord(RGain);
XBYTE[0x2128] = tmp0|(tmp1<<1)|(tmp2<<2)|(tmp3<<3);
// return
PRINT_L2(" L2_SetWB: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_SetColorC
//-----------------------------------------------------------------------------
/*
routine description:
Set the color correction matrix. The precision of coefficient is one sign bit,
two integer bits and six fraction bits.
arguments:
A11: the A11 coefficient for color correction matrix
A12: the A12 coefficient for color correction matrix
A13: the A13 coefficient for color correction matrix
A21: the A21 coefficient for color correction matrix
A22: the A22 coefficient for color correction matrix
A23: the A23 coefficient for color correction matrix
A31: the A31 coefficient for color correction matrix
A32: the A32 coefficient for color correction matrix
A33: the A33 coefficient for color correction matrix
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_SetColorC(USHORT A11, USHORT A12, USHORT A13,
USHORT A21, USHORT A22, USHORT A23,
USHORT A31, USHORT A32, USHORT A33) USING_0
{
UCHAR tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L2_SetColorC: Enter\n");
XBYTE[0x2140] = M_LoByteOfWord(A11);
XBYTE[0x2141] = M_LoByteOfWord(A12);
XBYTE[0x2142] = M_LoByteOfWord(A13);
XBYTE[0x2143] = M_LoByteOfWord(A21);
XBYTE[0x2144] = M_LoByteOfWord(A22);
XBYTE[0x2145] = M_LoByteOfWord(A23);
XBYTE[0x2146] = M_LoByteOfWord(A31);
XBYTE[0x2147] = M_LoByteOfWord(A32);
XBYTE[0x2148] = M_LoByteOfWord(A33);
tmp0 = M_HiByteOfWord(A11);
tmp1 = M_HiByteOfWord(A12);
tmp2 = M_HiByteOfWord(A13);
tmp3 = M_HiByteOfWord(A21);
tmp4 = M_HiByteOfWord(A22);
tmp5 = M_HiByteOfWord(A23);
tmp6 = M_HiByteOfWord(A31);
tmp7 = M_HiByteOfWord(A32);
XBYTE[0x2149] = tmp0|(tmp1<<1)|(tmp2<<2)|(tmp3<<3)|
(tmp4<<4)|(tmp5<<5)|(tmp6<<6)|(tmp7<<7);
XBYTE[0x214A] = M_HiByteOfWord(A33);
// return
PRINT_L2(" L2_SetColorC: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_SetLutGamma
//-----------------------------------------------------------------------------
/*
routine description:
Set the lookup table (LUT) gamma function.
arguments:
Mode:
0: LUT gamma disable
1: enable LUT gamma
2: enable LUT with low pass filter
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_SetLutGamma(UCHAR Mode) USING_0
{
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L2_SetLutGamma: Enter\n");
XBYTE[0x2150] = Mode;
// return
PRINT_L2(" L2_SetLutGamma: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_SetYEdge
//-----------------------------------------------------------------------------
/*
routine description:
Set the Y edge function (two 5x5 high-pass filters).
arguments:
Mode:
0: disable Y edge enhancement
1: only enable Y edge enhancement
2: only enable a 3x3 low-pass filter
3: enable Y edge and a 3x3 low-pass filter
return value:
0x00 - success
0x01 - general error
0x02 - parameter error
others - error
*/
UCHAR L2_SetYEdge(UCHAR Mode) USING_0
{
UCHAR status;
status = L2K_SUCCESS;
//body
PRINT_L2(" L2_SetYEdge: Enter\n");
XBYTE[0x21A0] = Mode;
// return
PRINT_L2(" L2_SetYEdge: Exit\n");
return(status);
}
//-----------------------------------------------------------------------------
//L2_SetYUVAvg
//-----------------------------------------------------------------------------
/*
routine description:
Set the average function for YUV data.
arguments:
Mode:
Bit 1 ~ Bit 0: Y horizontal average mode
00: no average
01: 2-pixel average
10: 3-pixel average
11: 4-pixel average
Bit 2: UV horizontal average
Bit 3: UV vertical average
return value:
0x00 - success
0x01 - general error
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -