XilinxProcessorIPLib/drivers/hdcp22_tx_dp/src/xhdcp22_tx.c
static int XHdcp22Tx_Dp_Write_Dpcd_Msg(XHdcp22_Tx *InstancePtr)
{
	XHdcp22_Tx_DDCMessage buffer;
	int NumWritten = 0;
	int Status = XST_FAILURE;

	/* Verify arguments. */
	Xil_AssertNonvoid(InstancePtr != NULL);

	memcpy(&buffer, InstancePtr->MessageBuffer, sizeof(XHdcp22_Tx_DDCMessage));

	switch (buffer.Message.MsgId) {
		case XHDCP22_TX_AKE_INIT:
			/*Write R_tx*/
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_R_TX_OFFSET,
					buffer.Message.AKEInit.Rtx,
					XHDCP22_TX_DP_HDCPPORT_R_TX_SIZE);
			/*Write TxCaps*/
			NumWritten += InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_TX_CAPS_OFFSET,
					buffer.Message.AKEInit.TxCaps,
					XHDCP22_TX_DP_HDCPPORT_TX_CAPS_SIZE);
			if (NumWritten == (XHDCP22_TX_DP_HDCPPORT_R_TX_SIZE +
					XHDCP22_TX_DP_HDCPPORT_TX_CAPS_SIZE))
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_AKE_NO_STORED_KM:
			/*Write E_kpub_km*/
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_E_KPUB_KM_OFFSET,
					buffer.Message.AKENoStoredKm.EKpubKm,
					XHDCP22_TX_DP_HDCPPORT_E_KPUB_KM_SIZE);
			if (NumWritten == XHDCP22_TX_DP_HDCPPORT_E_KPUB_KM_SIZE)
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_AKE_STORED_KM:
			/*Write Ekh_Km*/
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_E_KH_KM_OFFSET,
					buffer.Message.AKEStoredKm.EKhKm,
					XHDCP22_TX_DP_HDCPPORT_E_KH_KM_SIZE);
			/*Write M*/
			NumWritten += InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_M_OFFSET,
					buffer.Message.AKEStoredKm.Rtx,
					XHDCP22_TX_DP_HDCPPORT_M_SIZE);
			if (NumWritten == (XHDCP22_TX_DP_HDCPPORT_E_KH_KM_SIZE +
						XHDCP22_TX_DP_HDCPPORT_M_SIZE))
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_LC_INIT:
			/*Write Rn*/
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_R_N_OFFSET,
					buffer.Message.LCInit.Rn,
					XHDCP22_TX_DP_HDCPPORT_R_N_SIZE);
			if (NumWritten == XHDCP22_TX_DP_HDCPPORT_R_N_SIZE)
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_SKE_SEND_EKS:
			/*Write E_dkey_Ks*/
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_E_DKEY_KS_OFFSET,
					buffer.Message.SKESendEks.EDkeyKs,
					XHDCP22_TX_DP_HDCPPORT_E_DKEY_KS_SIZE);
			/*Write r_iv*/
			NumWritten += InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_R_IV_OFFSET,
					buffer.Message.SKESendEks.Riv,
					XHDCP22_TX_DP_HDCPPORT_R_IV_SIZE);
			if (NumWritten == (XHDCP22_TX_DP_HDCPPORT_E_DKEY_KS_SIZE +
						XHDCP22_TX_DP_HDCPPORT_R_IV_SIZE))
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_TYPE_VALUE:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_TYPE_VALUE_OFFSET,
					(u8 *)&InstancePtr->Info.ContentStreamType,
					XHDCP22_TX_DP_HDCPPORT_TYPE_VALUE_SIZE);
			if (NumWritten == XHDCP22_TX_DP_HDCPPORT_TYPE_VALUE_SIZE)
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_REPEATAUTH_SEND_ACK:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_V_OFFSET,
					buffer.Message.RepeatAuthSendAck.V,
					XHDCP22_TX_DP_HDCPPORT_V_SIZE);
			if (NumWritten == XHDCP22_TX_DP_HDCPPORT_V_SIZE)
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_REPEATAUTH_STREAM_MANAGE:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_SEQ_NUM_M_OFFSET,
					buffer.Message.RepeatAuthStreamManage.SeqNum_M,
					XHDCP22_TX_DP_HDCPPORT_SEQ_NUM_M_SIZE);
			NumWritten += InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_K_OFFSET,
					buffer.Message.RepeatAuthStreamManage.K,
					XHDCP22_TX_DP_HDCPPORT_K_SIZE);
			NumWritten += InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_STREAM_ID_TYPE_OFFSET,
					buffer.Message.RepeatAuthStreamManage.StreamID_Type,
					XHDCP22_TX_DP_HDCPPORT_STREAM_ID_TYPE_SIZE);
			if (NumWritten == (XHDCP22_TX_DP_HDCPPORT_SEQ_NUM_M_SIZE +
					XHDCP22_TX_DP_HDCPPORT_K_SIZE +
					XHDCP22_TX_DP_HDCPPORT_STREAM_ID_TYPE_SIZE))
				Status = XST_SUCCESS;
			break;
		default:
			xdbg_printf(XDBG_DEBUG_GENERAL,
					"Wrong Msg sending requested (id = %d)"
					"\n\r", buffer.Message.MsgId);
			Status = XST_FAILURE;
			break;
	}

	return Status;
}
/*****************************************************************************/
/**
* This function Writes a complete message into the DPCD registers
* of remote device.
*
* @param	InstancePtr is a pointer to the XHdcp22_Tx core instance.
*
* @return	Size of message written.
*
* @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.
******************************************************************************/
This function Writes a complete message into the DPCD registers
of remote device.
This function Writes a complete message into the DPCD registers of remote device .
static int XHdcp22Tx_Dp_Write_Dpcd_Msg(XHdcp22_Tx *InstancePtr)
{
	XHdcp22_Tx_DDCMessage buffer;
	int NumWritten = 0;
	int Status = XST_FAILURE;
	Xil_AssertNonvoid(InstancePtr != NULL);
	memcpy(&buffer, InstancePtr->MessageBuffer, sizeof(XHdcp22_Tx_DDCMessage));
	switch (buffer.Message.MsgId) {
		case XHDCP22_TX_AKE_INIT:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_R_TX_OFFSET,
					buffer.Message.AKEInit.Rtx,
					XHDCP22_TX_DP_HDCPPORT_R_TX_SIZE);
			NumWritten += InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_TX_CAPS_OFFSET,
					buffer.Message.AKEInit.TxCaps,
					XHDCP22_TX_DP_HDCPPORT_TX_CAPS_SIZE);
			if (NumWritten == (XHDCP22_TX_DP_HDCPPORT_R_TX_SIZE +
					XHDCP22_TX_DP_HDCPPORT_TX_CAPS_SIZE))
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_AKE_NO_STORED_KM:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_E_KPUB_KM_OFFSET,
					buffer.Message.AKENoStoredKm.EKpubKm,
					XHDCP22_TX_DP_HDCPPORT_E_KPUB_KM_SIZE);
			if (NumWritten == XHDCP22_TX_DP_HDCPPORT_E_KPUB_KM_SIZE)
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_AKE_STORED_KM:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_E_KH_KM_OFFSET,
					buffer.Message.AKEStoredKm.EKhKm,
					XHDCP22_TX_DP_HDCPPORT_E_KH_KM_SIZE);
			NumWritten += InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_M_OFFSET,
					buffer.Message.AKEStoredKm.Rtx,
					XHDCP22_TX_DP_HDCPPORT_M_SIZE);
			if (NumWritten == (XHDCP22_TX_DP_HDCPPORT_E_KH_KM_SIZE +
						XHDCP22_TX_DP_HDCPPORT_M_SIZE))
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_LC_INIT:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_R_N_OFFSET,
					buffer.Message.LCInit.Rn,
					XHDCP22_TX_DP_HDCPPORT_R_N_SIZE);
			if (NumWritten == XHDCP22_TX_DP_HDCPPORT_R_N_SIZE)
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_SKE_SEND_EKS:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_E_DKEY_KS_OFFSET,
					buffer.Message.SKESendEks.EDkeyKs,
					XHDCP22_TX_DP_HDCPPORT_E_DKEY_KS_SIZE);
			NumWritten += InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_R_IV_OFFSET,
					buffer.Message.SKESendEks.Riv,
					XHDCP22_TX_DP_HDCPPORT_R_IV_SIZE);
			if (NumWritten == (XHDCP22_TX_DP_HDCPPORT_E_DKEY_KS_SIZE +
						XHDCP22_TX_DP_HDCPPORT_R_IV_SIZE))
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_TYPE_VALUE:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_TYPE_VALUE_OFFSET,
					(u8 *)&InstancePtr->Info.ContentStreamType,
					XHDCP22_TX_DP_HDCPPORT_TYPE_VALUE_SIZE);
			if (NumWritten == XHDCP22_TX_DP_HDCPPORT_TYPE_VALUE_SIZE)
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_REPEATAUTH_SEND_ACK:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_V_OFFSET,
					buffer.Message.RepeatAuthSendAck.V,
					XHDCP22_TX_DP_HDCPPORT_V_SIZE);
			if (NumWritten == XHDCP22_TX_DP_HDCPPORT_V_SIZE)
				Status = XST_SUCCESS;
			break;
		case XHDCP22_TX_REPEATAUTH_STREAM_MANAGE:
			NumWritten = InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_SEQ_NUM_M_OFFSET,
					buffer.Message.RepeatAuthStreamManage.SeqNum_M,
					XHDCP22_TX_DP_HDCPPORT_SEQ_NUM_M_SIZE);
			NumWritten += InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_K_OFFSET,
					buffer.Message.RepeatAuthStreamManage.K,
					XHDCP22_TX_DP_HDCPPORT_K_SIZE);
			NumWritten += InstancePtr->TxDpAuxWriteCallback(
					InstancePtr->TxDpAuxWriteCallbackRef,
					XHDCP22_TX_DP_HDCPPORT_STREAM_ID_TYPE_OFFSET,
					buffer.Message.RepeatAuthStreamManage.StreamID_Type,
					XHDCP22_TX_DP_HDCPPORT_STREAM_ID_TYPE_SIZE);
			if (NumWritten == (XHDCP22_TX_DP_HDCPPORT_SEQ_NUM_M_SIZE +
					XHDCP22_TX_DP_HDCPPORT_K_SIZE +
					XHDCP22_TX_DP_HDCPPORT_STREAM_ID_TYPE_SIZE))
				Status = XST_SUCCESS;
			break;
		default:
			xdbg_printf(XDBG_DEBUG_GENERAL,
					"Wrong Msg sending requested (id = %d)"
					"\n\r", buffer.Message.MsgId);
			Status = XST_FAILURE;
			break;
	}
	return Status;
}
static int XHdcp22Tx_Dp_Write_Dpcd_Msg ( XHdcp22_Tx * InstancePtr ) { XHdcp22_Tx_DDCMessage buffer ; int NumWritten = 0 ; int Status = XST_FAILURE ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; memcpy ( & buffer , InstancePtr -> MessageBuffer , sizeof ( XHdcp22_Tx_DDCMessage ) ) ; switch ( buffer . Message . MsgId ) { case XHDCP22_TX_AKE_INIT : NumWritten = InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_R_TX_OFFSET , buffer . Message . AKEInit . Rtx , XHDCP22_TX_DP_HDCPPORT_R_TX_SIZE ) ; NumWritten += InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_TX_CAPS_OFFSET , buffer . Message . AKEInit . TxCaps , XHDCP22_TX_DP_HDCPPORT_TX_CAPS_SIZE ) ; if ( NumWritten == ( XHDCP22_TX_DP_HDCPPORT_R_TX_SIZE + XHDCP22_TX_DP_HDCPPORT_TX_CAPS_SIZE ) ) Status = XST_SUCCESS ; break ; case XHDCP22_TX_AKE_NO_STORED_KM : NumWritten = InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_E_KPUB_KM_OFFSET , buffer . Message . AKENoStoredKm . EKpubKm , XHDCP22_TX_DP_HDCPPORT_E_KPUB_KM_SIZE ) ; if ( NumWritten == XHDCP22_TX_DP_HDCPPORT_E_KPUB_KM_SIZE ) Status = XST_SUCCESS ; break ; case XHDCP22_TX_AKE_STORED_KM : NumWritten = InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_E_KH_KM_OFFSET , buffer . Message . AKEStoredKm . EKhKm , XHDCP22_TX_DP_HDCPPORT_E_KH_KM_SIZE ) ; NumWritten += InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_M_OFFSET , buffer . Message . AKEStoredKm . Rtx , XHDCP22_TX_DP_HDCPPORT_M_SIZE ) ; if ( NumWritten == ( XHDCP22_TX_DP_HDCPPORT_E_KH_KM_SIZE + XHDCP22_TX_DP_HDCPPORT_M_SIZE ) ) Status = XST_SUCCESS ; break ; case XHDCP22_TX_LC_INIT : NumWritten = InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_R_N_OFFSET , buffer . Message . LCInit . Rn , XHDCP22_TX_DP_HDCPPORT_R_N_SIZE ) ; if ( NumWritten == XHDCP22_TX_DP_HDCPPORT_R_N_SIZE ) Status = XST_SUCCESS ; break ; case XHDCP22_TX_SKE_SEND_EKS : NumWritten = InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_E_DKEY_KS_OFFSET , buffer . Message . SKESendEks . EDkeyKs , XHDCP22_TX_DP_HDCPPORT_E_DKEY_KS_SIZE ) ; NumWritten += InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_R_IV_OFFSET , buffer . Message . SKESendEks . Riv , XHDCP22_TX_DP_HDCPPORT_R_IV_SIZE ) ; if ( NumWritten == ( XHDCP22_TX_DP_HDCPPORT_E_DKEY_KS_SIZE + XHDCP22_TX_DP_HDCPPORT_R_IV_SIZE ) ) Status = XST_SUCCESS ; break ; case XHDCP22_TX_TYPE_VALUE : NumWritten = InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_TYPE_VALUE_OFFSET , ( u8 * ) & InstancePtr -> Info . ContentStreamType , XHDCP22_TX_DP_HDCPPORT_TYPE_VALUE_SIZE ) ; if ( NumWritten == XHDCP22_TX_DP_HDCPPORT_TYPE_VALUE_SIZE ) Status = XST_SUCCESS ; break ; case XHDCP22_TX_REPEATAUTH_SEND_ACK : NumWritten = InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_V_OFFSET , buffer . Message . RepeatAuthSendAck . V , XHDCP22_TX_DP_HDCPPORT_V_SIZE ) ; if ( NumWritten == XHDCP22_TX_DP_HDCPPORT_V_SIZE ) Status = XST_SUCCESS ; break ; case XHDCP22_TX_REPEATAUTH_STREAM_MANAGE : NumWritten = InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_SEQ_NUM_M_OFFSET , buffer . Message . RepeatAuthStreamManage . SeqNum_M , XHDCP22_TX_DP_HDCPPORT_SEQ_NUM_M_SIZE ) ; NumWritten += InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_K_OFFSET , buffer . Message . RepeatAuthStreamManage . K , XHDCP22_TX_DP_HDCPPORT_K_SIZE ) ; NumWritten += InstancePtr -> TxDpAuxWriteCallback ( InstancePtr -> TxDpAuxWriteCallbackRef , XHDCP22_TX_DP_HDCPPORT_STREAM_ID_TYPE_OFFSET , buffer . Message . RepeatAuthStreamManage . StreamID_Type , XHDCP22_TX_DP_HDCPPORT_STREAM_ID_TYPE_SIZE ) ; if ( NumWritten == ( XHDCP22_TX_DP_HDCPPORT_SEQ_NUM_M_SIZE + XHDCP22_TX_DP_HDCPPORT_K_SIZE + XHDCP22_TX_DP_HDCPPORT_STREAM_ID_TYPE_SIZE ) ) Status = XST_SUCCESS ; break ; default : xdbg_printf ( XDBG_DEBUG_GENERAL , " " " \n \r " , buffer . Message . MsgId ) ; Status = XST_FAILURE ; break ; } return Status ; }
This function Writes a complete message into the DPCD registers
of remote device.
This function Writes a complete message into the DPCD registers of remote device .
/* Verify arguments. */ /*Write R_tx*/ /*Write TxCaps*/ /*Write E_kpub_km*/ /*Write Ekh_Km*/ /*Write M*/ /*Write Rn*/ /*Write E_dkey_Ks*/ /*Write r_iv*/