/* 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.
 *
 *****************************************************************************/


/**
 * @file HDMI customization file:
 *
 * @author josh.pan@mediatek.com
 */
#include "x_gpio.h"
#include "x_printf.h"

#include "hw_vdoin.h"
#include "hw_hdmi.h"
#include "hw_pdwnc.h"

#include "drv_hdmi.h"
#include "host9777_if.h"
#include "drv_video.h"
#include "drv_adcset.h"

#include "sv_const.h"
#include "source_table.h"


#define HDMI_GPIO_HPD0 (253)
#define HDMI_GPIO_HPD1 (221)
#define HDMI_GPIO_HPD2 (225)
#define HDMI_GPIO_HPD3 (229)

#define HDMI_GPIO_PWR0 (252)
#define HDMI_GPIO_PWR1 (222)
#define HDMI_GPIO_PWR2 (226)
#define HDMI_GPIO_PWR3 (259)

extern E_HDMI_SWITCH_NUM eActiveHdmiPort;
extern UINT8 u1GetCdsenseStatus(void);

extern UINT8 u1FlgHdmiMhlSrcChged;
#ifdef CC_SUPPORT_BOSTON_SWITCH
extern UINT8 u1CurrentSilRxPort;
#endif

//====================//
void vHDMIHPDHigh(E_HDMI_SWITCH_NUM eSwitch)
{ 
	vHdmiSetHpdStatus(eSwitch, 0);
       
	switch(eSwitch)
	{
#ifdef HDMI_GPIO_HPD0
		case HDMI_SWITCH_1:
			if(!u1GetCdsenseStatus())
			{
				GPIO_GetIn(HDMI_GPIO_HPD0);
			}
			break;
#endif
#ifdef HDMI_GPIO_HPD1			
		case HDMI_SWITCH_2:
			GPIO_SetOut(HDMI_GPIO_HPD1,0);
			break;
#endif
#ifdef HDMI_GPIO_HPD2
		case HDMI_SWITCH_3:
			GPIO_SetOut(HDMI_GPIO_HPD2,0);
			break;
#endif
#ifdef HDMI_GPIO_HPD3
		case HDMI_SWITCH_4:
			GPIO_SetOut(HDMI_GPIO_HPD3,0);
			break;
#endif			
		default: /* disable all */
			break;
	}
}

//====================//
void vHDMIHPDLow(E_HDMI_SWITCH_NUM eSwitch)
{
	INT32 i4Val = 1;
    vHdmiSetHpdStatus(eSwitch, 1);
       
	switch(eSwitch)
	{
#ifdef HDMI_GPIO_HPD0
		case HDMI_SWITCH_1:			
			if(!u1GetCdsenseStatus())
			{
				GPIO_SetOut(HDMI_GPIO_HPD0, 0);
			}
			break;
#endif			
#ifdef HDMI_GPIO_HPD1
		case HDMI_SWITCH_2:	
 			GPIO_SetOut(HDMI_GPIO_HPD1, i4Val);
			break;
#endif			
#ifdef HDMI_GPIO_HPD2
		case HDMI_SWITCH_3:		
 			GPIO_SetOut(HDMI_GPIO_HPD2, i4Val);
			break;
#endif			
#ifdef HDMI_GPIO_HPD3
		case HDMI_SWITCH_4:
 			GPIO_SetOut(HDMI_GPIO_HPD3, i4Val);
			break;
#endif			
		default: /* disable all */
			break;
	}
}

//====================//
UINT8 bHDMIPort5VStatus(E_HDMI_SWITCH_NUM ePort)
{
    UINT32 input = 0;

    if (u1IsHdmiHpdPulse(ePort) == 1)
    {
        // hpd pulse period
        return (input);
    }
#ifdef CC_SUPPORT_BOSTON_SWITCH
#ifdef CC_COMBINE_4K_2K	
 	if(u1GetHDMI2KModel())
	{   
#endif
#endif
	    switch(ePort)
	    {
#ifdef HDMI_GPIO_HPD0
	        case HDMI_SWITCH_1: 
				if(_bIsMhlDevice == 1)
				{
					input = 1;
					_bIsMhlDevice = 1;
				}
				else
				{
					_bIsMhlDevice = 0;
					input = GPIO_GetIn(HDMI_GPIO_PWR0); 				
				}
		        break;
#endif
#ifdef HDMI_GPIO_HPD1
	        case HDMI_SWITCH_2: 
		          input = GPIO_GetIn(HDMI_GPIO_PWR1);
		         break;
#endif
#ifdef HDMI_GPIO_HPD2
	        case HDMI_SWITCH_3: 
		          input = GPIO_GetIn(HDMI_GPIO_PWR2);
		         break;
#endif
#ifdef HDMI_GPIO_HPD3
	        case HDMI_SWITCH_4: 
		          input = GPIO_GetIn(HDMI_GPIO_PWR3);
		         break;
#endif
		  default:
		         break;
		}
#ifdef CC_SUPPORT_BOSTON_SWITCH
#ifdef CC_COMBINE_4K_2K	
 	}
	else
	{
		return 1;
	}
#endif
#endif
    return input;
}
#ifdef CC_COMBINE_4K_2K	
#ifdef CC_SUPPORT_BOSTON_SWITCH	
UINT8 bHDMISourceDetect5VStatus(E_HDMI_SWITCH_NUM ePort)
{
	UINT8 input = 0;
	if(u1GetHDMI2KModel())
	{ 
		input = bHDMIPort5VStatus(ePort);
	}
	else
	{
		input = GetHdmi4KModelPort5VStatus(ePort - 1);	
	}
	return input;
}
#endif
#endif
//====================//
#ifdef CC_COMBINE_4K_2K	
#ifdef CC_SUPPORT_BOSTON_SWITCH				   
UINT8 fgSwitchInitFlag = 0;
#endif
#endif
void vHDMISwitchInit(void)
{   
#ifdef CC_SUPPORT_BOSTON_SWITCH
#ifdef CC_COMBINE_4K_2K	
	//fgSwitchInitFlag = 0;
	if(!u1GetHDMI2KModel())
	{
	  	Printf("switch init start ...........\n");
		vCreateSii9777Thread();
	  	Printf("switch init end ...........\n");
	}
#endif
#endif
}

//====================//
void vHDMISetSwitch(E_HDMI_SWITCH_NUM eSwitch)
{
    E_HDMI_SWITCH_NUM i = HDMI_SWITCH_INIT;
    E_HDMI_SWITCH_NUM eHdmiRx;
	UINT8 u1PwOnInit = 0;
#ifdef CC_COMBINE_4K_2K	

	  if(u1GetHDMI2KModel())
	  	{
	  	Printf("2k Model ...........\n");
      // port mapping here 
#endif
      switch(eSwitch)
      {
          case HDMI_SWITCH_1:
                   eHdmiRx = HDMI_SWITCH_1;
  		break;
  				
          case HDMI_SWITCH_2:
                   eHdmiRx = HDMI_SWITCH_2;
  	       break;

          case HDMI_SWITCH_3:
                   eHdmiRx = HDMI_SWITCH_3;
  	       break;

          case HDMI_SWITCH_4:
                   eHdmiRx = HDMI_SWITCH_4;
  	       break;
  	       
          default:
          	      eHdmiRx = eSwitch;
  		break;
      }
	  
#ifdef CC_COMBINE_4K_2K	
	  	}
	  else   //4k Model
	  	{
#ifdef CC_SUPPORT_BOSTON_SWITCH	  	
	  		UINT8 silPort = 0;
#endif			
			Printf("4k Model ...........\n");
	  		switch(eSwitch)
      		{
          case HDMI_SWITCH_1:
#ifdef CC_SUPPORT_BOSTON_SWITCH
                   eHdmiRx = HDMI_SWITCH_1;
				   silPort = 0;
				   if(fgSwitchInitFlag)
				   	{
					   u1HostSii9777RxPortSet(&silPort);
					   Printf("4k Model Boston Port rx0...........\n");
				   	}
				   else
				   	{
						Printf("Boston error, please check ...........\n");
				   	}	
#else
					eHdmiRx = HDMI_SWITCH_1;
#endif			
  			break;
  				
          case HDMI_SWITCH_2:
#ifdef CC_SUPPORT_BOSTON_SWITCH
                   eHdmiRx = HDMI_SWITCH_1;
				   silPort = 1;
				   if(fgSwitchInitFlag)
				   	{
					   u1HostSii9777RxPortSet(&silPort);
					   Printf("4k Model Boston Port rx1...........\n");
				   	}
				   else
				   	{
						Printf("Boston error, please check ...........\n");
				   	}	
#else
					eHdmiRx = HDMI_SWITCH_2;
#endif			
  			break;
          case HDMI_SWITCH_3:
#ifdef CC_SUPPORT_BOSTON_SWITCH

                   eHdmiRx = HDMI_SWITCH_1;
				   silPort = 2;
				  if(fgSwitchInitFlag)
				   {
					  u1HostSii9777RxPortSet(&silPort);
					  Printf("4k Model Boston Port rx2...........\n");
				   }
				  else
				   {
					   Printf("Boston error, please check ...........\n");
				   }	
#else
					eHdmiRx = HDMI_SWITCH_3;
#endif			
  	       break;

          case HDMI_SWITCH_4:
#ifdef CC_SUPPORT_BOSTON_SWITCH
                   eHdmiRx = HDMI_SWITCH_1;
				   silPort = 3;
				 if(fgSwitchInitFlag)
				  {
					 u1HostSii9777RxPortSet(&silPort);
					 Printf("4k Model Boston Port rx3...........\n");
				  }
				 else
				  {
					  Printf("Boston error, please check ...........\n");
				  } 
#else
					eHdmiRx = HDMI_SWITCH_4;
#endif			

  	       break;
  	       
          default:
          	      eHdmiRx = eSwitch;
  		break;
	  			}
#ifdef CC_SUPPORT_BOSTON_SWITCH
			u1CurrentSilRxPort = silPort;	
#endif
	  	}
#endif
    if (eHDMICurrSwitch == HDMI_SWITCH_INIT)       
	{          		
		u1PwOnInit = 1;              
	}	

#ifdef CC_COMBINE_4K_2K		
	if(u1GetHDMI2KModel())
	{
		if(((eActiveHdmiPort == HDMI_SWITCH_1) && (eHdmiRx != HDMI_SWITCH_1))
			|| ((eActiveHdmiPort != HDMI_SWITCH_1) && (eHdmiRx == HDMI_SWITCH_1)))
		{
			u1FlgHdmiMhlSrcChged = 1;//MHL -> HDMI ->MHL, set to 1
		}   
	}
#endif	    			
	if (eHDMICurrSwitch != eHdmiRx)
	{	
		eHDMICurrSwitch = eHdmiRx;
              eActiveHdmiPort = eHdmiRx;
		
              if (u1IsHdmiResStable(eActiveHdmiPort) && u1IsHdmiRxShared(eActiveHdmiPort) == 0)
              {
                  vSetHdmiFastSw(eActiveHdmiPort, 1);
              }
		else
		{
		    vSetHdmiFastSw(eActiveHdmiPort, 0);
		    if (u1PwOnInit == 0)
			{
				vHDMIHPDLow(eActiveHdmiPort);
			}

		}
		
              vHDMISel(eHdmiRx);

		// HPD high for unselected ports, support CEC feature.
		for ( i = HDMI_SWITCH_1 ; i <= HDMI_SWITCH_4 ; i++) 
		{
			if (i != eHdmiRx)
			{
				vHDMIHPDHigh(i);
			}
		}
		
		#if MUTE_TEMP
		vHDMIVideoOutOff();
		#endif
		
        if (u1IsHdmiFastSw(eActiveHdmiPort) == 0)
        {
            if (u1PwOnInit == 0)
			{
	      		vSetHdmiState(HDMI_STATE_INIT);
            }

        }
         else
        {
	      vSetHdmiState(HDMI_STATE_SCDT);
        }

	}
}
#ifdef CC_SUPPORT_BOSTON_SWITCH
#ifdef CC_COMBINE_4K_2K
void vHdmiSwitchCmdTest(UINT8 cmd, UINT32 value)
{
	switch(cmd)
	{
		
		case 101:
			Printf("siiPlatformInit() :%u\n",siiPlatformInit());
			break;
		case 102:
			vCreateSii9777Thread();
			break;
		case 103:
			{
				UINT8 port = value;
				u1HostSii9777RxPortSet(&port);
				Printf("set sii9777 rx port : %d\n",port);
			}
			break;
		case 104:
			{
				UINT8 port = value;
				u1HostSii9777RxPortGet(&port);
				Printf("Get sii9777 rx port : %d\n",port);
			}
			break;
		case 105:
			{
				UINT8 port = value;
				u1HostSii9777TxPortSet(&port);
				Printf("set sii9777 tx port : %d\n",port);
			}
			break;
		case 106:
			{
				UINT8 port = value;
				u1HostSii9777TxPortGet(&port);
				Printf("Get sii9777 tx port : %d\n",port);
			}
			break;
		case 107:
			{
				UINT8 port = ((value &0xf0)>>4);
				UINT8 hpdSet = value &0x0f;
				u1HostHpdSet(port,&hpdSet);
				Printf("sii9777 rx port%d  hpd set to %d\n",port,hpdSet);

			}
			break;
		case 108:
			{	
				
				UINT8 port = ((value &0xf0)>>4);
				UINT8 hpdSet = value &0x0f;
				u1HostHpdGet(port,&hpdSet);
				Printf("sii9777 rx port%d  hpd get is %d\n",port,hpdSet);
			}
			break;
		case 109:
			{
				UINT8 replicate = value;
				u1HostSii9777HpdReplicateSet(&replicate);
				Printf("Hpd replicated set to :%d\n",replicate);
			}
			break;
		case 110:
			{
				UINT8 replicate = value;
				u1HostSii9777HpdReplicateGet(&replicate);
				Printf("Hpd replicated Get is :%d\n",replicate);
			}
			break;
		case 111:
			{	
				UINT8 DualLinkAuto = value;
				u1HostSii9777DualLinkAutoSet(&DualLinkAuto);
				Printf("sii9777 dualLinkAutoSet :%d\n",DualLinkAuto);
			}
			break;
		case 112:
			{	
				UINT8 DualLinkAuto = value;
				u1HostSii9777DualLinkAutoGet(&DualLinkAuto);
				Printf("sii9777 dualLinkAutoGet :%d\n",DualLinkAuto);
			}
			break;
		case 113:
			{
				UINT8 splitMode = value;
				u1HostSii9777SplitModeSet(&splitMode);
				Printf("sii9777 splict mode set to  :%d\n",splitMode);	
			}
			
			break;
		case 114:
			{
				UINT8 splitMode = value;
				u1HostSii9777SplitModeGet(&splitMode);
				Printf("sii9777 splict mode Get is  :%d\n",splitMode);	
			}
			break;
		case 115:
			{
				UINT8 dualLink = value;
				u1HostSii9777DualLinkSet(&dualLink);
				Printf("sii9777 dualLink set to   :%d\n",dualLink);	
			}
			break;
		case 116:			
			{
				UINT8 dualLink = value;
				u1HostSii9777DualLinkGet(&dualLink);
				Printf("sii9777 dualLink Get  :%d\n",dualLink);	
			}
			break;
		case 117:
			{
				UINT32 version;
			    u1HostSii9777GetFirmwareVersion(&version);
				
				Printf("sii9777 version :%x\n",version);
			}
		break;
		case 118:
			{
				UINT8 edidReplicated = value;
				u1HostSii9777EdidReplicateSet(&edidReplicated);
				Printf("sii9777 edidReplicated set  :%d\n",edidReplicated);	
			}
			
			break;	
		case 119:
			{
				UINT8 edidReplicated = value;
				u1HostSii9777EdidReplicateGet(&edidReplicated);
				Printf("sii9777 edidReplicated get  :%d\n",edidReplicated);	
			}
			break;
		case 120:
			{
				extern UINT8 HDMIEDID_table[256];
				extern UINT8 HDMIEDID_CEC_192k_DeepColor12B_P0[256];
				UINT8 port = ((value &0xf0)>>4);
				if(value&0x0f)
				{
					u1HostSii9777EdidSet(port,HDMIEDID_table);
				}
				else
				{				
					u1HostSii9777EdidSet(port,HDMIEDID_CEC_192k_DeepColor12B_P0);
				}
				Printf("sii9777 edid set  \n");	
			}
			break;
		case 121:
			{
				UINT8 port = value;
				UINT32 i = 0;
				UINT8 edidGetArray[256];
				u1HostSii9777EdidGet(port,edidGetArray);
				Printf("sii9777 edid get  \n");
				Printf("\n");
				for(i=0;i<256;i++)
				{
					if(i && (i%16==0))
					{
						Printf("\n");
					}
					Printf("%x  ,",edidGetArray[i]);
				}
				Printf("\n");	
			}				
			break;
		case 122:
			{
				HostSii9777VideoTiming_t timingInfo;
				u1HostSii9777VideoTimingGet(&timingInfo);
				Printf("sii9777: get timing info\n");
				Printf("Htotal: %d\n",timingInfo.hTotal);
				Printf("hActive: %d\n",timingInfo.hActive);
				Printf("vTotal: %d\n",timingInfo.vTotal);
				Printf("vActive: %d\n",timingInfo.vActive);
				Printf("interlaced: %d\n",timingInfo.interlaced);
				Printf("hFrontPorch: %d\n",timingInfo.hFrontPorch);
				Printf("hSync: %d\n",timingInfo.hSync);
				Printf("pixelFreq: %d\n",timingInfo.pixelFreq);
				Printf("posHsync: %d\n",timingInfo.posHsync);
				Printf("posVsync: %d\n",timingInfo.posVsync);
				Printf("vFrontPorch: %d\n",timingInfo.vFrontPorch);
				Printf("vSync: %d\n",timingInfo.vSync);
			}
			break;
		case 123:
			{
				UINT32 productId;
				u1HostSii9777ProductIdStatusGet(&productId);
				Printf("sii9777 product ID: %x",productId);
				
			}
			break;
		case 124:
			{
				UINT8 chipVersion;
				u1HostSii9777ChipRevisionStatusGet(&chipVersion);
				Printf("sii9777 chip Revision: %x",chipVersion);
			}
			break;
		case 125:
			{
				UINT32 chipId;
				u1HostSii9777ChipIdStatusGet(&chipId);
				Printf("sii9777 chip ID: %x",chipId);
			}
			break;
		case 126:
			{
				UINT32 timpStampSta;
				u1HostSii9777FirmwareTimeStampStatusGet(&timpStampSta);					
				Printf("sii9777 time stamp: %d",timpStampSta);
			}
			break;
		case 127:
			{
				UINT8 bootStatus;
				u1HostSii9777BootStatusGet(&bootStatus);					
				Printf("sii9777 boot status: %d",bootStatus);
			}	
			break;
		case 128:
			{
				UINT8 avLinkSta;
				u1HostSii9777AvLinkStatusGet(&avLinkSta);					
				Printf("sii9777 avLinkSta: %d",avLinkSta);
			}
			break;
		case 129:
			{
				UINT8 hdcpStatus;
				u1HostSii9777HdcpStatusGet(&hdcpStatus);				
				Printf("sii9777 hdcpStatus: %d",hdcpStatus);
			}
			break;
		case 130:
			{
				UINT8 avMuteSta;
				u1HostSii9777AvMuteStatusGet(&avMuteSta);					
				Printf("sii9777 avMuteSta : %d",avMuteSta);
			}
			break;
		case 131:
			{
				UINT8 rx5VStatus;
				u1HostSii9777Plus5vStatusGet((UINT8)value,&rx5VStatus);					
				Printf("sii9777 port: %d , rx5VStatus : %d",value,rx5VStatus);
			}	
		break;
		case 132:
			{		
				UINT8 port = ((value &0xf0)>>4);
				UINT8 tmdsEnable = value &0x0f;
				u1HostSii9777TmdsEnableSet(port,&tmdsEnable);
				Printf("port: %d , tmdsEnable set:%d\n", port,tmdsEnable);
			}
			break;
		case 133:
			{
				
				UINT8 port = value;
				UINT8 tmdsEnable;
				u1HostSii9777TmdsEnableGet(port,&tmdsEnable);
				Printf("port: %d , tmdsEnable get:%d\n", port,tmdsEnable);
				
			}
			break;
		case 134:
			{
				HostSii9777VideoFormat_t host9777videofmtGet;
				UINT8 vdoValid;
				vdoValid = u1HostSii9777VideoFmtStatusGet(&host9777videofmtGet);
				Printf("9777 video format get: \n");
				if(vdoValid == 1)
				{
					Printf("videoVid : %d\n",host9777videofmtGet.videoVid);
					Printf("video3Dmode : %d\n",host9777videofmtGet.video3Dmode);
					Printf("lineNumEndOfTopBar : %d\n",host9777videofmtGet.vertBarInfo.lineNumEndOfTopBar);
					Printf("lineNumStartOfBottomBar : %d\n",host9777videofmtGet.vertBarInfo.lineNumStartOfBottomBar);
					Printf("horizBarInfo.pixNumEndOfLeftBar : %d\n",host9777videofmtGet.horizBarInfo.pixNumEndOfLeftBar);
					Printf("horizBarInfo.pixNumStartOfRightBar : %d\n",host9777videofmtGet.horizBarInfo.pixNumStartOfRightBar);
					Printf("scanInfo : %d\n",host9777videofmtGet.scanInfo);
					Printf("pixelRepetition : %d\n",host9777videofmtGet.pixelRepetition);
					Printf("pictureScaling : %d\n",host9777videofmtGet.pictureScaling);
					Printf("pictureAR : %d\n",host9777videofmtGet.pictureAR);
					Printf("isVertBarInfoValid : %d\n",host9777videofmtGet.isVertBarInfoValid);
					Printf("isHorizBarInfoValid : %d\n",host9777videofmtGet.isHorizBarInfoValid);
					Printf("isITcontent : %d\n",host9777videofmtGet.isITcontent);
					Printf("isActiveFmt : %d\n",host9777videofmtGet.isActiveFmt);
					Printf("colorSpace : %d\n",host9777videofmtGet.colorSpace);
					Printf("chromaSample : %d\n",host9777videofmtGet.chromaSample);
					Printf("bitDepth : %d\n",host9777videofmtGet.bitDepth);
					Printf("ActiveAR : %d\n",host9777videofmtGet.ActiveAR);
					Printf("contentType : %d\n",host9777videofmtGet.contentType);
				}
			}
		break;
		case 135:
			{
				UINT8 dualLinkStatus;
				u1HostSii9777DualLinkStatusGet(&dualLinkStatus);
				Printf("dualLinkStatus get: %d\n",dualLinkStatus);
			}
		break;
		case 136:
			{
				UINT8 swingLevel = 0;
				UINT8 txPort = value;
				u1Host9777TmdsSwingLevelGet(txPort,&swingLevel);
				Printf("tmsd Swing Level get,Port: %d  swing level: %d\n",value,swingLevel);	
			}
		break;		
		case 137:
			{
				UINT8 swingLevel = value;
				u1Host9777TmdsSwingLevelSet(2,&swingLevel);				
				u1Host9777TmdsSwingLevelSet(1,&swingLevel);
				Printf("\ntmsd Swing Level set,Port: 2  swing level: %d\n",swingLevel);			
				Printf("\ntmsd Swing Level set,Port: 1  swing level: %d\n",swingLevel);	
			}
		break;
		case 138:
			{
				UINT8 rxPort =value;
				UINT8 swapOn;
				u1Host9777TmdsPinSwapGet(rxPort,&swapOn);
				Printf("\ntmds Swap Pin get  port: %d, swap on:%d\n",rxPort,swapOn);					
			}
		break;
		case 139:
			{
				UINT8 rxPort =((value&0xf0)>>4);
				UINT8 swapOn = (value&0x0f);
				u1Host9777TmdsPinSwapSet(rxPort,&swapOn);
				Printf("\ntmds Swap Pin set  port: %d, swap on:%d\n",rxPort,swapOn);					
					
			}
		break;
		case 140:
			{
				UINT8 arcOn;
				u1Host9777ArcGet(&arcOn);
				Printf("\nswitch arc get:%d\n",arcOn);								
			}
		break;
		case 141:
			{
				UINT8 arcOn = value;
				u1Host9777ArcSet(&arcOn);
				Printf("\nswitch arc set:%d\n",arcOn);								
			}
		break;
		case 142:
			{
				SwitchBksv_t switchBksv;
				u1Host9777HdcpBksvRxidListGet(&switchBksv,5);
				Printf("\nbksv get:%x , %x, %x , %x , %x \n",switchBksv.bksv[0],switchBksv.bksv[1],switchBksv.bksv[2],switchBksv.bksv[3],switchBksv.bksv[4]);								
			}
		break;
		case 143:
			{
				SwitchBksv_t switchBksv;
				switchBksv.bksv[0] = 0x14;
				switchBksv.bksv[1] = 0x7c;
				switchBksv.bksv[2] = 0xe6;
				switchBksv.bksv[3] = 0x2c;
				switchBksv.bksv[4] = 0x37;
				u1Host9777HdcpBksvRxidListSet(&switchBksv,5);
				Printf("\nbksv get:%x , %x, %x , %x , %x \n",switchBksv.bksv[0],switchBksv.bksv[1],switchBksv.bksv[2],switchBksv.bksv[3],switchBksv.bksv[4]);								
			}
		break;
		case 144:
			{
				SwitchBksv_t switchBksv;
				switchBksv.bksv[0] = 0x24;
				switchBksv.bksv[1] = 0x7c;
				switchBksv.bksv[2] = 0xe6;
				switchBksv.bksv[3] = 0x2c;
				switchBksv.bksv[4] = 0x37;
				u1Host9777HdcpBksvRxidListSet(&switchBksv,5);
				Printf("\nbksv get:%x , %x, %x , %x , %x \n",switchBksv.bksv[0],switchBksv.bksv[1],switchBksv.bksv[2],switchBksv.bksv[3],switchBksv.bksv[4]);								
			}
		break;
		case 145:
			{
				SwitchBksv_t switchBksv;
				u1Host9777RxHdcpBksvOwnQuery(&switchBksv);	
				Printf("\nbksv get:%x , %x, %x , %x , %x \n",switchBksv.bksv[0],switchBksv.bksv[1],switchBksv.bksv[2],switchBksv.bksv[3],switchBksv.bksv[4]);								
			}
		break;
		case 146:
			{
				SwitchBksv_t switchBksv;
				u1Host9777RxHdcpRxIdOwnQuery(&switchBksv);	
				Printf("\nbksv get:%x , %x, %x , %x , %x \n",switchBksv.bksv[0],switchBksv.bksv[1],switchBksv.bksv[2],switchBksv.bksv[3],switchBksv.bksv[4]);								
			}
		break;
		case 147:
			{
				UINT8 cdsenseDectected = 0;
				u1Host9777RxCdSenseQuery(&cdsenseDectected);
				Printf("\n cdsenseDectected = %d\n",cdsenseDectected);
			}
		break;
		case 148:
			BostonfiwareSize = value;
			FirmwareUpdateRequest();
			Printf("\n firmware request update by command \n");
		break;
		case 149:
			u1Host9777CbusLocalDevcapSet(0xb,value);
			break;
		case 150:
			{
				UINT8 value[16];
				UINT8 i;
				u1Host9777CbusLocalDevcapGet(0,value,16);
				for(i=0;i<16;i++)
				{
					printf("value[%d]: %x \n",i,value[i]);
				}
			}
			break;
		case 151:
			u1Host9777CbusLocalXDevcapSet(0x2,value);
			break;
		case 152:
			{
				UINT8 value[4];
				UINT8 i;
				u1Host9777CbusLocalXDevcapGet(0,value,4);
				for(i=0;i<4;i++)
				{
					printf("value[%d]: %x \n",i,value[i]);
				}
			}
			break;
		case 153:
			printf("same:%d\n",checkEdidof9777IsSame());
			break;
		case 154:
			printf("version of file: %x\n",getFileVersionInfo());
			break;
		case 155:
			replaceFourPortEdidData();				
			printf("replace edid data in file\n");
			break;
		case 156:
			{
				UINT8 data[256];
				readEmmcBostonEdidData(data,value);
			}
		break;
		case 157:
			{
				extern UINT8 HDMIEDID_table[256];
				extern UINT8 HDMIEDID_CEC_192k_DeepColor12B_P0[256];
				writeEmmcBostonEdidData(HDMIEDID_CEC_192k_DeepColor12B_P0,value);
			}
		break;
		case 158:
			setEmmcEdidRequest();
			break;
		case 159:
			clearEmmcEdidRequest();
			break;
		case 160:
			{
				UINT8 u1HdmiPort = 1;
				for(u1HdmiPort = 1;u1HdmiPort<=4;u1HdmiPort++)
				{
					printf("bHDMISourceDetect5VStatus(%d) =%d",u1HdmiPort,bHDMISourceDetect5VStatus(u1HdmiPort));
				}
				break;
			}
		case 161:
			{
				
				extern void writeEmmcBostonData(UINT8 *data,UINT32 dataOffset,UINT32 length);
				UINT8 notToUpdateFw = value;
				writeEmmcBostonData(&notToUpdateFw,14,1);
				break;
			}
		case 162:
			{				
				extern void FirmwareUpdateRequestByfile(UINT8 haveHeader);
				extern UINT8 fgUseFileUpdate;
				UINT8 haveHeader = value;
				fgUseFileUpdate = 1;
				FirmwareUpdateRequestByfile(haveHeader);
				break;
			}
		default:
		break;
	}
}
#endif
#endif

void vHDMISetARCSwitch(UINT8 u1Port)
{
    return;
}

