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

📄 s3c6410_disp.cpp

📁 SAMSUNG S3C6410 CPU BSP for winmobile6
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	case ddgpePixelFormat_YVYU:
	case ddgpePixelFormat_VYUY:
		m_OverlayCtxt.uiSrcWidth = m_OverlayCtxt.uiSrcWidth-m_OverlayCtxt.uiSrcWidth%2;
		m_OverlayCtxt.uiSrcHeight = m_OverlayCtxt.uiSrcHeight-m_OverlayCtxt.uiSrcHeight%2;
		m_OverlayCtxt.uiSrcOffsetX = m_OverlayCtxt.uiSrcOffsetX-m_OverlayCtxt.uiSrcOffsetX%2;

		if (m_OverlayCtxt.uiSrcWidth < 2) m_OverlayCtxt.uiSrcWidth = 2;
		if (m_OverlayCtxt.uiSrcHeight < 2) m_OverlayCtxt.uiSrcHeight = 2;
		break;
	case ddgpePixelFormat_565:
		m_OverlayCtxt.uiSrcWidth = m_OverlayCtxt.uiSrcWidth-m_OverlayCtxt.uiSrcWidth%2;
		m_OverlayCtxt.uiSrcHeight = m_OverlayCtxt.uiSrcHeight-m_OverlayCtxt.uiSrcHeight%2;
		m_OverlayCtxt.uiSrcOffsetX = m_OverlayCtxt.uiSrcOffsetX-m_OverlayCtxt.uiSrcOffsetX%2;

		m_OverlayCtxt.uiDstWidth = m_OverlayCtxt.uiDstWidth-m_OverlayCtxt.uiDstWidth%2;
		m_OverlayCtxt.uiDstOffsetX = m_OverlayCtxt.uiDstOffsetX-m_OverlayCtxt.uiDstOffsetX%2;

		if (m_OverlayCtxt.uiSrcWidth < 2) m_OverlayCtxt.uiSrcWidth = 2;
		if (m_OverlayCtxt.uiSrcHeight < 2) m_OverlayCtxt.uiSrcHeight = 2;
		if (m_OverlayCtxt.uiDstWidth < 2) m_OverlayCtxt.uiDstWidth = 2;
		break;
	}

	// Adjust for Overlay Window Position
	if (m_OverlayCtxt.uiDstWidth+m_OverlayCtxt.uiDstOffsetX > (unsigned int)m_dwDeviceScreenWidth)
	{
		//m_OverlayCtxt.uiDstWidth = m_dwDeviceScreenWidth - m_OverlayCtxt.uiDstOffsetX;	// Adjust Width
		m_OverlayCtxt.uiDstOffsetX = m_dwDeviceScreenWidth - m_OverlayCtxt.uiDstWidth;		// Adjust Offset
	}

	if (m_OverlayCtxt.uiDstHeight+m_OverlayCtxt.uiDstOffsetY  > (unsigned int)m_dwDeviceScreenHeight)
	{
		//m_OverlayCtxt.uiDstHeight = m_dwDeviceScreenHeight - m_OverlayCtxt.uiDstOffsetY;	// Adjust Height
		m_OverlayCtxt.uiDstOffsetY  = m_dwDeviceScreenHeight - m_OverlayCtxt.uiDstHeight;	// Adjust Offset
	}

#if	0	// for Debug
	// After Adjust Size and Position
	DISPDRV_ERR((_T("[%d, %d, %d, %d]->[%d, %d, %d, %d]\n\r"),
		m_OverlayCtxt.uiSrcWidth, m_OverlayCtxt.uiSrcHeight, m_OverlayCtxt.uiSrcOffsetX, m_OverlayCtxt.uiSrcOffsetY,
		m_OverlayCtxt.uiDstWidth, m_OverlayCtxt.uiDstHeight, m_OverlayCtxt.uiDstOffsetX, m_OverlayCtxt.uiDstOffsetY));
#endif

	// Update TV DMA Context
	if (m_eTVDMAMode == TV_DMA_OVERLAY)
	{
		DevUpdateTVDMAContext();
	}

	DevOverlayInitialize();

CleanUp:

	LeaveCriticalSection(&m_csDevice);

	return bRet;
}


void
S3C6410Disp::OverlaySetPosition(UINT32 uiOffsetX, UINT32 uiOffsetY)
{
	DISPDRV_INF((_T("OverlaySetPosition(%d,%d)\n\r"), uiOffsetX, uiOffsetY));

	EnterCriticalSection(&m_csDevice);

	m_OverlayCtxt.uiDstOffsetX = uiOffsetX;
	m_OverlayCtxt.uiDstOffsetY  = uiOffsetY;

#if	0	// for Debug
	// Before Adjust Offset
	DISPDRV_ERR((_T("SetPostion [%d, %d, %d, %d]->[%d, %d, %d, %d]\n\r"),
		m_OverlayCtxt.uiSrcWidth, m_OverlayCtxt.uiSrcHeight, m_OverlayCtxt.uiSrcOffsetX, m_OverlayCtxt.uiSrcOffsetY,
		m_OverlayCtxt.uiDstWidth, m_OverlayCtxt.uiDstHeight, m_OverlayCtxt.uiDstOffsetX, m_OverlayCtxt.uiDstOffsetY));
#endif

	// Adjust for Post Processor and FIMD restriction
	if (m_OverlayCtxt.pSurface->PixelFormat() == ddgpePixelFormat_565)
	{
		m_OverlayCtxt.uiDstOffsetX = m_OverlayCtxt.uiDstOffsetX-m_OverlayCtxt.uiDstOffsetX%2;
	}

	// Adjust for Overlay Window Position
	if (m_OverlayCtxt.uiDstWidth+m_OverlayCtxt.uiDstOffsetX > (unsigned int)m_dwDeviceScreenWidth)
	{
		//m_OverlayCtxt.uiDstWidth = m_dwDeviceScreenWidth - m_OverlayCtxt.uiDstOffsetX;	// Adjust Width
		m_OverlayCtxt.uiDstOffsetX = m_dwDeviceScreenWidth - m_OverlayCtxt.uiDstWidth;		// Adjust Offset
	}

	if (m_OverlayCtxt.uiDstHeight+m_OverlayCtxt.uiDstOffsetY  > (unsigned int)m_dwDeviceScreenHeight)
	{
		//m_OverlayCtxt.uiDstHeight = m_dwDeviceScreenHeight - m_OverlayCtxt.uiDstOffsetY;	// Adjust Height
		m_OverlayCtxt.uiDstOffsetY  = m_dwDeviceScreenHeight - m_OverlayCtxt.uiDstHeight;	// Adjust Offset
	}

#if	0	// for Debug
	// After Adjust Offset
	DISPDRV_ERR((_T("SetPostion [%d, %d, %d, %d]->[%d, %d, %d, %d]\n\r"),
		m_OverlayCtxt.uiSrcWidth, m_OverlayCtxt.uiSrcHeight, m_OverlayCtxt.uiSrcOffsetX, m_OverlayCtxt.uiSrcOffsetY,
		m_OverlayCtxt.uiDstWidth, m_OverlayCtxt.uiDstHeight, m_OverlayCtxt.uiDstOffsetX, m_OverlayCtxt.uiDstOffsetY));
#endif

	DevOverlaySetPosition();

	LeaveCriticalSection(&m_csDevice);
}


void
S3C6410Disp::OverlayEnable(void)
{
	DISPDRV_MSG((_T("[DISPDRV] S3C6410Disp::OverlayEnable()\n\r")));

	EnterCriticalSection(&m_csDevice);

	m_OverlayCtxt.bShow = TRUE;

	DevOverlayEnable();

	if (m_eTVDMAMode == TV_DMA_OVERLAY)
	{
		DevOutputEnableTVDMA();
	}

	LeaveCriticalSection(&m_csDevice);
}


void
S3C6410Disp::OverlayDisable(void)
{
	DISPDRV_MSG((_T("[DISPDRV] S3C6410Disp::OverlayDisable()\n\r")));

	m_OverlayCtxt.pSurface = NULL;
	m_OverlayCtxt.pPrevSurface = NULL;

	m_OverlayCtxt.bShow = FALSE;

	EnterCriticalSection(&m_csDevice);

	DevOverlayDisable();

	// Update TV DMA Context
	if (m_eTVDMAMode == TV_DMA_OVERLAY)
	{
		DevOutputDisableTVDMA();
	}

	LeaveCriticalSection(&m_csDevice);

	// Release H/W Resource for Overlay to Video Engine Driver
	OverlayReleaseResource(m_OverlayCtxt.bLocalPath);
}


void
S3C6410Disp::OverlayBlendDisable()
{
	m_OverlayCtxt.bBlendOn = FALSE;
	DevOverlayBlendDisable();
}


void
S3C6410Disp::OverlaySetColorKey(BOOL bSrcCKey, EDDGPEPixelFormat Format, DWORD ColorKey)
{
	m_OverlayCtxt.bBlendOn = TRUE;
	m_OverlayCtxt.bColorKey = TRUE;
	m_OverlayCtxt.bSrcCKey = bSrcCKey;

	if (Format == ddgpePixelFormat_565)	// RGB565
	{
		m_OverlayCtxt.ColorKey =
					(((ColorKey&0xF800)>>11)<<19) |	// R bit
					(((ColorKey&0x07E0)>>5)<<10) |	// G bit
					((ColorKey&0x001F)<<3);			// B bit
		m_OverlayCtxt.CompareKey = 0x00070307;
	}
	else	// if (Format == ddgpePixelFormat_8888)	// RGB888
	{
		m_OverlayCtxt.ColorKey = ColorKey;
		m_OverlayCtxt.CompareKey = 0x00000000;
	}

	DevOverlaySetColorKey();
}

void
S3C6410Disp::OverlaySetAlpha(BOOL bUsePixelBlend, DWORD Alpha)
{
	m_OverlayCtxt.bBlendOn = TRUE;
	m_OverlayCtxt.bColorKey = FALSE;
	m_OverlayCtxt.bUsePixelBlend = bUsePixelBlend;
	m_OverlayCtxt.Alpha = Alpha;

	DevOverlaySetAlpha();
}


void
S3C6410Disp::InitalizeOverlayContext(void)
{
	DISPDRV_MSG((_T("[DISPDRV] ++InitalizeOverlayContext()\n\r")));

	m_OverlayCtxt.pSurface = NULL;			// Current Overlay Surface
	m_OverlayCtxt.pPrevSurface = NULL;

	m_OverlayCtxt.bLocalPath = FALSE;
	m_OverlayCtxt.uiSrcWidth = 0;
	m_OverlayCtxt.uiSrcHeight = 0;
	m_OverlayCtxt.uiSrcOffsetX = 0;
	m_OverlayCtxt.uiSrcOffsetY = 0;
	m_OverlayCtxt.uiDstWidth = 0;
	m_OverlayCtxt.uiDstHeight = 0;
	m_OverlayCtxt.uiDstOffsetX = 0;
	m_OverlayCtxt.uiDstOffsetY = 0;
	m_OverlayCtxt.bEnabled = FALSE;
	m_OverlayCtxt.bShow = FALSE;

	m_OverlayCtxt.bBlendOn = FALSE;
	m_OverlayCtxt.bColorKey = 0x0;
	m_OverlayCtxt.bSrcCKey = FALSE;
	m_OverlayCtxt.CompareKey = 0x0;
	m_OverlayCtxt.ColorKey = 0x0;
	m_OverlayCtxt.bUsePixelBlend = FALSE;
	m_OverlayCtxt.Alpha = 0x0;

	DISPDRV_MSG((_T("[DISPDRV] --InitalizeOverlayContext()\n\r")));
}


S3C6410Surf*
S3C6410Disp::GetCurrentOverlaySurf(void)
{
	return m_OverlayCtxt.pSurface;
}


S3C6410Surf*
S3C6410Disp::GetPreviousOverlaySurf(void)
{
	return m_OverlayCtxt.pPrevSurface;
}


BOOL
S3C6410Disp::DevInitialize(void)
{
	SVEARG_FIMD_OUTPUT_IF tParam;
	DWORD dwBytes;

	DISPDRV_MSG((_T("[DISPDRV] ++S3C6410Disp::DevInitialize()\n\r")));

	EnterCriticalSection(&m_csDevice);

	// Initialize SFR Address of Sub Module
	LDI_initialize_register_address((void *)m_pSPIReg, (void *)m_pDispConReg, (void *)m_pGPIOReg);

	// Set LCD Module Type
#if	(SMDK6410_LCD_MODULE == LCD_MODULE_LTS222)
	LDI_set_LCD_module_type(LDI_LTS222QV_RGB);
#elif	(SMDK6410_LCD_MODULE == LCD_MODULE_LTV350)
	LDI_set_LCD_module_type(LDI_LTV350QV_RGB);
#elif	(SMDK6410_LCD_MODULE == LCD_MODULE_LTE480)
	LDI_set_LCD_module_type(LDI_LTE480WV_RGB);
#elif	(SMDK6410_LCD_MODULE == LCD_MODULE_EMUL48_D1)
	LDI_set_LCD_module_type(LDI_LTE480WV_RGB);
#elif	(SMDK6410_LCD_MODULE == LCD_MODULE_EMUL48_QV)
	LDI_set_LCD_module_type(LDI_LTE480WV_RGB);
#elif	(SMDK6410_LCD_MODULE == LCD_MODULE_EMUL48_PQV)
	LDI_set_LCD_module_type(LDI_LTE480WV_RGB);
#elif	(SMDK6410_LCD_MODULE == LCD_MODULE_EMUL48_ML)
	LDI_set_LCD_module_type(LDI_LTE480WV_RGB);
#elif	(SMDK6410_LCD_MODULE == LCD_MODULE_EMUL48_MP)
	LDI_set_LCD_module_type(LDI_LTE480WV_RGB);
#elif	(SMDK6410_LCD_MODULE == LCD_MODULE_LTP700)
	LDI_set_LCD_module_type(LDI_LTP700WV_RGB);
#endif

	// Get RGB Interface Information from LDI Library
	LDI_fill_output_device_information(&tParam.tRGBDevInfo);

	tParam.dwTVOutScreenWidth = m_dwDeviceScreenWidth;
	tParam.dwTVOutScreenHeight = m_dwDeviceScreenHeight;

	// Initialize Display Interface Parameter
	if ( !DeviceIoControl(m_hVideoDrv, IOCTL_SVE_FIMD_SET_INTERFACE_PARAM, &tParam, sizeof(SVEARG_FIMD_OUTPUT_IF), NULL, 0, &dwBytes, NULL) )
	{
		DISPDRV_ERR((_T("[DISPDRV:ERR] DevInitialize() : IOCTL_SVE_FIMD_SET_INTERFACE_PARAM Failed\n\r")));
	}

	// Check TV Scaler Limitation
	if ((m_eOutputInterface == OUTPUT_IF_TV) && (m_dwDeviceScreenWidth > 800))
	{
		DISPDRV_ERR((_T("[DISPDRV:ERR] DevInitialize() : For TVout, Screen width[%d] should be lower than 800 pixel\n\r"), m_dwDeviceScreenWidth));
		DISPDRV_ERR((_T("[DISPDRV:ERR] DevInitialize() : Output Interface forced to RGB I/F\n\r")));
		m_eOutputInterface = OUTPUT_IF_RGB;
	}

	if (m_eOutputInterface == OUTPUT_IF_RGB)
	{
		DevOutputEnableRGBIF();
	}
	else if (m_eOutputInterface == OUTPUT_IF_TV)
	{
		// Backlight Off from Eboot
		// TODO: To be Replaced with Backlight Driver
		//m_pGPIOReg->GPFDAT &= ~(1<<15);									// set GPF[15] to Low
		//m_pGPIOReg->GPFCON = (m_pGPIOReg->GPFCON & ~(3<<30)) | (1<<30);	// set GPF[15] as Output

		DevOutputEnableTV();
	}

	LeaveCriticalSection(&m_csDevice);

	DISPDRV_MSG((_T("[DISPDRV] --S3C6410Disp::DevInitialize()\n\r")));

	return TRUE;
}


BOOL
S3C6410Disp::DevPowerOn(void)
{
	DWORD dwBytes;

	DISPDRV_INF((_T("[DISPDRV] ++S3C6410Disp::DevPowerOn()\n\r")));

	EnterCriticalSection(&m_csDevice);

#if	((SMDK6410_LCD_MODULE == LCD_MODULE_LTS222) \
	|| (SMDK6410_LCD_MODULE == LCD_MODULE_LTV350) \
	|| (SMDK6410_LCD_MODULE == LCD_MODULE_LTP700))
	// Initialize LCD Module
	LDI_initialize_LCD_module();
#endif

	// Power On Video Driver
	// All of HW State is restored by Video Driver
	if ( !DeviceIoControl(m_hVideoDrv, IOCTL_SVE_PM_SET_POWER_ON, NULL, 0, NULL, 0, &dwBytes, NULL) )
	{
		DISPDRV_ERR((_T("[DISPDRV:ERR] DevPowerOn() : IOCTL_SVE_PM_SET_POWER_ON Failed\n\r")));
	}

	if (m_eOutputInterface == OUTPUT_IF_RGB)
	{
#if ((SMDK6410_LCD_MODULE != LCD_MODULE_LTE480) \
	|| (SMDK6410_LCD_MODULE != LCD_MODULE_LTV350) \
	|| (SMDK6410_LCD_MODULE != LCD_MODULE_LTP700))	// In case of LTE480 Module
		// Initialize LCD Module
		LDI_initialize_LCD_module();
#endif
		// Backlight On
		// TODO: To be Replaced with Backlight Driver
		//m_pGPIOReg->GPFDAT |= (1<<15);										// set GPF[15] to High
		//m_pGPIOReg->GPFCON = (m_pGPIOReg->GPFCON & ~(3<<30)) | (1<<30);	// set GPF[15] as Output
	}

	LeaveCriticalSection(&m_csDevice);

	DISPDRV_INF((_T("[DISPDRV] --S3C6410Disp::DevPowerOn()\n\r")));

	return TRUE;
}


BOOL
S3C6410Disp::DevPowerOff(void)
{
	DWORD dwBytes;

	DISPDRV_INF((_T("[DISPDRV] ++S3C6410Disp::DevPowerOff()\n\r")));

	EnterCriticalSection(&m_csDevice);

	if (m_eOutputInterface == OUTPUT_IF_RGB)
	{
		// Backlight Off
		// TODO: To be Replaced with Backlight Driver
		//m_pGPIOReg->GPFDAT &= ~(1<<15);									// set GPF[15] to Low
		//m_pGPIOReg->GPFCON = (m_pGPIOReg->GPFCON & ~(3<<30)) | (1<<30);	// set GPF[15] as Output
	}

#if	((SMDK6410_LCD_MODULE == LCD_MODULE_LTS222) || (SMDK6410_LCD_MODULE == LCD_MODULE_LTV350)	\
	|| (SMDK6410_LCD_MODULE == LCD_MODULE_LTP700))
	// Power Off Video Driver
	// All of HW State will be restored by Video Driver
	if ( !DeviceIoControl(m_hVideoDrv, IOCTL_SVE_PM_SET_POWER_OFF, NULL, 0, NULL, 0, &dwBytes, NULL) )
	{
		DISPDRV_ERR((_T("[DISPDRV:ERR] DevPowerOff() : IOCTL_SVE_PM_SET_POWER_OFF Failed\n\r")));
	}

	// Deinitialize LCD Module
	LDI_deinitialize_LCD_module();
#else	// In case of LTE480 Module
	// Deinitialize LCD Module
	LDI_deinitialize_LCD_module();

	// Power Off Video Driver
	// All of HW State will be restored by Video Driver
	if ( !DeviceIoControl(m_hVideoDrv, IOCTL_SVE_PM_SET_POWER_OFF, NULL, 0, NULL, 0, &dwBytes, NULL) )
	{
		DISPDRV_ERR((_T("[DISPDRV:ERR] DevPowerOff() : IOCTL_SVE_PM_SET_POWER_OFF Failed\n\r")));
	}
#endif

#if 0 //G2D_ACCELERATE
	// Disable Block Power and Clock for FIMG-2D
	DevHWClockGating(HWCLK_2D_OFF);
	DevHWPowerGating(HWPWR_2D_OFF);
#endif

	LeaveCriticalSection(&m_csDevice);

	DISPDRV_INF((_T("[DISPDRV] --S3C6410Disp::DevPowerOff()\n\r")));

	return TRUE;
}


BOOL
S3C6410Disp::DevChangeOutputInterface(OUTPUT_INTERFACE eNewOutputIF)
{
	BOOL bRet = TRUE;

	DISPDRV_MSG((_T("[DISPDRV] ++S3C6410Disp::DevChangeOutputInterface(%d)\n\r"), eNewOutputIF));

	EnterCriticalSection(&m_csDevice);

	if (m_eOutputInterface == eNewOutputIF)
	{
		DISPDRV_INF((_T("[DISPDRV:INF] DevChangeOutputInterface(%d) : Same Inteface... Not Changed\n\r"), eNewOutputIF));
		bRet = FALSE;
		goto CleanUp;
	}

	if (eNewOutputIF == OUTPUT_IF_TV)
	{
		// Check TV Scaler Limitation
		if (m_dwDeviceScreenWidth > 800)
		{
			DISPDRV_ERR((_T("[DISPDRV:ERR] DevChangeOutputInterface() : For TVout, Screen width[%d] should be lower than 800 pixel\n\r"), m_dwDeviceScreenWidth));
			bRet = FALSE;
			goto CleanUp;
		}

		// Request Video Driver HW Resource
		if (!TVOutAllocResource())
		{
			DISPDRV_INF((_T("[DISPDRV:INF] DevChangeOutputInterface(%d) : TVOutAllocResource() Failed\n\r"), eNewOutputIF));
			bRet = FALSE;
			goto CleanUp;
		}
	}

	//---------------------------
	// Disable Old Output Interface
	//---------------------------
	if (m_eOutputInterface == OUTPUT_IF_RGB)	// Previous interface is RGB I/F
	{
		if (m_eTVDMAMode != 	TV_DMA_DISABLE)
		{
			DevOutputDisableTVDMA();
			m_eTVDMAMode = TV_DMA_DISABLE;
			DISPDRV_INF((_T("[DISPDRV:INF] DevChangeOutputInterface() : TV DMA is disabled for TV Out\n\r")));
		}

		DevOutputDisableRGBIF();
	}
	else		// Previous interface is TV Out
	{
		DevOutputDisableTV();
	}

	//---------------------------
	// Update Output Interface State
	//----------------

⌨️ 快捷键说明

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