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 #ifndef _MADP_MFE_H_ 79 #define _MADP_MFE_H_ 80 81 #include "MFE_chip.h" 82 #if defined(_MFE_T8_)&&defined(_KERNEL_MODE_) 83 #include "mdrv_mfe_io.h" //include define: _MFE_T8_ _MIPS_PLATFORM_...etc 84 #endif 85 #include "mdrv_mfe_st.h" 86 87 88 89 #ifdef __cplusplus 90 extern "C" 91 { 92 #endif 93 94 //input method: _SCALER_IN_, _FILE_IN_, _YUVGEN_, and _MUXTS_ 95 96 #define _SCALER_IN_ 97 98 // #define _FILE_IN_ 99 //#define _AUDIO_FILE_IN_ 100 //#define _YUVGEN_ 101 102 //#define _MUXTS_ 103 //#define _MUX_WITH_AUDIO_ 104 105 //#define NEW_APVR_INTERFACE 106 107 #define VVOIP_INTERFACE1 108 //#define AUDIO_MUX_DUMP 109 110 //#define _EN_ADP_CRC_ //for testing 111 //#define CRC_Accumulate //acc CRC value for overnight testing 112 //#define DEBUG_GET 113 //#define TIME_MEASURE 114 115 #define MFE_MIU 0 //kernel mode 116 117 #if defined(_YUVGEN_)||defined(_FILE_IN_) 118 #define TARGET_FRAME 10 119 #endif 120 121 #define FRAM_BUF_SIZE 512*1024 //output bsp buffer 122 123 typedef struct _MFE_INPUT_BUF_INFO { 124 MFE_U32 mfe_miu_offset; 125 MFE_U32 mfe_buf_pa_withoffset; 126 MFE_U32 mfe_buf_pa_withoutoffset; 127 MFE_U32 mfe_buf_size; 128 MFE_U32 mfe_buf_va; 129 MFE_U32 mfe_buf_va_end; 130 } MFE_INPUT_BUF_INFO; 131 132 133 #if defined(_YUVGEN_)||defined(_FILE_IN_) 134 // File IN 135 typedef struct _FILE_IN_INFO { 136 FILE *infile; 137 FILE *outfile; 138 int nTotalFramesInFile; // How many frames in the specified file. 139 int nFrameSize; 140 } FILE_IN_INFO; 141 #endif 142 143 #if defined(_MFE_T8_)&&defined(_MIPS_PLATFORM_) 144 #include "MuxCommon.h" 145 #if defined(_KERNEL_MODE_) 146 // #define E_SYS_MMAP_MFE E_SYS_MMAP_M4VE 147 #include "linux/types.h" 148 #define open_dev open 149 //#define MIU_OFFSET 0x0000000000 150 #if MFE_MIU==0 151 #define MIU_OFFSET 0x0000000000 152 #else 153 #define MIU_OFFSET 0x0010000000 154 #endif 155 156 #else 157 #include "MsTypes.h" 158 #define E_SYS_MMAP_MFE 0x02010000//0 159 #define MAdp_MPool_VA2PA(a) MS_VA2PA((MS_U32)(a)) 160 #define MAdp_MPool_PA2KSEG1(a) MS_PA2KSEG1((MS_U32)(a)) 161 #define open_dev(a, b) 1 162 #define MIU_OFFSET 0x18000000 163 #endif 164 165 #else 166 #define open_dev(a, b) 1 167 #include "memmap.h" 168 #define E_SYS_MMAP_MFE 0 169 #define MIU_OFFSET 0x0000000000 170 #ifdef WIN32 171 #include <windows.h> 172 #define usleep(time) Sleep(time) 173 #define MAdp_MPool_VA2PA(a) MAdp_MPool_VA2PA_Win32((U32)(a)) 174 #define MAdp_MPool_PA2KSEG1(a) MAdp_MPool_PA2VA_Win32((U32)(a)) 175 #else 176 #ifndef BOOLEAN 177 #define BOOLEAN bool 178 #endif 179 #define MAdp_MPool_VA2PA(a) (((U32)(a))-MEM_LOGMAPPHY) 180 #define MAdp_MPool_PA2KSEG1(a) (((U32)(a))+MEM_LOGMAPPHY) 181 #endif 182 #endif //defined(_MFE_T8_)&&defined(_MIPS_PLATFORM_) 183 184 #ifdef _MUXTS_ 185 #include "TsMuxer.h" 186 #endif 187 188 #if defined(_MFE_BIG2_)&&defined(_MIPS_PLATFORM_) 189 //#define printf diag_printf 190 #define usleep(time) cyg_thread_delay(time) 191 #endif 192 193 #ifndef MUX 194 #define MUX(a, b, c) ((a) ? (b) : (c)) 195 #endif 196 197 198 #if defined(VVOIP_INTERFACE1) 199 #include "apiVOIPMFE.h" 200 #else 201 #define I_VOP 0 /* vop coding modes */ 202 #define P_VOP 1 203 #define B_VOP 2 204 205 #if defined(NEW_APVR_INTERFACE) 206 207 typedef struct { 208 U32 Currentindex; // range = [0, DIP_DI_BUFFER_COUNT-1], MFE read index. 209 int frame_num; // number of frames in DI buffer. 210 } VENC_INFRAME_INFO; 211 212 213 typedef VENC_INFRAME_INFO* VENC_INFRAME_INFO_PTR; 214 typedef void (*GET_YUVFRAME_FUNC) (void* ppInfo); 215 typedef void (*CLEAR_BUF_STATUS_FUNC) (U16 nFrameCoded,void* ppInfo); 216 typedef void (*GET_AUDIO_DATA_FUNC) (U32 *AudAddr, U32 *AudSize, U32 *AudPTS, U8 *AudFrameCnt); 217 218 #endif 219 220 221 MFE_U32 MAdp_MFE_Init(float frame_rate,int test_case_format,int test_case_num); 222 MFE_BOOL MAdp_MFE_Encode(void/*U8 frc*/); 223 int MAdp_MFE_Finish(void); 224 225 226 #if defined(_MFE_T8_)&& (!defined(_KERNEL_MODE_)) 227 #define MAdp_MPool_Init() 228 int MAdp_MPool_GetBlockVa(MFE_U32 opt, MFE_U32 *buf_start, MFE_U32 *buf_size); 229 #endif 230 231 //set memory addr and size, miu0 or miu1. 232 #if defined(_MFE_T8_)&& (!defined(_KERNEL_MODE_)) 233 int MAdp_MFE_SetBuffInfo(int miu_type,unsigned int mfe_pa_without_offset_addr,unsigned int miu_offset,unsigned int mem_size); 234 #endif 235 236 237 238 #ifdef _MUXTS_ 239 #ifdef DEBUG_READ 240 void MPEG2TS_GetBuffer(U8** ppBuffer, U32* pSize, U32 readall); 241 void MPEG2TS_GetBufferDone(U8* pBuffer); 242 #else 243 void MPEG2TS_GetBuffer(U8** ppBuffer, U8 **ppBufReadPtr, U8 **ppBufWritePtr, IndexRingEntry **ppIndexPtr); 244 void MPEG2TS_GetBufferDone(U8* pNewBufReadPtr, U32 IndexRead); 245 #endif 246 void MAdp_TSMUX_Init(MUX_TYPE MuxType, CodecID VideoType, CodecID AudioType, 247 S32 Width, S32 Height, float Framerate, 248 U8 *g_read_bbuf, IndexRingEntry *g_index_ring, 249 U32 read_bbuf_size, U32 index_ring_size); 250 void MPEG2TS_Set_DownloadPID(U32 VideoPID, U32 AudioPID); 251 // TSMUX will call function provide by APVR adaptation layer instead of calling audio driver directly 252 void MPEG2TS_Init_AudioData_Func(GET_AUDIO_DATA_FUNC getAudioDataCallbackFunc); 253 254 // Related DDI API: DDI_PVR_SetEncodingBitRate 255 // Bitrates to map into PVR_ENCODING_BITRATE_T: 6000000, 5000000, 400000, 3000000, 2000000 256 void MPEG2TS_SetVideoBitrate(U32 bitRate); 257 258 // start/stop MPEG2TS file encoding 259 // Related DDI API: DDI_PVR_StartDownload, DDI_PVR_StopDownload 260 void MPEG2TS_Video_Encode_Enable(BOOL enable); 261 262 // get current I frame buffer information, it will be used to generate thumbnail 263 // Related DDI API: DDI_PVR_GetThumbnail 264 void MPEG2TS_Get_I_Frame(/*YUV420_START***/U32 frameBuf, U32 bufSize, U32* pts); 265 BOOL MPEG2TS_isIFrame_Ready(U32* pts); 266 void MPEG2TS_Init_Buf_Info(U8 frameBufferCount, U16 width, U16 height); 267 268 #endif 269 270 271 #if defined(NEW_APVR_INTERFACE) 272 void MPEG2TS_Init_FrameBuf_Status_Func(GET_YUVFRAME_FUNC getBufStatusCallbackFunc, 273 CLEAR_BUF_STATUS_FUNC clearBufStatusCallbackFunc); 274 #endif 275 276 277 //this function can write data to DRAM. We can use trace32:"data.save" to get data from FPGA to PC. 278 //data pointer, offset of 0x82C00000(physical DRAM addr,size(bytes) ) 279 void MADP_MFE_WRITE(unsigned char* data,unsigned int offset,unsigned int size); 280 281 282 #endif 283 284 285 286 #ifdef __cplusplus 287 } 288 #endif 289 290 #endif 291 292