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

📄 s3c2450disp.cpp

📁 SMDK2416_BSP
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	}
	if (m_hVFBMapping != NULL)
	{
		CloseHandle(m_hVFBMapping);
	}
	if (m_pLCDReg)
	{
		VirtualFree((PVOID)m_pLCDReg, 0, MEM_RELEASE);
		m_pLCDReg = NULL;
	}
	if (m_pIntrReg)
	{
		VirtualFree((PVOID)m_pIntrReg, 0, MEM_RELEASE);
		m_pIntrReg = NULL;
	}    
#if G2D_ACCELERATE
	if (m_oG2D)
	{
		m_oG2D->DeinitInterrupt();
		delete m_oG2D;
	}

	// Disable Block Power and Clock Source
	//	DevHWClockGating(HWCLK_2D_OFF);
	//	DevHWPowerGating(HWPWR_2D_OFF);
#endif		
}



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

    if (!m_CursorForcedOff && !m_CursorDisabled && !m_CursorVisible)
    {
        RECTL cursorRectSave = m_CursorRect;
        int   iRotate;
        RotateRectl(&m_CursorRect);
        for (y = m_CursorRect.top; y < m_CursorRect.bottom; y++)
        {
            if (y < 0)
            {
                continue;
            }
            if (y >= m_nScreenHeightSave)
            {
                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++)
            {
                if (x < 0)
                {
                    continue;
                }
                if (x >= m_nScreenWidthSave)
                {
                    break;
                }

                // x' = x - m_CursorRect.left; y' = y - m_CursorRect.top;
                // Width = m_CursorSize.x;   Height = m_CursorSize.y;
                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;
                }
                cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3)] = ptrLine[x * (m_colorDepth >> 3)];
                ptrLine[x * (m_colorDepth >> 3)] &= m_CursorAndShape[iRotate];
                ptrLine[x * (m_colorDepth >> 3)] ^= m_CursorXorShape[iRotate];
                if (m_colorDepth > 8)
                {
                    cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 1] = ptrLine[x * (m_colorDepth >> 3) + 1];
                    ptrLine[x * (m_colorDepth >> 3) + 1] &= m_CursorAndShape[iRotate];
                    ptrLine[x * (m_colorDepth >> 3) + 1] ^= m_CursorXorShape[iRotate];
                    if (m_colorDepth > 16)
                    {
                        cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 2] = ptrLine[x * (m_colorDepth >> 3) + 2];
                        ptrLine[x * (m_colorDepth >> 3) + 2] &= m_CursorAndShape[iRotate];
                        ptrLine[x * (m_colorDepth >> 3) + 2] ^= m_CursorXorShape[iRotate];
                    }
                }
            }
        }
        m_CursorRect = cursorRectSave;
        m_CursorVisible = TRUE;
    }
}

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

	if (!m_CursorForcedOff && !m_CursorDisabled && m_CursorVisible)
	{
		RECTL rSave = m_CursorRect;
		RotateRectl(&m_CursorRect);
		for (y = m_CursorRect.top; y < m_CursorRect.bottom; y++)
		{
			// clip to displayable screen area (top/bottom)
			if (y < 0)
			{
				continue;
			}
			if (y >= m_nScreenHeightSave)
			{
				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;
				}
				if (x >= m_nScreenWidthSave)
				{
					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];
					}
				}
			}
		}
		m_CursorRect = rSave;
		m_CursorVisible = FALSE;
	}
}

SCODE    S3C2450DISP::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;

	DEBUGMSG(GPE_ZONE_CURSOR,(TEXT("S3C2450DISP::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 (!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

		// 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    S3C2450DISP::MovePointer(INT xPosition, INT yPosition)
{
    DEBUGMSG(GPE_ZONE_CURSOR, (TEXT("S3C2450DISP::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    S3C2450DISP::WaitForNotBusy(void)
{
	DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2450DISP::WaitForNotBusy\r\n")));
#if G2D_ACCELERATE
	m_oG2D->WaitForIdle();	//< Wait for Fully Empty Command Fifo for all BitBlt request
#endif
    return;
}

int        S3C2450DISP::IsBusy(void)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2450DISP::IsBusy\r\n")));
    return    0;
}

void    S3C2450DISP::GetPhysicalVideoMemory(unsigned long *physicalMemoryBase, unsigned long *videoMemorySize)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2450DISP::GetPhysicalVideoMemory\r\n")));
    RETAILMSG (1, (TEXT("S3C2450DISP::GetPhysicalVideoMemory\r\n")));    

    *physicalMemoryBase = m_pvFlatFrameBuffer;
    *videoMemorySize = m_cbScanLineLength * m_cyPhysicalScreen;
}

void
S3C2450DISP::GetVirtualVideoMemory(
    unsigned long *virtualMemoryBase,
    unsigned long *videoMemorySize
    )
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2450DISP::GetVirtualVideoMemory\r\n")));
    RETAILMSG (1, (TEXT("S3C2450DISP::GetVirtualVideoMemory\r\n")));    

    *virtualMemoryBase = m_VirtualFrameBuffer;
//    *videoMemorySize = m_cbScanLineLength * m_cyPhysicalScreen;
    *videoMemorySize = 0x100000;
}

INT        S3C2450DISP::InVBlank(void)
{
    static    BOOL    value = FALSE;
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2450DISP::InVBlank\r\n")));
    value = !value;
    return value;
}

SCODE    S3C2450DISP::SetPalette(const PALETTEENTRY *source, USHORT firstEntry, USHORT numEntries)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2450DISP::SetPalette\r\n")));

    if (firstEntry < 0 || firstEntry + numEntries > 256 || source == NULL)
    {
        return    E_INVALIDARG;
    }


    return    S_OK;
}

VIDEO_POWER_STATE
PmToVideoPowerState(CEDEVICE_POWER_STATE pmDx)
{
	VIDEO_POWER_STATE vps;
	RETAILMSG(0,(_T("++PmToVideoPowerState\r\n")));

	switch(pmDx) {
	case D0:        // turn the display on
		vps = VideoPowerOn;
		break;

	case D1:        // if asked for a state we don't support, go to the next lower one
	case D2:
	case D3:
	case D4:
		vps = VideoPowerOff;
		break;

	default:
		RETAILMSG(0 , (L"PmToVideoPowerState: mapping unknown PM state %d to VideoPowerOn\r\n", pmDx));
		vps = VideoPowerOn;
		break;
	}

	return vps;
}

// this routine maps video power states to PM power states.
CEDEVICE_POWER_STATE
VideoToPmPowerState(VIDEO_POWER_STATE vps)
{
	CEDEVICE_POWER_STATE pmDx;
	RETAILMSG(0,(_T("++VideoToPmPowerState\r\n")));

	switch(vps)
	{
	case VideoPowerOn:
		pmDx = D0;
		break;

	case VideoPowerStandBy:
		pmDx = D1;
		break;

	case VideoPowerSuspend:
		pmDx = (CEDEVICE_POWER_STATE)D2;
		break;

	case VideoPowerOff:
		pmDx = (CEDEVICE_POWER_STATE)D4;
		break;

	default:
		pmDx = D0;
		RETAILMSG(0, (L"VideoToPmPowerState: mapping unknown video state %d to pm state %d\r\n",
		         vps, pmDx));
		break;
	}

	return pmDx;
}

#define ESC_SUCCESS             0x00000001
#define ESC_FAILED              0xFFFFFFFF
#define ESC_NOT_SUPPORTED       0x00000000
ULONG
S3C2450DISP::DrvEscape(
    SURFOBJ * pso,
    ULONG     iEsc,
    ULONG     cjIn,
    void    * pvIn,
    ULONG     cjOut,
    void    * pvOut
    )
{
	ULONG Result = 0;	
	if (iEsc == QUERYESCSUPPORT)
	{
		if (*(DWORD*)pvIn == GETGXINFO
			|| *(DWORD*)pvIn == DRVESC_GETSCREENROTATION
			|| *(DWORD*)pvIn == DRVESC_SETSCREENROTATION
			|| *(DWORD*)pvIn == SETPOWERMANAGEMENT
			|| *(DWORD*)pvIn == GETPOWERMANAGEMENT
			|| *(DWORD*)pvIn == IOCTL_POWER_CAPABILITIES
			|| *(DWORD*)pvIn == IOCTL_POWER_QUERY
			|| *(DWORD*)pvIn == IOCTL_POWER_SET
			|| *(DWORD*)pvIn == IOCTL_POWER_GET            

⌨️ 快捷键说明

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