XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.c
static void XHdcp1x_TxEnterState(XHdcp1x *InstancePtr, XHdcp1x_StateType State,
		XHdcp1x_StateType *NextStatePtr)
{
	/* Case-wise process the kind of state called */
	switch (State) {
		/* For the disabled state */
		case XHDCP1X_STATE_DISABLED:
			/* Clear auth request pending flag */
			InstancePtr->Tx.IsAuthReqPending = FALSE;
			XHdcp1x_TxDisableState(InstancePtr);
			break;

		/* For determine rx capable */
		case XHDCP1X_STATE_DETERMINERXCAPABLE:
			InstancePtr->RepeaterValues.hdcp14_PropagateTopoErrUpstream = FALSE;
			InstancePtr->Tx.Flags |= XVPHY_FLAG_PHY_UP;
			XHdcp1x_TxSetCheckLinkState(InstancePtr, FALSE);
			XHdcp1x_TxDisableEncryptionState(InstancePtr);
			XHdcp1x_TxCheckRxCapable(InstancePtr, NextStatePtr);
			break;

		/* For the exchange ksvs state */
		case XHDCP1X_STATE_EXCHANGEKSVS:
			InstancePtr->Tx.StateHelper = 0;
			XHdcp1x_TxExchangeKsvs(InstancePtr, NextStatePtr);
			break;

		/* For the computations state */
		case XHDCP1X_STATE_COMPUTATIONS:
			XHdcp1x_TxStartComputations(InstancePtr,
						    NextStatePtr);
			break;

		/* For the validate rx state */
		case XHDCP1X_STATE_VALIDATERX:
			InstancePtr->Tx.StateHelper = 0;
			XHdcp1x_TxStartTimer(InstancePtr, XVPHY_TMO_100MS);
			break;

		/* For the validate rx state */
		case XHDCP1X_STATE_TESTFORREPEATER:
#if (defined(XPAR_XV_HDMITX_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX_NUM_INSTANCES > 0)) || \
    (defined(XPAR_XV_HDMITX1_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX1_NUM_INSTANCES > 0))
			/* Enable encryption for HDMI (this will come immediately
			 * after Ro' has been read and successfully compared). */
			InstancePtr->Tx.EncryptionMap = 0x1;
			XHdcp1x_TxEnableEncryptionState(InstancePtr);
#else
			/* Enable encryption for DP (this will come immediately
			 * after Ro' has been read and successfully compared). */
			XHdcp1x_TxEnableEncryptionState(InstancePtr);
#endif
			break;

		/* For the wait for ready state */
		case XHDCP1X_STATE_WAITFORREADY:
			InstancePtr->Tx.StateHelper = 0;

#if (defined(XPAR_XV_HDMITX_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX_NUM_INSTANCES > 0)) || \
    (defined(XPAR_XV_HDMITX1_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX1_NUM_INSTANCES > 0))
			InstancePtr->Tx.WaitForReadyPollCntFlag = 0;
			/* Post the timeout */
			XHdcp1x_TxPostEvent(InstancePtr, XHDCP1X_EVENT_TIMEOUT);
#else
			XHdcp1x_TxStartTimer(InstancePtr,
					     (5 * XVPHY_TMO_1SECOND));
#endif

			break;

		/* For the read ksv list state */
		case XHDCP1X_STATE_READKSVLIST:
			XHdcp1x_TxReadKsvList(InstancePtr, NextStatePtr);
			break;

		/* For the authenticated state */
		case XHDCP1X_STATE_AUTHENTICATED:
			InstancePtr->Tx.StateHelper = 0;

			if (InstancePtr->Tx.PreviousState !=
					XHDCP1X_STATE_LINKINTEGRITYCHECK) {
				InstancePtr->Tx.Stats.AuthPassed++;
				XHdcp1x_TxSetCheckLinkState(InstancePtr, TRUE);
				XHdcp1x_TxDebugLog(InstancePtr,
					"authenticated");

				/* Authenticated callback */
				if (InstancePtr->Tx.IsAuthenticatedCallbackSet)
				{
					/* Clear auth request pending flag */
					InstancePtr->Tx.IsAuthReqPending = (FALSE);

					InstancePtr->Tx.AuthenticatedCallback
					(InstancePtr->Tx.AuthenticatedCallbackRef);
				}
			}

			if (InstancePtr->IsRepeater == 1) {
			  if(InstancePtr->Tx.DownstreamReady == 1) {
			    InstancePtr->Tx.DownstreamReady = 0;
#if (defined(XPAR_XV_HDMITX_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX_NUM_INSTANCES > 0)) || \
    (defined(XPAR_XV_HDMITX1_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX1_NUM_INSTANCES > 0))
			    /* Do nothing for HDMI. */
#else
			    /* In case of DisplayPort , read the Downstream Repeater
			     * Configuration values, and update the StateHelper flag. */
			    u32 Buf;
				XHdcp1x_PortRead(InstancePtr, XHDCP1X_PORT_OFFSET_BINFO,
							&Buf, XHDCP1X_PORT_SIZE_BINFO);
				InstancePtr->Tx.StateHelper = (Buf & 0x0000FFFFu);
#endif
			    XHdcp1x_TxSetRepeaterInfo(InstancePtr);
			    if (InstancePtr->Tx.IsRepeaterExchangeCallbackSet)
			    {
			      InstancePtr->Tx.RepeaterExchangeCallback(
			        InstancePtr->Tx.RepeaterExchangeRef);
			    }
			  }
			}
			break;

		/* For the link integrity check state */
		case XHDCP1X_STATE_LINKINTEGRITYCHECK:
			XHdcp1x_TxCheckLinkIntegrity(InstancePtr,
						NextStatePtr);
			break;

		/* For the unauthenticated state */
		case XHDCP1X_STATE_UNAUTHENTICATED:
			InstancePtr->Tx.Flags &= ~XVPHY_FLAG_IS_REPEATER;
			InstancePtr->Tx.Flags |= XVPHY_FLAG_PHY_UP;
			XHdcp1x_TxDisableEncryptionState(InstancePtr);
			break;

		/* For physical layer down */
		case XHDCP1X_STATE_PHYDOWN:
			InstancePtr->Tx.Flags &= ~XVPHY_FLAG_PHY_UP;
			XHdcp1x_TxDisableEncryptionState(InstancePtr);
			XHdcp1x_CipherDisable(InstancePtr);
			break;

		/* Otherwise */
		default:
			/* Do nothing */
			break;
	}
}
/*****************************************************************************/
/**
* This function enters a state.
*
* @param	InstancePtr is the HDCP state machine.
* @param	State is the state to enter.
* @param	NextStatePtr is the next state.
*
* @return	None.
*
* @note		None.
*
******************************************************************************/
This function enters a state.
This function enters a state .
static void XHdcp1x_TxEnterState(XHdcp1x *InstancePtr, XHdcp1x_StateType State,
		XHdcp1x_StateType *NextStatePtr)
{
	switch (State) {
		case XHDCP1X_STATE_DISABLED:
			InstancePtr->Tx.IsAuthReqPending = FALSE;
			XHdcp1x_TxDisableState(InstancePtr);
			break;
		case XHDCP1X_STATE_DETERMINERXCAPABLE:
			InstancePtr->RepeaterValues.hdcp14_PropagateTopoErrUpstream = FALSE;
			InstancePtr->Tx.Flags |= XVPHY_FLAG_PHY_UP;
			XHdcp1x_TxSetCheckLinkState(InstancePtr, FALSE);
			XHdcp1x_TxDisableEncryptionState(InstancePtr);
			XHdcp1x_TxCheckRxCapable(InstancePtr, NextStatePtr);
			break;
		case XHDCP1X_STATE_EXCHANGEKSVS:
			InstancePtr->Tx.StateHelper = 0;
			XHdcp1x_TxExchangeKsvs(InstancePtr, NextStatePtr);
			break;
		case XHDCP1X_STATE_COMPUTATIONS:
			XHdcp1x_TxStartComputations(InstancePtr,
						    NextStatePtr);
			break;
		case XHDCP1X_STATE_VALIDATERX:
			InstancePtr->Tx.StateHelper = 0;
			XHdcp1x_TxStartTimer(InstancePtr, XVPHY_TMO_100MS);
			break;
		case XHDCP1X_STATE_TESTFORREPEATER:
#if (defined(XPAR_XV_HDMITX_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX_NUM_INSTANCES > 0)) || \
    (defined(XPAR_XV_HDMITX1_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX1_NUM_INSTANCES > 0))
			InstancePtr->Tx.EncryptionMap = 0x1;
			XHdcp1x_TxEnableEncryptionState(InstancePtr);
#else
			XHdcp1x_TxEnableEncryptionState(InstancePtr);
#endif
			break;
		case XHDCP1X_STATE_WAITFORREADY:
			InstancePtr->Tx.StateHelper = 0;
#if (defined(XPAR_XV_HDMITX_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX_NUM_INSTANCES > 0)) || \
    (defined(XPAR_XV_HDMITX1_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX1_NUM_INSTANCES > 0))
			InstancePtr->Tx.WaitForReadyPollCntFlag = 0;
			XHdcp1x_TxPostEvent(InstancePtr, XHDCP1X_EVENT_TIMEOUT);
#else
			XHdcp1x_TxStartTimer(InstancePtr,
					     (5 * XVPHY_TMO_1SECOND));
#endif
			break;
		case XHDCP1X_STATE_READKSVLIST:
			XHdcp1x_TxReadKsvList(InstancePtr, NextStatePtr);
			break;
		case XHDCP1X_STATE_AUTHENTICATED:
			InstancePtr->Tx.StateHelper = 0;
			if (InstancePtr->Tx.PreviousState !=
					XHDCP1X_STATE_LINKINTEGRITYCHECK) {
				InstancePtr->Tx.Stats.AuthPassed++;
				XHdcp1x_TxSetCheckLinkState(InstancePtr, TRUE);
				XHdcp1x_TxDebugLog(InstancePtr,
					"authenticated");
				if (InstancePtr->Tx.IsAuthenticatedCallbackSet)
				{
					InstancePtr->Tx.IsAuthReqPending = (FALSE);
					InstancePtr->Tx.AuthenticatedCallback
					(InstancePtr->Tx.AuthenticatedCallbackRef);
				}
			}
			if (InstancePtr->IsRepeater == 1) {
			  if(InstancePtr->Tx.DownstreamReady == 1) {
			    InstancePtr->Tx.DownstreamReady = 0;
#if (defined(XPAR_XV_HDMITX_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX_NUM_INSTANCES > 0)) || \
    (defined(XPAR_XV_HDMITX1_NUM_INSTANCES) && \
     (XPAR_XV_HDMITX1_NUM_INSTANCES > 0))
#else
			    u32 Buf;
				XHdcp1x_PortRead(InstancePtr, XHDCP1X_PORT_OFFSET_BINFO,
							&Buf, XHDCP1X_PORT_SIZE_BINFO);
				InstancePtr->Tx.StateHelper = (Buf & 0x0000FFFFu);
#endif
			    XHdcp1x_TxSetRepeaterInfo(InstancePtr);
			    if (InstancePtr->Tx.IsRepeaterExchangeCallbackSet)
			    {
			      InstancePtr->Tx.RepeaterExchangeCallback(
			        InstancePtr->Tx.RepeaterExchangeRef);
			    }
			  }
			}
			break;
		case XHDCP1X_STATE_LINKINTEGRITYCHECK:
			XHdcp1x_TxCheckLinkIntegrity(InstancePtr,
						NextStatePtr);
			break;
		case XHDCP1X_STATE_UNAUTHENTICATED:
			InstancePtr->Tx.Flags &= ~XVPHY_FLAG_IS_REPEATER;
			InstancePtr->Tx.Flags |= XVPHY_FLAG_PHY_UP;
			XHdcp1x_TxDisableEncryptionState(InstancePtr);
			break;
		case XHDCP1X_STATE_PHYDOWN:
			InstancePtr->Tx.Flags &= ~XVPHY_FLAG_PHY_UP;
			XHdcp1x_TxDisableEncryptionState(InstancePtr);
			XHdcp1x_CipherDisable(InstancePtr);
			break;
		default:
			break;
	}
}
static void XHdcp1x_TxEnterState ( XHdcp1x * InstancePtr , XHdcp1x_StateType State , XHdcp1x_StateType * NextStatePtr ) { switch ( State ) { case XHDCP1X_STATE_DISABLED : InstancePtr -> Tx . IsAuthReqPending = FALSE ; XHdcp1x_TxDisableState ( InstancePtr ) ; break ; case XHDCP1X_STATE_DETERMINERXCAPABLE : InstancePtr -> RepeaterValues . hdcp14_PropagateTopoErrUpstream = FALSE ; InstancePtr -> Tx . Flags |= XVPHY_FLAG_PHY_UP ; XHdcp1x_TxSetCheckLinkState ( InstancePtr , FALSE ) ; XHdcp1x_TxDisableEncryptionState ( InstancePtr ) ; XHdcp1x_TxCheckRxCapable ( InstancePtr , NextStatePtr ) ; break ; case XHDCP1X_STATE_EXCHANGEKSVS : InstancePtr -> Tx . StateHelper = 0 ; XHdcp1x_TxExchangeKsvs ( InstancePtr , NextStatePtr ) ; break ; case XHDCP1X_STATE_COMPUTATIONS : XHdcp1x_TxStartComputations ( InstancePtr , NextStatePtr ) ; break ; case XHDCP1X_STATE_VALIDATERX : InstancePtr -> Tx . StateHelper = 0 ; XHdcp1x_TxStartTimer ( InstancePtr , XVPHY_TMO_100MS ) ; break ; case XHDCP1X_STATE_TESTFORREPEATER : #if ( defined ( XPAR_XV_HDMITX_NUM_INSTANCES ) && ( XPAR_XV_HDMITX_NUM_INSTANCES > 0 ) ) || ( defined ( XPAR_XV_HDMITX1_NUM_INSTANCES ) && ( XPAR_XV_HDMITX1_NUM_INSTANCES > 0 ) ) InstancePtr -> Tx . EncryptionMap = 0x1 ; XHdcp1x_TxEnableEncryptionState ( InstancePtr ) ; #else XHdcp1x_TxEnableEncryptionState ( InstancePtr ) ; #endif break ; case XHDCP1X_STATE_WAITFORREADY : InstancePtr -> Tx . StateHelper = 0 ; #if ( defined ( XPAR_XV_HDMITX_NUM_INSTANCES ) && ( XPAR_XV_HDMITX_NUM_INSTANCES > 0 ) ) || ( defined ( XPAR_XV_HDMITX1_NUM_INSTANCES ) && ( XPAR_XV_HDMITX1_NUM_INSTANCES > 0 ) ) InstancePtr -> Tx . WaitForReadyPollCntFlag = 0 ; XHdcp1x_TxPostEvent ( InstancePtr , XHDCP1X_EVENT_TIMEOUT ) ; #else XHdcp1x_TxStartTimer ( InstancePtr , ( 5 * XVPHY_TMO_1SECOND ) ) ; #endif break ; case XHDCP1X_STATE_READKSVLIST : XHdcp1x_TxReadKsvList ( InstancePtr , NextStatePtr ) ; break ; case XHDCP1X_STATE_AUTHENTICATED : InstancePtr -> Tx . StateHelper = 0 ; if ( InstancePtr -> Tx . PreviousState != XHDCP1X_STATE_LINKINTEGRITYCHECK ) { InstancePtr -> Tx . Stats . AuthPassed ++ ; XHdcp1x_TxSetCheckLinkState ( InstancePtr , TRUE ) ; XHdcp1x_TxDebugLog ( InstancePtr , " " ) ; if ( InstancePtr -> Tx . IsAuthenticatedCallbackSet ) { InstancePtr -> Tx . IsAuthReqPending = ( FALSE ) ; InstancePtr -> Tx . AuthenticatedCallback ( InstancePtr -> Tx . AuthenticatedCallbackRef ) ; } } if ( InstancePtr -> IsRepeater == 1 ) { if ( InstancePtr -> Tx . DownstreamReady == 1 ) { InstancePtr -> Tx . DownstreamReady = 0 ; #if ( defined ( XPAR_XV_HDMITX_NUM_INSTANCES ) && ( XPAR_XV_HDMITX_NUM_INSTANCES > 0 ) ) || ( defined ( XPAR_XV_HDMITX1_NUM_INSTANCES ) && ( XPAR_XV_HDMITX1_NUM_INSTANCES > 0 ) ) #else u32 Buf ; XHdcp1x_PortRead ( InstancePtr , XHDCP1X_PORT_OFFSET_BINFO , & Buf , XHDCP1X_PORT_SIZE_BINFO ) ; InstancePtr -> Tx . StateHelper = ( Buf & 0x0000FFFFu ) ; #endif XHdcp1x_TxSetRepeaterInfo ( InstancePtr ) ; if ( InstancePtr -> Tx . IsRepeaterExchangeCallbackSet ) { InstancePtr -> Tx . RepeaterExchangeCallback ( InstancePtr -> Tx . RepeaterExchangeRef ) ; } } } break ; case XHDCP1X_STATE_LINKINTEGRITYCHECK : XHdcp1x_TxCheckLinkIntegrity ( InstancePtr , NextStatePtr ) ; break ; case XHDCP1X_STATE_UNAUTHENTICATED : InstancePtr -> Tx . Flags &= ~ XVPHY_FLAG_IS_REPEATER ; InstancePtr -> Tx . Flags |= XVPHY_FLAG_PHY_UP ; XHdcp1x_TxDisableEncryptionState ( InstancePtr ) ; break ; case XHDCP1X_STATE_PHYDOWN : InstancePtr -> Tx . Flags &= ~ XVPHY_FLAG_PHY_UP ; XHdcp1x_TxDisableEncryptionState ( InstancePtr ) ; XHdcp1x_CipherDisable ( InstancePtr ) ; break ; default : break ; } }
This function enters a state.
This function enters a state .
/* Case-wise process the kind of state called */ /* For the disabled state */ /* Clear auth request pending flag */ /* For determine rx capable */ /* For the exchange ksvs state */ /* For the computations state */ /* For the validate rx state */ /* For the validate rx state */ /* Enable encryption for HDMI (this will come immediately
			 * after Ro' has been read and successfully compared). */ /* Enable encryption for DP (this will come immediately
			 * after Ro' has been read and successfully compared). */ /* For the wait for ready state */ /* Post the timeout */ /* For the read ksv list state */ /* For the authenticated state */ /* Authenticated callback */ /* Clear auth request pending flag */ /* Do nothing for HDMI. */ /* In case of DisplayPort , read the Downstream Repeater
			     * Configuration values, and update the StateHelper flag. */ /* For the link integrity check state */ /* For the unauthenticated state */ /* For physical layer down */ /* Otherwise */ /* Do nothing */