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 drvIR.h 98 /// @brief IR Driver Interface 99 /// @author MStar Semiconductor Inc. 100 /////////////////////////////////////////////////////////////////////////////////////////////////// 101 102 /*! \defgroup G_IR IR interface 103 \ingroup G_PERIPHERAL 104 105 \brief 106 107 Commonly, remote controls are Consumer IR devices which send digitally-coded pulses of infrared radiation to control functions such as 108 power, volume, tuning, temperature set point, fan speed, or other features. Remote controls for these devices are usually small wireless 109 handheld objects with an array of buttons for adjusting various settings such as television channel, track number, and volume. 110 For many devices, the remote control contains all the function controls while the controlled device itself has only a handful of essential primary controls. 111 112 <b>Features</b> 113 114 - Consumer electronics infrared protocols 115 - Infrared, line of sight and operating angle 116 - Remote control systems 117 - The opto components, and circuits 118 119 <b> IR Block Diagram: </b> \n 120 \image html drvIR_pic1.png 121 122 <b> Operation Code Flow: </b> \n 123 -# Prepare IR setting for each operation 124 -# Set and start IR in command handle 125 -# Trigger IR 126 127 \defgroup G_IR_INIT Initialization Task relative 128 \ingroup G_IR 129 \defgroup G_IR_COMMON Common Task relative 130 \ingroup G_IR 131 \defgroup G_IR_CONTROL Control relative 132 \ingroup G_IR 133 */ 134 135 #ifndef _DRV_IR_H_ 136 #define _DRV_IR_H_ 137 138 139 #ifdef __cplusplus 140 extern "C" 141 { 142 #endif 143 144 #include "MsTypes.h" 145 #include "MsDevice.h" 146 //------------------------------------------------------------------------------------------------- 147 // Driver Capability 148 //------------------------------------------------------------------------------------------------- 149 150 151 //------------------------------------------------------------------------------------------------- 152 // Macro and Define 153 //------------------------------------------------------------------------------------------------- 154 /// define IR library version 155 #define MSIF_IR_LIB_CODE {'I','R','_','_'} 156 #define MSIF_IR_LIBVER {'0','5'} 157 #define MSIF_IR_BUILDNUM {'0','0' } 158 #define MSIF_IR_CHANGELIST {'0','0','4','4','3','0','8','6'} 159 160 #define IR_DRV_VERSION /* Character String for DRV/API version */ \ 161 MSIF_TAG, /* 'MSIF' */ \ 162 MSIF_CLASS, /* '00' */ \ 163 MSIF_CUS, /* 0x0000 */ \ 164 MSIF_MOD, /* 0x0000 */ \ 165 MSIF_CHIP, \ 166 MSIF_CPU, \ 167 MSIF_IR_LIB_CODE, /* IP__ */ \ 168 MSIF_IR_LIBVER, /* 0.0 ~ Z.Z */ \ 169 MSIF_IR_BUILDNUM, /* 00 ~ 99 */ \ 170 MSIF_IR_CHANGELIST, /* CL# */ \ 171 MSIF_OS 172 173 /// IR driver 174 #define IR_VERSION_STRING_MAX 33 175 #define IR_DUMMY_KEY 0xFF 176 #define IR_DUMMY_STATUS 0x00 177 178 //IR Decode mode list 179 #define IR_DEC_RC_RC5 0 180 #define IR_DEC_RC_RC5X 1 181 #define IR_DEC_RC_RC6 2 182 #define IR_DEC_FULL 3 183 #define IR_DEC_RAW 4 184 #define IR_DEC_SW 5 185 #define IR_DEC_FMT 6 186 187 //------------------------------------------------------------------------------------------------- 188 // Type and Structure 189 //------------------------------------------------------------------------------------------------- 190 /// define IR driver info 191 typedef struct __attribute__((aligned (4096))) 192 { 193 MS_U8 u8IsDecodeEn : 1; /// check decode enable (Full/Raw) 194 MS_U8 u8IsIntMsked : 1; /// check int mask (Full/Raw) 195 MS_U8 u8IsPolarInv : 1; /// check signal polarity inverted (Full/Raw) 196 MS_U8 u8IsFifoFullEn : 1; /// Fifo full check enable (Full/Raw) 197 MS_U8 u8IsFifoFull : 1; /// Check Fifo full (Full/Raw) 198 MS_U8 u8IsKeyMsbFst : 1; /// Check Key MSB first (Full/Raw) 199 MS_U8 u8IsBitInvEn : 1; /// Check decode logic bit inverse (Full/Raw) 200 MS_U8 u8IsGlhrmEn : 1; /// glitch removal enable 201 MS_U8 u8DecodeMode : 4; /// decode mode. 0: RC5, 1: RC5X, 2: RC6, 3: Full, 4: Raw, 5: SW, 6:FMT 202 MS_U8 u8CCodeBytes : 2; /// customer code bytes: 1 or 2 bytes (Full only) 203 MS_U8 u8Reserved : 2; /// RFU 204 MS_U8 u8CodeBits; /// Code bits: 0x00~0x7F 205 MS_U8 u8FifoDepth; /// Fifo depth (Full/Raw) 206 //for RC 207 MS_U8 u8IsRCDecodeEn : 1; /// check RC decode enable (RC) 208 MS_U8 u8IsRCPolarInv : 1; /// check RC signal polarity inverted (RC) 209 MS_U8 u8RCReserved : 6; /// RFU (RC) 210 }IR_DrvInfo; 211 212 /// define IR key code time & bounds 213 typedef struct 214 { 215 MS_S16 s16Time; ///key code time 216 MS_S8 s8UpBnd; ///upper bound 217 MS_S8 s8LoBnd; ///low bound 218 } IR_TimeCfg; 219 220 /// define IR time parameters 221 typedef struct __attribute__((aligned (4096))) 222 { 223 IR_TimeCfg tHdr; /// header code time 224 IR_TimeCfg tOff; /// off code time 225 IR_TimeCfg tOffRpt; /// off code repeat time 226 IR_TimeCfg tLg01Hg; /// logical 0/1 high time 227 IR_TimeCfg tLg0; /// logical 0 time 228 IR_TimeCfg tLg1; /// logical 1 time 229 230 } IR_TimeBnd; 231 232 /// define IR configuration parameters 233 typedef struct __attribute__((aligned (4096))) 234 { 235 //MS_U8 u8ModeSel; /// IR mode selection 236 MS_U8 u8Ctrl0; /// IR enable control 0 237 MS_U8 u8Ctrl1; /// IR enable control 1 238 MS_U8 u8Clk_mhz; /// IR required clock 239 MS_U8 u8HdrCode0; /// IR Header code 0 240 MS_U8 u8HdrCode1; /// IR Header code 1 241 MS_U8 u8CCodeBytes; /// Customer codes: 1 or 2 bytes 242 MS_U8 u8CodeBits; /// Code bits: 0x00~0x7F 243 MS_U8 u8HdrCode20; /// 2nd IR Header code 0 244 MS_U8 u8HdrCode21; /// 2nd IR Header code 1 245 246 } IR_RegCfg; 247 248 /// emurate IR fucntion return result 249 typedef enum 250 { 251 /// IR result for failure 252 E_IR_FAIL =0, 253 /// IR result for OK 254 E_IR_OK = 1, 255 256 } IR_Result; 257 258 /// emurate IR status 259 typedef enum 260 { 261 /// IR Driver Status: Initialization OK 262 E_IR_INIT_OK = (1<<0), 263 /// IR Driver Status: Callback installed 264 E_IR_INST_CLBK = (1<<1), 265 /// IR Driver Status: FIFO empty 266 E_IR_FIFO_EMPTY = (1<<2), 267 /// IR Driver Status: FIFO full 268 E_IR_FIFO_FULL = (1<<3), 269 /// IR Driver Status: Get key code 270 E_IR_KEY_CODE = (1<<4), 271 /// IR Driver Status: Key timeout 272 E_IR_KEY_TIMEOUT = (1<<5), 273 /// IR Driver Status: Key decoded error 274 E_IR_KEY_DECERR = (1<<6), 275 /// IR Driver Status: IR is enabled 276 E_IR_ENABLE = (1<<7), 277 /// IR Driver Status: Maximum status 278 E_IR_MAX_STATUS = 255 279 } IR_Status; 280 281 //------------------------------- 282 // Mailbox Class : IR 283 //------------------------------- 284 /// emurate IR mailbox commands from cpu to mcu51 285 typedef enum 286 { 287 /// mbx command for initialization 288 E_IR_CPUTo51_CMD_INIT=0x00, 289 /// mbx command for configuration 290 E_IR_CPUTo51_CMD_CONFIG, 291 /// mbx command for key code 292 E_IR_CPUTo51_CMD_KEYCODE, 293 /// mbx command for set callback 294 E_IR_CPUTo51_CMD_SETCLBK, 295 /// mbx command for library version 296 E_IR_CPUTo51_CMD_LIBVER, 297 /// mbx command for status 298 E_IR_CPUTo51_CMD_STATUS, 299 /// mbx command for enable 300 E_IR_CPUTo51_CMD_ENABLE, 301 /// mbx command for driver info 302 E_IR_CPUTo51_CMD_INFO, 303 } IR_CPUTo51CmdIdx; 304 305 /// emurate IR mailbox commands ack from mcu51 to cpu 306 typedef enum 307 { 308 //(1) Acknowledge from MCU51 309 /// ack mbx command for initialization 310 E_IR_51ToCPU_CMD_ACK_INIT=0x00, 311 /// ack mbx command for configuration 312 E_IR_51ToCPU_CMD_ACK_CONFIG, 313 /// ack mbx command for key code 314 E_IR_51ToCPU_CMD_ACK_KEYCODE, 315 /// ack mbx command for set callback 316 E_IR_51ToCPU_CMD_ACK_SETCLBK, 317 /// ack mbx command for library version 318 E_IR_51ToCPU_CMD_ACK_LIBVER, 319 ///ack mbx command for status 320 E_IR_51ToCPU_CMD_ACK_STATUS, 321 ///ack mbx command for enable 322 E_IR_51ToCPU_CMD_ACK_ENABLE, 323 ///ack mbx command for driver info 324 E_IR_51ToCPU_CMD_ACK_INFO, 325 326 //(2) Notification from MCU51 327 ///notification mbx command for key code 328 E_IR_51ToCPU_CMD_KEYCODE, 329 330 } IR_51ToCPUCmdIdx; 331 332 /// emurate ack flags 333 typedef enum 334 { 335 /// ack flag for null 336 E_IR_ACKFLG_NULL = 0, 337 /// ack flag for wait initialization 338 E_IR_ACKFLG_WAIT_INIT = (1<<0), 339 /// ack flag for wait configuration 340 E_IR_ACKFLG_WAIT_CONFIG = (1<<1), 341 /// ack flag for wait key code 342 E_IR_ACKFLG_WAIT_KEYCODE = (1<<2), 343 /// ack flag for wait set callback 344 E_IR_ACKFLG_WAIT_SETCLBK = (1<<3), 345 /// ack flag for wait library version 346 E_IR_ACKFLG_WAIT_LIBVER = (1<<4), 347 /// ack flag for wait status 348 E_IR_ACKFLG_WAIT_STATUS = (1<<5), 349 /// ack flag for wait enable 350 E_IR_ACKFLG_WAIT_ENABLE = (1<<6), 351 /// ack flag for wait driver info 352 E_IR_ACKFLG_WAIT_INFO = (1<<7), 353 } IR_AckFlags; 354 355 /// Callback function which is called in IR ISR. 356 typedef void ( *IR_Callback ) (MS_U8 u8Key, MS_U8 u8RepeatFlag); 357 358 ///Define IR debug level 359 typedef enum _IR_DbgLvl 360 { 361 E_IR_DBGLVL_NONE = 0, /// no debug message 362 E_IR_DBGLVL_WARNING, /// show warning only 363 E_IR_DBGLVL_ERROR, /// show error only 364 E_IR_DBGLVL_INFO, /// show error & informaiton 365 E_IR_DBGLVL_ALL, /// show error, information & funciton name 366 }IR_DbgLvl; 367 368 //------------------------------------------------------------------------------------------------- 369 // Function and Variable 370 //------------------------------------------------------------------------------------------------- 371 372 //------------------------------------------------------------------------------------------------- 373 /// IR Iinitialized function before using IR to receive keys. 374 /// @ingroup G_IR_INIT 375 /// @param pIRRegCfg \b IN: pointer to IR configuration structure 376 /// @return E_IR_OK: Success 377 /// @return E_IR_FAIL or other values: Failure 378 //------------------------------------------------------------------------------------------------- 379 IR_Result MDrv_IR_Init(IR_RegCfg *pIRRegCfg); 380 381 //------------------------------------------------------------------------------------------------- 382 /// IR configuration function for time bound 383 /// @ingroup G_IR_COMMON 384 /// @param pIRTimeBnd \b IN: pointer to IR time bound structure 385 /// @return E_IR_OK: Success 386 /// @return E_IR_FAIL or other values: Failure 387 //------------------------------------------------------------------------------------------------- 388 IR_Result MDrv_IR_Config(IR_TimeBnd *pIRTimeBnd); 389 390 391 //------------------------------------------------------------------------------------------------- 392 /// IR get key code function. 393 /// @ingroup G_IR_CONTROL 394 /// @param pu8Key \b OUT: Get IR key code 395 /// @param pu8Repeat \b OUT: Get IR key repeat status 396 /// @return E_IR_OK: Success 397 /// @return E_IR_FAIL or other values: Failure 398 //------------------------------------------------------------------------------------------------- 399 IR_Result MDrv_IR_GetKeyCode(MS_U8 *pu8Key, MS_U8 *pu8Repeat); 400 401 402 //------------------------------------------------------------------------------------------------- 403 /// Set IR callback function when receive IR key. Support only one callback. If call it twice, 404 /// the first callback does not be called. 405 /// Note: The callback runs at interrupt mode. 406 /// @ingroup G_IR_CONTROL 407 /// @param pCallback \b IN: Set the callback function when generate IR interrupt. 408 /// @return E_IR_OK: Success 409 /// @return E_IR_FAIL or other values: Failure 410 //------------------------------------------------------------------------------------------------- 411 IR_Result MDrv_IR_SetCallback(IR_Callback pCallback); 412 413 414 //------------------------------------------------------------------------------------------------- 415 /// Get IR callback function which receive IR key. 416 /// @ingroup G_IR_CONTROL 417 /// @return the callback function when generate IR interrupt 418 //------------------------------------------------------------------------------------------------- 419 IR_Callback MDrv_IR_GetCallback(void); 420 421 422 //------------------------------------------------------------------------------------------------- 423 /// Get IR library version function. 424 /// @ingroup G_IR_COMMON 425 /// @param ppVersion \b OUT: pointer to library structure 426 /// @return E_IR_OK: Success 427 /// @return E_IR_FAIL or other values: Failure 428 //------------------------------------------------------------------------------------------------- 429 IR_Result MDrv_IR_GetLibVer(const MSIF_Version **ppVersion); 430 431 432 //------------------------------------------------------------------------------------------------- 433 /// Get IR status function. 434 /// @ingroup G_IR_CONTROL 435 /// @param pu8IRStatus \b OUT: pointer to status structure 436 /// @return E_IR_OK: Success 437 /// @return E_IR_FAIL or other values: Failure 438 //------------------------------------------------------------------------------------------------- 439 IR_Result MDrv_IR_GetStatus(MS_U8 *pu8IRStatus); 440 441 442 //------------------------------------------------------------------------------------------------- 443 /// Set IR enable function. 444 /// @ingroup G_IR_CONTROL 445 /// @param bEnable \b IN: TRUE: enable IR, FALSE: disable IR 446 /// @return E_IR_OK: Success 447 /// @return E_IR_FAIL or other values: Failure 448 //------------------------------------------------------------------------------------------------- 449 IR_Result MDrv_IR_Enable(MS_BOOL bEnable); 450 451 452 //------------------------------------------------------------------------------------------------- 453 /// Get IR driver information function. 454 /// @ingroup G_IR_COMMON 455 /// @return @ref IR_DrvInfo structure 456 //------------------------------------------------------------------------------------------------- 457 const IR_DrvInfo* MDrv_IR_GetInfo(void); 458 459 //------------------------------------------------------------------------------------------------- 460 /// Set IR debug function. 461 /// @ingroup G_IR_COMMON 462 /// @param eLevel \b IN: E_IR_DBGLVL_NONE/E_IR_DBGLVL_WARNING/E_IR_DBGLVL_ERROR/E_IR_DBGLVL_INFO/E_IR_DBGLVL_ALL 463 /// @return E_IR_OK: Success 464 /// @return E_IR_FAIL or other values: Failure 465 //------------------------------------------------------------------------------------------------- 466 IR_Result MDrv_IR_SetDbgLevel(IR_DbgLvl eLevel); 467 468 #define IR_VERSION 0x00000001 469 470 //#ifdef MSOS_TYPE_LINUX 471 #if 1 472 #define IR_MAX_BUF_DPH 2 473 #define IR_MAX_BUF_LEN 256 474 typedef enum 475 { 476 E_IR_DECMODE_HWFULL = 0, 477 E_IR_DECMODE_HWRAW, 478 E_IR_DECMODE_HWRC5, 479 E_IR_DECMODE_HWRC5X, 480 E_IR_DECMODE_HWRC6, 481 E_IR_DECMODE_SW, 482 E_IR_DECMODE_SHOT, 483 E_IR_DECMODE_NONE 484 } IR_DecodeMode; 485 486 ///IR data sequence format select for NEC-like (PPM modulation) formats. 487 ///Note: 488 ///S = System Code. 489 ///C = Customer Code Bits, (ex: C8= customer code 8bits). 490 ///D = Data (Key) Code Bits, (ex: D8= data code 8bits). 491 ///P = Format with Parity Check (ex: 3th byte and 4th byte of NEC format). 492 typedef enum 493 { 494 E_IR_XFM_NOTDEF = 0, ///Format not define 495 E_IR_XFM_C16D8D8P=1, ///ex: NEC, Toshiba format 496 E_IR_XFM_C8D8=2, ///ex: Mitsubushi, Konka format 497 E_IR_XFM_C4D8C4D8P=3, ///ex: RCA format 498 E_IR_XFM_C26D8D8P=4, ///ex: C26D8D8P 499 E_IR_XFM_C32D8D8P=5, ///ex: C32D8D8P 500 E_IR_XFM_C5D6C5D6P=6, ///ex: C5D6C5D6P 501 E_IR_XFM_C6D6C6D6P=7, ///ex: C6D6C6D6P 502 E_IR_XFM_D7C6=8, ///ex: Sony-D7C6 503 E_IR_XFM_D7C8=9, ///ex: Sony-D7C8 504 E_IR_XFM_D8C6=10, ///ex: Sony-D8C6 505 E_IR_XFM_D5_only=11, ///ex: MV500 506 E_IR_XFM_S1C4D6=12, ///ex: IRT1250 507 E_IR_XFM_C5D6D4=13, ///ex: LR3715M 508 E_IR_XFM_R1T1C3D6=14, ///ex: M3004 LAB1-Carrier 509 E_IR_XFM_RESERVED=15, ///Reserved 510 511 } IR_ExtFormat; 512 513 typedef enum 514 { 515 EN_IR_SHOT_P = 0x01, /// 2'b01: only pshot edge detect for counter 516 EN_IR_SHOT_N = 0x02, /// 2'b10: only nshot edge detect for counter 517 EN_IR_SHOT_PN = 0x03, /// 2'b11/2'b00: both pshot/nshot edge detect for counter 518 EN_IR_SHOT_INVLD, /// Invalid for value greater than 2'b11 519 520 } IR_ShotSel; 521 522 /// define IR key code time & bounds 523 typedef struct 524 { 525 MS_S16 s16Time; ///key code time 526 MS_S8 s8UpBnd; ///upper bound 527 MS_S8 s8LoBnd; ///low bound 528 } IR_TimeBndParam; 529 530 /// define IR key code time tail 531 typedef struct 532 { 533 MS_U32 gu32KeyMin; /// Min Tail Time for key 534 MS_U32 gu32KeyMax; /// Max Tail Time for key 535 MS_U32 gu32RptMin; /// Min Tail Time for Rpt 536 MS_U32 gu32RptMax; /// Max Tail Time for Rpt 537 } IR_TimeTailParam; 538 539 /// define IR time parameters 540 typedef struct 541 { 542 IR_TimeBndParam tHdr; /// header code time 543 IR_TimeBndParam tOff; /// off code time 544 IR_TimeBndParam tOffRpt; /// off code repeat time 545 IR_TimeBndParam tLg01Hg; /// logical 0/1 high time 546 IR_TimeBndParam tLg0; /// logical 0 time 547 IR_TimeBndParam tLg1; /// logical 1 time 548 IR_TimeBndParam tSepr; /// Separate time 549 MS_U32 u32TimeoutCyc; /// Timeout cycle count 550 MS_U16 u16RCBitTime; /// RC Bit Time 551 IR_TimeTailParam tTail; /// Tail Time for sw shot mode 552 } IR_TimeCfgParam; 553 554 /// define IR configuration parameters 555 typedef struct 556 { 557 MS_U8 u8DecMode; /// IR mode selection 558 MS_U8 u8ExtFormat; /// IR extention format 559 MS_U8 u8Ctrl0; /// IR enable control 0 560 MS_U8 u8Ctrl1; /// IR enable control 1 561 MS_U8 u8Clk_mhz; /// IR required clock 562 MS_U8 u8HdrCode0; /// IR Header code 0 563 MS_U8 u8HdrCode1; /// IR Header code 1 564 MS_U8 u8CCodeBytes; /// Customer codes: 1 or 2 bytes 565 MS_U8 u8CodeBits; /// Code bits: 1~128 bits 566 MS_U8 u8KeySelect; /// IR select Nth key N(1~16) 567 MS_U16 u16GlhrmNum; /// Glitch Remove Number 568 IR_ShotSel enShotSel; /// Shot selection for SW decoder 569 MS_BOOL bInvertPolar; /// Invert the polarity for input IR signal 570 571 } IR_InitCfgParam; 572 573 /// define Ping-Pong Buffer structure for IR SW shot count 574 typedef struct 575 { 576 MS_U32 u32Buffer[IR_MAX_BUF_DPH][IR_MAX_BUF_LEN]; ///Ping-Pong Buffer 577 MS_U32 u32Length; ///Data Length for Read Index buffer 578 MS_U8 u8RdIdx; ///Read Index 579 MS_U8 u8WtIdx; ///Write Index 580 } IR_PulseShotInfo; 581 582 /// define HeaderInfo for sw mode change headercode in apps 583 typedef struct 584 { 585 MS_U8 u8IRHeaderCode0; //IRHeaderCode0 586 MS_U8 u8IRHeaderCode1; //IRHeaderCode1 587 MS_U8 u8IR2HeaderCode0; //IR2HeaderCode0 588 MS_U8 u8IR2HeaderCode1; //IR2HeaderCode1 589 }MS_MultiIR_HeaderInfo; 590 591 #define IR_IOC_MAGIC 'u' 592 #define MDRV_IR_INIT _IO(IR_IOC_MAGIC, 0) 593 #define MDRV_IR_SET_DELAYTIME _IOW(IR_IOC_MAGIC, 1, int) 594 #define MDRV_IR_GET_KEY _IOW(IR_IOC_MAGIC, 2, int) 595 #define MDRV_IR_GET_LASTKEYTIME _IOW(IR_IOC_MAGIC, 3, int) 596 #define MDRV_IR_PARSE_KEY _IOW(IR_IOC_MAGIC, 4, int) 597 #define MDRV_IR_TEST _IOW(IR_IOC_MAGIC, 5, int) 598 #define MDRV_IR_ENABLE_IR _IOW(IR_IOC_MAGIC, 6, int) 599 #define MDRV_IR_IS_FANTASY_PROTOCOL_SUPPORTED _IOR(IR_IOC_MAGIC, 7, int) 600 #define MDRV_IR_ENABLE_FANTASY_DATA_TRANSFER _IOW(IR_IOC_MAGIC, 8, int) 601 #define MDRV_IR_SET_MASTER_PID _IOW(IR_IOC_MAGIC, 9, int) 602 #define MDRV_IR_GET_MASTER_PID _IOW(IR_IOC_MAGIC, 10, int) 603 #define MDRV_IR_INITCFG _IOW(IR_IOC_MAGIC, 11, IR_InitCfgParam) 604 #define MDRV_IR_TIMECFG _IOW(IR_IOC_MAGIC, 12, IR_TimeCfgParam) 605 #define MDRV_IR_GET_SWSHOT_BUF _IOW(IR_IOC_MAGIC, 13, IR_PulseShotInfo) 606 #define MDRV_IR_SEND_KEY _IOW(IR_IOC_MAGIC, 14, int) 607 #define MDRV_IR_SET_HEADER _IOW(IR_IOC_MAGIC, 15, MS_MultiIR_HeaderInfo) 608 609 #define IR_IOC_MAXNR 15 610 611 //------------------------------------------------------------------------------------------------- 612 /// Set IR enable function. 613 /// @ingroup G_IR_CONTROL 614 /// @param bEnable \b IN: TRUE: enable IR, FALSE: disable IR 615 /// @return E_IR_OK: Success 616 /// @return E_IR_FAIL or other values: Failure 617 //------------------------------------------------------------------------------------------------- 618 void MDrv_IR_OpenDevice(void); 619 //------------------------------------------------------------------------------------------------- 620 /// Set IR enable function. 621 /// @ingroup G_IR_CONTROL 622 /// @param bEnable \b IN: TRUE: enable IR, FALSE: disable IR 623 /// @return E_IR_OK: Success 624 /// @return E_IR_FAIL or other values: Failure 625 //------------------------------------------------------------------------------------------------- 626 void MDrv_IR_InitCfg(IR_InitCfgParam* pInitCfg); 627 //------------------------------------------------------------------------------------------------- 628 /// Set IR enable function. 629 /// @ingroup G_IR_CONTROL 630 /// @param bEnable \b IN: TRUE: enable IR, FALSE: disable IR 631 /// @return E_IR_OK: Success 632 /// @return E_IR_FAIL or other values: Failure 633 //------------------------------------------------------------------------------------------------- 634 void MDrv_IR_TimeCfg(IR_TimeCfgParam* pTimeCfg); 635 //------------------------------------------------------------------------------------------------- 636 /// Set IR enable function. 637 /// @ingroup G_IR_CONTROL 638 /// @param bEnable \b IN: TRUE: enable IR, FALSE: disable IR 639 /// @return E_IR_OK: Success 640 /// @return E_IR_FAIL or other values: Failure 641 //------------------------------------------------------------------------------------------------- 642 void MDrv_IR_GetPulseShot(IR_PulseShotInfo* pPulseShotInfo); 643 //------------------------------------------------------------------------------------------------- 644 /// Set IR enable function. 645 /// @ingroup G_IR_CONTROL 646 /// @param bEnable \b IN: TRUE: enable IR, FALSE: disable IR 647 /// @return E_IR_OK: Success 648 /// @return E_IR_FAIL or other values: Failure 649 //------------------------------------------------------------------------------------------------- 650 void MDrv_IR_SetMultiHeaderCode(MS_MultiIR_HeaderInfo* pMultiHeaderCode); 651 652 //-------------------------------------------------------------------------------------------------- 653 // Utopia2.0 will call this function to register IR module 654 //-------------------------------------------------------------------------------------------------- 655 //------------------------------------------------------------------------------------------------- 656 /// Set IR debug function. 657 /// @ingroup G_IR_ToBeRemove 658 /// @param eLevel \b IN: E_IR_DBGLVL_NONE/E_IR_DBGLVL_WARNING/E_IR_DBGLVL_ERROR/E_IR_DBGLVL_INFO/E_IR_DBGLVL_ALL 659 /// @return E_IR_OK: Success 660 /// @return E_IR_FAIL or other values: Failure 661 //------------------------------------------------------------------------------------------------- 662 void IRRegisterToUtopia(FUtopiaOpen ModuleType); 663 //------------------------------------------------------------------------------------------------- 664 /// Set IR debug function. 665 /// @ingroup G_IR_ToBeRemove 666 /// @param eLevel \b IN: E_IR_DBGLVL_NONE/E_IR_DBGLVL_WARNING/E_IR_DBGLVL_ERROR/E_IR_DBGLVL_INFO/E_IR_DBGLVL_ALL 667 /// @return E_IR_OK: Success 668 /// @return E_IR_FAIL or other values: Failure 669 //------------------------------------------------------------------------------------------------- 670 MS_U32 IROpen(void** pInstance, MS_U32 u32ModuleVersion, void* pAttribute); 671 //------------------------------------------------------------------------------------------------- 672 /// Set IR debug function. 673 /// @ingroup G_IR_ToBeRemove 674 /// @param eLevel \b IN: E_IR_DBGLVL_NONE/E_IR_DBGLVL_WARNING/E_IR_DBGLVL_ERROR/E_IR_DBGLVL_INFO/E_IR_DBGLVL_ALL 675 /// @return E_IR_OK: Success 676 /// @return E_IR_FAIL or other values: Failure 677 //------------------------------------------------------------------------------------------------- 678 MS_U32 IRClose(void* pInstance); 679 //------------------------------------------------------------------------------------------------- 680 /// Set IR debug function. 681 /// @ingroup G_IR_ToBeRemove 682 /// @param eLevel \b IN: E_IR_DBGLVL_NONE/E_IR_DBGLVL_WARNING/E_IR_DBGLVL_ERROR/E_IR_DBGLVL_INFO/E_IR_DBGLVL_ALL 683 /// @return E_IR_OK: Success 684 /// @return E_IR_FAIL or other values: Failure 685 //------------------------------------------------------------------------------------------------- 686 MS_U32 IRIoctl(void* pInstance, MS_U32 u32Cmd, void *pArgs); 687 688 //------------------------------------------------------------------------------------------------- 689 /// Set IR debug function. 690 /// @ingroup G_IR_ToBeRemove 691 /// @param eLevel \b IN: E_IR_DBGLVL_NONE/E_IR_DBGLVL_WARNING/E_IR_DBGLVL_ERROR/E_IR_DBGLVL_INFO/E_IR_DBGLVL_ALL 692 /// @return E_IR_OK: Success 693 /// @return E_IR_FAIL or other values: Failure 694 //------------------------------------------------------------------------------------------------- 695 MS_U32 MDrv_IR_SetPowerState(EN_POWER_MODE u16PowerState); 696 697 698 //IR_Private 699 typedef struct _IR_RESOURCE_PRIVATE 700 { 701 MS_U32 Dummy; 702 }IR_RESOURCE_PRIVATE; 703 704 typedef struct _IR_INSTANT_PRIVATE 705 { 706 707 }IR_INSTANT_PRIVATE; 708 709 710 #endif 711 712 #ifdef __cplusplus 713 } 714 #endif 715 716 717 #endif // _DRV_IR_H_ 718 719