📄 hal_display.c
字号:
if (mode)
reg |= 0x100;
else
reg &= ~0x100;
halWriteReg16(REG0202_DISPLAY_MODE_SETTING1, reg);
}
/****************************************************************************
; Function: GetLcdDisplayBlank
; Input : None
; Output : Blank mode
; Format : unsigned long GetLcdDisplayBlank(void)
;****************************************************************************/
unsigned long GetLcdDisplayBlank(void)
{
return halReadReg16(REG0202_DISPLAY_MODE_SETTING1) & 0x100;
}
/****************************************************************************
; Function: Set SW Video Invert
; Input : mode
; Output : None
; Format : void SetVideoInvert (unsigned short mode)
;****************************************************************************/
void SetVideoInvert (unsigned short mode)
{
unsigned short reg = halReadReg16(REG0202_DISPLAY_MODE_SETTING1);
if (mode)
reg |= 0x0200;
else
reg &= ~0x0200;
halWriteReg16(REG0202_DISPLAY_MODE_SETTING1, reg);
}
/****************************************************************************
; Function: Set the start address
; Input : Window Number
; start address
; Output : None
; Format : void SetStartAddress(WindowDef WindowNum, unsigned long address)
;****************************************************************************/
void SetStartAddress(WindowDef WindowNum, unsigned long address)
{
unsigned long bpp = GetBitsPerPixel( WindowNum );
address += CalculateSwivelViewBias( WindowNum );
if ( bpp == 16 || bpp == 32 )
address &= ~(bpp/8 - 1); // Align on 16-bit or 32-bit boundary
if ( WindowNum == cl_PIP_WINDOW )
{
halWriteReg16( REG0218_PIP_DISPLAY_START_ADDR0, (unsigned short)address );
halWriteReg16( REG021A_PIP_DISPLAY_START_ADDR1, (unsigned short)(address >> 16) );
}
else // cl_MAIN_WINDOW
{
halWriteReg16( REG0210_MWIN_DISP_START_ADDR0, (unsigned short)address );
halWriteReg16( REG0212_MWIN_DISP_START_ADDR1, (unsigned short)(address >> 16) );
}
}
/****************************************************************************
; Function: Get the start address
; Input : Window Number
; Output : Start address
; Format : unsigned long GetStartAddress(WindowDef WindowNum)
;****************************************************************************/
unsigned long GetStartAddress(WindowDef WindowNum)
{
unsigned long address;
if ( WindowNum == cl_PIP_WINDOW )
address = halReadReg16(REG0218_PIP_DISPLAY_START_ADDR0) | (halReadReg16(REG021A_PIP_DISPLAY_START_ADDR1) << 16);
else // cl_MAIN_WINDOW
address = halReadReg16(REG0210_MWIN_DISP_START_ADDR0) | (halReadReg16(REG0212_MWIN_DISP_START_ADDR1) << 16);
address -= CalculateSwivelViewBias( WindowNum );
return address;
}
/****************************************************************************
; Function: Set the PIP position
; Input : start and end position
; Output : None
; Format : void SetPipPosition(unsigned long xStart, unsigned long yStart, unsigned long xEnd, unsigned long yEnd)
;****************************************************************************/
void SetPipPosition(unsigned long xStart, unsigned long yStart, unsigned long xEnd, unsigned long yEnd)
{
halWriteReg16(REG0220_PIP_X_START_POS, (unsigned short) xStart);
halWriteReg16(REG0222_PIP_Y_START_POS, (unsigned short) yStart);
halWriteReg16(REG0224_PIP_X_END_POS, (unsigned short) xEnd);
halWriteReg16(REG0226_PIP_Y_END_POS, (unsigned short) yEnd);
}
/****************************************************************************
; Function: Get the PIP position
; Input : the pionter of start and end position
; Output : None
; Format : void GetPipPosition(unsigned long *xStart, unsigned long *yStart, unsigned long *xEnd, unsigned long *yEnd)
;****************************************************************************/
void GetPipPosition(unsigned long *xStart, unsigned long *yStart, unsigned long *xEnd, unsigned long *yEnd)
{
*xStart = halReadReg16(REG0220_PIP_X_START_POS);
*yStart = halReadReg16(REG0222_PIP_Y_START_POS);
*xEnd = halReadReg16(REG0224_PIP_X_END_POS);
*yEnd = halReadReg16(REG0226_PIP_Y_END_POS);
}
/****************************************************************************
; Function: Set the PIP size
; Input : the start position (X,Y)
; width and height
; Output : None
; Format : void SetPipSize(unsigned long x1, unsigned long y1, unsigned long width, unsigned long height)
;****************************************************************************/
void SetPipSize(unsigned long x1, unsigned long y1, unsigned long width, unsigned long height)
{
unsigned long xStart, yStart, xEnd, yEnd;
unsigned long x2, y2;
OutputPortDef OutputPort = GetOutputPort();
unsigned long PanelWidth = GetLcdHdp(OutputPort);
unsigned long PanelHeight = GetLcdVdp(OutputPort);
x2 = x1 + width;
y2 = y1 + height;
switch (GetSwivelViewMode(cl_MAIN_WINDOW))
{
case 0:
default:
xStart = x1;
xEnd = x2;
yStart = y1;
yEnd = y2;
break;
case 90:
xStart = y1;
xEnd = y2;
yStart = PanelHeight - x2;
yEnd = PanelHeight - x1;
break;
case 180:
xStart = PanelWidth - x2;
xEnd = PanelWidth - x1;
yStart = PanelHeight - y2;
yEnd = PanelHeight - y1;
break;
case 270:
xStart = PanelWidth - y2;
xEnd = PanelWidth - y1;
yStart = x1;
yEnd = x2;
break;
}
halWriteReg16(REG0220_PIP_X_START_POS, (unsigned short)xStart);
halWriteReg16(REG0224_PIP_X_END_POS, (unsigned short)(xEnd-1));
halWriteReg16(REG0222_PIP_Y_START_POS, (unsigned short)yStart);
halWriteReg16(REG0226_PIP_Y_END_POS, (unsigned short)(yEnd-1));
}
//---------------------------------------------------------------------------
// FUNCTION: SetPipSizeCenter()
//---------------------------------------------------------------------------
void SetPipSizeCenter(unsigned long x1, unsigned long y1, unsigned long width, unsigned long height)
{
unsigned long xStart, yStart, xEnd, yEnd;
unsigned long x2, y2;
OutputPortDef OutputPort = GetOutputPort();
unsigned long PanelWidth = GetLcdHdp(OutputPort);
unsigned long PanelHeight = GetLcdVdp(OutputPort);
x2 = x1 + width;
y2 = y1 + height;
/*
switch (GetSwivelViewMode(cl_MAIN_WINDOW))
{
case 0:
default:
*/ xStart = x1;
xEnd = x2;
yStart = y1;
yEnd = y2;
/* break;
case 90:
xStart = y1;
xEnd = y2;
yStart = PanelHeight - x2;
yEnd = PanelHeight - x1;
break;
case 180:
xStart = PanelWidth - x2;
xEnd = PanelWidth - x1;
yStart = PanelHeight - y2;
yEnd = PanelHeight - y1;
break;
case 270:
xStart = PanelWidth - y2;
xEnd = PanelWidth - y1;
yStart = x1;
yEnd = x2;
break;
}
*/ halWriteReg16(REG0220_PIP_X_START_POS, (unsigned short)(((unsigned short)(PanelWidth)-(unsigned short)(xEnd-1)+(unsigned short)(xStart))/2));
halWriteReg16(REG0224_PIP_X_END_POS, (unsigned short)((unsigned short)(xEnd-1)+(((unsigned short)(PanelWidth)-(unsigned short)(xEnd-1)+(unsigned short)(xStart))/2)));
halWriteReg16(REG0222_PIP_Y_START_POS, (unsigned short)(((unsigned short)(PanelHeight)-(unsigned short)(yEnd-1)+(unsigned short)(yStart))/2)+8);
halWriteReg16(REG0226_PIP_Y_END_POS, (unsigned short)((unsigned short)(yEnd-1)+(((unsigned short)(PanelHeight)-(unsigned short)(yEnd-1)+(unsigned short)(yStart))/2))+8);
}
/****************************************************************************
; Function: Get the PIP size
; Input : the pointer
; Output : None
; Format : void GetPipSize(unsigned long x1, unsigned long y1, unsigned long width, unsigned long height)
;****************************************************************************/
void GetPipSize(unsigned long *x, unsigned long * y, unsigned long * width, unsigned long * height)
{
unsigned long xStart, yStart, xEnd, yEnd;
unsigned long x1, y1, x2, y2;
OutputPortDef OutputPort = GetOutputPort();
unsigned long PanelWidth = GetLcdHdp(OutputPort);
unsigned long PanelHeight = GetLcdVdp(OutputPort);
xStart = halReadReg16(REG0220_PIP_X_START_POS);
xEnd = halReadReg16(REG0224_PIP_X_END_POS) + 1;
yStart = halReadReg16(REG0222_PIP_Y_START_POS);
yEnd = halReadReg16(REG0226_PIP_Y_END_POS) + 1;
switch (GetSwivelViewMode(cl_MAIN_WINDOW))
{
case 0:
default:
x1 = xStart;
x2 = xEnd;
y1 = yStart;
y2 = yEnd;
break;
case 90:
x1 = PanelHeight - yEnd;
x2 = PanelHeight - yStart;
y1 = xStart;
y2 = xEnd;
break;
case 180:
x1 = PanelWidth - xEnd;
x2 = PanelWidth - xStart;
y1 = PanelHeight - yEnd;
y2 = PanelHeight - yStart;
break;
case 270:
x1 = yStart;
x2 = yEnd;
y1 = PanelWidth - xEnd;
y2 = PanelWidth - xStart;
break;
}
if (x != NULL)
*x = x1;
if (y != NULL)
*y = y1;
if (width != NULL)
*width = x2 - x1;
if (height != NULL)
*height = y2 - y1;
}
/****************************************************************************
; Function: Set the Display Mode
; Input : WindowNum : the type window ( Main or PIP )
; bpp : the bit of display
; Output : None
; Format : void SetDisplayMode(WindowDef WindowNum, unsigned long bpp)
;****************************************************************************/
void SetDisplayMode(WindowDef WindowNum, unsigned long bpp)
{
unsigned long width;
unsigned long stride;
unsigned long PixelDoubling = GetPixelDoubling(WindowNum);
OutputPortDef OutputPort = GetOutputPort();
switch (WindowNum)
{
default:
case cl_MAIN_WINDOW:
if (bpp == 32) // if it is 32bit ,no use LUT
if (!GetLutBypassEnable(cl_LUT1))
SetLutBypassEnable(cl_LUT1, TRUE);
SetBitsPerPixel(WindowNum, bpp);
switch (GetSwivelViewMode(WindowNum))
{
case 0:
case 180:
default:
width = GetLcdHdp(OutputPort);
break;
case 90:
case 270:
width = GetLcdVdp(OutputPort);
break;
}
// Adjust for pixel doubling
if (PixelDoubling & cl_PIXELDOUBLE_HORIZ)
width /= 2;
SetStride(WindowNum, width * bpp / 8UL);
SetStartAddress(WindowNum, MAIN_WINDOW_ADDRESS);
break;
case cl_PIP_WINDOW:
// Program the bits-per-pixel select bits
SetBitsPerPixel(WindowNum, bpp);
switch (GetSwivelViewMode(WindowNum))
{
case 0:
case 180:
default:
// width = GetLcdHdp(OutputPort);
width = halReadReg16(REG0224_PIP_X_END_POS) - halReadReg16(REG0220_PIP_X_START_POS) + 1;
break;
case 90:
case 270:
// width = GetLcdVdp(OutputPort);
width = halReadReg16(REG0226_PIP_Y_END_POS) - halReadReg16(REG0222_PIP_Y_START_POS) + 1;
break;
}
// Adjust for pixel doubling
if (PixelDoubling & cl_PIXELDOUBLE_HORIZ)
width /= 2;
stride = width * bpp / 8;
SetStride(WindowNum, stride);
SetStartAddress(WindowNum,PIP_WINDOW_ADDRESS);
break;
}
}
/****************************************************************************
; Function: Get Display Mode
; Input : None
; Output : Display Mode
; Format : DisplayModeDef GetDisplayMode(void)
;****************************************************************************/
DisplayModeDef GetDisplayMode(void)
{
switch ((halReadReg16(REG0200_DISPLAY_MODE_SETTING0) >> 8) & 0x03)
{
case 0: return cl_DISPLAY_MODE_NORMAL; break;
case 1: return cl_DISPLAY_MODE_PIP; break;
case 3: return cl_DISPLAY_MODE_PIP_WITH_OVERLAY; break;
default: return cl_DISPLAY_MODE_RESERVED; break;
}
}
/****************************************************************************
; Function: Get Memory Address
; Input : Base Address
; Output : Base Address
; Format : unsigned long GetMemAddress(unsigned long BaseAddress)
;****************************************************************************/
unsigned long GetMemAddress(unsigned long BaseAddress)
{
return BaseAddress;
}
/****************************************************************************
; Function: Get the DisplayWidth
; Input : Window Number
; Output : Display width
; Format : unsigned long GetDisplayWidth(WindowDef WindowNum)
;****************************************************************************/
unsigned long GetDisplayWidth(WindowDef WindowNum)
{
unsigned long width;
unsigned long swivel = GetSwivelViewMode(WindowNum);
if (WindowNum == cl_PIP_WINDOW)
{
if (swivel == 90 || swivel == 270)
width = halReadReg16(REG0226_PIP_Y_END_POS) - halReadReg16(REG0222_PIP_Y_START_POS) + 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -