XilinxProcessorIPLib/drivers/hdcp22_rx_dp/src/xhdcp22_rx.c
static int XHdcp22Rx_SendMessageRepeaterAuthSendRxIdList(XHdcp22_Rx *InstancePtr)
{
	/* Verify arguments */
	Xil_AssertNonvoid(InstancePtr != NULL);

	XHdcp22_Rx_Message *MsgPtr = (XHdcp22_Rx_Message*)InstancePtr->MessageBuffer;
	u32 Offset;
	u32 MessageSize;

	/* Set message ID */
	MsgPtr->RepeaterAuthSendRxIdList.MsgId      =
		XHDCP22_RX_MSG_ID_REPEATERAUTHSENDRXIDLIST;

	/* Set RxInfo bit fields */
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[0]  =
		(u8)((InstancePtr->Topology.Depth & 0x07) << 1);                    // RxInfo[11:9] = Depth[2:0]
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[0] |=
		(u8)((InstancePtr->Topology.DeviceCnt & 0x10) >> 4);                // RxInfo[8]    = DeviceCnt[4]
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[1]  =
		(u8)((InstancePtr->Topology.DeviceCnt & 0x0F) << 4);                // RxInfo[7:4]  = DeviceCnt[3:0]
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[1] |=
		(u8)((InstancePtr->Topology.MaxDevsExceeded & 0x01) << 3);          // RxInfo[3]    = MaxDevsExceeded
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[1] |=
		(u8)((InstancePtr->Topology.MaxCascadeExceeded & 0x01) << 2);       // RxInfo[2]    = MaxCascadeExceeded
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[1] |=
		(u8)((InstancePtr->Topology.Hdcp2LegacyDeviceDownstream & 0x01) << 1); // RxInfo[1]    = Hdcp2LegacyDeviceDownstream
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[1] |=
		(u8)(InstancePtr->Topology.Hdcp1DeviceDownstream & 0x01);           // RxInfo[0]    = Hdcp1DeviceDownstream

	/* Set seq_numb_V bytes */
	MsgPtr->RepeaterAuthSendRxIdList.SeqNumV[0] = (InstancePtr->Info.SeqNumV >> 16) & 0xFF;
	MsgPtr->RepeaterAuthSendRxIdList.SeqNumV[1] = (InstancePtr->Info.SeqNumV >> 8) & 0xFF;
	MsgPtr->RepeaterAuthSendRxIdList.SeqNumV[2] = (InstancePtr->Info.SeqNumV) & 0xFF;

	/* Set other message fields
	 * - When topology maximums are not exceeded send seq_num_V, VPrime, and Receiver ID List
	 * - Otherwise, only send RxInfo
	 */
	if(InstancePtr->Topology.MaxDevsExceeded != TRUE &&
		InstancePtr->Topology.MaxCascadeExceeded != TRUE)
	{
		/* Increment seq_num_V count with rollover */
		InstancePtr->Info.SeqNumV = (InstancePtr->Info.SeqNumV + 1) % XHDCP22_RX_MAX_SEQNUMV;

		/* Compute VPrime */
		XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_DEBUG, XHDCP22_RX_LOG_DEBUG_COMPUTE_VPRIME);
		XHdcp22Rx_ComputeVPrime((u8 *)InstancePtr->Topology.ReceiverIdList,
			InstancePtr->Topology.DeviceCnt,
			MsgPtr->RepeaterAuthSendRxIdList.RxInfo,
			MsgPtr->RepeaterAuthSendRxIdList.SeqNumV,
			InstancePtr->Params.Km,
			InstancePtr->Params.Rrx,
			InstancePtr->Params.Rtx,
			InstancePtr->Params.VPrime);
		XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_DEBUG, XHDCP22_RX_LOG_DEBUG_COMPUTE_VPRIME_DONE);

		/* Copy VPrime[0:16], most significant 128-bits */
		memcpy(MsgPtr->RepeaterAuthSendRxIdList.VPrime, InstancePtr->Params.VPrime, 16);

		/* Copy receiver ID list */
		memcpy(MsgPtr->RepeaterAuthSendRxIdList.ReceiverIdList,
				InstancePtr->Topology.ReceiverIdList,
				XHDCP22_RX_RCVID_SIZE*InstancePtr->Topology.DeviceCnt);

		/* Update message size */
		MessageSize = 22 + XHDCP22_RX_RCVID_SIZE*InstancePtr->Topology.DeviceCnt;
	}
	else
	{
		/* Update message size */
		MessageSize = 3;
	}

	if (InstancePtr->Config.Protocol == XHDCP22_RX_DP) {
		/*Write message to DPCD registers*/
		XHdcp22Rx_Dp_Write_Dpcd_Msg(InstancePtr);
	} else {
		/* Write message to buffer */
		InstancePtr->Handles.DdcSetAddressCallback(InstancePtr->Handles.DdcSetAddressCallbackRef,
			XHDCP22_RX_DDC_READ_REG);
		for(Offset = 0; Offset < MessageSize; Offset++)
		{
			InstancePtr->Handles.DdcSetDataCallback(InstancePtr->Handles.DdcSetDataCallbackRef,
				InstancePtr->MessageBuffer[Offset]);
		}
	}

	/* Set the TopologyReady flag */
	InstancePtr->Info.TopologyReady = TRUE;

	if (InstancePtr->Config.Protocol == XHDCP22_RX_DP) {
		u8 rxstatus = RX_STATUS_REPEATER_READY_AVAILABLE;
		/*Write READY in RxStatus*/
		InstancePtr->Handles.RxDpAuxWriteCallback(
				InstancePtr->Handles.RxDpAuxWriteCallbackRef,
				RX_STATUS_OFFSET, &rxstatus, 1);

		/*Clear AUX_DEFERS for READY message*/
		InstancePtr->Handles.RxDpSetClearAuxDeferCallback(
				InstancePtr->Handles.RxDpSetClearAuxDeferCallbackRef,
				(FALSE));

		/*raise CP_IRQ*/
		InstancePtr->Handles.RxDpCpIrqSetCallback(
				InstancePtr->Handles.RxDpCpIrqSetCallbackRef);

	} else {
		/* Write message size and assert the RxStatus READY bit signaling completion */
		XHdcp22Rx_SetRxStatus(InstancePtr, MessageSize,
			InstancePtr->Info.ReauthReq, InstancePtr->Info.TopologyReady);
	}

	/* Start 2 second timer */
	XHdcp22Rx_StartTimer(InstancePtr, XHDCP22_RX_REPEATERAUTH_ACK_INTERVAL, 0);

	/* Log message write completion */
	XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_INFO_MESSAGE, XHDCP22_RX_MSG_ID_REPEATERAUTHSENDRXIDLIST);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
* This function generates the RepeaterAuth_Send_ReceiverID_List message
* and writes it into the read message buffer. After the complete message
* has been written to the buffer the MessageSize and READY fields are set
* in the DDC RxStatus register signaling the transmitter that the message
* is available for reading. When the topology maximums are not exceeded
* VPrime is computed. seq_num_v is incremented after the transmission of
* each RepeaterAuth_Send_ReceiverID_List message. The READY bit in the
* RxStatus register is cleared automatically.
*
* @param    InstancePtr is a pointer to the XHdcp22_Rx core instance.
*
* @return   - XST_SUCCESS if device count is equal to zero.
*           - XST_FAILURE if device count is greater than zero.
*
* @note     The RepeaterAuth_Send_ReceiverID_List must be available
*           and READY bit asserted in the RxStatus register for
*           the upstream transmitter within 3 seconds.
******************************************************************************/
This function generates the RepeaterAuth_Send_ReceiverID_List message
and writes it into the read message buffer. After the complete message
has been written to the buffer the MessageSize and READY fields are set
in the DDC RxStatus register signaling the transmitter that the message
is available for reading. When the topology maximums are not exceeded
VPrime is computed. seq_num_v is incremented after the transmission of
each RepeaterAuth_Send_ReceiverID_List message. The READY bit in the
RxStatus register is cleared automatically.
This function generates the RepeaterAuth_Send_ReceiverID_List message and writes it into the read message buffer . After the complete message has been written to the buffer the MessageSize and READY fields are set in the DDC RxStatus register signaling the transmitter that the message is available for reading . When the topology maximums are not exceeded VPrime is computed . seq_num_v is incremented after the transmission of each RepeaterAuth_Send_ReceiverID_List message . The READY bit in the RxStatus register is cleared automatically .
static int XHdcp22Rx_SendMessageRepeaterAuthSendRxIdList(XHdcp22_Rx *InstancePtr)
{
	Xil_AssertNonvoid(InstancePtr != NULL);
	XHdcp22_Rx_Message *MsgPtr = (XHdcp22_Rx_Message*)InstancePtr->MessageBuffer;
	u32 Offset;
	u32 MessageSize;
	MsgPtr->RepeaterAuthSendRxIdList.MsgId      =
		XHDCP22_RX_MSG_ID_REPEATERAUTHSENDRXIDLIST;
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[0]  =
		(u8)((InstancePtr->Topology.Depth & 0x07) << 1);                    
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[0] |=
		(u8)((InstancePtr->Topology.DeviceCnt & 0x10) >> 4);                
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[1]  =
		(u8)((InstancePtr->Topology.DeviceCnt & 0x0F) << 4);                
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[1] |=
		(u8)((InstancePtr->Topology.MaxDevsExceeded & 0x01) << 3);          
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[1] |=
		(u8)((InstancePtr->Topology.MaxCascadeExceeded & 0x01) << 2);       
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[1] |=
		(u8)((InstancePtr->Topology.Hdcp2LegacyDeviceDownstream & 0x01) << 1); 
	MsgPtr->RepeaterAuthSendRxIdList.RxInfo[1] |=
		(u8)(InstancePtr->Topology.Hdcp1DeviceDownstream & 0x01);           
	MsgPtr->RepeaterAuthSendRxIdList.SeqNumV[0] = (InstancePtr->Info.SeqNumV >> 16) & 0xFF;
	MsgPtr->RepeaterAuthSendRxIdList.SeqNumV[1] = (InstancePtr->Info.SeqNumV >> 8) & 0xFF;
	MsgPtr->RepeaterAuthSendRxIdList.SeqNumV[2] = (InstancePtr->Info.SeqNumV) & 0xFF;
	if(InstancePtr->Topology.MaxDevsExceeded != TRUE &&
		InstancePtr->Topology.MaxCascadeExceeded != TRUE)
	{
		InstancePtr->Info.SeqNumV = (InstancePtr->Info.SeqNumV + 1) % XHDCP22_RX_MAX_SEQNUMV;
		XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_DEBUG, XHDCP22_RX_LOG_DEBUG_COMPUTE_VPRIME);
		XHdcp22Rx_ComputeVPrime((u8 *)InstancePtr->Topology.ReceiverIdList,
			InstancePtr->Topology.DeviceCnt,
			MsgPtr->RepeaterAuthSendRxIdList.RxInfo,
			MsgPtr->RepeaterAuthSendRxIdList.SeqNumV,
			InstancePtr->Params.Km,
			InstancePtr->Params.Rrx,
			InstancePtr->Params.Rtx,
			InstancePtr->Params.VPrime);
		XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_DEBUG, XHDCP22_RX_LOG_DEBUG_COMPUTE_VPRIME_DONE);
		memcpy(MsgPtr->RepeaterAuthSendRxIdList.VPrime, InstancePtr->Params.VPrime, 16);
		memcpy(MsgPtr->RepeaterAuthSendRxIdList.ReceiverIdList,
				InstancePtr->Topology.ReceiverIdList,
				XHDCP22_RX_RCVID_SIZE*InstancePtr->Topology.DeviceCnt);
		MessageSize = 22 + XHDCP22_RX_RCVID_SIZE*InstancePtr->Topology.DeviceCnt;
	}
	else
	{
		MessageSize = 3;
	}
	if (InstancePtr->Config.Protocol == XHDCP22_RX_DP) {
		XHdcp22Rx_Dp_Write_Dpcd_Msg(InstancePtr);
	} else {
		InstancePtr->Handles.DdcSetAddressCallback(InstancePtr->Handles.DdcSetAddressCallbackRef,
			XHDCP22_RX_DDC_READ_REG);
		for(Offset = 0; Offset < MessageSize; Offset++)
		{
			InstancePtr->Handles.DdcSetDataCallback(InstancePtr->Handles.DdcSetDataCallbackRef,
				InstancePtr->MessageBuffer[Offset]);
		}
	}
	InstancePtr->Info.TopologyReady = TRUE;
	if (InstancePtr->Config.Protocol == XHDCP22_RX_DP) {
		u8 rxstatus = RX_STATUS_REPEATER_READY_AVAILABLE;
		InstancePtr->Handles.RxDpAuxWriteCallback(
				InstancePtr->Handles.RxDpAuxWriteCallbackRef,
				RX_STATUS_OFFSET, &rxstatus, 1);
		InstancePtr->Handles.RxDpSetClearAuxDeferCallback(
				InstancePtr->Handles.RxDpSetClearAuxDeferCallbackRef,
				(FALSE));
		InstancePtr->Handles.RxDpCpIrqSetCallback(
				InstancePtr->Handles.RxDpCpIrqSetCallbackRef);
	} else {
		XHdcp22Rx_SetRxStatus(InstancePtr, MessageSize,
			InstancePtr->Info.ReauthReq, InstancePtr->Info.TopologyReady);
	}
	XHdcp22Rx_StartTimer(InstancePtr, XHDCP22_RX_REPEATERAUTH_ACK_INTERVAL, 0);
	XHdcp22Rx_LogWr(InstancePtr, XHDCP22_RX_LOG_EVT_INFO_MESSAGE, XHDCP22_RX_MSG_ID_REPEATERAUTHSENDRXIDLIST);
	return XST_SUCCESS;
}
static int XHdcp22Rx_SendMessageRepeaterAuthSendRxIdList ( XHdcp22_Rx * InstancePtr ) { Xil_AssertNonvoid ( InstancePtr != NULL ) ; XHdcp22_Rx_Message * MsgPtr = ( XHdcp22_Rx_Message * ) InstancePtr -> MessageBuffer ; u32 Offset ; u32 MessageSize ; MsgPtr -> RepeaterAuthSendRxIdList . MsgId = XHDCP22_RX_MSG_ID_REPEATERAUTHSENDRXIDLIST ; MsgPtr -> RepeaterAuthSendRxIdList . RxInfo [ 0 ] = ( u8 ) ( ( InstancePtr -> Topology . Depth & 0x07 ) << 1 ) ; MsgPtr -> RepeaterAuthSendRxIdList . RxInfo [ 0 ] |= ( u8 ) ( ( InstancePtr -> Topology . DeviceCnt & 0x10 ) >> 4 ) ; MsgPtr -> RepeaterAuthSendRxIdList . RxInfo [ 1 ] = ( u8 ) ( ( InstancePtr -> Topology . DeviceCnt & 0x0F ) << 4 ) ; MsgPtr -> RepeaterAuthSendRxIdList . RxInfo [ 1 ] |= ( u8 ) ( ( InstancePtr -> Topology . MaxDevsExceeded & 0x01 ) << 3 ) ; MsgPtr -> RepeaterAuthSendRxIdList . RxInfo [ 1 ] |= ( u8 ) ( ( InstancePtr -> Topology . MaxCascadeExceeded & 0x01 ) << 2 ) ; MsgPtr -> RepeaterAuthSendRxIdList . RxInfo [ 1 ] |= ( u8 ) ( ( InstancePtr -> Topology . Hdcp2LegacyDeviceDownstream & 0x01 ) << 1 ) ; MsgPtr -> RepeaterAuthSendRxIdList . RxInfo [ 1 ] |= ( u8 ) ( InstancePtr -> Topology . Hdcp1DeviceDownstream & 0x01 ) ; MsgPtr -> RepeaterAuthSendRxIdList . SeqNumV [ 0 ] = ( InstancePtr -> Info . SeqNumV >> 16 ) & 0xFF ; MsgPtr -> RepeaterAuthSendRxIdList . SeqNumV [ 1 ] = ( InstancePtr -> Info . SeqNumV >> 8 ) & 0xFF ; MsgPtr -> RepeaterAuthSendRxIdList . SeqNumV [ 2 ] = ( InstancePtr -> Info . SeqNumV ) & 0xFF ; if ( InstancePtr -> Topology . MaxDevsExceeded != TRUE && InstancePtr -> Topology . MaxCascadeExceeded != TRUE ) { InstancePtr -> Info . SeqNumV = ( InstancePtr -> Info . SeqNumV + 1 ) % XHDCP22_RX_MAX_SEQNUMV ; XHdcp22Rx_LogWr ( InstancePtr , XHDCP22_RX_LOG_EVT_DEBUG , XHDCP22_RX_LOG_DEBUG_COMPUTE_VPRIME ) ; XHdcp22Rx_ComputeVPrime ( ( u8 * ) InstancePtr -> Topology . ReceiverIdList , InstancePtr -> Topology . DeviceCnt , MsgPtr -> RepeaterAuthSendRxIdList . RxInfo , MsgPtr -> RepeaterAuthSendRxIdList . SeqNumV , InstancePtr -> Params . Km , InstancePtr -> Params . Rrx , InstancePtr -> Params . Rtx , InstancePtr -> Params . VPrime ) ; XHdcp22Rx_LogWr ( InstancePtr , XHDCP22_RX_LOG_EVT_DEBUG , XHDCP22_RX_LOG_DEBUG_COMPUTE_VPRIME_DONE ) ; memcpy ( MsgPtr -> RepeaterAuthSendRxIdList . VPrime , InstancePtr -> Params . VPrime , 16 ) ; memcpy ( MsgPtr -> RepeaterAuthSendRxIdList . ReceiverIdList , InstancePtr -> Topology . ReceiverIdList , XHDCP22_RX_RCVID_SIZE * InstancePtr -> Topology . DeviceCnt ) ; MessageSize = 22 + XHDCP22_RX_RCVID_SIZE * InstancePtr -> Topology . DeviceCnt ; } else { MessageSize = 3 ; } if ( InstancePtr -> Config . Protocol == XHDCP22_RX_DP ) { XHdcp22Rx_Dp_Write_Dpcd_Msg ( InstancePtr ) ; } else { InstancePtr -> Handles . DdcSetAddressCallback ( InstancePtr -> Handles . DdcSetAddressCallbackRef , XHDCP22_RX_DDC_READ_REG ) ; for ( Offset = 0 ; Offset < MessageSize ; Offset ++ ) { InstancePtr -> Handles . DdcSetDataCallback ( InstancePtr -> Handles . DdcSetDataCallbackRef , InstancePtr -> MessageBuffer [ Offset ] ) ; } } InstancePtr -> Info . TopologyReady = TRUE ; if ( InstancePtr -> Config . Protocol == XHDCP22_RX_DP ) { u8 rxstatus = RX_STATUS_REPEATER_READY_AVAILABLE ; InstancePtr -> Handles . RxDpAuxWriteCallback ( InstancePtr -> Handles . RxDpAuxWriteCallbackRef , RX_STATUS_OFFSET , & rxstatus , 1 ) ; InstancePtr -> Handles . RxDpSetClearAuxDeferCallback ( InstancePtr -> Handles . RxDpSetClearAuxDeferCallbackRef , ( FALSE ) ) ; InstancePtr -> Handles . RxDpCpIrqSetCallback ( InstancePtr -> Handles . RxDpCpIrqSetCallbackRef ) ; } else { XHdcp22Rx_SetRxStatus ( InstancePtr , MessageSize , InstancePtr -> Info . ReauthReq , InstancePtr -> Info . TopologyReady ) ; } XHdcp22Rx_StartTimer ( InstancePtr , XHDCP22_RX_REPEATERAUTH_ACK_INTERVAL , 0 ) ; XHdcp22Rx_LogWr ( InstancePtr , XHDCP22_RX_LOG_EVT_INFO_MESSAGE , XHDCP22_RX_MSG_ID_REPEATERAUTHSENDRXIDLIST ) ; return XST_SUCCESS ; }
This function generates the RepeaterAuth_Send_ReceiverID_List message
and writes it into the read message buffer.
This function generates the RepeaterAuth_Send_ReceiverID_List message and writes it into the read message buffer .
/* Verify arguments */ /* Set message ID */ /* Set RxInfo bit fields */ // RxInfo[11:9] = Depth[2:0] // RxInfo[8]    = DeviceCnt[4] // RxInfo[7:4]  = DeviceCnt[3:0] // RxInfo[3]    = MaxDevsExceeded // RxInfo[2]    = MaxCascadeExceeded // RxInfo[1]    = Hdcp2LegacyDeviceDownstream // RxInfo[0]    = Hdcp1DeviceDownstream /* Set seq_numb_V bytes */ /* Set other message fields
	 * - When topology maximums are not exceeded send seq_num_V, VPrime, and Receiver ID List
	 * - Otherwise, only send RxInfo
	 */ /* Increment seq_num_V count with rollover */ /* Compute VPrime */ /* Copy VPrime[0:16], most significant 128-bits */ /* Copy receiver ID list */ /* Update message size */ /* Update message size */ /*Write message to DPCD registers*/ /* Write message to buffer */ /* Set the TopologyReady flag */ /*Write READY in RxStatus*/ /*Clear AUX_DEFERS for READY message*/ /*raise CP_IRQ*/ /* Write message size and assert the RxStatus READY bit signaling completion */ /* Start 2 second timer */ /* Log message write completion */