/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/


/*****************************************************************************
 *
 * Filename:
 * ---------
 *   $Workfile: command.c $ 
 *
 * Project:
 * --------
 *   MT8226
 *
 * Description:
 * ------------
 *   BIM register definition
 *   
 * Author:
 * -------
 *   David Hsieh
 *
 * Last changed:
 * ------------- 
 * $Author: wangliang.wang $ 
 *
 * $Modtime: 04/05/27 10:47p $    
 *
 * $Revision: #5 $
****************************************************************************/
#include "general.h"
#include "Command_Task.h"
#include "Cust_Tasks.h"
#include "drv_hdmicec.h"
#include "custom_def.h"
#if ENABLE_CBUS
#include "drv_mhlcbus.h"
#endif

extern UINT8 uWhiteLedDuty;
extern UINT8 uRedLedDuty;
extern UINT8 uGreenLedDuty;
extern UINT8 uBlueLedDuty;

extern UINT8 xdata u1SleepStatus;

#if DRAM_RESET_GPIO_CTRL
extern UINT8 xdata _u1DramRestGpio;
extern UINT8 xdata _u1DramRestOnce;

#endif


#if CUST_AUTO_IRRC_WAKEUP
extern UINT32 u4NextWakeupTime;
extern UINT8 uNextWakeupTimerOn;
#endif

extern UINT8 GetColorIdx(UINT8 flag);

#if S_HOTEL_MODE_COMMAND
extern UINT8 bModule2Status;
extern UINT8 u1CustomData1_HotelModule;
extern UINT8 u1CustomData3_Module1ReplyData;
extern UINT8 u1hotel_module2_init_mode;
extern UINT8 xdata u1Module2Enable;
extern UINT8 data u1HotelDbg;
extern UINT8 u1Module2AvSelectPW;
extern UINT8 u1Module2AvSelectSrc;
extern UINT8 u1Module2HdmiPortSel;
#endif
extern UINT8 Cbus8032GetHDMI2KModel;
extern UINT8 u1ECOModel;

extern UINT32 SIR_KEY_POWER1;
extern UINT32 SIR_KEY_POWER2;
extern UINT32 SIR_KEY_POWER3;
extern UINT32 SIR_KEY_POWER4;
extern UINT32 SIR_KEY_POWER5;
extern UINT32 SIR_KEY_POWER6;
extern UINT32 SIR_KEY_POWER7;
extern UINT32 SIR_KEY_POWER8;
extern UINT32 SIR_KEY_POWER9;
extern UINT32 SIR_KEY_POWER10;
extern UINT32 SIR_KEY_POWER11;
extern UINT32 SIR_KEY_POWER12;
extern UINT32 SIR_KEY_POWER13;
extern UINT32 SIR_KEY_POWER14;
extern UINT32 SIR_KEY_POWER15;
extern UINT32 SIR_KEY_POWER16;


void vCMD_RESONSE(UINT8 u1Cmd, UINT8 u1Para0, UINT8 u1Para1, UINT8 u1Para2)
{
    UINT32 u4Para;
    u4Para = (((UINT32)u1Para2) << 24) | (((UINT32)u1Para1) << 16) | (((UINT32)u1Para0) << 8) | u1Cmd;
    MWriteDataToARM(u4Para);
    MTriggerARMInterrupt();
}

#if ENABLE_CEC
void CECMenuLanguageOK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_MenuLanguage);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_MenuLanguage, 0, 0, 0);
}
void CECEnableCECOK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_EnableCEC);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_EnableCEC, 0, 0, 0);
}
void CECEnableOneTouchPlayOK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_EnableOneTouch);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_EnableOneTouch, 0, 0, 0);
}
void CECT8032CtlCECOK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_SetT8032CtlCEC);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_SetT8032CtlCEC, 0, 0, 0);	
}
void CECSetVendorIDOK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_SetVendorID);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_SetVendorID, 0, 0, 0);	
}
void CECSetVersionOK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_SetVersion);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_SetVersion, 0, 0, 0);	
}
#ifdef CEC_FEATURE_3_1 
void CECSetOSDName1OK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_SetOSDName1);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_SetOSDName1, 0, 0, 0);	
}
void CECSetOSDName2OK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_SetOSDName2);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_SetOSDName2, 0, 0, 0);	
}
void CECSetOSDName3OK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_SetOSDName3);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_SetOSDName3, 0, 0, 0);	
}
void CECSetOSDName4OK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_SetOSDName4);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_SetOSDName4, 0, 0, 0);	
}
void CECSetWkpCode1OK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_SetWakeupOpCode1);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_SetWakeupOpCode1, 0, 0, 0);	
}
void CECSetWkpCode2OK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_SetWakeupOpCode2);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_SetWakeupOpCode2, 0, 0, 0);	
}
void CECSetWkpCode3OK(void)
{
//	vWriteDataToARM(Cmd_ResponseCEC_SetWakeupOpCode3);
//	vTriggerARMInterrupt();
    vCMD_RESONSE(Cmd_ResponseCEC_SetWakeupOpCode3, 0, 0, 0);	
}
#endif
#endif

#if SUPORT_COLD_REBOOT
extern UINT8 u1ColdRebootChk;
#endif

#if CUS_SH_HOTEL_MODE 
extern UINT8 fgCust_SH_HotelModeUartWakeupEn;    
#endif

#if SUPPORT_ERROR_LED_CTRL
extern Error_Code_Ctrl gErrCodeCtrl;
#endif
#if S_HOTEL_MODE_COMMAND
extern Led_Toggle_Ctrl gLedToggleCtrl;
#endif

#if SUSPEND_MODE
extern UINT8 PreStandbySta;
extern UINT8 GoingSupend;
extern UINT8 SuspendTimer;
extern UINT8 xdata _u1SmPcb;
extern UINT8 xdata ConsoleLockMode;
extern UINT8 xdata ICEMode;
#endif

#if SIR_TASK
extern SIRC_CTRL_T idata gSIRC_ctrl;
extern UINT8 data gIRWakeupKeyList;
#endif

#if DISABLE_WAKEUP_SOMETIME
extern Delay_Wakeup_Ctrl gDelayWakeupCtrl;
#endif

void vCommandTask(void)
{
    PDWNC_T8032_CMD_T data tmpCmd;
    if(bCommandPop(&tmpCmd) == NO_EVENT)
    {
        return;//no new command
    }
#if UART_DBG    
    LogSB("Mcmd", tmpCmd.u1Cmd);
    LogSB("Scmd", tmpCmd.u1SubCmd);
#endif 
    vIO32Write4B(PDWNC_CHK_SEL,0);
//    Cmd_ReadT8032WakeUp is the COMMAND most frequestly issued from ARM, so place it at 1st decision...
    if(tmpCmd.u1Cmd == Cmd_ReadT8032WakeUp)
    {
        vCMD_RESONSE(Cmd_ReadT8032WakeUp, MGET_SYS_WAKEUP_REASON(), MGET_SYS_SUB_WAKEUP_REASON(), MGET_SYS_SERVICE_MODE());
    }
    if(tmpCmd.u1Cmd == Cmd_ReadT8032WakeUpNew)
    {
        vCMD_RESONSE(Cmd_ReadT8032WakeUpNew, MGET_SYS_SUB_WAKEUP_REASON(),MGET_SYS_SUB_WAKEUP_REASON_2(), MGET_SYS_SUB_WAKEUP_REASON_3());
    }
#if CM4_WAKEUP_TASK
    else if(tmpCmd.u1Cmd == Cmd_CM4TriggerT8032Wakeup)
    {
        #if 0
            if(u1SleepStatus == SLEEP_STANDBY_STATE)
            {
                u1SleepStatus = SLEEP_WAKEUP_STATE;
                vWakeUpSystem(PDWNC_WAKE_UP_REASON_CM4,0);
            }
            else if(u1SleepStatus == SLEEP_SUSPEND_STATE)
        #endif
        {
            //u1SleepStatus = SLEEP_WAKEUP_STATE;
            vWakeUpSystem(PDWNC_WAKE_UP_REASON_CM4,0);
        }
    }
#endif
    #if SIF_PDWNC_TEST  
    else if(tmpCmd.u1Cmd == Cmd_PDSIF_READ)
    {
        #if UART_DBG
        LogS("t8032 Cmd_PDSIF_READ");        
        #endif         
        vCMD_RESONSE(Cmd_PDSIF_READ, PD_SIF_Read_Test(tmpCmd.u1SubCmd,tmpCmd.au1Data[0],tmpCmd.au1Data[1],tmpCmd.au1Data[2]), 0, 0);
    }
    else if(tmpCmd.u1Cmd == Cmd_PDSIF_WRITE)
    {
        #if UART_DBG
        LogS("t8032 Cmd_PDSIF_WRITE");
        #endif        
        vCMD_RESONSE(Cmd_PDSIF_WRITE, PD_SIF_Write_Test(tmpCmd.u1SubCmd,tmpCmd.au1Data[0],tmpCmd.au1Data[1],tmpCmd.au1Data[2]), 0, 0);
    }
    else if(tmpCmd.u1Cmd == Cmd_PDSIF_EEP_READ)
    {
        #if UART_DBG
        LogS("t8032 Cmd_PDSIF_EEP_READ");        
        #endif        
        vCMD_RESONSE(Cmd_PDSIF_EEP_READ, PD_SIF_EEP_Read_Test(tmpCmd.au1Data[0],tmpCmd.au1Data[1],tmpCmd.au1Data[2]), 0, 0);
    }
    else if(tmpCmd.u1Cmd == Cmd_PDSIF_EEP_WRITE)
    {
        #if UART_DBG
        LogS("t8032 Cmd_PDSIF_EEP_WRITE");
        #endif       
        vCMD_RESONSE(Cmd_PDSIF_EEP_WRITE, PD_SIF_EEP_Write_Test(tmpCmd.au1Data[0],tmpCmd.au1Data[1],tmpCmd.au1Data[2],tmpCmd.au1Data[3]), 0, 0);
    }
    #endif

#if T8032_GPIO_TEST
	else if(tmpCmd.u1Cmd == Cmd_GPIOOutput)
	{
		//tmpCmd.au1Data[0]: number, OPCTRL(x)-OPCTRL0 or ADIN(x)-ADIN0. for example: OPCTRL0=>0, ADIN0=>0
		//tmpCmd.au1Data[1]: flag, OPCTRL is 0, ADIN is 1
		//tmpCmd.au1Data[2]: GPIO value (just for output)
		#if UART_DBG
        LogS("t8032 Cmd_GPIOOutput");
		#endif		
		if(tmpCmd.au1Data[1] == 0)			
        	{vCMD_RESONSE(Cmd_GPIOOutput, GPIO_SetOut(tmpCmd.au1Data[0]+200,tmpCmd.au1Data[2]), 0, 0);}
		else
			{vCMD_RESONSE(Cmd_GPIOOutput, GPIO_SetOut(tmpCmd.au1Data[0]+400,tmpCmd.au1Data[2]), 0, 0);}
	}
	
	else if(tmpCmd.u1Cmd == Cmd_GPIOInput)
	{
		#if UART_DBG
        LogS("t8032 Cmd_GPIOInput");
		#endif
		if(tmpCmd.au1Data[1] == 0)			
        	{vCMD_RESONSE(Cmd_GPIOInput, GPIO_GetIn(tmpCmd.au1Data[0]+200), 0, 0);}
		else
        	{vCMD_RESONSE(Cmd_GPIOInput, GPIO_GetIn(tmpCmd.au1Data[0]+400), 0, 0);}
	}
#endif	

#if SUPPORT_ERROR_LED_CTRL    
    else if(tmpCmd.u1Cmd == Cmd_SetClearErrCode)
    {
        #if UART_DBG
        LogS("Cmd_SetClearErrCode");
        #endif
        gErrCodeCtrl.fgErrCodeLedType = tmpCmd.u1SubCmd;
        /*
                For PWM , it is LED_PWM number 0/1/2/3/4/5
                For GPIO, it is GPIO number , no need to minus OPCTRL0 or SERVO0
            */
        if(gErrCodeCtrl.fgErrCodeLedType == 2)
        {
            gErrCodeCtrl.fgErrCodeLedGpioIdx = tmpCmd.au1Data[0];
        }
        else if(gErrCodeCtrl.fgErrCodeLedType == 1)
        {
            gErrCodeCtrl.fgErrCodeLedGpioIdx = tmpCmd.au1Data[0];
        }
        else
        {
            gErrCodeCtrl.fgErrCodeLedGpioIdx = tmpCmd.au1Data[0];
        }

        gErrCodeCtrl.fgErrCodeLedPolarity =  tmpCmd.au1Data[1];
        gErrCodeCtrl.fgErrCodeLedPeriod =  tmpCmd.au1Data[2];
        gErrCodeCtrl.fgErrCodeLedInterval =  tmpCmd.au1Data[3];
/*
        if(gErrCodeCtrl.fgErrCodeLedInterval > gErrCodeCtrl.fgErrCodeLedPeriod)
        {
            gErrCodeCtrl.fgErrCodeLedInterval -= gErrCodeCtrl.fgErrCodeLedPeriod;        
        }
*/        
        #if UART_DBG
        LogSB("set fgErrCodeLedType", gErrCodeCtrl.fgErrCodeLedType);
        LogSW("set fgErrCodeLedGpioIdx", gErrCodeCtrl.fgErrCodeLedGpioIdx);
        LogSB("set fgErrCodeLedPolarity", gErrCodeCtrl.fgErrCodeLedPolarity);
        LogSB("set fgErrCodeLedPeriod", gErrCodeCtrl.fgErrCodeLedPeriod);                
        LogSB("set fgErrCodeLedInterval", gErrCodeCtrl.fgErrCodeLedInterval);                                
        #endif
        vCMD_RESONSE(Cmd_SetClearErrCode, 0, 0, 0);
    }
    else if(tmpCmd.u1Cmd == Cmd_EnableDisableErrCode)
    {
        gErrCodeCtrl.fgErrCodeBlinkingTime = tmpCmd.u1SubCmd;
		gErrCodeCtrl.fgSonyErrLedStateMachine = SONY_ERROR_CODE_STATE_INIT;   
        vSonyErrCodeLedReset();                
//        SetCtrlLedEnable();        
        #if UART_DBG
        LogSB("set fgErrCodeLedType", gErrCodeCtrl.fgErrCodeLedType);
        LogSW("set fgErrCodeLedGpioIdx", gErrCodeCtrl.fgErrCodeLedGpioIdx);
        LogSB("set fgErrCodeLedPolarity", gErrCodeCtrl.fgErrCodeLedPolarity);
        LogSB("set fgErrCodeLedPeriod", gErrCodeCtrl.fgErrCodeLedPeriod);                
        LogSB("set fgErrCodeLedInterval", gErrCodeCtrl.fgErrCodeLedInterval);                                
        LogSB("Cmd_EnableDisableErrCode", gErrCodeCtrl.fgErrCodeBlinkingTime );
        #endif        
        vCMD_RESONSE(Cmd_EnableDisableErrCode, 0, 0, 0);
    }
#endif 

#if DISABLE_WAKEUP_SOMETIME
	else if(tmpCmd.u1Cmd == Cmd_SetDisableWakeupTime)
	{
		gDelayWakeupCtrl.u1DelayTimeCnt = tmpCmd.u1SubCmd;
		gDelayWakeupCtrl.u1Enable = (gDelayWakeupCtrl.u1DelayTimeCnt) ? 1 : 0;		
		gDelayWakeupCtrl.u1WakeupEnReg0 = tmpCmd.au1Data[0];
		gDelayWakeupCtrl.u1WakeupEnReg1 = tmpCmd.au1Data[1];
		gDelayWakeupCtrl.u1WakeupEnReg2 = tmpCmd.au1Data[2];
		gDelayWakeupCtrl.u1WakeupEnReg3 = tmpCmd.au1Data[3];		
		#if UART_DBG
		LogSB("Cmd_SetDisableWakeupTime", gDelayWakeupCtrl.u1DelayTimeCnt);
		#endif		  
		if(gDelayWakeupCtrl.u1Enable)
		{//ARM should be set PDWNC_WAKEN register as 0 before enter standby!
			if(gDelayWakeupCtrl.u1WakeupEnReg0 + gDelayWakeupCtrl.u1WakeupEnReg1 + gDelayWakeupCtrl.u1WakeupEnReg2 + gDelayWakeupCtrl.u1WakeupEnReg3)
			{
				vCMD_RESONSE(Cmd_SetDisableWakeupTime, 0, 0, 0);
			}
			else
			{
				//something wrong not respone!!
			}
		}
		else
		{
			vCMD_RESONSE(Cmd_SetDisableWakeupTime, 0, 0, 0);
		}
	}
#endif


#if SIR_TASK
	else if(tmpCmd.u1Cmd == Cmd_SetIRWakeupKEY)
	{
		gIRWakeupKeyList = tmpCmd.u1SubCmd;
		vCMD_RESONSE(Cmd_SetIRWakeupKEY, 0, 0, 0);
	}
#endif	
  
	#if SUSPEND_MODE
    else if(tmpCmd.u1Cmd == Cmd_EnterSuspend)
    {
	#if UART_DBG
        LogS("EnterSuspend");
	#endif		
		PreStandbySta = tmpCmd.u1SubCmd;
		GoingSupend = SUSPEND_STAGE1;
		SuspendTimer = tmpCmd.au1Data[3];

		u1SleepStatus = SLEEP_SUSPEND_STATE;
		//vSetTimer(SUSPEND_MODE_TIMER_ID,tmpCmd.au1Data[0]);
        //vCMD_RESONSE(Cmd_EnterSuspend, 0, 0, 0); //entery suspend mode without ack
        #if UART_TASK		
		vRS232CustTaskStandby();
        #endif
		_u1SmPcb = tmpCmd.au1Data[2];
		vCMD_RESONSE(Cmd_EnterSuspend, 0, 0, 0);
    }
	#endif
	#if defined(CC_MT5891)||defined(CC_MT5893) || defined(CC_MT5895)
	else if(tmpCmd.u1Cmd == Cmd_EnterDramSelfRefresh)
	{
		#if UART_DBG
		LogS("EnterDramSelfRefresh......");
		#endif		
		vWdtEnterDramSelfRefresh();
	}
	#endif
    else if(tmpCmd.u1Cmd == Cmd_EnterPowerDown)//the only one command without response to ARM
    {
        #if UART_DBG
            LogS("EnterStandby");
        #endif        
		#if SUSPEND_MODE		
		if(GoingSupend)
		{
			#if UART_DBG
			LogS("Error:already call entery suspend mode");
			#endif
			PreStandbySta = tmpCmd.u1SubCmd;
		}
		else
		#endif
		{
			MSET_SYS_PRE_STANDBY_STATUS(tmpCmd.u1SubCmd);
			u1SleepStatus = SLEEP_STANDBY_STATE;
			if(tmpCmd.au1Data[2] == 1)
			{
				//Muffin Dram power is control by GPIO ,not PMIC
				//vDrvPMIC_B4_Standby();
			}
			vEnterPowerStandby();
		}
		#if UART_TASK
		vRS232CustTaskStandby();
		#endif
    }
    else if(tmpCmd.u1Cmd == Cmd_EnterPowerNormal)
    {
        if(tmpCmd.u1SubCmd == Cmd_Sub_PowerStage_loader)
        {
            #if CEC_log
                LogS("Loader mode \n");
            #endif	
            MSET_SYS_STATE(LOADER_STATE);
#if DRAM_RESET_GPIO_CTRL
			_u1DramRestGpio = tmpCmd.au1Data[0];
			_u1DramRestOnce = 0;
#endif
        }
        else if(tmpCmd.u1SubCmd==Cmd_Sub_PowerStage_normal)
        {
            #if CEC_log
            LogS("Normal mode \n");
            #endif	
            MSET_SYS_STATE(NORMAL_POWER_STATE);
#if IR_TASK
#if QUERY_IR_POWER_KEY_STATE_SUPPORT
            gSIRC_ctrl._gu1ARM_IR_WORKING = 1;
#endif
            vIO32Write4B(PDWNC_T8032_INTEN,(u4IO32Read4B(PDWNC_T8032_INTEN)&(0x0000C000)));
            vIO32WriteFldAlign(PDWNC_IRCLR, 0x1, FLD_IRCLR);
#endif
        }
/*        
        #if T8032_OCCUPIED_UART0_AT_NORMAL_POWER        
            vCMD_RESONSE(Cmd_EnterPowerNormal, 0, 0, 1);
        #else
            vCMD_RESONSE(Cmd_EnterPowerNormal, 0, 0, 0);
        #endif
        vWakeUpSystemTasks();
*/
        vWakeUpSystemTasks();        
#if UART_TASK		
		vRS232CustTaskWakeup();
#endif
		#if SUSPEND_MODE
		GoingSupend = SUSPEND_STAGE0;
		#endif
        vRegWrite1B(PDWNC_BCR, u1RegRead1B(PDWNC_BCR)|0xC0); //flush RX/TX buffer;        
        //MUART_FLUSH_TX_BUF();
        //MUART_FLUSH_RX_BUF();
        #if T8032_OCCUPIED_UART0_AT_NORMAL_POWER        
            vCMD_RESONSE(Cmd_EnterPowerNormal, 0, 0, 1);
        #else
            #if UART_DBG    
                    LogS("SWITCH_ARM");
            #endif         
            vCMD_RESONSE(Cmd_EnterPowerNormal, 0, 0, 0);
        #endif        
    }
    else if(tmpCmd.u1Cmd == Cmd_QuerySwVersion)
    {
            #if UART_DBG
                LogSB("QuerySWversion", FW_VERSION);
            #endif   
            
        vCMD_RESONSE(Cmd_QuerySwVersion, FW_VERSION, 0, 0);
    }
    else if(tmpCmd.u1Cmd == Cmd_EnterXdataSwitch)
    {
        #if UART_DBG
                LogS("xdata :ARM");
            #endif       
//        MSET_XDATA_SWITCH_REQ_FLAG(NEW_EVENT);
        MDisableINT();//disable all interrupt
        EWDI = 0; //disable watch dog interrupt
//        EWT = 0;//disable watch dog reset

        vCMD_RESONSE(Cmd_EnterXdataSwitch, 0, 0, 0);//While arm get this respond, xdata will be switched to ARM right away
        while(MARM_CONTROL_XDATA()); //trap here until arm return access right of xdata
        MEnableINT();
        EWDI = 1; //restore watch dog interrupt
        #if UART_DBG
                LogS("xdata: uP");
        #endif       
        
    }    
#if RC56_IR_DRIVER
    else if(tmpCmd.u1Cmd == Cmd_SetClrIR_FILTER)
    {
        if(tmpCmd.u1SubCmd == Cmd_Sub_SetIR_FilterSysCode)
        {
            gLPIR.fgIR_FilterFlag = XferToColorCfg(tmpCmd.au1Data[0]);//			fgIR_FilterFlag |= XferToColorCfg((UINT8)(u4DataFromARM & 0x000000ff));
            #if UART_DBG
            LogSB("SetColor",GetColorIdx(gLPIR.fgIR_FilterFlag));            
            #endif
        }
        else if(tmpCmd.u1SubCmd==Cmd_Sub_ClrIR_FilterSysCode)
        {
            gLPIR.fgIR_FilterFlag=IR_BLUE_CFG;
#if UART_DBG
            LogS("ClrColor");            
#endif
            
        }
        vCMD_RESONSE(Cmd_SetClrIR_FILTER, 0, 0, 0);
     }
#endif    
    else if(tmpCmd.u1Cmd == Cmd_SetLightGuideLevel)
    {
    }  
    else if(tmpCmd.u1Cmd == Cmd_AliveCheck)
    {

    }
    else if(tmpCmd.u1Cmd == Cmd_SetClearErrCode)
    {

    }
    else if(tmpCmd.u1Cmd == Cmd_EnableDisableErrCode)
    {

    }
#if SUSPEND_MODE
#ifdef CONSOLELOCK_MODE
    else if(tmpCmd.u1Cmd == Cmd_ConsoleLockQuery)
    {
        if(ConsoleLockMode == 0x4C)
        {
            #if UART_DBG
            LogS("UART XXXConsole");
            #endif
            vCMD_RESONSE(Cmd_ConsoleLockQuery, 0, 0, Cmd_Sub_ConsoleLockOn);
        }
        else
        {
            #if UART_DBG
            LogS("UART OOO Console");
            #endif
            vCMD_RESONSE(Cmd_ConsoleLockQuery, 0, 0, Cmd_Sub_ConsoleLockOff);
        }
    }
    else if(tmpCmd.u1Cmd == Cmd_ConsoleLockSet)
    {
        if(tmpCmd.u1SubCmd == Cmd_Sub_ConsoleLockOn)
        {
            ConsoleLockMode = 0x4C;
            #if UART_DBG
            LogS("T8032EnableConsole");            
            #endif
        }
        else if(tmpCmd.u1SubCmd==Cmd_Sub_ConsoleLockOff)
        {
            ConsoleLockMode = 0x00;
            #if UART_DBG
            LogS("T8032DisableConsole");            
            #endif         
        }
        vCMD_RESONSE(Cmd_ConsoleLockSet, 0, 0, 0);    
    }
    else if(tmpCmd.u1Cmd == Cmd_IceModeQuery)
    {
        if(ICEMode == 0xA)
        {
            vCMD_RESONSE(Cmd_IceModeQuery, 0, 0, 0xA);
        }
        else
        {
            vCMD_RESONSE(Cmd_IceModeQuery, 0, 0, 0x0);
        }
    }
    else if(tmpCmd.u1Cmd == Cmd_IceModeSet)
    {
        if(tmpCmd.u1SubCmd == 0x1)
        {
            ICEMode = 0xA;
            #if UART_DBG
            LogS("T8032EnableICEMode");            
            #endif
        }
        else if(tmpCmd.u1SubCmd == 0x0)
        {
            ICEMode = 0x0;
            #if UART_DBG
            LogS("T8032DisableICEmode");            
            #endif
        }
        vCMD_RESONSE(Cmd_IceModeSet, 0, 0, 0);    
    }

#endif
#endif
#if CUST_AUTO_IRRC_WAKEUP
    else if (tmpCmd.u1Cmd == Cmd_NextWakeupTime)
    {
        uNextWakeupTimerOn = 0;
        u4NextWakeupTime = (tmpCmd.au1Data[0] | (tmpCmd.au1Data[1]<<8) | (tmpCmd.au1Data[2]<<16) | (tmpCmd.au1Data[3]<<24));

        if (u4NextWakeupTime != 0)
        {
            vSetTimer(NEXT_WAKEUP_TIME_TIMER_ID, u4NextWakeupTime/20);
            u4NextWakeupTime = 0;
            uNextWakeupTimerOn = 1;
        }
        vCMD_RESONSE(Cmd_NextWakeupTime, 0, 0, 0);
    }
#endif
    //#if ENABLE_CBUS
    else if(tmpCmd.u1Cmd == Cmd_Cbus_SetT8032CtlCbus)
    {
#if ENABLE_CBUS
        fgCbus8032Ctrl = tmpCmd.au1Data[0];
        fgCbus8032VbusCharge = tmpCmd.au1Data[1];
        fgCbus8032VbusMhlSequence = tmpCmd.au1Data[2];
        fgCbus8032VbusSonyDongle = tmpCmd.au1Data[3];
#endif
         vCMD_RESONSE(Cmd_ResponseCbus_SetT8032CtlCbus, 0, 0, 0);
    }
    else if(tmpCmd.u1Cmd == Cmd_Cbus_SetT8032CtlActiveStd)
    {
        #if ENABLE_CBUS
        fgCbus8032ActiveStandby = tmpCmd.au1Data[0];
        #endif
        vCMD_RESONSE(Cmd_Cbus_SetT8032CtlActiveStd, 0, 0, 0);
    }
    //#endif
#if ENABLE_CEC    
    else if(tmpCmd.u1Cmd == Cmd_CEC_MenuLanguage)
    {
        u1CecMenuLanguage[0] = tmpCmd.au1Data[3];
        u1CecMenuLanguage[1] = tmpCmd.au1Data[2];
        u1CecMenuLanguage[2] = tmpCmd.au1Data[1];
        #if UART_DBG
                LogS("CECMENU");
                Log4B(0x55, u1CecMenuLanguage[2] , u1CecMenuLanguage[1] , u1CecMenuLanguage[0] );
        #endif       
        
        CECMenuLanguageOK();
    }
    else if(tmpCmd.u1Cmd == Cmd_CEC_EnableCEC)
    {
        if(tmpCmd.au1Data[0] == 0 && tmpCmd.au1Data[1] == 0 && tmpCmd.au1Data[2] == 0 && tmpCmd.au1Data[3] == 0)
        {
            fgCecEnRx = 0;
        }
        else
        {
            fgCecEnRx = 1;
        }
        #if UART_DBG
                LogSB("set fgEnCEC", fgCecEnRx);
        #endif
        CECEnableCECOK();        
    }
    else if(tmpCmd.u1Cmd == Cmd_CEC_EnableOneTouch)
    {
        if(tmpCmd.au1Data[0] == 0 && tmpCmd.au1Data[1] == 0 && tmpCmd.au1Data[2] == 0 && tmpCmd.au1Data[3] == 0)
        {
            fgCecEnOneTouchPlay = 0;
        }
        else
        {
            fgCecEnOneTouchPlay = 1;
        }
        #if UART_DBG
                LogSB("set fgEnOneTouchPlay", fgCecEnOneTouchPlay);
        #endif

        CECEnableOneTouchPlayOK();
    }        
#endif    
    else if(tmpCmd.u1Cmd == Cmd_SetLEDBlink)
    {

    }
    else if(tmpCmd.u1Cmd == Cmd_SetFWUpgrate)
    {
        MSET_SYS_FW_UPGRADING(tmpCmd.u1SubCmd);
        vCMD_RESONSE(Cmd_SetFWUpgrate, 0, 0, 0);
    }
    else if(tmpCmd.u1Cmd == Cmd_SetBaudrate)
    {
        MSET_SYS_UART_BAUDRATE(tmpCmd.u1SubCmd);
        vCMD_RESONSE(Cmd_SetBaudrate, 0, 0, 0);
    }
#if SUPORT_COLD_REBOOT
    else if(tmpCmd.u1Cmd == Cmd_ColdReboot)
    {
        if(tmpCmd.u1SubCmd == 0)
        {//force set a timer
            vSetTimer(COLD_REBOOT_TIMER_ID, 1);
        }
        else
        {
            vSetTimer(COLD_REBOOT_TIMER_ID, tmpCmd.u1SubCmd);
        }
        u1ColdRebootChk = 1;
        vEnterPowerStandby();   
    }
#endif
#if CUS_SH_HOTEL_MODE 
    else if(tmpCmd.u1Cmd == PDWNC_CMD_ARMT8032_CUST_SH_CUSTDATA)
    {
        fgCust_SH_HotelModeUartWakeupEn = tmpCmd.u1SubCmd;    
        vCMD_RESONSE(PDWNC_CMD_ARMT8032_CUST_SH_CUSTDATA, 0, 0, 0);    
    }
#endif
    else if(tmpCmd.u1Cmd == Cmd_DigitKeyWakeup)
    {

    }
#if S_HOTEL_MODE_COMMAND
    else if(tmpCmd.u1Cmd == Cmd_SetCustData)
    {
		vSetToggleLedDisable();
		SYS_PrintString(1, "gLedToggleCtrl");
		SYS_PrintString_B(1, "u1SubCmd", tmpCmd.u1SubCmd);
		gLedToggleCtrl.u1LedType = ((tmpCmd.u1SubCmd) & 0x80) ? 1 : 0;
		SYS_PrintString_B(1, "u1LedType", gLedToggleCtrl.u1LedType);
		gLedToggleCtrl.u1LedPolarity = ((tmpCmd.u1SubCmd) & 0x40) ? 1 : 0;
		SYS_PrintString_B(1, "u1LedPolarity", gLedToggleCtrl.u1LedPolarity);
		if(gLedToggleCtrl.u1LedType)
		{
			gLedToggleCtrl.u2LedGpio  = ((tmpCmd.u1SubCmd) & 0x3f) + SERVO(0);
		}
		else
		{
			gLedToggleCtrl.u2LedGpio  = ((tmpCmd.u1SubCmd) & 0x3f) + OPCTRL(0);
		}
		SYS_PrintString_W(1, "u2LedGpio", gLedToggleCtrl.u2LedGpio);

		u1CustomData3_Module1ReplyData = ((tmpCmd.au1Data[0]) & 0x1) ? 1 : 0;
		u1Module2Enable = ((tmpCmd.au1Data[0]) & 0x2) ? 1 : 0;
		u1hotel_module2_init_mode = ((tmpCmd.au1Data[0]) & 0x4) ? 1 : 0;
		u1HotelDbg = ((tmpCmd.au1Data[0]) & 0x8) ? 1 : 0;
		u1CustomData1_HotelModule = (tmpCmd.au1Data[0] & 0xf0) >> 4;

		u1Module2AvSelectPW = tmpCmd.au1Data[1];
        u1Module2AvSelectSrc = tmpCmd.au1Data[3];
		u1Module2HdmiPortSel = tmpCmd.au1Data[2];

		vCMD_RESONSE(Cmd_SetCustData, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_GetCustData)
	{
		vCMD_RESONSE(Cmd_GetCustData, bModule2Status, 0, 0);
	}
#endif
	else if(tmpCmd.u1Cmd == Cmd_SetEcoMode)
	{
		#if UART_DBG
		LogS("ECO mode");
		#endif
		u1ECOModel = tmpCmd.u1SubCmd;
		vCMD_RESONSE(Cmd_SetEcoMode, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey1)
	{
		if(tmpCmd.u1SubCmd == 1)  //add 
		{
			SIR_KEY_POWER1 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER1 = 0x0000;  //delete
		}
		vCMD_RESONSE(Cmd_SetPowerKey1, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey2)
	{
		if(tmpCmd.u1SubCmd == 1)
		{
			SIR_KEY_POWER2 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER2 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey2, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey3)
	{
		if(tmpCmd.u1SubCmd == 1)
		{
			SIR_KEY_POWER3 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER3 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey3, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey4)
	{
		if(tmpCmd.u1SubCmd == 1)
		{
			SIR_KEY_POWER4 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER4 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey4, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey5)
	{
		if(tmpCmd.u1SubCmd == 1)
		{
			SIR_KEY_POWER5 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER5 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey5, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey6)
	{
		if(tmpCmd.u1SubCmd == 1)
		{
			SIR_KEY_POWER6 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER6 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey6, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey7)
	{
		if(tmpCmd.u1SubCmd == 1)
		{
			SIR_KEY_POWER7 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER7 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey7, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey8)
	{
		if(tmpCmd.u1SubCmd == 1)
		{
			SIR_KEY_POWER8 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER8 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey8, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey9)
	{
		if(tmpCmd.u1SubCmd == 1)
		{
			SIR_KEY_POWER9 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER9 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey9, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey10)
	{
		if(tmpCmd.u1SubCmd == 1)
		{
			SIR_KEY_POWER10 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER10 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey10, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey11)
	{
	    if(tmpCmd.u1SubCmd == 1)
	    {
			SIR_KEY_POWER11 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER11 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey11, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey12)
	{
	    if(tmpCmd.u1SubCmd == 1)
	    {
			SIR_KEY_POWER12 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER12 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey12, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey13)
	{
	    if(tmpCmd.u1SubCmd == 1)
	    {
			SIR_KEY_POWER13 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER13 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey13, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey14)
	{
	    if(tmpCmd.u1SubCmd == 1)
	    {
			SIR_KEY_POWER14 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER14 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey14, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey15)
	{
	    if(tmpCmd.u1SubCmd == 1)
	    {
			SIR_KEY_POWER15 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER15 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey15, 0, 0, 0);
	}
	else if(tmpCmd.u1Cmd == Cmd_SetPowerKey16)
	{
	    if(tmpCmd.u1SubCmd == 1)
	    {
			SIR_KEY_POWER16 = (UINT32)((((UINT32)(tmpCmd.au1Data[2]))<<16)|(((UINT32)(tmpCmd.au1Data[1]))<<8)|(((UINT32)(tmpCmd.au1Data[0]))));// max 20bit
		}
		else
		{
			SIR_KEY_POWER16 = 0x0000;
		}
		vCMD_RESONSE(Cmd_SetPowerKey16, 0, 0, 0);
	}

    else if(tmpCmd.u1Cmd == Cmd_QueryServiceMode)
    {

    }
#if ENABLE_CEC    
    else if(tmpCmd.u1Cmd == Cmd_CEC_SupportUserControlPressed)
    {

    }
    else if(tmpCmd.u1Cmd == Cmd_CEC_SetVendorID)
    {
        #if UART_DBG
                LogS("Cmd_CEC_SetVendorID");
        #endif         
        u1CecVendorID[0] = tmpCmd.au1Data[0];
        u1CecVendorID[1] = tmpCmd.au1Data[1];
        u1CecVendorID[2] = tmpCmd.au1Data[2];
        CECSetVendorIDOK();
    }
    else if(tmpCmd.u1Cmd == Cmd_CEC_SetVersion)
    {
        #if UART_DBG
                LogS("Cmd_CEC_SetVersion");
        #endif         

        u1CecVersion = tmpCmd.au1Data[0]; 
        CECSetVersionOK();
    }
    else if(tmpCmd.u1Cmd == Cmd_CEC_SetT8032CtlCEC)
    {
         fgCec8032Ctrl = tmpCmd.au1Data[0];
         CECT8032CtlCECOK();
    }     
 #endif

 #ifdef CEC_FEATURE_3_1     
    else if(tmpCmd.u1Cmd == Cmd_CEC_SetOSDName1)
    {
        _rCECOsdName.u1Size = tmpCmd.au1Data[0];
        _rCECOsdName.au1OsdName[0] = tmpCmd.au1Data[1];
        _rCECOsdName.au1OsdName[1] = tmpCmd.au1Data[2];
        _rCECOsdName.au1OsdName[2] = tmpCmd.au1Data[3];
         CECSetOSDName1OK();
    }
    else if(tmpCmd.u1Cmd == Cmd_CEC_SetOSDName2)
    {
        _rCECOsdName.au1OsdName[3] = tmpCmd.au1Data[0];
        _rCECOsdName.au1OsdName[4] = tmpCmd.au1Data[1];
        _rCECOsdName.au1OsdName[5] = tmpCmd.au1Data[2];
        _rCECOsdName.au1OsdName[6] = tmpCmd.au1Data[3];
         CECSetOSDName2OK();
    }
    else if(tmpCmd.u1Cmd == Cmd_CEC_SetOSDName3)
    {
        _rCECOsdName.au1OsdName[7] = tmpCmd.au1Data[0];
        _rCECOsdName.au1OsdName[8] = tmpCmd.au1Data[1];
        _rCECOsdName.au1OsdName[9] = tmpCmd.au1Data[2];
        _rCECOsdName.au1OsdName[10] = tmpCmd.au1Data[3];
         CECSetOSDName3OK();
    }
    else if(tmpCmd.u1Cmd == Cmd_CEC_SetOSDName4)
    {
        _rCECOsdName.au1OsdName[11] = tmpCmd.au1Data[0];
        _rCECOsdName.au1OsdName[12] = tmpCmd.au1Data[1];
        _rCECOsdName.au1OsdName[13] = tmpCmd.au1Data[2];
         CECSetOSDName4OK();

    }    
    else if(tmpCmd.u1Cmd == Cmd_CEC_SetWakeupOpCode1)
    {
        _rCECWkpOpCode.u1Size = tmpCmd.au1Data[0];
        _rCECWkpOpCode.au1WkpCode[0] =  tmpCmd.au1Data[1];
        _rCECWkpOpCode.au1WkpCode[1] =  tmpCmd.au1Data[2];
        _rCECWkpOpCode.au1WkpCode[2] =  tmpCmd.au1Data[3];
        CECSetWkpCode1OK();
    }
    else if(tmpCmd.u1Cmd == Cmd_CEC_SetWakeupOpCode2)
    {
        _rCECWkpOpCode.au1WkpCode[3] = tmpCmd.au1Data[0];
        _rCECWkpOpCode.au1WkpCode[4] = tmpCmd.au1Data[1];
        _rCECWkpOpCode.au1WkpCode[5] = tmpCmd.au1Data[2];
        _rCECWkpOpCode.au1WkpCode[6] = tmpCmd.au1Data[3];
        CECSetWkpCode2OK();
    }
    else if(tmpCmd.u1Cmd == Cmd_CEC_SetWakeupOpCode3)
    {
        _rCECWkpOpCode.au1WkpCode[7] = tmpCmd.au1Data[0];
        _rCECWkpOpCode.au1WkpCode[8] = tmpCmd.au1Data[1];
        _rCECWkpOpCode.au1WkpCode[9] = tmpCmd.au1Data[2];
        _rCECWkpOpCode.au1WkpCode[10] = tmpCmd.au1Data[3];
        CECSetWkpCode3OK();
    } 
#endif    
    else if(tmpCmd.u1Cmd == Cmd_OtherEngineSwitch)
    {
        vCMD_RESONSE(Cmd_OtherEngineSwitch, 0, 0, 0);
    } 
#if SIR_TASK
#if QUERY_IR_POWER_KEY_STATE_SUPPORT	
    else if(tmpCmd.u1Cmd == Cmd_QueryIRPowerKeyState)
    {
	    gSIRC_ctrl._gu1ARM_IR_WORKING = 1;
		MIR_DIS_INT();//disable IR interrupt
		vCMD_RESONSE(Cmd_QueryIRPowerKeyState, bGetTimer(SIR_LONG_PRESSING_CHK_TIMER_ID), 0, 0);
    }
#endif
    else if(tmpCmd.u1Cmd == Cmd_GetIrWakeupValue)//
    {
	    vCMD_RESONSE(Cmd_GetIrWakeupValue, 0xFF, 0, 0);
    }
    else if(tmpCmd.u1Cmd == Cmd_EnableWRGBLed)
    {
		uWhiteLedDuty = tmpCmd.au1Data[0];
		uRedLedDuty   = tmpCmd.au1Data[1];
		uGreenLedDuty = tmpCmd.au1Data[2];
		uBlueLedDuty  = tmpCmd.au1Data[3];
		vCMD_RESONSE(Cmd_EnableWRGBLed, 0, 0, 0);
    }
	else if(tmpCmd.u1Cmd == Cmd_ResponseCbus_SetT8032CtlMhlPullDown)
	{
	    if(tmpCmd.u1SubCmd == Cmd_ResponseCbus_enable_pulldown)
	    {
	    	#if ENABLE_CBUS
	      Cbus8032GetHDMI2KModel = 0x55;
	      #endif
	      vCMD_RESONSE(Cmd_ResponseCbus_SetT8032CtlMhlPullDown, 0, 0, Cmd_ResponseCbus_enable_pulldown);
	    }
		else
		{
			#if ENABLE_CBUS
                  Cbus8032GetHDMI2KModel = 0x00;
      #endif
		  vCMD_RESONSE(Cmd_ResponseCbus_SetT8032CtlMhlPullDown, 0, 0, 0);
		}
	}
#endif
/*    
    else if(tmpCmd.u1Cmd == Cmd_QueryIRPowerKeyState)
    {

    }
*/    
    else
    {
#if UART_DBG
                LogSB("Not support command",  tmpCmd.u1Cmd);
#endif
    }
    
}
