option_330.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #include "mergeImage.h"
  2. #include <Customization.h>
  3. #include "gpioset.h"
  4. #ifdef OP_IRCommandType
  5. #define showMsg( args... ) printf( args )
  6. CUSTIMIZATION_TABLE OptionData;
  7. int GetOptionData(void )
  8. {
  9. //unsigned char i, j;
  10. showMsg( "\n**** GetOptionData ****\n");
  11. memset(&OptionData, 0, sizeof(OptionData));
  12. /* ------------------------------------------------*/
  13. #if 0
  14. OptionData.GPIOSET[0] = 0x1e;
  15. OptionData.GPIOSET[1] = 0x02;
  16. OptionData.GPIOSET[2] = 0x15;
  17. OptionData.GPIOSET[3] = 0x16;
  18. OptionData.GPIOSET[4] = 0xe0;
  19. OptionData.GPIOSET[5] = 0xa4;
  20. OptionData.GPIOSET[6] = 0x88;
  21. OptionData.GPIOSET[7] = 0x09;
  22. OptionData.GPIOSET[8] = 0x0a;
  23. OptionData.GPIOSET[9] = 0x0b;
  24. OptionData.GPIOSET[10] = 0x0c;
  25. OptionData.GPIOSET[11] = 0x0d;
  26. OptionData.GPIOSET[12] = 0x0e;
  27. OptionData.GPIOSET[13] = 0x11;
  28. OptionData.GPIOSET[14] = 0xc3;
  29. OptionData.GPIOSET[15] = 0xbf;
  30. OptionData.GPIOSET[16] = 0xff;
  31. OptionData.GPIOSET[17] = 0x00;
  32. #endif
  33. /*------------------------------------------------*/
  34. OptionData.IRCommandType = OP_IRCommandType;
  35. // IR setting
  36. OptionData.pIR_Set[0] = OP_IR_Protocol_reg; /* 0xbe080004 */
  37. showMsg( "OP_IR_Protocol_reg=%x\tpIR_Set=%x\n", (unsigned int)OP_IR_Protocol_reg, (unsigned int)OptionData.pIR_Set[0]);
  38. OptionData.pIR_Set[1] = OP_IR_Interrupt_en_reg; /* 0xbe080008 */
  39. OptionData.pIR_Set[2] = OP_IR_Interrupt_staus; /* 0xbe08000c */
  40. OptionData.pIR_Set[3] = OP_IR_MinSpaceBetweenPacket; /* 0xbe080010 */
  41. OptionData.pIR_Set[4] = OP_IR_Max_Min_Symbol; /* 0xbe080014 */
  42. OptionData.pIR_Set[5] = OP_IR_Max_Min_Short_Mark; /* 0xbe080018 */
  43. OptionData.pIR_Set[6] = OP_IR_Max_Min_Short_Space; /* 0xbe08001c */
  44. OptionData.pIR_Set[7] = OP_IR_Max_Min_Long_Mark; /* 0xbe080020 */
  45. OptionData.pIR_Set[8] = OP_IR_Max_Min_Head_Mark; /* 0xbe080024 */
  46. OptionData.pIR_Set[9] = OP_IR_Max_Min_Head_Space; /* 0xbe080028 */
  47. OptionData.pIR_Set[10] =OP_IR_REG_2C; /* 0xbe08002c */
  48. OptionData.pIR_Set[11] =OP_IR_Max_Min_Repeat_Space; /* 0xbe080030 */
  49. OptionData.pIR_Set[12] =OP_IR_Extra_Decode_Option; /* 0xbe080034 */
  50. OptionData.pIR_Set[13] =OP_IR_REG_38; /* 0xbe080038 */
  51. OptionData.pIR_Set[14] =OP_IR_WatchDog_Timeout; /* 0xbe08003c */
  52. OptionData.pIR_Set[15] =OP_IR_Repeat_Threshold; /* 0xbe080040 */
  53. OptionData.pIR_Set[16] =OP_IR_Packet_Timeout_Threshold; /* 0xbe080044 */
  54. OptionData.pIR_Set[17] =OP_IR_Key_Press_Counter; /* 0xbe080048 */
  55. OptionData.pIR_Set[18] =OP_IR_Protocol_Type_Option; /* 0xbe08004c */
  56. OptionData.pIR_Set[19] =OP_IR_Internal_Counter; /* 0xbe080050 */
  57. OptionData.pIR_Set[20] =OP_IR_Bit47_to_Bit16; /* 0xbe080054 */
  58. OptionData.pIR_Set[21] =OP_IR_Receiver_Signal; /* 0xbe080058 */
  59. OptionData.pIR_Set[22] =OP_IR_Power_Code_Option; /* 0xbe08005c */
  60. OptionData.pIR_Set[23] =OP_IR_Power_Code_A_Low_Channel; /* 0xbe080060 */
  61. OptionData.pIR_Set[24] =OP_IR_Power_Code_A_High_Channel;/* 0xbe080064 */
  62. OptionData.pIR_Set[25] =OP_IR_Power_Code_B_Low_Channel; /* 0xbe080068 */
  63. OptionData.pIR_Set[26] =OP_IR_Power_Code_B_High_Channel;/* 0xbe08006c */
  64. OptionData.pIR_Set[27] =OP_IR_Power_Code_C_Low_Channel; /* 0xbe080070 */
  65. OptionData.pIR_Set[28] =OP_IR_Power_Code_C_High_Channel;/* 0xbe080074 */
  66. OptionData.pIR_Set[29] =OP_IR_Power_Code_D_Low_Channel; /* 0xbe080078 */
  67. OptionData.pIR_Set[30] =OP_IR_Power_Code_D_High_Channel;/* 0xbe08007c */
  68. OptionData.pIR_Set[31] =OP_IR_Max_Min_Long1_MarkSpace; /* 0xbe080080 */
  69. OptionData.pIR_Set[32] =OP_IR_Max_Min_Long2_MarkSpace; /* 0xbe080084 */
  70. //------------------------------------------------//
  71. OptionData.PowerOnKeySets = 2;
  72. OptionData.KEYPAD_PWR_ON_KEY = OP_KEYPAD_PWR_ON_KEY;
  73. showMsg("----\n");
  74. //------------------------------------------------//
  75. // LED
  76. OptionData.GreenLEDNum = 0x01; // GPIO 01 as Green LED
  77. OptionData.GreenLEDMode = 1; // GPIO mode
  78. OptionData.RedLEDNum = 1; // PWM0 as Red LED
  79. OptionData.RedLEDMode = 0; // PWM mode
  80. OptionData.LEDOnStatus = 0x80;
  81. OptionData.LEDOffStatus = 0x40;
  82. // Panel
  83. OptionData.PanelPWROnGPIONum = 2; // GPIO 02 as panel power control
  84. OptionData.PanelBackLightGPIONum = 30; // GPIO 30 as Back Light control
  85. OptionData.PanelPWMNum = 2; // PWM 2 as Back Light Brig
  86. //------------------------------------------------//
  87. OptionData.DVD_IROUT_GPIO_NO = 28; /* 0xbe080098 */
  88. //------------------------------------------------//
  89. OptionData.HDMISwitchMap = OP_HDMI_SWITCH; /* 0xbe08009A */
  90. OptionData.HDMIPortMap = OP_HDMI_PORT_MAP; /* 0xbe08009C */
  91. OptionData.IR_PowerOnKey[0].Custom_Code = 0x09f6; /* 0xbe0800A0 */
  92. OptionData.IR_PowerOnKey[0].Key_Code[0] = 0x45ba;
  93. OptionData.IR_PowerOnKey[1].Custom_Code = 0x649b; /* 0xbe0800C0 */
  94. OptionData.IR_PowerOnKey[1].Key_Code[0] = 0x50af;
  95. showMsg( "\n**** GetOptionData done ****\n");
  96. //------------------------------------------------//
  97. showMsg( "**** size of Option:%x ****\n", sizeof(OptionData));
  98. return 0;
  99. }
  100. int GPIOini2Bin(unsigned char *GPIOData)
  101. {
  102. int i, j;
  103. char pChar[256];
  104. PADJUST_GPIO GPIOiniData;
  105. GPIO_FORMAT GPIOset[64];
  106. FILE *fPtr;
  107. char GPIOdescript[256];
  108. int nFieldNum;
  109. showMsg( "\n**** GPIOini2Bin ****\n");
  110. memset(pChar, 0xFF, sizeof(pChar));
  111. memset(GPIOset, 0, sizeof(GPIOset));
  112. memset(GPIOdescript, 0, sizeof(GPIOdescript));
  113. GPIOiniData = (PADJUST_GPIO)(pChar);
  114. fPtr = fopen(GPIOSetIniFileName, "r");
  115. if ( fPtr == NULL ) {
  116. showMsg("### Open %s file fail ###\n", GPIOSetIniFileName);
  117. return -1;
  118. }
  119. do {
  120. // Get string from file
  121. if(fgets(GPIOdescript, sizeof(GPIOdescript), fPtr));
  122. } while (((GPIOdescript[0]=='#')&&(GPIOdescript[1]!='i')&&(GPIOdescript[2]!='n')&&(GPIOdescript[3]!='d')&&(GPIOdescript[4]!='e')&&(GPIOdescript[5]!='x')) || \
  123. ((GPIOdescript[0]!='i')&&(GPIOdescript[1]!='n')&&(GPIOdescript[2]!='d')&&(GPIOdescript[3]!='e')&&(GPIOdescript[4]!='x')) );
  124. j = 0;
  125. for ( i=0;i<64;i++) {
  126. nFieldNum = fscanf(fPtr,"%d %d %d %d %d %d %d %d %d %d %d %x",(int *)&GPIOset[i].index, \
  127. (int *)&GPIOset[i].AuxEnalbe,\
  128. (int *)&GPIOset[i].AuxMode,\
  129. (int *)&GPIOset[i].AuxValue,\
  130. (int *)&GPIOset[i].AInternalPU,\
  131. (int *)&GPIOset[i].AInternalPD, \
  132. (int *)&GPIOset[i].MainEnalbe,\
  133. (int *)&GPIOset[i].MainMode,\
  134. (int *)&GPIOset[i].MainValue,\
  135. (int *)&GPIOset[i].MInternalPU, \
  136. (int *)&GPIOset[i].MInternalPD, \
  137. (int *)&GPIOset[i].MDELAY_TIME);
  138. GPIOiniData->GPIO[j] = GPIOset[i].index;
  139. GPIOiniData->GPIO[j+1] = GPIOset[i].AuxEnalbe +\
  140. (GPIOset[i].AuxMode<<1) +\
  141. (GPIOset[i].AuxValue<<2) +\
  142. (GPIOset[i].AInternalPU<<3) +\
  143. (GPIOset[i].AInternalPD<<4) +\
  144. (GPIOset[i].MainEnalbe<<5) +\
  145. (GPIOset[i].MainMode<<6) +\
  146. (GPIOset[i].MainValue<<7);
  147. GPIOiniData->GPIO[j+2] = (GPIOset[i].MInternalPU<<6) +\
  148. (GPIOset[i].MInternalPD<<7) +\
  149. (GPIOset[i].MDELAY_TIME&0x3F);
  150. //showMsg("\n**** GPIO%d:%02x %02x ****\n", GPIOiniData->GPIO[j], GPIOiniData->GPIO[j+1], GPIOiniData->GPIO[j+2]);
  151. j = j+3;
  152. if ( feof(fPtr) ) break;
  153. }
  154. fclose(fPtr);
  155. memcpy(GPIOData, GPIOiniData, sizeof(ADJUST_GPIO));
  156. showMsg( "\n**** GPIOini2Bin done (%d sets) ****\n", nFieldNum);
  157. return 0;
  158. }
  159. #endif // OP_IRCommandType