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

📄 misc.cpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*
 * $Workfile: MISC.CPP $
 * $Revision: 6 $
 * $Date: 4/07/00 8:51a $
 * $Modtime: 4/07/00 8:36a $
 * $Author: Sarma $
 *
 * This module performs miscellaneous support functions.
 *
 * Copyright (c) 1998 National Semiconductor Corporation.
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of National 
 * Semiconductor Corporation. ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into
 * with National Semiconductor Corporation.
 * This code is supplied as is.
 *
 */

/*
 *$Log: /CE/Platform/Nsc/Drivers/Video/gxvideo/base/MISC.CPP $
 * 
 * 6     4/07/00 8:51a Sarma
 * Removed Cyrix Corporation from the legal/confidentail information.
 * 
 * 5     4/06/00 10:36a Hari
 * Removed Debug messages.
 * 
 * 4     3/29/00 9:19a Sarma
 * Use m_PLaw to get memory location.
 * 
 * 3     7/20/99 2:21p Sarma
 * Added Power Handler function in Misc.cpp and supporting functions for
 * power management
 * 
 * 2     11/12/98 3:32p Sarma
 * Added Confidential copyright to files with VSS keywords for
 * log/history.
 * Added Screen saver support functions
 * StartScreenSaver, StopScreenSaver, ScreenPower, GetBltSolidColor.
 *$History: MISC.CPP $
 * 
 * *****************  Version 6  *****************
 * User: Sarma        Date: 4/07/00    Time: 8:51a
 * Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
 * Removed Cyrix Corporation from the legal/confidentail information.
 * 
 * *****************  Version 5  *****************
 * User: Hari         Date: 4/06/00    Time: 10:36a
 * Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
 * Removed Debug messages.
 * 
 * *****************  Version 4  *****************
 * User: Sarma        Date: 3/29/00    Time: 9:19a
 * Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
 * Use m_PLaw to get memory location.
 * 
 * *****************  Version 3  *****************
 * User: Sarma        Date: 7/20/99    Time: 2:21p
 * Updated in $/wince/v2.1/gxvideo
 * Added Power Handler function in Misc.cpp and supporting functions for
 * power management
 * 
 * *****************  Version 2  *****************
 * User: Sarma        Date: 11/12/98   Time: 3:32p
 * Updated in $/wince/v2.1/gxvideo
 * Added Confidential copyright to files with VSS keywords for
 * log/history.
 * Added Screen saver support functions
 * StartScreenSaver, StopScreenSaver, ScreenPower, GetBltSolidColor.
*/


#include "precomp.h"

#define SCREEN_ON	0x00
#define SCREEN_OFF	0x01


void APIENTRY StartScreenSaver()
{
//	RETAILMSG(1,(_T("StartScreenSaver\r\n")));
    // go to Software Suspend, Power Off
    // 1. DC_TIMING_CFG bit 2 set to 1, bit 1 set to 1
	GPE *pGPE = GetGPE();

	((GxVideo *)pGPE)->ScreenPower( SCREEN_OFF );

}
void APIENTRY StopScreenSaver()
{ 
//	RETAILMSG(1,(_T("StopScreenSaver\r\n")));
    // Exit Software Suspend, Power On
    // 1. DC_TIMING_CFG bit 2 set to 0, bit 0 set to 0
	GPE *pGPE = GetGPE();

	((GxVideo *)pGPE)->ScreenPower( SCREEN_ON );
}


void GxVideo::PowerHandler(BOOL bOff)
{
//	DEBUGMSG(1,(TEXT("GxVideo::PowerHandler\n")));
	ScreenPower(bOff);
}


void GxVideo::ScreenPower( BOOL mode )
{
 	dcfg30 = READ_REG32(CX5530registers, CX55xx_DISPLAY_CONFIG);
	tcfg = READ_REG32(GXregisters, DC_TIMING_CFG);
//	RETAILMSG(1,(_T("ScreenPower (before)0x%0x\r\n"), dwTcfg));


	if (mode == SCREEN_OFF)
	{
//		DEBUGMSG(1,(TEXT("GxVideo::ScreenPower Off\n")));
		dcfg30 &= ~(CX5530_DCFG_DAC_BL_EN | CX5530_DCFG_HSYNC_EN | CX5530_DCFG_VSYNC_EN);
		tcfg &= ~(DC_TCFG_BLKE | DC_TCFG_HSYE | DC_TCFG_VSYE);	//turn off display, HSYNC=VSYNC=off

	}
	else 
	{
		//the following must be done, or the monitor doesn't turn back on!
//		DEBUGMSG(1,(TEXT("GxVideo::ScreenPower On\n")));
		dcfg30 |= CX5530_DCFG_DIS_EN;
		dcfg30 |= CX5530_DCFG_HSYNC_EN;
		dcfg30 |= CX5530_DCFG_VSYNC_EN;
			
		// ENABLE CRT OUTPUT

		dcfg30 |= CX5530_DCFG_DAC_BL_EN;
		dcfg30 |= CX5530_DCFG_DAC_PWDNX;

		// ENABLE FLAT PANEL OUTPUT

		dcfg30 |= CX5530_DCFG_FP_PWR_EN;
		dcfg30 |= CX5530_DCFG_FP_DATA_EN;

		// PICK WHICH DATA STREAM GOES THROUGH THE PALETTE
		// For this file, this is always the video stream.

		dcfg30 |= CX5530_DCFG_GV_PAL_BYP;

		tcfg |= DC_TCFG_BLKE | DC_TCFG_HSYE | DC_TCFG_VSYE;		//turn on display, HSYNC=VSYNC=on
	}


//	RETAILMSG(1,(_T("ScreenPower (after)0x%0x\r\n"), dwTcfg));

	//make sure to disable write-protect first
	Unlock();
   	WRITE_REG32(CX5530registers, CX55xx_DISPLAY_CONFIG, dcfg30);
	WRITE_REG32(GXregisters, DC_TIMING_CFG, tcfg);

	//enable original write-protect settings back
	Lock();
}

//----------------------------------------------------------------------------
// delay_milleseconds
//
// This routine performs a delay.  It is used when setting a video mode, and
// does not need to be extremely accurate.  It must guarantee, however, that 
// AT LEAST the amount of specified time has passed.  There is no problem 
// with waiting too long (until setting the mode takes too long).
//----------------------------------------------------------------------------

void GxVideo::delay_milliseconds()
{
	_asm {
		mov cx,10000
		mov dx,80h
delay:
		in	ax,dx
		loop delay 
	}
}


//----------------------------------------------------------------------------
// Unlock
//
// This routine unlocks the display controller registers.  It saves the 
// current value of the lock to restore later.
//----------------------------------------------------------------------------

void GPEVGA::Unlock()
{
	m_unlock = READ_REG32(GXregisters, DC_UNLOCK);
	DEBUGMSG( GPE_ZONE_HW,(TEXT("GxVideo::Unlock 0x%08x\r\n"),m_unlock));
	WRITE_REG32(GXregisters, DC_UNLOCK, DC_UNLOCK_VALUE);
}

//----------------------------------------------------------------------------
// Lock
//
// This routine restores the value of the lock on the display controller 
// registers.
//----------------------------------------------------------------------------

void GPEVGA::Lock()
{
	if (m_unlock == 0xFFFFFFFF) //first time locking
	{
		m_unlock = READ_REG32(GXregisters, DC_UNLOCK);
	}
	WRITE_REG32(GXregisters, DC_UNLOCK, m_unlock);
	DEBUGMSG( GPE_ZONE_HW,(TEXT("GxVideo::Lock 0x%08x\r\n"),m_unlock));
}

//----------------------------------------------------------------------------
// WaitForNotBusy
//
// This routine does not return until the graphics pipeline is idle.
//----------------------------------------------------------------------------

void GxVideo::WaitForNotBusy()
{
#ifdef ENABLE_ACCELERATION
	WAIT_BUSY(GXregisters);
#else
	return;
#endif
}

//----------------------------------------------------------------------------
// IsBusy
//
// This routine returns 0 if the graphics pipeline is idle or 1 if it is still 
// busy.
//----------------------------------------------------------------------------

int GxVideo::IsBusy()
{
#ifdef ENABLE_ACCELERATION
	unsigned long data;
	data = READ_REG32(GXregisters, GP_BLIT_STATUS);
	return ((data & 0x07) != 0);
#else
	return 0;
#endif
}

//----------------------------------------------------------------------------
// gx_read_processor_id
//
// This routine reads the processor ID register in GX.  For GXm, this 
// value is >= 0x40.
//
// This routine is not needed for MXi.
//----------------------------------------------------------------------------

unsigned char GxVideo::gx_read_processor_id(void)
{
	unsigned char data;

	_asm {
		pushf
		cli
		mov		al, 0FFh
		out		22h, al
		in		al, 23h
		mov		data, al
		popf
	}

	// Adjust version by 0x10 to show real version number.
	// This is silly to add 10 and compare to 40, but this is how the Win95
	// drivers do it, which started with GX (rev 1.0 came back as 0x00). 
	// This is done to keep the parameters consistent across drivers for
	// readability.

	data += 0x10;
	DEBUGMSG( 0,(TEXT("gx_read_processor_id = %d\n"),data));
	return(data);
}

//----------------------------------------------------------------------------
// gx_read_gcr
//
// This routine reads the GCR register in GX.  The base address is stored
// in bits [1:0], and the scratchpad size is stored in bits [3:2].
//----------------------------------------------------------------------------

unsigned char GxVideo::gx_read_gcr(void)
{
	unsigned char ccr3, data;

	// SAVE VALUE OF CCR3

	_asm {
	
		pushf
		cli

		// READ CCR3

		mov		al, 0C3h
		out		22h, al
		in		al, 023h
		mov		ccr3, al

⌨️ 快捷键说明

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