00001 /* $Id: */ 00002 /****************************************************************************** 00003 * 00004 * (c) Copyright 2009 - 2010 Xilinx, Inc. All rights reserved. 00005 * 00006 * This file contains confidential and proprietary information 00007 * of Xilinx, Inc. and is protected under U.S. and 00008 * international copyright and other intellectual property 00009 * laws. 00010 * 00011 * DISCLAIMER 00012 * This disclaimer is not a license and does not grant any 00013 * rights to the materials distributed herewith. Except as 00014 * otherwise provided in a valid license issued to you by 00015 * Xilinx, and to the maximum extent permitted by applicable 00016 * law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND 00017 * WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES 00018 * AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING 00019 * BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- 00020 * INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and 00021 * (2) Xilinx shall not be liable (whether in contract or tort, 00022 * including negligence, or under any other theory of 00023 * liability) for any loss or damage of any kind or nature 00024 * related to, arising under or in connection with these 00025 * materials, including for any direct, or any indirect, 00026 * special, incidental, or consequential loss or damage 00027 * (including loss of data, profits, goodwill, or any type of 00028 * loss or damage suffered as a result of any action brought 00029 * by a third party) even if such damage or loss was 00030 * reasonably foreseeable or Xilinx had been advised of the 00031 * possibility of the same. 00032 * 00033 * CRITICAL APPLICATIONS 00034 * Xilinx products are not designed or intended to be fail- 00035 * safe, or for use in any application requiring fail-safe 00036 * performance, such as life-support or safety devices or 00037 * systems, Class III medical devices, nuclear facilities, 00038 * applications related to the deployment of airbags, or any 00039 * other applications that could lead to death, personal 00040 * injury, or severe property or environmental damage 00041 * (individually and collectively, "Critical 00042 * Applications"). Customer assumes the sole risk and 00043 * liability of any use of Xilinx products in Critical 00044 * Applications, subject only to applicable laws and 00045 * regulations governing limitations on product liability. 00046 * 00047 * THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS 00048 * PART OF THIS FILE AT ALL TIMES. 00049 * 00050 ******************************************************************************/ 00051 /*****************************************************************************/ 00052 /** 00053 * 00054 * @file xosd_intr.c 00055 * 00056 * This code contains interrupt related functions of Xilinx MVI Video 00057 * On-Screen-Display device driver. Please see xosd.h for more details of 00058 * the driver. 00059 * 00060 * <pre> 00061 * MODIFICATION HISTORY: 00062 * 00063 * Ver Who Date Changes 00064 * ----- ---- -------- ------------------------------------------------------- 00065 * 1.00a xd 08/18/08 First release 00066 * </pre> 00067 * 00068 ******************************************************************************/ 00069 00070 #include "xosd.h" 00071 00072 /*****************************************************************************/ 00073 /** 00074 * 00075 * This function is the interrupt handler for the On-Screen-Display 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 * XOSD_SetCallBack() during initialization phase. An example delivered with 00085 * this driver demonstrates how this could be done. 00086 * 00087 * @param InstancePtr is a pointer to the XOSD instance that just interrupted. 00088 * @return None. 00089 * @note None. 00090 * 00091 ******************************************************************************/ 00092 void XOSD_IntrHandler(void *InstancePtr) 00093 { 00094 u32 PendingIntr; 00095 u32 ErrorStatus; 00096 XOSD *XOSDPtr; 00097 00098 XOSDPtr = (XOSD *)InstancePtr; 00099 00100 /* Validate parameters */ 00101 XASSERT_VOID(XOSDPtr != NULL); 00102 XASSERT_VOID(XOSDPtr->IsReady == XCOMPONENT_IS_READY); 00103 00104 /* Get pending interrupts */ 00105 PendingIntr = XOSD_IntrGetPending(XOSDPtr); 00106 00107 /* Clear pending interrupts */ 00108 XOSD_IntrClear(XOSDPtr, PendingIntr); 00109 00110 /* Error interrupt is occurring or spurious interrupt */ 00111 if ((0 == (PendingIntr & XOSD_IXR_ALLINTR_MASK)) || 00112 (PendingIntr & XOSD_IXR_ALLIERR_MASK)) { 00113 00114 ErrorStatus = PendingIntr & XOSD_IXR_ALLIERR_MASK; 00115 XOSDPtr->ErrCallBack(XOSDPtr->ErrRef, ErrorStatus); 00116 00117 /* The Error CallBack should reset the device and so 00118 * there is no need to handle other interrupts 00119 */ 00120 return; 00121 } 00122 00123 /* A VBI Start has happened */ 00124 if ((PendingIntr & XOSD_IXR_VBIS_MASK)) 00125 XOSDPtr->VbiStartCallBack(XOSDPtr->VbiStartRef); 00126 00127 /* A VBI End has happened */ 00128 if ((PendingIntr & XOSD_IXR_VBIE_MASK)) 00129 XOSDPtr->VbiEndCallBack(XOSDPtr->VbiEndRef); 00130 00131 /* A Frame Done interrupt has happened */ 00132 if ((PendingIntr & XOSD_IXR_FD_MASK)) 00133 XOSDPtr->FrameDoneCallBack(XOSDPtr->FrameDoneRef); 00134 00135 } 00136 00137 /*****************************************************************************/ 00138 /** 00139 * 00140 * This routine installs an asynchronous callback function for the given 00141 * HandlerType: 00142 * 00143 * <pre> 00144 * HandlerType Callback Function Type 00145 * ----------------------- --------------------------- 00146 * XOSD_HANDLER_VBISTART XOSD_CallBack 00147 * XOSD_HANDLER_VBIEND XOSD_CallBack 00148 * XOSD_HANDLER_FRAMEDONE XOSD_CallBack 00149 * XOSD_HANDLER_ERROR XOSD_ErrCallBack 00150 * 00151 * HandlerType Invoked by this driver when: 00152 * ----------------------- -------------------------------------------------- 00153 * XOSD_HANDLER_VBISTART A Vertical Blank Interval Start Interrupt happens 00154 * XOSD_HANDLER_VBIEND A Vertical Blank Interval End Interrupt happens 00155 * XOSD_HANDLER_FRAMEDONE A Frame Done Interrupt happens 00156 * XOSD_HANDLER_ERROR An error condition happens 00157 * 00158 * </pre> 00159 * 00160 * @param InstancePtr is a pointer to the XOSD instance to be worked on. 00161 * @param HandlerType specifies which callback is to be attached. 00162 * @param CallbackFunc is the address of the callback function. 00163 * @param CallbackRef is a user data item that will be passed to the 00164 * callback function when it is invoked. 00165 * 00166 * @return 00167 * - XST_SUCCESS when handler is installed. 00168 * - XST_INVALID_PARAM when HandlerType is invalid. 00169 * 00170 * @note 00171 * Invoking this function for a handler that already has been installed replaces 00172 * it with the new handler. 00173 * 00174 ******************************************************************************/ 00175 int XOSD_SetCallBack(XOSD *InstancePtr, u32 HandlerType, 00176 void *CallBackFunc, void *CallBackRef) 00177 { 00178 XASSERT_NONVOID(InstancePtr != NULL); 00179 XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY); 00180 XASSERT_NONVOID(CallBackFunc != NULL); 00181 XASSERT_NONVOID(CallBackRef != NULL); 00182 00183 switch (HandlerType) { 00184 case XOSD_HANDLER_VBISTART: 00185 InstancePtr->VbiStartCallBack = (XOSD_CallBack)CallBackFunc; 00186 InstancePtr->VbiStartRef = CallBackRef; 00187 break; 00188 00189 case XOSD_HANDLER_VBIEND: 00190 InstancePtr->VbiEndCallBack = (XOSD_CallBack)CallBackFunc; 00191 InstancePtr->VbiEndRef = CallBackRef; 00192 break; 00193 00194 case XOSD_HANDLER_FRAMEDONE: 00195 InstancePtr->FrameDoneCallBack = (XOSD_CallBack)CallBackFunc; 00196 InstancePtr->FrameDoneRef = CallBackRef; 00197 break; 00198 00199 case XOSD_HANDLER_ERROR: 00200 InstancePtr->ErrCallBack = (XOSD_ErrorCallBack)CallBackFunc; 00201 InstancePtr->ErrRef = CallBackRef; 00202 break; 00203 00204 default: 00205 return XST_INVALID_PARAM; 00206 00207 } 00208 return XST_SUCCESS; 00209 }