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

📄 s3c2410disp.cpp

📁 混泰CH7023,CH7024,CH7025视频解码芯片
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	}
	if(dwStatus == ERROR_SUCCESS && dwType == REG_DWORD) {
		dwSize = sizeof(DWORD);
		dwStatus = RegQueryValueEx(hkDisplay, _T("LCDPhysicalFrameBase"), NULL, &dwType, 
			(LPBYTE) &dwLCDPhysicalFrameBase, &dwSize);
	}

	// close the registry key
	if(hkDisplay != NULL) {
		RegCloseKey(hkDisplay);
	}

	// did we get everything?
	if(dwStatus != ERROR_SUCCESS) {
		RETAILMSG(0, (_T("SALCD2: InitializeHardware: couldn't get registry configuration\r\n")));
		return;
	}
	RETAILMSG(0,(_T("wangjunfeng\n")));
	// map frame buffer into process space memory
	m_VirtualFrameBuffer = (DWORD)VirtualAlloc(0, FRAMEBUF_SIZE, MEM_RESERVE, PAGE_NOACCESS);
	if (m_VirtualFrameBuffer == NULL) 
	{
	    RETAILMSG(0,(TEXT("m_VirtualFrameBuffer is not allocated\n\r")));
		return;
	}
	else if (!VirtualCopy((PVOID)m_VirtualFrameBuffer, (PVOID)gdwLCDVirtualFrameBase, FRAMEBUF_SIZE, PAGE_READWRITE | PAGE_NOCACHE))
	{
	    RETAILMSG(0, (TEXT("m_VirtualFrameBuffer is not mapped\n\r")));
    	VirtualFree((PVOID)m_VirtualFrameBuffer, 0, MEM_RELEASE);
    	return;
	}

	RETAILMSG(0, (TEXT("m_VirtualFrameBuffer is mapped at %x(PHY : %x)\n\r"), m_VirtualFrameBuffer, gdwLCDVirtualFrameBase));
	RETAILMSG(0, (TEXT("Clearing frame buffer !!!\n\r")));

	ptr = (WORD *)m_VirtualFrameBuffer;

	// clear rest of frame buffer out
	for (index = 0; index < CH7025_OUTPUT_TIMING.ha*CH7025_OUTPUT_TIMING.va; index++)
	{
		if(index < CH7025_OUTPUT_TIMING.ha*10)
		{
			ptr[index] = 0xf800;
		}
		else if(index < CH7025_OUTPUT_TIMING.ha*20)
		{
			ptr[index] = 0x07e0;
		}
		else if(index < CH7025_OUTPUT_TIMING.ha*40)
		{
			ptr[index] = 0x001f;
		}
		else
		{
			ptr[index] = 0xffff;
		}
	}
	RETAILMSG(1, (_T("--S3C2410DISP::InitializeHardware\r\n")));
}

SCODE S3C2410DISP::SetMode (INT modeId, HPALETTE *palette)
{
	RETAILMSG(0, (TEXT("++S3C2410DISP::SetMode\r\n")));

	if (modeId != 0)
	{
		RETAILMSG(0, (TEXT("S3C2410DISP::SetMode Want mode %d, only have mode 0\r\n"),modeId));
		return	E_INVALIDARG;
	}

	if (palette)
	{
		*palette = EngCreatePalette (PAL_BITFIELDS, 0, NULL, gBitMasks[0], gBitMasks[1], gBitMasks[2]);
	}

	RETAILMSG(0, (TEXT("--S3C2410DISP::SetMode\r\n")));

	return S_OK;
}

SCODE S3C2410DISP::GetModeInfo(GPEMode *mode,	INT modeNumber)
{
	RETAILMSG(0, (TEXT("++S3C2410DISP::GetModeInfo\r\n")));

	if (modeNumber != 0)
	{
		return E_INVALIDARG;
	}

	*mode = m_ModeInfo;

	RETAILMSG(0, (TEXT("--S3C2410DISP::GetModeInfo\r\n")));

	return S_OK;
}

int	S3C2410DISP::NumModes()
{
	RETAILMSG(0, (TEXT("++S3C2410DISP::NumModes\r\n")));
	RETAILMSG(0, (TEXT("--S3C2410DISP::NumModes\r\n")));
	return	1;
}

void	S3C2410DISP::CursorOn (void)
{
	UCHAR	*ptrScreen = (UCHAR*)m_pPrimarySurface->Buffer();
	UCHAR	*ptrLine;
	UCHAR	*cbsLine;
#ifndef ROTATE
	UCHAR	*xorLine;
	UCHAR	*andLine;
#endif //!ROTATE	
	int		x, y;

	if (!m_CursorForcedOff && !m_CursorDisabled && !m_CursorVisible)
	{
#ifdef ROTATE
		RECTL rSave;
		int   iRotate;
#endif //ROTATE

		if (!m_CursorBackingStore)
		{
			RETAILMSG(0, (TEXT("S3C2410DISP::CursorOn - No backing store available\r\n")));
			return;
		}
#ifdef ROTATE
		rSave = m_CursorRect;
		RotateRectl(&m_CursorRect);
#endif //ROTATE

		for (y = m_CursorRect.top; y < m_CursorRect.bottom; y++)
		{
			if (y < 0)
			{
				continue;
			}
#ifdef ROTATE
			if (y >= m_nScreenHeightSave)
#else
			if (y >= m_nScreenHeight)
#endif //ROTATE			
			{
				break;
			}

			ptrLine = &ptrScreen[y * m_pPrimarySurface->Stride()];
			cbsLine = &m_CursorBackingStore[(y - m_CursorRect.top) * (m_CursorSize.x * (m_colorDepth >> 3))];
#ifndef ROTATE
			xorLine = &m_CursorXorShape[(y - m_CursorRect.top) * m_CursorSize.x];
			andLine = &m_CursorAndShape[(y - m_CursorRect.top) * m_CursorSize.x];
#endif //!ROTATE

			for (x = m_CursorRect.left; x < m_CursorRect.right; x++)
			{
				if (x < 0)
				{
					continue;
				}
#ifdef ROTATE
				if (x >= m_nScreenWidthSave)
#else
				if (x >= m_nScreenWidth)
#endif //!ROTATE				
				{
					break;
				}
#ifdef ROTATE
				switch (m_iRotate)
				{
					case DMDO_0:
						iRotate = (y - m_CursorRect.top)*m_CursorSize.x + x - m_CursorRect.left;
						break;
					case DMDO_90:
						iRotate = (x - m_CursorRect.left)*m_CursorSize.x + m_CursorSize.y - 1 - (y - m_CursorRect.top);   
						break;
					case DMDO_180:
						iRotate = (m_CursorSize.y - 1 - (y - m_CursorRect.top))*m_CursorSize.x + m_CursorSize.x - 1 - (x - m_CursorRect.left);
						break;
					case DMDO_270:
						iRotate = (m_CursorSize.x -1 - (x - m_CursorRect.left))*m_CursorSize.x + y - m_CursorRect.top;
						break;
					default:
					    iRotate = (y - m_CursorRect.top)*m_CursorSize.x + x - m_CursorRect.left;
						break;
				}
#endif //ROTATE					
				cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3)] = ptrLine[x * (m_colorDepth >> 3)];
#ifdef ROTATE
				ptrLine[x * (m_colorDepth >> 3)] &= m_CursorAndShape[iRotate];
				ptrLine[x * (m_colorDepth >> 3)] ^= m_CursorXorShape[iRotate];
#else 
				ptrLine[x * (m_colorDepth >> 3)] &= andLine[x - m_CursorRect.left];
				ptrLine[x * (m_colorDepth >> 3)] ^= xorLine[x - m_CursorRect.left];
#endif //ROTATE				
				if (m_colorDepth > 8)
				{
					cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 1] = ptrLine[x * (m_colorDepth >> 3) + 1];
#ifdef ROTATE
       		        ptrLine[x * (m_colorDepth >> 3) + 1] &= m_CursorAndShape[iRotate];
					ptrLine[x * (m_colorDepth >> 3) + 1] ^= m_CursorXorShape[iRotate];				
#else
					ptrLine[x * (m_colorDepth >> 3) + 1] &= andLine[x - m_CursorRect.left];
					ptrLine[x * (m_colorDepth >> 3) + 1] ^= xorLine[x - m_CursorRect.left];
#endif //ROTATE					
					if (m_colorDepth > 16)
					{
						cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 2] = ptrLine[x * (m_colorDepth >> 3) + 2];
#ifdef ROTATE
						ptrLine[x * (m_colorDepth >> 3) + 2] &= m_CursorAndShape[iRotate];
						ptrLine[x * (m_colorDepth >> 3) + 2] ^= m_CursorXorShape[iRotate];
#else
						ptrLine[x * (m_colorDepth >> 3) + 2] &= andLine[x - m_CursorRect.left];
						ptrLine[x * (m_colorDepth >> 3) + 2] ^= xorLine[x - m_CursorRect.left];
#endif //ROTATE						
					}
				}
			}
		}
#ifdef ROTATE
		m_CursorRect = rSave;
#endif 
		m_CursorVisible = TRUE;
	}
}

void	S3C2410DISP::CursorOff (void)
{
	UCHAR	*ptrScreen = (UCHAR*)m_pPrimarySurface->Buffer();
	UCHAR	*ptrLine;
	UCHAR	*cbsLine;
	int		x, y;

	if (!m_CursorForcedOff && !m_CursorDisabled && m_CursorVisible)
	{
#ifdef ROTATE
		RECTL rSave;
#endif //ROTATE

		if (!m_CursorBackingStore)
		{
			RETAILMSG(0, (TEXT("S3C2410DISP::CursorOff - No backing store available\r\n")));
			return;
		}
#ifdef ROTATE
		rSave = m_CursorRect;
		RotateRectl(&m_CursorRect);
#endif //ROTATE

		for (y = m_CursorRect.top; y < m_CursorRect.bottom; y++)
		{
			// clip to displayable screen area (top/bottom)
			if (y < 0)
			{
				continue;
			}
#ifndef ROTATE
			if (y >= m_nScreenHeight)
#else 
			if (y >= m_nScreenHeightSave)
#endif //!ROTATE
			{
				break;
			}

			ptrLine = &ptrScreen[y * m_pPrimarySurface->Stride()];
			cbsLine = &m_CursorBackingStore[(y - m_CursorRect.top) * (m_CursorSize.x * (m_colorDepth >> 3))];

			for (x = m_CursorRect.left; x < m_CursorRect.right; x++)
			{
				// clip to displayable screen area (left/right)
				if (x < 0)
				{
					continue;
				}
#ifndef ROTATE
				if (x >= m_nScreenWidth)
#else
				if (x>= m_nScreenWidthSave)
#endif //!ROTATE
				{
					break;
				}

				ptrLine[x * (m_colorDepth >> 3)] = cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3)];
				if (m_colorDepth > 8)
				{
					ptrLine[x * (m_colorDepth >> 3) + 1] = cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 1];
					if (m_colorDepth > 16)
					{
						ptrLine[x * (m_colorDepth >> 3) + 2] = cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 2];
					}
				}
			}
		}
#ifdef ROTATE
		m_CursorRect = rSave;
#endif //ROTATE
		m_CursorVisible = FALSE;
	}
}

SCODE	S3C2410DISP::SetPointerShape(GPESurf *pMask, GPESurf *pColorSurf, INT xHot, INT yHot, INT cX, INT cY)
{
	UCHAR	*andPtr;		// input pointer
	UCHAR	*xorPtr;		// input pointer
	UCHAR	*andLine;		// output pointer
	UCHAR	*xorLine;		// output pointer
	char	bAnd;
	char	bXor;
	int		row;
	int		col;
	int		i;
	int		bitMask;

	RETAILMSG(0, (TEXT("S3C2410DISP::SetPointerShape(0x%X, 0x%X, %d, %d, %d, %d)\r\n"),pMask, pColorSurf, xHot, yHot, cX, cY));

	// turn current cursor off
	CursorOff();

	// release memory associated with old cursor
	if (m_CursorBackingStore)
	{
		delete (void*)m_CursorBackingStore;
		m_CursorBackingStore = NULL;
	}
	if (m_CursorXorShape)
	{
		delete (void*)m_CursorXorShape;
        m_CursorXorShape = NULL;
	}
	if (m_CursorAndShape)
	{
		delete (void*)m_CursorAndShape;
        m_CursorAndShape = NULL;
	}

	if (!pMask)							// do we have a new cursor shape
	{
		m_CursorDisabled = TRUE;		// no, so tag as disabled
	}
	else
	{
		m_CursorDisabled = FALSE;		// yes, so tag as not disabled

		// allocate memory based on new cursor size
        m_CursorBackingStore = new UCHAR[(cX * (m_colorDepth >> 3)) * cY];
        m_CursorXorShape = new UCHAR[cX * cY];
        m_CursorAndShape = new UCHAR[cX * cY];

		// store size and hotspot for new cursor
		m_CursorSize.x = cX;
		m_CursorSize.y = cY;
		m_CursorHotspot.x = xHot;
		m_CursorHotspot.y = yHot;

		andPtr = (UCHAR*)pMask->Buffer();
		xorPtr = (UCHAR*)pMask->Buffer() + (cY * pMask->Stride());

		// store OR and AND mask for new cursor
		for (row = 0; row < cY; row++)
		{
			andLine = &m_CursorAndShape[cX * row];
			xorLine = &m_CursorXorShape[cX * row];

			for (col = 0; col < cX / 8; col++)
			{
				bAnd = andPtr[row * pMask->Stride() + col];
				bXor = xorPtr[row * pMask->Stride() + col];

				for (bitMask = 0x0080, i = 0; i < 8; bitMask >>= 1, i++)
				{
					andLine[(col * 8) + i] = bAnd & bitMask ? 0xFF : 0x00;
					xorLine[(col * 8) + i] = bXor & bitMask ? 0xFF : 0x00;
				}
			}
		}
	}

	return	S_OK;
}

SCODE	S3C2410DISP::MovePointer(INT xPosition, INT yPosition)
{
	RETAILMSG(0, (TEXT("S3C2410DISP::MovePointer(%d, %d)\r\n"), xPosition, yPosition));

	CursorOff();

	if (xPosition != -1 || yPosition != -1)
	{
		// compute new cursor rect
		m_CursorRect.left = xPosition - m_CursorHotspot.x;
		m_CursorRect.right = m_CursorRect.left + m_CursorSize.x;
		m_CursorRect.top = yPosition - m_CursorHotspot.y;
		m_CursorRect.bottom = m_CursorRect.top + m_CursorSize.y;

		CursorOn();
	}

	return	S_OK;
}

void	S3C2410DISP::WaitForNotBusy(void)
{
	RETAILMSG(0, (TEXT("S3C2410DISP::WaitForNotBusy\r\n")));
	return;
}

int		S3C2410DISP::IsBusy(void)
{
	RETAILMSG(0, (TEXT("S3C2410DISP::IsBusy\r\n")));
	return	0;
}

void	S3C2410DISP::GetPhysicalVideoMemory(unsigned long *physicalMemoryBase, unsigned long *videoMemorySize)
{
	RETAILMSG(0, (TEXT("S3C2410DISP::GetPhysicalVideoMemory\r\n")));

	*physicalMemoryBase = gdwLCDVirtualFrameBase;
	*videoMemorySize = m_cbScanLineLength * m_nScreenHeight;
}

SCODE	S3C2410DISP::AllocSurface(GPESurf **surface, INT width, INT height, EGPEFormat format, INT surfaceFlags)
{
	RETAILMSG(0, (TEXT("S3C2410DISP::AllocSurface\r\n")));

	if (surfaceFlags & GPE_REQUIRE_VIDEO_MEMORY)
	{
		return	E_OUTOFMEMORY;
	}

	// Allocate from system memory

⌨️ 快捷键说明

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