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 drvNJPD.h 98 /// @brief NJPD Driver Interface 99 /// @author MStar Semiconductor Inc. 100 /////////////////////////////////////////////////////////////////////////////////////////////////// 101 102 #ifndef _DRV_NJPD_H_ 103 #define _DRV_NJPD_H_ 104 105 #include "njpeg_def.h" 106 107 108 #ifdef __cplusplus 109 extern "C" 110 { 111 #endif 112 113 //------------------------------------------------------------------------------------------------- 114 // Macro and Define 115 //------------------------------------------------------------------------------------------------- 116 #define MSIF_NJPD_LIB_CODE {'J','P','D','_'} ///<Lib code 117 #define MSIF_NJPD_LIBVER {'0','1'} ///<LIB version 118 #define MSIF_NJPD_BUILDNUM {'0','3'} ///<Build Number 119 #define MSIF_NJPD_CHANGELIST {'0','0','6','1','6','2','3','3'} ///<P4 ChangeList Number 120 121 122 //------------------------------------------------------------------------------ 123 /// @brief \b NJPD_DRV_VERSION : NJPEG Version 124 //------------------------------------------------------------------------------ 125 #define NJPD_DRV_VERSION /* Character String for DRV/API version */ \ 126 MSIF_TAG, /* 'MSIF' */ \ 127 MSIF_CLASS, /* '00' */ \ 128 MSIF_CUS, /* 0x0000 */ \ 129 MSIF_MOD, /* 0x0000 */ \ 130 MSIF_CHIP, \ 131 MSIF_CPU, \ 132 MSIF_NJPD_LIB_CODE, /* IP__ */ \ 133 MSIF_NJPD_LIBVER, /* 0.0 ~ Z.Z */ \ 134 MSIF_NJPD_BUILDNUM, /* 00 ~ 99 */ \ 135 MSIF_NJPD_CHANGELIST, /* CL# */ \ 136 MSIF_OS 137 138 #if 0 139 #if defined (__aeon__) 140 #define AEON_NON_CACHE_MASK 0x80000000 141 #elif defined (MSOS_TYPE_LINUX) 142 #define AEON_NON_CACHE_MASK 0x0 143 #else 144 #define AEON_NON_CACHE_MASK 0xA0000000 145 #endif 146 #endif 147 148 #define NJPD_BIT(_bit_) (1<<(_bit_)) 149 #define NJPD_BITMASK(_bits_) (NJPD_BIT(((1)?_bits_)+1)-NJPD_BIT(((0)?_bits_))) 150 #define NJPD_OFFSET(x) ((x)<<1) 151 152 /*****************Config Flag*********************/ 153 154 // detail for reg: BK_NJPD_GLOBAL_SETTING00 (0x00) 155 #define NJPD_Y_HSF1 NJPD_BIT(0) 156 #define NJPD_Y_HSF2 NJPD_BIT(1) 157 #define NJPD_Y_VSF2 NJPD_BIT(2) 158 #define NJPD_UV NJPD_BIT(3) 159 #define NJPD_SWRST NJPD_BIT(4) 160 #define NJPD_RST_EN NJPD_BIT(5) 161 #define NJPD_ROI_EN NJPD_BIT(6) 162 #define NJPD_SUVQ NJPD_BIT(7) 163 #define NJPD_SUVH NJPD_BIT(8) 164 #define NJPD_YC_SWAP NJPD_BIT(10) 165 #define NJPD_UV_SWAP NJPD_BIT(11) 166 167 168 // detail for reg: BK_NJPD_GLOBAL_SETTING01 (0x01) 169 #define NJPD_DOWN_SCALE (NJPD_BIT(0) | NJPD_BIT(1)) 170 #define NJPD_SVLD NJPD_BIT(6) 171 #define NJPD_UV_7BIT NJPD_BIT(8) 172 #define NJPD_UV_MSB NJPD_BIT(9) 173 #define NJPD_GTABLE_RST NJPD_BIT(10) 174 #define NJPD_HTABLE_RELOAD_EN NJPD_BIT(11) 175 #define NJPD_GTABLE_RELOAD_EN NJPD_BIT(12) 176 #define NJPD_QTABLE_RELOAD_EN NJPD_BIT(13) 177 178 // detail for reg: BK_NJPD_GLOBAL_SETTING02 (0x02) 179 #define NJPD_TBC_MODE NJPD_BIT(1) 180 #define NJPD_FFD9_EN NJPD_BIT(2) 181 #define NJPD_LITTLE_ENDIAN NJPD_BIT(8) 182 #define NJPD_REMOVE_0xFF00 NJPD_BIT(9) 183 #define NJPD_REMOVE_0xFFFF NJPD_BIT(10) 184 #define NJPD_HUFF_TABLE_ERROR NJPD_BIT(11) 185 #define NJPD_HUFF_DATA_LOSS_ERROR NJPD_BIT(12) 186 #define NJPD_BITSTREAM_LE NJPD_BIT(13) 187 #define NJPD_SRAM_SD_EN NJPD_BIT(15) 188 189 190 // detail for reg: BK_NJPD_WRITE_ONE_CLEAR (0x08) 191 #define NJPD_DECODE_ENABLE NJPD_BIT(0) 192 #define NJPD_TABLE_LOADING_START NJPD_BIT(1) 193 #define NJPD_MIU_PARK NJPD_BIT(2) 194 #define NJPD_MRC0_VALID NJPD_BIT(3) 195 #define NJPD_MRC1_VALID NJPD_BIT(4) 196 #define NJPD_MRC_LAST NJPD_BIT(5) 197 #define NJPD_TBC_EN NJPD_BIT(6) 198 #define NJPD_TBC_DONE_CLR NJPD_BIT(7) 199 #define NJPD_CLEAR_CRC NJPD_BIT(8) 200 #define NJPD_HANDSHAKE_SW_WOC NJPD_BIT(9) 201 202 203 // detail for reg: BK_NJPD_MIU_READ_STATUS (0x0e) 204 #define NJPD_MIU_MRC0_STATUS NJPD_BIT(0) 205 #define NJPD_MIU_MRC1_STATUS NJPD_BIT(1) 206 #define NJPD_MIU_HTABLE_RDY NJPD_BIT(2) 207 #define NJPD_MIU_GTABLE_RDY NJPD_BIT(3) 208 #define NJPD_MIU_QTABLE_RDY NJPD_BIT(4) 209 210 211 // detail for reg: BK_NJPD1_IBUF_READ_LENGTH (0x28) 212 #define NJPD_MIU_SEL_SHIFT 10 213 #define NJPD_MIU_SEL_1_SHIFT 11 214 #define NJPD_MIU_SEL NJPD_BIT(NJPD_MIU_SEL_SHIFT) // this reg only supported in edison/einstein/eiffel 215 #define NJPD_MIU_SEL_1 NJPD_BIT(NJPD_MIU_SEL_1_SHIFT) // this reg only supported in einstein3 216 217 // detail for reg: BK_NJPD_IRQ_CLEAR (0x29) 218 //[0] Decode done event flag 219 //[1] Mini-code error event flag 220 //[2] Inverse scan error event flag 221 //[3] Restart marker error event flag 222 //[4] Restart marker index disorder error event flag 223 //[5] End image error event flag 224 //[6] Read buffer0 empty event flag 225 //[7] Read buffer1 empty event flag 226 //[8] MIU write protect event flag 227 //[9] Data lose error event flag 228 //[10] iBuf table load done flag 229 //[11] Huffman table error 230 231 #define NJPD_EVENT_DECODE_DONE NJPD_BIT(0) 232 #define NJPD_EVENT_MINICODE_ERR NJPD_BIT(1) 233 #define NJPD_EVENT_INV_SCAN_ERR NJPD_BIT(2) 234 #define NJPD_EVENT_RES_MARKER_ERR NJPD_BIT(3) 235 #define NJPD_EVENT_RMID_ERR NJPD_BIT(4) 236 #define NJPD_EVENT_END_IMAGE_ERR NJPD_BIT(5) 237 #define NJPD_EVENT_MRC0_EMPTY NJPD_BIT(6) 238 #define NJPD_EVENT_MRC1_EMPTY NJPD_BIT(7) 239 #define NJPD_EVENT_WRITE_PROTECT NJPD_BIT(8) 240 #define NJPD_EVENT_DATA_LOSS_ERR NJPD_BIT(9) 241 #define NJPD_EVENT_IBUF_LOAD_DONE NJPD_BIT(10) 242 #define NJPD_EVENT_HUFF_TABLE_ERR NJPD_BIT(11) 243 #define NJPD_EVENT_ALL (NJPD_EVENT_DECODE_DONE | NJPD_EVENT_MINICODE_ERR | \ 244 NJPD_EVENT_INV_SCAN_ERR | NJPD_EVENT_RES_MARKER_ERR | NJPD_EVENT_RMID_ERR | \ 245 NJPD_EVENT_END_IMAGE_ERR | NJPD_EVENT_MRC0_EMPTY | NJPD_EVENT_MRC1_EMPTY | \ 246 NJPD_EVENT_WRITE_PROTECT | NJPD_EVENT_DATA_LOSS_ERR | \ 247 NJPD_EVENT_IBUF_LOAD_DONE | NJPD_EVENT_HUFF_TABLE_ERR) 248 249 #define NJPD_EVENT_ERROR ( NJPD_EVENT_MINICODE_ERR | NJPD_EVENT_INV_SCAN_ERR | \ 250 NJPD_EVENT_RES_MARKER_ERR | NJPD_EVENT_RMID_ERR | NJPD_EVENT_END_IMAGE_ERR | \ 251 NJPD_EVENT_DATA_LOSS_ERR | NJPD_EVENT_HUFF_TABLE_ERR) 252 253 254 // detail for reg: BK_NJPD_TBC (0x40) 255 #define NJPD_JPD_TBC_RW NJPD_BIT(0) 256 #define NJPD_JPD_TBC_SEL (NJPD_BIT(1) | NJPD_BIT(2)) 257 #define NJPD_JPD_TBC_TABLE_READ NJPD_BIT(4) 258 #define NJPD_JPD_TBC_ADR (NJPD_BIT(8) | NJPD_BIT(9) | NJPD_BIT(10) | NJPD_BIT(11) | NJPD_BIT(12) | NJPD_BIT(13) | NJPD_BIT(14) | NJPD_BIT(15)) 259 260 261 // detail for reg: BK_NJPD2_MARB_SETTING_06 (0x56) 262 #define NJPD_JPD_MARB_MRPRIORITY_SW (NJPD_BIT(0) | NJPD_BIT(1)) 263 264 // detail for reg: BK_NJPD2_MARB_SETTING_07 (0x57) 265 #define NJPD_JPD_MARB_BURST_SPLIT (NJPD_BIT(12) | NJPD_BIT(13)) 266 267 268 // detail for reg: BK_NJPD_MARB_LBOUND_0_H (0x5b) 269 #define NJPD_MARB_MIU_BOUND_EN_0 NJPD_BIT(13) 270 271 272 273 // detail for reg: BK_NJPD_TOP_MARB_PORT_ENABLE (0x76) 274 #define NJPD_TOP_MARB_P0_ENABLE NJPD_BIT(0) 275 #define NJPD_TOP_MARB_P1_ENABLE NJPD_BIT(1) 276 #define NJPD_TOP_MARB_P2_ENABLE NJPD_BIT(2) 277 #define NJPD_TOP_MARB_P0_W_BYPASS_ENABLE NJPD_BIT(4) 278 #define NJPD_TOP_MARB_P1_W_BYPASS_ENABLE NJPD_BIT(5) 279 #define NJPD_TOP_MARB_P2_W_BYPASS_ENABLE NJPD_BIT(6) 280 #define NJPD_TOP_MARB_P0_R_BYPASS_ENABLE NJPD_BIT(7) 281 #define NJPD_TOP_MARB_P1_R_BYPASS_ENABLE NJPD_BIT(0) // second byte 282 #define NJPD_TOP_MARB_P2_R_BYPASS_ENABLE NJPD_BIT(1) // second byte 283 284 //------------------------------------------------------------------------------------------------- 285 // Type and Structure 286 //------------------------------------------------------------------------------------------------- 287 288 typedef enum 289 { 290 E_HVD_FW_INPUT_SOURCE_NONE, ///< No input fw. 291 E_HVD_FW_INPUT_SOURCE_DRAM, ///< input source from DRAM. 292 E_HVD_FW_INPUT_SOURCE_FLASH, ///< input source from FLASH. 293 } HVD_FWInputSourceType; 294 295 // Chip Define 296 typedef enum 297 { 298 E_MJPEG_MSTAR_CHIP_NONE = 0, 299 E_MJPEG_MSTAR_CHIP_U3, 300 E_MJPEG_MSTAR_CHIP_T3, 301 E_MJPEG_MSTAR_CHIP_T4, 302 E_MJPEG_MSTAR_CHIP_JANUS, 303 E_MJPEG_MSTAR_CHIP_U4, 304 E_MJPEG_MSTAR_CHIP_T8, 305 E_MJPEG_MSTAR_CHIP_T9, 306 E_MJPEG_MSTAR_CHIP_T13, 307 E_MJPEG_MSTAR_CHIP_A1, 308 E_MJPEG_MSTAR_CHIP_A6, 309 E_MJPEG_MSTAR_CHIP_A7, 310 E_MJPEG_MSTAR_CHIP_AMETHYST, 311 E_MJPEG_MSTAR_CHIP_EAGLE, 312 E_MJPEG_MSTAR_CHIP_J2, 313 E_MJPEG_MSTAR_CHIP_EMERALD, 314 E_MJPEG_MSTAR_CHIP_NUGGET, 315 E_MJPEG_MSTAR_CHIP_NIKON, 316 } MJPEG_MSTAR_CHIP_ID; 317 318 typedef enum 319 { 320 E_NJPD_EVENT_DEC_NONE = 0x00 321 , E_NJPD_EVENT_DEC_DONE = 0x01 322 , E_NJPD_EVENT_MINICODE_ERR = 0x02 323 , E_NJPD_EVENT_INV_SCAN_ERR = 0x04 324 , E_NJPD_EVENT_RES_MARKER_ERR = 0x08 325 , E_NJPD_EVENT_RMID_ERR = 0x10 326 327 , E_NJPD_EVENT_END_IMAGE_ERR = 0x20 328 , E_NJPD_EVENT_MRC0_EMPTY = 0x40 329 , E_NJPD_EVENT_MRC1_EMPTY = 0x80 330 , E_NJPD_EVENT_WRITE_PROTECT = 0x100 331 , E_NJPD_EVENT_DATA_LOSS_ERR = 0x200 332 333 , E_NJPD_EVENT_IBUF_LOAD_DONE = 0x400 334 , E_NJPD_EVENT_HUFF_TABLE_ERR = 0x800 335 } NJPD_Event; 336 337 338 // NJPD Downscale Ratio 339 // Bellows are 1, 1/2, 1/4 and 1/8 in order 340 typedef enum 341 { 342 E_NJPD_DOWNSCALE_ORG = 0x00 343 , E_NJPD_DOWNSCALE_HALF = 0x01 344 , E_NJPD_DOWNSCALE_FOURTH = 0x02 345 , E_NJPD_DOWNSCALE_EIGHTH = 0x03 346 } NJPD_DownScale; 347 348 // Mimic fwNJPD_if.h 349 typedef enum 350 { 351 // Invalid cmd 352 E_MJPEG_CMD_INVALID = 0xffffffffUL, 353 354 E_MJPEG_CMD_GO = 0x00, // Start to show 355 E_MJPEG_CMD_SET_FRAME_BUFF_START_ADDR = 0x01, // Set frame buffer address 356 E_MJPEG_CMD_SET_FRAME_BUFF_UNIT_SIZE = 0x02, // Set frame buffer size 357 E_MJPEG_CMD_SET_FRAME_BUFF_TOTAL_NUM = 0x03, // Set total number of frame buffer 358 E_MJPEG_CMD_SET_FRAME_BUFF_IDX = 0x04, // Set frame buffer index 359 E_MJPEG_CMD_SET_FRAME_BUFF_IDX_READY = 0x05, // Set frame buffer index ready for display 360 E_MJPEG_CMD_SET_WIDTH = 0x06, // Set frame width 361 E_MJPEG_CMD_SET_HEIGHT = 0x07, // Set frame height 362 E_MJPEG_CMD_SET_PITCH = 0x08, // Set pitch 363 E_MJPEG_CMD_SET_FRAME_ID_L = 0x09, // Set frame ID_L 364 E_MJPEG_CMD_SET_FRAME_ID_H = 0x0A, // Set frame ID_H 365 E_MJPEG_CMD_SET_TIMESTAMP = 0x0B, // Set Time Stamp 366 E_MJPEG_CMD_SET_FRAMERATE = 0x0C, // Set FrameRate 367 E_MJPEG_CMD_SET_FRAMERATE_BASE = 0x0D, // Set FrameRate Base 368 E_MJPEG_CMD_SET_FRAME_BUFF_IDX_VALID = 0x0E, // Set frame buffer index available 369 E_MJPEG_CMD_SET_CHIP_ID = 0x0F, // Set frame buffer index available 370 371 E_MJPEG_CMD_PLAY = 0x20, // Play 372 E_MJPEG_CMD_PAUSE = 0x21, // Pause 373 E_MJPEG_CMD_RESUME = 0x22, // Resume 374 E_MJPEG_CMD_STEP_PLAY = 0x23, // Step play 375 E_MJPEG_CMD_SET_SPEED_TYPE = 0x24, // Set play speed type: default, fast, slow 376 E_MJPEG_CMD_SET_SPEED = 0x25, // Set play speed 377 E_MJPEG_CMD_FLUSH_DISP_QUEUE = 0X26, // Flush display queue 378 E_MJPEG_CMD_FREEZE_DISP = 0x27, // Freeze display 379 E_MJPEG_CMD_ENABLE_AVSYNC = 0x28, // Enable AV sync 380 E_MJPEG_CMD_SET_AVSYNC_DELAY = 0x29, // Set AV sync delay 381 E_MJPEG_CMD_SET_AVSYNC_TOLERENCE = 0x2A, // Set AV sync tolerence 382 E_MJPEG_CMD_SET_PTS_BASE = 0x2B, // Set PTS base 383 E_MJPEG_CMD_SET_STC_BASE = 0x2C, // Set STC base 384 E_MJPEG_CMD_SET_BLUE_SCREEN = 0x2D, // Set Blue Screen 385 E_MJPEG_CMD_PUSH_QUEUE_PARA_SETTING = 0x2E, 386 E_MJPEG_CMD_SET_DISPLAY_OUTSIDE_MODE = 0x2F, 387 388 E_MJPEG_CMD_GET_NEXT_FREE_FRAME_BUFF_IDX = 0x40, // Get next free frame buffer index 389 E_MJPEG_CMD_COMPENSATE_PTS = 0x41, // Ask firmware to compensate PTS 390 391 // Display Command Queue 392 E_MJPEG_CMD_ENABLE_DISP_CMD_QUEUE = 0x80, // Enable Display Command Queue 393 E_MJPEG_CMD_PUSH_DISP_CMD = 0x81, // Push Display Command 394 E_MJPEG_CMD_GET_DISP_CMD_Q_VACANCY = 0x82, // Check if the display command queue full or not 395 396 E_MJPEG_CMD_IS_STEP_PLAY_DONE = 0xFF, // 397 E_MJPEG_CMD_IS_DISP_FINISH = 0xFE, // 398 E_MJPEG_CMD_IS_PLAYING = 0xFC, // 399 E_MJPEG_CMD_IS_DISPLAY_QUEUE_FULL = 0xFB, // 400 E_MJPEG_CMD_IS_AVSYNC_ON = 0xFA, // 401 E_MJPEG_CMD_IS_REACH_AVSYNC = 0xF9, // 402 E_MJPEG_CMD_IS_FLUSH_DONE = 0xF8, // Check if flush done 403 404 } MJPEG_User_Cmd; 405 406 // NJPD debug level enum 407 typedef enum 408 { 409 E_NJPD_DEBUG_DRV_NONE = 0x0 410 , E_NJPD_DEBUG_DRV_MSG = 0x02 411 , E_NJPD_DEBUG_DRV_ERR = 0x08 412 } NJPD_DrvDbgLevel; 413 414 typedef enum 415 { 416 E_NJPD_FAILED = 0 417 , E_NJPD_OK = 1 418 , E_NJPD_INVALID_PARAM = 2 419 } NJPD_Return; 420 421 typedef enum 422 { 423 E_SCALING_ORG = 0 424 , E_SCALING_1_2 = 1 425 , E_SCALING_1_4 = 2 426 , E_SCALING_1_8 = 3 427 } NJPD_SCALING_DOWN_FACTOR; 428 429 /// frame information 430 typedef struct 431 { 432 MS_PHY u32LumaAddr; /// frame buffer base + the start offset of current displayed luma data. Unit: byte. 433 MS_PHY u32ChromaAddr; /// frame buffer base + the start offset of current displayed chroma data. Unit: byte. 434 MS_U32 u32TimeStamp; /// Time stamp(DTS, PTS) of current displayed frame. Unit: ms (todo: 90khz) 435 MS_U32 u32ID_L; /// low part of ID number 436 MS_U32 u32ID_H; /// high part of ID number 437 MS_U16 u16Pitch; /// pitch 438 MS_U16 u16Width; /// width 439 MS_U16 u16Height; /// hight 440 MS_U32 eFrameType;///< Frame type: I, P, B frame 441 } MJPEG_DRV_FrameInfo; 442 443 typedef enum 444 { 445 E_MJPEG_DRV_STREAM_NONE = 0, 446 E_MJPEG_DRV_MAIN_STREAM, 447 E_MJPEG_DRV_SUB_STREAM 448 } MJPEG_DRV_StreamType; 449 450 typedef enum 451 { 452 E_NJPD_NJPD1, 453 E_NJPD_NJPD2, 454 E_NJPD_NJPD_TOTAL, // Do not remove this one 455 E_NJPD_MJPEG_ON =0xcc, 456 E_NJPD_MJPEG_OFF=0xdd, 457 } JPD_Number; 458 459 // NJPD Interrupt Register Function 460 typedef void (*NJPD_IsrFuncCb)(void); 461 462 //------------------------------------------------------------------------------ 463 // Structure for buffer 464 typedef struct 465 { 466 MS_PHY u32ThumbnailBufAddr; 467 MS_U32 u32ThumbnailBufSize; 468 MS_U32 u32ThumbnailBufOffset; 469 MS_PHY u32MRCBufAddr; // MRC buffer address 470 MS_U32 u32MRCBufSize; // MRC buffer size 471 MS_U32 u32MRCBufOffset; // MRC access byte address offset in MRC buffer relative to MRC start address 472 MS_PHY u32MWCBufAddr; // MWC buffer address 473 MS_U16 u16MWCBufLineNum; // MWC Line number 474 MS_BOOL bProgressive; 475 MS_BOOL bThumbnailAccessMode; 476 } NJPD_BufCfg; 477 //------------------------------------------------------------------------------ 478 // Structure for Grpinf of Table IndirectAccess 479 typedef struct 480 { 481 MS_U8 *u8DcLumaValid; 482 MS_U8 *u8DcLumaSymbol; 483 MS_U16 *u16DcLumaCode; 484 MS_U8 *u8DcChromaValid; 485 MS_U8 *u8DcChromaSymbol; 486 MS_U16 *u16DcChromaCode; 487 MS_U8 *u8DcChroma2Valid; 488 MS_U8 *u8DcChroma2Symbol; 489 MS_U16 *u16DcChroma2Code; 490 MS_U8 *u8AcLumaValid; 491 MS_U8 *u8AcLumaSymbol; 492 MS_U16 *u16AcLumaCode; 493 MS_U8 *u8AcChromaValid; 494 MS_U8 *u8AcChromaSymbol; 495 MS_U16 *u16AcChromaCode; 496 MS_U8 *u8AcChroma2Valid; 497 MS_U8 *u8AcChroma2Symbol; 498 MS_U16 *u16AcChroma2Code; 499 MS_BOOL DHT; 500 MS_BOOL bUVHuffman; 501 MS_U8 u8DcLumaCnt; 502 MS_U8 u8DcChromaCnt; 503 MS_U8 u8DcChroma2Cnt; 504 MS_U8 u8AcLumaCnt; 505 MS_U8 u8AcChromaCnt; 506 MS_U8 u8AcChroma2Cnt; 507 } NJPD_Grpinf; 508 //------------------------------------------------------------------------------ 509 // Structure for Symidx of Table Indirect Access 510 typedef struct 511 { 512 MS_U8 *u8DcLumaHuffVal; 513 MS_U8 *u8DcChromaHuffVal; 514 MS_U8 *u8DcChroma2HuffVal; 515 MS_U8 *u8AcLumaHuffVal; 516 MS_U8 *u8AcChromaHuffVal; 517 MS_U8 *u8AcChroma2HuffVal; 518 MS_BOOL DHT; 519 MS_BOOL bUVHuffman; 520 } NJPD_Symidx; 521 //------------------------------------------------------------------------------ 522 // Structure for Quantization Table 523 typedef struct 524 { 525 MS_U16 s16Value[64]; 526 MS_BOOL bValid; 527 } NJPD_QuanTbl; 528 //------------------------------------------------------------------------------ 529 // Structure for IQtbl of Table Indirect Access 530 typedef struct 531 { 532 MS_U8 *u8CompQuant; 533 NJPD_QuanTbl *QuantTables; 534 MS_U8 u8CompNum; 535 MS_BOOL DQT; 536 } NJPD_IQTbl; 537 //------------------------------------------------------------------------------ 538 // Structure for NJPD capability 539 typedef struct 540 { 541 MS_BOOL bBaseline; 542 MS_BOOL bProgressive; 543 MS_BOOL bMJPEG; 544 } NJPD_Cap; 545 //------------------------------------------------------------------------------ 546 // Structure for NJPD Information 547 typedef struct 548 { 549 MS_U8* pu8HalVer; 550 MS_U8* pu8FwVer; 551 NJPD_Cap stCap; 552 } NJPD_Info; 553 //------------------------------------------------------------------------------ 554 // Structure for NJPD Status 555 typedef struct 556 { 557 MS_U32 u32CurMRCAddr; 558 MS_U16 u16CurVidx; 559 MS_U16 u16CurRow; 560 MS_U16 u16CurCol; 561 MS_BOOL bIsBusy; 562 MS_BOOL bIsrEnable; 563 } NJPD_Status; 564 565 //------------------------------------------------------------------------------------------------- 566 // Function and Variable 567 //------------------------------------------------------------------------------------------------- 568 //void MDrv_NJPD_Initialize(MS_U8 u8ChipType); 569 MS_BOOL MDrv_NJPD_InitBuf(NJPD_BufCfg in, MS_BOOL bMJPEG); 570 //void MDrv_NJPD_Reset(void); 571 //void MDrv_NJPD_SW_Pause_Reset(void); 572 void MDrv_NJPD_Rst(void); 573 //MS_U16 MDrv_NJPD_GetSWResetMask(void); 574 //void MDrv_NJPD_SetReadBuffer(MS_U32 u32BufAddr, MS_U32 u32BufSize); 575 //void MDrv_NJPD_SetMRCStartAddr(MS_U32 u32ByteOffset); 576 //void MDrv_NJPD_SetOutputFrameBuffer(MS_U32 u32BufAddr); 577 MS_U32 MDrv_NJPD_GetMWCStartAddr(void); 578 MS_U32 MDrv_NJPD_GetWritePtrAddr(void); 579 void MDrv_NJPD_SetPicDimension(MS_U16 u16Width, MS_U16 u16Height); 580 //MS_U16 MDrv_NJPD_ReadNJPDStatus(void); 581 MS_U16 MDrv_NJPD_GetEventFlag(void); 582 //void MDrv_NJPD_ClearNJPDStatus(MS_U16 status_bit); 583 void MDrv_NJPD_SetEventFlag(MS_U16 u16Value); 584 void MDrv_NJPD_SetROI(MS_U16 start_x, MS_U16 start_y, MS_U16 width, MS_U16 height); 585 //void MDrv_NJPD_SetClock(MS_U8 on); 586 void MDrv_NJPD_PowerOn(void); 587 void MDrv_NJPD_PowerOff(void); 588 #if 0 // unused function 589 MS_U32 MDrv_NJPD_ReadCurrentMRCAddr(void); 590 #endif 591 void MDrv_NJPD_SetRSTIntv(MS_U16 u16Value); 592 MS_U16 MDrv_NJPD_GetCurVidx(void); 593 594 void MDrv_NJPD_WriteGrpinf(NJPD_Grpinf in); 595 void MDrv_NJPD_WriteSymidx(NJPD_Symidx in); 596 void MDrv_NJPD_WriteIQTbl(NJPD_IQTbl in); 597 598 void MDrv_NJPD_SetDbgLevel(MS_U8 u8DbgLevel); 599 void MDrv_NJPD_GetInfo(NJPD_Info *pNJPD_Info); 600 NJPD_Status* MDrv_NJPD_GetStatus(void); 601 MS_BOOL MDrv_NJPD_GetLibVer(const MSIF_Version **ppVersion); 602 603 MS_BOOL MDrv_NJPD_EnableISR(NJPD_IsrFuncCb IsrCb); 604 MS_BOOL MDrv_NJPD_DisableISR(void); 605 606 MS_U32 MDrv_NJPD_GetCurMRCAddr(void); 607 MS_U16 MDrv_NJPD_GetCurRow(void); 608 MS_U16 MDrv_NJPD_GetCurCol(void); 609 610 void MDrv_NJPD_SetAutoProtect(MS_BOOL enable); 611 void MDrv_NJPD_SetWPENEndAddr(MS_PHY u32ByteOffset); 612 void MDrv_NJPD_SetWPENStartAddr(MS_PHY u32ByteOffset); 613 614 void MDrv_NJPD_SetSpare(MS_U16 u16Value); 615 MS_U16 MDrv_NJPD_GetSpare(void); 616 void MDrv_NJPD_SetMRC_Valid(MS_U16 u16Value); 617 618 void MDrv_NJPD_DecodeEnable(void); 619 void MDrv_NJPD_TableLoadingStart(void); 620 void MDrv_NJPD_ReadLastBuffer(void); 621 void MDrv_NJPD_SetScalingDownFactor(NJPD_SCALING_DOWN_FACTOR eScalingFactor); 622 623 void MDrv_NJPD_GTable_Rst(MS_BOOL bEnable); 624 void MDrv_NJPD_HTable_Reload_Enable(MS_BOOL bEnable); 625 void MDrv_NJPD_GTable_Reload_Enable(MS_BOOL bEnable); 626 void MDrv_NJPD_QTable_Reload_Enable(MS_BOOL bEnable); 627 void MDrv_NJPD_SetSoftwareVLD(MS_BOOL bEnable); 628 void MDrv_NJPD_SetDifferentQTable(MS_BOOL bEnable); 629 void MDrv_NJPD_SetDifferentHTable(MS_BOOL bEnable); 630 void MDrv_NJPD_Set_GlobalSetting00(MS_U16 u16Value); 631 MS_U16 MDrv_NJPD_Get_GlobalSetting00(void); 632 void MDrv_NJPD_SetHTableStartAddr(MS_PHY u32ByteOffset); 633 void MDrv_NJPD_SetQTableStartAddr(MS_PHY u32ByteOffset); 634 void MDrv_NJPD_SetGTableStartAddr(MS_PHY u32ByteOffset); 635 void MDrv_NJPD_SetVerificationMode(NJPD_VerificationMode VerificationMode); 636 NJPD_VerificationMode MDrv_NJPD_GetVerificationMode(void); 637 void MDrv_NJPD_Debug(void); 638 void MDrv_NJPD_EnablePowerSaving(void); 639 void MDrv_NJPD_SetNJPDInstance(JPD_Number JPDNum); 640 MS_BOOL MDrv_NJPD_IsNeedToPatch(NJPD_PATCH_INDEX eIndex); 641 642 #ifdef MSOS_TYPE_LINUX_KERNEL 643 MS_BOOL MDrv_NJPD_Get_ISR(void); 644 void MDrv_NJPD_Set_ISR(MS_BOOL val); 645 #endif 646 MS_U8 MDrv_NJPD_JPDCount(void); 647 648 649 #ifdef __cplusplus 650 } 651 #endif 652 653 #endif // _DRV_NJPD_H_ 654 655