⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hal_display.c

📁 一款SmartPhone的驱动代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/************************************************************************
;  	HAL_DISPLAY.C
;
;	The routines in this file comprise display mode set
;
;	The Function is basic operation of LCDC
;
; 	Copyright (c) 2002 Epson Research and Development, Inc.
;
;  	All Rights Reserved.
;	2002.11.12	D Eric 		Start.					
;														
;************************************************************************/
#include "sysLCDC.h"


/****************************************************************************
; Function:	Display mode select  	
; Input :	Display Mode 
; Output :	None
; Format :	void SelectDispMode(unsigned short mode )
;****************************************************************************/
void SelectDispMode(DisplayModeDef displaymode)
{
	unsigned short reg = halReadReg16(REG0200_DISPLAY_MODE_SETTING0)&0xFCFF;
	reg=reg|((unsigned short)displaymode<<8);

	halWriteReg16(REG0200_DISPLAY_MODE_SETTING0,reg);
}

/****************************************************************************
; Function:	Set PipOverlay Enable 	
; Input :	PIP Overlay Mode
; Output :	None
; Format :	void SetPipOverlayEnable(PipOverlayDef mode)
;****************************************************************************/
void SetPipOverlayEnable(PipOverlayDef mode)
{
	unsigned short reg = halReadReg16(REG0200_DISPLAY_MODE_SETTING0);
	reg &= ~0x300;
	switch (mode)
	{
		default: break;  										// cl_PIP_DISABLE
		case cl_PIP_ENABLE:       	reg |= 0x100; break;
		case cl_PIP_WITH_OVERLAY: 	reg |= 0x300; break;
	}
	halWriteReg16(REG0200_DISPLAY_MODE_SETTING0, reg);
}

/****************************************************************************
; Function:	Set the Bits Per Pixel of Windows	
; Input :	Window Number
;			Color depth bpp
; Output :	void
; Format :	void SetBitsPerPixel(WindowDef WindowNum, unsigned long bpp)
;****************************************************************************/
void SetBitsPerPixel ( WindowDef WindowNum, unsigned long bpp)
{
	unsigned short reg = halReadReg16(REG0200_DISPLAY_MODE_SETTING0);

	switch (WindowNum)
	{
		default:
		case cl_MAIN_WINDOW:
				reg &= ~0x0003;
				switch (bpp)
				{
					case 16:	reg |= 0x0001; break;
					case 32:	reg |= 0x0003; break;
				}
				halWriteReg16(REG0200_DISPLAY_MODE_SETTING0, reg);
				break;

		case cl_PIP_WINDOW:
				reg &= ~0x000c;
				switch (bpp)
				{
					case 16:	reg |= 0x0004; break;
					case 32:	reg |= 0x000c; break;
				}
			
				halWriteReg16(REG0200_DISPLAY_MODE_SETTING0, reg);
				break;
	}
}

/****************************************************************************
; Function:	Get the bits per pixel of windows 	
; Input :	Window Number
; Output :	Color depth bpp
; Format :	unsigned long GetBitsPerPixel(WindowDef WindowNum)
;****************************************************************************/
unsigned long GetBitsPerPixel(WindowDef WindowNum)
{
	unsigned short reg = halReadReg16(REG0200_DISPLAY_MODE_SETTING0);

	switch (WindowNum)
	{
		default:
		case cl_MAIN_WINDOW:
			switch (reg & 0x0003)
			{
				default:	return 8; break;
				case 1:		return 16; break;
				case 3:		return 32; break;
			}
			break;

		case cl_PIP_WINDOW:
			switch ((reg >> 2) & 0x03)
			{
				default:	return 8; break;
				case 1:		return 16; break;
				case 3:		return 32; break;
			}
			break;
	}
}

/****************************************************************************
; Function:	Set the Stride  	
; Input :	Windows Number
;		stride
; Output :	None
; Format :	void SetStride(WindowDef WindowNum, unsigned long stride)
;****************************************************************************/
void SetStride(WindowDef WindowNum, unsigned long stride)
{
	unsigned long Register = (WindowNum==cl_PIP_WINDOW) ? REG021E_PIPWIN_LINE_ADDR_OFFSET : REG0216_MWIN_LINE_ADDR_OFFSET;
	unsigned short Value = (unsigned short) ((halReadReg16(Register) & ~0x0FFF) | (stride & 0x0FFF));

	halWriteReg16(Register, Value);
}

/****************************************************************************
; Function:	Get the Stride	
; Input :	Window Number
; Output :	stride
; Format :	unsigned short GetStride(WindowDef WindowNum)
;****************************************************************************/
unsigned short GetStride(WindowDef WindowNum)
{
	unsigned long Register = (WindowNum==cl_PIP_WINDOW) ? REG021E_PIPWIN_LINE_ADDR_OFFSET : REG0216_MWIN_LINE_ADDR_OFFSET;

	return ((unsigned short) (halReadReg16(Register) & 0x0FFF));
}

/****************************************************************************
; Function:	Set SwivelView Mode 	
; Input :	Window Number
;		SwivelView mode
; Output :	None
; Format :	void SetSwivelViewMode(WindowDef WindowNum, unsigned long mode)
;****************************************************************************/
void SetSwivelViewMode(WindowDef WindowNum, unsigned long mode)
{
	unsigned short reg = halReadReg16(REG0202_DISPLAY_MODE_SETTING1);
	
	switch (WindowNum)
	{
		default:
		case cl_MAIN_WINDOW:
			reg &= ~0x0003;
			switch (mode)
			{
				default: break;
				case 90:  	reg |= 0x0001; break;
				case 180: 	reg |= 0x0002; break;
				case 270: 	reg |= 0x0003; break;
			}
			break;

		case cl_PIP_WINDOW:
			reg &= ~0x0030;
			switch (mode)
			{
				default: break;
				case 90:  	reg |= 0x0010; break;
				case 180: 	reg |= 0x0020; break;
				case 270:	reg |= 0x0030; break;
			}
			break;
	}

	halWriteReg16(REG0202_DISPLAY_MODE_SETTING1, reg);
}

/****************************************************************************
; Function:	Get SwivelView Mode 	
; Input :	Window Number
; Output :	SwivelView Mode
; Format :	unsigned long GetSwivelViewMode(WindowDef WindowNum)
;****************************************************************************/
unsigned long GetSwivelViewMode(WindowDef WindowNum)
{
	static unsigned long aSwivelViewMode[] = {0, 90, 180, 270};

	if (WindowNum == cl_PIP_WINDOW)
		return aSwivelViewMode[(halReadReg16(REG0202_DISPLAY_MODE_SETTING1) >> 4) & 0x03];
	else  // cl_MAIN_WINDOW
		return aSwivelViewMode[halReadReg16(REG0202_DISPLAY_MODE_SETTING1) & 0x03];
}


/***************************************** I think it is error*************************/
/****************************************************************************
; Function:	Set Win Mirror	
; Input :	Window Nimber
		Enable/Disable
; Output :	None
; Format :	void SetWinMirror(WindowDef WindowNum, unsigned long enable)
;****************************************************************************/
void SetWinMirror(WindowDef WindowNum, unsigned long enable)
{
	unsigned short reg;

	switch (WindowNum)
	{
		default:
		case cl_MAIN_WINDOW:
			reg = (unsigned short) (halReadReg16(REG0202_DISPLAY_MODE_SETTING1) & ~0x0008);

			if (enable)
				reg |= 0x0008;
			break;

		case cl_PIP_WINDOW:
			reg = (unsigned short) (halReadReg16(REG0202_DISPLAY_MODE_SETTING1) & ~0x0080);

			if (enable)
				reg |= 0x0080;
			break;
	}

	halWriteReg16(REG0202_DISPLAY_MODE_SETTING1, reg);
}

/****************************************************************************
; Function:	Get Win Mirror 	
; Input :	Windows Number
; Output :	Enable/Disable
; Format :	unsigned long GetWinMirror(WindowDef WindowNum)
;****************************************************************************/
unsigned long GetWinMirror(WindowDef WindowNum)
{
	return FALSE;
}
/*******************************************************************************/




/****************************************************************************
; Function:	Set Pixel Double 	
; Input :	Window Number
;		Pixel Double mode
; Output :	None
; Format :	void SetPixelDoubling(WindowDef WindowNum, PixelDoublingDef mode)
;****************************************************************************/
void SetPixelDoubling(WindowDef WindowNum, PixelDoublingDef mode)
{
	unsigned short val;
	unsigned long index;

	if (WindowNum == cl_PIP_WINDOW)
		index = REG021E_PIPWIN_LINE_ADDR_OFFSET;
	else
		index = REG0216_MWIN_LINE_ADDR_OFFSET;

	val = (unsigned short) (halReadReg16(index) & ~0x3000);

	switch (GetSwivelViewMode(WindowNum))
	{
		default:
		case 0:
		case 180:
			if (mode & cl_PIXELDOUBLE_HORIZ)
				val |= 0x1000;
			
			if (mode & cl_PIXELDOUBLE_VERT)
				val |= 0x2000;
			break;

		case 90:
		case 270:
			if (mode & cl_PIXELDOUBLE_HORIZ)
				val |= 0x2000;
			
			if (mode & cl_PIXELDOUBLE_VERT)
				val |= 0x1000;
			break;
	}

	halWriteReg16(index, val);

}

/****************************************************************************
; Function:	Get Pixel Doube 	
; Input :	Window Number
; Output :	Pixel Doube Mode
; Format :	PixelDoublingDef GetPixelDoubling(WindowDef WindowNum)
;****************************************************************************/
PixelDoublingDef GetPixelDoubling(WindowDef WindowNum)
{
	unsigned long mode = cl_PIXELDOUBLE_NONE;

	unsigned short reg;

	if (WindowNum == cl_PIP_WINDOW)
		reg = halReadReg16(REG021E_PIPWIN_LINE_ADDR_OFFSET);
	else
		reg = halReadReg16(REG0216_MWIN_LINE_ADDR_OFFSET);

	switch (GetSwivelViewMode(WindowNum))
	{
		default:
		case 0:
		case 180:
			if (reg & 0x1000)
				mode |= cl_PIXELDOUBLE_HORIZ;
			if (reg & 0x2000)
				mode |= cl_PIXELDOUBLE_VERT;
			break;
		case 90:
		case 270:
			if (reg & 0x1000)
				mode |= cl_PIXELDOUBLE_VERT;
			if (reg & 0x2000)
				mode |= cl_PIXELDOUBLE_HORIZ;
			break;
	}

	return mode;
}




/****************************************************************************
; Function:	Calculate the SwivelView Bias	
; Input :	Window Number
; Output :	Bias
; Format :	unsigned long CalculateSwivelViewBias( WindowDef WindowNum )
;***************************************************************************/
unsigned long CalculateSwivelViewBias( WindowDef WindowNum )
{
	unsigned long Bias, width, height;
	unsigned long swivel= GetSwivelViewMode( WindowNum );
	unsigned long stride= GetStride( WindowNum );
	unsigned long bpp= GetBitsPerPixel( WindowNum );
	unsigned long skew= bpp/8;
	unsigned long doubles= GetPixelDoubling( WindowNum );

	if ( WindowNum == cl_PIP_WINDOW )
	{
		width  = halReadReg16(REG0224_PIP_X_END_POS) - halReadReg16(REG0220_PIP_X_START_POS) + 1;
		height = halReadReg16(REG0226_PIP_Y_END_POS) - halReadReg16(REG0222_PIP_Y_START_POS) + 1;
	}
	else
	{
		width  = GetLcdHdp( GetOutputPort() );
		height = GetLcdVdp( GetOutputPort() );
	}

	switch ( swivel )
	{
		default:
		case 0:
		case 180:
			if ( (doubles & cl_PIXELDOUBLE_HORIZ) )
				width /= 2;
			if ( (doubles & cl_PIXELDOUBLE_VERT) )
				height /= 2;
			break;

		case 90:
		case 270:
			if ( (doubles & cl_PIXELDOUBLE_HORIZ) )
				height /= 2;
			if ( (doubles & cl_PIXELDOUBLE_VERT) )
				width /= 2;
			break;
	}


	switch ( swivel )
	{
		default:
		case 0:		Bias = 0;												break;
		case 90:	Bias = ((height*bpp)/8) - skew;							break;
		case 180:	Bias = ((width *bpp)/8) + (stride*(height-1)) - skew;	break;
		case 270:	Bias = stride*(width-1);								break;
	}

	if ( GetWinMirror( WindowNum ) )
	{
		switch ( swivel )
		{
			default:
			case 0:		Bias += stride - skew;							break;
			case 90:	Bias = 0;										break;
			case 180:	Bias -= stride - skew;							break;
			case 270:	Bias += GetLcdVdp( GetOutputPort() ) - skew;	break;
		}
	}

	return Bias;
}

/****************************************************************************
; Function:	Set Lcd Display Blank	
; Input :	Blank Mode
; Output :	None
; Format :	void SetLcdDisplayBlank(unsigned short mode)
;****************************************************************************/
void SetLcdDisplayBlank(unsigned short mode)
{
	unsigned short reg = halReadReg16(REG0202_DISPLAY_MODE_SETTING1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -