/*******************************************************************************
*
* Copyright 2014, Silicon Image, Inc.  All rights reserved.
* No part of this work may be reproduced, modified, distributed, transmitted,
* transcribed, or translated into any language or computer format, in any form
* or by any means without written permission of
* Silicon Image, Inc., 1140 East Arques Avenue, Sunnyvale, California 94085
*
*******************************************************************************/
/**
* @file sii9777_rx_func.h
*
* @brief Host Driver for SiI9777 Rx device.
*
*******************************************************************************/

#ifndef SII9777_RX_FUNC_H
#define SII9777_RX_FUNC_H

#ifdef __cplusplus
extern "C"{
#endif

/*
General RETVAL codes
SII_RETVAL__SUCCESS	    0   Driver instance handle obtained by calling 
                            Sii9777Create.  API successfully completed.

SII_RETVAL__INST_ERR	1   Wrong or Invalid instance passed
SII_RETVAL__HOST_ERR	2   I2C / SPI host interface error
*/

/***** #include statements ****************************************************/

/***** public functions *******************************************************/

/******************************************************************************/
/**
*
* Erases the power-up default EDID configuration data.
* This function also sets the firmware image’s byte offset to 0.
*
* @param[in]  inst         Driver instance handle obtained by calling Sii9777Create.
*
* @retval     SiiRetVal_t  See general SII_RETVAL definitions in the beginning of the file.
*
*******************************************************************************/
SiiRetVal_t Sii9777EdidErase( SiiInst_t inst );

/******************************************************************************/
/**
* @brief Rx +5V status interrogation
*
* @param[in]  inst          Driver instance handle obtained by calling Sii9777Create.
* @param[in]  port          Input port:
*                           SII9777_RX_PORT__0
*                           SII9777_RX_PORT__1
*                           SII9777_RX_PORT__2
*                           SII9777_RX_PORT__3
*
* @param[out] pbPlus5v      Pointer to a boolean variable to copy RX +5V status,
*                           false  : No +5V signal. 
*                           true : +5V signal detected. 
*
* @retval SiiRetVal_t	    See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777Plus5vQuery( SiiInst_t inst, Sii9777RxPort_t port, bool_t *pbPlus5v );

/******************************************************************************/
/**
* @brief Active Input Select control
*
* Controls which Rx input is used for processing. 
* Only one input at the time can be selected as the active input.  
*
* @param[in]  inst    Driver instance handle obtained by calling Sii9777Create.
* @param[in]  pPort   Input port:
*                     SII9777_RX_PORT__0
*                     SII9777_RX_PORT__1
*                     SII9777_RX_PORT__2
*                     SII9777_RX_PORT__3
*
*
* @retval SiiRetVal_t See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777InputSelectSet( SiiInst_t inst, Sii9777RxPort_t* pPort );
SiiRetVal_t Sii9777InputSelectGet( SiiInst_t inst, Sii9777RxPort_t* pPort );

/******************************************************************************/
/**
* @brief Prevents upstream device from reading EDID.

* @param[in]  inst      Driver instance handle obtained by calling Sii9777Create.
* @param[in]  port      Input port:
*                       SII9777_RX_PORT__0
*                       SII9777_RX_PORT__1
*                       SII9777_RX_PORT__2
*                       SII9777_RX_PORT__3  
*
* @param[out] pbDdc     true  : Allow upstream device to read EDID.
*                       false : Prevent upstream device from reading EDID.
*
* @retval SiiRetVal_t   See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777EdidDdcSet( SiiInst_t inst, Sii9777RxPort_t port, bool_t* pbDdc );
SiiRetVal_t Sii9777EdidDdcGet( SiiInst_t inst, Sii9777RxPort_t port, bool_t* pbDdc );

/******************************************************************************/
/**
* @brief RX EDID replicate enable/disable control
*
* When enabled all input port EDID configurations will be replicated 
* based on down-stream device’s EDID connected to Primary output port. 
* Upstream hot-plug will only be toggled when input port EDID configuration is changed.
*
* @param[in]  inst  Driver instance handle obtained by calling Sii9777Create.
* @param[in]  bOn   true  : All input port EDID configuration are replicated 
*                           from down-stream device 
*                           connected to primary output port.
*                   false : All input EDID configuration are defined by user 
*					        application through Sii9777EdidSet.
*
* @retval   SiiRetVal_t	    See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777EdidReplicateEnableSet( SiiInst_t inst, bool_t* pbOn );
SiiRetVal_t Sii9777EdidReplicateEnableGet( SiiInst_t inst, bool_t* pbOn );

/******************************************************************************/
/**
* @brief Read/Write up-stream EDID-Rx 
*
* EDID configuration control. EDID configuration request is acknowledged 
* only if EDID replication is disabled.
* Note: Check-sum is recalculated after EDID data modification.  
*
* @param[in]  inst       Driver instance handle obtained by calling Sii9777Create.
* @param[in]  port       Input port:
*                        SII9777_RX_PORT__0
*                        SII9777_RX_PORT__1
*                        SII9777_RX_PORT__2
*                        SII9777_RX_PORT__3 
*
* @param[in]  offset     EDID offset pointer. Must be less than 256
* @param[out] pData      Pointer to local array of bytes.
* @param[in]  length     Length of requested EDID data transaction.
*
* @retval    SiiRetVal_t See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777EdidSet( SiiInst_t inst, Sii9777RxPort_t port, 
	               uint16_t offset, uint8_t *pData, uint16_t length );

SiiRetVal_t Sii9777EdidGet( SiiInst_t inst, Sii9777RxPort_t port, 
	                    uint16_t offset, uint8_t *pData, uint16_t length );

/******************************************************************************/
/**
* @brief Provides current applied EDID configuration.    
*
* @param[in]  inst       Driver instance handle obtained by calling Sii9777Create.
* @param[in]  port       Input port:
*                        SII9777_RX_PORT__0
*                        SII9777_RX_PORT__1
*                        SII9777_RX_PORT__2
*                        SII9777_RX_PORT__3 
*
* @param[in]  offset     EDID offset pointer. Must be less than 256
* @param[out] pData      Pointer to local array of bytes.
* @param[in]  length     Length of requested EDID data transaction.
*
* @retval    SiiRetVal_t See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777EdidQuery( SiiInst_t inst, Sii9777RxPort_t port, uint16_t offset, uint8_t *pData, uint16_t length );

/******************************************************************************/
/**
* @brief HPD replicate enable/disable control
*
* Replicates HPD’s low-level of down-stream device connected to primary 
* output port to HPD output signal of selected input port. 
* Up-stream HPD will only be released high 
* if user also has enabled upstream HPD through ‘Sii9777HpdSet?
*
* @param[in]  inst  Driver instance handle obtained by calling Sii9777Create.
*
* @param[in]  bOn   true  : HPD’s low-level of user selected input port 
*                           is replicated from down-stream device 
*                           connected to primary output port.
*                   false : HPD of user selected input port 
*                           is determined by user application 
*                           only through Sii9777EdidSet.
*
* @retval   SiiRetVal_t	    See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t	Sii9777HpdReplicateEnableSet( SiiInst_t inst, bool_t* pbOn );
SiiRetVal_t Sii9777HpdReplicateEnableGet( SiiInst_t inst, bool_t* pbOn );

/******************************************************************************/
/**
* @brief HPD user control 
*
* Controls the desired state of HPD signal of each input port.
* Note: After HPD is requested to go low the Sii9777 device will not allow 
* the HPD to go high for at least 500msec. even if user application requests 
* HPD to go back high within 500msec.
* Note: Sii9777 device also forces HPD signal to go low for at least 500msec 
* when user application calls Sii9777EdidSet() or Sii9777InputSelectSet(). 
* It is therefore recommended for the user to call this function first 
* to force HPD to go low before requesting (multiple) EDID modifications 
* followed by this function call to request HPD become high active again. 
* The system makes sure that HPD low time is at least 500ms 
* (the standard requires at least 100ms).  
*
* @param[in]  inst     Driver instance handle obtained by calling Sii9777Create.
* @param[in]  port     Input port:
*                      SII9777_RX_PORT__0
*                      SII9777_RX_PORT__1
*                      SII9777_RX_PORT__2
*                      SII9777_RX_PORT__3
*
* @param[in]  pbHpd    true  : Allow (release) Hot-Plug signal to go high.
*                      false : Forces Hot-Plug signal to go low unconditionally.
*
* @retval SiiRetVal_t  See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777HpdSet( SiiInst_t inst, Sii9777RxPort_t port, bool_t *pbHpd );
SiiRetVal_t Sii9777HpdGet( SiiInst_t inst, Sii9777RxPort_t port, bool_t *pbHpd );

/******************************************************************************/
/**
* @brief Rx HPD Interrogation function
*
* Provides current applied HPD level.   
*
* @param[in]  inst     Driver instance handle obtained by calling Sii9777Create.
* @param[in]  port     Input port:
*                      SII9777_RX_PORT__0
*                      SII9777_RX_PORT__1
*                      SII9777_RX_PORT__2
*                      SII9777_RX_PORT__3
*
* @param[in]  pbHpd    true  : Current HPD level is high
*                      false : Current HPD level is low
*
* @retval SiiRetVal_t  See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777HpdQuery( SiiInst_t inst, Sii9777RxPort_t port, bool_t *pbHpd );

/******************************************************************************/
/**
* @brief Rx AV Link status interrogation
*
* Returns the current Rx AV Link status.
*
* @param[in]  inst         Driver instance handle obtained by calling Sii9777Create.
* @param[out] pAvLink      Enumerator indicates any of the following states:
*                          SII9777_AV_LINK__NONE    No video
*                          SII9777_AV_LINK__DVI     DVI
*                          SII9777_AV_LINK__HDMI1   HDMI1.x
*                          SII9777_AV_LINK__HDMI2   HDMI2.x
*                          SII9777_AV_LINK__MHL     MHL1/2
*                          SII9777_AV_LINK__MHL3    MHL3
*
* @retval    SiiRetVal_t   See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777AvLinkQuery( SiiInst_t inst, Sii9777AvLink_t *pAvLink );

/******************************************************************************/
/**
* @brief Rx AV Mute status interrogation
*
* Returns the current Rx AV Mute status.
*
* @param[in]  inst           Driver instance handle obtained by calling Sii9777Create.
* @param[out] pbAvMute       true  : Input signal is AV Muted. 
*                            false : Input signal is not AV Muted.
*
* @retval SiiRetVal_t	     See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777AvMuteQuery( SiiInst_t inst, bool_t *pbAvMute );

/******************************************************************************/
/**
* @brief Rx Video timing interrogation
*
* Returns the current Rx Video timing.
*
* @param[in]  inst           Driver instance handle obtained by calling Sii9777Create.
* @param[out] pVideoTiming   Pointer to video timing structure.
*
* @retval     SiiRetVal_t    See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777VideoTimingQuery( SiiInst_t inst, Sii9777VideoTiming_t *pVideoTiming );

/******************************************************************************/
/**
* @brief Incoming video format interrogation
*
* Retrieve data structure representing incoming video format. 
* The structure is based on the following IF/Ps  :
* - AVI
* - HDMI VSIF
* - HDMI-Forum VSIF
* - MHL VSIF
*  - GBD (Gamut Boundary Packet)
* For DVI video, or if the measured data differs from the information in the received IF/Ps, 
* the driver provides the video format according to the measured data.
* Any detected format change generates a SII9777_EVENT__RX_VIDEO_FMT_CHNG notification.
*
* @param[in]  inst        Driver instance handle obtained by calling Sii9777Create.
* @param[out] pVideoFmt   Pointer to video format structure.
*
* @retval     SiiRetVal_t See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777VideoFormatQuery( SiiInst_t inst, Sii9777VideoFmt_t *pVideoFmt );

/******************************************************************************/
/**
* @brief Incoming audio format interrogation
*
* Retrieve data structure representing Audio info frame and some channel status bytes.
* Any detected format change generates SII9777_EVENT__RX_AUDIO_FMT_CHNG notification.
*
* @param[in]  inst        Driver instance handle obtained by calling Sii9777Create.
* @param[out] pAudioFmt   Pointer to a buffer to copy the audio format structure  .
*
* @retval SiiRetVal_t	  See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777AudioFormatQuery( SiiInst_t inst, Sii9777AudioFmt_t *pAudioFmt );

/******************************************************************************/
/**
* @brief ISRC information
*
* Retrieve data structure representing ISRC information.
* The structure is based on the following packets: ISRC1, ISRC2.
*
* @param[in]  inst      Driver instance handle obtained by calling Sii9777Create.
* @param[out] pIsrc     Pointer to a buffer to copy ISRC structure.
*
* @retval SiiRetVal_t	See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777IsrcQuery( SiiInst_t inst, Sii9777Isrc_t* pIsrc );

/******************************************************************************/
/**
* @brief Audio Content Protection information
*
* Retrieve data structure representing Audio Content Protection information.
* The structure is based on the ACP packet as defined in <insert cross-reference>. 
* SII9777_EVENT__RX_ACP_CHNG notification is generated when incoming ACP information changes.
*
* @param[in]  inst      Driver instance handle obtained by calling Sii9777Create.
* @param[out] pAcp      Pointer to a buffer to copy ACP structure.
*
* @retval SiiRetVal_t	See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777AcpQuery( SiiInst_t inst, Sii9777Acp_t* pAcp );

/******************************************************************************/
/**
* @brief Source Product Description information
*
* Retrieve data structure representing Source Product Description information.
* The structure is based on SPD packet. 
* SII9777_EVENT__RX_SPD_CHNG notification is generated when incoming SPD information changes.
*
* @param[in]  inst     Driver instance handle obtained by calling Sii9777Create.
* @param[out] pSpd     Pointer to a buffer to copy SPD structure.
*
* @retval SiiRetVal_t  See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777SpdQuery( SiiInst_t inst, Sii9777Spd_t* pSpd );

/******************************************************************************/
/**
* @brief High Dynamic Range information
*
* Retrieve data structure representing High Dynamic Range information.
* The structure is based on the HDR packet as defined in <insert cross-reference>. 
* SII9777_EVENT__RX_HDR_CHNG notification is generated when incoming HDR information changes.
*
* @param[in]  inst      Driver instance handle obtained by calling Sii9777Create.
* @param[out] pHdr      Pointer to a buffer to copy HDR structure.
*
* @retval SiiRetVal_t	See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777HdrQuery( SiiInst_t inst, Sii9777Hdr_t* pHdr );

/******************************************************************************/
/**
* @brief Allow upstream device to access HDCP registers or not
*
* Controls whether or not upstream device can access HDCP registers. 
* Set to ‘false?to indicate no-HDCP support to upstream device. 
* This may force the upstream device to send unprotected content without HDCP.
*
* @param[in]  inst      Driver instance handle obtained by calling Sii9777Create.
* @param[in]  port      Input port:
*                       SII9777_RX_PORT__0
*                       SII9777_RX_PORT__1
*                       SII9777_RX_PORT__2
*                       SII9777_RX_PORT__3
*
* @param[out] pbDdc     true  : Allow upstream device to access HDCP registers.
*                       false : Prevent  upstream device from reading HDCP registers.
*
* @retval SiiRetVal_t	See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777HdcpDdcSet( SiiInst_t inst, Sii9777RxPort_t port, bool_t* pbDdc );
SiiRetVal_t Sii9777HdcpDdcGet( SiiInst_t inst, Sii9777RxPort_t port, bool_t* pbDdc );

/******************************************************************************/
/**
* @brief Retrieves HDCP 2.X Stream_Manage message from up-stream device. 
*        Note: This function is only expected to be called 
*        when Sii9777-Rx is used in AVR repeater case, 
*        and attached downstream device is also a repeater.
*
* @param[in]          Driver instance handle obtained by calling Sii9777Create.
*
* @param[out]         Stream management information structure:
*                     'seq_num_M' for the RepeaterAuth_Stream_Manage message.
*                     'K value' for the RepeaterAuth_Stream_Manage message. 
*                     Is always  0x001 in HDMI.
*                     'streamID_Type' for the RepeaterAuth_Stream_Manage message, 
*                     the buffer length should be ‘K?
*
* @retval SiiRetVal_t See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777HdcpStreamManageInfoQuery( SiiInst_t inst, Sii9777HdcpStreamManageInfo_t* pStreamManageInfo );

/******************************************************************************/
/**
* @brief Configures HDCP 2.X RxInfo and HDCP 1.X BStatus.
*        Note: This function is only required if Sii9777 device is part of repeater product.
*
* @param[in]  inst          Driver instance returned by @ref Sii9777Create()
* @param[out] pTopology     Pointer to a structure to return downstream topology data structure
*
* @retval SiiRetVal_t       See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777HdcpTopologySet( SiiInst_t inst, Sii9777HdcpTopology_t *pTopology );
SiiRetVal_t Sii9777HdcpTopologyGet( SiiInst_t inst, Sii9777HdcpTopology_t *pTopology );

/******************************************************************************/
/**
* @brief 
*
* Writes array of downstream BKSV’s / RXID’s for upstream revocation purpose. 
* Repeater ready (‘Sii9777HdcpRepeaterReadySet? must be set ‘false?
* for the duration of writing the complete BKSV list.
* The current BKSV/RXID list is over written as soon ‘Sii9777HdcpBksvRxidListSet? 
* is called with ‘len?greater than 0 and prior 
* to that ‘Sii9777HdcpRepeaterReadySet?is to ‘false?
* This function is only expected to be called when Rx is used as part of a repeater product.
*
* @param[in]  inst         Driver instance handle obtained by calling Sii9777Create.
* @param[out] pBksvList    Pointer to array of BKSVs or RXIDs
* @param[in]  len          Length of BKSV list
*
* @retval SiiRetVal_t      See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777HdcpBksvRxidListSet( SiiInst_t inst, Sii9777HdcpKsv_t* pBksvList, uint8_t len );
SiiRetVal_t Sii9777HdcpBksvRxidListGet( SiiInst_t inst, Sii9777HdcpKsv_t* pBksvList, uint8_t len );

/******************************************************************************/
/**
* @brief Indicates repeater mode to upstream device.
*        This function is only expected to be called 
*        when Rx is used as part of a repeater product.
*        Note: Repeater bit is required to be set 
*        if Sii9777 device serves as part of repeater mode.
*
* @param[in]  inst               Driver instance handle obtained by calling Sii9777Create.
* @param[out] pbOn               true  : Asserts ready status to upstream device.
*                                 false : Indicates Sink device to upstream device.
*
* @retval SiiRetVal_t            See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777HdcpRepeaterEnableSet( SiiInst_t inst, bool_t *pbOn );
SiiRetVal_t Sii9777HdcpRepeaterEnableGet( SiiInst_t inst, bool_t *pbOn );

/******************************************************************************/
/**
* @brief Provides own BKSV of HDCP 1.4 receiver.
*
* @param[in]   inst	   Driver instance handle obtained by calling Sii9777Create.
*
* @param[out]  pBksv   BKSV key (5 bytes)
*
* @retval      SiiRetVal_t	See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777RxHdcpBksvOwnQuery( SiiInst_t inst, Sii9777HdcpKsv_t*   pBksv);

/******************************************************************************/
/**
* @brief       Provides own RxID of HDCP 2.2 receiver.
*
* @param[in]   inst	 Driver instance handle obtained by calling Sii9777Create.
*
* @param[out]  pRxId RxID key (5 bytes)
*
* @retval      SiiRetVal_t	See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777RxHdcpRxIdOwnQuery( SiiInst_t inst, Sii9777HdcpKsv_t* pRxId);

/******************************************************************************/
/**
* @brief Provides the current Rx HDCP status.  
*
* @param[in]  inst           Driver instance handle obtained by calling Sii9777Create.
* @param[out] pHdcpStat      Enumerator indicates any of the following states:
*                            SII9777_HDCP_STATUS__OFF
*                            SII9777_HDCP_STATUS__SUCCESS_1_X
*                            SII9777_HDCP_STATUS__SUCCESS_2_2
*                            SII9777_HDCP_STATUS__AUTHENTICATING
*                            SII9777_HDCP_STATUS__FAILED
*
* @retval     SiiRetVal_t    See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777HdcpStatusQuery( SiiInst_t inst, Sii9777HdcpStatus_t *pHdcpStat );

/******************************************************************************/
/**
* @brief Enable/Disable local content protection.  
*
* Enable/Disable local content protection.
* Note: This content protection is based on HDCP1.4 source device. This content protection
*       can not be used for external sink devices.
* Note: Tx2 port does not support HDCP content protection
*
* @param[in]  inst           Driver instance handle obtained by calling Sii9777Create.
* @param[out] port           Output port selection:
*                            SII9777_TX_PORT__0
*                            SII9777_TX_PORT__1
*                            SII9777_TX_PORT__2
* @param[out] pbOn           true  : Allow TMDS output signals to become active.
*                            false : Forces TMDS output signals to be turned off.
*
* @retval     SiiRetVal_t    See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777HdcpEnableSet( SiiInst_t inst, Sii9777TxPort_t port, bool_t *pbOn );
SiiRetVal_t Sii9777HdcpEnableGet( SiiInst_t inst, Sii9777TxPort_t port, bool_t *pbOn );

/******************************************************************************/
/**
* @brief Forces TMDS output to be muted. Mute is defined as a valid video signal 
* that is blanked (‘black?, no audio, and AV-MUTE bit is enabled.
*
* @param[in]  inst  Driver instance handle obtained by calling Sii9777Create.
*
* @param[in]  pPort	Output port:
*             SII9777_TX_PORT__0
*             SII9777_TX_PORT__1
*             SII9777_TX_PORT__2
*
* @param[in]  pbOn true  : Mute TMDS output signal.
*             false : Un-mute TMDS output signal.
*
* @retval     SiiRetVal_t See general SII_RETVAL definitions 
*
*******************************************************************************/
SiiRetVal_t Sii9777AvMuteSet( SiiInst_t inst, Sii9777TxPort_t port, bool_t* pbOn );
SiiRetVal_t Sii9777AvMuteGet( SiiInst_t inst, Sii9777TxPort_t port, bool_t* pbOn );

/******************************************************************************/
/**
* @brief
*
* @param[in]  inst  Driver instance handle obtained by calling Sii9777Create.
*
* @param[in]  pPort	Output port:
*                   SII9777_TX_PORT__0
*                   SII9777_TX_PORT__1
*                   SII9777_TX_PORT__2
*
* @param[in]  tmdsSwingLevel TMDS swing level range from -7...+7.
*
* @retval SiiRetVal_t See general SII_RETVAL definitions    
*
*******************************************************************************/
SiiRetVal_t Sii9777TmdsSwingLevelSet(SiiInst_t inst, Sii9777TxPort_t pPort, int8_t *tmdsSwingLevel);
SiiRetVal_t Sii9777TmdsSwingLevelGet(SiiInst_t inst, Sii9777TxPort_t pPort, int8_t *tmdsSwingLevel);

/******************************************************************************/
/**
* @brief Configure output port pin alignment to be either connector oriented or SOC oriented.
*
* @param[in]  inst  Driver instance handle obtained by calling Sii9777Create.
*
* @param[in]  pPort	Output port:
*                   SII9777_TX_PORT__0
*                   SII9777_TX_PORT__1
*                   SII9777_TX_PORT__2
* @param[in]  pTmdsPinSwap:
*                   SII9777_TMDS_PIN_SWAP__NONE
*                   SII9777_TMDS_PIN_SWAP__FULL
*                   SII9777_TMDS_PIN_SWAP__DATA
*
* @retval     SiiRetVal_t	See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777TmdsPinSwapSet(SiiInst_t inst, Sii9777TxPort_t pPort, Sii9777TmdsPinSwap_t* pTmdsPinSwap);
SiiRetVal_t Sii9777TmdsPinSwapGet(SiiInst_t inst, Sii9777TxPort_t pPort, Sii9777TmdsPinSwap_t* pTmdsPinSwap);

/******************************************************************************/
/**
* @brief Controls selection of primary output port.
*
* Controls which output is defined as primary output port. Only the primary output
* allows HPD and EDID to be replicated to input port(s).
*
* @param[in]  inst        Driver instance handle obtained by calling Sii9777Create.
* @param[out] pPort       Primary output port selection:
*                         SII9777_TX_PORT__0
*                         SII9777_TX_PORT__1
*                         SII9777_TX_PORT__2
*
* @retval SiiRetVal_t	  See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777PrimTxPortSet( SiiInst_t inst, Sii9777TxPort_t* pPort );
SiiRetVal_t Sii9777PrimTxPortGet( SiiInst_t inst, Sii9777TxPort_t* pPort );

/******************************************************************************/
/**
* @brief Controls the maximum video pixel bit depth output by Tx port.
*
* Controls the maximum video pixel bit depth output by Tx port. With this control
* the user can force the output to use a lower deep color mode than is provided
* on active input port. For instance, when user selects ‘SII9777_BIT_DEPTH__10?
* while upstream device provides a 12-bit deep color mode, the output video bit depth
* is truncated to 10bit (Deep color mode TMDS frequency = pixel frequency x 1.25).
*
* @param[in]  inst        Driver instance handle obtained by calling Sii9777Create.
* @param[out] pPort       Primary output port selection:
*                         SII9777_TX_PORT__0
*                         SII9777_TX_PORT__1
*                         SII9777_TX_PORT__2
* @param[in]  pDeepColor
*                         SII9777_BIT_DEPTH__8           Bit depth is limited to 8 bits
*                         SII9777_BIT_DEPTH__10          Bit depth is limited to 10 bits
*                         SII9777_BIT_DEPTH__12          Bit depth is limited to 12 bits
*
* @retval SiiRetVal_t	  See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777BitDepthLimitSet( SiiInst_t inst, Sii9777TxPort_t port, Sii9777BitDepth_t *pDeepColor );
SiiRetVal_t Sii9777BitDepthLimitGet( SiiInst_t inst, Sii9777TxPort_t port, Sii9777BitDepth_t *pDeepColor );

/******************************************************************************/
/**
* @brief Configures video pixel format
*
* Configures video pixel format that is desired to be used on video output (Tx0/Tx1/Tx2).
* This configuration is only used when pixel format conversion between input and output is enabled.
*
* @param[in]  inst      Driver instance handle obtained by calling Sii9777Create.
* @param[in]  pPixFmt   Pointer to data structure containing pixel format parameters
*
* @retval    SiiRetVal_t See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777OutputPixelFormatSet( SiiInst_t inst, Sii9777PixFmt_t* pPixFmt );
SiiRetVal_t Sii9777OutputPixelFormatGet( SiiInst_t inst, Sii9777PixFmt_t* pPixFmt );

/******************************************************************************/
/**
* @brief Dual-link format Look-up table configuration.
*
* Any video resolution received on an input that matches any video resolution ID 
* in the provided list will force the video to be split  through Tx1 and Tx2. 
* Audio is output to 'primTxPort'. 
* If no match is found then both audio and video will be routed to 'primTxPort'.
*
* @param[in]  inst     Driver instance handle obtained by calling Sii9777Create.
* @param[out] pVidRes  Pointer to array of video resolution IDs
* @param[in]  len      Length of array of VidRes ID's. 
*
* @retval SiiRetVal_t  See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777DualLinkLutSet( SiiInst_t inst, Sii9777VidRes_t* pVidRes, uint8_t len );
SiiRetVal_t Sii9777DualLinkLutGet( SiiInst_t inst, Sii9777VidRes_t* pVidRes, uint8_t len );

/******************************************************************************/
/**
* @brief Manual Dual link control.
*
* Forces  video to be split over Tx1 and Tx2 or unsplit  over 'primTxPort'  by manual overwrite.
*
* @param[in]  inst          Driver instance handle obtained by calling Sii9777Create.
* @param[in]  bDualLink     true:    Dual output (Tx1/Tx2) enabled
*                           false:   Dual output disabled.
*
* @retval SiiRetVal_t	See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777DualLinkManualSet( SiiInst_t inst, bool_t* bDualLink );
SiiRetVal_t Sii9777DualLinkManualGet( SiiInst_t inst, bool_t* bDualLink );

/******************************************************************************/
/**
* @brief Dual link control.
*
* Selects whether Dual-link function is asserted automatically through  
* the automatic video resolution list or controlled manually by 'Sii9777DualLinkSet()'
*
* @param[in]  inst           Driver instance handle obtained by calling Sii9777Create.
* @param[]    bAuto          true  : Dual link is asserted automatically. 
*                            false : Dual link is asserted manually.
*
*
* @retval    SiiRetVal_t     See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777DualLinkAutoEnableSet( SiiInst_t inst, bool_t* bAuto );
SiiRetVal_t Sii9777DualLinkAutoEnableGet( SiiInst_t inst, bool_t* bAuto );

/******************************************************************************/
/**
* @brief Queries Dual link state.
*
* Queries current state of Dual link configuration.
*
* @param[in]  inst           Driver instance returned by @ref Sii9777Create()
* @param[]    bDualLink      - @ref true    Dual link is currently enabled.
*                            - @ref false   Dual link is currently disabled.
*
* @retval SiiRetVal_t	See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777DualLinkQuery( SiiInst_t inst, bool_t* bDualLink );

/******************************************************************************/
/**
* @brief Dual link swap enable control.
*
* Selects mapping of dual link video content to Tx1 and Tx2 outputs.
*
* @param[in]  inst           Driver instance handle obtained by calling Sii9777Create.
* @param[]    pbOn           true  : Left/Even is output on Tx2, Right/Odd is output on Tx1.
*                            false : Left/Even is output on Tx1, Right/Odd is output on Tx2
*
* @retval    SiiRetVal_t     See general SII_RETVAL definitions
*
*******************************************************************************/
SiiRetVal_t Sii9777DualLinkSwapEnableSet( SiiInst_t inst, bool_t* pbOn );
SiiRetVal_t Sii9777DualLinkSwapEnableGet( SiiInst_t inst, bool_t* pbOn );

/******************************************************************************/
/**
* @brief Controls Audio Return Channel (ARC)
*
* Controls whether Audio Return Channel (ARC) is disabled or enabled through S/PDIF input.
*
* @param[in]  inst  Driver instance handle obtained by calling Sii9777Create.
* @param[in]  pOn   true  : S/PDIF is routed to ARC.
*                   false : ARC is disabled.
*
* @retval SiiRetVal_t See general SII_RETVAL definitions 
*
*******************************************************************************/
SiiRetVal_t Sii9777ArcEnableSet( SiiInst_t inst, bool_t* pOn );
SiiRetVal_t Sii9777ArcEnableGet( SiiInst_t inst, bool_t* pOn );

/******************************************************************************/
/**
* @brief Read the SCDC TMDS configuration of selected Rx.
*
* Read the SCDC TMDS configuration of selected Rx.
*
* @param[in]  inst      Driver instance handle obtained by calling Sii9777Create.
* @param[in]  pScdcCfg  Return the value of the SCDC TMDS Configuration
*                       bit0 : scramble enable or not
*                       bit1 : Tmds_bit_clock_ratio enable or not
*
* @retval SiiRetVal_t See general SII_RETVAL definitions 
*
*******************************************************************************/
SiiRetVal_t Sii9777ScdcRxConfigQuery( SiiInst_t inst, uint8_t*  pScdcCfg );

/******************************************************************************/
/**
* @brief Read the SCDC TMDS configuration of Tx0.
*
* Read the SCDC TMDS configuration of Tx0.
*
* @param[in]  inst      Driver instance handle obtained by calling Sii9777Create.
* @param[in]  pScdcCfg  Return the value of the SCDC TMDS Configuration
*                       bit0 : scramble enable or not
*                       bit1 : Tmds_bit_clock_ratio enable or not
*
* @retval SiiRetVal_t See general SII_RETVAL definitions 
*
*******************************************************************************/
SiiRetVal_t Sii9777ScdcTx0ConfigQuery( SiiInst_t inst, uint8_t*  pScdcCfg );

#if 0

/******************************************************************************/
/**
* @brief Indicates repeater mode to upstream device.
*
* Indicates repeater mode to upstream device.
* This function is only expected to be called when Rx is used as part of a repeater product.
*
* @param[in]  inst      Driver instance returned by @ref Sii9777Create()
* @param[out] pbValid   Pointer to repeater mode indicator.
*                       true  : Asserts ready status to upstream device.
*                       false : Indicates Sink device to upstream device.
*
* @retval SiiRetVal_t  See general SII_RETVAL definitions

*******************************************************************************/
SiiRetVal_t Sii9777HdcpRepeaterReadySet( SiiInst_t inst, bool_t* pbValid );
SiiRetVal_t Sii9777HdcpRepeaterReadyGet( SiiInst_t inst, bool_t* pbValid );

#endif

/******************************************************************************/

#ifdef __cplusplus
}
#endif

#endif // SII9777_RX_FUNC_H

