XilinxProcessorIPLib/drivers/hdcp22_rx_dp/src/xhdcp22_rx.c
static int XHdcp22Rx_Dp_Read_Dpcd_Msg(XHdcp22_Rx *InstancePtr)
{
	int size = 0;
	u8 buf[XHDCP22_RX_MAX_MESSAGE_SIZE] = {0};
	u32 dpcdflag = InstancePtr->Info.DpcdFlag;
	if (dpcdflag == (XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE |
			XHDCP22_RX_DPCD_FLAG_RPTR_RCVID_LST_ACK_READ_DONE))
	{
		dpcdflag = XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE;
	}

	switch(dpcdflag) {
		case XHDCP22_RX_DPCD_FLAG_AKE_INIT_RCVD:
			/*Read Rtx*/
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					R_TX_OFFSET, buf,
					R_TX_SIZE + TX_CAPS_SIZE);
			/*Put this msg into MsgBuffer*/
			InstancePtr->MessageBuffer[0] =
				XHDCP22_RX_MSG_ID_AKEINIT; /*Refer Note*/
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					R_TX_SIZE + TX_CAPS_SIZE);
			/*This is for Message Id InstancePtr->MessageBuffer[0]*/
			size += 1;
			/*Clear Dpcd flag*/
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_AKE_INIT_RCVD;
			break;
		case XHDCP22_RX_DPCD_FLAG_AKE_NO_STORED_KM_RCVD:
			/*Read Ekpub_Km*/
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					E_KPUB_KM_OFFSET, buf,
					E_KPUB_KM_SIZE);
			/*Put this msg into MsgBuffer*/
			InstancePtr->MessageBuffer[0] =
				XHDCP22_RX_MSG_ID_AKENOSTOREDKM; /*Refer Note*/
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					E_KPUB_KM_SIZE);

			/*This is for Message Id InstancePtr->MessageBuffer[0]*/
			size += 1;
			/*Clear Dpcd flag*/
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_AKE_NO_STORED_KM_RCVD;
			break;
		case XHDCP22_RX_DPCD_FLAG_AKE_STORED_KM_RCVD:
			/*Read Ekh_Km*/
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					E_KH_KM_OFFSET, buf,
					E_KH_KM_SIZE + M_SIZE);
			/*Put this msg into MsgBuffer*/
			InstancePtr->MessageBuffer[0] =
				XHDCP22_RX_MSG_ID_AKESTOREDKM; /*Refer Note*/
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					E_KH_KM_SIZE + M_SIZE);
			/*This is for Message Id InstancePtr->MessageBuffer[0]*/
			size += 1;
			/*Clear Dpcd flag*/
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_AKE_STORED_KM_RCVD;
			break;
		case XHDCP22_RX_DPCD_FLAG_LC_INIT_RCVD:
			/*Read LC_Init*/
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					R_N_OFFSET, buf,
					R_N_SIZE);
			/*Put this msg into MsgBuffer*/
			InstancePtr->MessageBuffer[0] =
				XHDCP22_RX_MSG_ID_LCINIT; /*Refer Note*/
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					R_N_SIZE);
			/*This is for Message Id InstancePtr->MessageBuffer[0]*/
			size += 1;
			/*Clear Dpcd flag*/
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_LC_INIT_RCVD;
			break;
		case XHDCP22_RX_DPCD_FLAG_SKE_SEND_EKS_RCVD:
			/*Read Edkey_ks*/
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					E_DKEY_KS_OFFSET, buf,
					E_DKEY_KS_SIZE + R_IV_SIZE);
			/*Put this msg into MsgBuffer*/
			InstancePtr->MessageBuffer[0] =
				XHDCP22_RX_MSG_ID_SKESENDEKS; /*Refer Note*/
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					E_DKEY_KS_SIZE + R_IV_SIZE);
			/*This is for Message Id InstancePtr->MessageBuffer[0]*/
			size += 1;
			/*Clear Dpcd flag*/
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_SKE_SEND_EKS_RCVD;
			break;
		case XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE:
			/*Read Stream_Manage*/
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					SEQ_NUM_M_OFFSET, buf,
					(SEQ_NUM_M_SIZE + K_SIZE +
					STREAMID_TYPE_SIZE));
			/*Put this msg into MsgBuffer*/
			InstancePtr->MessageBuffer[0] =
					XHDCP22_RX_MSG_ID_REPEATERAUTHSTREAMMANAGE; /*Refer Note*/
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					(SEQ_NUM_M_SIZE + K_SIZE + STREAMID_TYPE_SIZE));
			/*This is for Message Id InstancePtr->MessageBuffer[0]*/
			size += 1;
			/*Clear Dpcd flag*/
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE;
			break;
		case XHDCP22_RX_DPCD_FLAG_RPTR_RCVID_LST_ACK_READ_DONE:
			/*Read RPTR RCVID_LIST_ACK*/
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
						V_OFFSET, buf, V_SIZE);
			/*Put this msg into MsgBuffer*/
			InstancePtr->MessageBuffer[0] =
					XHDCP22_RX_MSG_ID_REPEATERAUTHSENDACK; /*Refer Note*/
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					V_SIZE);
			/*This is for Message Id InstancePtr->MessageBuffer[0]*/
			size += 1;
			/*Clear Dpcd flag*/
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_RPTR_RCVID_LST_ACK_READ_DONE;
			break;
		default:
			break;
	}

	return size;
}
/*****************************************************************************/
/**
 * This function reads a complete message out of the DPCD registers based on
 * the DPCD flag
 *
 * @param	InstancePtr is a pointer to the XHdcp22_Rx core instance.
 *
 * @return	Size of message read out of read message buffer.
 *
 * @note	For DP there are no msg_ids for all the HDCP msgs,
 * 		But to make less changes in the already existed HDCP22
 * 		statmachine which is written for HDMI,
 * 		Assigned msg_ids for each msg rcvd.
 ******************************************************************************/
This function reads a complete message out of the DPCD registers based on
the DPCD flag

@param       InstancePtr is a pointer to the XHdcp22_Rx core instance.

@return      Size of message read out of read message buffer.

@note        For DP there are no msg_ids for all the HDCP msgs,
But to make less changes in the already existed HDCP22
statmachine which is written for HDMI,
Assigned msg_ids for each msg rcvd.
This function reads a complete message out of the DPCD registers based on the DPCD flag @param InstancePtr is a pointer to the XHdcp22_Rx core instance . @return Size of message read out of read message buffer . @note For DP there are no msg_ids for all the HDCP msgs But to make less changes in the already existed HDCP22 statmachine which is written for HDMI Assigned msg_ids for each msg rcvd .
static int XHdcp22Rx_Dp_Read_Dpcd_Msg(XHdcp22_Rx *InstancePtr)
{
	int size = 0;
	u8 buf[XHDCP22_RX_MAX_MESSAGE_SIZE] = {0};
	u32 dpcdflag = InstancePtr->Info.DpcdFlag;
	if (dpcdflag == (XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE |
			XHDCP22_RX_DPCD_FLAG_RPTR_RCVID_LST_ACK_READ_DONE))
	{
		dpcdflag = XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE;
	}
	switch(dpcdflag) {
		case XHDCP22_RX_DPCD_FLAG_AKE_INIT_RCVD:
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					R_TX_OFFSET, buf,
					R_TX_SIZE + TX_CAPS_SIZE);
			InstancePtr->MessageBuffer[0] =
				XHDCP22_RX_MSG_ID_AKEINIT; 
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					R_TX_SIZE + TX_CAPS_SIZE);
			size += 1;
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_AKE_INIT_RCVD;
			break;
		case XHDCP22_RX_DPCD_FLAG_AKE_NO_STORED_KM_RCVD:
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					E_KPUB_KM_OFFSET, buf,
					E_KPUB_KM_SIZE);
			InstancePtr->MessageBuffer[0] =
				XHDCP22_RX_MSG_ID_AKENOSTOREDKM; 
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					E_KPUB_KM_SIZE);
			size += 1;
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_AKE_NO_STORED_KM_RCVD;
			break;
		case XHDCP22_RX_DPCD_FLAG_AKE_STORED_KM_RCVD:
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					E_KH_KM_OFFSET, buf,
					E_KH_KM_SIZE + M_SIZE);
			InstancePtr->MessageBuffer[0] =
				XHDCP22_RX_MSG_ID_AKESTOREDKM; 
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					E_KH_KM_SIZE + M_SIZE);
			size += 1;
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_AKE_STORED_KM_RCVD;
			break;
		case XHDCP22_RX_DPCD_FLAG_LC_INIT_RCVD:
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					R_N_OFFSET, buf,
					R_N_SIZE);
			InstancePtr->MessageBuffer[0] =
				XHDCP22_RX_MSG_ID_LCINIT; 
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					R_N_SIZE);
			size += 1;
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_LC_INIT_RCVD;
			break;
		case XHDCP22_RX_DPCD_FLAG_SKE_SEND_EKS_RCVD:
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					E_DKEY_KS_OFFSET, buf,
					E_DKEY_KS_SIZE + R_IV_SIZE);
			InstancePtr->MessageBuffer[0] =
				XHDCP22_RX_MSG_ID_SKESENDEKS; 
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					E_DKEY_KS_SIZE + R_IV_SIZE);
			size += 1;
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_SKE_SEND_EKS_RCVD;
			break;
		case XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE:
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
					SEQ_NUM_M_OFFSET, buf,
					(SEQ_NUM_M_SIZE + K_SIZE +
					STREAMID_TYPE_SIZE));
			InstancePtr->MessageBuffer[0] =
					XHDCP22_RX_MSG_ID_REPEATERAUTHSTREAMMANAGE; 
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					(SEQ_NUM_M_SIZE + K_SIZE + STREAMID_TYPE_SIZE));
			size += 1;
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE;
			break;
		case XHDCP22_RX_DPCD_FLAG_RPTR_RCVID_LST_ACK_READ_DONE:
			size = InstancePtr->Handles.RxDpAuxReadCallback(
					InstancePtr->Handles.
						RxDpAuxReadCallbackRef,
						V_OFFSET, buf, V_SIZE);
			InstancePtr->MessageBuffer[0] =
					XHDCP22_RX_MSG_ID_REPEATERAUTHSENDACK; 
			memcpy(&InstancePtr->MessageBuffer[1], buf,
					V_SIZE);
			size += 1;
			InstancePtr->Info.DpcdFlag &= ~XHDCP22_RX_DPCD_FLAG_RPTR_RCVID_LST_ACK_READ_DONE;
			break;
		default:
			break;
	}
	return size;
}
static int XHdcp22Rx_Dp_Read_Dpcd_Msg ( XHdcp22_Rx * InstancePtr ) { int size = 0 ; u8 buf [ XHDCP22_RX_MAX_MESSAGE_SIZE ] = { 0 } ; u32 dpcdflag = InstancePtr -> Info . DpcdFlag ; if ( dpcdflag == ( XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE | XHDCP22_RX_DPCD_FLAG_RPTR_RCVID_LST_ACK_READ_DONE ) ) { dpcdflag = XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE ; } switch ( dpcdflag ) { case XHDCP22_RX_DPCD_FLAG_AKE_INIT_RCVD : size = InstancePtr -> Handles . RxDpAuxReadCallback ( InstancePtr -> Handles . RxDpAuxReadCallbackRef , R_TX_OFFSET , buf , R_TX_SIZE + TX_CAPS_SIZE ) ; InstancePtr -> MessageBuffer [ 0 ] = XHDCP22_RX_MSG_ID_AKEINIT ; memcpy ( & InstancePtr -> MessageBuffer [ 1 ] , buf , R_TX_SIZE + TX_CAPS_SIZE ) ; size += 1 ; InstancePtr -> Info . DpcdFlag &= ~ XHDCP22_RX_DPCD_FLAG_AKE_INIT_RCVD ; break ; case XHDCP22_RX_DPCD_FLAG_AKE_NO_STORED_KM_RCVD : size = InstancePtr -> Handles . RxDpAuxReadCallback ( InstancePtr -> Handles . RxDpAuxReadCallbackRef , E_KPUB_KM_OFFSET , buf , E_KPUB_KM_SIZE ) ; InstancePtr -> MessageBuffer [ 0 ] = XHDCP22_RX_MSG_ID_AKENOSTOREDKM ; memcpy ( & InstancePtr -> MessageBuffer [ 1 ] , buf , E_KPUB_KM_SIZE ) ; size += 1 ; InstancePtr -> Info . DpcdFlag &= ~ XHDCP22_RX_DPCD_FLAG_AKE_NO_STORED_KM_RCVD ; break ; case XHDCP22_RX_DPCD_FLAG_AKE_STORED_KM_RCVD : size = InstancePtr -> Handles . RxDpAuxReadCallback ( InstancePtr -> Handles . RxDpAuxReadCallbackRef , E_KH_KM_OFFSET , buf , E_KH_KM_SIZE + M_SIZE ) ; InstancePtr -> MessageBuffer [ 0 ] = XHDCP22_RX_MSG_ID_AKESTOREDKM ; memcpy ( & InstancePtr -> MessageBuffer [ 1 ] , buf , E_KH_KM_SIZE + M_SIZE ) ; size += 1 ; InstancePtr -> Info . DpcdFlag &= ~ XHDCP22_RX_DPCD_FLAG_AKE_STORED_KM_RCVD ; break ; case XHDCP22_RX_DPCD_FLAG_LC_INIT_RCVD : size = InstancePtr -> Handles . RxDpAuxReadCallback ( InstancePtr -> Handles . RxDpAuxReadCallbackRef , R_N_OFFSET , buf , R_N_SIZE ) ; InstancePtr -> MessageBuffer [ 0 ] = XHDCP22_RX_MSG_ID_LCINIT ; memcpy ( & InstancePtr -> MessageBuffer [ 1 ] , buf , R_N_SIZE ) ; size += 1 ; InstancePtr -> Info . DpcdFlag &= ~ XHDCP22_RX_DPCD_FLAG_LC_INIT_RCVD ; break ; case XHDCP22_RX_DPCD_FLAG_SKE_SEND_EKS_RCVD : size = InstancePtr -> Handles . RxDpAuxReadCallback ( InstancePtr -> Handles . RxDpAuxReadCallbackRef , E_DKEY_KS_OFFSET , buf , E_DKEY_KS_SIZE + R_IV_SIZE ) ; InstancePtr -> MessageBuffer [ 0 ] = XHDCP22_RX_MSG_ID_SKESENDEKS ; memcpy ( & InstancePtr -> MessageBuffer [ 1 ] , buf , E_DKEY_KS_SIZE + R_IV_SIZE ) ; size += 1 ; InstancePtr -> Info . DpcdFlag &= ~ XHDCP22_RX_DPCD_FLAG_SKE_SEND_EKS_RCVD ; break ; case XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE : size = InstancePtr -> Handles . RxDpAuxReadCallback ( InstancePtr -> Handles . RxDpAuxReadCallbackRef , SEQ_NUM_M_OFFSET , buf , ( SEQ_NUM_M_SIZE + K_SIZE + STREAMID_TYPE_SIZE ) ) ; InstancePtr -> MessageBuffer [ 0 ] = XHDCP22_RX_MSG_ID_REPEATERAUTHSTREAMMANAGE ; memcpy ( & InstancePtr -> MessageBuffer [ 1 ] , buf , ( SEQ_NUM_M_SIZE + K_SIZE + STREAMID_TYPE_SIZE ) ) ; size += 1 ; InstancePtr -> Info . DpcdFlag &= ~ XHDCP22_RX_DPCD_FLAG_RPTR_STREAM_MANAGE_READ_DONE ; break ; case XHDCP22_RX_DPCD_FLAG_RPTR_RCVID_LST_ACK_READ_DONE : size = InstancePtr -> Handles . RxDpAuxReadCallback ( InstancePtr -> Handles . RxDpAuxReadCallbackRef , V_OFFSET , buf , V_SIZE ) ; InstancePtr -> MessageBuffer [ 0 ] = XHDCP22_RX_MSG_ID_REPEATERAUTHSENDACK ; memcpy ( & InstancePtr -> MessageBuffer [ 1 ] , buf , V_SIZE ) ; size += 1 ; InstancePtr -> Info . DpcdFlag &= ~ XHDCP22_RX_DPCD_FLAG_RPTR_RCVID_LST_ACK_READ_DONE ; break ; default : break ; } return size ; }
This function reads a complete message out of the DPCD registers based on
 the DPCD flag
This function reads a complete message out of the DPCD registers based on the DPCD flag
/*Read Rtx*/ /*Put this msg into MsgBuffer*/ /*Refer Note*/ /*This is for Message Id InstancePtr->MessageBuffer[0]*/ /*Clear Dpcd flag*/ /*Read Ekpub_Km*/ /*Put this msg into MsgBuffer*/ /*Refer Note*/ /*This is for Message Id InstancePtr->MessageBuffer[0]*/ /*Clear Dpcd flag*/ /*Read Ekh_Km*/ /*Put this msg into MsgBuffer*/ /*Refer Note*/ /*This is for Message Id InstancePtr->MessageBuffer[0]*/ /*Clear Dpcd flag*/ /*Read LC_Init*/ /*Put this msg into MsgBuffer*/ /*Refer Note*/ /*This is for Message Id InstancePtr->MessageBuffer[0]*/ /*Clear Dpcd flag*/ /*Read Edkey_ks*/ /*Put this msg into MsgBuffer*/ /*Refer Note*/ /*This is for Message Id InstancePtr->MessageBuffer[0]*/ /*Clear Dpcd flag*/ /*Read Stream_Manage*/ /*Put this msg into MsgBuffer*/ /*Refer Note*/ /*This is for Message Id InstancePtr->MessageBuffer[0]*/ /*Clear Dpcd flag*/ /*Read RPTR RCVID_LIST_ACK*/ /*Put this msg into MsgBuffer*/ /*Refer Note*/ /*This is for Message Id InstancePtr->MessageBuffer[0]*/ /*Clear Dpcd flag*/