irp.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:10k
源码类别:

DVD

开发平台:

C/C++

  1. #include <gendef.h>
  2. #include <stblast.h>
  3. #include <stcommon.h>
  4. #include <string.h>
  5. #include <sti5105.h>
  6. #include <swconfig.h>
  7. #include <stsys.h>
  8. #include "irp.h"
  9. #include "osp.h"
  10. /******************************************************************************
  11. *                        Extern variables
  12. ******************************************************************************/
  13. extern void IRCEvtCallback
  14. (
  15. STEVT_CallReason_t Reason,
  16. const ST_DeviceName_t RegistrantName,
  17. STEVT_EventConstant_t Event,
  18. const void *EventData,
  19. const void *SubscriberData_p
  20. );
  21. /******************************************************************************
  22. *                        Local variables
  23. ******************************************************************************/
  24. static ST_DeviceName_t  BLAST_DeviceName = {"RX"};
  25. ST_ClockInfo_t ST_ClockInfo;
  26. static ST_DeviceName_t  EvtblastDeviceName = "EVTBlast";
  27. extern partition_t *SystemPartition;
  28. STBLAST_Handle_t BLAST_Handle;
  29. UINT32 BlasterSemaphore_p;
  30. static STEVT_Handle_t IrEvtHandle;
  31. UINT32 blaster_EvtInit(void)
  32. {
  33. ST_ErrorCode_t error = ST_NO_ERROR;
  34. STEVT_InitParams_t EVTInitParams;
  35. STEVT_OpenParams_t EVTOpenParams;
  36. EVTInitParams.EventMaxNum = EVT_MAX_EVENTS;
  37. EVTInitParams.ConnectMaxNum = EVT_MAX_CONNECTIONS;
  38. EVTInitParams.SubscrMaxNum = EVT_MAX_SUBSCRIBERS;
  39. EVTInitParams.MemoryPartition = SystemPartition;
  40. error = STEVT_Init(EvtblastDeviceName, &EVTInitParams);
  41. if (error == ST_NO_ERROR)
  42. {
  43. error = STEVT_Open(EvtblastDeviceName, &EVTOpenParams,&IrEvtHandle);
  44. if(error != ST_NO_ERROR)
  45. {
  46. STTBX_Print(("STEVT_Open for blast failed"));
  47. return RETFIAL1;
  48. }
  49. }
  50. else
  51. {
  52. STTBX_Print(("STEVT_Init for blast failed"));
  53. return RETFIAL1;
  54. }
  55. return RETOK;
  56. }
  57. UINT32 blaster_Init(void)
  58. {
  59.     ST_ErrorCode_t  error;
  60. STBLAST_InitParams_t BLASTInitParams;
  61.     STBLAST_OpenParams_t BlastOpenParams;
  62.     STEVT_DeviceSubscribeParams_t   EvtSubParams;
  63.     STBLAST_Protocol_t              Protocol;
  64.     STBLAST_ProtocolParams_t        ProtocolParams;
  65.     memset(&BLASTInitParams, 0, sizeof(STBLAST_InitParams_t));
  66.     memset(&BlastOpenParams, 0, sizeof(STBLAST_OpenParams_t));
  67. memset(&ProtocolParams, 0, sizeof(STBLAST_ProtocolParams_t));
  68. ST_GetClockInfo(&ST_ClockInfo);    
  69.     
  70.     /* General parameter for blaster initialization */
  71.     /* Parameters for IR receiver */
  72.     BLASTInitParams.DeviceType = STBLAST_DEVICE_IR_RECEIVER;
  73.     BLASTInitParams.DriverPartition = SystemPartition;
  74.     BLASTInitParams.ClockSpeed = BLAST_CLOCK_FREQUENCY;
  75.     BLASTInitParams.SymbolBufferSize = SYMBOL_BUFFER_SIZE;
  76.     BLASTInitParams.BaseAddress         = (U32 *)IRB_BASE_ADDRESS;
  77.     BLASTInitParams.InterruptNumber = IRB_INTERRUPT;
  78.     BLASTInitParams.InterruptLevel      = IRB_INTERRUPT_LEVEL;
  79.     BLASTInitParams.InputActiveLow      = TRUE;
  80.     strcpy(BLASTInitParams.EVTDeviceName, EvtblastDeviceName);
  81.     strcpy(BLASTInitParams.RxPin.PortName, BLAST_RXD_PIO);
  82.     BLASTInitParams.RxPin.BitMask = BLAST_RXD_BIT;
  83.     error = STBLAST_Init(BLAST_DeviceName, &BLASTInitParams);
  84. if (error != ST_NO_ERROR)
  85. {
  86. STTBX_Print(("nSTBLAST_Init Error,Code=0x%x",error));
  87. return RETFIAL1;
  88. }
  89.     BlastOpenParams.RxParams.GlitchWidth = 0;
  90.     error = STBLAST_Open(BLAST_DeviceName, &BlastOpenParams, &BLAST_Handle);
  91. if (error != ST_NO_ERROR)
  92. {
  93. STTBX_Print(("nSTBLAST_Open Error"));
  94. return RETFIAL1;
  95. }
  96.     /* Subscribe to the relevant blaster events */
  97.     memset(&EvtSubParams, 0, sizeof(EvtSubParams));
  98.     EvtSubParams.NotifyCallback = IRCEvtCallback;
  99.     error = STEVT_SubscribeDeviceEvent(IrEvtHandle,
  100.                                BLAST_DeviceName,
  101.                                STBLAST_READ_DONE_EVT,
  102.                                &EvtSubParams);
  103. if (error != ST_NO_ERROR)
  104. {
  105. STTBX_Print(("IRC Sbscribe Event Error"));
  106. }
  107. KB_OSPSemInit("BLAS", 0, J_OSP_WAIT_FIFO, &BlasterSemaphore_p);
  108. /* Config the protocol */
  109. #if defined (PROTOCOL_RC6A)
  110.     Protocol                                        = STBLAST_PROTOCOL_RC6A;
  111.     ProtocolParams.RC6A.CustomerCode                = 0x00000000;
  112.     ProtocolParams.RC6A.BufferElementsPerPayload    = 1; /* not used yet */
  113.     ProtocolParams.RC6A.NumberPayloadBits           = 12;
  114. error = STBLAST_SetProtocol(BLAST_Handle, Protocol, &ProtocolParams);
  115. #elif defined (PROTOCOL_RC6_MODE0)
  116. Protocol                                        = STBLAST_PROTOCOL_RC6_MODE0;
  117.     ProtocolParams.RC6A.CustomerCode                = 39;
  118.     ProtocolParams.RC6A.BufferElementsPerPayload    = 1; /* not used yet */
  119.     ProtocolParams.RC6A.NumberPayloadBits           = 8;
  120. error = STBLAST_SetProtocol(BLAST_Handle, Protocol, &ProtocolParams);
  121. #elif defined (PROTOCOL_RC5)   /* protocol params is not required for the RC5 */
  122.     Protocol                                        = STBLAST_PROTOCOL_RC5;
  123. memset(&ProtocolParams, 0, sizeof(STBLAST_ProtocolParams_t));
  124. error = STBLAST_SetProtocol(BLAST_Handle, Protocol, &ProtocolParams);
  125. #elif defined (PROTOCOL_USER_DEFINED)
  126. Protocol = STBLAST_PROTOCOL_USER_DEFINED;
  127. /*----------------- NEC Remote Control ------------------*/
  128.     ProtocolParams.UserDefined.Coding = STBLAST_CODING_SPACE;
  129.     ProtocolParams.UserDefined.SubCarrierFreq     = 38000;
  130.     ProtocolParams.UserDefined.NumberStartSymbols = 1;
  131.     ProtocolParams.UserDefined.NumberStopSymbols  = 0;
  132. #if defined(ST_7100)   
  133.     /* for 7100 the received value tolerence is diffrent
  134.       depends on receiver */ 
  135.     ProtocolParams.UserDefined.HighDataSymbol.MarkPeriod   = 600;
  136.     ProtocolParams.UserDefined.HighDataSymbol.SymbolPeriod = 2240;
  137.     ProtocolParams.UserDefined.LowDataSymbol.MarkPeriod    = 600;
  138.     ProtocolParams.UserDefined.LowDataSymbol.SymbolPeriod  = 1120;
  139. #else
  140.     ProtocolParams.UserDefined.HighDataSymbol.MarkPeriod   = 560;
  141.     ProtocolParams.UserDefined.HighDataSymbol.SymbolPeriod = 2240;
  142.     ProtocolParams.UserDefined.LowDataSymbol.MarkPeriod    = 560;
  143.     ProtocolParams.UserDefined.LowDataSymbol.SymbolPeriod  = 1120;
  144. #endif    
  145.     ProtocolParams.UserDefined.NumberPayloadBits        = 32;
  146.     ProtocolParams.UserDefined.BufferElementsPerPayload = 1;
  147.     /* Setup the SPACE coded protocol */
  148.     /* Start symbol */
  149.     ProtocolParams.UserDefined.StartSymbols[0].MarkPeriod   = 9000;
  150.     ProtocolParams.UserDefined.StartSymbols[0].SymbolPeriod = 13500;
  151. #if 0
  152. /*--------- Force Remote Control ------------*/
  153.     ProtocolParams.UserDefined.Coding = STBLAST_CODING_SPACE;
  154.     ProtocolParams.UserDefined.SubCarrierFreq = 38000;
  155.     ProtocolParams.UserDefined.NumberStartSymbols = 10;
  156.     ProtocolParams.UserDefined.NumberStopSymbols = 0;
  157.     ProtocolParams.UserDefined.HighDataSymbol.MarkPeriod = 600;
  158.     ProtocolParams.UserDefined.HighDataSymbol.SymbolPeriod = 2000;
  159.     ProtocolParams.UserDefined.LowDataSymbol.MarkPeriod = 600;
  160.     ProtocolParams.UserDefined.LowDataSymbol.SymbolPeriod = 1000;
  161.     ProtocolParams.UserDefined.NumberPayloadBits = 8;
  162.     ProtocolParams.UserDefined.BufferElementsPerPayload=1;
  163.     /* Setup the SPACE coded protocol */
  164.     /* Start symbol */
  165.     ProtocolParams.UserDefined.StartSymbols[0].MarkPeriod = 8000;
  166.     ProtocolParams.UserDefined.StartSymbols[0].SymbolPeriod = 12000;
  167.     
  168.     /* Address symbols */
  169.     ProtocolParams.UserDefined.StartSymbols[1].MarkPeriod = 600;   /* 0*/
  170.     ProtocolParams.UserDefined.StartSymbols[1].SymbolPeriod = 1000;
  171.     ProtocolParams.UserDefined.StartSymbols[2].MarkPeriod = 600;   /* 0*/
  172.     ProtocolParams.UserDefined.StartSymbols[2].SymbolPeriod = 1000;
  173.     ProtocolParams.UserDefined.StartSymbols[3].MarkPeriod = 600;   /* 0*/
  174.     ProtocolParams.UserDefined.StartSymbols[3].SymbolPeriod = 1000;
  175.     ProtocolParams.UserDefined.StartSymbols[4].MarkPeriod = 600;   /* 1*/
  176.     ProtocolParams.UserDefined.StartSymbols[4].SymbolPeriod = 2000;
  177.     ProtocolParams.UserDefined.StartSymbols[5].MarkPeriod = 600;   /* 0*/
  178.     ProtocolParams.UserDefined.StartSymbols[5].SymbolPeriod = 1000;
  179.     ProtocolParams.UserDefined.StartSymbols[6].MarkPeriod = 600;   /* 0*/
  180.     ProtocolParams.UserDefined.StartSymbols[6].SymbolPeriod = 1000;
  181.     ProtocolParams.UserDefined.StartSymbols[7].MarkPeriod = 600;   /* 0*/
  182.     ProtocolParams.UserDefined.StartSymbols[7].SymbolPeriod = 1000;
  183.     ProtocolParams.UserDefined.StartSymbols[8].MarkPeriod = 600;   /* 0*/
  184.     ProtocolParams.UserDefined.StartSymbols[8].SymbolPeriod = 1000;
  185.     
  186.     /* Padding symbol */
  187.     ProtocolParams.UserDefined.StartSymbols[9].MarkPeriod = 600;
  188.     ProtocolParams.UserDefined.StartSymbols[9].SymbolPeriod = 4500;
  189. /*----------------- Sony Remote Control ------------------*/
  190.     ProtocolParams.UserDefined.Coding = STBLAST_CODING_PULSE;  
  191.     ProtocolParams.UserDefined.SubCarrierFreq = 40000;
  192.     ProtocolParams.UserDefined.NumberStartSymbols = 1;
  193.     ProtocolParams.UserDefined.NumberStopSymbols = 0;
  194.     ProtocolParams.UserDefined.HighDataSymbol.MarkPeriod = 600;
  195.     ProtocolParams.UserDefined.HighDataSymbol.SymbolPeriod = 1200;
  196.     ProtocolParams.UserDefined.LowDataSymbol.MarkPeriod = 1200;
  197.     ProtocolParams.UserDefined.LowDataSymbol.SymbolPeriod = 1800;
  198.     ProtocolParams.UserDefined.NumberPayloadBits = 12;
  199.     ProtocolParams.UserDefined.StartSymbols[0].MarkPeriod = 2400;
  200.     ProtocolParams.UserDefined.StartSymbols[0].SymbolPeriod = 3000;
  201. /*----------------- ST Remote Control --------------------*/
  202.     ProtocolParams.UserDefined.Coding = STBLAST_CODING_SPACE;
  203.     ProtocolParams.UserDefined.SubCarrierFreq = 5000;
  204.     ProtocolParams.UserDefined.NumberStartSymbols = 0;
  205.     ProtocolParams.UserDefined.NumberStopSymbols = 0;
  206.     ProtocolParams.UserDefined.HighDataSymbol.MarkPeriod = 250;
  207.     ProtocolParams.UserDefined.HighDataSymbol.SymbolPeriod = 7600;
  208.     ProtocolParams.UserDefined.LowDataSymbol.MarkPeriod = 250;
  209.     ProtocolParams.UserDefined.LowDataSymbol.SymbolPeriod = 5100;
  210.     ProtocolParams.UserDefined.NumberPayloadBits = 12;
  211. #endif
  212. error = STBLAST_SetProtocol(BLAST_Handle, Protocol, &ProtocolParams);
  213. #endif
  214. if (error != ST_NO_ERROR)
  215. {
  216. STTBX_Print(("nSTBLAST_SetProtocol Error %dn", error));
  217. return RETFIAL1;
  218. }
  219. STTBX_Print(("nblaster_Init OKn"));
  220. return RETOK;
  221. }
  222. /* End of file */