00001 /* $Id: */ 00002 /****************************************************************************** 00003 -- (c) Copyright 2008 - 2011 Xilinx, Inc. All rights reserved. 00004 -- 00005 -- This file contains confidential and proprietary information 00006 -- of Xilinx, Inc. and is protected under U.S. and 00007 -- international copyright and other intellectual property 00008 -- laws. 00009 -- 00010 -- DISCLAIMER 00011 -- This disclaimer is not a license and does not grant any 00012 -- rights to the materials distributed herewith. Except as 00013 -- otherwise provided in a valid license issued to you by 00014 -- Xilinx, and to the maximum extent permitted by applicable 00015 -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND 00016 -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES 00017 -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING 00018 -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- 00019 -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and 00020 -- (2) Xilinx shall not be liable (whether in contract or tort, 00021 -- including negligence, or under any other theory of 00022 -- liability) for any loss or damage of any kind or nature 00023 -- related to, arising under or in connection with these 00024 -- materials, including for any direct, or any indirect, 00025 -- special, incidental, or consequential loss or damage 00026 -- (including loss of data, profits, goodwill, or any type of 00027 -- loss or damage suffered as a result of any action brought 00028 -- by a third party) even if such damage or loss was 00029 -- reasonably foreseeable or Xilinx had been advised of the 00030 -- possibility of the same. 00031 -- 00032 -- CRITICAL APPLICATIONS 00033 -- Xilinx products are not designed or intended to be fail- 00034 -- safe, or for use in any application requiring fail-safe 00035 -- performance, such as life-support or safety devices or 00036 -- systems, Class III medical devices, nuclear facilities, 00037 -- applications related to the deployment of airbags, or any 00038 -- other applications that could lead to death, personal 00039 -- injury, or severe property or environmental damage 00040 -- (individually and collectively, "Critical 00041 -- Applications"). Customer assumes the sole risk and 00042 -- liability of any use of Xilinx products in Critical 00043 -- Applications, subject only to applicable laws and 00044 -- regulations governing limitations on product liability. 00045 -- 00046 -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS 00047 -- PART OF THIS FILE AT ALL TIMES. 00048 ******************************************************************************/ 00049 /*****************************************************************************/ 00050 /** 00051 * 00052 * @file xvtc_intr.c 00053 * 00054 * This code contains interrupt related functions of Xilinx MVI VTC 00055 * device driver. Please see xvtc.h for more details of the driver. 00056 * 00057 * <pre> 00058 * MODIFICATION HISTORY: 00059 * 00060 * Ver Who Date Changes 00061 * ----- ---- -------- ----------------------------------------------- 00062 * 1.00a xd 08/05/08 First release 00063 * 1.01a xd 07/23/10 Added GIER; Added more h/w generic info into 00064 * xparameters.h; Feed callbacks with pending 00065 * interrupt info. Added Doxygen & Version support 00066 * </pre> 00067 * 00068 ******************************************************************************/ 00069 00070 #include "xvtc.h" 00071 00072 /*****************************************************************************/ 00073 /** 00074 * 00075 * This function is the interrupt handler for the VTC driver. 00076 * 00077 * This handler reads the pending interrupt from the IER/ISR, determines the 00078 * source of the interrupts, calls according callbacks, and finally clears the 00079 * interrupts. 00080 * 00081 * The application is responsible for connecting this function to the interrupt 00082 * system. Application beyond this driver is also responsible for providing 00083 * callbacks to handle interrupts and installing the callbacks using 00084 * XVtc_SetCallBack() during initialization phase. An example delivered 00085 * with this driver demonstrates how this could be done. 00086 * 00087 * @param InstancePtr is a pointer to the XVtc instance that just 00088 * interrupted. 00089 * @return None. 00090 * @note None. 00091 * 00092 ******************************************************************************/ 00093 void XVtc_IntrHandler(void *InstancePtr) 00094 { 00095 u32 PendingIntr; 00096 u32 ErrorStatus; 00097 XVtc *XVtcPtr = (XVtc *) InstancePtr; 00098 00099 /* Validate parameters */ 00100 XASSERT_VOID(XVtcPtr != NULL); 00101 XASSERT_VOID(XVtcPtr->IsReady == XCOMPONENT_IS_READY); 00102 00103 /* Get pending interrupts */ 00104 PendingIntr = XVtc_IntrGetPending(XVtcPtr); 00105 00106 /* Clear pending interrupt(s) */ 00107 XVtc_IntrClear(XVtcPtr, PendingIntr); 00108 00109 /* Spurious interrupt has happened */ 00110 if (0 == (PendingIntr | XVTC_IXR_ALLINTR_MASK)) { 00111 ErrorStatus = 0; 00112 XVtcPtr->ErrCallBack(XVtcPtr->ErrRef, ErrorStatus); 00113 return; 00114 } 00115 00116 /* A generator event has happened */ 00117 if ((PendingIntr & XVTC_IXR_G_ALL_MASK)) 00118 XVtcPtr->GeneratorCallBack(XVtcPtr->GeneratorRef, 00119 PendingIntr); 00120 00121 /* A detector event has happened */ 00122 if ((PendingIntr & XVTC_IXR_D_ALL_MASK)) 00123 XVtcPtr->DetectorCallBack(XVtcPtr->DetectorRef, 00124 PendingIntr); 00125 00126 /* A frame sync is done */ 00127 if ((PendingIntr & XVTC_IXR_FSYNCALL_MASK)) 00128 XVtcPtr->FrameSyncCallBack(XVtcPtr->FrameSyncRef, 00129 PendingIntr); 00130 00131 /* A signal lock is detected */ 00132 if ((PendingIntr & XVTC_IXR_LOCKALL_MASK)) 00133 XVtcPtr->LockCallBack(XVtcPtr->LockRef, 00134 PendingIntr); 00135 } 00136 00137 00138 /*****************************************************************************/ 00139 /** 00140 * 00141 * This routine installs an asynchronous callback function for the given 00142 * HandlerType: 00143 * 00144 * <pre> 00145 * HandlerType Callback Function Type 00146 * ----------------------- --------------------------- 00147 * XVTC_HANDLER_FRAMESYNC XVtc_FrameSyncCallBack 00148 * XVTC_HANDLER_LOCK XVtc_LockCallBack 00149 * XVTC_HANDLER_DETECTOR XVtc_DetectorCallBack 00150 * XVTC_HANDLER_GENERATOR XVtc_GeneratorCallBack 00151 * XVTC_HANDLER_ERROR XVtc_ErrCallBack 00152 * 00153 * HandlerType Invoked by this driver when: 00154 * ----------------------- -------------------------------------------------- 00155 * XVTC_HANDLER_FRAMESYNC A frame sync event happens 00156 * XVTC_HANDLER_LOCK A signal lock event happens 00157 * XVTC_HANDLER_DETECTOR A detector related event happens 00158 * XVTC_HANDLER_GENERATOR A generator related event happens 00159 * XVTC_HANDLER_ERROR An error condition happens 00160 * 00161 * </pre> 00162 * 00163 * @param InstancePtr is a pointer to the XVtc instance to be worked 00164 * on. 00165 * @param HandlerType specifies which callback is to be attached. 00166 * @param CallbackFunc is the address of the callback function. 00167 * @param CallbackRef is a user data item that will be passed to the 00168 * callback function when it is invoked. 00169 * 00170 * @return 00171 * - XST_SUCCESS when handler is installed. 00172 * - XST_INVALID_PARAM when HandlerType is invalid. 00173 * 00174 * @note 00175 * Invoking this function for a handler that already has been installed replaces 00176 * it with the new handler. 00177 * 00178 ******************************************************************************/ 00179 int XVtc_SetCallBack(XVtc *InstancePtr, u32 HandlerType, 00180 void *CallBackFunc, void *CallBackRef) 00181 { 00182 XASSERT_NONVOID(InstancePtr != NULL); 00183 XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); 00184 00185 switch (HandlerType) { 00186 case XVTC_HANDLER_FRAMESYNC: 00187 InstancePtr->FrameSyncCallBack = 00188 (XVtc_CallBack) CallBackFunc; 00189 InstancePtr->FrameSyncRef = CallBackRef; 00190 break; 00191 00192 case XVTC_HANDLER_LOCK: 00193 InstancePtr->LockCallBack = (XVtc_CallBack) CallBackFunc; 00194 InstancePtr->LockRef = CallBackRef; 00195 break; 00196 00197 case XVTC_HANDLER_DETECTOR: 00198 InstancePtr->DetectorCallBack = 00199 (XVtc_CallBack) CallBackFunc; 00200 InstancePtr->DetectorRef = CallBackRef; 00201 break; 00202 00203 case XVTC_HANDLER_GENERATOR: 00204 InstancePtr->GeneratorCallBack = 00205 (XVtc_CallBack) CallBackFunc; 00206 InstancePtr->GeneratorRef = CallBackRef; 00207 break; 00208 00209 case XVTC_HANDLER_ERROR: 00210 InstancePtr->ErrCallBack = 00211 (XVtc_ErrorCallBack) CallBackFunc; 00212 InstancePtr->ErrRef = CallBackRef; 00213 break; 00214 00215 default: 00216 return XST_INVALID_PARAM; 00217 00218 } 00219 return XST_SUCCESS; 00220 }