XilinxProcessorIPLib/drivers/hdcp22_tx_dp/src/xhdcp22_tx.c
static int XHdcp22Tx_ReceiveMsg(XHdcp22_Tx *InstancePtr, u8 MessageId,
                                u32 MessageSize)
{
	int Result = XST_SUCCESS;
	XHdcp22_Tx_DDCMessage* MsgPtr =
	                       (XHdcp22_Tx_DDCMessage*)InstancePtr->MessageBuffer;
	u32 ReceivedSize = InstancePtr->Info.RxStatus &
		XHDCP22_TX_RXSTATUS_AVAIL_BYTES_MASK;

	if (InstancePtr->Config.Protocol == XHDCP22_TX_DP)
		return XHdcp22Tx_Dp_ReadDpRxMsg(InstancePtr, MessageId);

	/* Check if the received size matches the expected size. */
	if (ReceivedSize != MessageSize) {
		XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG, XHDCP22_TX_LOG_DBG_MSG_READ_FAIL);
		return XST_FAILURE;
	}

	MsgPtr->DdcAddress = XHDCP22_TX_HDCPPORT_READ_MSG_OFFSET;
	/* Set the Expected msg ID in the buffer for testing purposes */
	MsgPtr->Message.MsgId = MessageId;

	Result = InstancePtr->DdcWrite(XHDCP22_TX_DDC_BASE_ADDRESS, 1,
			&MsgPtr->DdcAddress, (FALSE),
			InstancePtr->DdcHandlerRef);
	if (Result != XST_SUCCESS) {
		XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG, XHDCP22_TX_LOG_DBG_MSG_READ_FAIL);
		return Result;
	}

	/* Reading starts on message id */
	Result = InstancePtr->DdcRead(XHDCP22_TX_DDC_BASE_ADDRESS, ReceivedSize,
			(u8 *)&MsgPtr->Message.MsgId,
			(TRUE), InstancePtr->DdcHandlerRef);
	if (Result != XST_SUCCESS) {
		XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG, XHDCP22_TX_LOG_DBG_MSG_READ_FAIL);
		return Result;
	}

	/* Check if the received message id matches the expected message id */
	if (MsgPtr->Message.MsgId != MessageId)
		return XST_FAILURE;


	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function receives a message send by HDCP22 RX.
*
* @param  InstancePtr is a pointer to the XHdcp22Tx core instance.
* @param  MessageId the message Id of the expected message.
* @param  MessageSize the size of the expected message.
*
* @return
*         - XST_SUCCESS if the message size and id are as expected.
*         - XST_FAILURE if if the message size and id are incorrect.
* @note   None.
*
******************************************************************************/
This function receives a message send by HDCP22 RX.
This function receives a message send by HDCP22 RX .
static int XHdcp22Tx_ReceiveMsg(XHdcp22_Tx *InstancePtr, u8 MessageId,
                                u32 MessageSize)
{
	int Result = XST_SUCCESS;
	XHdcp22_Tx_DDCMessage* MsgPtr =
	                       (XHdcp22_Tx_DDCMessage*)InstancePtr->MessageBuffer;
	u32 ReceivedSize = InstancePtr->Info.RxStatus &
		XHDCP22_TX_RXSTATUS_AVAIL_BYTES_MASK;
	if (InstancePtr->Config.Protocol == XHDCP22_TX_DP)
		return XHdcp22Tx_Dp_ReadDpRxMsg(InstancePtr, MessageId);
	if (ReceivedSize != MessageSize) {
		XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG, XHDCP22_TX_LOG_DBG_MSG_READ_FAIL);
		return XST_FAILURE;
	}
	MsgPtr->DdcAddress = XHDCP22_TX_HDCPPORT_READ_MSG_OFFSET;
	MsgPtr->Message.MsgId = MessageId;
	Result = InstancePtr->DdcWrite(XHDCP22_TX_DDC_BASE_ADDRESS, 1,
			&MsgPtr->DdcAddress, (FALSE),
			InstancePtr->DdcHandlerRef);
	if (Result != XST_SUCCESS) {
		XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG, XHDCP22_TX_LOG_DBG_MSG_READ_FAIL);
		return Result;
	}
	Result = InstancePtr->DdcRead(XHDCP22_TX_DDC_BASE_ADDRESS, ReceivedSize,
			(u8 *)&MsgPtr->Message.MsgId,
			(TRUE), InstancePtr->DdcHandlerRef);
	if (Result != XST_SUCCESS) {
		XHdcp22Tx_LogWr(InstancePtr, XHDCP22_TX_LOG_EVT_DBG, XHDCP22_TX_LOG_DBG_MSG_READ_FAIL);
		return Result;
	}
	if (MsgPtr->Message.MsgId != MessageId)
		return XST_FAILURE;
	return XST_SUCCESS;
}
static int XHdcp22Tx_ReceiveMsg ( XHdcp22_Tx * InstancePtr , u8 MessageId , u32 MessageSize ) { int Result = XST_SUCCESS ; XHdcp22_Tx_DDCMessage * MsgPtr = ( XHdcp22_Tx_DDCMessage * ) InstancePtr -> MessageBuffer ; u32 ReceivedSize = InstancePtr -> Info . RxStatus & XHDCP22_TX_RXSTATUS_AVAIL_BYTES_MASK ; if ( InstancePtr -> Config . Protocol == XHDCP22_TX_DP ) return XHdcp22Tx_Dp_ReadDpRxMsg ( InstancePtr , MessageId ) ; if ( ReceivedSize != MessageSize ) { XHdcp22Tx_LogWr ( InstancePtr , XHDCP22_TX_LOG_EVT_DBG , XHDCP22_TX_LOG_DBG_MSG_READ_FAIL ) ; return XST_FAILURE ; } MsgPtr -> DdcAddress = XHDCP22_TX_HDCPPORT_READ_MSG_OFFSET ; MsgPtr -> Message . MsgId = MessageId ; Result = InstancePtr -> DdcWrite ( XHDCP22_TX_DDC_BASE_ADDRESS , 1 , & MsgPtr -> DdcAddress , ( FALSE ) , InstancePtr -> DdcHandlerRef ) ; if ( Result != XST_SUCCESS ) { XHdcp22Tx_LogWr ( InstancePtr , XHDCP22_TX_LOG_EVT_DBG , XHDCP22_TX_LOG_DBG_MSG_READ_FAIL ) ; return Result ; } Result = InstancePtr -> DdcRead ( XHDCP22_TX_DDC_BASE_ADDRESS , ReceivedSize , ( u8 * ) & MsgPtr -> Message . MsgId , ( TRUE ) , InstancePtr -> DdcHandlerRef ) ; if ( Result != XST_SUCCESS ) { XHdcp22Tx_LogWr ( InstancePtr , XHDCP22_TX_LOG_EVT_DBG , XHDCP22_TX_LOG_DBG_MSG_READ_FAIL ) ; return Result ; } if ( MsgPtr -> Message . MsgId != MessageId ) return XST_FAILURE ; return XST_SUCCESS ; }
This function receives a message send by HDCP22 RX.
This function receives a message send by HDCP22 RX .
/* Check if the received size matches the expected size. */ /* Set the Expected msg ID in the buffer for testing purposes */ /* Reading starts on message id */ /* Check if the received message id matches the expected message id */