wifi_alc.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:23k
源码类别:

MTK

开发平台:

C++ Builder

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2001
  8. *
  9. *****************************************************************************/
  10. /*****************************************************************************
  11.  *
  12.  * Filename:
  13.  * ---------
  14.  *   wifi_alc.cpp
  15.  *
  16.  * Project:
  17.  * --------
  18.  *   Maui META APP
  19.  *
  20.  * Description:
  21.  * ------------
  22.  *   WiFi ALC source
  23.  *
  24.  * Author:
  25.  * -------
  26.  *  Andy Ueng (mtk00490)
  27.  *
  28.  *============================================================================
  29.  *             HISTORY
  30.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  31.  *------------------------------------------------------------------------------
  32.  * $Revision$
  33.  * $Modtime$
  34.  * $Log$
  35.  * 
  36.  *------------------------------------------------------------------------------
  37.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  38.  *============================================================================
  39.  ****************************************************************************/
  40. #pragma hdrstop
  41. #ifndef  _WIFI_COMMON_H_
  42. #include "wifi_common.h"
  43. #endif
  44. #ifndef  _WIFI_ALC_H_
  45. #include "wifi_alc.h"
  46. #endif
  47. // man
  48. #ifndef  _MAN_FDM_H_
  49. #include "man_fdm.h"
  50. #endif
  51. #ifndef  _MAN_ACTIVE_H_
  52. #include "man_active.h"
  53. #endif
  54. // misc
  55. #ifndef  _FT_UTILS_H_
  56. #include "ft_utils.h"
  57. #endif
  58. //===========================================================================
  59. static CWIFIALC*  g_wifi_alc_ptr;
  60. static bool g_bIsRunning = false;
  61. //===========================================================================
  62. static void REQ_ReadAlcPowerFromNVRAM(void)
  63. {
  64.     g_wifi_alc_ptr->REQ_ReadAlcPowerFromNVRAM();
  65. }
  66. //---------------------------------------------------------------------------
  67. static void CNF_ReadAlcPowerFromNVRAM(void)
  68. {
  69.     g_wifi_alc_ptr->CNF_ReadAlcPowerFromNVRAM();
  70. }
  71. //---------------------------------------------------------------------------
  72. static void REQ_WriteAlcPowerToNVRAM(void)
  73. {
  74.     g_wifi_alc_ptr->REQ_WriteAlcPowerToNVRAM();
  75. }
  76. //---------------------------------------------------------------------------
  77. static void CNF_WriteAlcPowerToNVRAM(void)
  78. {
  79.     g_wifi_alc_ptr->CNF_WriteAlcPowerToNVRAM();
  80. }
  81. //---------------------------------------------------------------------------
  82. static void REQ_ReadAlcSlopeFromNVRAM(void)
  83. {
  84.     g_wifi_alc_ptr->REQ_ReadAlcSlopeFromNVRAM();
  85. }
  86. //---------------------------------------------------------------------------
  87. static void CNF_ReadAlcSlopeFromNVRAM(void)
  88. {
  89.     g_wifi_alc_ptr->CNF_ReadAlcSlopeFromNVRAM();
  90. }
  91. //---------------------------------------------------------------------------
  92. static void REQ_WriteAlcSlopeToNVRAM(void)
  93. {
  94.     g_wifi_alc_ptr->REQ_WriteAlcSlopeToNVRAM();
  95. }
  96. //---------------------------------------------------------------------------
  97. static void CNF_WriteAlcSlopeToNVRAM(void)
  98. {
  99.     g_wifi_alc_ptr->CNF_WriteAlcSlopeToNVRAM();
  100. }
  101. //---------------------------------------------------------------------------
  102. static void REQ_TimeOut(void)
  103. {
  104.     g_wifi_alc_ptr->REQ_TimeOut();
  105. }
  106. //---------------------------------------------------------------------------
  107. static void REQ_Finish(void)
  108. {
  109.     g_wifi_alc_ptr->REQ_Finish();
  110. }
  111. //===========================================================================
  112. CWIFIALC::CWIFIALC(void)
  113. {
  114.     g_bIsRunning = false;
  115.     ConfirmCallback = NULL;
  116.     m_uiAlcPowerBufSize2400M = 0;
  117.     m_cAlcPowerBuf2400M = NULL;
  118.     m_uiAlcSlopeBufSize2400M = 0;
  119.     m_cAlcSlopeBuf2400M = NULL;
  120. }
  121. //---------------------------------------------------------------------------
  122. CWIFIALC::~CWIFIALC()
  123. {
  124.     g_bIsRunning = false;
  125.     ConfirmCallback = NULL;
  126.     if (m_cAlcPowerBuf2400M)
  127.     {
  128.         delete [] m_cAlcPowerBuf2400M;
  129.         m_cAlcPowerBuf2400M = NULL;
  130.     }
  131.     if (m_cAlcSlopeBuf2400M)
  132.     {
  133.         delete [] m_cAlcSlopeBuf2400M;
  134.         m_cAlcSlopeBuf2400M = NULL;
  135.     }
  136. }
  137. //---------------------------------------------------------------------------
  138. void CWIFIALC::REQ_Finish(void)
  139. {
  140.     if (!g_bIsRunning)
  141.     {
  142.         return;
  143.     }
  144.     Confirm(METAAPP_SUCCESS);
  145. }
  146. //---------------------------------------------------------------------------
  147. void CWIFIALC::REQ_Stop(void)
  148. {
  149.     if (!g_bIsRunning)
  150.     {
  151.         return;
  152.     }
  153.     NVRAMMan->REQ_Stop();
  154.     Confirm(METAAPP_STOP);
  155. }
  156. //---------------------------------------------------------------------------
  157. void CWIFIALC::REQ_TimeOut(void)
  158. {
  159.     if (!g_bIsRunning)
  160.     {
  161.         return;
  162.     }
  163.     
  164.     NVRAMMan->REQ_Stop();
  165.     Confirm(METAAPP_TIMEOUT);
  166. }
  167. //---------------------------------------------------------------------------
  168. void CWIFIALC::Confirm(E_METAAPP_RESULT_T confirm_state)
  169. {
  170.     if (!g_bIsRunning)
  171.     {
  172.         return;
  173.     }
  174.     g_bIsRunning = false;
  175.     if (NULL == ConfirmCallback)
  176.     {
  177.         return;
  178.     }
  179.     m_eConfirmState = confirm_state;
  180.     ActiveMan->SetActiveFunction(ConfirmCallback);
  181. }
  182. //===========================================================================
  183. void CWIFIALC::REQ_Read_From_NVRAM_Start(void)
  184. {
  185.     g_wifi_alc_ptr = this;
  186.     g_bIsRunning = true;
  187.     REQ_ReadAlcPowerFromNVRAM();
  188. }
  189. //-------------------------------------
  190. void CWIFIALC::REQ_ReadAlcPowerFromNVRAM(void)
  191. {
  192.     if (!g_bIsRunning)
  193.     {
  194.         return;
  195.     }
  196.     if (NULL == m_cAlcPowerBuf2400M)
  197.     {
  198.         META_RESULT MetaResult;
  199.         MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_WNDRV_TX_ALC_POWER_LID", (int *) &m_uiAlcPowerBufSize2400M);
  200.         if (MetaResult != META_SUCCESS)
  201.         {
  202.             Confirm(METAAPP_FAIL );
  203.             return;
  204.         }
  205.         m_cAlcPowerBuf2400M = new char[m_uiAlcPowerBufSize2400M];
  206.     }
  207.     NVRAMMan->ConfirmCallback = ::CNF_ReadAlcPowerFromNVRAM;
  208.     NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_WNDRV_TX_ALC_POWER_LID",
  209.                                   1,
  210.                                   m_uiAlcPowerBufSize2400M,
  211.                                   m_cAlcPowerBuf2400M);
  212. }
  213. //-------------------------------------
  214. void CWIFIALC::CNF_ReadAlcPowerFromNVRAM(void)
  215. {
  216.     if (!g_bIsRunning)
  217.     {
  218.         return;
  219.     }
  220.     E_METAAPP_RESULT_T  state = NVRAMMan->Get_ConfirmState();
  221.     switch (state)
  222.     {
  223.         case METAAPP_SUCCESS:
  224.         {
  225.             META_RESULT  MetaResult;
  226.             MetaResult = META_NVRAM_WiFi_Decompose_ALC_2400M(&m_sAlcPower2400M, m_cAlcPowerBuf2400M, m_uiAlcPowerBufSize2400M);
  227.             if (MetaResult != META_SUCCESS)
  228.             {
  229.                 Confirm(METAAPP_FAIL);
  230.                 return;
  231.             }
  232.             REQ_ReadAlcSlopeFromNVRAM();
  233.         }
  234.         break;
  235.         default:
  236.         {
  237.             Confirm(state);
  238.         }
  239.         break;
  240.     }
  241. }
  242. //--------------------------------------------------------------------------
  243. void CWIFIALC::REQ_ReadAlcSlopeFromNVRAM(void)
  244. {
  245.     if (!g_bIsRunning)
  246.     {
  247.         return;
  248.     }
  249.     if (NULL == m_cAlcSlopeBuf2400M)
  250.     {
  251.         META_RESULT MetaResult;
  252.         MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_WNDRV_ALC_SLOPE_LID", (int *) &m_uiAlcSlopeBufSize2400M);
  253.         if (MetaResult != META_SUCCESS)
  254.         {
  255.             Confirm(METAAPP_FAIL );
  256.             return;
  257.         }
  258.         m_cAlcSlopeBuf2400M = new char[m_uiAlcSlopeBufSize2400M];
  259.     }
  260.     NVRAMMan->ConfirmCallback = ::CNF_ReadAlcSlopeFromNVRAM;
  261.     NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_WNDRV_ALC_SLOPE_LID",
  262.                                   1,
  263.                                   m_uiAlcSlopeBufSize2400M,
  264.                                   m_cAlcSlopeBuf2400M);
  265. }
  266. //-------------------------------------
  267. void CWIFIALC::CNF_ReadAlcSlopeFromNVRAM(void)
  268. {
  269.     if (!g_bIsRunning)
  270.     {
  271.         return;
  272.     }
  273.     E_METAAPP_RESULT_T  state = NVRAMMan->Get_ConfirmState();
  274.     switch (state)
  275.     {
  276.         case METAAPP_SUCCESS:
  277.         {
  278.             META_RESULT  MetaResult;
  279.             MetaResult = META_NVRAM_WiFi_Decompose_TxALC2400M(&m_sAlcSlope2400M, m_cAlcSlopeBuf2400M, m_uiAlcSlopeBufSize2400M);
  280.             if (MetaResult != META_SUCCESS)
  281.             {
  282.                 Confirm(METAAPP_FAIL);
  283.                 return;
  284.             }
  285.             ActiveMan->SetActiveFunction(::REQ_Finish);
  286.         }
  287.         break;
  288.         default:
  289.         {
  290.             Confirm(state);
  291.         }
  292.         break;
  293.     }
  294. }
  295. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  296. void CWIFIALC::REQ_Write_To_NVRAM_Start(void)
  297. {
  298.     g_wifi_alc_ptr = this;
  299.     g_bIsRunning = true;
  300.     REQ_WriteAlcPowerToNVRAM();
  301. }
  302. //---------------------------------------------------------------------------
  303. void CWIFIALC::REQ_WriteAlcPowerToNVRAM(void)
  304. {
  305.     if (!g_bIsRunning)
  306.     {
  307.         return;
  308.     }
  309.     if (NULL == m_cAlcPowerBuf2400M)
  310.     {
  311.         META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_WNDRV_TX_ALC_POWER_LID", (int *) &m_uiAlcPowerBufSize2400M);
  312.         if (MetaResult != META_SUCCESS)
  313.         {
  314.             Confirm(METAAPP_FAIL);
  315.             return;
  316.         }
  317.         m_cAlcPowerBuf2400M = new char[m_uiAlcPowerBufSize2400M];
  318.     }
  319.     META_RESULT  MetaResult;
  320.     MetaResult = META_NVRAM_WiFi_Compose_ALC_2400M(&m_sAlcPower2400M,
  321.                                                       m_cAlcPowerBuf2400M,
  322.                                                       m_uiAlcPowerBufSize2400M);
  323.     if (MetaResult != META_SUCCESS)
  324.     {
  325.         Confirm(METAAPP_FAIL);
  326.         return;
  327.     }
  328.     NVRAMMan->ConfirmCallback = ::CNF_WriteAlcPowerToNVRAM;
  329.     NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_WNDRV_TX_ALC_POWER_LID",
  330.                                    1,
  331.                                    m_uiAlcPowerBufSize2400M,
  332.                                    m_cAlcPowerBuf2400M
  333.                                    );
  334. }
  335. //-------------------------------------
  336. void CWIFIALC::CNF_WriteAlcPowerToNVRAM(void)
  337. {
  338.     if (!g_bIsRunning)
  339.     {
  340.         return;
  341.     }
  342.     E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
  343.     if (state != METAAPP_SUCCESS)
  344.     {
  345.         Confirm(state);
  346.         return;
  347.     }
  348.     REQ_WriteAlcSlopeToNVRAM();
  349. }
  350. //--------------------------------------------------------------------------
  351. void CWIFIALC::REQ_WriteAlcSlopeToNVRAM(void)
  352. {
  353.     if (!g_bIsRunning)
  354.     {
  355.         return;
  356.     }
  357.     if (NULL == m_cAlcSlopeBuf2400M)
  358.     {
  359.         META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_WNDRV_ALC_SLOPE_LID", (int *) &m_uiAlcSlopeBufSize2400M);
  360.         if (MetaResult != META_SUCCESS)
  361.         {
  362.             Confirm(METAAPP_FAIL);
  363.             return;
  364.         }
  365.         m_cAlcSlopeBuf2400M = new char[m_uiAlcSlopeBufSize2400M];
  366.     }
  367.     META_RESULT  MetaResult;
  368.     MetaResult = META_NVRAM_WiFi_Compose_TxALC2400M(&m_sAlcSlope2400M,
  369.                                                       m_cAlcSlopeBuf2400M,
  370.                                                       m_uiAlcSlopeBufSize2400M);
  371.     if (MetaResult != META_SUCCESS)
  372.     {
  373.         Confirm(METAAPP_FAIL);
  374.         return;
  375.     }
  376.     NVRAMMan->ConfirmCallback = ::CNF_WriteAlcSlopeToNVRAM;
  377.     NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_WNDRV_ALC_SLOPE_LID",
  378.                                    1,
  379.                                    m_uiAlcSlopeBufSize2400M,
  380.                                    m_cAlcSlopeBuf2400M
  381.                                    );
  382. }
  383. //-------------------------------------
  384. void CWIFIALC::CNF_WriteAlcSlopeToNVRAM(void)
  385. {
  386.     if (!g_bIsRunning)
  387.     {
  388.         return;
  389.     }
  390.     E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
  391.     Confirm(state);
  392. }
  393. //===========================================================================
  394. #define  TX_ALC_CCK_IDX              0
  395. #define  TX_OUTPUT_POWER_DB_CCK_IDX  1
  396. #define  TX_ALC_OFDM_IDX             2
  397. #define  TX_OUTPUT_POWER_DB_OFDM_IDX 3
  398. #define  ALC_SLOPE1_DIVIDER_IDX      0
  399. #define  ALC_SLOPE1_DIVIDEND_IDX     1
  400. #define  ALC_SLOPE2_DIVIDER_IDX      2
  401. #define  ALC_SLOPE2_DIVIDEND_IDX     3
  402. static const AnsiString asSECTION_NAME_2400M = "WiFi ALC 2.4G";
  403. static const AnsiString asKEY_NAME_POWER_2400M[] =
  404. {
  405.     "TX ALC CCK",
  406.     "TX output power DB CCK",
  407.     "TX ALC OFDM",
  408.     "TX output power DB OFDM"
  409. };
  410. static const AnsiString asKEY_NAME_SLOPE_2400M[] =
  411. {
  412.     "ALC Slop1 Divider",
  413.     "ALC Slop1 Dividend",
  414.     "ALC Slop2 Divider",
  415.     "ALC Slop2 Dividend"
  416. };
  417. //----------------------------------------------------------------------------
  418. bool CWIFIALC::WiFiAlc2400MSectionExist(char *filename)
  419. {
  420.     TIniFile   *ini_file;
  421.     ini_file = new TIniFile(filename);
  422.     if (NULL == ini_file)
  423.     {
  424.         return false;
  425.     }
  426.     if (ini_file->SectionExists(asSECTION_NAME_2400M))
  427.     {
  428.         return true;
  429.     }
  430.     return false;
  431. }
  432. //----------------------------------------------------------------------------
  433. bool CWIFIALC::REQ_Read_From_File(char *filename)
  434. {
  435.     TIniFile   *ini_file;
  436.     AnsiString  as_data;
  437.     char        str[2048];
  438.     unsigned char      ucdata[WIFI_ALC_2400M_CH_NUM];
  439.     ini_file = new TIniFile(filename);
  440.     if (NULL == ini_file)
  441.     {
  442.         return false;
  443.     }
  444.     // TX ALC CCK
  445.     as_data = ini_file->ReadString(asSECTION_NAME_2400M,
  446.                                    asKEY_NAME_POWER_2400M[TX_ALC_CCK_IDX],
  447.                                    "0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  448.     strcpy(str, as_data.c_str());
  449.     String_To_Array_UnsignedChar(str, ucdata, WIFI_ALC_2400M_CH_NUM);
  450.     for(int j=0; j<WIFI_ALC_2400M_CH_NUM; j++ )
  451.     {
  452.         m_sAlcPower2400M.txAlcCCK[j] = ucdata[j];
  453.     }
  454.     // TX output power DB CCK
  455.     as_data = ini_file->ReadString(asSECTION_NAME_2400M,
  456.                                    asKEY_NAME_POWER_2400M[TX_OUTPUT_POWER_DB_CCK_IDX],
  457.                                    "0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  458.     strcpy(str, as_data.c_str());
  459.     String_To_Array_UnsignedChar(str, ucdata, WIFI_ALC_2400M_CH_NUM);
  460.     for (int j=0; j<WIFI_ALC_2400M_CH_NUM; j++ )
  461.     {
  462.         m_sAlcPower2400M.txOutputPowerDBCCK[j] = ucdata[j];
  463.     }
  464.     // TX ALC OFDM
  465.     for (int i=0; i<WIFI_ALC_2400M_TX_RATE_NUM; i++)
  466.     {
  467.         AnsiString as = asKEY_NAME_POWER_2400M[TX_ALC_OFDM_IDX] + IntToStr(i);
  468.         as_data = ini_file->ReadString(asSECTION_NAME_2400M,
  469.                                        as,
  470.                                        "0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  471.         strcpy(str, as_data.c_str());
  472.         String_To_Array_UnsignedChar(str, ucdata, WIFI_ALC_2400M_CH_NUM);
  473.         for(int j=0; j<WIFI_ALC_2400M_CH_NUM; j++ )
  474.         {
  475.            m_sAlcPower2400M.txAlcOFDM[i][j] = ucdata[j];
  476.         }
  477.     }
  478.     // TX output power DB OFDM
  479.     for (int i=0; i<WIFI_ALC_2400M_TX_RATE_NUM; i++)
  480.     {
  481.         AnsiString as = asKEY_NAME_POWER_2400M[TX_OUTPUT_POWER_DB_OFDM_IDX] + IntToStr(i);
  482.         as_data = ini_file->ReadString(asSECTION_NAME_2400M,
  483.                                        as,
  484.                                        "0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  485.         strcpy(str, as_data.c_str());
  486.         String_To_Array_UnsignedChar(str, ucdata, WIFI_ALC_2400M_CH_NUM);
  487.         for(int j=0; j<WIFI_ALC_2400M_CH_NUM; j++ )
  488.         {
  489.            m_sAlcPower2400M.txOutputPowerDBOFDM[i][j] = ucdata[j];
  490.         }
  491.     }
  492.     // ALC slope
  493.     m_sAlcSlope2400M.alcSlop1Divider = ini_file->ReadInteger(asSECTION_NAME_2400M,
  494.                                        asKEY_NAME_SLOPE_2400M[ALC_SLOPE1_DIVIDER_IDX],
  495.                                        10);
  496.     m_sAlcSlope2400M.alcSlop1Dividend = ini_file->ReadInteger(asSECTION_NAME_2400M,
  497.                                         asKEY_NAME_SLOPE_2400M[ALC_SLOPE1_DIVIDEND_IDX],
  498.                                         1);
  499.     m_sAlcSlope2400M.alcSlop2Divider = ini_file->ReadInteger(asSECTION_NAME_2400M,
  500.                                        asKEY_NAME_SLOPE_2400M[ALC_SLOPE2_DIVIDER_IDX],
  501.                                        15);
  502.     m_sAlcSlope2400M.alcSlop2Dividend = ini_file->ReadInteger(asSECTION_NAME_2400M,
  503.                                         asKEY_NAME_SLOPE_2400M[ALC_SLOPE2_DIVIDEND_IDX],
  504.                                         10);
  505.     delete  ini_file;
  506.     return true;
  507. }
  508. //-----------------------------------------------------------------------------
  509. bool CWIFIALC::REQ_Write_To_File(char *filename)
  510. {
  511.     TIniFile   *ini_file;
  512.     char        str[2048];
  513.     unsigned char         ucdata[WIFI_ALC_2400M_CH_NUM];
  514.     ini_file = new TIniFile(filename);
  515.     if (NULL == ini_file)
  516.     {
  517.         return  false;
  518.     }
  519.     // TX ALC CCK
  520.     for (int j=0; j<NUM_TX_POWER_2400M_CH; j++)
  521.     {
  522.         ucdata[j] = m_sAlcPower2400M.txAlcCCK[j];
  523.     }
  524.     Array_To_String_UnsignedChar(str, ucdata, WIFI_ALC_2400M_CH_NUM, ',');
  525.     ini_file->WriteString(asSECTION_NAME_2400M,
  526.                           asKEY_NAME_POWER_2400M[TX_ALC_CCK_IDX],
  527.                           str);
  528.     // TX output power DB CCK
  529.     for (int j=0; j<NUM_TX_POWER_2400M_CH; j++)
  530.     {
  531.         ucdata[j] = m_sAlcPower2400M.txOutputPowerDBCCK[j];
  532.     }
  533.     Array_To_String_UnsignedChar(str, ucdata, WIFI_ALC_2400M_CH_NUM, ',');
  534.     ini_file->WriteString(asSECTION_NAME_2400M,
  535.                           asKEY_NAME_POWER_2400M[TX_OUTPUT_POWER_DB_CCK_IDX],
  536.                           str);
  537.     // TX ALC OFDM
  538.     for (int i=0; i<WIFI_ALC_2400M_TX_RATE_NUM; i++)
  539.     {
  540.         for (int j=0; j<NUM_TX_POWER_2400M_CH; j++)
  541.         {
  542.             ucdata[j] = m_sAlcPower2400M.txAlcOFDM[i][j];
  543.         }
  544.         AnsiString as = asKEY_NAME_POWER_2400M[TX_ALC_OFDM_IDX] + IntToStr(i);
  545.         Array_To_String_UnsignedChar(str, ucdata, WIFI_ALC_2400M_CH_NUM, ',');
  546.         ini_file->WriteString(asSECTION_NAME_2400M,
  547.                               as,
  548.                               str);
  549.     }
  550.     // TX output power DB OFDM
  551.     for (int i=0; i<WIFI_ALC_2400M_TX_RATE_NUM; i++)
  552.     {
  553.         for (int j=0; j<NUM_TX_POWER_2400M_CH; j++)
  554.         {
  555.             ucdata[j] = m_sAlcPower2400M.txOutputPowerDBOFDM[i][j];
  556.         }
  557.         AnsiString as = asKEY_NAME_POWER_2400M[TX_OUTPUT_POWER_DB_OFDM_IDX] + IntToStr(i);
  558.         Array_To_String_UnsignedChar(str, ucdata, WIFI_ALC_2400M_CH_NUM, ',');
  559.         ini_file->WriteString(asSECTION_NAME_2400M,
  560.                               as,
  561.                               str);
  562.     }
  563.     // ALC slope
  564.     ini_file->WriteString(asSECTION_NAME_2400M,
  565.                           asKEY_NAME_SLOPE_2400M[ALC_SLOPE1_DIVIDER_IDX],
  566.                           IntToStr(m_sAlcSlope2400M.alcSlop1Divider)
  567.                          );
  568.     ini_file->WriteString(asSECTION_NAME_2400M,
  569.                           asKEY_NAME_SLOPE_2400M[ALC_SLOPE1_DIVIDEND_IDX],
  570.                           IntToStr(m_sAlcSlope2400M.alcSlop1Dividend)
  571.                          );
  572.     ini_file->WriteString(asSECTION_NAME_2400M,
  573.                           asKEY_NAME_SLOPE_2400M[ALC_SLOPE2_DIVIDER_IDX],
  574.                           IntToStr(m_sAlcSlope2400M.alcSlop2Divider)
  575.                          );
  576.     ini_file->WriteString(asSECTION_NAME_2400M,
  577.                           asKEY_NAME_SLOPE_2400M[ALC_SLOPE2_DIVIDEND_IDX],
  578.                           IntToStr(m_sAlcSlope2400M.alcSlop2Dividend)
  579.                          );
  580.     delete  ini_file;
  581.     return  true;
  582. }
  583. //==========================================================================
  584. //////////////////////////////    Query    /////////////////////////////////
  585. //===========================================================================
  586. bool CWIFIALC::REQ_Query_ALC_Suppport_Start(void)
  587. {
  588.     if (META_QueryIfTargetSupportWifiALC_r(m_META_HANDLE_Obj.Get_MainHandle(), 300) != META_SUCCESS)
  589.     {
  590.         return false;
  591.     }
  592.     return true;
  593. }
  594. //===========================================================================
  595. /////////////////////////  Global information  //////////////////////////////
  596. //===========================================================================
  597. E_METAAPP_RESULT_T CWIFIALC::Get_ConfirmState(void)
  598. {
  599.     return m_eConfirmState;
  600. }
  601. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  602. WiFi_ALC_2400M_S* CWIFIALC::Get_AlcPower2400M(void)
  603. {
  604.     return &m_sAlcPower2400M;
  605. }
  606. //---------------------------------------------------------------------------
  607. void CWIFIALC::Set_AlcPower2400M(WiFi_ALC_2400M_S alc)
  608. {
  609.     m_sAlcPower2400M = alc;
  610. }
  611. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  612. unsigned char CWIFIALC::Get_AlcPower2400MAlc(E_WIFI_MOD mod, unsigned int ch_idx, WiFi_TestRate_E rate)
  613. {
  614.     unsigned char alc;
  615.     if (WIFI_MOD_CCK == mod)
  616.     {
  617.         alc = m_sAlcPower2400M.txAlcCCK[ch_idx];
  618.     }
  619.     else
  620.     {
  621.         alc = m_sAlcPower2400M.txAlcOFDM[rate][ch_idx];
  622.     }
  623.     return alc;
  624. }
  625. //---------------------------------------------------------------------------
  626. void CWIFIALC::Set_AlcPower2400MAlc(E_WIFI_MOD mod, unsigned int ch_idx, WiFi_TestRate_E rate, unsigned char alc)
  627. {
  628.     if (WIFI_MOD_CCK == mod)
  629.     {
  630.         m_sAlcPower2400M.txAlcCCK[ch_idx] = alc;
  631.     }
  632.     else
  633.     {
  634.         m_sAlcPower2400M.txAlcOFDM[rate][ch_idx] = alc;
  635.     }
  636. }
  637. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  638. unsigned char CWIFIALC::Get_AlcPower2400MPowerDB(E_WIFI_MOD mod, unsigned int ch_idx, WiFi_TestRate_E rate)
  639. {
  640.     unsigned char db;
  641.     if (WIFI_MOD_CCK == mod)
  642.     {
  643.         db = m_sAlcPower2400M.txOutputPowerDBCCK[ch_idx];
  644.     }
  645.     else
  646.     {
  647.         db = m_sAlcPower2400M.txOutputPowerDBOFDM[rate][ch_idx];
  648.     }
  649.     return db;
  650. }
  651. //---------------------------------------------------------------------------
  652. void CWIFIALC::Set_AlcPower2400MPowerDB(E_WIFI_MOD mod, unsigned int ch_idx, WiFi_TestRate_E rate, unsigned char db)
  653. {
  654.     if (WIFI_MOD_CCK == mod)
  655.     {
  656.         m_sAlcPower2400M.txOutputPowerDBCCK[ch_idx] = db;
  657.     }
  658.     else
  659.     {
  660.         m_sAlcPower2400M.txOutputPowerDBOFDM[rate][ch_idx] = db;
  661.     }
  662. }
  663. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  664. WiFi_TxALC_2400M_S* CWIFIALC::Get_AlcSlope2400M(void)
  665. {
  666.     return &m_sAlcSlope2400M;
  667. }
  668. //---------------------------------------------------------------------------
  669. void CWIFIALC::Set_AlcSlope2400M(WiFi_TxALC_2400M_S alc)
  670. {
  671.     m_sAlcSlope2400M = alc;
  672. }