1 //<MStar Software> 2 //****************************************************************************** 3 // MStar Software 4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved. 5 // All software, firmware and related documentation herein ("MStar Software") are 6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by 7 // law, including, but not limited to, copyright law and international treaties. 8 // Any use, modification, reproduction, retransmission, or republication of all 9 // or part of MStar Software is expressly prohibited, unless prior written 10 // permission has been granted by MStar. 11 // 12 // By accessing, browsing and/or using MStar Software, you acknowledge that you 13 // have read, understood, and agree, to be bound by below terms ("Terms") and to 14 // comply with all applicable laws and regulations: 15 // 16 // 1. MStar shall retain any and all right, ownership and interest to MStar 17 // Software and any modification/derivatives thereof. 18 // No right, ownership, or interest to MStar Software and any 19 // modification/derivatives thereof is transferred to you under Terms. 20 // 21 // 2. You understand that MStar Software might include, incorporate or be 22 // supplied together with third party`s software and the use of MStar 23 // Software may require additional licenses from third parties. 24 // Therefore, you hereby agree it is your sole responsibility to separately 25 // obtain any and all third party right and license necessary for your use of 26 // such third party`s software. 27 // 28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as 29 // MStar`s confidential information and you agree to keep MStar`s 30 // confidential information in strictest confidence and not disclose to any 31 // third party. 32 // 33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any 34 // kind. Any warranties are hereby expressly disclaimed by MStar, including 35 // without limitation, any warranties of merchantability, non-infringement of 36 // intellectual property rights, fitness for a particular purpose, error free 37 // and in conformity with any international standard. You agree to waive any 38 // claim against MStar for any loss, damage, cost or expense that you may 39 // incur related to your use of MStar Software. 40 // In no event shall MStar be liable for any direct, indirect, incidental or 41 // consequential damages, including without limitation, lost of profit or 42 // revenues, lost or damage of data, and unauthorized system use. 43 // You agree that this Section 4 shall still apply without being affected 44 // even if MStar Software has been modified by MStar in accordance with your 45 // request or instruction for your use, except otherwise agreed by both 46 // parties in writing. 47 // 48 // 5. If requested, MStar may from time to time provide technical supports or 49 // services in relation with MStar Software to you for your use of 50 // MStar Software in conjunction with your or your customer`s product 51 // ("Services"). 52 // You understand and agree that, except otherwise agreed by both parties in 53 // writing, Services are provided on an "AS IS" basis and the warranty 54 // disclaimer set forth in Section 4 above shall apply. 55 // 56 // 6. Nothing contained herein shall be construed as by implication, estoppels 57 // or otherwise: 58 // (a) conferring any license or right to use MStar name, trademark, service 59 // mark, symbol or any other identification; 60 // (b) obligating MStar or any of its affiliates to furnish any person, 61 // including without limitation, you and your customers, any assistance 62 // of any kind whatsoever, or any information; or 63 // (c) conferring any license or right under any intellectual property right. 64 // 65 // 7. These terms shall be governed by and construed in accordance with the laws 66 // of Taiwan, R.O.C., excluding its conflict of law rules. 67 // Any and all dispute arising out hereof or related hereto shall be finally 68 // settled by arbitration referred to the Chinese Arbitration Association, 69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration 70 // Rules of the Association by three (3) arbitrators appointed in accordance 71 // with the said Rules. 72 // The place of arbitration shall be in Taipei, Taiwan and the language shall 73 // be English. 74 // The arbitration award shall be final and binding to both parties. 75 // 76 //****************************************************************************** 77 //<MStar Software> 78 //////////////////////////////////////////////////////////////////////////////// 79 // 80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc. 81 // All rights reserved. 82 // 83 // Unless otherwise stipulated in writing, any and all information contained 84 // herein regardless in any format shall remain the sole proprietary of 85 // MStar Semiconductor Inc. and be kept in strict confidence 86 // ("MStar Confidential Information") by the recipient. 87 // Any unauthorized act including without limitation unauthorized disclosure, 88 // copying, use, reproduction, sale, distribution, modification, disassembling, 89 // reverse engineering and compiling of the contents of MStar Confidential 90 // Information is unlawful and strictly prohibited. MStar hereby reserves the 91 // rights to any and all damages, losses, costs and expenses resulting therefrom. 92 // 93 //////////////////////////////////////////////////////////////////////////////// 94 95 //////////////////////////////////////////////////////////////////////////////////////////////////// 96 /// 97 /// file drvOTV.h 98 /// @brief OTV Driver Interface 99 /// @author MStar Semiconductor,Inc. 100 /// @attention 101 //////////////////////////////////////////////////////////////////////////////////////////////////// 102 103 #ifndef _DRVOTV_H_ 104 #define _DRVOTV_H_ 105 106 #ifdef __cplusplus 107 extern "C" 108 { 109 #endif 110 111 //-------------------------------------------------------------------------------------------------- 112 // Define 113 //-------------------------------------------------------------------------------------------------- 114 115 #define DRVOTV_PID_NULL 0x1FFF // Transport stream null PID 116 117 #define MSIF_OTV_LIB_CODE {'O','T','V'} // Lib code 118 #define MSIF_OTV_LIBVER {'0','2'} // LIB version 119 #define MSIF_OTV_BUILDNUM {'0','0'} // Build Number 120 #define MSIF_OTV_CHANGELIST {'0','0','5','1','1','4','7','0'} // P4 ChangeList Number 121 122 #define OTV_DRV_VERSION /* Character String for DRV/API version */ \ 123 MSIF_TAG, /* 'MSIF' */ \ 124 MSIF_CLASS, /* '00' */ \ 125 MSIF_CUS, /* 0x0000 */ \ 126 MSIF_MOD, /* 0x0000 */ \ 127 MSIF_CHIP, \ 128 MSIF_CPU, \ 129 MSIF_OTV_LIB_CODE, /* IP__ */ \ 130 MSIF_OTV_LIBVER, /* 0.0 ~ Z.Z */ \ 131 MSIF_OTV_BUILDNUM, /* 00 ~ 99 */ \ 132 MSIF_OTV_CHANGELIST, /* CL# */ \ 133 MSIF_OS 134 135 //-------------------------------------------------------------------------------------------------- 136 // Driver Capability 137 //-------------------------------------------------------------------------------------------------- 138 139 //-------------------------------------------------------------------------------------------------- 140 // Type and Structure 141 //-------------------------------------------------------------------------------------------------- 142 143 /// OTV DDI return value 144 /// @name TSP_Result 145 /// @ref TSP_Result 146 /// return value 147 /// @{ 148 149 typedef enum 150 { 151 DRVOTV_FAIL = 0, 152 DRVOTV_OK, 153 DRVOTV_INVALID_PARAM, 154 DRVOTV_FUNC_ERROR, 155 } DrvOTV_Result; 156 157 158 typedef enum 159 { 160 E_DRVOTV_TIME_WATERMARK_50MS = 0, 161 E_DRVOTV_TIME_WATERMARK_200MS = 1, 162 E_DRVOTV_TIME_WATERMARK_500MS = 2, 163 164 }DrvOTV_Time_Watermark; 165 166 167 // DRV OTV HW Interrupt Status 168 #define DRVOTV_HWINT_TYPE MS_U32 169 170 #define E_DRVOTV_HWINT_MASK 0x0000FFFF 171 #define E_DRVOTV_HWINT_EVENT 0x00000001 172 #define E_DRVOTV_HWINT_TIMER 0x00000002 173 #define E_DRVOTV_HWINT_TASKEND 0x00008000 // This is not OTV HWINT, the bit is used to inform OTV ISR task end 174 #define E_DRVOTV_HWINT_MASK_SHIFT 0 175 176 177 #define E_DRVOTV_EVENT_NUM_MASK 0x00FF0000 178 #define E_DRVOTV_EVENT_NUM_MASK_SHIFT 16 179 180 #define E_DRVOTV_ENG_MASK 0xFF000000 181 #define E_DRVOTV_ENG_MASK_SHIFT 24 182 183 184 // DRV OTV Event Type 185 #define DRVOTV_EVENT_TYPE MS_U32 186 187 // Payload/Event Mask flag 188 #define E_DRVOTV_EVENT_MASK 0xffffffff 189 #define E_DRVOTV_EVENT_AFE 0x00000001 // Adaptation Field Extension flag 190 #define E_DRVOTV_EVENT_TPD 0x00000002 // Transport Private Data flag 191 #define E_DRVOTV_EVENT_SP 0x00000004 // Splicing Point flag 192 #define E_DRVOTV_EVENT_OPCR 0x00000008 // OPCR flag 193 #define E_DRVOTV_EVENT_PCR 0x00000010 // PCR flag 194 #define E_DRVOTV_EVENT_ESPI 0x00000020 // Elementary Stream Priority Indicator 195 #define E_DRVOTV_EVENT_RAI 0x00000040 // Random Access Indicator 196 #define E_DRVOTV_EVENT_DI 0x00000080 // Discontinuity Indicator 197 #define E_DRVOTV_EVENT_CESOS 0x00000100 // Change of Elementary Stream to Odd Scrambled 198 #define E_DRVOTV_EVENT_CESES 0x00000200 // Change of Elementary Stream to Even Scrambled 199 #define E_DRVOTV_EVENT_CESNS 0x00000400 // Change of Elementary Stream to Not Scrambled 200 #define E_DRVOTV_EVENT_PUSI 0x00000800 // Payload Unit Start Indicator 201 #define E_DRVOTV_EVENT_FPR 0x00001000 // First Packet Recorded 202 203 204 typedef enum 205 { 206 E_DRVOTV_CAP_FILTER_NUM = 0, // Get filter number 207 E_DRVOTV_CAP_FILTER_PVR_NUM, // Get pvr filter number 208 E_DRVOTV_CAP_PVR_ALIGN, // Get pvr buffer minimal alignment 209 E_DRVOTV_CAP_RESOURCE_SIZE, // Get the data structure size of private resource (share resource) 210 E_DRVOTV_CAP_OTV_NUM, // Get OTV num 211 212 E_DRVOTV_CAP_NULL, 213 } DrvOTV_Cap; 214 215 /// OTV channel state bit flags 216 typedef enum //_DrvTSP_FltState 217 { 218 E_DRVOTV_FLT_STATE_FREE = 0x00000000, ///<\n 219 E_DRVOTV_FLT_STATE_ALLOC = 0x00000001, ///<\n 220 E_DRVOTV_FLT_STATE_ENABLE = 0x00000002, ///<\n 221 E_DRVOTV_FLT_STATE_OVERFLOW = 0x00010000, //[Reserved] 222 E_DRVOTV_FLT_STATE_NA = 0xFFFFFFFF, 223 } DrvOTV_FltState; 224 225 typedef enum 226 { 227 E_DRV_OTV_DBG_LEVEL_NONE, // no debug message shown 228 E_DRV_OTV_DBG_LEVEL_ERR, // only shows error message that can't be recover 229 E_DRV_OTV_DBG_LEVEL_WARN, // error case can be recover, like retry 230 E_DRV_OTV_DBG_LEVEL_EVENT, // event that is okay but better known, ex: timestamp ring, file circular, etc. 231 E_DRV_OTV_DBG_LEVEL_INFO, // information for internal parameter 232 E_DRV_OTV_DBG_LEVEL_FUNC, // Function trace and input parameter trace 233 E_DRV_OTV_DBG_LEVEL_TRACE, // debug trace 234 } DRV_OTV_DBGMSG_LEVEL; 235 236 typedef enum 237 { 238 E_DRV_OTV_DBG_MODEL_NONE, // @temporarily , need to refine 239 E_DRV_OTV_DBG_MODEL_ALL, 240 } DRV_OTV_DBGMSG_MODEL; 241 242 typedef struct //_DrvOTV_Msg 243 {/*//why union? by teddy.chen 244 /// Union data type of message 245 union 246 { 247 /// FltInfo message 248 /// - Byte[0] : Section filter id 249 /// - Byte[1] : TSP id 250 MS_U32 FltInfo; 251 /// PvrBufId 252 /// - Byte[0] : PVR buffer id 253 MS_U32 PvrBufId; 254 }; 255 */ 256 MS_U8 u8PVREngNum; 257 } DrvOTV_Msg; 258 259 260 typedef struct 261 { 262 MS_U32 Event_Descriptor; 263 MS_U16 Pid; 264 MS_U32 PacketNum; 265 MS_U32 Timer; 266 MS_U32 PCR; 267 268 }DrvOTV_EventArray; 269 270 271 /// TSP notification function 272 typedef void (*DrvOTV_NotifyCb)(MS_U32 u32OTV_Eng, DRVOTV_HWINT_TYPE OTV_HWINT, MS_U32 u32EventNum, DrvOTV_EventArray* pstEventArray /*event callback struct*/, void * ); 273 274 275 //-------------------------------------------------------------------------------------------------- 276 // Function Prototype 277 //-------------------------------------------------------------------------------------------------- 278 279 // Initialization API 280 DrvOTV_Result MDrv_OTV_InitLibResource(void* pResMemAddr); 281 DrvOTV_Result MDrv_OTV_Init(void); 282 DrvOTV_Result MDrv_OTV_Exit(void); 283 DrvOTV_Result MDrv_OTV_ISR(MS_U32 u32OTVEng, DRVOTV_HWINT_TYPE HWINT_TYPE); 284 285 //DrvOTV_Result MDrv_OTV_Reset(void); 286 //DrvOTV_Result MDrv_OTV_GetCap(DrvOTV_Cap eCap, void* pOutput); 287 288 // OTV API 289 DrvOTV_Result MDrv_OTV_AllocFlt(MS_U32 u32OTVEng, MS_U32 *pu32FltId); 290 DrvOTV_Result MDrv_OTV_ReleaseFlt(MS_U32 u32OTVEng, MS_U32 u32FltId); 291 DrvOTV_Result MDrv_OTV_SetFltPid(MS_U32 u32OTVEng, MS_U32 u32Fltid, MS_U16 u16Pid); 292 DrvOTV_Result MDrv_OTV_GetFltPid(MS_U32 u32OTVEng, MS_U32 u32Fltid, MS_U16 *pu16Pid); 293 DrvOTV_Result MDrv_OTV_SetFltEvent(MS_U32 u32OTVEng, MS_U32 u32FltId, DRVOTV_EVENT_TYPE eEvent); 294 DrvOTV_Result MDrv_OTV_GetFltEvent(MS_U32 u32OTVEng, MS_U32 u32FltId, DRVOTV_EVENT_TYPE* pEvent); 295 DrvOTV_Result MDrv_OTV_GetCurPktStatus(MS_U32 u32OTVEng, MS_U32* u32PktStamp, MS_U32* u32PktNumber); 296 DrvOTV_Result MDrv_OTV_SetNotifyCb(MS_U32 u32OTVEng, DrvOTV_NotifyCb pfCallback); 297 DrvOTV_Result MDrv_OTV_HWINT_Enable(MS_U32 u32OTVEng, DRVOTV_HWINT_TYPE HWINT_TYPE, MS_BOOL bEnable); 298 DrvOTV_Result MDrv_OTV_HWINT_Get(MS_U32 u32OTVEng, DRVOTV_HWINT_TYPE HWINT_TYPE, MS_BOOL* bInterrupted); 299 DrvOTV_Result MDrv_OTV_HWINT_Clear(MS_U32 u32OTVEng, DRVOTV_HWINT_TYPE HWINT_TYPE); 300 DrvOTV_Result MDrv_OTV_HWINT_SetEvent_Threshold(MS_U32 u32OTVEng, MS_U32 u32Threshold /*Maximum value is 31*/); 301 DrvOTV_Result MDrv_OTV_HWINT_SetTimer_Timeout(MS_U32 u32OTVEng, DrvOTV_Time_Watermark Timeout); 302 DrvOTV_Result MDrv_OTV_SetDbgLevel(DRV_OTV_DBGMSG_LEVEL level, DRV_OTV_DBGMSG_MODEL model); 303 304 #ifdef __cplusplus 305 } // closing brace for extern "C" 306 #endif 307 308 #endif // _DRVOTV_H_ 309