XilinxProcessorIPLib/drivers/hdcp22_tx_dp/src/xhdcp22_tx.c
static XHdcp22_Tx_StateType XHdcp22Tx_StateA2_1(XHdcp22_Tx *InstancePtr)
{
	int Result = XST_SUCCESS;
	u8 LPrime[XHDCP22_TX_H_PRIME_SIZE];

	XHdcp22_Tx_PairingInfo *PairingInfoPtr =
	                       (XHdcp22_Tx_PairingInfo *)InstancePtr->Info.StateContext;
	XHdcp22_Tx_DDCMessage *MsgPtr =
	                      (XHdcp22_Tx_DDCMessage *)InstancePtr->MessageBuffer;

	/* Wait for the receiver to respond within 20 msecs.
	 * If the receiver has timed out we go to state A2 for a retry.
	 * If the receiver is busy, we stay in this state (return from polling).
	 * If the receiver has finished, but the message was not handled yet,
	 * we handle the message.*/
	Result = XHdcp22Tx_WaitForReceiver(InstancePtr, sizeof(XHdcp22_Tx_LCSendLPrime), FALSE);
	if (Result != XST_SUCCESS) {
		/* Retry state state A2 */
		return XHDCP22_TX_STATE_A2;
	}
	if (InstancePtr->Info.MsgAvailable == (FALSE)) {
		return XHDCP22_TX_STATE_A2_1;
	}

	/* Log after waiting (don't clutter our log buffer, check on counter) */
	if (InstancePtr->Info.LocalityCheckCounter == 1) {
		XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_STATE,
		                (u16)XHDCP22_TX_STATE_A2_1);
	}

	/* Receive the expected message */
	XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG, XHDCP22_TX_LOG_DBG_RX_L1);
	Result = XHdcp22Tx_ReceiveMsg(InstancePtr, XHDCP22_TX_LC_SEND_L_PRIME,
	                              sizeof(XHdcp22_Tx_LCSendLPrime));
	if (Result != XST_SUCCESS) {
		/* Retry state state A2 */
		return XHDCP22_TX_STATE_A2;
	}

	xdbg_printf(XDBG_DEBUG_GENERAL,"HDCP22TX: Reading Done for L'\n\r");

	/* Verify the received L' */
	XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG,
	XHDCP22_TX_LOG_DBG_COMPUTE_L);
	XHdcp22Tx_ComputeLPrime(InstancePtr->Info.Rn, PairingInfoPtr->Km,
	                        InstancePtr->Info.Rrx, InstancePtr->Info.Rtx,
	                        LPrime);
	XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG,
		XHDCP22_TX_LOG_DBG_COMPUTE_L_DONE);

	if(memcmp(MsgPtr->Message.LCSendLPrime.LPrime, LPrime, sizeof(LPrime)) != 0) {
		XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG,
			XHDCP22_TX_LOG_DBG_COMPARE_L_FAIL);
		/* Retry state A2 */
		return XHDCP22_TX_STATE_A2;
	}

	/* Log how many times the locality check was repeated (*/
	XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_LCCHK_COUNT,
	                (u16)InstancePtr->Info.LocalityCheckCounter);
	return XHDCP22_TX_STATE_A3;
}
/*****************************************************************************/
/**
*
* This function executes a part of the A2 state functionality of the HDCP2.2
* TX protocol.
* It receives and verifies L' (locality check).
*
* @param  InstancePtr is a pointer to the XHdcp22Tx core instance.
*
* @return
*         - XHDCP22_TX_STATE_A2_1 if busy waiting for the
*           XHDCP22_TX_AKE_SEND_L_PRIME message.
*         - XHDCP22_TX_STATE_A3 if authentication is done.
*
* @note   None.
*
******************************************************************************/
This function executes a part of the A2 state functionality of the HDCP2.2
TX protocol.
It receives and verifies L' (locality check).
This function executes a part of the A2 state functionality of the HDCP2 . 2 TX protocol . It receives and verifies L ' ( locality check ) .
static XHdcp22_Tx_StateType XHdcp22Tx_StateA2_1(XHdcp22_Tx *InstancePtr)
{
	int Result = XST_SUCCESS;
	u8 LPrime[XHDCP22_TX_H_PRIME_SIZE];
	XHdcp22_Tx_PairingInfo *PairingInfoPtr =
	                       (XHdcp22_Tx_PairingInfo *)InstancePtr->Info.StateContext;
	XHdcp22_Tx_DDCMessage *MsgPtr =
	                      (XHdcp22_Tx_DDCMessage *)InstancePtr->MessageBuffer;
	Result = XHdcp22Tx_WaitForReceiver(InstancePtr, sizeof(XHdcp22_Tx_LCSendLPrime), FALSE);
	if (Result != XST_SUCCESS) {
		return XHDCP22_TX_STATE_A2;
	}
	if (InstancePtr->Info.MsgAvailable == (FALSE)) {
		return XHDCP22_TX_STATE_A2_1;
	}
	if (InstancePtr->Info.LocalityCheckCounter == 1) {
		XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_STATE,
		                (u16)XHDCP22_TX_STATE_A2_1);
	}
	XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG, XHDCP22_TX_LOG_DBG_RX_L1);
	Result = XHdcp22Tx_ReceiveMsg(InstancePtr, XHDCP22_TX_LC_SEND_L_PRIME,
	                              sizeof(XHdcp22_Tx_LCSendLPrime));
	if (Result != XST_SUCCESS) {
		return XHDCP22_TX_STATE_A2;
	}
	xdbg_printf(XDBG_DEBUG_GENERAL,"HDCP22TX: Reading Done for L'\n\r");
	XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG,
	XHDCP22_TX_LOG_DBG_COMPUTE_L);
	XHdcp22Tx_ComputeLPrime(InstancePtr->Info.Rn, PairingInfoPtr->Km,
	                        InstancePtr->Info.Rrx, InstancePtr->Info.Rtx,
	                        LPrime);
	XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG,
		XHDCP22_TX_LOG_DBG_COMPUTE_L_DONE);
	if(memcmp(MsgPtr->Message.LCSendLPrime.LPrime, LPrime, sizeof(LPrime)) != 0) {
		XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG,
			XHDCP22_TX_LOG_DBG_COMPARE_L_FAIL);
		return XHDCP22_TX_STATE_A2;
	}
	XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_LCCHK_COUNT,
	                (u16)InstancePtr->Info.LocalityCheckCounter);
	return XHDCP22_TX_STATE_A3;
}
static XHdcp22_Tx_StateType XHdcp22Tx_StateA2_1 ( XHdcp22_Tx * InstancePtr ) { int Result = XST_SUCCESS ; u8 LPrime [ XHDCP22_TX_H_PRIME_SIZE ] ; XHdcp22_Tx_PairingInfo * PairingInfoPtr = ( XHdcp22_Tx_PairingInfo * ) InstancePtr -> Info . StateContext ; XHdcp22_Tx_DDCMessage * MsgPtr = ( XHdcp22_Tx_DDCMessage * ) InstancePtr -> MessageBuffer ; Result = XHdcp22Tx_WaitForReceiver ( InstancePtr , sizeof ( XHdcp22_Tx_LCSendLPrime ) , FALSE ) ; if ( Result != XST_SUCCESS ) { return XHDCP22_TX_STATE_A2 ; } if ( InstancePtr -> Info . MsgAvailable == ( FALSE ) ) { return XHDCP22_TX_STATE_A2_1 ; } if ( InstancePtr -> Info . LocalityCheckCounter == 1 ) { XHdcp22Tx_LogWr ( InstancePtr , XHDCP22_TX_LOG_EVT_STATE , ( u16 ) XHDCP22_TX_STATE_A2_1 ) ; } XHdcp22Tx_LogWr ( InstancePtr , XHDCP22_TX_LOG_EVT_DBG , XHDCP22_TX_LOG_DBG_RX_L1 ) ; Result = XHdcp22Tx_ReceiveMsg ( InstancePtr , XHDCP22_TX_LC_SEND_L_PRIME , sizeof ( XHdcp22_Tx_LCSendLPrime ) ) ; if ( Result != XST_SUCCESS ) { return XHDCP22_TX_STATE_A2 ; } xdbg_printf ( XDBG_DEBUG_GENERAL , " \n \r " ) ; XHdcp22Tx_LogWr ( InstancePtr , XHDCP22_TX_LOG_EVT_DBG , XHDCP22_TX_LOG_DBG_COMPUTE_L ) ; XHdcp22Tx_ComputeLPrime ( InstancePtr -> Info . Rn , PairingInfoPtr -> Km , InstancePtr -> Info . Rrx , InstancePtr -> Info . Rtx , LPrime ) ; XHdcp22Tx_LogWr ( InstancePtr , XHDCP22_TX_LOG_EVT_DBG , XHDCP22_TX_LOG_DBG_COMPUTE_L_DONE ) ; if ( memcmp ( MsgPtr -> Message . LCSendLPrime . LPrime , LPrime , sizeof ( LPrime ) ) != 0 ) { XHdcp22Tx_LogWr ( InstancePtr , XHDCP22_TX_LOG_EVT_DBG , XHDCP22_TX_LOG_DBG_COMPARE_L_FAIL ) ; return XHDCP22_TX_STATE_A2 ; } XHdcp22Tx_LogWr ( InstancePtr , XHDCP22_TX_LOG_EVT_LCCHK_COUNT , ( u16 ) InstancePtr -> Info . LocalityCheckCounter ) ; return XHDCP22_TX_STATE_A3 ; }
This function executes a part of the A2 state functionality of the HDCP2.2
TX protocol.
This function executes a part of the A2 state functionality of the HDCP2 . 2 TX protocol .
/* Wait for the receiver to respond within 20 msecs.
	 * If the receiver has timed out we go to state A2 for a retry.
	 * If the receiver is busy, we stay in this state (return from polling).
	 * If the receiver has finished, but the message was not handled yet,
	 * we handle the message.*/ /* Retry state state A2 */ /* Log after waiting (don't clutter our log buffer, check on counter) */ /* Receive the expected message */ /* Retry state state A2 */ /* Verify the received L' */ /* Retry state A2 */ /* Log how many times the locality check was repeated (*/