XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.c
int XHdcp1x_TxSetCallback(XHdcp1x *InstancePtr,
	XHdcp1x_HandlerType HandlerType, void *CallbackFunc, void *CallbackRef)
{
	/* Verify arguments. */
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(HandlerType > (XHDCP1X_HANDLER_UNDEFINED));
	Xil_AssertNonvoid(HandlerType < (XHDCP1X_HANDLER_INVALID));
	Xil_AssertNonvoid(CallbackFunc != NULL);
	Xil_AssertNonvoid(CallbackRef != NULL);

	u32 Status = XST_NO_DATA;

	/* Check for handler type */
	switch (HandlerType)
	{
		/* DDC write */
		case (XHDCP1X_HANDLER_DDC_WRITE):
			InstancePtr->Tx.DdcWrite
				= (XHdcp1x_RunDdcHandler)CallbackFunc;
			InstancePtr->Tx.DdcWriteRef = CallbackRef;
			InstancePtr->Tx.IsDdcWriteSet = (TRUE);
			Status = (XST_SUCCESS);
			break;

		/* DDC read */
		case (XHDCP1X_HANDLER_DDC_READ):
			InstancePtr->Tx.DdcRead
				= (XHdcp1x_RunDdcHandler)CallbackFunc;
			InstancePtr->Tx.DdcReadRef = CallbackRef;
			InstancePtr->Tx.IsDdcReadSet = (TRUE);
			Status = (XST_SUCCESS);
			break;

		/* Authenticated */
		case (XHDCP1X_HANDLER_AUTHENTICATED):
			InstancePtr->Tx.AuthenticatedCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Tx.AuthenticatedCallbackRef = CallbackRef;
			InstancePtr->Tx.IsAuthenticatedCallbackSet = (TRUE);
			Status = (XST_SUCCESS);
			break;

		/* Repeater - Repeater exchange (values) */
		/* Equivalent of case (XHDCP1X_RPTR_HDLR_REPEATER_EXCHANGE): */
		case (XHDCP1X_HANDLER_RPTR_RPTREXCHANGE):
			InstancePtr->Tx.RepeaterExchangeCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Tx.RepeaterExchangeRef = CallbackRef;
			InstancePtr->Tx.IsRepeaterExchangeCallbackSet = (TRUE);
			break;

		/* Un-authenticated */
		case (XHDCP1X_HANDLER_UNAUTHENTICATED):
			InstancePtr->Tx.UnauthenticatedCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Tx.UnauthenticatedCallbackRef
				= CallbackRef;
			InstancePtr->Tx.IsUnauthenticatedCallbackSet = (TRUE);
			break;

		default:
			Status = (XST_INVALID_PARAM);
			break;
	}

	return (Status);
}
/*****************************************************************************/
/**
* This function installs callback functions for the given
* HandlerType:
*
* @param	InstancePtr is a pointer to the HDCP core instance.
* @param	HandlerType specifies the type of handler.
* @param	CallbackFunc is the address of the callback function.
* @param	CallbackRef is a user data item that will be passed to the
*		callback function when it is invoked.
*
* @return
*		- XST_SUCCESS if callback function installed successfully.
*		- XST_INVALID_PARAM when HandlerType is invalid.
*
* @note		Invoking this function for a handler that already has been
*			installed replaces it with the new handler.
*
******************************************************************************/
This function installs callback functions for the given
HandlerType.
This function installs callback functions for the given HandlerType .
int XHdcp1x_TxSetCallback(XHdcp1x *InstancePtr,
	XHdcp1x_HandlerType HandlerType, void *CallbackFunc, void *CallbackRef)
{
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(HandlerType > (XHDCP1X_HANDLER_UNDEFINED));
	Xil_AssertNonvoid(HandlerType < (XHDCP1X_HANDLER_INVALID));
	Xil_AssertNonvoid(CallbackFunc != NULL);
	Xil_AssertNonvoid(CallbackRef != NULL);
	u32 Status = XST_NO_DATA;
	switch (HandlerType)
	{
		case (XHDCP1X_HANDLER_DDC_WRITE):
			InstancePtr->Tx.DdcWrite
				= (XHdcp1x_RunDdcHandler)CallbackFunc;
			InstancePtr->Tx.DdcWriteRef = CallbackRef;
			InstancePtr->Tx.IsDdcWriteSet = (TRUE);
			Status = (XST_SUCCESS);
			break;
		case (XHDCP1X_HANDLER_DDC_READ):
			InstancePtr->Tx.DdcRead
				= (XHdcp1x_RunDdcHandler)CallbackFunc;
			InstancePtr->Tx.DdcReadRef = CallbackRef;
			InstancePtr->Tx.IsDdcReadSet = (TRUE);
			Status = (XST_SUCCESS);
			break;
		case (XHDCP1X_HANDLER_AUTHENTICATED):
			InstancePtr->Tx.AuthenticatedCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Tx.AuthenticatedCallbackRef = CallbackRef;
			InstancePtr->Tx.IsAuthenticatedCallbackSet = (TRUE);
			Status = (XST_SUCCESS);
			break;
		case (XHDCP1X_HANDLER_RPTR_RPTREXCHANGE):
			InstancePtr->Tx.RepeaterExchangeCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Tx.RepeaterExchangeRef = CallbackRef;
			InstancePtr->Tx.IsRepeaterExchangeCallbackSet = (TRUE);
			break;
		case (XHDCP1X_HANDLER_UNAUTHENTICATED):
			InstancePtr->Tx.UnauthenticatedCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Tx.UnauthenticatedCallbackRef
				= CallbackRef;
			InstancePtr->Tx.IsUnauthenticatedCallbackSet = (TRUE);
			break;
		default:
			Status = (XST_INVALID_PARAM);
			break;
	}
	return (Status);
}
int XHdcp1x_TxSetCallback ( XHdcp1x * InstancePtr , XHdcp1x_HandlerType HandlerType , void * CallbackFunc , void * CallbackRef ) { Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( HandlerType > ( XHDCP1X_HANDLER_UNDEFINED ) ) ; Xil_AssertNonvoid ( HandlerType < ( XHDCP1X_HANDLER_INVALID ) ) ; Xil_AssertNonvoid ( CallbackFunc != NULL ) ; Xil_AssertNonvoid ( CallbackRef != NULL ) ; u32 Status = XST_NO_DATA ; switch ( HandlerType ) { case ( XHDCP1X_HANDLER_DDC_WRITE ) : InstancePtr -> Tx . DdcWrite = ( XHdcp1x_RunDdcHandler ) CallbackFunc ; InstancePtr -> Tx . DdcWriteRef = CallbackRef ; InstancePtr -> Tx . IsDdcWriteSet = ( TRUE ) ; Status = ( XST_SUCCESS ) ; break ; case ( XHDCP1X_HANDLER_DDC_READ ) : InstancePtr -> Tx . DdcRead = ( XHdcp1x_RunDdcHandler ) CallbackFunc ; InstancePtr -> Tx . DdcReadRef = CallbackRef ; InstancePtr -> Tx . IsDdcReadSet = ( TRUE ) ; Status = ( XST_SUCCESS ) ; break ; case ( XHDCP1X_HANDLER_AUTHENTICATED ) : InstancePtr -> Tx . AuthenticatedCallback = ( XHdcp1x_Callback ) CallbackFunc ; InstancePtr -> Tx . AuthenticatedCallbackRef = CallbackRef ; InstancePtr -> Tx . IsAuthenticatedCallbackSet = ( TRUE ) ; Status = ( XST_SUCCESS ) ; break ; case ( XHDCP1X_HANDLER_RPTR_RPTREXCHANGE ) : InstancePtr -> Tx . RepeaterExchangeCallback = ( XHdcp1x_Callback ) CallbackFunc ; InstancePtr -> Tx . RepeaterExchangeRef = CallbackRef ; InstancePtr -> Tx . IsRepeaterExchangeCallbackSet = ( TRUE ) ; break ; case ( XHDCP1X_HANDLER_UNAUTHENTICATED ) : InstancePtr -> Tx . UnauthenticatedCallback = ( XHdcp1x_Callback ) CallbackFunc ; InstancePtr -> Tx . UnauthenticatedCallbackRef = CallbackRef ; InstancePtr -> Tx . IsUnauthenticatedCallbackSet = ( TRUE ) ; break ; default : Status = ( XST_INVALID_PARAM ) ; break ; } return ( Status ) ; }
This function installs callback functions for the given
HandlerType:
This function installs callback functions for the given HandlerType :
/* Verify arguments. */ /* Check for handler type */ /* DDC write */ /* DDC read */ /* Authenticated */ /* Repeater - Repeater exchange (values) */ /* Equivalent of case (XHDCP1X_RPTR_HDLR_REPEATER_EXCHANGE): */ /* Un-authenticated */