XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_rx.c
int XHdcp1x_RxSetCallback(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;

	/* Check for handler type */
	switch (HandlerType)
	{
		case (XHDCP1X_HANDLER_DDC_SETREGADDR):
			InstancePtr->Rx.DdcSetAddressCallback
				= (XHdcp1x_SetDdcHandler)CallbackFunc;
			InstancePtr->Rx.DdcSetAddressCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsDdcSetAddressCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;

		case (XHDCP1X_HANDLER_DDC_SETREGDATA):
			InstancePtr->Rx.DdcSetDataCallback
				= (XHdcp1x_SetDdcHandler)CallbackFunc;
			InstancePtr->Rx.DdcSetDataCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsDdcSetDataCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;

		case (XHDCP1X_HANDLER_DDC_GETREGDATA):
			InstancePtr->Rx.DdcGetDataCallback
				= (XHdcp1x_GetDdcHandler)CallbackFunc;
			InstancePtr->Rx.DdcGetDataCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsDdcGetDataCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;

		/* Repeater - trigger Downstream Authentication */
		/* Eqilvalent of case
		 * (XHDCP1X_RPTR_HDLR_TRIG_DOWNSTREAM_AUTH):
		 */
		case (XHDCP1X_HANDLER_RPTR_TRIGDWNSTRMAUTH):
			InstancePtr->Rx.RepeaterDownstreamAuthCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Rx.RepeaterDownstreamAuthRef
				= CallbackRef;
			InstancePtr->Rx.IsRepeaterDownstreamAuthCallbackSet
				= (TRUE);
			Status = XST_SUCCESS;
			break;

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

		// unauthenticated
		case (XHDCP1X_HANDLER_UNAUTHENTICATED):
			InstancePtr->Rx.UnauthenticatedCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Rx.UnauthenticatedCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsUnauthenticatedCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;

		// topology updated
		case (XHDCP1X_HANDLER_TOPOLOGY_UPDATE):
			InstancePtr->Rx.TopologyUpdateCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Rx.TopologyUpdateCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsTopologyUpdateCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;

		// encryption updated
		case (XHDCP1X_HANDLER_ENCRYPTION_UPDATE):
			InstancePtr->Rx.EncryptionUpdateCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Rx.EncryptionUpdateCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsEncryptionUpdateCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;

		default:
			Status = XST_INVALID_PARAM;
			break;
	}

	return (Status);
}
/************************** Function Definitions *****************************/
/*****************************************************************************/
/**
* 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.
*
******************************************************************************/
Function Definitions
This function installs callback functions for the given
HandlerType.
Function Definitions This function installs callback functions for the given HandlerType .
int XHdcp1x_RxSetCallback(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;
	switch (HandlerType)
	{
		case (XHDCP1X_HANDLER_DDC_SETREGADDR):
			InstancePtr->Rx.DdcSetAddressCallback
				= (XHdcp1x_SetDdcHandler)CallbackFunc;
			InstancePtr->Rx.DdcSetAddressCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsDdcSetAddressCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;
		case (XHDCP1X_HANDLER_DDC_SETREGDATA):
			InstancePtr->Rx.DdcSetDataCallback
				= (XHdcp1x_SetDdcHandler)CallbackFunc;
			InstancePtr->Rx.DdcSetDataCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsDdcSetDataCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;
		case (XHDCP1X_HANDLER_DDC_GETREGDATA):
			InstancePtr->Rx.DdcGetDataCallback
				= (XHdcp1x_GetDdcHandler)CallbackFunc;
			InstancePtr->Rx.DdcGetDataCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsDdcGetDataCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;
		case (XHDCP1X_HANDLER_RPTR_TRIGDWNSTRMAUTH):
			InstancePtr->Rx.RepeaterDownstreamAuthCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Rx.RepeaterDownstreamAuthRef
				= CallbackRef;
			InstancePtr->Rx.IsRepeaterDownstreamAuthCallbackSet
				= (TRUE);
			Status = XST_SUCCESS;
			break;
		case (XHDCP1X_HANDLER_AUTHENTICATED):
			InstancePtr->Rx.AuthenticatedCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Rx.AuthenticatedCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsAuthenticatedCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;
		case (XHDCP1X_HANDLER_UNAUTHENTICATED):
			InstancePtr->Rx.UnauthenticatedCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Rx.UnauthenticatedCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsUnauthenticatedCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;
		case (XHDCP1X_HANDLER_TOPOLOGY_UPDATE):
			InstancePtr->Rx.TopologyUpdateCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Rx.TopologyUpdateCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsTopologyUpdateCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;
		case (XHDCP1X_HANDLER_ENCRYPTION_UPDATE):
			InstancePtr->Rx.EncryptionUpdateCallback
				= (XHdcp1x_Callback)CallbackFunc;
			InstancePtr->Rx.EncryptionUpdateCallbackRef
				= CallbackRef;
			InstancePtr->Rx.IsEncryptionUpdateCallbackSet = (TRUE);
			Status = XST_SUCCESS;
			break;
		default:
			Status = XST_INVALID_PARAM;
			break;
	}
	return (Status);
}
int XHdcp1x_RxSetCallback ( 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 ; switch ( HandlerType ) { case ( XHDCP1X_HANDLER_DDC_SETREGADDR ) : InstancePtr -> Rx . DdcSetAddressCallback = ( XHdcp1x_SetDdcHandler ) CallbackFunc ; InstancePtr -> Rx . DdcSetAddressCallbackRef = CallbackRef ; InstancePtr -> Rx . IsDdcSetAddressCallbackSet = ( TRUE ) ; Status = XST_SUCCESS ; break ; case ( XHDCP1X_HANDLER_DDC_SETREGDATA ) : InstancePtr -> Rx . DdcSetDataCallback = ( XHdcp1x_SetDdcHandler ) CallbackFunc ; InstancePtr -> Rx . DdcSetDataCallbackRef = CallbackRef ; InstancePtr -> Rx . IsDdcSetDataCallbackSet = ( TRUE ) ; Status = XST_SUCCESS ; break ; case ( XHDCP1X_HANDLER_DDC_GETREGDATA ) : InstancePtr -> Rx . DdcGetDataCallback = ( XHdcp1x_GetDdcHandler ) CallbackFunc ; InstancePtr -> Rx . DdcGetDataCallbackRef = CallbackRef ; InstancePtr -> Rx . IsDdcGetDataCallbackSet = ( TRUE ) ; Status = XST_SUCCESS ; break ; case ( XHDCP1X_HANDLER_RPTR_TRIGDWNSTRMAUTH ) : InstancePtr -> Rx . RepeaterDownstreamAuthCallback = ( XHdcp1x_Callback ) CallbackFunc ; InstancePtr -> Rx . RepeaterDownstreamAuthRef = CallbackRef ; InstancePtr -> Rx . IsRepeaterDownstreamAuthCallbackSet = ( TRUE ) ; Status = XST_SUCCESS ; break ; case ( XHDCP1X_HANDLER_AUTHENTICATED ) : InstancePtr -> Rx . AuthenticatedCallback = ( XHdcp1x_Callback ) CallbackFunc ; InstancePtr -> Rx . AuthenticatedCallbackRef = CallbackRef ; InstancePtr -> Rx . IsAuthenticatedCallbackSet = ( TRUE ) ; Status = XST_SUCCESS ; break ; case ( XHDCP1X_HANDLER_UNAUTHENTICATED ) : InstancePtr -> Rx . UnauthenticatedCallback = ( XHdcp1x_Callback ) CallbackFunc ; InstancePtr -> Rx . UnauthenticatedCallbackRef = CallbackRef ; InstancePtr -> Rx . IsUnauthenticatedCallbackSet = ( TRUE ) ; Status = XST_SUCCESS ; break ; case ( XHDCP1X_HANDLER_TOPOLOGY_UPDATE ) : InstancePtr -> Rx . TopologyUpdateCallback = ( XHdcp1x_Callback ) CallbackFunc ; InstancePtr -> Rx . TopologyUpdateCallbackRef = CallbackRef ; InstancePtr -> Rx . IsTopologyUpdateCallbackSet = ( TRUE ) ; Status = XST_SUCCESS ; break ; case ( XHDCP1X_HANDLER_ENCRYPTION_UPDATE ) : InstancePtr -> Rx . EncryptionUpdateCallback = ( XHdcp1x_Callback ) CallbackFunc ; InstancePtr -> Rx . EncryptionUpdateCallbackRef = CallbackRef ; InstancePtr -> Rx . IsEncryptionUpdateCallbackSet = ( TRUE ) ; Status = XST_SUCCESS ; break ; default : Status = XST_INVALID_PARAM ; break ; } return ( Status ) ; }
Function Definitions
This function installs callback functions for the given
HandlerType:
Function Definitions This function installs callback functions for the given HandlerType :
/* Verify arguments. */ /* Check for handler type */ /* Repeater - trigger Downstream Authentication */ /* Eqilvalent of case
		 * (XHDCP1X_RPTR_HDLR_TRIG_DOWNSTREAM_AUTH):
		 */ // authenticated // unauthenticated // topology updated // encryption updated