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) 2006-2008 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 ///@file Datatype.h 94 ///@brief Datatype defination 95 ///@author MStarSemi Inc. 96 /// 97 /// Define datatype in this file. 98 /// 99 /////////////////////////////////////////////////////////////////////////////// 100 #ifndef __DATATYPE_H 101 #define __DATATYPE_H 102 103 #include <stdio.h> 104 105 /////////////////////////////////////////////////////////////////// 106 // Char definition : 2 bytes font talbe 107 /////////////////////////////////////////////////////////////////// 108 #define CHAR_RETURNICON 0x0019 109 #define CHAR_ENTERICON 0x001A 110 #define CHAR_MOVEICON 0x001B 111 #define CHAR_UP 0x001C 112 #define CHAR_DOWN 0x001D 113 #define CHAR_LEFT 0x001E 114 #define CHAR_RIGHT 0x001F 115 #define CHAR_SPACE 0x0020 116 #define CHAR_PERCENT 0x0025 117 #define CHAR_APOSTROPHE 0x0027 118 #define CHAR_LEFT_QUOTE 0x0028 119 #define CHAR_RIGHT_QUOTE 0x0029 120 #define CHAR_STAR 0x002A 121 #define CHAR_PLUS 0x002B 122 #define CHAR_COMMA 0x002C 123 #define CHAR_MINUS 0x002D 124 #define CHAR_DOT 0x002E 125 #define CHAR_SLASH 0x002F 126 #define CHAR_0 0x0030 127 #define CHAR_1 0x0031 128 #define CHAR_2 0x0032 129 #define CHAR_3 0x0033 130 #define CHAR_4 0x0034 131 #define CHAR_5 0x0035 132 #define CHAR_6 0x0036 133 #define CHAR_7 0x0037 134 #define CHAR_8 0x0038 135 #define CHAR_9 0x0039 136 #define CHAR_COLON 0x003A 137 #define CHAR_GT 0x003E 138 #define CHAR_QM 0x003F 139 #define CHAR_AT 0x0040 140 #define CHAR_A 0x0041 141 #define CHAR_B 0x0042 142 #define CHAR_C 0x0043 143 #define CHAR_D 0x0044 144 #define CHAR_E 0x0045 145 #define CHAR_F 0x0046 146 #define CHAR_G 0x0047 147 #define CHAR_H 0x0048 148 #define CHAR_I 0x0049 149 #define CHAR_J 0x004A 150 #define CHAR_K 0x004B 151 #define CHAR_L 0x004C 152 #define CHAR_M 0x004D 153 #define CHAR_N 0x004E 154 #define CHAR_O 0x004F 155 #define CHAR_P 0x0050 156 #define CHAR_Q 0x0051 157 #define CHAR_R 0x0052 158 #define CHAR_S 0x0053 159 #define CHAR_T 0x0054 160 #define CHAR_U 0x0055 161 #define CHAR_V 0x0056 162 #define CHAR_W 0x0057 163 #define CHAR_X 0x0058 164 #define CHAR_Y 0x0059 165 #define CHAR_Z 0x005A 166 #define CHAR_LEFT_BRACKET 0x005B 167 #define CHAR_RIGHT_BRACKET 0x005D 168 #define CHAR_US 0x005f 169 #define CHAR_a 0x0061 170 #define CHAR_b 0x0062 171 #define CHAR_c 0x0063 172 #define CHAR_d 0x0064 173 #define CHAR_e 0x0065 174 #define CHAR_f 0x0066 175 #define CHAR_g 0x0067 176 #define CHAR_h 0x0068 177 #define CHAR_i 0x0069 178 #define CHAR_j 0x006A 179 #define CHAR_k 0x006B 180 #define CHAR_l 0x006C 181 #define CHAR_m 0x006D 182 #define CHAR_n 0x006E 183 #define CHAR_o 0x006F 184 #define CHAR_p 0x0070 185 #define CHAR_q 0x0071 186 #define CHAR_r 0x0072 187 #define CHAR_s 0x0073 188 #define CHAR_t 0x0074 189 #define CHAR_u 0x0075 190 #define CHAR_v 0x0076 191 #define CHAR_w 0x0077 192 #define CHAR_x 0x0078 193 #define CHAR_y 0x0079 194 #define CHAR_z 0x007A 195 #define CHAR_wave 0x007E 196 197 #define CHAR_CC 0x010D 198 #define CHAR_SIGNAL 0x0121 199 //extended ASCII 200 #define CHAR_EXT_C 0x00C7 201 #define CHAR_EXT_c 0x00E7 202 #define CHAR_EXT_e 0x00E9 203 #define CHAR_EXT_e2 0x00E8 204 #define CHAR_EXT_e3 0x00EA 205 #define CHAR_EXT_e4 0x00EB 206 #define CHAR_EXT_E2 0x00C8 207 #define CHAR_EXT_E3 0x00C9 208 #define CHAR_EXT_O 0x00D3 209 #define CHAR_EXT_a 0x00E1 210 #define CHAR_EXT_a1 0x00E0 211 #define CHAR_EXT_a2 0x00E2 212 #define CHAR_EXT_A 0x00C1 213 #define CHAR_EXT_u 0x00FA 214 #define CHAR_EXT_U 0x00DA 215 #define CHAR_EXT_n 0x00F1 216 #define CHAR_EXT_N 0x00D1 217 #define CHAR_EXT_I 0x00CD 218 #define CHAR_EXT_i 0x00ED 219 #define CHAR_EXT_i2 0x00EE 220 #define CHAR_EXT_o 0x00F3 221 222 //KOREA Font UNICODE 223 #define CHAR_KOREAN_AM1 0xc624 224 #define CHAR_KOREAN_AM2 0xc804 225 #define CHAR_KOREAN_PM1 0xc624 226 #define CHAR_KOREAN_PM2 0xd6c4 227 228 #define CHAR_KOREAN_YEAR 0xB144 229 #define CHAR_KOREAN_MONTH 0xC6D4 230 #define CHAR_KOREAN_DAY 0xC77C 231 232 233 #undef NULL 234 #define NULL 0 235 236 #if defined(__cplusplus) 237 #define MST_BEGIN_DECL extern "C" { 238 #define MST_END_DECL } 239 #else 240 #define MST_BEGIN_DECL 241 #define MST_END_DECL 242 #endif 243 244 #define MST_MACRO_START do { 245 #define MST_MACRO_END } while (0) 246 247 /********************************************************************************/ 248 /* Primitive types */ 249 /********************************************************************************/ 250 251 #if defined (__aeon__) || defined (__mips__) || defined (__arm__) 252 253 #define WORDS_LITTLEENDIAN 254 255 #if defined (__aeon__) 256 #define RIU_MAP 0xA0000000 257 #else 258 #if defined(MCU_MIPS_34K) || defined(MCU_MIPS_74K) || defined(MCU_MIPS_1004K) || defined(MCU_ARM_9) 259 extern unsigned long RIU_MAP; 260 #else 261 #define RIU_MAP 0xBF800000 262 #endif 263 #endif 264 #define RIU ((unsigned short volatile *) RIU_MAP) 265 #define RIU8 ((unsigned char volatile *) RIU_MAP) 266 267 #define REG8(a) RIU8[((a) * 2) - ((a) & 1)] 268 269 // C51 extension keyword 270 #define xdata 271 #define code 272 #define bit U8 273 #define _AT_(x) 274 275 #define DATA 276 #define IDATA 277 #define PDATA 278 #define XDATA 279 #define RDATA 280 281 282 typedef unsigned char BIT; 283 284 typedef unsigned char U8; 285 typedef unsigned short U16; 286 typedef unsigned long U32; 287 typedef signed char S8; 288 typedef signed short S16; 289 typedef signed long S32; 290 291 typedef U8 UINT8; 292 typedef U16 UINT16; 293 typedef U32 UINT32; 294 295 typedef U8 U_INT8; 296 typedef U16 U_INT16; 297 typedef U32 U_INT32; 298 299 typedef U16 FAST_U8; 300 typedef U16 FAST_U16; 301 typedef U32 FAST_U32; 302 typedef S16 FAST_S8; 303 typedef S16 FAST_S16; 304 typedef S32 FAST_S32; 305 306 #elif defined (__aarch64__) 307 308 #define WORDS_LITTLEENDIAN 309 310 extern unsigned long RIU_MAP; 311 312 #define RIU ((unsigned short volatile *) RIU_MAP) 313 #define RIU8 ((unsigned char volatile *) RIU_MAP) 314 315 #define REG8(a) RIU8[((a) * 2) - ((a) & 1)] 316 317 // C51 extension keyword 318 #define xdata 319 #define code 320 #define bit U8 321 #define _AT_(x) 322 323 #define DATA 324 #define IDATA 325 #define PDATA 326 #define XDATA 327 #define RDATA 328 329 330 typedef unsigned char BIT; 331 332 typedef unsigned char U8; 333 typedef unsigned short U16; 334 typedef unsigned int U32; 335 typedef signed char S8; 336 typedef signed short S16; 337 typedef signed int S32; 338 339 typedef U8 UINT8; 340 typedef U16 UINT16; 341 typedef U32 UINT32; 342 343 typedef U8 U_INT8; 344 typedef U16 U_INT16; 345 typedef U32 U_INT32; 346 347 typedef U16 FAST_U8; 348 typedef U16 FAST_U16; 349 typedef U32 FAST_U32; 350 typedef S16 FAST_S8; 351 typedef S16 FAST_S16; 352 typedef S32 FAST_S32; 353 354 #else 355 356 #error "primitive types are not defined" 357 358 #endif 359 360 /// Data type unsigned char 361 typedef unsigned char UCHAR; 362 /// Data type unsigned char 363 typedef unsigned char BYTE; 364 /// Data type unsigned int 365 typedef unsigned int UINT; 366 /// Data type unsigned int 367 typedef unsigned short WORD; // 16bit 368 /// Data type unsigned long 369 typedef unsigned long ULONG; 370 /// Data type unsigned long 371 typedef unsigned long DWORD; 372 373 #ifndef NULL 374 #define NULL (void *)0 375 #endif 376 377 typedef U8 BOOLEAN; ///< BOOLEAN 378 #define BOOL BOOLEAN 379 380 #define HIBYTE(value) ((BYTE)((value) / 0x100)) 381 #define LOBYTE(value) ((BYTE)(value)) 382 #define MAKEWORD(value1, value2) (((WORD)(value1)) * 0x100) + (value2) 383 #define HINIBBLE(value) ((value) >> 4) 384 #define LONIBBLE(value) ((value) & 0x0f) 385 386 typedef struct 387 { 388 BYTE bBOOL_0 :1; 389 BYTE bBOOL_1 :1; 390 BYTE bBOOL_2 :1; 391 BYTE bBOOL_3 :1; 392 BYTE bBOOL_4 :1; 393 BYTE bBOOL_5 :1; 394 BYTE bBOOL_6 :1; 395 BYTE bBOOL_7 :1; 396 } BOOLEANS; 397 398 /********************************************************************************/ 399 /* Macro for endianess */ 400 /********************************************************************************/ 401 402 #define ReadU16BE(b) (((U16)((b)[0])<<8)|((b)[1])) 403 #define ReadU24BE(b) (((U32)((b)[0])<<16)|((U32)((b)[1])<<8)|((b)[2]))) 404 #define ReadU32BE(b) (((U32)((b)[0])<<24)|((U32)((b)[1])<<16)|((U32)((b)[2])<<8)|((b)[3])) 405 #define ReadU16LE(b) (((b)[0])|((U16)((b)[1])<<8)) 406 #define ReadU24LE(b) (((b)[0])|((U32)((b)[1])<<8)|((U32)((b)[2])<<16)) 407 #define ReadU32LE(b) (((b)[0])|((U32)((b)[1])<<8)|((U32)((b)[2])<<16)|((U32)((b)[3])<<24)) 408 409 #define Swap16(x) MDrv_ByteSwapU16(x) 410 #define Swap32(x) MDrv_ByteSwapU32(x) 411 412 #define ByteSwap16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8) 413 #define ByteSwap32(x) \ 414 ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ 415 (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) 416 417 #ifdef WORDS_BIGENDIAN 418 #define BE2ME16(x) (x) 419 #define BE2ME32(x) (x) 420 #define LE2ME16(x) ByteSwap16(x) 421 #define LE2ME32(x) ByteSwap32(x) 422 #define ME2BE16(x) (x) 423 #define ME2BE32(x) (x) 424 #define ME2LE16(x) ByteSwap16(x) 425 #define ME2LE32(x) ByteSwap32(x) 426 #else 427 #define BE2ME16(x) ByteSwap16(x) 428 #define BE2ME32(x) ByteSwap32(x) 429 #define LE2ME16(x) (x) 430 #define LE2ME32(x) (x) 431 #define ME2BE16(x) ByteSwap16(x) 432 #define ME2BE32(x) ByteSwap32(x) 433 #define ME2LE16(x) (x) 434 #define ME2LE32(x) (x) 435 #endif 436 437 /********************************************************************************/ 438 /* Macro for TDA1236D */ 439 /********************************************************************************/ 440 #define Data8 U8 441 #define Data16 S16 442 #define Data32 S32 443 #define bool BOOLEAN 444 #define Bool BOOLEAN 445 #define true TRUE 446 #define false FALSE 447 448 /******************************************************************************/ 449 /* Macro for bitwise */ 450 /******************************************************************************/ 451 #define _BITMASK(loc_msb, loc_lsb) ((1U << (loc_msb)) - (1U << (loc_lsb)) + (1U << (loc_msb))) 452 #define BITMASK(x) _BITMASK(1?x, 0?x) 453 #define BITFLAG(loc) (1U << (loc)) 454 455 #define BIT0 0x0001 456 #define BIT1 0x0002 457 #define BIT2 0x0004 458 #define BIT3 0x0008 459 #define BIT4 0x0010 460 #define BIT5 0x0020 461 #define BIT6 0x0040 462 #define BIT7 0x0080 463 #define BIT8 0x0100 464 #define BIT9 0x0200 465 #define BIT10 0x0400 466 #define BIT11 0x0800 467 #define BIT12 0x1000 468 #define BIT13 0x2000 469 #define BIT14 0x4000 470 #define BIT15 0x8000 471 472 #define _BIT0 0x0001 473 #define _BIT1 0x0002 474 #define _BIT2 0x0004 475 #define _BIT3 0x0008 476 #define _BIT4 0x0010 477 #define _BIT5 0x0020 478 #define _BIT6 0x0040 479 #define _BIT7 0x0080 480 #define _BIT8 0x0100 481 #define _BIT9 0x0200 482 #define _BIT10 0x0400 483 #define _BIT11 0x0800 484 #define _BIT12 0x1000 485 #define _BIT13 0x2000 486 #define _BIT14 0x4000 487 #define _BIT15 0x8000 488 489 #define SETBIT(REG, BIT) ((REG) |= (1UL << (BIT))) 490 #define CLRBIT(REG, BIT) ((REG) &= ~(1UL << (BIT))) 491 #define GETBIT(REG, BIT) (((REG) >> (BIT)) & 0x01UL) 492 #define COMPLEMENT(a) (~(a)) 493 494 /// define MSRET U8 495 typedef U8 MSRET; 496 /// MS Return Error 497 #define MSRET_ERROR 0 498 /// MS Return OK 499 #define MSRET_OK 1 500 501 /// defination for FALSE 502 #define FALSE 0 503 /// defination for TRUE 504 #define TRUE 1 505 506 #define DISABLE 0 507 #define ENABLE 1 508 509 /// 0: FAIL 510 #define FAIL 0 511 /// 1: PASS 512 #define PASS 1 513 514 /// 0: NO 515 #define NO 0 516 /// 1: YES 517 #define YES 1 518 519 /// 0: WRITE 520 #define WRITE 0 521 /// 1: READ 522 #define READ 1 523 524 525 #define FE_NOT_LOCK 0 526 #define FE_LOCK 1 527 #define FE_AGC_NOT_LOCK 2 528 529 530 #define NONE_HIGHLIGHT 0 531 #define HIGHLIGHT 1 532 533 #define HIU16(u32) ((U16)((u32)>>16)) 534 #define LOU16(u32) ((U16)(u32)) 535 536 537 #define LOWBYTE(u16) ((U8)(u16)) 538 #define HIGHBYTE(u16) ((U8)((u16) >> 8)) 539 #define HIGHNIBBLE(u8) ((u8) >> 4) 540 #define LOWNIBBLE(u8) ((u8) & 0x0F) 541 #define BCD2Dec(x) ((((x) >> 4) * 10) + ((x) & 0x0F)) 542 #define DEC2BCD(x) ((((x) / 10) * 16) + ((x) % 10)) 543 544 545 /// Font handle, handle to font table in memory 546 typedef S8 FONTHANDLE; 547 /// Bitmap handle, handle to bitmap buffer 548 typedef S16 BMPHANDLE; 549 typedef S8 DBHANDLE; 550 551 #define INVALID_FONTHANDLE -1 552 #define INVALID_BMPHANDLE -1 553 #define INVALID_DBHANDLE -1 554 555 // NOTE. these have problem with long integer (32-bit) on C51 556 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 557 #define MIN(a ,b) (((a) < (b)) ? (a) : (b)) 558 559 560 #define _MAX( a, b ) (((a) >= (b)) * (a) + ((b) > (a)) * (b)) 561 #define _MIN( a, b ) (((a) <= (b)) * (a) + ((b) < (a)) * (b)) 562 563 #define _CONCAT( a, b ) a##b 564 #define CONCAT( a, b ) _CONCAT( a, b ) 565 566 #define COUNTOF( array ) (sizeof(array) / sizeof((array)[0])) 567 568 #define UNUSED( var ) ((void)(var)) 569 570 extern U32 MDrv_ByteSwapU32(U32 val); 571 extern U16 MDrv_ByteSwapU16(U16 val); 572 573 #define IS_FPGA (!RIU[0x2510]) 574 575 #endif /* __DATATYPE_H */ 576