예제 #1
0
파일: Power.c 프로젝트: blueskycoco/BigStar
BOOL SVE_video_engine_power_on(void)
{
	SVEngineContext *pCtxt;
	SVEnginePowerContext *pPMCtxt;
	BOOL bRet = TRUE;
	int iWinCnt;

	VDE_MSG((_T("[VDE] ++SVE_video_engine_power_on()\r\n")));

	pCtxt = SVE_get_context();
	pPMCtxt = SVE_get_power_context();

	if (pPMCtxt->bPowerOn)
	{
		VDE_INF((_T("[VDE:INF] SVE_video_engine_power_on() : Video Engine is Already Power On\r\n")));
		goto CleanUp;
	}

	//-------------------------------
	// HW Block Power On and Clock On
	//-------------------------------
	//SVE_hw_power_control(HWPWR_ALL_ON);
	SVE_hw_power_control(HWPWR_DISPLAY_ON);
	SVE_hw_power_control(HWPWR_2D_ON);
	//SVE_hw_clock_control(HWCLK_ALL_ON);
	SVE_hw_clock_control(HWCLK_DISPLAY_ON);
	SVE_hw_clock_control(HWCLK_2D_ON);

	//-------------------
	// FIMD Reconfiguration
	//-------------------
	if (pPMCtxt->bFIMDOutputParam)
	{
		Disp_set_output_device_information(&pPMCtxt->tFIMDOutputParam.tRGBDevInfo);
		Disp_set_output_TV_information(pPMCtxt->tFIMDOutputParam.dwTVOutScreenWidth, pPMCtxt->tFIMDOutputParam.dwTVOutScreenHeight);

		if (pPMCtxt->bFIMDOutputTV)
		{
			Disp_initialize_output_interface(DISP_VIDOUT_TVENCODER);
		}
		else
		{
			Disp_initialize_output_interface(DISP_VIDOUT_RGBIF);
		}
	}

	//---------------------------
	// FIMD Window Reconfiguration
	//---------------------------

	for (iWinCnt=DISP_WIN0; iWinCnt< DISP_WIN_MAX; iWinCnt++)
	{
		if (pPMCtxt->bFIMDWinMode[iWinCnt])
		{
			Disp_set_window_mode(pPMCtxt->tFIMDWinMode[iWinCnt].dwWinMode, pPMCtxt->tFIMDWinMode[iWinCnt].dwBPP,
									pPMCtxt->tFIMDWinMode[iWinCnt].dwWidth, pPMCtxt->tFIMDWinMode[iWinCnt].dwHeight,
									pPMCtxt->tFIMDWinMode[iWinCnt].dwOffsetX, pPMCtxt->tFIMDWinMode[iWinCnt].dwOffsetY);
		}

		if (pPMCtxt->bFIMDWinFBuffer[iWinCnt])
		{
			Disp_set_framebuffer(iWinCnt, pPMCtxt->tFIMDWinFBuffer[iWinCnt].dwFrameBuffer);
		}

		if (pPMCtxt->bFIMDColorKey[iWinCnt])
		{
			Disp_set_color_key(iWinCnt, pPMCtxt->tFIMDColorKey[iWinCnt].bOnOff, pPMCtxt->tFIMDColorKey[iWinCnt].dwDirection,
								pPMCtxt->tFIMDColorKey[iWinCnt].dwColorKey, pPMCtxt->tFIMDColorKey[iWinCnt].dwCompareKey);
		}

		if (pPMCtxt->bFIMDAlpha[iWinCnt])
		{
			Disp_set_alpha_blending(iWinCnt, pPMCtxt->tFIMDAlpha[iWinCnt].dwMethod,
									pPMCtxt->tFIMDAlpha[iWinCnt].dwAlpha0, pPMCtxt->tFIMDAlpha[iWinCnt].dwAlpha1);
		}

		if (pPMCtxt->bFIMDWinEnable[iWinCnt])
		{
			Disp_window_onfoff(iWinCnt, DISP_WINDOW_ON);
			pCtxt->bWindowEnable[iWinCnt] = TRUE;
		}
	}

	//---------------------------
	// Post Processor Reconfiguration
	//---------------------------

	if (pPMCtxt->bPostParam)
	{
		SVE_hw_power_control(HWPWR_POST_ON);
		SVE_hw_clock_control(HWCLK_POST_ON);
		Post_initialize(pPMCtxt->tPostParam.dwOpMode, pPMCtxt->tPostParam.dwScanMode,
					pPMCtxt->tPostParam.dwSrcType,
					pPMCtxt->tPostParam.dwSrcBaseWidth, pPMCtxt->tPostParam.dwSrcBaseHeight,
					pPMCtxt->tPostParam.dwSrcWidth, pPMCtxt->tPostParam.dwSrcHeight,
					pPMCtxt->tPostParam.dwSrcOffsetX, pPMCtxt->tPostParam.dwSrcOffsetY,
					pPMCtxt->tPostParam.dwDstType,
					pPMCtxt->tPostParam.dwDstBaseWidth, pPMCtxt->tPostParam.dwDstBaseHeight,
					pPMCtxt->tPostParam.dwDstWidth, pPMCtxt->tPostParam.dwDstHeight,
					pPMCtxt->tPostParam.dwDstOffsetX, pPMCtxt->tPostParam.dwDstOffsetY);

		if (pPMCtxt->bPostSrcBuffer)
		{
			Post_set_source_buffer(pPMCtxt->tPostSrcBuffer.dwBufferRGBY,
										pPMCtxt->tPostSrcBuffer.dwBufferCb,
										pPMCtxt->tPostSrcBuffer.dwBufferCr);

			Post_set_next_source_buffer(pPMCtxt->tPostSrcBuffer.dwBufferRGBY,
										pPMCtxt->tPostSrcBuffer.dwBufferCb,
										pPMCtxt->tPostSrcBuffer.dwBufferCr);
		}

		if (pPMCtxt->bPostDstBuffer)
		{

			Post_set_destination_buffer(pPMCtxt->tPostDstBuffer.dwBufferRGBY,
										pPMCtxt->tPostDstBuffer.dwBufferCb,
										pPMCtxt->tPostDstBuffer.dwBufferCr);

			Post_set_next_destination_buffer(pPMCtxt->tPostDstBuffer.dwBufferRGBY,
										pPMCtxt->tPostDstBuffer.dwBufferCb,
										pPMCtxt->tPostDstBuffer.dwBufferCr);
		}

		if (pPMCtxt->bPostStart)
		{
			pPMCtxt->bTVSCStart  = FALSE;	// for Trigger Once
			Post_enable_interrupt();
			Post_processing_start();
		}
	}

	//-----------------------
	// TV Scaler Reconfiguration
	//-----------------------

	if (pPMCtxt->bTVSCParam)
	{
		SVE_hw_power_control(HWPWR_TV_ON);
		SVE_hw_clock_control(HWCLK_TV_ON);
		TVSC_initialize(pPMCtxt->tTVSCParam.dwOpMode, pPMCtxt->tTVSCParam.dwScanMode,
					pPMCtxt->tTVSCParam.dwSrcType,
					pPMCtxt->tTVSCParam.dwSrcBaseWidth, pPMCtxt->tTVSCParam.dwSrcBaseHeight,
					pPMCtxt->tTVSCParam.dwSrcWidth, pPMCtxt->tTVSCParam.dwSrcHeight,
					pPMCtxt->tTVSCParam.dwSrcOffsetX, pPMCtxt->tTVSCParam.dwSrcOffsetY,
					pPMCtxt->tTVSCParam.dwDstType,
					pPMCtxt->tTVSCParam.dwDstBaseWidth, pPMCtxt->tTVSCParam.dwDstBaseHeight,
					pPMCtxt->tTVSCParam.dwDstWidth, pPMCtxt->tTVSCParam.dwDstHeight,
					pPMCtxt->tTVSCParam.dwDstOffsetX, pPMCtxt->tTVSCParam.dwDstOffsetY);

		if (pPMCtxt->bTVSCSrcBuffer)
		{
			TVSC_set_source_buffer(pPMCtxt->tTVSCSrcBuffer.dwBufferRGBY,
										pPMCtxt->tTVSCSrcBuffer.dwBufferCb,
										pPMCtxt->tTVSCSrcBuffer.dwBufferCr);

			TVSC_set_next_source_buffer(pPMCtxt->tTVSCSrcBuffer.dwBufferRGBY,
										pPMCtxt->tTVSCSrcBuffer.dwBufferCb,
										pPMCtxt->tTVSCSrcBuffer.dwBufferCr);
		}

		if (pPMCtxt->bTVSCDstBuffer)
		{
			TVSC_set_destination_buffer(pPMCtxt->tTVSCDstBuffer.dwBufferRGBY,
										pPMCtxt->tTVSCDstBuffer.dwBufferCb,
										pPMCtxt->tTVSCDstBuffer.dwBufferCr);

			TVSC_set_next_destination_buffer(pPMCtxt->tTVSCDstBuffer.dwBufferRGBY,
										pPMCtxt->tTVSCDstBuffer.dwBufferCb,
										pPMCtxt->tTVSCDstBuffer.dwBufferCr);
		}

		if (pPMCtxt->bTVSCStart)
		{
			pPMCtxt->bTVSCStart  = FALSE;
			TVSC_enable_interrupt();
			TVSC_processing_start();
		}
	}

	//---------------------------
	// Local Path Reconfiguration
	//---------------------------

	if (pPMCtxt->bLocalPathWin0Enable)
	{
		Post_enable_interrupt();
		Post_processing_start();
		Disp_set_framebuffer(DISP_WIN0, IMAGE_FRAMEBUFFER_PA_START);	// Safe Frame Bufer Address for Local Path
		Disp_window_onfoff(DISP_WIN0, DISP_WINDOW_ON);

		pCtxt->bWindowEnable[DISP_WIN0] = TRUE;
	}

	if (pPMCtxt->bLocalPathWin1Enable)
	{
		// TODO: Enable CamIF MSDMA or TV Scaler
		pCtxt->bWindowEnable[DISP_WIN1] = TRUE;
	}

	if (pPMCtxt->bLocalPathWin2Enable)
	{
		// TODO: Enable CamIF MSDMA or TV Scaler
		pCtxt->bWindowEnable[DISP_WIN2] = TRUE;
	}

	//---------------------------
	// Image Rotator Reconfiguration
	//---------------------------

	if (pPMCtxt->bRotatorParam)
	{
		SVE_hw_power_control(HWPWR_ROTATOR_ON);
		SVE_hw_clock_control(HWCLK_ROTATOR_ON);
		Rotator_initialize(pPMCtxt->tRotatorParam.dwImgFormat,
						pPMCtxt->tRotatorParam.dwOpType,
						pPMCtxt->tRotatorParam.dwSrcWidth,
						pPMCtxt->tRotatorParam.dwSrcHeight);

		if (pPMCtxt->bRotatorSrcBuffer)
		{
			Rotator_set_source_buffer(pPMCtxt->tRotatorSrcBuffer.dwBufferRGBY,
									pPMCtxt->tRotatorSrcBuffer.dwBufferCb,
									pPMCtxt->tRotatorSrcBuffer.dwBufferCr);
		}

		if (pPMCtxt->bRotatorDstBuffer)
		{
			Rotator_set_destination_buffer(pPMCtxt->tRotatorDstBuffer.dwBufferRGBY,
									pPMCtxt->tRotatorDstBuffer.dwBufferCb,
									pPMCtxt->tRotatorDstBuffer.dwBufferCr);
		}

		if (pPMCtxt->bRotatorStart)
		{
			pPMCtxt->bRotatorStart = FALSE;
			pCtxt->bRotatorBusy = TRUE;
			Rotator_enable_interrupt();
			Rotator_start();
		}
	}

	//---------------------------
	// TV Encoder Reconfiguration
	//---------------------------

	if (pPMCtxt->bTVEncParam)
	{
		TVEnc_initialize(pPMCtxt->tTVEncParam.dwOutputType,
						pPMCtxt->tTVEncParam.dwOutputStandard, pPMCtxt->tTVEncParam.dwMVisionPattern,
						pPMCtxt->tTVEncParam.dwSrcWidth, pPMCtxt->tTVEncParam.dwSrcHeight);
	}

	//-------------------
	// Enable Video Output
	//-------------------

	if (pPMCtxt->bTVEncEnable)
	{
		// TV Encoder On
		TVEnc_output_onoff(TVENC_ENCODER_ON);

		// TV Scaler Start
		TVSC_enable_interrupt();
		TVSC_processing_start();
	}

	if (pPMCtxt->bFIMDOutputEnable)
	{
		// Enable Interrupt
		Disp_set_frame_interrupt(DISP_FRMINT_FRONTPORCH);
		Disp_enable_frame_interrupt();

		// Video Output Enable
		Disp_envid_onoff(DISP_ENVID_ON);
		pCtxt->bVideoEnable = TRUE;
	}

	//-------------------
	// Update Power State
	//-------------------
	pPMCtxt->bPowerOn = TRUE;

CleanUp:

	VDE_MSG((_T("[VDE] --SVE_video_engine_power_on()\r\n")));

	return bRet;
}
예제 #2
0
BOOL SVE_TVScaler_API_Proc(
    DWORD hOpenContext,
    DWORD dwCode,
    PBYTE pBufIn,
    DWORD dwLenIn,
    PBYTE pBufOut,
    DWORD dwLenOut,
    PDWORD pdwActualOut
    )
{
    SVEngineContext *pCtxt;
    SVEnginePowerContext *pPMCtxt;
    BOOL bRet = TRUE;

    //VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\r\n"),
    //            hOpenContext, dwCode, pBufIn, dwLenIn, pBufOut, dwLenOut, pdwActualOut));
    VDE_MSG((_T("[VDE] ++SVE_TVScaler_API_Proc()\n\r")));

    pCtxt = SVE_get_context();
    pPMCtxt = SVE_get_power_context();

    //-------------------------------------------------------------
    // Check OpenContext of Caller have the right to access to H/W Resource
    //-------------------------------------------------------------
    switch(dwCode)
    {
    case SVE_TVSC_SET_PROCESSING_PARAM:
    case SVE_TVSC_SET_SOURCE_BUFFER:
    case SVE_TVSC_SET_NEXT_SOURCE_BUFFER:
    case SVE_TVSC_SET_DESTINATION_BUFFER:
    case SVE_TVSC_SET_NEXT_DESTINATION_BUFFER:
    case SVE_TVSC_SET_PROCESSING_START:
    case SVE_TVSC_SET_PROCESSING_STOP:
    case SVE_TVSC_WAIT_PROCESSING_DONE:
    case SVE_TVSC_GET_PROCESSING_STATUS:
        bRet = SVE_resource_compare_TVScaler_TVEncoder(hOpenContext);
        if (!bRet)
        {
            VDE_ERR((_T("[VDE:ERR] SVE_TVScaler_API_Proc(0x%08x) : No Right to Access to H/W Resource\r\n"), dwCode));
            goto CleanUp;
        }
        break;
    default:
        bRet = FALSE;
        DEBUGMSG(VDE_ZONE_ERROR, (TEXT("[VDE:ERR] Invalid IOCTL code\n")));        
        goto CleanUp;
        break;
    }

    //--------------------------------
    // Processing IOCTL for TV Scaler
    //--------------------------------

    switch(dwCode)
    {
        case SVE_TVSC_SET_PROCESSING_PARAM:
        {
            SVEARG_TVSC_PARAMETER *pArg;

            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_PROCESSING_PARAM\n\r")));

            if(!pBufIn)
            {
                DEBUGMSG(VDE_ZONE_ERROR,(TEXT("Invalid Buffer : pBufIn:0x%x\n"), pBufIn));
                bRet = FALSE;
                break;
            }            

            pArg = (SVEARG_TVSC_PARAMETER *)pBufIn;

            if (pPMCtxt->bPowerOn)
            {
                if (TVSC_get_processing_state() == TVSC_BUSY)        // TV Scaler Running
                {
                    VDE_ERR((_T("[VDE:ERR] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_PROCESSING_START : TV Scaler is Running\n\r")));
                    bRet = FALSE;
                    break;
                }

                TVSC_initialize(pArg->dwOpMode, pArg->dwScanMode,
                            pArg->dwSrcType, pArg->dwSrcBaseWidth, pArg->dwSrcBaseHeight, pArg->dwSrcWidth, pArg->dwSrcHeight, pArg->dwSrcOffsetX, pArg->dwSrcOffsetY,
                            pArg->dwDstType, pArg->dwDstBaseWidth, pArg->dwDstBaseHeight, pArg->dwDstWidth, pArg->dwDstHeight, pArg->dwDstOffsetX, pArg->dwDstOffsetY);
            }

            // Backup for PM
            memcpy(&pPMCtxt->tTVSCParam, pArg, sizeof(SVEARG_TVSC_PARAMETER));

            break;
        }

        case SVE_TVSC_SET_SOURCE_BUFFER:
        {
            SVEARG_TVSC_BUFFER *pArg;

            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_SOURCE_BUFFER\n\r")));

            pArg = (SVEARG_TVSC_BUFFER *)pBufIn;

            if (pPMCtxt->bPowerOn)
            {
                if (TVSC_get_processing_state() == TVSC_BUSY)        // TV Scaler Running
                {
                    VDE_ERR((_T("[VDE:ERR] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_SOURCE_BUFFER : TV Scaler is Running\n\r")));
                    bRet = FALSE;
                    break;
                }

                TVSC_set_source_buffer(pArg->dwBufferRGBY, pArg->dwBufferCb, pArg->dwBufferCr);
            }

            // Backup for PM
            memcpy(&pPMCtxt->tTVSCSrcBuffer, pArg, sizeof(SVEARG_TVSC_BUFFER));
            pPMCtxt->bTVSCSrcBuffer = TRUE;

            break;
        }

        case SVE_TVSC_SET_NEXT_SOURCE_BUFFER:
        {
            SVEARG_TVSC_BUFFER *pArg;

            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_NEXT_SOURCE_BUFFER\n\r")));

            pArg = (SVEARG_TVSC_BUFFER *)pBufIn;

            if (pPMCtxt->bPowerOn)
            {
                if (TVSC_get_processing_state() == TVSC_BUSY)        // TV Scaler Running
                {
                    BOOL bRetry = TRUE;

                    while(bRetry)
                    {
                        if (pCtxt->TVSCCmdCtxt.bCmdSetSrcBuffer == FALSE)
                        {
                            EnterCriticalSection(&pCtxt->TVSCCmdCtxt.csCmd);                        
                            // We can change buffer address here...
                            // But, after interrupt occurs, It can take effect..
                            TVSC_set_next_source_buffer(pArg->dwBufferRGBY, pArg->dwBufferCb, pArg->dwBufferCr);

                            pCtxt->TVSCCmdCtxt.bCmdSetSrcBuffer = TRUE;
                            bRetry = FALSE;
                            LeaveCriticalSection(&pCtxt->TVSCCmdCtxt.csCmd);                            
                        }

                        if (bRetry || pArg->bWaitForVSync)
                        {
                            if (WAIT_TIMEOUT == SVE_wait_tvsc_cmd_done())
                            {
                                VDE_ERR((_T("[VDE:ERR] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_NEXT_SOURCE_BUFFER : SVE_wait_tvsc_cmd_done() TimeOut\n\r")));
                                bRetry = FALSE;
                                bRet = FALSE;
                            }
                        }
                    }
                }
                else
                {
                    TVSC_set_next_source_buffer(pArg->dwBufferRGBY, pArg->dwBufferCb, pArg->dwBufferCr);
                }
            }

            // Backup for PM
            memcpy(&pPMCtxt->tTVSCSrcBuffer, pArg, sizeof(SVEARG_TVSC_BUFFER));
            pPMCtxt->bTVSCSrcBuffer = TRUE;

            break;
        }

        case SVE_TVSC_SET_DESTINATION_BUFFER:
        {
            SVEARG_TVSC_BUFFER *pArg;

            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_DESTINATION_BUFFER\n\r")));

            pArg = (SVEARG_TVSC_BUFFER *)pBufIn;

            if (pPMCtxt->bPowerOn)
            {
                if (TVSC_get_processing_state() == TVSC_BUSY)        // TV Scaler Running
                {
                    VDE_ERR((_T("[VDE:ERR] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_DESTINATION_BUFFER : TV Scaler is Running\n\r")));
                    bRet = FALSE;
                    break;
                }

                TVSC_set_destination_buffer(pArg->dwBufferRGBY, pArg->dwBufferCb, pArg->dwBufferCr);
            }

            // Backup for PM
            memcpy(&pPMCtxt->tTVSCDstBuffer, pArg, sizeof(SVEARG_TVSC_BUFFER));
            pPMCtxt->bTVSCDstBuffer = TRUE;

            break;
        }

        case SVE_TVSC_SET_NEXT_DESTINATION_BUFFER:
        {
            SVEARG_TVSC_BUFFER *pArg;

            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_NEXT_DESTINATION_BUFFER\n\r")));

            pArg = (SVEARG_TVSC_BUFFER *)pBufIn;

            if (pPMCtxt->bPowerOn)
            {
                if (TVSC_get_processing_state() == TVSC_BUSY)        // TV Scaler Running
                {
                    BOOL bRetry = TRUE;

                    while(bRetry)
                    {
                        if (pCtxt->TVSCCmdCtxt.bCmdSetDstBuffer == FALSE)
                        {
                            EnterCriticalSection(&pCtxt->TVSCCmdCtxt.csCmd);
                        
                            // We can change buffer address here...
                            // But, after interrupt occurs, It can take effect..
                            TVSC_set_next_destination_buffer(pArg->dwBufferRGBY, pArg->dwBufferCb, pArg->dwBufferCr);

                            pCtxt->TVSCCmdCtxt.bCmdSetDstBuffer = TRUE;
                            bRetry = FALSE;

                            LeaveCriticalSection(&pCtxt->TVSCCmdCtxt.csCmd);                            
                        }

                        if (bRetry || pArg->bWaitForVSync)
                        {
                            if (WAIT_TIMEOUT == SVE_wait_tvsc_cmd_done())
                            {
                                VDE_ERR((_T("[VDE:ERR] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_NEXT_DESTINATION_BUFFER : SVE_wait_tvsc_cmd_done() TimeOut\n\r")));
                                bRetry = FALSE;
                                bRet = FALSE;
                            }
                        }
                    }
                }
                else
                {
                    TVSC_set_next_destination_buffer(pArg->dwBufferRGBY, pArg->dwBufferCb, pArg->dwBufferCr);
                }
            }

            // Backup for PM
            memcpy(&pPMCtxt->tTVSCDstBuffer, pArg, sizeof(SVEARG_TVSC_BUFFER));
            pPMCtxt->bTVSCDstBuffer = TRUE;

            break;
        }

        case SVE_TVSC_SET_PROCESSING_START:
        {
            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_PROCESSING_START\n\r")));

            if (pPMCtxt->bPowerOn)
            {
                if (TVSC_get_processing_state() == TVSC_BUSY)        // TV Scaler Running
                {
                    VDE_ERR((_T("[VDE:ERR] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_PROCESSING_START : TV Scaler is Running\n\r")));
                    bRet = FALSE;
                    break;
                }

                TVSC_enable_interrupt();
                TVSC_processing_start();
            }

            // Backup for PM
            pPMCtxt->bTVSCStart = TRUE;

            break;
        }

        case SVE_TVSC_SET_PROCESSING_STOP:
        {
            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_PROCESSING_STOP\n\r")));

            if (pPMCtxt->bPowerOn)
            {
                TVSC_autoload_disable();

                if (TVSC_get_processing_state() == TVSC_BUSY)    // TV Scaler Running
                {
                    // Wait for Current Frame Finished
                    if (WAIT_TIMEOUT == SVE_wait_tvsc_cmd_done())
                    {
                        if (TVSC_get_processing_state() == TVSC_IDLE)
                        {
                            // Time Out, But TV Scaler Finished
                            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_PROCESSING_STOP : SVE_wait_tvsc_cmd_done() TimeOut, But TV Scaler Finished\n\r")));
                        }
                        else
                        {
                            VDE_INF((_T("[VDE:INF] SVE_TVScaler_API_Proc() : SVE_TVSC_SET_PROCESSING_STOP : SVE_wait_tvsc_cmd_done() TimeOut\n\r")));
                            TVSC_processing_stop();
                        }
                    }
                }
            }

            // Backup for PM
            pPMCtxt->bTVSCStart = FALSE;

            break;
        }

        case SVE_TVSC_WAIT_PROCESSING_DONE:
        {
            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_WAIT_PROCESSING_DONE\n\r")));

            if (pPMCtxt->bPowerOn)
            {
                if (TVSC_get_processing_state() == TVSC_BUSY)        // TV Scaler Running
                {
                    if (WAIT_TIMEOUT == SVE_wait_tvsc_cmd_done())
                    {
                        if (TVSC_get_processing_state() == TVSC_IDLE)
                        {
                            // Time Out, But TV Scaler Finished
                            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_WAIT_PROCESSING_DONE : SVE_wait_tvsc_cmd_done() TimeOut, But TV Scaler Finished\n\r")));
                        }
                        else
                        {
                            VDE_INF((_T("[VDE:INF] SVE_TVScaler_API_Proc() : SVE_TVSC_WAIT_PROCESSING_DONE : SVE_wait_tvsc_cmd_done() TimeOut\n\r")));
                            bRet = FALSE;
                        }
                    }
                }
            }

            // Backup for PM
            pPMCtxt->bTVSCStart = FALSE;

            break;
        }

        case SVE_TVSC_GET_PROCESSING_STATUS:
        {
            DWORD *pArg;

            VDE_MSG((_T("[VDE] SVE_TVScaler_API_Proc() : SVE_TVSC_GET_PROCESSING_STATUS\n\r")));

            pArg = (DWORD *)pBufOut;

            if (pPMCtxt->bPowerOn)
            {
                *pArg = TVSC_get_processing_state();
            }
            else
            {
                *pArg = TVSC_IDLE;
            }

            *pdwActualOut = sizeof(DWORD);

            break;
        }
        default:    // This is filtered above switch statement
            bRet = FALSE;
            break;            
        
    }

CleanUp:

    VDE_MSG((_T("[VDE] --SVE_TVScaler_API_Proc()\n\r")));

    return bRet;
}