/** * * This function installs an asynchronous callback function for the given * HandlerType: * * <pre> * HandlerType Callback Function Type * ---------------------------------------- ----------------------------------- * XDPRXSS_HANDLER_DP_VM_CHG_EVENT XDp_RxSetIntrVmChangeHandler * XDPRXSS_HANDLER_DP_PWR_CHG_EVENT XDp_RxSetIntrPowerStateHandler * XDPRXSS_HANDLER_DP_NO_VID_EVENT XDp_RxSetIntrNoVideoHandler * XDPRXSS_HANDLER_DP_VBLANK_EVENT XDp_RxSetIntrVBlankHandler * XDPRXSS_HANDLER_DP_TLOST_EVENT XDp_RxSetIntrTrainingLostHandler * XDPRXSS_HANDLER_DP_VID_EVENT XDp_RxSetIntrVideoHandler * XDPRXSS_HANDLER_DP_INFO_PKT_EVENT XDp_RxSetIntrInfoPktHandler * XDPRXSS_HANDLER_DP_EXT_PKT_EVENT XDp_RxSetIntrExtPktHandler * XDPRXSS_HANDLER_DP_TDONE_EVENT XDp_RxSetIntrTrainingDoneHandler * XDPRXSS_HANDLER_DP_BW_CHG_EVENT XDp_RxSetIntrBwChangeHandler * XDPRXSS_HANDLER_DP_DWN_REQ_EVENT XDp_RxSetIntrDownReqHandler * XDPRXSS_HANDLER_DP_DWN_REP_EVENT XDp_RxSetIntrDownReplyHandler * XDPRXSS_HANDLER_DP_AUD_OVRFLW_EVENT XDp_RxSetIntrAudioOverHandler * XDPRXSS_HANDLER_DP_PAYLOAD_ALLOC_EVENT XDp_RxSetIntrPayloadAllocHandler * XDPRXSS_HANDLER_DP_ACT_RX_EVENT XDp_RxSetIntrActRxHandler * XDPRXSS_HANDLER_DP_CRC_TEST_EVENT XDp_RxSetIntrCrcTestHandler * XDPRXSS_HANDLER_UNPLUG_EVENT UnplugCallback * XDPRXSS_HANDLER_LINKBW_EVENT LinkBwCallback * XDPRXSS_HANDLER_PLL_RESET_EVENT PllResetCallback * </pre> * * @param InstancePtr is a pointer to the XDpRxSs 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. * ******************************************************************************/ u32 XDpRxSs_SetCallBack(XDpRxSs *InstancePtr, u32 HandlerType, void *CallbackFunc, void *CallbackRef) { u32 Status; /* Verify arguments. */ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); Xil_AssertNonvoid(HandlerType >= XDPRXSS_HANDLER_DP_VM_CHG_EVENT); Xil_AssertNonvoid(CallbackFunc != NULL); Xil_AssertNonvoid(CallbackRef != NULL); /* Assign callback based on handler type */ switch (HandlerType) { case XDPRXSS_HANDLER_DP_VM_CHG_EVENT: XDp_RxSetIntrVmChangeHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_PWR_CHG_EVENT: XDp_RxSetIntrPowerStateHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_NO_VID_EVENT: XDp_RxSetIntrNoVideoHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_VBLANK_EVENT: XDp_RxSetIntrVBlankHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_TLOST_EVENT: XDp_RxSetIntrTrainingLostHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_VID_EVENT: XDp_RxSetIntrVideoHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_INFO_PKT_EVENT: XDp_RxSetIntrInfoPktHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_EXT_PKT_EVENT: XDp_RxSetIntrExtPktHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_TDONE_EVENT: XDp_RxSetIntrTrainingDoneHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_BW_CHG_EVENT: XDp_RxSetIntrBwChangeHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_DWN_REQ_EVENT: XDp_RxSetIntrDownReqHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_DWN_REP_EVENT: XDp_RxSetIntrDownReplyHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_AUD_OVRFLW_EVENT: XDp_RxSetIntrAudioOverHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_PAYLOAD_ALLOC_EVENT: XDp_RxSetIntrPayloadAllocHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_ACT_RX_EVENT: XDp_RxSetIntrActRxHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_DP_CRC_TEST_EVENT: XDp_RxSetIntrCrcTestHandler(InstancePtr->DpPtr, CallbackFunc, CallbackRef); Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_UNPLUG_EVENT: InstancePtr->UnplugCallback = (XDpRxSs_Callback)((void *)CallbackFunc); InstancePtr->UnplugRef = CallbackRef; Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_LINKBW_EVENT: InstancePtr->LinkBwCallback = (XDpRxSs_Callback)((void *)CallbackFunc); InstancePtr->LinkBwRef = CallbackRef; Status = XST_SUCCESS; break; case XDPRXSS_HANDLER_PLL_RESET_EVENT: InstancePtr->PllResetCallback = (XDpRxSs_Callback)((void *)CallbackFunc); InstancePtr->PllResetRef = CallbackRef; Status = XST_SUCCESS; break; default: Status = XST_INVALID_PARAM; break; } return Status; }
/** * This function sets up the interrupt system such that interrupts caused by * Hot-Plug-Detect (HPD) events and pulses are handled. This function is * application-specific for systems that have an interrupt controller connected * to the processor. The user should modify this function to fit the * application. * * @param InstancePtr is a pointer to the XDp instance. * @param IntcPtr is a pointer to the interrupt instance. * @param IntrId is the unique device ID of the interrupt controller. * @param DpIntrId is the interrupt ID of the DisplayPort RX connection to * the interrupt controller. * * @return * - XST_SUCCESS if the interrupt system was successfully set up. * - XST_FAILURE otherwise. * * @note An interrupt controller must be present in the system, connected * to the processor and the DisplayPort RX core. * *******************************************************************************/ static u32 Dprx_SetupInterruptHandler(XDp *InstancePtr, INTC *IntcPtr, u16 IntrId, u16 DpIntrId) { u32 Status; /* Set the HPD interrupt handlers. */ XDp_RxSetIntrVmChangeHandler(InstancePtr, Dprx_InterruptHandlerVmChange, InstancePtr); XDp_RxSetIntrPowerStateHandler(InstancePtr, Dprx_InterruptHandlerPowerState, InstancePtr); XDp_RxSetIntrNoVideoHandler(InstancePtr, Dprx_InterruptHandlerNoVideo, InstancePtr); XDp_RxSetIntrVBlankHandler(InstancePtr, Dprx_InterruptHandlerVBlank, InstancePtr); XDp_RxSetIntrTrainingLostHandler(InstancePtr, Dprx_InterruptHandlerTrainingLost, InstancePtr); XDp_RxSetIntrVideoHandler(InstancePtr, Dprx_InterruptHandlerVideo, InstancePtr); XDp_RxSetIntrTrainingDoneHandler(InstancePtr, Dprx_InterruptHandlerTrainingDone, InstancePtr); XDp_RxSetIntrBwChangeHandler(InstancePtr, Dprx_InterruptHandlerBwChange, InstancePtr); XDp_RxSetIntrTp1Handler(InstancePtr, Dprx_InterruptHandlerTp1, InstancePtr); XDp_RxSetIntrTp2Handler(InstancePtr, Dprx_InterruptHandlerTp2, InstancePtr); XDp_RxSetIntrTp3Handler(InstancePtr, Dprx_InterruptHandlerTp3, InstancePtr); /* Initialize interrupt controller driver. */ #ifdef XPAR_INTC_0_DEVICE_ID Status = XIntc_Initialize(IntcPtr, IntrId); if (Status != XST_SUCCESS) { return XST_FAILURE; } #else XScuGic_Config *IntcConfig; IntcConfig = XScuGic_LookupConfig(IntrId); Status = XScuGic_CfgInitialize(IntcPtr, IntcConfig, IntcConfig->CpuBaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } XScuGic_SetPriorityTriggerType(IntcPtr, DpIntrId, 0xA0, 0x1); #endif /* XPAR_INTC_0_DEVICE_ID */ /* Connect the device driver handler that will be called when an * interrupt for the device occurs, the handler defined above performs * the specific interrupt processing for the device. */ #ifdef XPAR_INTC_0_DEVICE_ID Status = XIntc_Connect(IntcPtr, DpIntrId, (XInterruptHandler)XDp_InterruptHandler, InstancePtr); #else Status = XScuGic_Connect(IntcPtr, DpIntrId, (Xil_InterruptHandler)XDp_InterruptHandler, InstancePtr); #endif /* XPAR_INTC_0_DEVICE_ID */ if (Status != XST_SUCCESS) { return XST_FAILURE; } /* Start the interrupt controller. */ #ifdef XPAR_INTC_0_DEVICE_ID Status = XIntc_Start(IntcPtr, XIN_REAL_MODE); if (Status != XST_SUCCESS) { return XST_FAILURE; } XIntc_Enable(IntcPtr, DpIntrId); #else XScuGic_Enable(IntcPtr, DpIntrId); #endif /* XPAR_INTC_0_DEVICE_ID */ /* Initialize the exception table. */ Xil_ExceptionInit(); /* Register the interrupt controller handler with the exception * table. */ Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)INTC_HANDLER, IntcPtr); /* Enable exceptions. */ Xil_ExceptionEnable(); return XST_SUCCESS; }