/**
 * @file drv_hdmi_inc.h
 * @brief HDMI RX driver layer interface.
 * @verbatim
 * ==============================================================================
 *                        ##### How to use this driver #####
 * ==============================================================================
 * (+) Use HS_HAL_WDT_Start(...) to start the wdt immediately.
 * (+) Use HS_HAL_WDT_Stop(...) to stop the wdt immediately.
 * (+) Use HS_HAL_WDT_Feed(...) to feed the watchdog and it will restart the counter immediately. 
 * @endverbatim
 *
 * @author HiView SoC Software Team
 * @version 0.0.1
 * @date 2022-08-22
 */
#ifndef __HV_DRV_HDMIINC_H__
#define __HV_DRV_HDMIINC_H__

#include "Common/hv_comm_DataType.h"
#include "hv_cal_HdmiRx.h"

#define CEC_ACTIVE_SOURCE                  0x82 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_IMAGE_VIEW_ON                  0x04 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_TEXT_VIEW_ON                   0x0d /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_REQUEST_ACTIVE_SOURCE          0x85 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_STANDBY                        0x36 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_GIVE_PHYSICAL_ADDRESS          0x83 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_GET_MENU_LANGUAGE              0x91 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_REPORT_PHYSICAL_ADDRESS        0x84 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_SET_MENU_LANGUAGE              0x32 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_DEVICE_VENDOR_ID               0x87 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_GIVE_DEVICE_VENDOR_ID          0x8c /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_VENDOR_COMMAND                 0x89 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_VENDOR_RC_BUTTON_DOWN          0x8a /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_VENDOR_RC_BUTTON_UP            0x8b /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_SET_OSD_STRING                 0x64 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_GIVE_OSD_NAME                  0x46 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_SET_OSD_NAME                   0x47 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_MENU_REQUEST                   0x8d /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_MENU_STATUS                    0x8e /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_USER_CONTROL_PRESSED           0x44 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_USER_CONTROL_RELEASED          0x45 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_GIVE_DEVICE_POWER_STATUS       0x8f /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_REPORT_POWER_STATUS            0x90 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_FEATURE_ABORT                  0x00 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_RECORD_OFF                     0x0b /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_RECORD_ON                      0x09 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_RECORD_STATUS                  0x0a /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_RECORD_TV_SCREEN               0x0f /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_SELECT_DIGITAL_SOURCE          0x93 /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_INACTIVE_SOURCE                0x9D /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_VERSION                        0x9E /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_GET_VERSION                    0x9F /*!< CEC command ID. Please refer to the HDMI spec. */
#define CEC_INITIATE_ARC                   0xC0
#define CEC_REPORT_ARC_INITIATED           0xC1
#define CEC_ABORT_TEST                     0xff /*!< CEC command ID. Please refer to the HDMI spec. */

#define CEC_CMD_NULL                       0x00
#define CEC_PWR_ON                         0x01 
#define CEC_PWR_OFF                        0x02 
#define CEC_PWR_ONOFF                      0x03

#define CEC_USER_CTRL_POWER                0x40 /*!< Power command of CEC user control. */
#if 0
typedef enum _CEC_COMMAND
{
	eFeatureAbort			=0x00,

// One Touch Play Feature
	eActiveSource			=0x82,	// follower:TV, switch	--> Broadcst , Directly address
	eImageViewOn			=0x04,	// follower:TV, switch	--> Broadcst
	eTextViewOn			=0x0D,	// follower:TV

// Routing Control Feature
	eRoutingChange			=0x80,	// follower:TV, switch	--> Broadcst
	eRoutingInformation		=0x81,	// follower:switch		--> Broadcst
	eRequestActiveSource	=0x85,	// follower:switch		--> Broadcst 	, AVR to request active source when Audio ocntrol feature is active
	eSetStreamPath			=0x86,	// follower:switch		--> Broadcst
	eInactiveSource			=0x9D,	//
	eStandBy				=0x36,	// follower:All			--> Broadcst

// One Touch Record Feature
	eRecordOff				=0x0B,
	eRecordOn				=0x09,
	eRecordStatus			=0x0A,
	eRecordTVScreen		=0x0F,

// Timer Programming Feature
	eClearAnalogueTimer	=0x33,
	eClearDigitalTimer		=0x99,
	eClearExternalTimer		=0xA1,
	eSetAnalogueTimer		=0x34,
	eSetDigitalTimer			=0x97,
	eSetExternalTimer		=0xA2,
	eSetTimerProgramTitle	=0x67,
	eTimerClearedStatus		=0x43,
	eTimerStatus			=0x35,

// System Information Feature
	eCECVersioin			=0x9E,
	eGetCECVersion			=0x9F,
	eGivePhysicalAddress	=0x83,	// follower:All
	eGetMenuLanguage		=0x91,	// follower:TV
	eReportPhysicalAddress	=0x84,	// follower:TV
	eSetMenuLanguage		=0x32,	// follower:All,		Initiator:TV
	eReportFeatures			=0xA6,
	eGiveFeatures			=0xA5,

// Deck Control Feature
	eDeckControl			=0x42,
	eDeckStatus				=0x1B,
	eGiveDeckStatus			=0x1A,
	ePlay					=0x41,

// Tuner Control Featuer
	eGiveTunerDeviceStatus	=0x08,
	eSelectAnalogueService	=0x92,
	eSelectDigitalService		=0x93,
	eTunerDeviceStatus		=0x07,
	eTunerStepDecrement	=0x06,
	eTunerStepIncrement	=0x05,

// Vendor Specific Commands Feature
	eDeviceVendorID		=0x87,
	eGiveDeviceVendorID	=0x8C,
	eVendorCommand		=0x89,
	eGiveDevicePowerStatus	=0x8F,
	eReportPowerStatus		=0x90,
	eVendorCommandWithID =0xA0,
	eRemoteButtonDown		=0x8A,
	eRemoteButtonUp		=0x8B,

// OSD Display Feature
	eSetOSDString			=0x64,

// Device OSD Transfer Feature
	eGiveOSDName			=0x46,
	eSetOSDName			=0x47,

// Device Menu Control Feature
	eMenuRequest			=0x8D,
	eMenuStatus				=0x8E,
	eUserControlPressed		=0x44,
	eUserControlReleased	=0x45,

// System Audio Control Feature
	eSystemAudioModeRequest	=0x70,
	eGiveAudioStatus		=0x71,
	eSetSystemAudioMode	=0x72,
	eReportAudioStatus		=0x7A,
	eGiveSystemAudioModeStatus	=0x7D,
	eSystemAudioModeStatus		=0x7E,
	eReportAudioDescriptor 	=0xA3,
	eRequestAudioDescriptor =0xA4,

// Audio Rate Control Feature
	eSetAudioRate			=0x9A,

// ACR
	eInitiateARC				=0xC0,
	eReportARCInitiated		=0xC1,
	eReportARCTerminated	=0xC2,
	eRequestARCInitiation	=0xC3,
	eRequestARCTermination	=0xC4,
	eTerminateARC			=0xC5,

// Dynamic Auto Lipsync Featuer
	eRequestCurrentLatency	=0xA7,
	eReportCurrentLatency	=0xA8,
// HEC
	eCDCMessage			=0xF8,

//Audio Format Feature
	eReportShortAudioDescription	= 0xA3 ,
	eRequestShortAudioDescription	= 0xA4 ,

// Polling Mesage
	ePollingMessage,

	eAbort					=0xff,

	eCECNone

} eCEC_CMD;
#endif

typedef enum{
    eCDCFeature = 0,
    eOTPFeature,
    eRoutingCtlFeature,
    eStandByFeature,
    eOTRFeature,
    eTimerProgFeature,
    eSysInfoFeature,
    eDeckCtrlFeature,
    eTunerCtrlFeature,
    eVenSpecCmdFeature,
    eOSDDisplayFeature,
    eDevOSDTransferFeature,
    eDevMenuCtrlFeature,
    eRemoteCtlPassthroughFeature,
    ePowerStatusFeature,
    eGeneralProtocolMessage,
    eSysAudioCtlFeature,
    eAudioRateCtrlFeature,
    eARCFeature,
    eDynAutoLipsyncFeature,
    eHECFeature,
    eAudioFormatFeature ,
    eNoneFeature
}CECOpCodeType;

typedef enum {
    eCecPowerStatusOn       = 0x00,
    eCecPowerStatusOff      = 0x01,
    eCecPowerStatusOnToOff  = 0x02,
    eCecPowerStatusOffToOn  = 0x03
}CECPowerStatus;

typedef enum {
    eSelect		= 0x00 ,
    eUp			= 0x01	,
    eDown		= 0x02	,
    eLeft		= 0x03 ,
    eRight		= 0x04 ,
    eRightUp	= 0x05 ,
    eRightDown	= 0x06 ,
    eLeftUp		= 0x07 ,
    eLeftDown	= 0x08 ,
    eRootMenu	= 0x09 ,
    eSetupMenu	= 0x0A ,
    eContentsMenu = 0x0B ,
    eFavoriteMenu = 0x0C ,
    eExit		= 0x0D ,
    eMediaTopMenu = 0x10 ,
    eMediaContentSensitiveMenu = 0x11 ,
    eNumberEntryMode = 0x1D ,
    eDot		= 0x2A ,
    eEnter		= 0x2B ,
    eClear		= 0x2C ,
    eNextFavorite = 0x2F ,
    eChannelUp	= 0x30 ,
    eChannelDown= 0x31 ,
    ePreViousChannel = 0x32 ,
    eSoundSelect= 0x33 ,
    eInputSelect= 0x34 ,
    eDisplayInformation = 0x35 ,
    eHelp		= 0x36,
    ePageUp		= 0x37,
    ePageDown	= 0x38,
    ePower 		= 0x40,
    eVolumeUp 	= 0x41 ,
    eVolumeDown = 0x42 ,
    eMute		= 0x43 ,
    ePlayCmd	= 0x44 ,
    eStop		= 0x45 ,
    ePause		= 0x46 ,
    eRecord		= 0x47 ,
    eRewind		= 0x48 ,
    eFastForward= 0x49 ,
    eEject		= 0x4A ,
    eForward	= 0x4B ,
    eBackward	= 0x4C ,
    eStopRecord = 0x4D ,
    ePauseRecord= 0x4E ,
    eAngle		= 0x50 ,
    eSubPicture = 0x51 ,
    eVideoOnDemand = 0x52 ,
    eElectronicProgramGuide = 0x53 ,
    etimerProgramming 		= 0x54 ,
    einitialConfiguration 	= 0x55 ,
    eSelectBroadcastType 	= 0x56 ,
    eSelectSoundPresentation = 0x57 ,
    ePlayFunction 	= 0x60 ,
    ePausePlayFunction 		= 0x61 ,
    eRecordFunction = 0x62 ,
    ePauseRecordFunction 	= 0x63 ,
    eStopFunction	= 0x64 ,
    eMuteFunction	= 0x65 ,
    eRestoreVolumnFunction 	= 0x66 ,
    eTuneFunction	= 0x67 ,
    eSelectMediaFunction 	= 0x68 ,
    eSelectAVInputFunction 	= 0x69 ,
    eSelectAudioInputFunction = 0x6A ,
    ePowerToggleFunction	= 0x6B ,
    ePowerOffFunction		= 0x6C ,
    ePowerOnFunction		= 0x6D ,
}CECUICmd;

typedef enum _CEC_Logic_DEVICE_ID_t
{
    DEVICE_ID_TV=0,
    DEVICE_ID_RECORDING1,		// 1
    DEVICE_ID_RECORDING2,		// 2
    DEVICE_ID_TUNER1,			// 3
    DEVICE_ID_PLAYBACK1,		// 4
    DEVICE_ID_AUDIO,			// 5
    DEVICE_ID_TUNER2,			// 6
    DEVICE_ID_TUNER3,			// 7
    DEVICE_ID_PLAYBACK2,		// 8
    DEVICE_ID_RECORDING3,		// 9
    DEVICE_ID_TUNER4,			// 10
    DEVICE_ID_PLAYBACK3,		// 11
    DEVICE_ID_RESERVED1,		// 12
    DEVICE_ID_RESERVED2,		// 13
    DEVICE_ID_FREEUSE,			// 14
    DEVICE_ID_BROADCAST,		// 15
    DEVICE_ID_MAX
} CEC_Logic_DEVICE_ID_t;

typedef struct 
{
    UCHAR8 ucHeader;
    UCHAR8 ucOPCode;
    UCHAR8 aucOperandBuf[14];
}SCecMsg;

typedef struct 
{
    UCHAR8 ucGet;
    UCHAR8 ucPut;
    UCHAR8 aucCmdBuf[DCEC_CMD_CACHE_NUM];
}SCecCmd;

typedef struct
{
    UCHAR8          ucDestinationLA;
    SCecCmd         stCecCmd;
    HV_VOS_QUEUE_S *pstCECMsgQueue;
}SCecControl;


#endif

